@kubb/plugin-solid-query 3.16.2 → 3.16.4

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 (39) hide show
  1. package/dist/components-CNM6UaoG.js +320 -0
  2. package/dist/components-CNM6UaoG.js.map +1 -0
  3. package/dist/components-LAcBpjX8.cjs +366 -0
  4. package/dist/components-LAcBpjX8.cjs.map +1 -0
  5. package/dist/components.cjs +4 -19
  6. package/dist/components.d.cts +143 -57
  7. package/dist/components.d.ts +143 -57
  8. package/dist/components.js +3 -3
  9. package/dist/generators-DS71XOIi.cjs +199 -0
  10. package/dist/generators-DS71XOIi.cjs.map +1 -0
  11. package/dist/generators-DU74wsZY.js +194 -0
  12. package/dist/generators-DU74wsZY.js.map +1 -0
  13. package/dist/generators.cjs +3 -12
  14. package/dist/generators.d.cts +5 -7
  15. package/dist/generators.d.ts +5 -7
  16. package/dist/generators.js +4 -4
  17. package/dist/index.cjs +97 -128
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +6 -8
  20. package/dist/index.d.ts +6 -8
  21. package/dist/index.js +97 -122
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-C4Kxe-X1.d.ts +1335 -0
  24. package/dist/types-DULzisVA.d.cts +1335 -0
  25. package/package.json +23 -28
  26. package/dist/chunk-DVQAS6QW.cjs +0 -265
  27. package/dist/chunk-DVQAS6QW.cjs.map +0 -1
  28. package/dist/chunk-IH7LFLIP.cjs +0 -161
  29. package/dist/chunk-IH7LFLIP.cjs.map +0 -1
  30. package/dist/chunk-U7KQKXOC.js +0 -159
  31. package/dist/chunk-U7KQKXOC.js.map +0 -1
  32. package/dist/chunk-XXQM3BYJ.js +0 -261
  33. package/dist/chunk-XXQM3BYJ.js.map +0 -1
  34. package/dist/components.cjs.map +0 -1
  35. package/dist/components.js.map +0 -1
  36. package/dist/generators.cjs.map +0 -1
  37. package/dist/generators.js.map +0 -1
  38. package/dist/types-Cx6RgBxP.d.cts +0 -114
  39. package/dist/types-Cx6RgBxP.d.ts +0 -114
@@ -1,159 +0,0 @@
1
- import { QueryKey, QueryOptions, Query } from './chunk-XXQM3BYJ.js';
2
- import { pluginClientName } from '@kubb/plugin-client';
3
- import { Client } from '@kubb/plugin-client/components';
4
- import { createReactGenerator } from '@kubb/plugin-oas';
5
- import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks';
6
- import { getFooter, getBanner } from '@kubb/plugin-oas/utils';
7
- import { pluginTsName } from '@kubb/plugin-ts';
8
- import { pluginZodName } from '@kubb/plugin-zod';
9
- import { useApp, File } from '@kubb/react';
10
- import { difference } from 'remeda';
11
- import { jsxs, jsx, Fragment } from '@kubb/react/jsx-runtime';
12
-
13
- var queryGenerator = createReactGenerator({
14
- name: "svelte-query",
15
- Operation({ options, operation }) {
16
- const {
17
- plugin: {
18
- options: { output }
19
- },
20
- pluginManager
21
- } = useApp();
22
- const oas = useOas();
23
- const { getSchemas, getName, getFile } = useOperationManager();
24
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
25
- const isMutation = difference(["post", "put", "delete", "patch"], options.query ? options.query.methods : []).some((method) => operation.method === method);
26
- const importPath = options.query ? options.query.importPath : "@tanstack/solid-query";
27
- const query = {
28
- name: getName(operation, { type: "function", prefix: "create" }),
29
- typeName: getName(operation, { type: "type" }),
30
- file: getFile(operation, { prefix: "create" })
31
- };
32
- const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
33
- const client = {
34
- name: hasClientPlugin ? getName(operation, {
35
- type: "function",
36
- pluginKey: [pluginClientName]
37
- }) : getName(operation, {
38
- type: "function"
39
- }),
40
- file: getFile(operation, { pluginKey: [pluginClientName] })
41
- };
42
- const queryOptions = {
43
- name: getName(operation, { type: "function", suffix: "QueryOptions" })
44
- };
45
- const queryKey = {
46
- name: getName(operation, { type: "const", suffix: "QueryKey" }),
47
- typeName: getName(operation, { type: "type", suffix: "QueryKey" })
48
- };
49
- const type = {
50
- file: getFile(operation, { pluginKey: [pluginTsName] }),
51
- //todo remove type?
52
- schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
53
- };
54
- const zod = {
55
- file: getFile(operation, { pluginKey: [pluginZodName] }),
56
- schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
57
- };
58
- if (!isQuery || isMutation) {
59
- return null;
60
- }
61
- return /* @__PURE__ */ jsxs(
62
- File,
63
- {
64
- baseName: query.file.baseName,
65
- path: query.file.path,
66
- meta: query.file.meta,
67
- banner: getBanner({ oas, output, config: pluginManager.config }),
68
- footer: getFooter({ oas, output }),
69
- children: [
70
- options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
71
- /* @__PURE__ */ jsx(File.Import, { name: "fetch", path: options.client.importPath }),
72
- !!hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
73
- /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
74
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
75
- /* @__PURE__ */ jsx(
76
- File.Import,
77
- {
78
- name: [
79
- type.schemas.request?.name,
80
- type.schemas.response.name,
81
- type.schemas.pathParams?.name,
82
- type.schemas.queryParams?.name,
83
- type.schemas.headerParams?.name,
84
- ...type.schemas.statusCodes?.map((item) => item.name) || []
85
- ].filter(Boolean),
86
- root: query.file.path,
87
- path: type.file.path,
88
- isTypeOnly: true
89
- }
90
- ),
91
- /* @__PURE__ */ jsx(
92
- QueryKey,
93
- {
94
- name: queryKey.name,
95
- typeName: queryKey.typeName,
96
- operation,
97
- paramsCasing: options.paramsCasing,
98
- pathParamsType: options.pathParamsType,
99
- typeSchemas: type.schemas,
100
- transformer: options.queryKey
101
- }
102
- ),
103
- !hasClientPlugin && /* @__PURE__ */ jsx(
104
- Client,
105
- {
106
- name: client.name,
107
- baseURL: options.client.baseURL,
108
- operation,
109
- typeSchemas: type.schemas,
110
- zodSchemas: zod.schemas,
111
- dataReturnType: options.client.dataReturnType,
112
- paramsCasing: options.paramsCasing,
113
- paramsType: options.paramsType,
114
- pathParamsType: options.pathParamsType,
115
- parser: options.parser
116
- }
117
- ),
118
- /* @__PURE__ */ jsx(File.Import, { name: ["queryOptions"], path: importPath }),
119
- /* @__PURE__ */ jsx(
120
- QueryOptions,
121
- {
122
- name: queryOptions.name,
123
- clientName: client.name,
124
- queryKeyName: queryKey.name,
125
- typeSchemas: type.schemas,
126
- paramsCasing: options.paramsCasing,
127
- paramsType: options.paramsType,
128
- pathParamsType: options.pathParamsType,
129
- dataReturnType: options.client.dataReturnType
130
- }
131
- ),
132
- options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
133
- /* @__PURE__ */ jsx(File.Import, { name: ["createQuery"], path: importPath }),
134
- /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryClient", "UseBaseQueryOptions", "UseQueryResult"], path: importPath, isTypeOnly: true }),
135
- /* @__PURE__ */ jsx(
136
- Query,
137
- {
138
- name: query.name,
139
- queryOptionsName: queryOptions.name,
140
- typeSchemas: type.schemas,
141
- paramsType: options.paramsType,
142
- pathParamsType: options.pathParamsType,
143
- operation,
144
- paramsCasing: options.paramsCasing,
145
- dataReturnType: options.client.dataReturnType,
146
- queryKeyName: queryKey.name,
147
- queryKeyTypeName: queryKey.typeName
148
- }
149
- )
150
- ] })
151
- ]
152
- }
153
- );
154
- }
155
- });
156
-
157
- export { queryGenerator };
158
- //# sourceMappingURL=chunk-U7KQKXOC.js.map
159
- //# sourceMappingURL=chunk-U7KQKXOC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generators/queryGenerator.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAYO,IAAM,iBAAiB,oBAAuC,CAAA;AAAA,EACnE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gBACZ,kBAAkB,YAAa,CAAA,IAAA;AAAA,gBAC/B,aAAa,IAAK,CAAA,OAAA;AAAA,gBAClB,YAAY,OAAQ,CAAA,UAAA;AAAA,gBACpB,gBAAgB,OAAQ,CAAA,cAAA;AAAA,gBACxB,SAAA;AAAA,gBACA,cAAc,OAAQ,CAAA,YAAA;AAAA,gBACtB,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,gBAC/B,cAAc,QAAS,CAAA,IAAA;AAAA,gBACvB,kBAAkB,QAAS,CAAA;AAAA;AAAA;AAC7B,WACF,EAAA;AAAA;AAAA;AAAA,KAEJ;AAAA;AAGN,CAAC","file":"chunk-U7KQKXOC.js","sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSolidQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSolidQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginSolidQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(['post', 'put', 'delete', 'patch'], options.query ? options.query.methods : []).some((method) => operation.method === method)\n const importPath = options.query ? options.query.importPath : '@tanstack/solid-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.queryKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'UseBaseQueryOptions', 'UseQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"]}
@@ -1,261 +0,0 @@
1
- import { File, Function, Type, FunctionParams } from '@kubb/react';
2
- import { isOptional } from '@kubb/oas';
3
- import { getComments, getPathParams } from '@kubb/plugin-oas/utils';
4
- import { URLPath } from '@kubb/core/utils';
5
- import { jsxs, Fragment, jsx } from '@kubb/react/jsx-runtime';
6
- import { Client } from '@kubb/plugin-client/components';
7
-
8
- // src/components/Query.tsx
9
- function getParams({ pathParamsType, paramsCasing, typeSchemas }) {
10
- return FunctionParams.factory({
11
- pathParams: {
12
- mode: pathParamsType === "object" ? "object" : "inlineSpread",
13
- children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing })
14
- },
15
- data: typeSchemas.request?.name ? {
16
- type: typeSchemas.request?.name,
17
- optional: isOptional(typeSchemas.request?.schema)
18
- } : void 0,
19
- params: typeSchemas.queryParams?.name ? {
20
- type: typeSchemas.queryParams?.name,
21
- optional: isOptional(typeSchemas.queryParams?.schema)
22
- } : void 0
23
- });
24
- }
25
- var getTransformer = ({ operation, schemas, casing }) => {
26
- const path = new URLPath(operation.path, { casing });
27
- const keys = [
28
- path.toObject({
29
- type: "path",
30
- stringify: true
31
- }),
32
- schemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
33
- schemas.request?.name ? "...(data ? [data] : [])" : void 0
34
- ].filter(Boolean);
35
- return keys;
36
- };
37
- function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
38
- const params = getParams({ pathParamsType, paramsCasing, typeSchemas });
39
- const keys = transformer({
40
- operation,
41
- schemas: typeSchemas,
42
- casing: paramsCasing
43
- });
44
- return /* @__PURE__ */ jsxs(Fragment, { children: [
45
- /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keys.join(", ")}] as const` }) }),
46
- /* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })
47
- ] });
48
- }
49
- QueryKey.getParams = getParams;
50
- QueryKey.getTransformer = getTransformer;
51
- function getParams2({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
52
- if (paramsType === "object") {
53
- return FunctionParams.factory({
54
- data: {
55
- mode: "object",
56
- children: {
57
- ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
58
- data: typeSchemas.request?.name ? {
59
- type: typeSchemas.request?.name,
60
- optional: isOptional(typeSchemas.request?.schema)
61
- } : void 0,
62
- params: typeSchemas.queryParams?.name ? {
63
- type: typeSchemas.queryParams?.name,
64
- optional: isOptional(typeSchemas.queryParams?.schema)
65
- } : void 0,
66
- headers: typeSchemas.headerParams?.name ? {
67
- type: typeSchemas.headerParams?.name,
68
- optional: isOptional(typeSchemas.headerParams?.schema)
69
- } : void 0
70
- }
71
- },
72
- config: {
73
- type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
74
- default: "{}"
75
- }
76
- });
77
- }
78
- return FunctionParams.factory({
79
- pathParams: typeSchemas.pathParams?.name ? {
80
- mode: pathParamsType === "object" ? "object" : "inlineSpread",
81
- children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
82
- optional: isOptional(typeSchemas.pathParams?.schema)
83
- } : void 0,
84
- data: typeSchemas.request?.name ? {
85
- type: typeSchemas.request?.name,
86
- optional: isOptional(typeSchemas.request?.schema)
87
- } : void 0,
88
- params: typeSchemas.queryParams?.name ? {
89
- type: typeSchemas.queryParams?.name,
90
- optional: isOptional(typeSchemas.queryParams?.schema)
91
- } : void 0,
92
- headers: typeSchemas.headerParams?.name ? {
93
- type: typeSchemas.headerParams?.name,
94
- optional: isOptional(typeSchemas.headerParams?.schema)
95
- } : void 0,
96
- config: {
97
- type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
98
- default: "{}"
99
- }
100
- });
101
- }
102
- function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }) {
103
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
104
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
105
- const params = getParams2({ paramsType, paramsCasing, pathParamsType, typeSchemas });
106
- const clientParams = Client.getParams({
107
- paramsCasing,
108
- typeSchemas,
109
- paramsType,
110
- pathParamsType,
111
- isConfigurable: true
112
- });
113
- const queryKeyParams = QueryKey.getParams({
114
- pathParamsType,
115
- paramsCasing,
116
- typeSchemas
117
- });
118
- const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
119
- const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
120
- return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params: params.toConstructor(), children: `
121
- const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
122
- return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
123
- ${enabledText}
124
- queryKey,
125
- queryFn: async ({ signal }) => {
126
- config.signal = signal
127
- return ${clientName}(${clientParams.toCall()})
128
- },
129
- })
130
- ` }) });
131
- }
132
- QueryOptions.getParams = getParams2;
133
- function getParams3({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
134
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
135
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
136
- if (paramsType === "object") {
137
- return FunctionParams.factory({
138
- data: {
139
- mode: "object",
140
- children: {
141
- ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
142
- data: typeSchemas.request?.name ? {
143
- type: typeSchemas.request?.name,
144
- optional: isOptional(typeSchemas.request?.schema)
145
- } : void 0,
146
- params: typeSchemas.queryParams?.name ? {
147
- type: typeSchemas.queryParams?.name,
148
- optional: isOptional(typeSchemas.queryParams?.schema)
149
- } : void 0,
150
- headers: typeSchemas.headerParams?.name ? {
151
- type: typeSchemas.headerParams?.name,
152
- optional: isOptional(typeSchemas.headerParams?.schema)
153
- } : void 0
154
- }
155
- },
156
- options: {
157
- type: `
158
- {
159
- query?: Partial<UseBaseQueryOptions<${[TData, TError, "TData", "TQueryData", "TQueryKey"].join(", ")}>> & { client?: QueryClient },
160
- client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
161
- }
162
- `,
163
- default: "{}"
164
- }
165
- });
166
- }
167
- return FunctionParams.factory({
168
- pathParams: typeSchemas.pathParams?.name ? {
169
- mode: pathParamsType === "object" ? "object" : "inlineSpread",
170
- children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
171
- optional: isOptional(typeSchemas.pathParams?.schema)
172
- } : void 0,
173
- data: typeSchemas.request?.name ? {
174
- type: typeSchemas.request?.name,
175
- optional: isOptional(typeSchemas.request?.schema)
176
- } : void 0,
177
- params: typeSchemas.queryParams?.name ? {
178
- type: typeSchemas.queryParams?.name,
179
- optional: isOptional(typeSchemas.queryParams?.schema)
180
- } : void 0,
181
- headers: typeSchemas.headerParams?.name ? {
182
- type: typeSchemas.headerParams?.name,
183
- optional: isOptional(typeSchemas.headerParams?.schema)
184
- } : void 0,
185
- options: {
186
- type: `
187
- {
188
- query?: Partial<UseBaseQueryOptions<${[TData, TError, "TData", "TQueryData", "TQueryKey"].join(", ")}>> & { client?: QueryClient },
189
- client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
190
- }
191
- `,
192
- default: "{}"
193
- }
194
- });
195
- }
196
- function Query({
197
- name,
198
- queryKeyTypeName,
199
- queryOptionsName,
200
- queryKeyName,
201
- paramsCasing,
202
- paramsType,
203
- pathParamsType,
204
- dataReturnType,
205
- typeSchemas,
206
- operation
207
- }) {
208
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
209
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
210
- const returnType = `UseQueryResult<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
211
- const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
212
- const queryKeyParams = QueryKey.getParams({
213
- pathParamsType,
214
- typeSchemas,
215
- paramsCasing
216
- });
217
- const queryOptionsParams = QueryOptions.getParams({
218
- paramsType,
219
- paramsCasing,
220
- pathParamsType,
221
- typeSchemas
222
- });
223
- const params = getParams3({
224
- paramsCasing,
225
- paramsType,
226
- pathParamsType,
227
- dataReturnType,
228
- typeSchemas
229
- });
230
- const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as UseBaseQueryOptions`;
231
- return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(
232
- Function,
233
- {
234
- name,
235
- export: true,
236
- generics: generics.join(", "),
237
- params: params.toConstructor(),
238
- JSDoc: {
239
- comments: getComments(operation)
240
- },
241
- children: `
242
- const { query: { client: queryClient, ...queryOptions } = {}, client: config = {} } = options ?? {}
243
- const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
244
-
245
- const query = createQuery(() => ({
246
- ...${queryOptions},
247
- queryKey,
248
- initialData: null,
249
- ...queryOptions as unknown as Omit<UseBaseQueryOptions, "queryKey">
250
- }), queryClient? () => queryClient: undefined) as ${returnType}
251
-
252
- return query
253
- `
254
- }
255
- ) });
256
- }
257
- Query.getParams = getParams3;
258
-
259
- export { Query, QueryKey, QueryOptions };
260
- //# sourceMappingURL=chunk-XXQM3BYJ.js.map
261
- //# sourceMappingURL=chunk-XXQM3BYJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"names":["getParams","FunctionParams","getPathParams","isOptional","jsx","File","Function"],"mappings":";;;;;;;;AAyBA,SAAS,SAAU,CAAA,EAAE,cAAgB,EAAA,YAAA,EAAc,aAA+B,EAAA;AAChF,EAAA,OAAO,eAAe,OAAQ,CAAA;AAAA,IAC5B,UAAY,EAAA;AAAA,MACV,IAA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AAI,cAAe,CAAA,MAAA,EAAQ,CAAA;;AAAA;AAAA,WAAA,EAG9E,YAAY,CAAA;AAAA;AAAA;AAAA;AAAA,yDAAA,EAIkC,UAAU;;AAAA;AAAA,OAAA;AAAA;AAAA,GAKjE,EAAA,CAAA;AAEJ;AAEA,KAAA,CAAM,SAAYN,GAAAA,UAAAA","file":"chunk-XXQM3BYJ.js","sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\n\ntype Props = {\n name: string\n clientName: string\n queryKeyName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n typeSchemas,\n paramsType,\n pathParamsType,\n isConfigurable: true,\n })\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n paramsCasing,\n typeSchemas,\n })\n\n const enabled = Object.entries(queryKeyParams.flatParams)\n .map(([key, item]) => (item && !item.optional ? key : undefined))\n .filter(Boolean)\n .join('&& ')\n\n const enabledText = enabled ? `enabled: !!(${enabled}),` : ''\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({\n ${enabledText}\n queryKey,\n queryFn: async ({ signal }) => {\n config.signal = signal\n return ${clientName}(${clientParams.toCall()})\n },\n })\n`}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n queryKeyTypeName,\n queryOptionsName,\n queryKeyName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const returnType = `UseQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`\n const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const queryOptionsParams = QueryOptions.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as UseBaseQueryOptions`\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={generics.join(', ')}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: { client: queryClient, ...queryOptions } = {}, client: config = {} } = options ?? {}\n const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})\n\n const query = createQuery(() => ({\n ...${queryOptions},\n queryKey,\n initialData: null,\n ...queryOptions as unknown as Omit<UseBaseQueryOptions, \"queryKey\">\n }), queryClient? () => queryClient: undefined) as ${returnType}\n\n return query\n `}\n </Function>\n </File.Source>\n )\n}\n\nQuery.getParams = getParams\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
@@ -1,114 +0,0 @@
1
- import { Output, Group, PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
2
- import { Oas, contentType, Operation, HttpMethod } from '@kubb/oas';
3
- import { PluginClient } from '@kubb/plugin-client';
4
- import { Exclude, Include, Override, ResolvePathOptions, OperationSchemas, Generator } from '@kubb/plugin-oas';
5
-
6
- type TransformerProps = {
7
- operation: Operation;
8
- schemas: OperationSchemas;
9
- casing: 'camelcase' | undefined;
10
- };
11
- type Transformer = (props: TransformerProps) => unknown[];
12
- /**
13
- * Customize the queryKey
14
- */
15
- type QueryKey = Transformer;
16
- type Query = {
17
- /**
18
- * Define which HttpMethods can be used for queries
19
- * @default ['get']
20
- */
21
- methods: Array<HttpMethod>;
22
- /**
23
- * Path to the useQuery that will be used to do the useQuery functionality.
24
- * It will be used as `import { useQuery } from '${importPath}'`.
25
- * It allows both relative and absolute path.
26
- * the path will be applied as is, so relative path should be based on the file being generated.
27
- * @default '@tanstack/svelte-query'
28
- */
29
- importPath?: string;
30
- };
31
- type Options = {
32
- /**
33
- * Specify the export location for the files and define the behavior of the output
34
- * @default { path: 'hooks', barrelType: 'named' }
35
- */
36
- output?: Output<Oas>;
37
- /**
38
- * Define which contentType should be used.
39
- * By default, the first JSON valid mediaType will be used
40
- */
41
- contentType?: contentType;
42
- /**
43
- * Group the @tanstack/query hooks based on the provided name.
44
- */
45
- group?: Group;
46
- client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
47
- /**
48
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
49
- */
50
- exclude?: Array<Exclude>;
51
- /**
52
- * Array containing include parameters to include tags/operations/methods/paths.
53
- */
54
- include?: Array<Include>;
55
- /**
56
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
57
- */
58
- override?: Array<Override<ResolvedOptions>>;
59
- /**
60
- * How to style your params, by default no casing is applied
61
- * - 'camelcase' will use camelcase for the params names
62
- */
63
- paramsCasing?: 'camelcase';
64
- /**
65
- * How to pass your params
66
- * - 'object' will return the params and pathParams as an object.
67
- * - 'inline' will return the params as comma separated params.
68
- * @default 'inline'
69
- */
70
- paramsType?: 'object' | 'inline';
71
- /**
72
- * How to pass your pathParams.
73
- * - 'object' will return the pathParams as an object.
74
- * - 'inline' will return the pathParams as comma separated params.
75
- * @default 'inline'
76
- */
77
- pathParamsType?: PluginClient['options']['pathParamsType'];
78
- queryKey?: QueryKey;
79
- /**
80
- * Override some useQuery behaviours.
81
- */
82
- query?: Partial<Query> | false;
83
- /**
84
- * Which parser should be used before returning the data to `@tanstack/query`.
85
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
86
- */
87
- parser?: PluginClient['options']['parser'];
88
- transformers?: {
89
- /**
90
- * Customize the names based on the type that is provided by the plugin.
91
- */
92
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
93
- };
94
- /**
95
- * Define some generators next to the solid-query generators
96
- */
97
- generators?: Array<Generator<PluginSolidQuery>>;
98
- };
99
- type ResolvedOptions = {
100
- output: Output<Oas>;
101
- group: Options['group'];
102
- client: Required<Omit<NonNullable<PluginSolidQuery['options']['client']>, 'baseURL'>> & {
103
- baseURL?: string;
104
- };
105
- parser: Required<NonNullable<Options['parser']>>;
106
- paramsCasing: Options['paramsCasing'];
107
- paramsType: NonNullable<Options['paramsType']>;
108
- pathParamsType: NonNullable<Options['pathParamsType']>;
109
- queryKey: QueryKey | undefined;
110
- query: NonNullable<Required<Query>> | false;
111
- };
112
- type PluginSolidQuery = PluginFactoryOptions<'plugin-solid-query', Options, ResolvedOptions, never, ResolvePathOptions>;
113
-
114
- export type { Options as O, PluginSolidQuery as P, Transformer as T };