feat: add axios
This commit is contained in:
parent
9d44b23565
commit
112dd2358a
|
@ -4,7 +4,7 @@ export default defineConfig({
|
|||
cakes: {
|
||||
output: {
|
||||
mode: 'tags-split',
|
||||
target: 'src/cakes.ts',
|
||||
target: 'src/shared/api',
|
||||
schemas: 'src/shared/model',
|
||||
client: 'vue-query',
|
||||
// mock: true,
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/vue-query": "^5.51.15"
|
||||
"@tanstack/vue-query": "^5.51.15",
|
||||
"axios": "^1.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^2.24.0",
|
||||
|
|
|
@ -8,6 +8,9 @@ dependencies:
|
|||
'@tanstack/vue-query':
|
||||
specifier: ^5.51.15
|
||||
version: 5.51.15(vue@3.4.34)
|
||||
axios:
|
||||
specifier: ^1.7.2
|
||||
version: 1.7.2
|
||||
|
||||
devDependencies:
|
||||
'@antfu/eslint-config':
|
||||
|
@ -21,7 +24,7 @@ devDependencies:
|
|||
version: 0.4.0(eslint@9.5.0)(typescript@5.5.4)(vite@5.3.5)
|
||||
'@nuxt/ui':
|
||||
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':
|
||||
specifier: ^0.61.6
|
||||
version: 0.61.7(eslint@9.5.0)(typescript@5.5.4)
|
||||
|
@ -2123,7 +2126,7 @@ packages:
|
|||
- supports-color
|
||||
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==}
|
||||
engines: {node: '>=v16.20.2'}
|
||||
dependencies:
|
||||
|
@ -2140,7 +2143,7 @@ packages:
|
|||
'@tailwindcss/forms': 0.5.7(tailwindcss@3.4.7)
|
||||
'@tailwindcss/typography': 0.5.13(tailwindcss@3.4.7)
|
||||
'@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)
|
||||
defu: 6.1.4
|
||||
fuse.js: 6.6.2
|
||||
|
@ -4239,7 +4242,7 @@ packages:
|
|||
- vue
|
||||
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==}
|
||||
peerDependencies:
|
||||
async-validator: ^4
|
||||
|
@ -4282,6 +4285,7 @@ packages:
|
|||
dependencies:
|
||||
'@vueuse/core': 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
|
||||
vue-demi: 0.14.10(vue@3.4.34)
|
||||
transitivePeerDependencies:
|
||||
|
@ -4713,6 +4717,9 @@ packages:
|
|||
resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==}
|
||||
dev: true
|
||||
|
||||
/asynckit@0.4.0:
|
||||
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||
|
||||
/at-least-node@1.0.0:
|
||||
resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==}
|
||||
engines: {node: '>= 4.0.0'}
|
||||
|
@ -4741,6 +4748,15 @@ packages:
|
|||
possible-typed-array-names: 1.0.0
|
||||
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:
|
||||
resolution: {integrity: sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==}
|
||||
dev: true
|
||||
|
@ -5079,6 +5095,12 @@ packages:
|
|||
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
|
||||
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:
|
||||
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
||||
dev: true
|
||||
|
@ -5496,6 +5518,10 @@ packages:
|
|||
resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==}
|
||||
dev: true
|
||||
|
||||
/delayed-stream@1.0.0:
|
||||
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
||||
/delegates@1.0.0:
|
||||
resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==}
|
||||
dev: true
|
||||
|
@ -6609,6 +6635,15 @@ packages:
|
|||
resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}
|
||||
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:
|
||||
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
|
||||
dependencies:
|
||||
|
@ -6623,6 +6658,14 @@ packages:
|
|||
signal-exit: 4.1.0
|
||||
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:
|
||||
resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==}
|
||||
dev: true
|
||||
|
@ -7992,14 +8035,12 @@ packages:
|
|||
/mime-db@1.52.0:
|
||||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
dev: true
|
||||
|
||||
/mime-types@2.1.35:
|
||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
dependencies:
|
||||
mime-db: 1.52.0
|
||||
dev: true
|
||||
|
||||
/mime@1.6.0:
|
||||
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
|
||||
|
@ -9391,6 +9432,9 @@ packages:
|
|||
resolution: {integrity: sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==}
|
||||
dev: true
|
||||
|
||||
/proxy-from-env@1.1.0:
|
||||
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
|
||||
|
||||
/punycode@2.3.1:
|
||||
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
||||
engines: {node: '>=6'}
|
||||
|
|
327
src/crm/crm.ts
327
src/crm/crm.ts
|
@ -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
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* main.proto
|
||||
* 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
|
||||
|
@ -53,12 +53,10 @@ handled, all other features will continue to work unchanged.
|
|||
*/
|
||||
export interface ApiHttpBody {
|
||||
/** 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. */
|
||||
data?: string
|
||||
/**
|
||||
Application specific response metadata. Must be set in the first response
|
||||
for streaming APIs.
|
||||
*/
|
||||
extensions?: ProtobufAny[]
|
||||
data?: string;
|
||||
/** Application specific response metadata. Must be set in the first response
|
||||
for streaming APIs. */
|
||||
extensions?: ProtobufAny[];
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
|
||||
export interface CRMSearchParams {
|
||||
text?: string
|
||||
}
|
||||
export type CRMSearchParams = {
|
||||
text?: string;
|
||||
};
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
*/
|
||||
|
||||
export interface CrabscrmLabel {
|
||||
name?: string
|
||||
name?: string;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrmOrderItem } from './crmOrderItem'
|
||||
import type { CrmOrderItem } from './crmOrderItem';
|
||||
|
||||
export interface CrabscrmOrder {
|
||||
items?: CrmOrderItem[]
|
||||
name?: string
|
||||
phone?: string
|
||||
items?: CrmOrderItem[];
|
||||
name?: string;
|
||||
phone?: string;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrmCategory } from './crmCategory'
|
||||
import type { CrmCategory } from './crmCategory';
|
||||
|
||||
export interface CrmBreadcrumbsRsp {
|
||||
categories?: CrmCategory[]
|
||||
categories?: CrmCategory[];
|
||||
}
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrabscrmLabel } from './crabscrmLabel'
|
||||
import type { CrmVariant } from './crmVariant'
|
||||
import type { CrabscrmLabel } from './crabscrmLabel';
|
||||
import type { CrmVariant } from './crmVariant';
|
||||
|
||||
export interface CrmCartItem {
|
||||
amount?: string
|
||||
amountOld?: string
|
||||
article?: string
|
||||
count?: string
|
||||
id?: string
|
||||
images?: string[]
|
||||
inventory?: number
|
||||
labels?: CrabscrmLabel[]
|
||||
name?: string
|
||||
unit?: string
|
||||
uri?: string
|
||||
variants?: CrmVariant[]
|
||||
amount?: string;
|
||||
amountOld?: string;
|
||||
article?: string;
|
||||
count?: string;
|
||||
id?: string;
|
||||
images?: string[];
|
||||
inventory?: number;
|
||||
labels?: CrabscrmLabel[];
|
||||
name?: string;
|
||||
unit?: string;
|
||||
uri?: string;
|
||||
variants?: CrmVariant[];
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrmCartItem } from './crmCartItem'
|
||||
import type { CrmCartItem } from './crmCartItem';
|
||||
|
||||
export interface CrmCartRsp {
|
||||
amount?: string
|
||||
amountOld?: string
|
||||
items?: CrmCartItem[]
|
||||
amount?: string;
|
||||
amountOld?: string;
|
||||
items?: CrmCartItem[];
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrmCategory } from './crmCategory'
|
||||
import type { CrmCategory } from './crmCategory';
|
||||
|
||||
export interface CrmCatalogRsp {
|
||||
categories?: CrmCategory[]
|
||||
categories?: CrmCategory[];
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
export interface CrmCategory {
|
||||
children?: CrmCategory[]
|
||||
id?: string
|
||||
name?: string
|
||||
uri?: string
|
||||
children?: CrmCategory[];
|
||||
id?: string;
|
||||
name?: string;
|
||||
uri?: string;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
*/
|
||||
|
||||
export interface CrmCharacteristic {
|
||||
name?: string
|
||||
value?: string
|
||||
name?: string;
|
||||
value?: string;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
export interface CrmGroupedProduct {
|
||||
image?: string
|
||||
name?: string
|
||||
uri?: string
|
||||
image?: string;
|
||||
name?: string;
|
||||
uri?: string;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
*/
|
||||
|
||||
export interface CrmOrderItem {
|
||||
count?: string
|
||||
productId?: string
|
||||
count?: string;
|
||||
productId?: string;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrmProduct } from './crmProduct'
|
||||
import type { CrmProduct } from './crmProduct';
|
||||
|
||||
export interface CrmPositionsRsp {
|
||||
products?: CrmProduct[]
|
||||
products?: CrmProduct[];
|
||||
}
|
||||
|
|
|
@ -4,23 +4,23 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrmCharacteristic } from './crmCharacteristic'
|
||||
import type { CrmGroupedProduct } from './crmGroupedProduct'
|
||||
import type { CrabscrmLabel } from './crabscrmLabel'
|
||||
import type { CrmVariant } from './crmVariant'
|
||||
import type { CrmCharacteristic } from './crmCharacteristic';
|
||||
import type { CrmGroupedProduct } from './crmGroupedProduct';
|
||||
import type { CrabscrmLabel } from './crabscrmLabel';
|
||||
import type { CrmVariant } from './crmVariant';
|
||||
|
||||
export interface CrmProduct {
|
||||
article?: string
|
||||
category?: string
|
||||
characteristics?: CrmCharacteristic[]
|
||||
description?: string
|
||||
groupedProducts?: CrmGroupedProduct[]
|
||||
id?: string
|
||||
images?: string[]
|
||||
inventory?: number
|
||||
labels?: CrabscrmLabel[]
|
||||
name?: string
|
||||
unit?: string
|
||||
uri?: string
|
||||
variants?: CrmVariant[]
|
||||
article?: string;
|
||||
category?: string;
|
||||
characteristics?: CrmCharacteristic[];
|
||||
description?: string;
|
||||
groupedProducts?: CrmGroupedProduct[];
|
||||
id?: string;
|
||||
images?: string[];
|
||||
inventory?: number;
|
||||
labels?: CrabscrmLabel[];
|
||||
name?: string;
|
||||
unit?: string;
|
||||
uri?: string;
|
||||
variants?: CrmVariant[];
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrmProduct } from './crmProduct'
|
||||
import type { CrmProduct } from './crmProduct';
|
||||
|
||||
export interface CrmProductRsp {
|
||||
product?: CrmProduct
|
||||
product?: CrmProduct;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
*/
|
||||
|
||||
export interface CrmProperty {
|
||||
name?: string
|
||||
value?: string
|
||||
name?: string;
|
||||
value?: string;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { CrmProperty } from './crmProperty'
|
||||
import type { CrmProperty } from './crmProperty';
|
||||
|
||||
export interface CrmVariant {
|
||||
active?: boolean
|
||||
price?: string
|
||||
properties?: CrmProperty[]
|
||||
active?: boolean;
|
||||
price?: string;
|
||||
properties?: CrmProperty[];
|
||||
}
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
|
||||
export * from './apiHttpBody'
|
||||
export * from './cRMSearchParams'
|
||||
export * from './crabscrmLabel'
|
||||
export * from './crabscrmOrder'
|
||||
export * from './crmBreadcrumbsRsp'
|
||||
export * from './crmCartItem'
|
||||
export * from './crmCartRsp'
|
||||
export * from './crmCatalogRsp'
|
||||
export * from './crmCategory'
|
||||
export * from './crmCharacteristic'
|
||||
export * from './crmGroupedProduct'
|
||||
export * from './crmOrderItem'
|
||||
export * from './crmOrderRsp'
|
||||
export * from './crmPositionsRsp'
|
||||
export * from './crmProduct'
|
||||
export * from './crmProductRsp'
|
||||
export * from './crmProperty'
|
||||
export * from './crmVariant'
|
||||
export * from './protobufAny'
|
||||
export * from './rpcStatus'
|
||||
export * from './apiHttpBody';
|
||||
export * from './cRMSearchParams';
|
||||
export * from './crabscrmLabel';
|
||||
export * from './crabscrmOrder';
|
||||
export * from './crmBreadcrumbsRsp';
|
||||
export * from './crmCartItem';
|
||||
export * from './crmCartRsp';
|
||||
export * from './crmCatalogRsp';
|
||||
export * from './crmCategory';
|
||||
export * from './crmCharacteristic';
|
||||
export * from './crmGroupedProduct';
|
||||
export * from './crmOrderItem';
|
||||
export * from './crmOrderRsp';
|
||||
export * from './crmPositionsRsp';
|
||||
export * from './crmProduct';
|
||||
export * from './crmProductRsp';
|
||||
export * from './crmProperty';
|
||||
export * from './crmVariant';
|
||||
export * from './protobufAny';
|
||||
export * from './rpcStatus';
|
|
@ -93,8 +93,7 @@ field. Example (for message [google.protobuf.Duration][]):
|
|||
}
|
||||
*/
|
||||
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
|
||||
one "/" character. The last segment of the URL's path must represent
|
||||
the fully qualified name of the type (as in
|
||||
|
@ -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.
|
||||
|
||||
Schemes other than `http`, `https` (or the empty scheme) might be
|
||||
used with implementation specific semantics.
|
||||
*/
|
||||
'@type'?: string
|
||||
[key: string]: unknown
|
||||
used with implementation specific semantics. */
|
||||
'@type'?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* main.proto
|
||||
* OpenAPI spec version: version not set
|
||||
*/
|
||||
import type { ProtobufAny } from './protobufAny'
|
||||
import type { ProtobufAny } from './protobufAny';
|
||||
|
||||
export interface RpcStatus {
|
||||
code?: number
|
||||
details?: ProtobufAny[]
|
||||
message?: string
|
||||
code?: number;
|
||||
details?: ProtobufAny[];
|
||||
message?: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue