feat: add axios

This commit is contained in:
Константин Уколов 2024-07-31 10:53:01 +03:00
parent 9d44b23565
commit 112dd2358a
25 changed files with 629 additions and 457 deletions

View File

@ -4,7 +4,7 @@ export default defineConfig({
cakes: { cakes: {
output: { output: {
mode: 'tags-split', mode: 'tags-split',
target: 'src/cakes.ts', target: 'src/shared/api',
schemas: 'src/shared/model', schemas: 'src/shared/model',
client: 'vue-query', client: 'vue-query',
// mock: true, // mock: true,

View File

@ -10,7 +10,8 @@
"postinstall": "nuxt prepare" "postinstall": "nuxt prepare"
}, },
"dependencies": { "dependencies": {
"@tanstack/vue-query": "^5.51.15" "@tanstack/vue-query": "^5.51.15",
"axios": "^1.7.2"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^2.24.0", "@antfu/eslint-config": "^2.24.0",

View File

@ -8,6 +8,9 @@ dependencies:
'@tanstack/vue-query': '@tanstack/vue-query':
specifier: ^5.51.15 specifier: ^5.51.15
version: 5.51.15(vue@3.4.34) version: 5.51.15(vue@3.4.34)
axios:
specifier: ^1.7.2
version: 1.7.2
devDependencies: devDependencies:
'@antfu/eslint-config': '@antfu/eslint-config':
@ -21,7 +24,7 @@ devDependencies:
version: 0.4.0(eslint@9.5.0)(typescript@5.5.4)(vite@5.3.5) version: 0.4.0(eslint@9.5.0)(typescript@5.5.4)(vite@5.3.5)
'@nuxt/ui': '@nuxt/ui':
specifier: ^2.17.0 specifier: ^2.17.0
version: 2.18.2(vite@5.3.5)(vue@3.4.34) version: 2.18.2(axios@1.7.2)(vite@5.3.5)(vue@3.4.34)
'@unocss/eslint-plugin': '@unocss/eslint-plugin':
specifier: ^0.61.6 specifier: ^0.61.6
version: 0.61.7(eslint@9.5.0)(typescript@5.5.4) version: 0.61.7(eslint@9.5.0)(typescript@5.5.4)
@ -2123,7 +2126,7 @@ packages:
- supports-color - supports-color
dev: true dev: true
/@nuxt/ui@2.18.2(vite@5.3.5)(vue@3.4.34): /@nuxt/ui@2.18.2(axios@1.7.2)(vite@5.3.5)(vue@3.4.34):
resolution: {integrity: sha512-azij3fV1FkEMG+sgTMEQiXkJMnII3HNQE+3r8g9QhUgO7iZ13TlUkXl0iYd+U/cGa4aZYki6WXJ45WyETtV/IA==} resolution: {integrity: sha512-azij3fV1FkEMG+sgTMEQiXkJMnII3HNQE+3r8g9QhUgO7iZ13TlUkXl0iYd+U/cGa4aZYki6WXJ45WyETtV/IA==}
engines: {node: '>=v16.20.2'} engines: {node: '>=v16.20.2'}
dependencies: dependencies:
@ -2140,7 +2143,7 @@ packages:
'@tailwindcss/forms': 0.5.7(tailwindcss@3.4.7) '@tailwindcss/forms': 0.5.7(tailwindcss@3.4.7)
'@tailwindcss/typography': 0.5.13(tailwindcss@3.4.7) '@tailwindcss/typography': 0.5.13(tailwindcss@3.4.7)
'@vueuse/core': 10.11.0(vue@3.4.34) '@vueuse/core': 10.11.0(vue@3.4.34)
'@vueuse/integrations': 10.11.0(fuse.js@6.6.2)(vue@3.4.34) '@vueuse/integrations': 10.11.0(axios@1.7.2)(fuse.js@6.6.2)(vue@3.4.34)
'@vueuse/math': 10.11.0(vue@3.4.34) '@vueuse/math': 10.11.0(vue@3.4.34)
defu: 6.1.4 defu: 6.1.4
fuse.js: 6.6.2 fuse.js: 6.6.2
@ -4239,7 +4242,7 @@ packages:
- vue - vue
dev: true dev: true
/@vueuse/integrations@10.11.0(fuse.js@6.6.2)(vue@3.4.34): /@vueuse/integrations@10.11.0(axios@1.7.2)(fuse.js@6.6.2)(vue@3.4.34):
resolution: {integrity: sha512-Pp6MtWEIr+NDOccWd8j59Kpjy5YDXogXI61Kb1JxvSfVBO8NzFQkmrKmSZz47i+ZqHnIzxaT38L358yDHTncZg==} resolution: {integrity: sha512-Pp6MtWEIr+NDOccWd8j59Kpjy5YDXogXI61Kb1JxvSfVBO8NzFQkmrKmSZz47i+ZqHnIzxaT38L358yDHTncZg==}
peerDependencies: peerDependencies:
async-validator: ^4 async-validator: ^4
@ -4282,6 +4285,7 @@ packages:
dependencies: dependencies:
'@vueuse/core': 10.11.0(vue@3.4.34) '@vueuse/core': 10.11.0(vue@3.4.34)
'@vueuse/shared': 10.11.0(vue@3.4.34) '@vueuse/shared': 10.11.0(vue@3.4.34)
axios: 1.7.2
fuse.js: 6.6.2 fuse.js: 6.6.2
vue-demi: 0.14.10(vue@3.4.34) vue-demi: 0.14.10(vue@3.4.34)
transitivePeerDependencies: transitivePeerDependencies:
@ -4713,6 +4717,9 @@ packages:
resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==}
dev: true dev: true
/asynckit@0.4.0:
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
/at-least-node@1.0.0: /at-least-node@1.0.0:
resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==}
engines: {node: '>= 4.0.0'} engines: {node: '>= 4.0.0'}
@ -4741,6 +4748,15 @@ packages:
possible-typed-array-names: 1.0.0 possible-typed-array-names: 1.0.0
dev: true dev: true
/axios@1.7.2:
resolution: {integrity: sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==}
dependencies:
follow-redirects: 1.15.6
form-data: 4.0.0
proxy-from-env: 1.1.0
transitivePeerDependencies:
- debug
/b4a@1.6.6: /b4a@1.6.6:
resolution: {integrity: sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==} resolution: {integrity: sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==}
dev: true dev: true
@ -5079,6 +5095,12 @@ packages:
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
dev: true dev: true
/combined-stream@1.0.8:
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
engines: {node: '>= 0.8'}
dependencies:
delayed-stream: 1.0.0
/commander@2.20.3: /commander@2.20.3:
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
dev: true dev: true
@ -5496,6 +5518,10 @@ packages:
resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==}
dev: true dev: true
/delayed-stream@1.0.0:
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
engines: {node: '>=0.4.0'}
/delegates@1.0.0: /delegates@1.0.0:
resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==} resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==}
dev: true dev: true
@ -6609,6 +6635,15 @@ packages:
resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==} resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}
dev: true dev: true
/follow-redirects@1.15.6:
resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==}
engines: {node: '>=4.0'}
peerDependencies:
debug: '*'
peerDependenciesMeta:
debug:
optional: true
/for-each@0.3.3: /for-each@0.3.3:
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
dependencies: dependencies:
@ -6623,6 +6658,14 @@ packages:
signal-exit: 4.1.0 signal-exit: 4.1.0
dev: true dev: true
/form-data@4.0.0:
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
engines: {node: '>= 6'}
dependencies:
asynckit: 0.4.0
combined-stream: 1.0.8
mime-types: 2.1.35
/fraction.js@4.3.7: /fraction.js@4.3.7:
resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==}
dev: true dev: true
@ -7992,14 +8035,12 @@ packages:
/mime-db@1.52.0: /mime-db@1.52.0:
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: true
/mime-types@2.1.35: /mime-types@2.1.35:
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dependencies: dependencies:
mime-db: 1.52.0 mime-db: 1.52.0
dev: true
/mime@1.6.0: /mime@1.6.0:
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
@ -9391,6 +9432,9 @@ packages:
resolution: {integrity: sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==} resolution: {integrity: sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==}
dev: true dev: true
/proxy-from-env@1.1.0:
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
/punycode@2.3.1: /punycode@2.3.1:
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'} engines: {node: '>=6'}

View File

@ -1,327 +0,0 @@
/**
* Generated by orval v6.31.0 🍺
* Do not edit manually.
* main.proto
* OpenAPI spec version: version not set
*/
import {
useMutation,
useQuery,
} from '@tanstack/vue-query'
import type {
MutationFunction,
QueryFunction,
QueryKey,
UseMutationOptions,
UseMutationReturnType,
UseQueryOptions,
UseQueryReturnType,
} from '@tanstack/vue-query'
import axios from 'axios'
import type {
AxiosError,
AxiosRequestConfig,
AxiosResponse,
} from 'axios'
import {
computed,
unref,
} from 'vue'
import type {
MaybeRef,
} from 'vue'
import type {
ApiHttpBody,
CRMSearchParams,
CrabscrmOrder,
CrmBreadcrumbsRsp,
CrmCartRsp,
CrmCatalogRsp,
CrmOrderItem,
CrmOrderRsp,
CrmPositionsRsp,
CrmProductRsp,
RpcStatus,
} from '.././shared/model'
export function cRMGetCart(crmOrderItem: MaybeRef<CrmOrderItem[]>, options?: AxiosRequestConfig): Promise<AxiosResponse<CrmCartRsp>> {
crmOrderItem = unref(crmOrderItem)
return axios.post(
`/cart`,
crmOrderItem,
options,
)
}
export function getCRMGetCartMutationOptions<TError = AxiosError<RpcStatus>, TContext = unknown>(options?: { mutation?: UseMutationOptions<Awaited<ReturnType<typeof cRMGetCart>>, TError, { data: CrmOrderItem[] }, TContext>, axios?: AxiosRequestConfig }): UseMutationOptions<Awaited<ReturnType<typeof cRMGetCart>>, TError, { data: CrmOrderItem[] }, TContext> {
const { mutation: mutationOptions, axios: axiosOptions } = options ?? {}
const mutationFn: MutationFunction<Awaited<ReturnType<typeof cRMGetCart>>, { data: CrmOrderItem[] }> = (props) => {
const { data } = props ?? {}
return cRMGetCart(data, axiosOptions)
}
return { mutationFn, ...mutationOptions }
}
export type CRMGetCartMutationResult = NonNullable<Awaited<ReturnType<typeof cRMGetCart>>>
export type CRMGetCartMutationBody = CrmOrderItem[]
export type CRMGetCartMutationError = AxiosError<RpcStatus>
export function useCRMGetCart<TError = AxiosError<RpcStatus>, TContext = unknown>(options?: { mutation?: UseMutationOptions<Awaited<ReturnType<typeof cRMGetCart>>, TError, { data: CrmOrderItem[] }, TContext>, axios?: AxiosRequestConfig }): UseMutationReturnType<
Awaited<ReturnType<typeof cRMGetCart>>,
TError,
{ data: CrmOrderItem[] },
TContext
> {
const mutationOptions = getCRMGetCartMutationOptions(options)
return useMutation(mutationOptions)
}
export function cRMGetCatalog(options?: AxiosRequestConfig): Promise<AxiosResponse<CrmCatalogRsp>> {
return axios.get(
`/catalog`,
options,
)
}
export function getCRMGetCatalogQueryKey() {
return ['catalog'] as const
}
export function getCRMGetCatalogQueryOptions<TData = Awaited<ReturnType<typeof cRMGetCatalog>>, TError = AxiosError<RpcStatus>>(options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetCatalog>>, TError, TData>>, axios?: AxiosRequestConfig }) {
const { query: queryOptions, axios: axiosOptions } = options ?? {}
const queryKey = getCRMGetCatalogQueryKey()
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetCatalog>>> = ({ signal }) => cRMGetCatalog({ signal, ...axiosOptions })
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<Awaited<ReturnType<typeof cRMGetCatalog>>, TError, TData>
}
export type CRMGetCatalogQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetCatalog>>>
export type CRMGetCatalogQueryError = AxiosError<RpcStatus>
export function useCRMGetCatalog<TData = Awaited<ReturnType<typeof cRMGetCatalog>>, TError = AxiosError<RpcStatus>>(options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetCatalog>>, TError, TData>>, axios?: AxiosRequestConfig }): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getCRMGetCatalogQueryOptions(options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey }
query.queryKey = unref(queryOptions).queryKey as QueryKey
return query
}
export function cRMGetImage(name: MaybeRef<string>, options?: AxiosRequestConfig): Promise<AxiosResponse<ApiHttpBody>> {
name = unref(name)
return axios.get(
`/images/${name}`,
options,
)
}
export function getCRMGetImageQueryKey(name: MaybeRef<string>) {
return ['images', name] as const
}
export function getCRMGetImageQueryOptions<TData = Awaited<ReturnType<typeof cRMGetImage>>, TError = AxiosError<RpcStatus>>(name: MaybeRef<string>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetImage>>, TError, TData>>, axios?: AxiosRequestConfig }) {
const { query: queryOptions, axios: axiosOptions } = options ?? {}
const queryKey = getCRMGetImageQueryKey(name)
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetImage>>> = ({ signal }) => cRMGetImage(name, { signal, ...axiosOptions })
return { queryKey, queryFn, enabled: computed(() => !!(unref(name))), ...queryOptions } as UseQueryOptions<Awaited<ReturnType<typeof cRMGetImage>>, TError, TData>
}
export type CRMGetImageQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetImage>>>
export type CRMGetImageQueryError = AxiosError<RpcStatus>
export function useCRMGetImage<TData = Awaited<ReturnType<typeof cRMGetImage>>, TError = AxiosError<RpcStatus>>(name: MaybeRef<string>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetImage>>, TError, TData>>, axios?: AxiosRequestConfig }): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getCRMGetImageQueryOptions(name, options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey }
query.queryKey = unref(queryOptions).queryKey as QueryKey
return query
}
export function cRMOrder(crabscrmOrder: MaybeRef<CrabscrmOrder>, options?: AxiosRequestConfig): Promise<AxiosResponse<CrmOrderRsp>> {
crabscrmOrder = unref(crabscrmOrder)
return axios.post(
`/orders`,
crabscrmOrder,
options,
)
}
export function getCRMOrderMutationOptions<TError = AxiosError<RpcStatus>, TContext = unknown>(options?: { mutation?: UseMutationOptions<Awaited<ReturnType<typeof cRMOrder>>, TError, { data: CrabscrmOrder }, TContext>, axios?: AxiosRequestConfig }): UseMutationOptions<Awaited<ReturnType<typeof cRMOrder>>, TError, { data: CrabscrmOrder }, TContext> {
const { mutation: mutationOptions, axios: axiosOptions } = options ?? {}
const mutationFn: MutationFunction<Awaited<ReturnType<typeof cRMOrder>>, { data: CrabscrmOrder }> = (props) => {
const { data } = props ?? {}
return cRMOrder(data, axiosOptions)
}
return { mutationFn, ...mutationOptions }
}
export type CRMOrderMutationResult = NonNullable<Awaited<ReturnType<typeof cRMOrder>>>
export type CRMOrderMutationBody = CrabscrmOrder
export type CRMOrderMutationError = AxiosError<RpcStatus>
export function useCRMOrder<TError = AxiosError<RpcStatus>, TContext = unknown>(options?: { mutation?: UseMutationOptions<Awaited<ReturnType<typeof cRMOrder>>, TError, { data: CrabscrmOrder }, TContext>, axios?: AxiosRequestConfig }): UseMutationReturnType<
Awaited<ReturnType<typeof cRMOrder>>,
TError,
{ data: CrabscrmOrder },
TContext
> {
const mutationOptions = getCRMOrderMutationOptions(options)
return useMutation(mutationOptions)
}
export function cRMGetPositions(id: MaybeRef<string>, options?: AxiosRequestConfig): Promise<AxiosResponse<CrmPositionsRsp>> {
id = unref(id)
return axios.get(
`/positions/${id}`,
options,
)
}
export function getCRMGetPositionsQueryKey(id: MaybeRef<string>) {
return ['positions', id] as const
}
export function getCRMGetPositionsQueryOptions<TData = Awaited<ReturnType<typeof cRMGetPositions>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetPositions>>, TError, TData>>, axios?: AxiosRequestConfig }) {
const { query: queryOptions, axios: axiosOptions } = options ?? {}
const queryKey = getCRMGetPositionsQueryKey(id)
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetPositions>>> = ({ signal }) => cRMGetPositions(id, { signal, ...axiosOptions })
return { queryKey, queryFn, enabled: computed(() => !!(unref(id))), ...queryOptions } as UseQueryOptions<Awaited<ReturnType<typeof cRMGetPositions>>, TError, TData>
}
export type CRMGetPositionsQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetPositions>>>
export type CRMGetPositionsQueryError = AxiosError<RpcStatus>
export function useCRMGetPositions<TData = Awaited<ReturnType<typeof cRMGetPositions>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetPositions>>, TError, TData>>, axios?: AxiosRequestConfig }): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getCRMGetPositionsQueryOptions(id, options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey }
query.queryKey = unref(queryOptions).queryKey as QueryKey
return query
}
export function cRMGetProduct(id: MaybeRef<string>, options?: AxiosRequestConfig): Promise<AxiosResponse<CrmProductRsp>> {
id = unref(id)
return axios.get(
`/products/${id}`,
options,
)
}
export function getCRMGetProductQueryKey(id: MaybeRef<string>) {
return ['products', id] as const
}
export function getCRMGetProductQueryOptions<TData = Awaited<ReturnType<typeof cRMGetProduct>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetProduct>>, TError, TData>>, axios?: AxiosRequestConfig }) {
const { query: queryOptions, axios: axiosOptions } = options ?? {}
const queryKey = getCRMGetProductQueryKey(id)
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetProduct>>> = ({ signal }) => cRMGetProduct(id, { signal, ...axiosOptions })
return { queryKey, queryFn, enabled: computed(() => !!(unref(id))), ...queryOptions } as UseQueryOptions<Awaited<ReturnType<typeof cRMGetProduct>>, TError, TData>
}
export type CRMGetProductQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetProduct>>>
export type CRMGetProductQueryError = AxiosError<RpcStatus>
export function useCRMGetProduct<TData = Awaited<ReturnType<typeof cRMGetProduct>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetProduct>>, TError, TData>>, axios?: AxiosRequestConfig }): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getCRMGetProductQueryOptions(id, options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey }
query.queryKey = unref(queryOptions).queryKey as QueryKey
return query
}
export function cRMGetBreadcrumbs(id: MaybeRef<string>, options?: AxiosRequestConfig): Promise<AxiosResponse<CrmBreadcrumbsRsp>> {
id = unref(id)
return axios.get(
`/products/${id}/breadcrumbs`,
options,
)
}
export function getCRMGetBreadcrumbsQueryKey(id: MaybeRef<string>) {
return ['products', id, 'breadcrumbs'] as const
}
export function getCRMGetBreadcrumbsQueryOptions<TData = Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError, TData>>, axios?: AxiosRequestConfig }) {
const { query: queryOptions, axios: axiosOptions } = options ?? {}
const queryKey = getCRMGetBreadcrumbsQueryKey(id)
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>> = ({ signal }) => cRMGetBreadcrumbs(id, { signal, ...axiosOptions })
return { queryKey, queryFn, enabled: computed(() => !!(unref(id))), ...queryOptions } as UseQueryOptions<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError, TData>
}
export type CRMGetBreadcrumbsQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>>
export type CRMGetBreadcrumbsQueryError = AxiosError<RpcStatus>
export function useCRMGetBreadcrumbs<TData = Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError, TData>>, axios?: AxiosRequestConfig }): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getCRMGetBreadcrumbsQueryOptions(id, options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey }
query.queryKey = unref(queryOptions).queryKey as QueryKey
return query
}
export function cRMSearch(params?: MaybeRef<CRMSearchParams>, options?: AxiosRequestConfig): Promise<AxiosResponse<CrmPositionsRsp>> {
params = unref(params)
return axios.get(
`/search`,
{
...options,
params: { ...unref(params), ...options?.params },
},
)
}
export function getCRMSearchQueryKey(params?: MaybeRef<CRMSearchParams>) {
return ['search', ...(params ? [params] : [])] as const
}
export function getCRMSearchQueryOptions<TData = Awaited<ReturnType<typeof cRMSearch>>, TError = AxiosError<RpcStatus>>(params?: MaybeRef<CRMSearchParams>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMSearch>>, TError, TData>>, axios?: AxiosRequestConfig }) {
const { query: queryOptions, axios: axiosOptions } = options ?? {}
const queryKey = getCRMSearchQueryKey(params)
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMSearch>>> = ({ signal }) => cRMSearch(params, { signal, ...axiosOptions })
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<Awaited<ReturnType<typeof cRMSearch>>, TError, TData>
}
export type CRMSearchQueryResult = NonNullable<Awaited<ReturnType<typeof cRMSearch>>>
export type CRMSearchQueryError = AxiosError<RpcStatus>
export function useCRMSearch<TData = Awaited<ReturnType<typeof cRMSearch>>, TError = AxiosError<RpcStatus>>(params?: MaybeRef<CRMSearchParams>, options?: { query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMSearch>>, TError, TData>>, axios?: AxiosRequestConfig }): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getCRMSearchQueryOptions(params, options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey }
query.queryKey = unref(queryOptions).queryKey as QueryKey
return query
}

458
src/shared/api/crm/crm.ts Normal file
View File

@ -0,0 +1,458 @@
/**
* Generated by orval v6.31.0 🍺
* Do not edit manually.
* main.proto
* OpenAPI spec version: version not set
*/
import {
useMutation,
useQuery
} from '@tanstack/vue-query'
import type {
MutationFunction,
QueryFunction,
QueryKey,
UseMutationOptions,
UseMutationReturnType,
UseQueryOptions,
UseQueryReturnType
} from '@tanstack/vue-query'
import axios from 'axios'
import type {
AxiosError,
AxiosRequestConfig,
AxiosResponse
} from 'axios'
import {
computed,
unref
} from 'vue'
import type {
MaybeRef
} from 'vue'
import type {
ApiHttpBody,
CRMSearchParams,
CrabscrmOrder,
CrmBreadcrumbsRsp,
CrmCartRsp,
CrmCatalogRsp,
CrmOrderItem,
CrmOrderRsp,
CrmPositionsRsp,
CrmProductRsp,
RpcStatus
} from '../../model'
export const cRMGetCart = (
crmOrderItem: MaybeRef<CrmOrderItem[]>, options?: AxiosRequestConfig
): Promise<AxiosResponse<CrmCartRsp>> => {
crmOrderItem = unref(crmOrderItem);
return axios.post(
`/cart`,
crmOrderItem,options
);
}
export const getCRMGetCartMutationOptions = <TError = AxiosError<RpcStatus>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof cRMGetCart>>, TError,{data: CrmOrderItem[]}, TContext>, axios?: AxiosRequestConfig}
): UseMutationOptions<Awaited<ReturnType<typeof cRMGetCart>>, TError,{data: CrmOrderItem[]}, TContext> => {
const {mutation: mutationOptions, axios: axiosOptions} = options ?? {};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof cRMGetCart>>, {data: CrmOrderItem[]}> = (props) => {
const {data} = props ?? {};
return cRMGetCart(data,axiosOptions)
}
return { mutationFn, ...mutationOptions }}
export type CRMGetCartMutationResult = NonNullable<Awaited<ReturnType<typeof cRMGetCart>>>
export type CRMGetCartMutationBody = CrmOrderItem[]
export type CRMGetCartMutationError = AxiosError<RpcStatus>
export const useCRMGetCart = <TError = AxiosError<RpcStatus>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof cRMGetCart>>, TError,{data: CrmOrderItem[]}, TContext>, axios?: AxiosRequestConfig}
): UseMutationReturnType<
Awaited<ReturnType<typeof cRMGetCart>>,
TError,
{data: CrmOrderItem[]},
TContext
> => {
const mutationOptions = getCRMGetCartMutationOptions(options);
return useMutation(mutationOptions);
}
export const cRMGetCatalog = (
options?: AxiosRequestConfig
): Promise<AxiosResponse<CrmCatalogRsp>> => {
return axios.get(
`/catalog`,options
);
}
export const getCRMGetCatalogQueryKey = () => {
return ['catalog'] as const;
}
export const getCRMGetCatalogQueryOptions = <TData = Awaited<ReturnType<typeof cRMGetCatalog>>, TError = AxiosError<RpcStatus>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetCatalog>>, TError, TData>>, axios?: AxiosRequestConfig}
) => {
const {query: queryOptions, axios: axiosOptions} = options ?? {};
const queryKey = getCRMGetCatalogQueryKey();
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetCatalog>>> = ({ signal }) => cRMGetCatalog({ signal, ...axiosOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof cRMGetCatalog>>, TError, TData>
}
export type CRMGetCatalogQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetCatalog>>>
export type CRMGetCatalogQueryError = AxiosError<RpcStatus>
export const useCRMGetCatalog = <TData = Awaited<ReturnType<typeof cRMGetCatalog>>, TError = AxiosError<RpcStatus>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetCatalog>>, TError, TData>>, axios?: AxiosRequestConfig}
): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getCRMGetCatalogQueryOptions(options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey };
query.queryKey = unref(queryOptions).queryKey as QueryKey;
return query;
}
export const cRMGetImage = (
name: MaybeRef<string>, options?: AxiosRequestConfig
): Promise<AxiosResponse<ApiHttpBody>> => {
name = unref(name);
return axios.get(
`/images/${name}`,options
);
}
export const getCRMGetImageQueryKey = (name: MaybeRef<string>,) => {
return ['images',name] as const;
}
export const getCRMGetImageQueryOptions = <TData = Awaited<ReturnType<typeof cRMGetImage>>, TError = AxiosError<RpcStatus>>(name: MaybeRef<string>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetImage>>, TError, TData>>, axios?: AxiosRequestConfig}
) => {
const {query: queryOptions, axios: axiosOptions} = options ?? {};
const queryKey = getCRMGetImageQueryKey(name);
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetImage>>> = ({ signal }) => cRMGetImage(name, { signal, ...axiosOptions });
return { queryKey, queryFn, enabled: computed(() => !!(unref(name))), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof cRMGetImage>>, TError, TData>
}
export type CRMGetImageQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetImage>>>
export type CRMGetImageQueryError = AxiosError<RpcStatus>
export const useCRMGetImage = <TData = Awaited<ReturnType<typeof cRMGetImage>>, TError = AxiosError<RpcStatus>>(
name: MaybeRef<string>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetImage>>, TError, TData>>, axios?: AxiosRequestConfig}
): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getCRMGetImageQueryOptions(name,options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey };
query.queryKey = unref(queryOptions).queryKey as QueryKey;
return query;
}
export const cRMOrder = (
crabscrmOrder: MaybeRef<CrabscrmOrder>, options?: AxiosRequestConfig
): Promise<AxiosResponse<CrmOrderRsp>> => {
crabscrmOrder = unref(crabscrmOrder);
return axios.post(
`/orders`,
crabscrmOrder,options
);
}
export const getCRMOrderMutationOptions = <TError = AxiosError<RpcStatus>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof cRMOrder>>, TError,{data: CrabscrmOrder}, TContext>, axios?: AxiosRequestConfig}
): UseMutationOptions<Awaited<ReturnType<typeof cRMOrder>>, TError,{data: CrabscrmOrder}, TContext> => {
const {mutation: mutationOptions, axios: axiosOptions} = options ?? {};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof cRMOrder>>, {data: CrabscrmOrder}> = (props) => {
const {data} = props ?? {};
return cRMOrder(data,axiosOptions)
}
return { mutationFn, ...mutationOptions }}
export type CRMOrderMutationResult = NonNullable<Awaited<ReturnType<typeof cRMOrder>>>
export type CRMOrderMutationBody = CrabscrmOrder
export type CRMOrderMutationError = AxiosError<RpcStatus>
export const useCRMOrder = <TError = AxiosError<RpcStatus>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof cRMOrder>>, TError,{data: CrabscrmOrder}, TContext>, axios?: AxiosRequestConfig}
): UseMutationReturnType<
Awaited<ReturnType<typeof cRMOrder>>,
TError,
{data: CrabscrmOrder},
TContext
> => {
const mutationOptions = getCRMOrderMutationOptions(options);
return useMutation(mutationOptions);
}
export const cRMGetPositions = (
id: MaybeRef<string>, options?: AxiosRequestConfig
): Promise<AxiosResponse<CrmPositionsRsp>> => {
id = unref(id);
return axios.get(
`/positions/${id}`,options
);
}
export const getCRMGetPositionsQueryKey = (id: MaybeRef<string>,) => {
return ['positions',id] as const;
}
export const getCRMGetPositionsQueryOptions = <TData = Awaited<ReturnType<typeof cRMGetPositions>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetPositions>>, TError, TData>>, axios?: AxiosRequestConfig}
) => {
const {query: queryOptions, axios: axiosOptions} = options ?? {};
const queryKey = getCRMGetPositionsQueryKey(id);
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetPositions>>> = ({ signal }) => cRMGetPositions(id, { signal, ...axiosOptions });
return { queryKey, queryFn, enabled: computed(() => !!(unref(id))), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof cRMGetPositions>>, TError, TData>
}
export type CRMGetPositionsQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetPositions>>>
export type CRMGetPositionsQueryError = AxiosError<RpcStatus>
export const useCRMGetPositions = <TData = Awaited<ReturnType<typeof cRMGetPositions>>, TError = AxiosError<RpcStatus>>(
id: MaybeRef<string>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetPositions>>, TError, TData>>, axios?: AxiosRequestConfig}
): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getCRMGetPositionsQueryOptions(id,options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey };
query.queryKey = unref(queryOptions).queryKey as QueryKey;
return query;
}
export const cRMGetProduct = (
id: MaybeRef<string>, options?: AxiosRequestConfig
): Promise<AxiosResponse<CrmProductRsp>> => {
id = unref(id);
return axios.get(
`/products/${id}`,options
);
}
export const getCRMGetProductQueryKey = (id: MaybeRef<string>,) => {
return ['products',id] as const;
}
export const getCRMGetProductQueryOptions = <TData = Awaited<ReturnType<typeof cRMGetProduct>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetProduct>>, TError, TData>>, axios?: AxiosRequestConfig}
) => {
const {query: queryOptions, axios: axiosOptions} = options ?? {};
const queryKey = getCRMGetProductQueryKey(id);
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetProduct>>> = ({ signal }) => cRMGetProduct(id, { signal, ...axiosOptions });
return { queryKey, queryFn, enabled: computed(() => !!(unref(id))), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof cRMGetProduct>>, TError, TData>
}
export type CRMGetProductQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetProduct>>>
export type CRMGetProductQueryError = AxiosError<RpcStatus>
export const useCRMGetProduct = <TData = Awaited<ReturnType<typeof cRMGetProduct>>, TError = AxiosError<RpcStatus>>(
id: MaybeRef<string>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetProduct>>, TError, TData>>, axios?: AxiosRequestConfig}
): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getCRMGetProductQueryOptions(id,options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey };
query.queryKey = unref(queryOptions).queryKey as QueryKey;
return query;
}
export const cRMGetBreadcrumbs = (
id: MaybeRef<string>, options?: AxiosRequestConfig
): Promise<AxiosResponse<CrmBreadcrumbsRsp>> => {
id = unref(id);
return axios.get(
`/products/${id}/breadcrumbs`,options
);
}
export const getCRMGetBreadcrumbsQueryKey = (id: MaybeRef<string>,) => {
return ['products',id,'breadcrumbs'] as const;
}
export const getCRMGetBreadcrumbsQueryOptions = <TData = Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError = AxiosError<RpcStatus>>(id: MaybeRef<string>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError, TData>>, axios?: AxiosRequestConfig}
) => {
const {query: queryOptions, axios: axiosOptions} = options ?? {};
const queryKey = getCRMGetBreadcrumbsQueryKey(id);
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>> = ({ signal }) => cRMGetBreadcrumbs(id, { signal, ...axiosOptions });
return { queryKey, queryFn, enabled: computed(() => !!(unref(id))), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError, TData>
}
export type CRMGetBreadcrumbsQueryResult = NonNullable<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>>
export type CRMGetBreadcrumbsQueryError = AxiosError<RpcStatus>
export const useCRMGetBreadcrumbs = <TData = Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError = AxiosError<RpcStatus>>(
id: MaybeRef<string>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMGetBreadcrumbs>>, TError, TData>>, axios?: AxiosRequestConfig}
): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getCRMGetBreadcrumbsQueryOptions(id,options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey };
query.queryKey = unref(queryOptions).queryKey as QueryKey;
return query;
}
export const cRMSearch = (
params?: MaybeRef<CRMSearchParams>, options?: AxiosRequestConfig
): Promise<AxiosResponse<CrmPositionsRsp>> => {
params = unref(params);
return axios.get(
`/search`,{
...options,
params: {...unref(params), ...options?.params},}
);
}
export const getCRMSearchQueryKey = (params?: MaybeRef<CRMSearchParams>,) => {
return ['search', ...(params ? [params]: [])] as const;
}
export const getCRMSearchQueryOptions = <TData = Awaited<ReturnType<typeof cRMSearch>>, TError = AxiosError<RpcStatus>>(params?: MaybeRef<CRMSearchParams>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMSearch>>, TError, TData>>, axios?: AxiosRequestConfig}
) => {
const {query: queryOptions, axios: axiosOptions} = options ?? {};
const queryKey = getCRMSearchQueryKey(params);
const queryFn: QueryFunction<Awaited<ReturnType<typeof cRMSearch>>> = ({ signal }) => cRMSearch(params, { signal, ...axiosOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof cRMSearch>>, TError, TData>
}
export type CRMSearchQueryResult = NonNullable<Awaited<ReturnType<typeof cRMSearch>>>
export type CRMSearchQueryError = AxiosError<RpcStatus>
export const useCRMSearch = <TData = Awaited<ReturnType<typeof cRMSearch>>, TError = AxiosError<RpcStatus>>(
params?: MaybeRef<CRMSearchParams>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof cRMSearch>>, TError, TData>>, axios?: AxiosRequestConfig}
): UseQueryReturnType<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getCRMSearchQueryOptions(params,options)
const query = useQuery(queryOptions) as UseQueryReturnType<TData, TError> & { queryKey: QueryKey };
query.queryKey = unref(queryOptions).queryKey as QueryKey;
return query;
}

View File

@ -4,7 +4,7 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { ProtobufAny } from './protobufAny' import type { ProtobufAny } from './protobufAny';
/** /**
* Message that represents an arbitrary HTTP body. It should only be used for * Message that represents an arbitrary HTTP body. It should only be used for
@ -53,12 +53,10 @@ handled, all other features will continue to work unchanged.
*/ */
export interface ApiHttpBody { export interface ApiHttpBody {
/** The HTTP Content-Type header value specifying the content type of the body. */ /** The HTTP Content-Type header value specifying the content type of the body. */
contentType?: string contentType?: string;
/** The HTTP request/response body as raw binary. */ /** The HTTP request/response body as raw binary. */
data?: string data?: string;
/** /** Application specific response metadata. Must be set in the first response
Application specific response metadata. Must be set in the first response for streaming APIs. */
for streaming APIs. extensions?: ProtobufAny[];
*/
extensions?: ProtobufAny[]
} }

View File

@ -5,6 +5,6 @@
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
export interface CRMSearchParams { export type CRMSearchParams = {
text?: string text?: string;
} };

View File

@ -6,5 +6,5 @@
*/ */
export interface CrabscrmLabel { export interface CrabscrmLabel {
name?: string name?: string;
} }

View File

@ -4,10 +4,10 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrmOrderItem } from './crmOrderItem' import type { CrmOrderItem } from './crmOrderItem';
export interface CrabscrmOrder { export interface CrabscrmOrder {
items?: CrmOrderItem[] items?: CrmOrderItem[];
name?: string name?: string;
phone?: string phone?: string;
} }

View File

@ -4,8 +4,8 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrmCategory } from './crmCategory' import type { CrmCategory } from './crmCategory';
export interface CrmBreadcrumbsRsp { export interface CrmBreadcrumbsRsp {
categories?: CrmCategory[] categories?: CrmCategory[];
} }

View File

@ -4,20 +4,20 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrabscrmLabel } from './crabscrmLabel' import type { CrabscrmLabel } from './crabscrmLabel';
import type { CrmVariant } from './crmVariant' import type { CrmVariant } from './crmVariant';
export interface CrmCartItem { export interface CrmCartItem {
amount?: string amount?: string;
amountOld?: string amountOld?: string;
article?: string article?: string;
count?: string count?: string;
id?: string id?: string;
images?: string[] images?: string[];
inventory?: number inventory?: number;
labels?: CrabscrmLabel[] labels?: CrabscrmLabel[];
name?: string name?: string;
unit?: string unit?: string;
uri?: string uri?: string;
variants?: CrmVariant[] variants?: CrmVariant[];
} }

View File

@ -4,10 +4,10 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrmCartItem } from './crmCartItem' import type { CrmCartItem } from './crmCartItem';
export interface CrmCartRsp { export interface CrmCartRsp {
amount?: string amount?: string;
amountOld?: string amountOld?: string;
items?: CrmCartItem[] items?: CrmCartItem[];
} }

View File

@ -4,8 +4,8 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrmCategory } from './crmCategory' import type { CrmCategory } from './crmCategory';
export interface CrmCatalogRsp { export interface CrmCatalogRsp {
categories?: CrmCategory[] categories?: CrmCategory[];
} }

View File

@ -6,8 +6,8 @@
*/ */
export interface CrmCategory { export interface CrmCategory {
children?: CrmCategory[] children?: CrmCategory[];
id?: string id?: string;
name?: string name?: string;
uri?: string uri?: string;
} }

View File

@ -6,6 +6,6 @@
*/ */
export interface CrmCharacteristic { export interface CrmCharacteristic {
name?: string name?: string;
value?: string value?: string;
} }

View File

@ -6,7 +6,7 @@
*/ */
export interface CrmGroupedProduct { export interface CrmGroupedProduct {
image?: string image?: string;
name?: string name?: string;
uri?: string uri?: string;
} }

View File

@ -6,6 +6,6 @@
*/ */
export interface CrmOrderItem { export interface CrmOrderItem {
count?: string count?: string;
productId?: string productId?: string;
} }

View File

@ -4,8 +4,8 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrmProduct } from './crmProduct' import type { CrmProduct } from './crmProduct';
export interface CrmPositionsRsp { export interface CrmPositionsRsp {
products?: CrmProduct[] products?: CrmProduct[];
} }

View File

@ -4,23 +4,23 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrmCharacteristic } from './crmCharacteristic' import type { CrmCharacteristic } from './crmCharacteristic';
import type { CrmGroupedProduct } from './crmGroupedProduct' import type { CrmGroupedProduct } from './crmGroupedProduct';
import type { CrabscrmLabel } from './crabscrmLabel' import type { CrabscrmLabel } from './crabscrmLabel';
import type { CrmVariant } from './crmVariant' import type { CrmVariant } from './crmVariant';
export interface CrmProduct { export interface CrmProduct {
article?: string article?: string;
category?: string category?: string;
characteristics?: CrmCharacteristic[] characteristics?: CrmCharacteristic[];
description?: string description?: string;
groupedProducts?: CrmGroupedProduct[] groupedProducts?: CrmGroupedProduct[];
id?: string id?: string;
images?: string[] images?: string[];
inventory?: number inventory?: number;
labels?: CrabscrmLabel[] labels?: CrabscrmLabel[];
name?: string name?: string;
unit?: string unit?: string;
uri?: string uri?: string;
variants?: CrmVariant[] variants?: CrmVariant[];
} }

View File

@ -4,8 +4,8 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrmProduct } from './crmProduct' import type { CrmProduct } from './crmProduct';
export interface CrmProductRsp { export interface CrmProductRsp {
product?: CrmProduct product?: CrmProduct;
} }

View File

@ -6,6 +6,6 @@
*/ */
export interface CrmProperty { export interface CrmProperty {
name?: string name?: string;
value?: string value?: string;
} }

View File

@ -4,10 +4,10 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { CrmProperty } from './crmProperty' import type { CrmProperty } from './crmProperty';
export interface CrmVariant { export interface CrmVariant {
active?: boolean active?: boolean;
price?: string price?: string;
properties?: CrmProperty[] properties?: CrmProperty[];
} }

View File

@ -5,23 +5,23 @@
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
export * from './apiHttpBody' export * from './apiHttpBody';
export * from './cRMSearchParams' export * from './cRMSearchParams';
export * from './crabscrmLabel' export * from './crabscrmLabel';
export * from './crabscrmOrder' export * from './crabscrmOrder';
export * from './crmBreadcrumbsRsp' export * from './crmBreadcrumbsRsp';
export * from './crmCartItem' export * from './crmCartItem';
export * from './crmCartRsp' export * from './crmCartRsp';
export * from './crmCatalogRsp' export * from './crmCatalogRsp';
export * from './crmCategory' export * from './crmCategory';
export * from './crmCharacteristic' export * from './crmCharacteristic';
export * from './crmGroupedProduct' export * from './crmGroupedProduct';
export * from './crmOrderItem' export * from './crmOrderItem';
export * from './crmOrderRsp' export * from './crmOrderRsp';
export * from './crmPositionsRsp' export * from './crmPositionsRsp';
export * from './crmProduct' export * from './crmProduct';
export * from './crmProductRsp' export * from './crmProductRsp';
export * from './crmProperty' export * from './crmProperty';
export * from './crmVariant' export * from './crmVariant';
export * from './protobufAny' export * from './protobufAny';
export * from './rpcStatus' export * from './rpcStatus';

View File

@ -93,8 +93,7 @@ field. Example (for message [google.protobuf.Duration][]):
} }
*/ */
export interface ProtobufAny { export interface ProtobufAny {
/** /** A URL/resource name that uniquely identifies the type of the serialized
A URL/resource name that uniquely identifies the type of the serialized
protocol buffer message. This string must contain at least protocol buffer message. This string must contain at least
one "/" character. The last segment of the URL's path must represent one "/" character. The last segment of the URL's path must represent
the fully qualified name of the type (as in the fully qualified name of the type (as in
@ -106,10 +105,10 @@ expect it to use in the context of Any. However, for URLs which use the
scheme `http`, `https`, or no scheme, one can optionally set up a type scheme `http`, `https`, or no scheme, one can optionally set up a type
server that maps type URLs to message definitions as follows: server that maps type URLs to message definitions as follows:
* If no scheme is provided, `https` is assumed. * If no scheme is provided, `https` is assumed.
* An HTTP GET on the URL must yield a [google.protobuf.Type][] * An HTTP GET on the URL must yield a [google.protobuf.Type][]
value in binary format, or produce an error. value in binary format, or produce an error.
* Applications are allowed to cache lookup results based on the * Applications are allowed to cache lookup results based on the
URL, or have them precompiled into a binary to avoid any URL, or have them precompiled into a binary to avoid any
lookup. Therefore, binary compatibility needs to be preserved lookup. Therefore, binary compatibility needs to be preserved
on changes to types. (Use versioned type names to manage on changes to types. (Use versioned type names to manage
@ -121,8 +120,7 @@ type.googleapis.com. As of May 2023, there are no widely used type server
implementations and no plans to implement one. implementations and no plans to implement one.
Schemes other than `http`, `https` (or the empty scheme) might be Schemes other than `http`, `https` (or the empty scheme) might be
used with implementation specific semantics. used with implementation specific semantics. */
*/ '@type'?: string;
'@type'?: string [key: string]: unknown;
[key: string]: unknown
} }

View File

@ -4,10 +4,10 @@
* main.proto * main.proto
* OpenAPI spec version: version not set * OpenAPI spec version: version not set
*/ */
import type { ProtobufAny } from './protobufAny' import type { ProtobufAny } from './protobufAny';
export interface RpcStatus { export interface RpcStatus {
code?: number code?: number;
details?: ProtobufAny[] details?: ProtobufAny[];
message?: string message?: string;
} }