@keq-request/cli 5.0.0-alpha.27 → 5.0.0-alpha.29

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 (109) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cli.cjs +1060 -1112
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +1180 -1232
  5. package/dist/cli.js.map +1 -1
  6. package/dist/compiler/compiler.d.ts.map +1 -1
  7. package/dist/compiler/tasks/setup/index.d.ts.map +1 -1
  8. package/dist/compiler/tasks/setup/utils/index.d.ts +0 -1
  9. package/dist/compiler/tasks/setup/utils/index.d.ts.map +1 -1
  10. package/dist/compiler/tasks/setup/utils/parse-runtime-config.d.ts +3 -0
  11. package/dist/compiler/tasks/setup/utils/parse-runtime-config.d.ts.map +1 -0
  12. package/dist/compiler/types/compiler-context.d.ts +1 -1
  13. package/dist/compiler/types/compiler-context.d.ts.map +1 -1
  14. package/dist/compiler/types/compiler-hooks.d.ts +2 -1
  15. package/dist/compiler/types/compiler-hooks.d.ts.map +1 -1
  16. package/dist/define-config.d.ts +3 -0
  17. package/dist/define-config.d.ts.map +1 -0
  18. package/dist/index.cjs +1130 -1184
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +1041 -1094
  23. package/dist/index.js.map +1 -1
  24. package/dist/models/module-definition.d.ts +3 -2
  25. package/dist/models/module-definition.d.ts.map +1 -1
  26. package/dist/plugins/body-fallback/constants/index.d.ts +2 -0
  27. package/dist/plugins/body-fallback/constants/index.d.ts.map +1 -0
  28. package/dist/plugins/body-fallback/constants/metadata-storage.d.ts +6 -0
  29. package/dist/plugins/body-fallback/constants/metadata-storage.d.ts.map +1 -0
  30. package/dist/plugins/body-fallback/index.d.ts +3 -0
  31. package/dist/plugins/body-fallback/index.d.ts.map +1 -1
  32. package/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts +3 -0
  33. package/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts.map +1 -1
  34. package/dist/plugins/chinese-to-pinyin/constants/index.d.ts +2 -0
  35. package/dist/plugins/chinese-to-pinyin/constants/index.d.ts.map +1 -0
  36. package/dist/plugins/chinese-to-pinyin/constants/metadata-storage.d.ts +6 -0
  37. package/dist/plugins/chinese-to-pinyin/constants/metadata-storage.d.ts.map +1 -0
  38. package/dist/plugins/download-http-file/constants/index.d.ts +2 -0
  39. package/dist/plugins/download-http-file/constants/index.d.ts.map +1 -0
  40. package/dist/plugins/download-http-file/constants/metadata-storage.d.ts +6 -0
  41. package/dist/plugins/download-http-file/constants/metadata-storage.d.ts.map +1 -0
  42. package/dist/plugins/download-http-file/download-http-file.plugin.d.ts +5 -2
  43. package/dist/plugins/download-http-file/download-http-file.plugin.d.ts.map +1 -1
  44. package/dist/plugins/download-local-file/constants/index.d.ts +2 -0
  45. package/dist/plugins/download-local-file/constants/index.d.ts.map +1 -0
  46. package/dist/plugins/download-local-file/constants/metadata-storage.d.ts +6 -0
  47. package/dist/plugins/download-local-file/constants/metadata-storage.d.ts.map +1 -0
  48. package/dist/plugins/download-local-file/download-local-file.plugin.d.ts +3 -0
  49. package/dist/plugins/download-local-file/download-local-file.plugin.d.ts.map +1 -1
  50. package/dist/plugins/eslint/constants/index.d.ts +2 -0
  51. package/dist/plugins/eslint/constants/index.d.ts.map +1 -0
  52. package/dist/plugins/eslint/constants/metadata-storage.d.ts +6 -0
  53. package/dist/plugins/eslint/constants/metadata-storage.d.ts.map +1 -0
  54. package/dist/plugins/eslint/eslint.plugin.d.ts +18 -0
  55. package/dist/plugins/eslint/eslint.plugin.d.ts.map +1 -0
  56. package/dist/plugins/eslint/index.d.ts +1 -14
  57. package/dist/plugins/eslint/index.d.ts.map +1 -1
  58. package/dist/plugins/generate-declaration/generate-declaration.plugin.d.ts.map +1 -1
  59. package/dist/plugins/generate-declaration/generators/schema-declaration/schema.generator.d.ts.map +1 -1
  60. package/dist/plugins/generate-micro-function/generate-micro-function.plugin.d.ts.map +1 -1
  61. package/dist/plugins/generate-nestjs-module/generate-nestjs-module.d.ts.map +1 -1
  62. package/dist/plugins/initialize/initialize.plugin.d.ts.map +1 -1
  63. package/dist/plugins/prettier/constants/index.d.ts +2 -0
  64. package/dist/plugins/prettier/constants/index.d.ts.map +1 -0
  65. package/dist/plugins/prettier/constants/metadata-storage.d.ts +6 -0
  66. package/dist/plugins/prettier/constants/metadata-storage.d.ts.map +1 -0
  67. package/dist/plugins/prettier/prettier.plugin.d.ts +3 -0
  68. package/dist/plugins/prettier/prettier.plugin.d.ts.map +1 -1
  69. package/dist/plugins/shaking/constants/index.d.ts +2 -0
  70. package/dist/plugins/shaking/constants/index.d.ts.map +1 -0
  71. package/dist/plugins/shaking/constants/metadata-storage.d.ts +6 -0
  72. package/dist/plugins/shaking/constants/metadata-storage.d.ts.map +1 -0
  73. package/dist/plugins/shaking/shaking.plugin.d.ts +3 -0
  74. package/dist/plugins/shaking/shaking.plugin.d.ts.map +1 -1
  75. package/dist/plugins/terminal-select/constants/index.d.ts +2 -0
  76. package/dist/plugins/terminal-select/constants/index.d.ts.map +1 -0
  77. package/dist/plugins/terminal-select/constants/metadata-storage.d.ts +6 -0
  78. package/dist/plugins/terminal-select/constants/metadata-storage.d.ts.map +1 -0
  79. package/dist/plugins/terminal-select/terminal-select.plugin.d.ts +3 -0
  80. package/dist/plugins/terminal-select/terminal-select.plugin.d.ts.map +1 -1
  81. package/dist/plugins.cjs +208 -47
  82. package/dist/plugins.cjs.map +1 -1
  83. package/dist/plugins.js +208 -47
  84. package/dist/plugins.js.map +1 -1
  85. package/dist/translators/index.d.ts +3 -0
  86. package/dist/translators/index.d.ts.map +1 -0
  87. package/dist/translators/micro-function.translator.d.ts +5 -0
  88. package/dist/translators/micro-function.translator.d.ts.map +1 -0
  89. package/dist/translators/nestjs.translator.d.ts +5 -0
  90. package/dist/translators/nestjs.translator.d.ts.map +1 -0
  91. package/dist/translators.cjs +2061 -0
  92. package/dist/translators.cjs.map +1 -0
  93. package/dist/translators.js +2023 -0
  94. package/dist/translators.js.map +1 -0
  95. package/dist/types/address.d.ts +8 -0
  96. package/dist/types/address.d.ts.map +1 -0
  97. package/dist/types/index.d.ts +3 -1
  98. package/dist/types/index.d.ts.map +1 -1
  99. package/dist/types/runtime-config.d.ts +39 -8
  100. package/dist/types/runtime-config.d.ts.map +1 -1
  101. package/dist/types/translator.d.ts +5 -0
  102. package/dist/types/translator.d.ts.map +1 -0
  103. package/dist/utils/is-valid-url.d.ts +16 -0
  104. package/dist/utils/is-valid-url.d.ts.map +1 -0
  105. package/package.json +8 -3
  106. package/dist/compiler/tasks/setup/utils/validate-modules.d.ts +0 -2
  107. package/dist/compiler/tasks/setup/utils/validate-modules.d.ts.map +0 -1
  108. package/dist/define-keq-config.d.ts +0 -3
  109. package/dist/define-keq-config.d.ts.map +0 -1
package/dist/plugins.cjs CHANGED
@@ -57,14 +57,21 @@ __export(plugins_exports, {
57
57
  });
58
58
  module.exports = __toCommonJS(plugins_exports);
59
59
 
60
- // src/plugins/eslint/index.ts
60
+ // src/plugins/eslint/eslint.plugin.ts
61
61
  var import_eslint = require("eslint");
62
+
63
+ // src/plugins/eslint/constants/metadata-storage.ts
64
+ var MetadataStorage = /* @__PURE__ */ new WeakMap();
65
+
66
+ // src/plugins/eslint/eslint.plugin.ts
62
67
  var EslintPlugin = class _EslintPlugin {
63
68
  constructor(options = {}) {
64
69
  this.options = options;
65
70
  }
66
71
  apply(compiler) {
67
72
  if (!compiler.options.build) return;
73
+ if (MetadataStorage.has(compiler)) return;
74
+ _EslintPlugin.register(compiler);
68
75
  if (this.options.disable && this.options.disable.length > 0) {
69
76
  const $rules = [
70
77
  ...this.options.disable.map((rule) => `/* eslint-disable ${rule} */`)
@@ -84,15 +91,33 @@ var EslintPlugin = class _EslintPlugin {
84
91
  await import_eslint.ESLint.outputFixes(results);
85
92
  });
86
93
  }
94
+ static register(compiler) {
95
+ if (!MetadataStorage.has(compiler)) {
96
+ MetadataStorage.set(compiler, {
97
+ hooks: {}
98
+ });
99
+ }
100
+ return MetadataStorage.get(compiler);
101
+ }
102
+ static of(compiler) {
103
+ return this.register(compiler);
104
+ }
87
105
  };
88
106
 
89
107
  // src/plugins/prettier/prettier.plugin.ts
90
108
  var import_child_process = require("child_process");
91
109
  var import_util = require("util");
110
+
111
+ // src/plugins/prettier/constants/metadata-storage.ts
112
+ var MetadataStorage2 = /* @__PURE__ */ new WeakMap();
113
+
114
+ // src/plugins/prettier/prettier.plugin.ts
92
115
  var execAsync = (0, import_util.promisify)(import_child_process.exec);
93
116
  var PrettierPlugin = class _PrettierPlugin {
94
117
  apply(compiler) {
95
118
  if (!compiler.options.build) return;
119
+ if (MetadataStorage2.has(compiler)) return;
120
+ _PrettierPlugin.register(compiler);
96
121
  compiler.hooks.afterPersist.tapPromise(_PrettierPlugin.name, async () => {
97
122
  const files = compiler.context.assets || [];
98
123
  if (files.length === 0) return;
@@ -100,6 +125,17 @@ var PrettierPlugin = class _PrettierPlugin {
100
125
  await execAsync(`prettier --write ${filePaths}`);
101
126
  });
102
127
  }
128
+ static register(compiler) {
129
+ if (!MetadataStorage2.has(compiler)) {
130
+ MetadataStorage2.set(compiler, {
131
+ hooks: {}
132
+ });
133
+ }
134
+ return MetadataStorage2.get(compiler);
135
+ }
136
+ static of(compiler) {
137
+ return this.register(compiler);
138
+ }
103
139
  };
104
140
 
105
141
  // src/plugins/body-fallback/index.ts
@@ -137,7 +173,7 @@ var JsonSchemaUtils = class {
137
173
  var import_tapable2 = require("tapable");
138
174
 
139
175
  // src/plugins/generate-micro-function/constants/metadata-storage.ts
140
- var MetadataStorage = /* @__PURE__ */ new WeakMap();
176
+ var MetadataStorage3 = /* @__PURE__ */ new WeakMap();
141
177
 
142
178
  // src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts
143
179
  var R18 = __toESM(require("ramda"), 1);
@@ -251,10 +287,14 @@ var ModuleDefinition = class _ModuleDefinition {
251
287
  address;
252
288
  constructor(name, address) {
253
289
  this.name = name;
254
- this.address = address;
290
+ if (typeof address === "string") {
291
+ this.address = { url: address, headers: {}, encoding: "utf8" };
292
+ } else {
293
+ this.address = address;
294
+ }
255
295
  }
256
296
  static unknown() {
257
- return new _ModuleDefinition("", "");
297
+ return new _ModuleDefinition("", { url: "", headers: {}, encoding: "utf8" });
258
298
  }
259
299
  };
260
300
 
@@ -1565,14 +1605,14 @@ var path5 = __toESM(require("path"), 1);
1565
1605
  var changeCase4 = __toESM(require("change-case"), 1);
1566
1606
 
1567
1607
  // src/plugins/generate-declaration/constants/metadata-storage.ts
1568
- var MetadataStorage2 = /* @__PURE__ */ new WeakMap();
1608
+ var MetadataStorage4 = /* @__PURE__ */ new WeakMap();
1569
1609
 
1570
1610
  // src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts
1571
1611
  var SCHEMA_GENERATOR = "schemaGenerator";
1572
1612
  var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
1573
1613
  async compile(compiler, task) {
1574
1614
  const context = compiler.context;
1575
- const metadata = MetadataStorage2.get(compiler);
1615
+ const metadata = MetadataStorage4.get(compiler);
1576
1616
  const rc = context.rc;
1577
1617
  const documents = context.documents;
1578
1618
  const schemaDefinitions = documents.flatMap((document) => document.schemas);
@@ -1645,7 +1685,7 @@ var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
1645
1685
  ].join("/");
1646
1686
  }
1647
1687
  static getEntrypointArtifactId(moduleDefinition) {
1648
- return `${moduleDefinition.address}/components/schemas/entrypoint?generator=${SCHEMA_GENERATOR}`;
1688
+ return `${moduleDefinition.address.url}/components/schemas/entrypoint?generator=${SCHEMA_GENERATOR}`;
1649
1689
  }
1650
1690
  static getSchemaDefinitionArtifactFilepath(schemaDefinition, fileNamingStyle) {
1651
1691
  const filename = `${changeCase4[fileNamingStyle](schemaDefinition.name)}.schema.ts`;
@@ -1668,7 +1708,7 @@ var OPERATION_GENERATOR = "operationDeclarationGenerator";
1668
1708
  var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
1669
1709
  async compile(compiler, task) {
1670
1710
  const context = compiler.context;
1671
- const metadata = MetadataStorage2.get(compiler);
1711
+ const metadata = MetadataStorage4.get(compiler);
1672
1712
  const rc = context.rc;
1673
1713
  const documents = context.documents;
1674
1714
  const operationDefinitions = documents.flatMap((document) => document.operations);
@@ -1743,7 +1783,7 @@ var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
1743
1783
  ].join("/");
1744
1784
  }
1745
1785
  static getEntrypointArtifactId(moduleDefinition) {
1746
- return `${moduleDefinition.address}/paths/entrypoint?generator=${OPERATION_GENERATOR}`;
1786
+ return `${moduleDefinition.address.url}/paths/entrypoint?generator=${OPERATION_GENERATOR}`;
1747
1787
  }
1748
1788
  };
1749
1789
 
@@ -1756,6 +1796,7 @@ var GenerateDeclarationPlugin = class _GenerateDeclarationPlugin {
1756
1796
  constructor() {
1757
1797
  }
1758
1798
  apply(compiler) {
1799
+ if (MetadataStorage4.has(compiler)) return;
1759
1800
  _GenerateDeclarationPlugin.register(compiler);
1760
1801
  compiler.hooks.compile.tapPromise(_GenerateDeclarationPlugin.name, async (task) => {
1761
1802
  compiler.context.artifacts?.push(
@@ -1765,8 +1806,8 @@ var GenerateDeclarationPlugin = class _GenerateDeclarationPlugin {
1765
1806
  });
1766
1807
  }
1767
1808
  static register(compiler) {
1768
- if (!MetadataStorage2.has(compiler)) {
1769
- MetadataStorage2.set(compiler, {
1809
+ if (!MetadataStorage4.has(compiler)) {
1810
+ MetadataStorage4.set(compiler, {
1770
1811
  hooks: {
1771
1812
  afterEntrypointArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "task"]),
1772
1813
  afterSchemaDeclarationArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "schemaDefinition", "task"]),
@@ -1774,7 +1815,7 @@ var GenerateDeclarationPlugin = class _GenerateDeclarationPlugin {
1774
1815
  }
1775
1816
  });
1776
1817
  }
1777
- return MetadataStorage2.get(compiler);
1818
+ return MetadataStorage4.get(compiler);
1778
1819
  }
1779
1820
  static of(compiler) {
1780
1821
  return this.register(compiler);
@@ -1819,7 +1860,7 @@ var RequestGenerator = class _RequestGenerator {
1819
1860
  var MICRO_FUNCTION_GENERATOR = "microFunctionGenerator";
1820
1861
  var MicroFunctionGenerator = class _MicroFunctionGenerator {
1821
1862
  async compile(compiler, task) {
1822
- const metadata = MetadataStorage.get(compiler);
1863
+ const metadata = MetadataStorage3.get(compiler);
1823
1864
  const context = compiler.context;
1824
1865
  const rc = context.rc;
1825
1866
  const documents = context.documents;
@@ -1922,6 +1963,7 @@ var GenerateMicroFunctionPlugin = class _GenerateMicroFunctionPlugin {
1922
1963
  microFunctionGenerator = new MicroFunctionGenerator();
1923
1964
  requestGenerator = new RequestGenerator();
1924
1965
  apply(compiler) {
1966
+ if (MetadataStorage3.has(compiler)) return;
1925
1967
  _GenerateMicroFunctionPlugin.register(compiler);
1926
1968
  compiler.hooks.compile.tapPromise(_GenerateMicroFunctionPlugin.name, async (task) => {
1927
1969
  const artifacts = [
@@ -1932,24 +1974,29 @@ var GenerateMicroFunctionPlugin = class _GenerateMicroFunctionPlugin {
1932
1974
  });
1933
1975
  }
1934
1976
  static register(compiler) {
1935
- if (!MetadataStorage.has(compiler)) {
1936
- MetadataStorage.set(compiler, {
1977
+ if (!MetadataStorage3.has(compiler)) {
1978
+ MetadataStorage3.set(compiler, {
1937
1979
  hooks: {
1938
1980
  afterEntrypointArtifactGenerated: new import_tapable2.AsyncSeriesWaterfallHook(["artifact", "task"]),
1939
1981
  afterMicroFunctionArtifactGenerated: new import_tapable2.AsyncSeriesWaterfallHook(["artifact", "operationDefinition", "task"])
1940
1982
  }
1941
1983
  });
1942
1984
  }
1943
- return MetadataStorage.get(compiler);
1985
+ return MetadataStorage3.get(compiler);
1944
1986
  }
1945
1987
  static of(compiler) {
1946
1988
  return this.register(compiler);
1947
1989
  }
1948
1990
  };
1949
1991
 
1992
+ // src/plugins/body-fallback/constants/metadata-storage.ts
1993
+ var MetadataStorage5 = /* @__PURE__ */ new WeakMap();
1994
+
1950
1995
  // src/plugins/body-fallback/index.ts
1951
1996
  var BodyFallbackPlugin = class _BodyFallbackPlugin {
1952
1997
  apply(compiler) {
1998
+ if (MetadataStorage5.has(compiler)) return;
1999
+ _BodyFallbackPlugin.register(compiler);
1953
2000
  compiler.hooks.setup.tap(_BodyFallbackPlugin.name, () => {
1954
2001
  const generateMicroFunctionPluginMetadata = GenerateMicroFunctionPlugin.of(compiler);
1955
2002
  if (!generateMicroFunctionPluginMetadata) {
@@ -1982,13 +2029,24 @@ var BodyFallbackPlugin = class _BodyFallbackPlugin {
1982
2029
  });
1983
2030
  });
1984
2031
  }
2032
+ static register(compiler) {
2033
+ if (!MetadataStorage5.has(compiler)) {
2034
+ MetadataStorage5.set(compiler, {
2035
+ hooks: {}
2036
+ });
2037
+ }
2038
+ return MetadataStorage5.get(compiler);
2039
+ }
2040
+ static of(compiler) {
2041
+ return this.register(compiler);
2042
+ }
1985
2043
  };
1986
2044
 
1987
2045
  // src/plugins/generate-nestjs-module/generate-nestjs-module.ts
1988
2046
  var import_tapable3 = require("tapable");
1989
2047
 
1990
2048
  // src/plugins/generate-nestjs-module/constants/metadata-storage.ts
1991
- var MetadataStorage3 = /* @__PURE__ */ new WeakMap();
2049
+ var MetadataStorage6 = /* @__PURE__ */ new WeakMap();
1992
2050
 
1993
2051
  // src/plugins/generate-nestjs-module/generators/nestjs-module.generator.ts
1994
2052
  var path8 = __toESM(require("path"), 1);
@@ -2034,7 +2092,7 @@ var NestjsModuleGenerator = class _NestjsModuleGenerator {
2034
2092
  return artifact;
2035
2093
  }
2036
2094
  async compile(compiler, task) {
2037
- const metadata = MetadataStorage3.get(compiler);
2095
+ const metadata = MetadataStorage6.get(compiler);
2038
2096
  const rc = compiler.context.rc;
2039
2097
  const documents = compiler.context.documents;
2040
2098
  const nestjsModuleArtifacts = await Promise.all(
@@ -2083,6 +2141,7 @@ var NestjsModuleGenerator = class _NestjsModuleGenerator {
2083
2141
  var GenerateNestjsModulePlugin = class _GenerateNestjsModulePlugin {
2084
2142
  nestjsModuleGenerator = new NestjsModuleGenerator();
2085
2143
  apply(compiler) {
2144
+ if (MetadataStorage6.has(compiler)) return;
2086
2145
  _GenerateNestjsModulePlugin.register(compiler);
2087
2146
  compiler.hooks.compile.tapPromise(_GenerateNestjsModulePlugin.name, async (task) => {
2088
2147
  const artifacts = await this.nestjsModuleGenerator.compile(compiler, task);
@@ -2090,24 +2149,31 @@ var GenerateNestjsModulePlugin = class _GenerateNestjsModulePlugin {
2090
2149
  });
2091
2150
  }
2092
2151
  static register(compiler) {
2093
- if (!MetadataStorage3.has(compiler)) {
2094
- MetadataStorage3.set(compiler, {
2152
+ if (!MetadataStorage6.has(compiler)) {
2153
+ MetadataStorage6.set(compiler, {
2095
2154
  hooks: {
2096
2155
  afterNestjsModuleArtifactGenerated: new import_tapable3.AsyncSeriesWaterfallHook(["artifact", "document", "task"])
2097
2156
  }
2098
2157
  });
2099
2158
  }
2100
- return MetadataStorage3.get(compiler);
2159
+ return MetadataStorage6.get(compiler);
2101
2160
  }
2102
2161
  static of(compiler) {
2103
- return MetadataStorage3.get(compiler);
2162
+ return MetadataStorage6.get(compiler);
2104
2163
  }
2105
2164
  };
2106
2165
 
2107
2166
  // src/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.ts
2108
2167
  var import_swagger_fix = require("swagger-fix");
2168
+
2169
+ // src/plugins/chinese-to-pinyin/constants/metadata-storage.ts
2170
+ var MetadataStorage7 = /* @__PURE__ */ new WeakMap();
2171
+
2172
+ // src/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.ts
2109
2173
  var ChineseToPinyinPlugin = class _ChineseToPinyinPlugin {
2110
2174
  apply(compiler) {
2175
+ if (MetadataStorage7.has(compiler)) return;
2176
+ _ChineseToPinyinPlugin.register(compiler);
2111
2177
  compiler.hooks.afterDownload.tap(_ChineseToPinyinPlugin.name, (task) => {
2112
2178
  const documents = compiler.context.documents;
2113
2179
  compiler.context.documents = documents.map((doc) => {
@@ -2118,27 +2184,44 @@ var ChineseToPinyinPlugin = class _ChineseToPinyinPlugin {
2118
2184
  });
2119
2185
  });
2120
2186
  }
2187
+ static register(compiler) {
2188
+ if (!MetadataStorage7.has(compiler)) {
2189
+ MetadataStorage7.set(compiler, {
2190
+ hooks: {}
2191
+ });
2192
+ }
2193
+ return MetadataStorage7.get(compiler);
2194
+ }
2195
+ static of(compiler) {
2196
+ return this.register(compiler);
2197
+ }
2121
2198
  };
2122
2199
 
2200
+ // src/plugins/download-http-file/constants/metadata-storage.ts
2201
+ var MetadataStorage8 = /* @__PURE__ */ new WeakMap();
2202
+
2123
2203
  // src/plugins/download-http-file/download-http-file.plugin.ts
2124
- var validUrl = __toESM(require("valid-url"), 1);
2125
2204
  var DownloadHttpFilePlugin = class _DownloadHttpFilePlugin {
2126
2205
  apply(compiler) {
2206
+ if (MetadataStorage8.has(compiler)) return;
2207
+ _DownloadHttpFilePlugin.register(compiler);
2127
2208
  compiler.hooks.download.tapPromise(_DownloadHttpFilePlugin.name, async (address, task) => {
2128
- if (!validUrl.isUri(address)) return void 0;
2209
+ const { url } = address;
2210
+ if (!url.startsWith("http://") && !url.startsWith("https://")) return void 0;
2129
2211
  const content = await this.download(address);
2130
2212
  const spec = this.deserialize(content);
2131
2213
  return JSON.stringify(spec);
2132
2214
  });
2133
2215
  }
2134
2216
  async download(address) {
2217
+ const { url, headers } = address;
2135
2218
  try {
2136
- const res = await fetch(address);
2219
+ const res = await fetch(url, { headers });
2137
2220
  if (res.status >= 400) throw new Error(`failed with status code ${res.status}`);
2138
2221
  return await res.text();
2139
2222
  } catch (e) {
2140
2223
  if (e instanceof Error) {
2141
- e.message = `Unable get the openapi/swagger file from ${address}: ${e.message}`;
2224
+ e.message = `Unable get the openapi/swagger file from ${url}: ${e.message}`;
2142
2225
  }
2143
2226
  throw e;
2144
2227
  }
@@ -2148,32 +2231,72 @@ var DownloadHttpFilePlugin = class _DownloadHttpFilePlugin {
2148
2231
  const spec = OpenapiUtils.to3_1(json);
2149
2232
  return spec;
2150
2233
  }
2234
+ static register(compiler) {
2235
+ if (!MetadataStorage8.has(compiler)) {
2236
+ MetadataStorage8.set(compiler, {
2237
+ hooks: {}
2238
+ });
2239
+ }
2240
+ return MetadataStorage8.get(compiler);
2241
+ }
2242
+ static of(compiler) {
2243
+ return this.register(compiler);
2244
+ }
2151
2245
  };
2152
2246
 
2153
2247
  // src/plugins/download-local-file/download-local-file.plugin.ts
2154
2248
  var path9 = __toESM(require("path"), 1);
2155
2249
  var fs = __toESM(require("fs/promises"), 1);
2156
2250
  var yaml = __toESM(require("js-yaml"), 1);
2251
+ var import_url = require("url");
2252
+
2253
+ // src/plugins/download-local-file/constants/metadata-storage.ts
2254
+ var MetadataStorage9 = /* @__PURE__ */ new WeakMap();
2255
+
2256
+ // src/plugins/download-local-file/download-local-file.plugin.ts
2157
2257
  var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
2158
2258
  apply(compiler) {
2259
+ if (MetadataStorage9.has(compiler)) return;
2260
+ _DownloadLocalFilePlugin.register(compiler);
2159
2261
  compiler.hooks.download.tapPromise(_DownloadLocalFilePlugin.name, async (address, task) => {
2160
- if (!address.startsWith("./") && !address.startsWith("/") && !address.startsWith("../")) return void 0;
2161
- const fileExt = path9.extname(address);
2162
- const content = await fs.readFile(address, "utf8");
2262
+ const { url, encoding } = address;
2263
+ if (!url.startsWith("file://")) return void 0;
2264
+ const filepath = (0, import_url.fileURLToPath)(url);
2265
+ const fileExt = path9.extname(filepath);
2266
+ const content = await fs.readFile(filepath, encoding);
2267
+ const str = typeof content === "string" ? content : content.toString(encoding);
2163
2268
  if ([".yml", ".yaml"].includes(fileExt)) {
2164
- const value = yaml.load(content);
2269
+ const value = yaml.load(str);
2165
2270
  return JSON.stringify(OpenapiUtils.to3_1(value));
2166
2271
  } else if (fileExt === ".json") {
2167
- return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(content)));
2272
+ return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(str)));
2168
2273
  }
2169
2274
  });
2170
2275
  }
2276
+ static register(compiler) {
2277
+ if (!MetadataStorage9.has(compiler)) {
2278
+ MetadataStorage9.set(compiler, {
2279
+ hooks: {}
2280
+ });
2281
+ }
2282
+ return MetadataStorage9.get(compiler);
2283
+ }
2284
+ static of(compiler) {
2285
+ return this.register(compiler);
2286
+ }
2171
2287
  };
2172
2288
 
2173
2289
  // src/plugins/shaking/shaking.plugin.ts
2174
2290
  var import_openapi_shaking = require("@opendoc/openapi-shaking");
2291
+
2292
+ // src/plugins/shaking/constants/metadata-storage.ts
2293
+ var MetadataStorage10 = /* @__PURE__ */ new WeakMap();
2294
+
2295
+ // src/plugins/shaking/shaking.plugin.ts
2175
2296
  var ShakingPlugin = class _ShakingPlugin {
2176
2297
  apply(compiler) {
2298
+ if (MetadataStorage10.has(compiler)) return;
2299
+ _ShakingPlugin.register(compiler);
2177
2300
  compiler.hooks.beforeCompile.tap(_ShakingPlugin.name, (task) => {
2178
2301
  const matcher = compiler.context.matcher;
2179
2302
  const documents = compiler.context.documents;
@@ -2202,10 +2325,25 @@ var ShakingPlugin = class _ShakingPlugin {
2202
2325
  sharkedSwagger,
2203
2326
  new ModuleDefinition(
2204
2327
  document.module.name,
2205
- `file://${document.module.name}.v3_1.sharked.json`
2328
+ {
2329
+ url: `memory://${document.module.name}.v3_1.sharked.json`,
2330
+ headers: {},
2331
+ encoding: "utf8"
2332
+ }
2206
2333
  )
2207
2334
  );
2208
2335
  }
2336
+ static register(compiler) {
2337
+ if (!MetadataStorage10.has(compiler)) {
2338
+ MetadataStorage10.set(compiler, {
2339
+ hooks: {}
2340
+ });
2341
+ }
2342
+ return MetadataStorage10.get(compiler);
2343
+ }
2344
+ static of(compiler) {
2345
+ return this.register(compiler);
2346
+ }
2209
2347
  };
2210
2348
 
2211
2349
  // src/plugins/terminal-select/utils/select-operation-definitions.ts
@@ -2231,12 +2369,17 @@ async function selectOperationDefinitions(task, operationDefinitions) {
2231
2369
  return selectedOperationDefinitions;
2232
2370
  }
2233
2371
 
2372
+ // src/plugins/terminal-select/constants/metadata-storage.ts
2373
+ var MetadataStorage11 = /* @__PURE__ */ new WeakMap();
2374
+
2234
2375
  // src/plugins/terminal-select/terminal-select.plugin.ts
2235
2376
  var TerminalSelectPlugin = class _TerminalSelectPlugin {
2236
2377
  constructor(options) {
2237
2378
  this.options = options;
2238
2379
  }
2239
2380
  apply(compiler) {
2381
+ if (MetadataStorage11.has(compiler)) return;
2382
+ _TerminalSelectPlugin.register(compiler);
2240
2383
  compiler.hooks.afterDownload.tapPromise(_TerminalSelectPlugin.name, async (task) => {
2241
2384
  const context = compiler.context;
2242
2385
  const matcher = context.matcher;
@@ -2263,6 +2406,17 @@ var TerminalSelectPlugin = class _TerminalSelectPlugin {
2263
2406
  }
2264
2407
  });
2265
2408
  }
2409
+ static register(compiler) {
2410
+ if (!MetadataStorage11.has(compiler)) {
2411
+ MetadataStorage11.set(compiler, {
2412
+ hooks: {}
2413
+ });
2414
+ }
2415
+ return MetadataStorage11.get(compiler);
2416
+ }
2417
+ static of(compiler) {
2418
+ return this.register(compiler);
2419
+ }
2266
2420
  };
2267
2421
 
2268
2422
  // src/plugins/initialize/initialize.plugin.ts
@@ -2273,27 +2427,34 @@ var InitializePlugin = class _InitializePlugin {
2273
2427
  }
2274
2428
  apply(compiler) {
2275
2429
  compiler.hooks.setup.tap(_InitializePlugin.name, (task) => {
2276
- new DownloadHttpFilePlugin().apply(compiler);
2277
- new DownloadLocalFilePlugin().apply(compiler);
2278
- new GenerateDeclarationPlugin().apply(compiler);
2430
+ const plugins = [
2431
+ new DownloadHttpFilePlugin(),
2432
+ new DownloadLocalFilePlugin()
2433
+ ];
2279
2434
  if (this.options.build) {
2280
- new ShakingPlugin().apply(compiler);
2435
+ plugins.push(new ShakingPlugin());
2281
2436
  }
2282
2437
  if (this.options.interactive) {
2283
- new TerminalSelectPlugin(
2284
- typeof this.options.interactive === "object" ? this.options.interactive : { mode: "except" }
2285
- ).apply(compiler);
2438
+ plugins.push(
2439
+ new TerminalSelectPlugin(
2440
+ typeof this.options.interactive === "object" ? this.options.interactive : { mode: "except" }
2441
+ )
2442
+ );
2286
2443
  }
2287
2444
  const rc = compiler.context.rc;
2288
- if (rc.mode === "micro-function") {
2289
- new GenerateMicroFunctionPlugin().apply(compiler);
2290
- } else if (rc.mode === "nestjs-module") {
2291
- new GenerateNestjsModulePlugin().apply(compiler);
2292
- }
2445
+ plugins.push(
2446
+ ...R20.unnest(
2447
+ (rc.translators || []).map((translator) => {
2448
+ const plugins2 = translator.apply();
2449
+ return plugins2;
2450
+ })
2451
+ )
2452
+ );
2293
2453
  if (rc.plugins && rc.plugins.length) {
2294
- for (const plugin of rc.plugins) {
2295
- plugin.apply(compiler);
2296
- }
2454
+ plugins.push(...rc.plugins);
2455
+ }
2456
+ for (const plugin of plugins) {
2457
+ plugin.apply(compiler);
2297
2458
  }
2298
2459
  });
2299
2460
  if (this.options.includes && this.options.includes.length) {