@kubb/plugin-swr 5.0.0-beta.104 → 5.0.0-beta.109

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.cjs CHANGED
@@ -23,7 +23,7 @@ var __copyProps = (to, from, except, desc) => {
23
23
  }
24
24
  return to;
25
25
  };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
27
27
  value: mod,
28
28
  enumerable: true
29
29
  }) : target, mod));
@@ -85,7 +85,7 @@ function operationFileEntry(node, name, extname = ".ts") {
85
85
  */
86
86
  function resolveDependencyOperationFile(options) {
87
87
  const { cache, node, resolver, root, output, group } = options;
88
- return cache.getOrSet(`${resolver.pluginName}:operationFile`, () => resolver.file({
88
+ return cache.ensureItem(`${resolver.pluginName}:operationFile`, () => resolver.file({
89
89
  ...operationFileEntry(node, node.operationId),
90
90
  root,
91
91
  output,
@@ -429,7 +429,7 @@ function resolveContractClient(options) {
429
429
  function resolveClientOperation(options) {
430
430
  const { clientPlugin, driver, node, root, output, cache } = options;
431
431
  if (!clientPlugin) return null;
432
- return cache.getOrSet(`${clientPlugin.pluginName}:clientOperation`, () => {
432
+ return cache.ensureItem(`${clientPlugin.pluginName}:clientOperation`, () => {
433
433
  const resolver = driver.getResolver(clientPlugin.pluginName);
434
434
  const plugin = driver.getPlugin(clientPlugin.pluginName);
435
435
  const file = resolver.file({
@@ -511,14 +511,16 @@ function buildGroupedRequestParam(node, options) {
511
511
  */
512
512
  function buildQueryOptionsParams(node, options) {
513
513
  const { resolver, memberTypeWrapper } = options;
514
- return (0, _kubb_plugin_ts.createFunctionParameters)({ params: [buildGroupedRequestParam(node, {
514
+ const groupedParam = buildGroupedRequestParam(node, {
515
515
  resolver,
516
516
  memberTypeWrapper
517
- }), (0, _kubb_plugin_ts.createFunctionParameter)({
517
+ });
518
+ const configParam = (0, _kubb_plugin_ts.createFunctionParameter)({
518
519
  name: "config",
519
520
  type: `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`,
520
521
  default: "{}"
521
- })].filter((param) => param !== null) });
522
+ });
523
+ return (0, _kubb_plugin_ts.createFunctionParameters)({ params: [groupedParam, configParam].filter((param) => param !== null) });
522
524
  }
523
525
  /**
524
526
  * Builds the call to a client `<op>` function inside a query/mutation hook body. The function takes
@@ -735,10 +737,12 @@ function buildMutationParamsNode(node, options) {
735
737
  const { mutationKeyTypeName, mutationArgTypeName, resolver } = options;
736
738
  const responseName = resolver.response.response(node);
737
739
  const errorNames = resolveErrorNames(node, resolver);
740
+ const TData = responseName;
741
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
738
742
  return (0, _kubb_plugin_ts.createFunctionParameters)({ params: [(0, _kubb_plugin_ts.createFunctionParameter)({
739
743
  name: "options",
740
744
  type: `{
741
- mutation?: SWRMutationConfiguration<${responseName}, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}, ${mutationKeyTypeName} | null, ${mutationArgTypeName}> & { throwOnError?: boolean },
745
+ mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${mutationArgTypeName}> & { throwOnError?: boolean },
742
746
  client?: ${buildRequestConfigType(node)},
743
747
  shouldFetch?: boolean,
744
748
  }`,
@@ -833,17 +837,20 @@ function buildQueryParamsNode(node, options) {
833
837
  const { resolver } = options;
834
838
  const responseName = resolver.response.response(node);
835
839
  const errorNames = resolveErrorNames(node, resolver);
840
+ const TData = responseName;
841
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
836
842
  const optionsParam = (0, _kubb_plugin_ts.createFunctionParameter)({
837
843
  name: "options",
838
844
  type: `{
839
- query?: SWRConfiguration<${[responseName, `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`].join(", ")}>,
845
+ query?: SWRConfiguration<${[TData, TError].join(", ")}>,
840
846
  client?: ${buildClientOptionType()},
841
847
  shouldFetch?: boolean,
842
848
  immutable?: boolean
843
849
  }`,
844
850
  default: "{}"
845
851
  });
846
- return (0, _kubb_plugin_ts.createFunctionParameters)({ params: [buildGroupedRequestParam(node, { resolver }), optionsParam].filter((param) => param !== null) });
852
+ const groupedParam = buildGroupedRequestParam(node, { resolver });
853
+ return (0, _kubb_plugin_ts.createFunctionParameters)({ params: [groupedParam, optionsParam].filter((param) => param !== null) });
847
854
  }
848
855
  function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, tsResolver }) {
849
856
  const responseName = tsResolver.response.response(node);