@nestia/migrate 11.0.0-dev.20260313 → 11.0.0-dev.20260313-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 (128) hide show
  1. package/lib/NestiaMigrateApplication.d.ts +24 -0
  2. package/lib/NestiaMigrateApplication.js +21136 -0
  3. package/lib/NestiaMigrateApplication.js.map +1 -0
  4. package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +5 -0
  5. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +46 -0
  6. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -0
  7. package/lib/archivers/NestiaMigrateFileArchiver.d.ts +8 -0
  8. package/lib/archivers/NestiaMigrateFileArchiver.js +36 -0
  9. package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -0
  10. package/lib/bundles/NEST_TEMPLATE.d.ts +1 -0
  11. package/lib/bundles/NEST_TEMPLATE.js +55 -0
  12. package/lib/bundles/NEST_TEMPLATE.js.map +1 -0
  13. package/lib/bundles/SDK_TEMPLATE.d.ts +1 -0
  14. package/lib/bundles/SDK_TEMPLATE.js +27 -0
  15. package/lib/bundles/SDK_TEMPLATE.js.map +1 -0
  16. package/lib/executable/NestiaMigrateCommander.d.ts +4 -0
  17. package/lib/executable/NestiaMigrateCommander.js +125 -0
  18. package/lib/executable/NestiaMigrateCommander.js.map +1 -0
  19. package/lib/executable/NestiaMigrateInquirer.d.ts +12 -0
  20. package/lib/executable/NestiaMigrateInquirer.js +91 -0
  21. package/lib/executable/NestiaMigrateInquirer.js.map +1 -0
  22. package/lib/executable/migrate.d.ts +2 -0
  23. package/lib/executable/migrate.js +9 -0
  24. package/lib/executable/migrate.js.map +1 -0
  25. package/lib/factories/TypeLiteralFactory.d.ts +4 -0
  26. package/lib/factories/TypeLiteralFactory.js +35 -0
  27. package/lib/factories/TypeLiteralFactory.js.map +1 -0
  28. package/lib/index.d.ts +3 -0
  29. package/lib/index.js +42 -0
  30. package/lib/index.js.map +1 -0
  31. package/lib/index.mjs +21880 -0
  32. package/lib/index.mjs.map +1 -0
  33. package/lib/module.d.ts +5 -0
  34. package/lib/module.js +22 -0
  35. package/lib/module.js.map +1 -0
  36. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +13 -0
  37. package/lib/programmers/NestiaMigrateApiFileProgrammer.js +40 -0
  38. package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -0
  39. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +14 -0
  40. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +180 -0
  41. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -0
  42. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +15 -0
  43. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +223 -0
  44. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -0
  45. package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +4 -0
  46. package/lib/programmers/NestiaMigrateApiProgrammer.js +82 -0
  47. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -0
  48. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +15 -0
  49. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +140 -0
  50. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -0
  51. package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +4 -0
  52. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +79 -0
  53. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -0
  54. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +15 -0
  55. package/lib/programmers/NestiaMigrateDtoProgrammer.js +65 -0
  56. package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -0
  57. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +15 -0
  58. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +80 -0
  59. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -0
  60. package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +4 -0
  61. package/lib/programmers/NestiaMigrateE2eProgrammer.js +32 -0
  62. package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -0
  63. package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +18 -0
  64. package/lib/programmers/NestiaMigrateImportProgrammer.js +65 -0
  65. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -0
  66. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +12 -0
  67. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +46 -0
  68. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -0
  69. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +16 -0
  70. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +221 -0
  71. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -0
  72. package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +5 -0
  73. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +29 -0
  74. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -0
  75. package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +4 -0
  76. package/lib/programmers/NestiaMigrateNestProgrammer.js +65 -0
  77. package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -0
  78. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +10 -0
  79. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +339 -0
  80. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -0
  81. package/lib/programmers/index.d.ts +15 -0
  82. package/lib/programmers/index.js +32 -0
  83. package/lib/programmers/index.js.map +1 -0
  84. package/lib/structures/INestiaMigrateConfig.d.ts +15 -0
  85. package/lib/structures/INestiaMigrateConfig.js +3 -0
  86. package/lib/structures/INestiaMigrateConfig.js.map +1 -0
  87. package/lib/structures/INestiaMigrateContext.d.ts +7 -0
  88. package/lib/structures/INestiaMigrateContext.js +3 -0
  89. package/lib/structures/INestiaMigrateContext.js.map +1 -0
  90. package/lib/structures/INestiaMigrateController.d.ts +7 -0
  91. package/lib/structures/INestiaMigrateController.js +3 -0
  92. package/lib/structures/INestiaMigrateController.js.map +1 -0
  93. package/lib/structures/INestiaMigrateDto.d.ts +7 -0
  94. package/lib/structures/INestiaMigrateDto.js +3 -0
  95. package/lib/structures/INestiaMigrateDto.js.map +1 -0
  96. package/lib/structures/INestiaMigrateFile.d.ts +5 -0
  97. package/lib/structures/INestiaMigrateFile.js +3 -0
  98. package/lib/structures/INestiaMigrateFile.js.map +1 -0
  99. package/lib/structures/INestiaMigrateProgram.d.ts +9 -0
  100. package/lib/structures/INestiaMigrateProgram.js +3 -0
  101. package/lib/structures/INestiaMigrateProgram.js.map +1 -0
  102. package/lib/structures/INestiaMigrateSchema.d.ts +4 -0
  103. package/lib/structures/INestiaMigrateSchema.js +3 -0
  104. package/lib/structures/INestiaMigrateSchema.js.map +1 -0
  105. package/lib/structures/index.d.ts +4 -0
  106. package/lib/structures/index.js +21 -0
  107. package/lib/structures/index.js.map +1 -0
  108. package/lib/utils/FilePrinter.d.ts +9 -0
  109. package/lib/utils/FilePrinter.js +35 -0
  110. package/lib/utils/FilePrinter.js.map +1 -0
  111. package/lib/utils/MapUtil.d.ts +3 -0
  112. package/lib/utils/MapUtil.js +15 -0
  113. package/lib/utils/MapUtil.js.map +1 -0
  114. package/lib/utils/SetupWizard.d.ts +3 -0
  115. package/lib/utils/SetupWizard.js +18 -0
  116. package/lib/utils/SetupWizard.js.map +1 -0
  117. package/lib/utils/StringUtil.d.ts +6 -0
  118. package/lib/utils/StringUtil.js +108 -0
  119. package/lib/utils/StringUtil.js.map +1 -0
  120. package/lib/utils/openapi-down-convert/RefVisitor.d.ts +52 -0
  121. package/lib/utils/openapi-down-convert/RefVisitor.js +102 -0
  122. package/lib/utils/openapi-down-convert/RefVisitor.js.map +1 -0
  123. package/lib/utils/openapi-down-convert/converter.d.ts +146 -0
  124. package/lib/utils/openapi-down-convert/converter.js +441 -0
  125. package/lib/utils/openapi-down-convert/converter.js.map +1 -0
  126. package/package.json +1 -2
  127. package/src/bundles/NEST_TEMPLATE.ts +1 -1
  128. package/src/bundles/SDK_TEMPLATE.ts +1 -1
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapUtil = void 0;
4
+ var MapUtil;
5
+ (function (MapUtil) {
6
+ MapUtil.take = (dict) => (key) => (generator) => {
7
+ const oldbie = dict.get(key);
8
+ if (oldbie)
9
+ return oldbie;
10
+ const value = generator();
11
+ dict.set(key, value);
12
+ return value;
13
+ };
14
+ })(MapUtil || (exports.MapUtil = MapUtil = {}));
15
+ //# sourceMappingURL=MapUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapUtil.js","sourceRoot":"","sources":["../../src/utils/MapUtil.ts"],"names":[],"mappings":";;;AAAA,IAAiB,OAAO,CAYvB;AAZD,WAAiB,OAAO;IACT,YAAI,GACf,CAAS,IAAiB,EAAE,EAAE,CAC9B,CAAC,GAAQ,EAAE,EAAE,CACb,CAAC,SAAkB,EAAK,EAAE;QACxB,MAAM,MAAM,GAAkB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,MAAM,KAAK,GAAM,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACN,CAAC,EAZgB,OAAO,uBAAP,OAAO,QAYvB"}
@@ -0,0 +1,3 @@
1
+ export declare namespace SetupWizard {
2
+ const setup: (output: string) => void;
3
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SetupWizard = void 0;
7
+ const child_process_1 = __importDefault(require("child_process"));
8
+ var SetupWizard;
9
+ (function (SetupWizard) {
10
+ SetupWizard.setup = (output) => {
11
+ execute(output)("npm install");
12
+ };
13
+ const execute = (cwd) => (command, fake) => {
14
+ console.log(fake !== null && fake !== void 0 ? fake : command);
15
+ child_process_1.default.execSync(command, { cwd, stdio: "inherit" });
16
+ };
17
+ })(SetupWizard || (exports.SetupWizard = SetupWizard = {}));
18
+ //# sourceMappingURL=SetupWizard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SetupWizard.js","sourceRoot":"","sources":["../../src/utils/SetupWizard.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA+B;AAE/B,IAAiB,WAAW,CAS3B;AATD,WAAiB,WAAW;IACb,iBAAK,GAAG,CAAC,MAAc,EAAE,EAAE;QACtC,OAAO,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,OAAe,EAAE,IAAa,EAAE,EAAE;QAClE,OAAO,CAAC,GAAG,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,OAAO,CAAC,CAAC;QAC7B,uBAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC,EATgB,WAAW,2BAAX,WAAW,QAS3B"}
@@ -0,0 +1,6 @@
1
+ export declare namespace StringUtil {
2
+ const capitalize: (str: string) => string;
3
+ const splitWithNormalization: (path: string) => string[];
4
+ const escapeDuplicate: (keep: string[]) => (change: string) => string;
5
+ const escapeNonVariable: (str: string) => string;
6
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringUtil = void 0;
4
+ var StringUtil;
5
+ (function (StringUtil) {
6
+ StringUtil.capitalize = (str) => str[0].toUpperCase() + str.slice(1).toLowerCase();
7
+ StringUtil.splitWithNormalization = (path) => path
8
+ .split("/")
9
+ .map((str) => normalize(str.trim()))
10
+ .filter((str) => !!str.length);
11
+ StringUtil.escapeDuplicate = (keep) => (change) => keep.includes(change) ? StringUtil.escapeDuplicate(keep)(`_${change}`) : change;
12
+ StringUtil.escapeNonVariable = (str) => {
13
+ str = escape(str);
14
+ for (const [before, after] of VARIABLE_REPLACERS)
15
+ str = str.split(before).join(after);
16
+ for (let i = 0; i <= 9; ++i)
17
+ if (str[0] === i.toString()) {
18
+ str = "_" + str;
19
+ break;
20
+ }
21
+ if (str === "")
22
+ return "_empty_";
23
+ return str;
24
+ };
25
+ })(StringUtil || (exports.StringUtil = StringUtil = {}));
26
+ const escape = (str) => {
27
+ str = str.trim();
28
+ if (RESERVED.has(str))
29
+ return `_${str}`;
30
+ else if (str.length !== 0 && "0" <= str[0] && str[0] <= "9")
31
+ str = `_${str}`;
32
+ return str;
33
+ };
34
+ const normalize = (str) => escape(str.split(".").join("_").split("-").join("_"));
35
+ const RESERVED = new Set([
36
+ "break",
37
+ "case",
38
+ "catch",
39
+ "class",
40
+ "const",
41
+ "continue",
42
+ "debugger",
43
+ "default",
44
+ "delete",
45
+ "do",
46
+ "else",
47
+ "enum",
48
+ "export",
49
+ "extends",
50
+ "false",
51
+ "finally",
52
+ "for",
53
+ "function",
54
+ "if",
55
+ "import",
56
+ "in",
57
+ "instanceof",
58
+ "module",
59
+ "new",
60
+ "null",
61
+ "package",
62
+ "public",
63
+ "private",
64
+ "protected",
65
+ "return",
66
+ "super",
67
+ "switch",
68
+ "this",
69
+ "throw",
70
+ "true",
71
+ "try",
72
+ "typeof",
73
+ "var",
74
+ "void",
75
+ "while",
76
+ "with",
77
+ ]);
78
+ const VARIABLE_REPLACERS = [
79
+ ["`", "_backquote_"],
80
+ ["!", "_exclamation_"],
81
+ ["@", "_at_"],
82
+ ["#", "_hash_"],
83
+ ["$", "_dollar_"],
84
+ ["%", "_percent_"],
85
+ ["^", "_caret_"],
86
+ ["&", "_and_"],
87
+ ["*", "_star_"],
88
+ ["(", "_lparen_"],
89
+ [")", "_rparen_"],
90
+ ["-", "_"],
91
+ ["+", "_plus_"],
92
+ ["|", "_or_"],
93
+ ["{", "_blt_"],
94
+ ["}", "_bgt_"],
95
+ ["<", "_lt_"],
96
+ [">", "_gt_"],
97
+ ["[", "_alt_"],
98
+ ["]", "_agt_"],
99
+ [",", "_comma_"],
100
+ ["'", "_singlequote_"],
101
+ ['"', "_doublequote_"],
102
+ [" ", "_space_"],
103
+ ["?", "_question_"],
104
+ [":", "_colon_"],
105
+ [";", "_semicolon_"],
106
+ ["...", "_rest_"],
107
+ ];
108
+ //# sourceMappingURL=StringUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StringUtil.js","sourceRoot":"","sources":["../../src/utils/StringUtil.ts"],"names":[],"mappings":";;;AAAA,IAAiB,UAAU,CA2B1B;AA3BD,WAAiB,UAAU;IACZ,qBAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CACxC,GAAG,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAExC,iCAAsB,GAAG,CAAC,IAAY,EAAE,EAAE,CACrD,IAAI;SACD,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;SACnC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEtB,0BAAe,GAC1B,CAAC,IAAc,EAAE,EAAE,CACnB,CAAC,MAAc,EAAU,EAAE,CACzB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CA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b,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,YAAY,CAAC;IACnB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,aAAa,CAAC;IACpB,CAAC,KAAK,EAAE,QAAQ,CAAC;CAClB,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Recursively walk a JSON object and invoke a callback function on each `{
3
+ * "$ref" : "path" }` object found
4
+ */
5
+ /**
6
+ * Represents a JSON Reference object, such as `{"$ref":
7
+ * "#/components/schemas/problemResponse" }`
8
+ */
9
+ export interface RefObject {
10
+ $ref: string;
11
+ }
12
+ /** JsonNode represents a node within the OpenAPI object */
13
+ export type JsonNode = object | [] | string | boolean | null | number;
14
+ /** A JSON Schema object in an API def */
15
+ export type SchemaObject = object;
16
+ /** Function signature for the visitRefObjects callback */
17
+ export type RefVisitor = (node: RefObject) => JsonNode;
18
+ /** Function signature for the visitSchemaObjects callback */
19
+ export type SchemaVisitor = (node: SchemaObject) => SchemaObject;
20
+ /** /** Function signature for the walkObject callback */
21
+ export type ObjectVisitor = (node: object) => JsonNode;
22
+ /** Test if a JSON node is a `{ $ref: "uri" }` object */
23
+ export declare function isRef(node: any): boolean;
24
+ /**
25
+ * Walk a JSON object and apply `schemaCallback` when a JSON schema is found.
26
+ * JSON Schema objects are items in components/schemas or in an item named
27
+ * `schema`
28
+ *
29
+ * @param node A node in the OpenAPI document
30
+ * @param schemaCallback The function to call on JSON schema objects
31
+ * @returns The modified (annotated) node
32
+ */
33
+ export declare function visitSchemaObjects(node: any, schemaCallback: SchemaVisitor): any;
34
+ /**
35
+ * Walk a JSON object and apply `refCallback` when a JSON `{$ref: url }` is
36
+ * found
37
+ *
38
+ * @param node A node in the OpenAPI document
39
+ * @param refCallback The function to call on JSON `$ref` objects
40
+ * @returns The modified (annotated) node
41
+ */
42
+ export declare function visitRefObjects(node: any, refCallback: RefVisitor): any;
43
+ /**
44
+ * Walk a JSON object or array and apply objectCallback when a JSON object is
45
+ * found
46
+ *
47
+ * @param node A node in the OpenAPI document
48
+ * @param objectCallback The function to call on JSON objects
49
+ * @param nav Tracks where we are in the original document
50
+ * @returns The modified (annotated) node
51
+ */
52
+ export declare function walkObject(node: object, objectCallback: ObjectVisitor): JsonNode;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRef = isRef;
4
+ exports.visitSchemaObjects = visitSchemaObjects;
5
+ exports.visitRefObjects = visitRefObjects;
6
+ exports.walkObject = walkObject;
7
+ /** Test if a JSON node is a `{ $ref: "uri" }` object */
8
+ function isRef(node) {
9
+ return (node !== null &&
10
+ typeof node === "object" &&
11
+ node.hasOwnProperty("$ref") &&
12
+ typeof node["$ref"] === "string");
13
+ }
14
+ /**
15
+ * Walk a JSON object and apply `schemaCallback` when a JSON schema is found.
16
+ * JSON Schema objects are items in components/schemas or in an item named
17
+ * `schema`
18
+ *
19
+ * @param node A node in the OpenAPI document
20
+ * @param schemaCallback The function to call on JSON schema objects
21
+ * @returns The modified (annotated) node
22
+ */
23
+ function visitSchemaObjects(node, schemaCallback) {
24
+ const objectVisitor = (node) => {
25
+ if (node.hasOwnProperty("schema")) {
26
+ const schema = node["schema"];
27
+ if (schema != null && typeof schema === "object") {
28
+ node["schema"] = schemaCallback(schema);
29
+ }
30
+ }
31
+ else if (node.hasOwnProperty("schemas")) {
32
+ const schemas = node["schemas"];
33
+ if (schemas != null && typeof schemas === "object") {
34
+ for (const schemaName in schemas) {
35
+ const schema = schemas[schemaName];
36
+ const newSchema = schemaCallback(schema);
37
+ schemas[schemaName] = newSchema;
38
+ }
39
+ }
40
+ }
41
+ return node;
42
+ };
43
+ return walkObject(node, objectVisitor);
44
+ }
45
+ /**
46
+ * Walk a JSON object and apply `refCallback` when a JSON `{$ref: url }` is
47
+ * found
48
+ *
49
+ * @param node A node in the OpenAPI document
50
+ * @param refCallback The function to call on JSON `$ref` objects
51
+ * @returns The modified (annotated) node
52
+ */
53
+ function visitRefObjects(node, refCallback) {
54
+ const objectVisitor = (node) => {
55
+ if (isRef(node)) {
56
+ return refCallback(node);
57
+ }
58
+ return node;
59
+ };
60
+ return walkObject(node, objectVisitor);
61
+ }
62
+ /**
63
+ * Walk a JSON object or array and apply objectCallback when a JSON object is
64
+ * found
65
+ *
66
+ * @param node A node in the OpenAPI document
67
+ * @param objectCallback The function to call on JSON objects
68
+ * @param nav Tracks where we are in the original document
69
+ * @returns The modified (annotated) node
70
+ */
71
+ function walkObject(node, objectCallback) {
72
+ return walkObj(node);
73
+ function walkObj(node) {
74
+ const object = objectCallback(node);
75
+ if (object !== null && typeof object === "object") {
76
+ const keys = [...Object.keys(node)]; // make copy since this code may re-enter objects
77
+ for (const key of keys) {
78
+ const val = node[key];
79
+ if (Array.isArray(val)) {
80
+ node[key] = walkArray(val);
81
+ }
82
+ else if (val !== null && typeof val === "object") {
83
+ node[key] = walkObj(val);
84
+ }
85
+ }
86
+ }
87
+ return object;
88
+ }
89
+ function walkArray(array) {
90
+ for (let index = 0; index < array.length; index += 1) {
91
+ const val = array[index];
92
+ if (val !== null && typeof val === "object") {
93
+ array[index] = walkObj(val);
94
+ }
95
+ else if (Array.isArray(val)) {
96
+ array[index] = walkArray(val);
97
+ }
98
+ }
99
+ return array;
100
+ }
101
+ }
102
+ //# sourceMappingURL=RefVisitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RefVisitor.js","sourceRoot":"","sources":["../../../src/utils/openapi-down-convert/RefVisitor.ts"],"names":[],"mappings":";;AA8BA,sBAOC;AAWD,gDAuBC;AAUD,0CAQC;AAWD,gCAiCC;AAxG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AAK,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"}
@@ -0,0 +1,146 @@
1
+ /** Options for the converter instantiation */
2
+ export interface ConverterOptions {
3
+ /** If `true`, log conversion transformations to stderr */
4
+ verbose?: boolean;
5
+ /**
6
+ * If `true`, remove `id` values in schema examples, to bypass [Spectral issue
7
+ * 2081](https://github.com/stoplightio/spectral/issues/2081)
8
+ */
9
+ deleteExampleWithId?: boolean;
10
+ /** If `true`, replace a `$ref` object that has siblings into an `allOf` */
11
+ allOfTransform?: boolean;
12
+ /** The authorizationUrl for openIdConnect -> oauth2 transformation */
13
+ authorizationUrl?: string;
14
+ /** The tokenUrl for openIdConnect -> oauth2 transformation */
15
+ tokenUrl?: string;
16
+ /**
17
+ * Name of YAML/JSON file with scope descriptions. This is a simple map in the
18
+ * format `{ scope1: "description of scope1", ... }`
19
+ */
20
+ scopeDescriptionFile?: string;
21
+ /**
22
+ * Earlier versions of the tool converted $comment to x-comment in JSON
23
+ * Schemas. The tool now deletes $comment values by default. Use this option
24
+ * to preserve the conversion and not delete comments.
25
+ */
26
+ convertSchemaComments?: boolean;
27
+ }
28
+ export declare class Converter {
29
+ private openapi30;
30
+ private verbose;
31
+ private deleteExampleWithId;
32
+ private allOfTransform;
33
+ private authorizationUrl;
34
+ /** The tokenUrl for openIdConnect -> oauth2 transformation */
35
+ private tokenUrl;
36
+ private scopeDescriptions;
37
+ private convertSchemaComments;
38
+ private returnCode;
39
+ /**
40
+ * Construct a new Converter
41
+ *
42
+ * @throws Error if the scopeDescriptionFile (if specified) cannot be read or
43
+ * parsed as YAML/JSON
44
+ */
45
+ constructor(openapiDocument: object, options?: ConverterOptions);
46
+ /**
47
+ * Load the scopes.yaml file and save in this.scopeDescriptions
48
+ *
49
+ * @throws Error if the file cannot be read or parsed as YAML/JSON
50
+ */
51
+ private loadScopeDescriptions;
52
+ /**
53
+ * Log a message to console.warn stream if verbose is true
54
+ *
55
+ * @param message Parameters for console.warn
56
+ */
57
+ private log;
58
+ /**
59
+ * Log a message to console.warn stream. Prefix the message string with
60
+ * `Warning: ` if it does not already have that text.
61
+ *
62
+ * @param message Parameters for console.warn
63
+ */
64
+ private warn;
65
+ /**
66
+ * Log an error message to `console.error` stream. Prefix the message string
67
+ * with `Error: ` if it does not already start with `'Error'`. Increments the
68
+ * `returnCode`, causing the CLI to throw an Error when done.
69
+ *
70
+ * @param message Parameters for `console.error`
71
+ */
72
+ private error;
73
+ /**
74
+ * Convert the OpenAPI document to 3.0
75
+ *
76
+ * @returns The converted document. The input is not modified.
77
+ */
78
+ convert(): object;
79
+ /**
80
+ * OpenAPI 3.1 uses JSON Schema 2020-12 which allows schema `examples`;
81
+ * OpenAPI 3.0 uses JSON Scheme Draft 7 which only allows `example`. Replace
82
+ * all `examples` with `example`, using `examples[0]`
83
+ */
84
+ convertJsonSchemaExamples(): void;
85
+ private walkNestedSchemaObjects;
86
+ /**
87
+ * OpenAPI 3.1 uses JSON Schema 2020-12 which allows `const` OpenAPI 3.0 uses
88
+ * JSON Scheme Draft 7 which only allows `enum`. Replace all `const: value`
89
+ * with `enum: [ value ]`
90
+ */
91
+ convertConstToEnum(): void;
92
+ /**
93
+ * Convert 2-element type arrays containing 'null' to string type and
94
+ * `nullable: true`
95
+ */
96
+ convertNullableTypeArray(): void;
97
+ removeWebhooksObject(): void;
98
+ removeUnsupportedSchemaKeywords(): void;
99
+ renameSchema$comment(): void;
100
+ private deleteSchema$comment;
101
+ /**
102
+ * Convert
103
+ *
104
+ * contentMediaType: "application/octet-stream";
105
+ *
106
+ * To
107
+ *
108
+ * format: binary;
109
+ *
110
+ * In `type: string` schemas. Warn if schema has a `format` already and it is
111
+ * not `binary`.
112
+ */
113
+ convertJsonSchemaContentMediaType(): void;
114
+ /**
115
+ * Convert
116
+ *
117
+ * contentEncoding: base64;
118
+ *
119
+ * To
120
+ *
121
+ * format: byte;
122
+ *
123
+ * In `type: string` schemas. It is an error if the schema has a `format`
124
+ * already and it is not `byte`.
125
+ */
126
+ convertJsonSchemaContentEncoding(): void;
127
+ private json;
128
+ /**
129
+ * OpenAPI 3.1 defines a new `openIdConnect` security scheme. Down-convert the
130
+ * scheme to `oauth2` / authorization code flow. Collect all the scopes used
131
+ * in any security requirements within operations and add them to the scheme.
132
+ * Also define the URLs to the `authorizationUrl` and `tokenUrl` of `oauth2`.
133
+ */
134
+ convertSecuritySchemes(): void;
135
+ /**
136
+ * Find remaining OpenAPI 3.0 [Reference
137
+ * Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)
138
+ * and down convert them to [JSON
139
+ * Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03)
140
+ * objects with _only_ a `$ref` property.
141
+ */
142
+ simplifyNonSchemaRef(): void;
143
+ removeLicenseIdentifier(): void;
144
+ convertSchemaRef(): void;
145
+ static deepClone(obj: object): object;
146
+ }