@kubb/plugin-vue-query 5.10.3 → 5.10.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.
package/dist/index.js CHANGED
@@ -5,11 +5,11 @@ import { File, Function, Type, jsxRenderer } from "@kubb/renderer-jsx";
5
5
  import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
6
6
  // kubb-extension.json
7
7
  var compatibility = {
8
- "kubb": ">=5.18.4",
8
+ "kubb": ">=5.19.0",
9
9
  "node": ">=22.22"
10
10
  };
11
11
  // package.json
12
- var version = "5.10.3";
12
+ var version = "5.10.5";
13
13
  // ../../internals/client/src/resolveClient.ts
14
14
  /**
15
15
  * Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
@@ -313,7 +313,7 @@ function operationFileEntry(node, name, extname = ".ts") {
313
313
  * operation. The plugin itself and every plugin that imports from it call this, so they all get
314
314
  * the same path.
315
315
  *
316
- * When that path matches the file of a component schema in `ctx.driver.inputNode`, ignoring case, the file name
316
+ * When that path matches the file of a component schema in `ctx.schemas`, ignoring case, the file name
317
317
  * gets an `Operation` suffix: operation `point` goes to `PointOperation.ts` next to schema `Point.ts`.
318
318
  * Otherwise the two merge into one file, or overwrite each other on a case-insensitive file system.
319
319
  * Only the file name changes. The declarations keep their names.
@@ -332,7 +332,7 @@ function resolveOperationFile(options) {
332
332
  group: options.group ?? void 0
333
333
  };
334
334
  return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => {
335
- const schemaPaths = memo(`${resolver.pluginName}:schemaFilePaths`, () => new Set((ctx.driver.inputNode?.schemas ?? []).flatMap((schema) => schema.name ? [resolver.file({
335
+ const schemaPaths = memo(`${resolver.pluginName}:schemaFilePaths`, () => new Set(ctx.schemas.flatMap((schema) => schema.name ? [resolver.file({
336
336
  name: schema.name,
337
337
  extname: ".ts",
338
338
  ...location
@@ -601,11 +601,12 @@ function resolveImportPath(options) {
601
601
  * and import path therefore match the `<op>` actually emitted, even when an `override` changes it.
602
602
  */
603
603
  function resolveClientOperation(options) {
604
- const { clientPlugin, driver, node, root, output, memo } = options;
604
+ const { clientPlugin, ctx, node, root, output } = options;
605
+ const { memo } = ctx;
605
606
  if (!clientPlugin) return null;
606
607
  return memo(`${clientPlugin.pluginName}:clientOperation:${node.operationId}`, () => {
607
- const resolver = driver.getResolver(clientPlugin.pluginName);
608
- const pluginOptions = driver.getPlugin(clientPlugin.pluginName)?.options ?? {};
608
+ const resolver = ctx.getResolver(clientPlugin.pluginName);
609
+ const pluginOptions = ctx.getPlugin(clientPlugin.pluginName)?.options ?? {};
609
610
  const { exclude, include, override } = pluginOptions;
610
611
  const operationOptions = Boolean(exclude?.length || include?.length || override?.length) && resolver.default ? resolver.default.options(node, {
611
612
  options: pluginOptions,
@@ -716,16 +717,16 @@ function toZodTypeResolver(resolver) {
716
717
  *
717
718
  * @example
718
719
  * ```ts
719
- * const types = resolveOperationTypes(ctx.driver, ctx.plugin.name)
720
+ * const types = resolveOperationTypes(ctx, ctx.plugin.name)
720
721
  * types.response.options(node) // 'GetPetByIdOptions', or 'GetPetByIdOptionsSchemaType' from zod
721
722
  * ```
722
723
  */
723
- function resolveOperationTypes(driver, pluginName) {
724
- return driver.memo(`operationTypes:${pluginName}`, () => {
725
- const pluginTs = driver.getPlugin(pluginTsName);
726
- const pluginZod = driver.getPlugin(pluginZodName);
724
+ function resolveOperationTypes(ctx, pluginName) {
725
+ return ctx.memo(`operationTypes:${pluginName}`, () => {
726
+ const pluginTs = ctx.getPlugin(pluginTsName);
727
+ const pluginZod = ctx.getPlugin(pluginZodName);
727
728
  if (pluginTs && pluginZod?.options?.inferred !== "codec") {
728
- const resolver = driver.getResolver(pluginTsName);
729
+ const resolver = ctx.getResolver(pluginTsName);
729
730
  return {
730
731
  response: resolver.response,
731
732
  resolver,
@@ -741,7 +742,7 @@ function resolveOperationTypes(driver, pluginName) {
741
742
  location: { kind: "config" },
742
743
  plugin: pluginName
743
744
  });
744
- const resolver = toZodTypeResolver(driver.getResolver(pluginZodName));
745
+ const resolver = toZodTypeResolver(ctx.getResolver(pluginZodName));
745
746
  return {
746
747
  response: resolver.response,
747
748
  resolver,
@@ -766,7 +767,7 @@ function resolveHookFile(node, ctx, options) {
766
767
  location: { kind: "config" },
767
768
  plugin: resolver.pluginName
768
769
  });
769
- const types = resolveOperationTypes(ctx.driver, resolver.pluginName);
770
+ const types = resolveOperationTypes(ctx, resolver.pluginName);
770
771
  const tsResolver = types.resolver;
771
772
  const headerTypeNames = returnType === "data" || !contractOp.typedHeaders ? [] : getResponseHeadersTypeNames({
772
773
  node,
@@ -1624,7 +1625,7 @@ const infiniteQueryGenerator = defineGenerator({
1624
1625
  },
1625
1626
  operation(node, ctx) {
1626
1627
  if (!ast.http.isOperation(node)) return null;
1627
- const { driver, resolver, root } = ctx;
1628
+ const { resolver, root } = ctx;
1628
1629
  const { output, query, infinite, client, group } = ctx.options;
1629
1630
  const infiniteOptions = infinite && typeof infinite === "object" ? infinite : null;
1630
1631
  if (!infiniteOptions) return null;
@@ -1633,11 +1634,10 @@ const infiniteQueryGenerator = defineGenerator({
1633
1634
  const importPath = query ? query.importPath : "@tanstack/vue-query";
1634
1635
  const contractOp = resolveClientOperation({
1635
1636
  clientPlugin: { pluginName: client.pluginName },
1636
- driver,
1637
+ ctx,
1637
1638
  node,
1638
1639
  root,
1639
- output,
1640
- memo: ctx.memo
1640
+ output
1641
1641
  });
1642
1642
  if (!contractOp) return null;
1643
1643
  const queryName = resolver.infiniteQuery.name(node);
@@ -1652,7 +1652,7 @@ const infiniteQueryGenerator = defineGenerator({
1652
1652
  returnType: ctx.options.returnType,
1653
1653
  keyTypeName: queryKeyTypeName,
1654
1654
  extraTypeNames: [resolvePageParamType(node, {
1655
- resolver: resolveOperationTypes(ctx.driver, ctx.resolver.pluginName).resolver,
1655
+ resolver: resolveOperationTypes(ctx, ctx.resolver.pluginName).resolver,
1656
1656
  initialPageParam: infiniteOptions.initialPageParam,
1657
1657
  queryParam: infiniteOptions.queryParam
1658
1658
  }).queryParamsTypeName]
@@ -1832,7 +1832,7 @@ const mutationGenerator = defineGenerator({
1832
1832
  renderer: jsxRenderer,
1833
1833
  operation(node, ctx) {
1834
1834
  if (!ast.http.isOperation(node)) return null;
1835
- const { driver, resolver, root } = ctx;
1835
+ const { resolver, root } = ctx;
1836
1836
  const { output, query, mutation, client, group, hooks } = ctx.options;
1837
1837
  const { isMutation } = classifyOperation(node, {
1838
1838
  query,
@@ -1842,11 +1842,10 @@ const mutationGenerator = defineGenerator({
1842
1842
  const importPath = mutation ? mutation.importPath : "@tanstack/vue-query";
1843
1843
  const contractOp = resolveClientOperation({
1844
1844
  clientPlugin: { pluginName: client.pluginName },
1845
- driver,
1845
+ ctx,
1846
1846
  node,
1847
1847
  root,
1848
- output,
1849
- memo: ctx.memo
1848
+ output
1850
1849
  });
1851
1850
  if (!contractOp) return null;
1852
1851
  const mutationHookName = resolver.mutation.name(node);
@@ -1908,7 +1907,7 @@ const queryGenerator = defineGenerator({
1908
1907
  renderer: jsxRenderer,
1909
1908
  operation(node, ctx) {
1910
1909
  if (!ast.http.isOperation(node)) return null;
1911
- const { driver, resolver, root } = ctx;
1910
+ const { resolver, root } = ctx;
1912
1911
  const { output, query, mutation, client, group, hooks } = ctx.options;
1913
1912
  const { isQuery, isMutation } = classifyOperation(node, {
1914
1913
  query,
@@ -1918,11 +1917,10 @@ const queryGenerator = defineGenerator({
1918
1917
  const importPath = query ? query.importPath : "@tanstack/vue-query";
1919
1918
  const contractOp = resolveClientOperation({
1920
1919
  clientPlugin: { pluginName: client.pluginName },
1921
- driver,
1920
+ ctx,
1922
1921
  node,
1923
1922
  root,
1924
- output,
1925
- memo: ctx.memo
1923
+ output
1926
1924
  });
1927
1925
  if (!contractOp) return null;
1928
1926
  const queryName = resolver.query.name(node);