@nestia/migrate 0.10.0 → 0.11.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.
Files changed (33) hide show
  1. package/lib/MigrateApplication.d.ts +3 -1
  2. package/lib/MigrateApplication.js +1558 -1601
  3. package/lib/MigrateApplication.js.map +1 -1
  4. package/lib/bundles/NEST_TEMPLATE.js +1 -1
  5. package/lib/internal/MigrateCommander.js +1 -1
  6. package/lib/internal/MigrateCommander.js.map +1 -1
  7. package/lib/structures/ISwaggerV20.d.ts +8 -0
  8. package/lib/structures/ISwaggerV20.js +3 -0
  9. package/lib/structures/ISwaggerV20.js.map +1 -0
  10. package/lib/structures/ISwaggerV31.d.ts +9 -0
  11. package/lib/structures/ISwaggerV31.js +3 -0
  12. package/lib/structures/ISwaggerV31.js.map +1 -0
  13. package/lib/utils/OpenApiConverter.d.ts +7 -0
  14. package/lib/utils/OpenApiConverter.js +3132 -0
  15. package/lib/utils/OpenApiConverter.js.map +1 -0
  16. package/lib/utils/openapi-down-convert/RefVisitor.d.ts +57 -0
  17. package/lib/utils/openapi-down-convert/RefVisitor.js +100 -0
  18. package/lib/utils/openapi-down-convert/RefVisitor.js.map +1 -0
  19. package/lib/utils/openapi-down-convert/converter.d.ts +138 -0
  20. package/lib/utils/openapi-down-convert/converter.js +431 -0
  21. package/lib/utils/openapi-down-convert/converter.js.map +1 -0
  22. package/package.json +11 -7
  23. package/src/MigrateApplication.ts +17 -8
  24. package/src/internal/MigrateCommander.ts +1 -1
  25. package/src/structures/ISwagger.ts +23 -23
  26. package/src/structures/ISwaggerV20.ts +10 -0
  27. package/src/structures/ISwaggerV31.ts +10 -0
  28. package/src/utils/OpenApiConverter.ts +19 -0
  29. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -0
  30. package/src/utils/openapi-down-convert/converter.ts +527 -0
  31. package/lib/utils/SwaggerExplorer.d.ts +0 -0
  32. package/lib/utils/SwaggerExplorer.js +0 -2
  33. package/lib/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAW,SAAS,CAAC,OAAO,EAAc,EAAE;IACjE,CAAC,CAAC;AACJ,CAAC,EAVgB,gBAAgB,gCAAhB,gBAAgB,QAUhC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Recursively walk a JSON object and invoke a callback function
3
+ * on each `{ "$ref" : "path" }` object found
4
+ */
5
+ /**
6
+ * Represents a JSON Reference object, such as
7
+ * `{"$ref": "#/components/schemas/problemResponse" }`
8
+ */
9
+ export interface RefObject {
10
+ $ref: string;
11
+ }
12
+ /**
13
+ * JsonNode represents a node within the OpenAPI object
14
+ */
15
+ export type JsonNode = object | [] | string | boolean | null | number;
16
+ /** A JSON Schema object in an API def */
17
+ export type SchemaObject = object;
18
+ /**
19
+ * Function signature for the visitRefObjects callback
20
+ */
21
+ export type RefVisitor = (node: RefObject) => JsonNode;
22
+ /**
23
+ * Function signature for the visitSchemaObjects callback
24
+ */
25
+ export type SchemaVisitor = (node: SchemaObject) => SchemaObject;
26
+ /**
27
+ /**
28
+ * Function signature for the walkObject callback
29
+ */
30
+ export type ObjectVisitor = (node: object) => JsonNode;
31
+ /**
32
+ * Test if a JSON node is a `{ $ref: "uri" }` object
33
+ */
34
+ export declare function isRef(node: any): boolean;
35
+ /**
36
+ * Walk a JSON object and apply `schemaCallback` when a JSON schema is found.
37
+ * JSON Schema objects are items in components/schemas or in an item named `schema`
38
+ * @param node a node in the OpenAPI document
39
+ * @param schemaCallback the function to call on JSON schema objects
40
+ * @return the modified (annotated) node
41
+ */
42
+ export declare function visitSchemaObjects(node: any, schemaCallback: SchemaVisitor): any;
43
+ /**
44
+ * Walk a JSON object and apply `refCallback` when a JSON `{$ref: url }` is found
45
+ * @param node a node in the OpenAPI document
46
+ * @param refCallback the function to call on JSON `$ref` objects
47
+ * @return the modified (annotated) node
48
+ */
49
+ export declare function visitRefObjects(node: any, refCallback: RefVisitor): any;
50
+ /**
51
+ * Walk a JSON object or array and apply objectCallback when a JSON object is found
52
+ * @param node a node in the OpenAPI document
53
+ * @param objectCallback the function to call on JSON objects
54
+ * @param nav tracks where we are in the original document
55
+ * @return the modified (annotated) node
56
+ */
57
+ export declare function walkObject(node: object, objectCallback: ObjectVisitor): JsonNode;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.walkObject = exports.visitRefObjects = exports.visitSchemaObjects = exports.isRef = void 0;
5
+ /**
6
+ * Test if a JSON node is a `{ $ref: "uri" }` object
7
+ */
8
+ function isRef(node) {
9
+ return (node !== null &&
10
+ typeof node === "object" &&
11
+ node.hasOwnProperty("$ref") &&
12
+ typeof node["$ref"] === "string");
13
+ }
14
+ exports.isRef = isRef;
15
+ /**
16
+ * Walk a JSON object and apply `schemaCallback` when a JSON schema is found.
17
+ * JSON Schema objects are items in components/schemas or in an item named `schema`
18
+ * @param node a node in the OpenAPI document
19
+ * @param schemaCallback the function to call on JSON schema objects
20
+ * @return the modified (annotated) node
21
+ */
22
+ function visitSchemaObjects(node, schemaCallback) {
23
+ const objectVisitor = (node) => {
24
+ if (node.hasOwnProperty("schema")) {
25
+ const schema = node["schema"];
26
+ if (schema != null && typeof schema === "object") {
27
+ node["schema"] = schemaCallback(schema);
28
+ }
29
+ }
30
+ else if (node.hasOwnProperty("schemas")) {
31
+ const schemas = node["schemas"];
32
+ if (schemas != null && typeof schemas === "object") {
33
+ for (const schemaName in schemas) {
34
+ const schema = schemas[schemaName];
35
+ const newSchema = schemaCallback(schema);
36
+ schemas[schemaName] = newSchema;
37
+ }
38
+ }
39
+ }
40
+ return node;
41
+ };
42
+ return walkObject(node, objectVisitor);
43
+ }
44
+ exports.visitSchemaObjects = visitSchemaObjects;
45
+ /**
46
+ * Walk a JSON object and apply `refCallback` when a JSON `{$ref: url }` is found
47
+ * @param node a node in the OpenAPI document
48
+ * @param refCallback the function to call on JSON `$ref` objects
49
+ * @return the modified (annotated) node
50
+ */
51
+ function visitRefObjects(node, refCallback) {
52
+ const objectVisitor = (node) => {
53
+ if (isRef(node)) {
54
+ return refCallback(node);
55
+ }
56
+ return node;
57
+ };
58
+ return walkObject(node, objectVisitor);
59
+ }
60
+ exports.visitRefObjects = visitRefObjects;
61
+ /**
62
+ * Walk a JSON object or array and apply objectCallback when a JSON object is found
63
+ * @param node a node in the OpenAPI document
64
+ * @param objectCallback the function to call on JSON objects
65
+ * @param nav tracks where we are in the original document
66
+ * @return the modified (annotated) node
67
+ */
68
+ function walkObject(node, objectCallback) {
69
+ return walkObj(node);
70
+ function walkObj(node) {
71
+ const object = objectCallback(node);
72
+ if (object !== null && typeof object === "object") {
73
+ const keys = [...Object.keys(node)]; // make copy since this code may re-enter objects
74
+ for (const key of keys) {
75
+ const val = node[key];
76
+ if (Array.isArray(val)) {
77
+ node[key] = walkArray(val);
78
+ }
79
+ else if (val !== null && typeof val === "object") {
80
+ node[key] = walkObj(val);
81
+ }
82
+ }
83
+ }
84
+ return object;
85
+ }
86
+ function walkArray(array) {
87
+ for (let index = 0; index < array.length; index += 1) {
88
+ const val = array[index];
89
+ if (val !== null && typeof val === "object") {
90
+ array[index] = walkObj(val);
91
+ }
92
+ else if (Array.isArray(val)) {
93
+ array[index] = walkArray(val);
94
+ }
95
+ }
96
+ return array;
97
+ }
98
+ }
99
+ exports.walkObject = walkObject;
100
+ //# sourceMappingURL=RefVisitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RefVisitor.js","sourceRoot":"","sources":["../../../src/utils/openapi-down-convert/RefVisitor.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;AAsCvD;;GAEG;AACH,SAAgB,KAAK,CAAC,IAAS;IAC7B,OAAO,CACL,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,QAAQ,CACjC,CAAC;AACJ,CAAC;AAPD,sBAOC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAChC,IAAS,EACT,cAA6B;IAE7B,MAAM,aAAa,GAAG,CAAC,IAAS,EAAY,EAAE;QAC5C,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACjD,IAAI,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;YAChC,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ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oBACvB,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAS,CAAC,CAAC;gBACnC,CAAC;qBAAM,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;oBACnD,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC3B,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,SAAS,SAAS,CAAC,KAAiB;QAClC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YACrD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAa,CAAC;YACrC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC5C,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAW,CAAC;YACxC,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,KAAK,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,GAAiB,CAAO,CAAC;YACpD,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAjCD,gCAiCC"}
@@ -0,0 +1,138 @@
1
+ /** Options for the converter instantiation */
2
+ export interface ConverterOptions {
3
+ /** if `true`, log conversion transformations to stderr */
4
+ verbose?: boolean;
5
+ /** if `true`, remove `id` values in schema examples, to bypass
6
+ * [Spectral issue 2081](https://github.com/stoplightio/spectral/issues/2081)
7
+ */
8
+ deleteExampleWithId?: boolean;
9
+ /** If `true`, replace a `$ref` object that has siblings into an `allOf` */
10
+ allOfTransform?: boolean;
11
+ /**
12
+ * The authorizationUrl for openIdConnect -> oauth2 transformation
13
+ */
14
+ authorizationUrl?: string;
15
+ /** The tokenUrl for openIdConnect -> oauth2 transformation */
16
+ tokenUrl?: string;
17
+ /** Name of YAML/JSON file with scope descriptions.
18
+ * This is a simple map in the format
19
+ * `{ scope1: "description of scope1", ... }`
20
+ */
21
+ scopeDescriptionFile?: string;
22
+ /** Earlier versions of the tool converted $comment to x-comment
23
+ * in JSON Schemas. The tool now deletes $comment values by default.
24
+ * Use this option to preserve the conversion and not delete
25
+ * comments.
26
+ */
27
+ convertSchemaComments?: boolean;
28
+ }
29
+ export declare class Converter {
30
+ private openapi30;
31
+ private verbose;
32
+ private deleteExampleWithId;
33
+ private allOfTransform;
34
+ private authorizationUrl;
35
+ /** The tokenUrl for openIdConnect -> oauth2 transformation */
36
+ private tokenUrl;
37
+ private scopeDescriptions;
38
+ private convertSchemaComments;
39
+ private returnCode;
40
+ /**
41
+ * Construct a new Converter
42
+ * @throws Error if the scopeDescriptionFile (if specified) cannot be read or parsed as YAML/JSON
43
+ */
44
+ constructor(openapiDocument: object, options?: ConverterOptions);
45
+ /** Load the scopes.yaml file and save in this.scopeDescriptions
46
+ * @throws Error if the file cannot be read or parsed as YAML/JSON
47
+ */
48
+ private loadScopeDescriptions;
49
+ /**
50
+ * Log a message to console.warn stream if verbose is true
51
+ * @param message parameters for console.warn
52
+ */
53
+ private log;
54
+ /**
55
+ * Log a message to console.warn stream. Prefix the message string with `Warning: `
56
+ * if it does not already have that text.
57
+ * @param message parameters for console.warn
58
+ */
59
+ private warn;
60
+ /**
61
+ * Log an error message to `console.error` stream. Prefix the message string with `Error: `
62
+ * if it does not already start with `'Error'`. Increments the `returnCode`, causing
63
+ * the CLI to throw an Error when done.
64
+ * @param message parameters for `console.error`
65
+ */
66
+ private error;
67
+ /**
68
+ * Convert the OpenAPI document to 3.0
69
+ * @returns the converted document. The input is not modified.
70
+ */
71
+ convert(): object;
72
+ /**
73
+ * OpenAPI 3.1 uses JSON Schema 2020-12 which allows schema `examples`;
74
+ * OpenAPI 3.0 uses JSON Scheme Draft 7 which only allows `example`.
75
+ * Replace all `examples` with `example`, using `examples[0]`
76
+ */
77
+ convertJsonSchemaExamples(): void;
78
+ private walkNestedSchemaObjects;
79
+ /**
80
+ * OpenAPI 3.1 uses JSON Schema 2020-12 which allows `const`
81
+ * OpenAPI 3.0 uses JSON Scheme Draft 7 which only allows `enum`.
82
+ * Replace all `const: value` with `enum: [ value ]`
83
+ */
84
+ convertConstToEnum(): void;
85
+ /**
86
+ * Convert 2-element type arrays containing 'null' to
87
+ * string type and `nullable: true`
88
+ */
89
+ convertNullableTypeArray(): void;
90
+ removeWebhooksObject(): void;
91
+ removeUnsupportedSchemaKeywords(): void;
92
+ renameSchema$comment(): void;
93
+ private deleteSchema$comment;
94
+ /**
95
+ * Convert
96
+ * ```
97
+ * contentMediaType: 'application/octet-stream'
98
+ * ```
99
+ * to
100
+ * ```
101
+ * format: binary
102
+ * ```
103
+ * in `type: string` schemas.
104
+ * Warn if schema has a `format` already and it is not `binary`.
105
+ */
106
+ convertJsonSchemaContentMediaType(): void;
107
+ /**
108
+ * Convert
109
+ * ```
110
+ * contentEncoding: base64
111
+ * ```
112
+ * to
113
+ * ```
114
+ * format: byte
115
+ * ```
116
+ * in `type: string` schemas. It is an error if the schema has a `format` already
117
+ * and it is not `byte`.
118
+ */
119
+ convertJsonSchemaContentEncoding(): void;
120
+ private json;
121
+ /**
122
+ * OpenAPI 3.1 defines a new `openIdConnect` security scheme.
123
+ * Down-convert the scheme to `oauth2` / authorization code flow.
124
+ * Collect all the scopes used in any security requirements within
125
+ * operations and add them to the scheme. Also define the
126
+ * URLs to the `authorizationUrl` and `tokenUrl` of `oauth2`.
127
+ */
128
+ convertSecuritySchemes(): void;
129
+ /**
130
+ * Find remaining OpenAPI 3.0 [Reference Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)
131
+ * and down convert them to [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) objects
132
+ * with _only_ a `$ref` property.
133
+ */
134
+ simplifyNonSchemaRef(): void;
135
+ removeLicenseIdentifier(): void;
136
+ convertSchemaRef(): void;
137
+ static deepClone(obj: object): object;
138
+ }