@kubb/plugin-swr 5.0.0-beta.95 → 5.0.0-beta.98
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 +83 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +82 -82
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { Resolver, ast, createResolver, defineGenerator, definePlugin } from "kubb/kit";
|
|
3
4
|
import { createFunctionParameter, createFunctionParameters, createObjectBindingPattern, createTypeLiteral, functionPrinter, pluginTsName } from "@kubb/plugin-ts";
|
|
4
|
-
import path from "node:path";
|
|
5
5
|
import { File, Function, Type, jsxRenderer } from "kubb/jsx";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
7
7
|
//#region ../../internals/utils/src/casing.ts
|
|
@@ -630,87 +630,6 @@ function resolveClientOperation(options) {
|
|
|
630
630
|
};
|
|
631
631
|
}
|
|
632
632
|
//#endregion
|
|
633
|
-
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
634
|
-
const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
|
|
635
|
-
const mutationKeyTransformer = ({ node }) => {
|
|
636
|
-
if (!node.path) return [];
|
|
637
|
-
return [`{ url: '${Url.toPath(node.path)}' }`];
|
|
638
|
-
};
|
|
639
|
-
function MutationKey$1({ name, node, transformer }) {
|
|
640
|
-
const paramsNode = createFunctionParameters({ params: [] });
|
|
641
|
-
const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
|
|
642
|
-
const keys = (transformer ?? mutationKeyTransformer)({
|
|
643
|
-
node,
|
|
644
|
-
casing: "camelcase"
|
|
645
|
-
});
|
|
646
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
647
|
-
name,
|
|
648
|
-
isExportable: true,
|
|
649
|
-
isIndexable: true,
|
|
650
|
-
children: /* @__PURE__ */ jsx(Function.Arrow, {
|
|
651
|
-
name,
|
|
652
|
-
export: true,
|
|
653
|
-
params: paramsSignature,
|
|
654
|
-
singleLine: true,
|
|
655
|
-
children: `[${keys.join(", ")}] as const`
|
|
656
|
-
})
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
__name(MutationKey$1, "MutationKey");
|
|
660
|
-
//#endregion
|
|
661
|
-
//#region ../../internals/tanstack-query/src/resolver.ts
|
|
662
|
-
/**
|
|
663
|
-
* Builds the shared query namespace for a variant. Spread the result into
|
|
664
|
-
* `createResolver` once per variant the plugin supports.
|
|
665
|
-
*
|
|
666
|
-
* @example
|
|
667
|
-
* ```ts
|
|
668
|
-
* createResolver<PluginReactQuery>({
|
|
669
|
-
* query: createQueryResolver(),
|
|
670
|
-
* suspenseQuery: createQueryResolver('Suspense'),
|
|
671
|
-
* })
|
|
672
|
-
* ```
|
|
673
|
-
*/
|
|
674
|
-
function createQueryResolver(variant = "") {
|
|
675
|
-
return {
|
|
676
|
-
name(node) {
|
|
677
|
-
return `use${capitalize(this.name(node.operationId))}${variant}`;
|
|
678
|
-
},
|
|
679
|
-
optionsName(node) {
|
|
680
|
-
return `${this.name(node.operationId)}${variant}QueryOptions`;
|
|
681
|
-
},
|
|
682
|
-
keyName(node) {
|
|
683
|
-
return `${this.name(node.operationId)}${variant}QueryKey`;
|
|
684
|
-
},
|
|
685
|
-
keyTypeName(node) {
|
|
686
|
-
return `${capitalize(this.name(node.operationId))}${variant}QueryKey`;
|
|
687
|
-
},
|
|
688
|
-
clientName(node) {
|
|
689
|
-
return `${this.name(node.operationId)}${variant}`;
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Builds the shared mutation namespace. Spread the result into
|
|
695
|
-
* `createResolver` and add plugin-specific methods (`optionsName`,
|
|
696
|
-
* `typeName`, `argTypeName`) next to it.
|
|
697
|
-
*
|
|
698
|
-
* @example
|
|
699
|
-
* ```ts
|
|
700
|
-
* createResolver<PluginSwr>({ mutation: { ...createMutationResolver(), argTypeName(node) {...} } })
|
|
701
|
-
* ```
|
|
702
|
-
*/
|
|
703
|
-
function createMutationResolver() {
|
|
704
|
-
return {
|
|
705
|
-
name(node) {
|
|
706
|
-
return `use${capitalize(this.name(node.operationId))}`;
|
|
707
|
-
},
|
|
708
|
-
keyName(node) {
|
|
709
|
-
return `${this.name(node.operationId)}MutationKey`;
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
//#endregion
|
|
714
633
|
//#region ../../internals/tanstack-query/src/utils.ts
|
|
715
634
|
/**
|
|
716
635
|
* The grouped request options, ordered for both the destructured signature and the
|
|
@@ -858,6 +777,87 @@ function buildQueryKeyParams(node, options) {
|
|
|
858
777
|
return createFunctionParameters({ params: groupedParam ? [groupedParam] : [] });
|
|
859
778
|
}
|
|
860
779
|
//#endregion
|
|
780
|
+
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
781
|
+
const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
|
|
782
|
+
const mutationKeyTransformer = ({ node }) => {
|
|
783
|
+
if (!node.path) return [];
|
|
784
|
+
return [`{ url: '${Url.toPath(node.path)}' }`];
|
|
785
|
+
};
|
|
786
|
+
function MutationKey$1({ name, node, transformer }) {
|
|
787
|
+
const paramsNode = createFunctionParameters({ params: [] });
|
|
788
|
+
const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
|
|
789
|
+
const keys = (transformer ?? mutationKeyTransformer)({
|
|
790
|
+
node,
|
|
791
|
+
casing: "camelcase"
|
|
792
|
+
});
|
|
793
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
794
|
+
name,
|
|
795
|
+
isExportable: true,
|
|
796
|
+
isIndexable: true,
|
|
797
|
+
children: /* @__PURE__ */ jsx(Function.Arrow, {
|
|
798
|
+
name,
|
|
799
|
+
export: true,
|
|
800
|
+
params: paramsSignature,
|
|
801
|
+
singleLine: true,
|
|
802
|
+
children: `[${keys.join(", ")}] as const`
|
|
803
|
+
})
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
__name(MutationKey$1, "MutationKey");
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region ../../internals/tanstack-query/src/resolver.ts
|
|
809
|
+
/**
|
|
810
|
+
* Builds the shared query namespace for a variant. Spread the result into
|
|
811
|
+
* `createResolver` once per variant the plugin supports.
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```ts
|
|
815
|
+
* createResolver<PluginReactQuery>({
|
|
816
|
+
* query: createQueryResolver(),
|
|
817
|
+
* suspenseQuery: createQueryResolver('Suspense'),
|
|
818
|
+
* })
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
function createQueryResolver(variant = "") {
|
|
822
|
+
return {
|
|
823
|
+
name(node) {
|
|
824
|
+
return `use${capitalize(this.name(node.operationId))}${variant}`;
|
|
825
|
+
},
|
|
826
|
+
optionsName(node) {
|
|
827
|
+
return `${this.name(node.operationId)}${variant}QueryOptions`;
|
|
828
|
+
},
|
|
829
|
+
keyName(node) {
|
|
830
|
+
return `${this.name(node.operationId)}${variant}QueryKey`;
|
|
831
|
+
},
|
|
832
|
+
keyTypeName(node) {
|
|
833
|
+
return `${capitalize(this.name(node.operationId))}${variant}QueryKey`;
|
|
834
|
+
},
|
|
835
|
+
clientName(node) {
|
|
836
|
+
return `${this.name(node.operationId)}${variant}`;
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Builds the shared mutation namespace. Spread the result into
|
|
842
|
+
* `createResolver` and add plugin-specific methods (`optionsName`,
|
|
843
|
+
* `typeName`, `argTypeName`) next to it.
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```ts
|
|
847
|
+
* createResolver<PluginSwr>({ mutation: { ...createMutationResolver(), argTypeName(node) {...} } })
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
function createMutationResolver() {
|
|
851
|
+
return {
|
|
852
|
+
name(node) {
|
|
853
|
+
return `use${capitalize(this.name(node.operationId))}`;
|
|
854
|
+
},
|
|
855
|
+
keyName(node) {
|
|
856
|
+
return `${this.name(node.operationId)}MutationKey`;
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
//#endregion
|
|
861
861
|
//#region ../../internals/tanstack-query/src/components/QueryKey.tsx
|
|
862
862
|
const declarationPrinter$3 = functionPrinter({ mode: "declaration" });
|
|
863
863
|
const queryKeyTransformer = ({ node }) => {
|