unplugin-kubb 5.14.4 → 5.14.5

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.
@@ -24,6 +24,7 @@ export declare function generateModule({ root, input, config, hooks }: {
24
24
  }): Promise<{
25
25
  text: string;
26
26
  errors: Array<ProblemDiagnostic>;
27
+ sources: Array<string>;
27
28
  }>;
28
29
  //#endregion
29
30
  //# sourceMappingURL=generateModule.d.ts.map
@@ -34,6 +34,7 @@ function selectConfig({ configs, fileName, cwd }) {
34
34
  */
35
35
  async function generateModule({ root, input, config, hooks }) {
36
36
  const storage = memoryStorage();
37
+ const adapter = config.adapter ?? adapterOas();
37
38
  const { diagnostics } = await createKubb({
38
39
  root,
39
40
  input,
@@ -43,7 +44,7 @@ async function generateModule({ root, input, config, hooks }) {
43
44
  format: false,
44
45
  lint: false
45
46
  },
46
- adapter: config.adapter ?? adapterOas(),
47
+ adapter,
47
48
  parsers: [parserTs()],
48
49
  plugins: (config.plugins ?? []).filter((plugin) => plugin.name !== pluginBarrelName).map(toModulePlugin),
49
50
  storage
@@ -51,7 +52,8 @@ async function generateModule({ root, input, config, hooks }) {
51
52
  const errors = diagnostics.filter(Diagnostics.isProblem).filter((diagnostic) => diagnostic.severity === "error");
52
53
  return {
53
54
  text: errors.length ? "" : await storage.readItem(path.resolve(root, moduleFile)) ?? "",
54
- errors
55
+ errors,
56
+ sources: adapter.sources ?? []
55
57
  };
56
58
  }
57
59
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"generateModule.js","names":[],"sources":["../src/generateModule.ts"],"sourcesContent":["import path from 'node:path'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport {\n createKubb,\n Diagnostics,\n type Hookable,\n type KubbHooks,\n memoryStorage,\n type Output,\n type Plugin,\n type ProblemDiagnostic,\n type UserConfig,\n} from '@kubb/core'\nimport { parserTs } from '@kubb/parser-ts'\nimport { pluginBarrelName } from '@kubb/plugin-barrel'\n\n// Every plugin writes to this one file, so Kubb merges their output and drops the imports between them.\nconst moduleFile = 'index.ts'\n\nconst toModulePlugin = (plugin: Plugin): Plugin => ({\n ...plugin,\n options: {\n ...plugin.options,\n // An explicit `mode: 'directory'` would otherwise survive and write under `index.ts/`.\n output: { ...(plugin.options as { output?: Output } | undefined)?.output, path: moduleFile, mode: 'file' },\n group: undefined,\n },\n})\n\n/**\n * The config whose `input` is `fileName`, else the first one without an `input`. A config for\n * another spec does not apply, so it returns `undefined` when no config fits. A relative `root`\n * resolves from `cwd`, and `input` from `root`.\n */\nexport function selectConfig({ configs, fileName, cwd }: { configs: Array<UserConfig>; fileName: string; cwd: string }): UserConfig | undefined {\n const matches = (config: UserConfig) => typeof config.input === 'string' && path.resolve(cwd, config.root || '.', config.input) === path.resolve(fileName)\n\n return configs.find(matches) ?? configs.find((config) => config.input === undefined)\n}\n\n/**\n * Generates the output of every plugin in `config` for one spec as one TypeScript module, without\n * writing files. Only `config`'s adapter and plugins are used. `text` is empty when `errors` is not.\n * The `*.openapi.yaml` loader and the `openapi-import` content mapper share it.\n */\nexport async function generateModule({\n root,\n input,\n config,\n hooks,\n}: {\n /** Folder of the spec; relative imports in the module resolve from here. */\n root: string\n input: UserConfig['input']\n config: UserConfig\n hooks?: Hookable<KubbHooks>\n}): Promise<{ text: string; errors: Array<ProblemDiagnostic> }> {\n const storage = memoryStorage()\n const { diagnostics } = await createKubb(\n {\n root,\n input,\n output: { path: '.', barrel: false, format: false, lint: false },\n adapter: config.adapter ?? adapterOas(),\n parsers: [parserTs()],\n plugins: (config.plugins ?? []).filter((plugin) => plugin.name !== pluginBarrelName).map(toModulePlugin),\n storage,\n },\n { hooks },\n ).safeBuild()\n const errors = diagnostics.filter(Diagnostics.isProblem).filter((diagnostic) => diagnostic.severity === 'error')\n // Files written elsewhere (a bundled client runtime) are left out; no output is an empty module.\n const text = errors.length ? '' : ((await storage.readItem(path.resolve(root, moduleFile))) ?? '')\n\n return { text, errors }\n}\n"],"mappings":";;;;;;;AAiBA,MAAM,aAAa;AAEnB,MAAM,kBAAkB,YAA4B;CAClD,GAAG;CACH,SAAS;EACP,GAAG,OAAO;EAEV,QAAQ;GAAE,GAAI,OAAO,SAA6C;GAAQ,MAAM;GAAY,MAAM;EAAO;EACzG,OAAO,KAAA;CACT;AACF;;;;;;AAOA,SAAgB,aAAa,EAAE,SAAS,UAAU,OAA8F;CAC9I,MAAM,WAAW,WAAuB,OAAO,OAAO,UAAU,YAAY,KAAK,QAAQ,KAAK,OAAO,QAAQ,KAAK,OAAO,KAAK,MAAM,KAAK,QAAQ,QAAQ;CAEzJ,OAAO,QAAQ,KAAK,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,UAAU,KAAA,CAAS;AACrF;;;;;;AAOA,eAAsB,eAAe,EACnC,MACA,OACA,QACA,SAO8D;CAC9D,MAAM,UAAU,cAAc;CAC9B,MAAM,EAAE,gBAAgB,MAAM,WAC5B;EACE;EACA;EACA,QAAQ;GAAE,MAAM;GAAK,QAAQ;GAAO,QAAQ;GAAO,MAAM;EAAM;EAC/D,SAAS,OAAO,WAAW,WAAW;EACtC,SAAS,CAAC,SAAS,CAAC;EACpB,UAAU,OAAO,WAAW,CAAC,EAAA,CAAG,QAAQ,WAAW,OAAO,SAAS,gBAAgB,CAAC,CAAC,IAAI,cAAc;EACvG;CACF,GACA,EAAE,MAAM,CACV,CAAC,CAAC,UAAU;CACZ,MAAM,SAAS,YAAY,OAAO,YAAY,SAAS,CAAC,CAAC,QAAQ,eAAe,WAAW,aAAa,OAAO;CAI/G,OAAO;EAAE,MAFI,OAAO,SAAS,KAAO,MAAM,QAAQ,SAAS,KAAK,QAAQ,MAAM,UAAU,CAAC,KAAM;EAEhF;CAAO;AACxB"}
1
+ {"version":3,"file":"generateModule.js","names":[],"sources":["../src/generateModule.ts"],"sourcesContent":["import path from 'node:path'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport {\n createKubb,\n Diagnostics,\n type Hookable,\n type KubbHooks,\n memoryStorage,\n type Output,\n type Plugin,\n type ProblemDiagnostic,\n type UserConfig,\n} from '@kubb/core'\nimport { parserTs } from '@kubb/parser-ts'\nimport { pluginBarrelName } from '@kubb/plugin-barrel'\n\n// Every plugin writes to this one file, so Kubb merges their output and drops the imports between them.\nconst moduleFile = 'index.ts'\n\nconst toModulePlugin = (plugin: Plugin): Plugin => ({\n ...plugin,\n options: {\n ...plugin.options,\n // An explicit `mode: 'directory'` would otherwise survive and write under `index.ts/`.\n output: { ...(plugin.options as { output?: Output } | undefined)?.output, path: moduleFile, mode: 'file' },\n group: undefined,\n },\n})\n\n/**\n * The config whose `input` is `fileName`, else the first one without an `input`. A config for\n * another spec does not apply, so it returns `undefined` when no config fits. A relative `root`\n * resolves from `cwd`, and `input` from `root`.\n */\nexport function selectConfig({ configs, fileName, cwd }: { configs: Array<UserConfig>; fileName: string; cwd: string }): UserConfig | undefined {\n const matches = (config: UserConfig) => typeof config.input === 'string' && path.resolve(cwd, config.root || '.', config.input) === path.resolve(fileName)\n\n return configs.find(matches) ?? configs.find((config) => config.input === undefined)\n}\n\n/**\n * Generates the output of every plugin in `config` for one spec as one TypeScript module, without\n * writing files. Only `config`'s adapter and plugins are used. `text` is empty when `errors` is not.\n * The `*.openapi.yaml` loader and the `openapi-import` content mapper share it.\n */\nexport async function generateModule({\n root,\n input,\n config,\n hooks,\n}: {\n /** Folder of the spec; relative imports in the module resolve from here. */\n root: string\n input: UserConfig['input']\n config: UserConfig\n hooks?: Hookable<KubbHooks>\n}): Promise<{ text: string; errors: Array<ProblemDiagnostic>; sources: Array<string> }> {\n const storage = memoryStorage()\n const adapter = config.adapter ?? adapterOas()\n const { diagnostics } = await createKubb(\n {\n root,\n input,\n output: { path: '.', barrel: false, format: false, lint: false },\n adapter,\n parsers: [parserTs()],\n plugins: (config.plugins ?? []).filter((plugin) => plugin.name !== pluginBarrelName).map(toModulePlugin),\n storage,\n },\n { hooks },\n ).safeBuild()\n const errors = diagnostics.filter(Diagnostics.isProblem).filter((diagnostic) => diagnostic.severity === 'error')\n // Files written elsewhere (a bundled client runtime) are left out; no output is an empty module.\n const text = errors.length ? '' : ((await storage.readItem(path.resolve(root, moduleFile))) ?? '')\n\n return { text, errors, sources: adapter.sources ?? [] }\n}\n"],"mappings":";;;;;;;AAiBA,MAAM,aAAa;AAEnB,MAAM,kBAAkB,YAA4B;CAClD,GAAG;CACH,SAAS;EACP,GAAG,OAAO;EAEV,QAAQ;GAAE,GAAI,OAAO,SAA6C;GAAQ,MAAM;GAAY,MAAM;EAAO;EACzG,OAAO,KAAA;CACT;AACF;;;;;;AAOA,SAAgB,aAAa,EAAE,SAAS,UAAU,OAA8F;CAC9I,MAAM,WAAW,WAAuB,OAAO,OAAO,UAAU,YAAY,KAAK,QAAQ,KAAK,OAAO,QAAQ,KAAK,OAAO,KAAK,MAAM,KAAK,QAAQ,QAAQ;CAEzJ,OAAO,QAAQ,KAAK,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,UAAU,KAAA,CAAS;AACrF;;;;;;AAOA,eAAsB,eAAe,EACnC,MACA,OACA,QACA,SAOsF;CACtF,MAAM,UAAU,cAAc;CAC9B,MAAM,UAAU,OAAO,WAAW,WAAW;CAC7C,MAAM,EAAE,gBAAgB,MAAM,WAC5B;EACE;EACA;EACA,QAAQ;GAAE,MAAM;GAAK,QAAQ;GAAO,QAAQ;GAAO,MAAM;EAAM;EAC/D;EACA,SAAS,CAAC,SAAS,CAAC;EACpB,UAAU,OAAO,WAAW,CAAC,EAAA,CAAG,QAAQ,WAAW,OAAO,SAAS,gBAAgB,CAAC,CAAC,IAAI,cAAc;EACvG;CACF,GACA,EAAE,MAAM,CACV,CAAC,CAAC,UAAU;CACZ,MAAM,SAAS,YAAY,OAAO,YAAY,SAAS,CAAC,CAAC,QAAQ,eAAe,WAAW,aAAa,OAAO;CAI/G,OAAO;EAAE,MAFI,OAAO,SAAS,KAAO,MAAM,QAAQ,SAAS,KAAK,QAAQ,MAAM,UAAU,CAAC,KAAM;EAEhF;EAAQ,SAAS,QAAQ,WAAW,CAAC;CAAE;AACxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-kubb",
3
- "version": "5.14.4",
3
+ "version": "5.14.5",
4
4
  "description": "Integration of Kubb for Vite, webpack, Rollup, Rolldown, Rspack, esbuild, Farm, Nuxt, and Astro.",
5
5
  "keywords": [
6
6
  "astro",
@@ -105,11 +105,11 @@
105
105
  "registry": "https://registry.npmjs.org/"
106
106
  },
107
107
  "dependencies": {
108
- "@kubb/adapter-oas": "5.14.4",
109
- "@kubb/core": "5.14.4",
110
- "@kubb/parser-md": "5.14.4",
111
- "@kubb/parser-ts": "5.14.4",
112
- "@kubb/plugin-barrel": "5.14.4",
108
+ "@kubb/adapter-oas": "5.14.5",
109
+ "@kubb/core": "5.14.5",
110
+ "@kubb/parser-md": "5.14.5",
111
+ "@kubb/parser-ts": "5.14.5",
112
+ "@kubb/plugin-barrel": "5.14.5",
113
113
  "jiti": "^2.7.0",
114
114
  "unplugin": "^3.4.0",
115
115
  "yuku-codegen": "^0.19.0",
@@ -118,7 +118,7 @@
118
118
  "devDependencies": {
119
119
  "@farmfe/core": "^1.7.11",
120
120
  "@internals/shared": "0.0.1",
121
- "@kubb/ast": "5.14.4",
121
+ "@kubb/ast": "5.14.5",
122
122
  "@nuxt/kit": "^4.6.2",
123
123
  "@nuxt/schema": "^4.6.2",
124
124
  "@rspack/core": "^2.2.9",