@squonk/account-server-client 0.1.13-rc.1 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunk-3DXYUDZH.cjs +46 -0
- package/chunk-3DXYUDZH.cjs.map +1 -0
- package/chunk-JR7F532L.js +46 -0
- package/chunk-JR7F532L.js.map +1 -0
- package/{custom-instance-108ca7f1.d.ts → custom-instance-28f27843.d.ts} +18 -2
- package/index.cjs +15 -79
- package/index.cjs.map +1 -7
- package/index.d.ts +1 -1
- package/index.js +7 -37
- package/index.js.map +1 -7
- package/organisation/organisation.cjs +43 -81
- package/organisation/organisation.cjs.map +1 -7
- package/organisation/organisation.d.ts +15 -2
- package/organisation/organisation.js +24 -34
- package/organisation/organisation.js.map +1 -7
- package/package.json +8 -8
- package/product/product.cjs +46 -111
- package/product/product.cjs.map +1 -7
- package/product/product.d.ts +1 -1
- package/product/product.js +5 -33
- package/product/product.js.map +1 -7
- package/service/service.cjs +22 -78
- package/service/service.cjs.map +1 -7
- package/service/service.d.ts +2 -2
- package/service/service.js +5 -33
- package/service/service.js.map +1 -7
- package/src/account-server-api.schemas.ts +20 -1
- package/src/custom-instance.ts +1 -2
- package/src/organisation/organisation.ts +54 -2
- package/src/product/product.ts +3 -1
- package/src/service/service.ts +3 -1
- package/src/unit/unit.ts +59 -12
- package/src/user/user.ts +7 -17
- package/unit/unit.cjs +58 -107
- package/unit/unit.cjs.map +1 -7
- package/unit/unit.d.ts +18 -5
- package/unit/unit.js +26 -40
- package/unit/unit.js.map +1 -7
- package/user/user.cjs +40 -115
- package/user/user.cjs.map +1 -7
- package/user/user.d.ts +1 -1
- package/user/user.js +9 -49
- package/user/user.js.map +1 -7
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/organisation/organisation.ts", "../../src/custom-instance.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Generated by orval v6.4.2 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n OrganisationsGetResponse,\n AsError,\n OrganisationPostResponse,\n OrganisationPostBodyBody,\n} from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets all the Organisations you are a member of. Admin users can see all Organisations\n\n * @summary Gets Organisations\n */\nexport const getOrganisations = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationsGetResponse>(\n { url: `/organisation`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationsQueryKey = () => [`/organisation`];\n\nexport const useGetOrganisations = <\n TData = AsyncReturnType<typeof getOrganisations>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetOrganisationsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisations>> = () =>\n getOrganisations(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a new Organisation\n\nYou need **admin** rights to use this method\n\n * @summary Create a new organisation\n */\nexport const createOrganisation = (\n organisationPostBodyBody: OrganisationPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationPostResponse>(\n { url: `/organisation`, method: \"post\", data: organisationPostBodyBody },\n options\n );\n};\n\nexport const useCreateOrganisation = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createOrganisation>,\n { data: OrganisationPostBodyBody }\n > = (props) => {\n const { data } = props || {};\n\n return createOrganisation(data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Units must first be deleted before an Organisation can be deleted\n\nYou need **admin** rights to use this method\n\n * @summary Deletes an Organisation\n */\nexport const deleteOrganisation = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/organisation/${orgid}`, method: \"delete\", data: undefined },\n options\n );\n};\n\nexport const useDeleteOrganisation = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisation>,\n { orgid: string }\n > = (props) => {\n const { orgid } = props || {};\n\n return deleteOrganisation(orgid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n", "/** Based off the example custom-instance from Orval docs\n * https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/src/api/mutator/custom-instance.ts\n *\n * See https://react-query.tanstack.com/guides/query-cancellation\n *\n * TODO: Considering using Fetch-API instead of axios. This instance will have to change. Could be\n * achieved without changing much using `redaxios`\n * Or use 'ky'\n */\n\nimport Axios, { AxiosError, AxiosRequestConfig } from 'axios';\n\n// ? Need the baseUrl or does it default to ''?\nexport const AXIOS_INSTANCE = Axios.create({ baseURL: '' });\n\n/**\n * Set the access token to be added as the `Authorization: Bearer 'token'` header\n * Useful for client only apps where a proxy API route isn't involved to securely add the access token\n * @param token access token\n */\nexport const setAuthToken = (token: string) => {\n AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n};\n\n/**\n * Set the url to which request paths are added to.\n * @param baseUrl origin + subpath e.g. 'https://example.com/subpath' or '/subpath'\n */\nexport const setBaseUrl = (baseUrl: string) => {\n AXIOS_INSTANCE.defaults.baseURL = baseUrl;\n};\n\nexport const customInstance = <TReturn>(\n config: AxiosRequestConfig,\n options?: AxiosRequestConfig,\n): Promise<TReturn> => {\n const source = Axios.CancelToken.source();\n\n const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(\n ({ data }) => data,\n );\n\n // Promise doesn't have a cancel method but react-query requires this method to make cancellations general.\n // This can either be a any assertion or a @ts-ignore comment.\n (promise as any).cancel = () => {\n source.cancel('Query was cancelled by React Query');\n };\n\n return promise;\n};\n\nexport type ErrorType<TError> = AxiosError<TError>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,yBASO;;;ACTP,mBAAsD;AAG/C,IAAM,iBAAiB,qBAAM,OAAO,EAAE,SAAS;AAmB/C,IAAM,iBAAiB,CAC5B,QACA,YACqB;AACrB,QAAM,SAAS,qBAAM,YAAY;AAEjC,QAAM,UAAU,eAAe,gD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WAAW;AAEpE,QAAM,WACJ,8CAAc,aAAY;AAE5B,QAAM,UAEF,MAAM,uBAAuB;AAEjC,QAAM,QAAQ,SAIZ,UAAU,SAAS;AAErB,SAAO;AAAA,IACL;AAAA,KACG;AAAA","sourcesContent":["/**\n * Generated by orval v6.6.0 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n OrganisationsGetResponse,\n AsError,\n OrganisationPostResponse,\n OrganisationPostBodyBody,\n OrganisationGetDefaultResponse,\n} from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets all the Organisations you are a member of. Admin users can see all Organisations\n\n * @summary Gets Organisations\n */\nexport const getOrganisations = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationsGetResponse>(\n { url: `/organisation`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationsQueryKey = () => [`/organisation`];\n\nexport const useGetOrganisations = <\n TData = AsyncReturnType<typeof getOrganisations>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetOrganisationsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisations>> = () =>\n getOrganisations(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a new Organisation\n\nYou need **admin** rights to use this method\n\n * @summary Create a new organisation\n */\nexport const createOrganisation = (\n organisationPostBodyBody: OrganisationPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationPostResponse>(\n { url: `/organisation`, method: \"post\", data: organisationPostBodyBody },\n options\n );\n};\n\nexport const useCreateOrganisation = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createOrganisation>,\n { data: OrganisationPostBodyBody }\n > = (props) => {\n const { data } = props || {};\n\n return createOrganisation(data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Units must first be deleted before an Organisation can be deleted\n\nYou need **admin** rights to use this method\n\n * @summary Deletes an Organisation\n */\nexport const deleteOrganisation = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/organisation/${orgid}`, method: \"delete\" },\n options\n );\n};\n\nexport const useDeleteOrganisation = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisation>,\n { orgid: string }\n > = (props) => {\n const { orgid } = props || {};\n\n return deleteOrganisation(orgid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets the built-in Default Organisation, used exclusively for Independent Units\n\n * @summary Gets the (built-in) Default Organisation\n */\nexport const getDefaultOrganisation = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationGetDefaultResponse>(\n { url: `/organisation/default`, method: \"get\" },\n options\n );\n};\n\nexport const getGetDefaultOrganisationQueryKey = () => [\n `/organisation/default`,\n];\n\nexport const useGetDefaultOrganisation = <\n TData = AsyncReturnType<typeof getDefaultOrganisation>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getDefaultOrganisation>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetDefaultOrganisationQueryKey();\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getDefaultOrganisation>\n > = () => getDefaultOrganisation(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getDefaultOrganisation>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_query from 'react-query';
|
|
2
2
|
import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
|
|
3
|
-
import {
|
|
3
|
+
import { N as customInstance, C as OrganisationsGetResponse, R as ErrorType, J as AsError, c as OrganisationPostBodyBody, H as OrganisationPostResponse, F as OrganisationGetDefaultResponse } from '../custom-instance-28f27843';
|
|
4
4
|
import 'axios';
|
|
5
5
|
|
|
6
6
|
declare type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
|
|
@@ -49,5 +49,18 @@ declare const useDeleteOrganisation: <TError = ErrorType<AsError>, TContext = un
|
|
|
49
49
|
} | undefined) => react_query.UseMutationResult<void, TError, {
|
|
50
50
|
orgid: string;
|
|
51
51
|
}, TContext>;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the built-in Default Organisation, used exclusively for Independent Units
|
|
54
|
+
|
|
55
|
+
* @summary Gets the (built-in) Default Organisation
|
|
56
|
+
*/
|
|
57
|
+
declare const getDefaultOrganisation: (options?: SecondParameter<typeof customInstance>) => Promise<OrganisationGetDefaultResponse>;
|
|
58
|
+
declare const getGetDefaultOrganisationQueryKey: () => string[];
|
|
59
|
+
declare const useGetDefaultOrganisation: <TData = OrganisationGetDefaultResponse, TError = ErrorType<void | AsError>>(options?: {
|
|
60
|
+
query?: UseQueryOptions<OrganisationGetDefaultResponse, TError, TData, QueryKey> | undefined;
|
|
61
|
+
request?: SecondParameter<typeof customInstance>;
|
|
62
|
+
} | undefined) => UseQueryResult<TData, TError> & {
|
|
63
|
+
queryKey: QueryKey;
|
|
64
|
+
};
|
|
52
65
|
|
|
53
|
-
export { createOrganisation, deleteOrganisation, getGetOrganisationsQueryKey, getOrganisations, useCreateOrganisation, useDeleteOrganisation, useGetOrganisations };
|
|
66
|
+
export { createOrganisation, deleteOrganisation, getDefaultOrganisation, getGetDefaultOrganisationQueryKey, getGetOrganisationsQueryKey, getOrganisations, useCreateOrganisation, useDeleteOrganisation, useGetDefaultOrganisation, useGetOrganisations };
|
|
@@ -1,42 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues,
|
|
3
|
+
customInstance
|
|
4
|
+
} from "../chunk-JR7F532L.js";
|
|
20
5
|
|
|
21
6
|
// src/organisation/organisation.ts
|
|
22
7
|
import {
|
|
23
8
|
useQuery,
|
|
24
9
|
useMutation
|
|
25
10
|
} from "react-query";
|
|
26
|
-
|
|
27
|
-
// src/custom-instance.ts
|
|
28
|
-
import Axios from "axios";
|
|
29
|
-
var AXIOS_INSTANCE = Axios.create({ baseURL: "" });
|
|
30
|
-
var customInstance = (config, options) => {
|
|
31
|
-
const source = Axios.CancelToken.source();
|
|
32
|
-
const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
|
|
33
|
-
promise.cancel = () => {
|
|
34
|
-
source.cancel("Query was cancelled by React Query");
|
|
35
|
-
};
|
|
36
|
-
return promise;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/organisation/organisation.ts
|
|
40
11
|
var getOrganisations = (options) => {
|
|
41
12
|
return customInstance({ url: `/organisation`, method: "get" }, options);
|
|
42
13
|
};
|
|
@@ -62,7 +33,7 @@ var useCreateOrganisation = (options) => {
|
|
|
62
33
|
return useMutation(mutationFn, mutationOptions);
|
|
63
34
|
};
|
|
64
35
|
var deleteOrganisation = (orgid, options) => {
|
|
65
|
-
return customInstance({ url: `/organisation/${orgid}`, method: "delete"
|
|
36
|
+
return customInstance({ url: `/organisation/${orgid}`, method: "delete" }, options);
|
|
66
37
|
};
|
|
67
38
|
var useDeleteOrganisation = (options) => {
|
|
68
39
|
const { mutation: mutationOptions, request: requestOptions } = options || {};
|
|
@@ -72,12 +43,31 @@ var useDeleteOrganisation = (options) => {
|
|
|
72
43
|
};
|
|
73
44
|
return useMutation(mutationFn, mutationOptions);
|
|
74
45
|
};
|
|
46
|
+
var getDefaultOrganisation = (options) => {
|
|
47
|
+
return customInstance({ url: `/organisation/default`, method: "get" }, options);
|
|
48
|
+
};
|
|
49
|
+
var getGetDefaultOrganisationQueryKey = () => [
|
|
50
|
+
`/organisation/default`
|
|
51
|
+
];
|
|
52
|
+
var useGetDefaultOrganisation = (options) => {
|
|
53
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
54
|
+
const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetDefaultOrganisationQueryKey();
|
|
55
|
+
const queryFn = () => getDefaultOrganisation(requestOptions);
|
|
56
|
+
const query = useQuery(queryKey, queryFn, queryOptions);
|
|
57
|
+
return __spreadValues({
|
|
58
|
+
queryKey
|
|
59
|
+
}, query);
|
|
60
|
+
};
|
|
75
61
|
export {
|
|
76
62
|
createOrganisation,
|
|
77
63
|
deleteOrganisation,
|
|
64
|
+
getDefaultOrganisation,
|
|
65
|
+
getGetDefaultOrganisationQueryKey,
|
|
78
66
|
getGetOrganisationsQueryKey,
|
|
79
67
|
getOrganisations,
|
|
80
68
|
useCreateOrganisation,
|
|
81
69
|
useDeleteOrganisation,
|
|
70
|
+
useGetDefaultOrganisation,
|
|
82
71
|
useGetOrganisations
|
|
83
72
|
};
|
|
73
|
+
//# sourceMappingURL=organisation.js.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/organisation/organisation.ts", "../../src/custom-instance.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Generated by orval v6.4.2 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n OrganisationsGetResponse,\n AsError,\n OrganisationPostResponse,\n OrganisationPostBodyBody,\n} from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets all the Organisations you are a member of. Admin users can see all Organisations\n\n * @summary Gets Organisations\n */\nexport const getOrganisations = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationsGetResponse>(\n { url: `/organisation`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationsQueryKey = () => [`/organisation`];\n\nexport const useGetOrganisations = <\n TData = AsyncReturnType<typeof getOrganisations>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetOrganisationsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisations>> = () =>\n getOrganisations(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a new Organisation\n\nYou need **admin** rights to use this method\n\n * @summary Create a new organisation\n */\nexport const createOrganisation = (\n organisationPostBodyBody: OrganisationPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationPostResponse>(\n { url: `/organisation`, method: \"post\", data: organisationPostBodyBody },\n options\n );\n};\n\nexport const useCreateOrganisation = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createOrganisation>,\n { data: OrganisationPostBodyBody }\n > = (props) => {\n const { data } = props || {};\n\n return createOrganisation(data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Units must first be deleted before an Organisation can be deleted\n\nYou need **admin** rights to use this method\n\n * @summary Deletes an Organisation\n */\nexport const deleteOrganisation = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/organisation/${orgid}`, method: \"delete\", data: undefined },\n options\n );\n};\n\nexport const useDeleteOrganisation = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisation>,\n { orgid: string }\n > = (props) => {\n const { orgid } = props || {};\n\n return deleteOrganisation(orgid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n", "/** Based off the example custom-instance from Orval docs\n * https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/src/api/mutator/custom-instance.ts\n *\n * See https://react-query.tanstack.com/guides/query-cancellation\n *\n * TODO: Considering using Fetch-API instead of axios. This instance will have to change. Could be\n * achieved without changing much using `redaxios`\n * Or use 'ky'\n */\n\nimport Axios, { AxiosError, AxiosRequestConfig } from 'axios';\n\n// ? Need the baseUrl or does it default to ''?\nexport const AXIOS_INSTANCE = Axios.create({ baseURL: '' });\n\n/**\n * Set the access token to be added as the `Authorization: Bearer 'token'` header\n * Useful for client only apps where a proxy API route isn't involved to securely add the access token\n * @param token access token\n */\nexport const setAuthToken = (token: string) => {\n AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n};\n\n/**\n * Set the url to which request paths are added to.\n * @param baseUrl origin + subpath e.g. 'https://example.com/subpath' or '/subpath'\n */\nexport const setBaseUrl = (baseUrl: string) => {\n AXIOS_INSTANCE.defaults.baseURL = baseUrl;\n};\n\nexport const customInstance = <TReturn>(\n config: AxiosRequestConfig,\n options?: AxiosRequestConfig,\n): Promise<TReturn> => {\n const source = Axios.CancelToken.source();\n\n const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(\n ({ data }) => data,\n );\n\n // Promise doesn't have a cancel method but react-query requires this method to make cancellations general.\n // This can either be a any assertion or a @ts-ignore comment.\n (promise as any).cancel = () => {\n source.cancel('Query was cancelled by React Query');\n };\n\n return promise;\n};\n\nexport type ErrorType<TError> = AxiosError<TError>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAUA;AAAA;AAAA;AAAA;;;ACAA;AAGO,IAAM,iBAAiB,MAAM,OAAO,EAAE,SAAS;AAmB/C,IAAM,iBAAiB,CAC5B,QACA,YACqB;AACrB,QAAM,SAAS,MAAM,YAAY;AAEjC,QAAM,UAAU,eAAe,gDAAK,SAAW,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orval v6.6.0 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n OrganisationsGetResponse,\n AsError,\n OrganisationPostResponse,\n OrganisationPostBodyBody,\n OrganisationGetDefaultResponse,\n} from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets all the Organisations you are a member of. Admin users can see all Organisations\n\n * @summary Gets Organisations\n */\nexport const getOrganisations = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationsGetResponse>(\n { url: `/organisation`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationsQueryKey = () => [`/organisation`];\n\nexport const useGetOrganisations = <\n TData = AsyncReturnType<typeof getOrganisations>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetOrganisationsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisations>> = () =>\n getOrganisations(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a new Organisation\n\nYou need **admin** rights to use this method\n\n * @summary Create a new organisation\n */\nexport const createOrganisation = (\n organisationPostBodyBody: OrganisationPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationPostResponse>(\n { url: `/organisation`, method: \"post\", data: organisationPostBodyBody },\n options\n );\n};\n\nexport const useCreateOrganisation = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createOrganisation>,\n { data: OrganisationPostBodyBody }\n > = (props) => {\n const { data } = props || {};\n\n return createOrganisation(data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Units must first be deleted before an Organisation can be deleted\n\nYou need **admin** rights to use this method\n\n * @summary Deletes an Organisation\n */\nexport const deleteOrganisation = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/organisation/${orgid}`, method: \"delete\" },\n options\n );\n};\n\nexport const useDeleteOrganisation = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisation>,\n { orgid: string }\n > = (props) => {\n const { orgid } = props || {};\n\n return deleteOrganisation(orgid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets the built-in Default Organisation, used exclusively for Independent Units\n\n * @summary Gets the (built-in) Default Organisation\n */\nexport const getDefaultOrganisation = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationGetDefaultResponse>(\n { url: `/organisation/default`, method: \"get\" },\n options\n );\n};\n\nexport const getGetDefaultOrganisationQueryKey = () => [\n `/organisation/default`,\n];\n\nexport const useGetDefaultOrganisation = <\n TData = AsyncReturnType<typeof getDefaultOrganisation>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getDefaultOrganisation>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetDefaultOrganisationQueryKey();\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getDefaultOrganisation>\n > = () => getDefaultOrganisation(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getDefaultOrganisation>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n"],"mappings":";;;;;;AAUA;AAAA;AAAA;AAAA;AAuCO,IAAM,mBAAmB,CAC9B,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,QAAQ,SAChC;AAAA;AAIG,IAAM,8BAA8B,MAAM,CAAC;AAE3C,IAAM,sBAAsB,CAGjC,YAO4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY;AAE3C,QAAM,UAAmE,MACvE,iBAAiB;AAEnB,QAAM,QAAQ,SAIZ,UAAU,SAAS;AAErB,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AAWA,IAAM,qBAAqB,CAChC,0BACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,QAAQ,QAAQ,MAAM,4BAC9C;AAAA;AAIG,IAAM,wBAAwB,CAGnC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,SAAS,SAAS;AAE1B,WAAO,mBAAmB,MAAM;AAAA;AAGlC,SAAO,YAKL,YAAY;AAAA;AAST,IAAM,qBAAqB,CAChC,OACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,SAAS,QAAQ,YACzC;AAAA;AAIG,IAAM,wBAAwB,CAGnC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,UAAU,SAAS;AAE3B,WAAO,mBAAmB,OAAO;AAAA;AAGnC,SAAO,YAKL,YAAY;AAAA;AAOT,IAAM,yBAAyB,CACpC,YACG;AACH,SAAO,eACL,EAAE,KAAK,yBAAyB,QAAQ,SACxC;AAAA;AAIG,IAAM,oCAAoC,MAAM;AAAA,EACrD;AAAA;AAGK,IAAM,4BAA4B,CAGvC,YAO4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WACJ,8CAAc,aAAY;AAE5B,QAAM,UAEF,MAAM,uBAAuB;AAEjC,QAAM,QAAQ,SAIZ,UAAU,SAAS;AAErB,SAAO;AAAA,IACL;AAAA,KACG;AAAA;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.15",
|
|
3
3
|
"author": "Oliver Dudgeon",
|
|
4
4
|
"name": "@squonk/account-server-client",
|
|
5
5
|
"private": false,
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"orval": "orval --config ./orval.config.cjs"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
19
|
-
"axios": "
|
|
20
|
-
"eslint": "^8.
|
|
18
|
+
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
|
19
|
+
"axios": "0.24.0",
|
|
20
|
+
"eslint": "^8.8.0",
|
|
21
21
|
"eslint-plugin-prettier": "^4.0.0",
|
|
22
22
|
"js-yaml": "^4.1.0",
|
|
23
|
-
"orval": "
|
|
23
|
+
"orval": "6.6.0",
|
|
24
24
|
"prettier": "^2.5.1",
|
|
25
|
-
"react-query": "
|
|
25
|
+
"react-query": "3.34.14",
|
|
26
26
|
"tslib": "^2.3.1",
|
|
27
|
-
"tsup": "
|
|
28
|
-
"typescript": "^4.5.
|
|
27
|
+
"tsup": "5.11.13",
|
|
28
|
+
"typescript": "^4.5.5"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"axios": ">=0.23",
|
package/product/product.cjs
CHANGED
|
@@ -1,106 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
-
var __export = (target, all) => {
|
|
26
|
-
__markAsModule(target);
|
|
27
|
-
for (var name in all)
|
|
28
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
29
|
-
};
|
|
30
|
-
var __reExport = (target, module2, desc) => {
|
|
31
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
32
|
-
for (let key of __getOwnPropNames(module2))
|
|
33
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
34
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
35
|
-
}
|
|
36
|
-
return target;
|
|
37
|
-
};
|
|
38
|
-
var __toModule = (module2) => {
|
|
39
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
40
|
-
};
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
41
2
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
createUnitProduct: () => createUnitProduct,
|
|
45
|
-
getGetProductQueryKey: () => getGetProductQueryKey,
|
|
46
|
-
getGetProductTypesQueryKey: () => getGetProductTypesQueryKey,
|
|
47
|
-
getGetProductsForUnitQueryKey: () => getGetProductsForUnitQueryKey,
|
|
48
|
-
getGetProductsQueryKey: () => getGetProductsQueryKey,
|
|
49
|
-
getProduct: () => getProduct,
|
|
50
|
-
getProductTypes: () => getProductTypes,
|
|
51
|
-
getProducts: () => getProducts,
|
|
52
|
-
getProductsForUnit: () => getProductsForUnit,
|
|
53
|
-
patchProduct: () => patchProduct,
|
|
54
|
-
useCreateUnitProduct: () => useCreateUnitProduct,
|
|
55
|
-
useGetProduct: () => useGetProduct,
|
|
56
|
-
useGetProductTypes: () => useGetProductTypes,
|
|
57
|
-
useGetProducts: () => useGetProducts,
|
|
58
|
-
useGetProductsForUnit: () => useGetProductsForUnit,
|
|
59
|
-
usePatchProduct: () => usePatchProduct
|
|
60
|
-
});
|
|
61
|
-
var import_react_query = __toModule(require("react-query"));
|
|
62
|
-
|
|
63
|
-
// src/custom-instance.ts
|
|
64
|
-
var import_axios = __toModule(require("axios"));
|
|
65
|
-
var AXIOS_INSTANCE = import_axios.default.create({ baseURL: "" });
|
|
66
|
-
var customInstance = (config, options) => {
|
|
67
|
-
const source = import_axios.default.CancelToken.source();
|
|
68
|
-
const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
|
|
69
|
-
promise.cancel = () => {
|
|
70
|
-
source.cancel("Query was cancelled by React Query");
|
|
71
|
-
};
|
|
72
|
-
return promise;
|
|
73
|
-
};
|
|
3
|
+
|
|
4
|
+
var _chunk3DXYUDZHcjs = require('../chunk-3DXYUDZH.cjs');
|
|
74
5
|
|
|
75
6
|
// src/product/product.ts
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _reactquery = require('react-query');
|
|
76
11
|
var getProductTypes = (options) => {
|
|
77
|
-
return customInstance({ url: `/product-type`, method: "get" }, options);
|
|
12
|
+
return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/product-type`, method: "get" }, options);
|
|
78
13
|
};
|
|
79
14
|
var getGetProductTypesQueryKey = () => [`/product-type`];
|
|
80
15
|
var useGetProductTypes = (options) => {
|
|
81
16
|
const { query: queryOptions, request: requestOptions } = options || {};
|
|
82
|
-
const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey)
|
|
17
|
+
const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetProductTypesQueryKey()));
|
|
83
18
|
const queryFn = () => getProductTypes(requestOptions);
|
|
84
|
-
const query = (0,
|
|
85
|
-
return __spreadValues({
|
|
19
|
+
const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, queryOptions);
|
|
20
|
+
return _chunk3DXYUDZHcjs.__spreadValues.call(void 0, {
|
|
86
21
|
queryKey
|
|
87
22
|
}, query);
|
|
88
23
|
};
|
|
89
24
|
var getProducts = (options) => {
|
|
90
|
-
return customInstance({ url: `/product`, method: "get" }, options);
|
|
25
|
+
return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/product`, method: "get" }, options);
|
|
91
26
|
};
|
|
92
27
|
var getGetProductsQueryKey = () => [`/product`];
|
|
93
28
|
var useGetProducts = (options) => {
|
|
94
29
|
const { query: queryOptions, request: requestOptions } = options || {};
|
|
95
|
-
const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey)
|
|
30
|
+
const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetProductsQueryKey()));
|
|
96
31
|
const queryFn = () => getProducts(requestOptions);
|
|
97
|
-
const query = (0,
|
|
98
|
-
return __spreadValues({
|
|
32
|
+
const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, queryOptions);
|
|
33
|
+
return _chunk3DXYUDZHcjs.__spreadValues.call(void 0, {
|
|
99
34
|
queryKey
|
|
100
35
|
}, query);
|
|
101
36
|
};
|
|
102
37
|
var createUnitProduct = (unitid, unitProductPostBodyBody, options) => {
|
|
103
|
-
return customInstance({
|
|
38
|
+
return _chunk3DXYUDZHcjs.customInstance.call(void 0, {
|
|
104
39
|
url: `/product/unit/${unitid}`,
|
|
105
40
|
method: "post",
|
|
106
41
|
data: unitProductPostBodyBody
|
|
@@ -112,40 +47,40 @@ var useCreateUnitProduct = (options) => {
|
|
|
112
47
|
const { unitid, data } = props || {};
|
|
113
48
|
return createUnitProduct(unitid, data, requestOptions);
|
|
114
49
|
};
|
|
115
|
-
return (0,
|
|
50
|
+
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
116
51
|
};
|
|
117
52
|
var getProductsForUnit = (unitid, options) => {
|
|
118
|
-
return customInstance({ url: `/product/unit/${unitid}`, method: "get" }, options);
|
|
53
|
+
return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/product/unit/${unitid}`, method: "get" }, options);
|
|
119
54
|
};
|
|
120
55
|
var getGetProductsForUnitQueryKey = (unitid) => [
|
|
121
56
|
`/product/unit/${unitid}`
|
|
122
57
|
];
|
|
123
58
|
var useGetProductsForUnit = (unitid, options) => {
|
|
124
59
|
const { query: queryOptions, request: requestOptions } = options || {};
|
|
125
|
-
const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey)
|
|
60
|
+
const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetProductsForUnitQueryKey(unitid)));
|
|
126
61
|
const queryFn = () => getProductsForUnit(unitid, requestOptions);
|
|
127
|
-
const query = (0,
|
|
128
|
-
return __spreadValues({
|
|
62
|
+
const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, _chunk3DXYUDZHcjs.__spreadValues.call(void 0, { enabled: !!unitid }, queryOptions));
|
|
63
|
+
return _chunk3DXYUDZHcjs.__spreadValues.call(void 0, {
|
|
129
64
|
queryKey
|
|
130
65
|
}, query);
|
|
131
66
|
};
|
|
132
67
|
var getProduct = (unitid, productid, options) => {
|
|
133
|
-
return customInstance({ url: `/product/unit/${unitid}/product/${productid}`, method: "get" }, options);
|
|
68
|
+
return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/product/unit/${unitid}/product/${productid}`, method: "get" }, options);
|
|
134
69
|
};
|
|
135
70
|
var getGetProductQueryKey = (unitid, productid) => [
|
|
136
71
|
`/product/unit/${unitid}/product/${productid}`
|
|
137
72
|
];
|
|
138
73
|
var useGetProduct = (unitid, productid, options) => {
|
|
139
74
|
const { query: queryOptions, request: requestOptions } = options || {};
|
|
140
|
-
const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey)
|
|
75
|
+
const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetProductQueryKey(unitid, productid)));
|
|
141
76
|
const queryFn = () => getProduct(unitid, productid, requestOptions);
|
|
142
|
-
const query = (0,
|
|
143
|
-
return __spreadValues({
|
|
77
|
+
const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, _chunk3DXYUDZHcjs.__spreadValues.call(void 0, { enabled: !!(unitid && productid) }, queryOptions));
|
|
78
|
+
return _chunk3DXYUDZHcjs.__spreadValues.call(void 0, {
|
|
144
79
|
queryKey
|
|
145
80
|
}, query);
|
|
146
81
|
};
|
|
147
82
|
var patchProduct = (unitid, productid, productPatchBodyBody, options) => {
|
|
148
|
-
return customInstance({
|
|
83
|
+
return _chunk3DXYUDZHcjs.customInstance.call(void 0, {
|
|
149
84
|
url: `/product/unit/${unitid}/product/${productid}`,
|
|
150
85
|
method: "patch",
|
|
151
86
|
data: productPatchBodyBody
|
|
@@ -157,24 +92,24 @@ var usePatchProduct = (options) => {
|
|
|
157
92
|
const { unitid, productid, data } = props || {};
|
|
158
93
|
return patchProduct(unitid, productid, data, requestOptions);
|
|
159
94
|
};
|
|
160
|
-
return (0,
|
|
95
|
+
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
161
96
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
exports.createUnitProduct = createUnitProduct; exports.getGetProductQueryKey = getGetProductQueryKey; exports.getGetProductTypesQueryKey = getGetProductTypesQueryKey; exports.getGetProductsForUnitQueryKey = getGetProductsForUnitQueryKey; exports.getGetProductsQueryKey = getGetProductsQueryKey; exports.getProduct = getProduct; exports.getProductTypes = getProductTypes; exports.getProducts = getProducts; exports.getProductsForUnit = getProductsForUnit; exports.patchProduct = patchProduct; exports.useCreateUnitProduct = useCreateUnitProduct; exports.useGetProduct = useGetProduct; exports.useGetProductTypes = useGetProductTypes; exports.useGetProducts = useGetProducts; exports.useGetProductsForUnit = useGetProductsForUnit; exports.usePatchProduct = usePatchProduct;
|
|
115
|
+
//# sourceMappingURL=product.cjs.map
|
package/product/product.cjs.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/product/product.ts", "../../src/custom-instance.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Generated by orval v6.4.2 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n ProductsGetTypesResponse,\n AsError,\n ProductsGetResponse,\n UnitProductPostResponse,\n UnitProductPostBodyBody,\n ProductUnitGetResponse,\n ProductPatchBodyBody,\n} from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets product types you can purchase\n\n * @summary Gets all Product Types\n */\nexport const getProductTypes = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetTypesResponse>(\n { url: `/product-type`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductTypesQueryKey = () => [`/product-type`];\n\nexport const useGetProductTypes = <\n TData = AsyncReturnType<typeof getProductTypes>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getProductTypes>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProductTypes>> = () =>\n getProductTypes(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getProductTypes>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets products you have access to, across all Units and Organisations\n\n * @summary Gets all Products\n */\nexport const getProducts = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetResponse>(\n { url: `/product`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductsQueryKey = () => [`/product`];\n\nexport const useGetProducts = <\n TData = AsyncReturnType<typeof getProducts>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getProducts>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProducts>> = () =>\n getProducts(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getProducts>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * @summary Creates a Product for an Organisational Unit\n */\nexport const createUnitProduct = (\n unitid: string,\n unitProductPostBodyBody: UnitProductPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UnitProductPostResponse>(\n {\n url: `/product/unit/${unitid}`,\n method: \"post\",\n data: unitProductPostBodyBody,\n },\n options\n );\n};\n\nexport const useCreateUnitProduct = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createUnitProduct>,\n TError,\n { unitid: string; data: UnitProductPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createUnitProduct>,\n { unitid: string; data: UnitProductPostBodyBody }\n > = (props) => {\n const { unitid, data } = props || {};\n\n return createUnitProduct(unitid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createUnitProduct>,\n TError,\n { unitid: string; data: UnitProductPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets products you have access to based on an Organisational Unit\n\n * @summary Gets Products for an Organisational Unit\n */\nexport const getProductsForUnit = (\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetResponse>(\n { url: `/product/unit/${unitid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductsForUnitQueryKey = (unitid: string) => [\n `/product/unit/${unitid}`,\n];\n\nexport const useGetProductsForUnit = <\n TData = AsyncReturnType<typeof getProductsForUnit>,\n TError = ErrorType<void | AsError>\n>(\n unitid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getProductsForUnit>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getProductsForUnit>\n > = () => getProductsForUnit(unitid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getProductsForUnit>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets a Unit's Product\n\n * @summary Gets a Unit's Product\n */\nexport const getProduct = (\n unitid: string,\n productid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductUnitGetResponse>(\n { url: `/product/unit/${unitid}/product/${productid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductQueryKey = (unitid: string, productid: string) => [\n `/product/unit/${unitid}/product/${productid}`,\n];\n\nexport const useGetProduct = <\n TData = AsyncReturnType<typeof getProduct>,\n TError = ErrorType<AsError | void>\n>(\n unitid: string,\n productid: string,\n options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getProduct>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetProductQueryKey(unitid, productid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProduct>> = () =>\n getProduct(unitid, productid, requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getProduct>, TError, TData>(\n queryKey,\n queryFn,\n { enabled: !!(unitid && productid), ...queryOptions }\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Used to update some adjustable parameters of a Product, i.e. to extend the Allowance or Limit. Curently you can only patch storage Products\n\n * @summary Adjust an existing Product\n */\nexport const patchProduct = (\n unitid: string,\n productid: string,\n productPatchBodyBody: ProductPatchBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/product/unit/${unitid}/product/${productid}`,\n method: \"patch\",\n data: productPatchBodyBody,\n },\n options\n );\n};\n\nexport const usePatchProduct = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof patchProduct>,\n TError,\n { unitid: string; productid: string; data: ProductPatchBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof patchProduct>,\n { unitid: string; productid: string; data: ProductPatchBodyBody }\n > = (props) => {\n const { unitid, productid, data } = props || {};\n\n return patchProduct(unitid, productid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof patchProduct>,\n TError,\n { unitid: string; productid: string; data: ProductPatchBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n", "/** Based off the example custom-instance from Orval docs\n * https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/src/api/mutator/custom-instance.ts\n *\n * See https://react-query.tanstack.com/guides/query-cancellation\n *\n * TODO: Considering using Fetch-API instead of axios. This instance will have to change. Could be\n * achieved without changing much using `redaxios`\n * Or use 'ky'\n */\n\nimport Axios, { AxiosError, AxiosRequestConfig } from 'axios';\n\n// ? Need the baseUrl or does it default to ''?\nexport const AXIOS_INSTANCE = Axios.create({ baseURL: '' });\n\n/**\n * Set the access token to be added as the `Authorization: Bearer 'token'` header\n * Useful for client only apps where a proxy API route isn't involved to securely add the access token\n * @param token access token\n */\nexport const setAuthToken = (token: string) => {\n AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n};\n\n/**\n * Set the url to which request paths are added to.\n * @param baseUrl origin + subpath e.g. 'https://example.com/subpath' or '/subpath'\n */\nexport const setBaseUrl = (baseUrl: string) => {\n AXIOS_INSTANCE.defaults.baseURL = baseUrl;\n};\n\nexport const customInstance = <TReturn>(\n config: AxiosRequestConfig,\n options?: AxiosRequestConfig,\n): Promise<TReturn> => {\n const source = Axios.CancelToken.source();\n\n const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(\n ({ data }) => data,\n );\n\n // Promise doesn't have a cancel method but react-query requires this method to make cancellations general.\n // This can either be a any assertion or a @ts-ignore comment.\n (promise as any).cancel = () => {\n source.cancel('Query was cancelled by React Query');\n };\n\n return promise;\n};\n\nexport type ErrorType<TError> = AxiosError<TError>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,yBASO;;;ACTP,mBAAsD;AAG/C,IAAM,iBAAiB,qBAAM,OAAO,EAAE,SAAS;AAmB/C,IAAM,iBAAiB,CAC5B,QACA,YACqB;AACrB,QAAM,SAAS,qBAAM,YAAY;AAEjC,QAAM,UAAU,eAAe,gDAAK,SAAW,UAAhB,EAAyB,aAAa,OAAO,UAAS,KACnF,CAAC,EAAE,WAAW;AAKhB,EAAC,QAAgB,SAAS,MAAM;AAC9B,WAAO,OAAO;AAAA;AAGhB,SAAO;AAAA;;;ADCF,IAAM,kBAAkB,CAC7B,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,QAAQ,SAChC;AAAA;AAIG,IAAM,6BAA6B,MAAM,CAAC;AAE1C,IAAM,qBAAqB,CAGhC,YAO4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY;AAE3C,QAAM,UAAkE,MACtE,gBAAgB;AAElB,QAAM,QAAQ,iCAIZ,UAAU,SAAS;A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AM,aAAa,CACxB,QACA,WACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,kBAAkB,aAAa,QAAQ,SAC/D;AAAA;AAIG,IAAM,wBAAwB,CAAC,QAAgB,cAAsB;AAAA,EAC1E,iBAAiB,kBAAkB;AAAA;AAG9B,IAAM,gBAAgB,CAI3B,QACA,WACA,YAI2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WACJ,8CAAc,aAAY,sBAAsB,QAAQ;AAE1D,QAAM,UAA6D,MACjE,WAAW,QAAQ,WAAW;AAEhC,QAAM,QAAQ,SACZ,UACA,SACA,iBAAE,SAAS,CAAC,CAAE,WAAU,cAAe;AAGzC,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,IAAM,eAAe,CAC1B,QACA,WACA,sBACA,YACG;AACH,SAAO,eACL;AAAA,IACE,KAAK,iBAAiB,kBAAkB;AAAA,IACxC,QAAQ;AAAA,IACR,MAAM;AAAA,KAER;AAAA;AAIG,IAAM,kBAAkB,CAG7B,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,QAAQ,WAAW,SAAS,SAAS;AAE7C,WAAO,aAAa,QAAQ,WAAW,MAAM;AAAA;AAG/C,SAAO,YAKL,YAAY;AAAA","sourcesContent":["/**\n * Generated by orval v6.6.0 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n ProductsGetTypesResponse,\n AsError,\n ProductsGetResponse,\n UnitProductPostResponse,\n UnitProductPostBodyBody,\n ProductUnitGetResponse,\n ProductPatchBodyBody,\n} from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets product types you can purchase\n\n * @summary Gets all Product Types\n */\nexport const getProductTypes = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetTypesResponse>(\n { url: `/product-type`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductTypesQueryKey = () => [`/product-type`];\n\nexport const useGetProductTypes = <\n TData = AsyncReturnType<typeof getProductTypes>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getProductTypes>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProductTypes>> = () =>\n getProductTypes(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getProductTypes>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets products you have access to, across all Units and Organisations\n\n * @summary Gets all Products\n */\nexport const getProducts = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetResponse>(\n { url: `/product`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductsQueryKey = () => [`/product`];\n\nexport const useGetProducts = <\n TData = AsyncReturnType<typeof getProducts>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getProducts>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProducts>> = () =>\n getProducts(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getProducts>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * @summary Creates a Product for an Organisational Unit\n */\nexport const createUnitProduct = (\n unitid: string,\n unitProductPostBodyBody: UnitProductPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UnitProductPostResponse>(\n {\n url: `/product/unit/${unitid}`,\n method: \"post\",\n data: unitProductPostBodyBody,\n },\n options\n );\n};\n\nexport const useCreateUnitProduct = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createUnitProduct>,\n TError,\n { unitid: string; data: UnitProductPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createUnitProduct>,\n { unitid: string; data: UnitProductPostBodyBody }\n > = (props) => {\n const { unitid, data } = props || {};\n\n return createUnitProduct(unitid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createUnitProduct>,\n TError,\n { unitid: string; data: UnitProductPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets products you have access to based on an Organisational Unit\n\n * @summary Gets Products for an Organisational Unit\n */\nexport const getProductsForUnit = (\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetResponse>(\n { url: `/product/unit/${unitid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductsForUnitQueryKey = (unitid: string) => [\n `/product/unit/${unitid}`,\n];\n\nexport const useGetProductsForUnit = <\n TData = AsyncReturnType<typeof getProductsForUnit>,\n TError = ErrorType<void | AsError>\n>(\n unitid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getProductsForUnit>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getProductsForUnit>\n > = () => getProductsForUnit(unitid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getProductsForUnit>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets a Unit's Product\n\n * @summary Gets a Unit's Product\n */\nexport const getProduct = (\n unitid: string,\n productid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductUnitGetResponse>(\n { url: `/product/unit/${unitid}/product/${productid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductQueryKey = (unitid: string, productid: string) => [\n `/product/unit/${unitid}/product/${productid}`,\n];\n\nexport const useGetProduct = <\n TData = AsyncReturnType<typeof getProduct>,\n TError = ErrorType<AsError | void>\n>(\n unitid: string,\n productid: string,\n options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getProduct>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetProductQueryKey(unitid, productid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProduct>> = () =>\n getProduct(unitid, productid, requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getProduct>, TError, TData>(\n queryKey,\n queryFn,\n { enabled: !!(unitid && productid), ...queryOptions }\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Used to update some adjustable parameters of a Product, i.e. to extend the Allowance or Limit. Curently you can only patch storage Products\n\n * @summary Adjust an existing Product\n */\nexport const patchProduct = (\n unitid: string,\n productid: string,\n productPatchBodyBody: ProductPatchBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/product/unit/${unitid}/product/${productid}`,\n method: \"patch\",\n data: productPatchBodyBody,\n },\n options\n );\n};\n\nexport const usePatchProduct = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof patchProduct>,\n TError,\n { unitid: string; productid: string; data: ProductPatchBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof patchProduct>,\n { unitid: string; productid: string; data: ProductPatchBodyBody }\n > = (props) => {\n const { unitid, productid, data } = props || {};\n\n return patchProduct(unitid, productid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof patchProduct>,\n TError,\n { unitid: string; productid: string; data: ProductPatchBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n"]}
|
package/product/product.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_query from 'react-query';
|
|
2
2
|
import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
|
|
3
|
-
import {
|
|
3
|
+
import { N as customInstance, z as ProductsGetTypesResponse, R as ErrorType, J as AsError, B as ProductsGetResponse, b as UnitProductPostBodyBody, w as UnitProductPostResponse, y as ProductUnitGetResponse, P as ProductPatchBodyBody } from '../custom-instance-28f27843';
|
|
4
4
|
import 'axios';
|
|
5
5
|
|
|
6
6
|
declare type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
|
package/product/product.js
CHANGED
|
@@ -1,42 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues,
|
|
3
|
+
customInstance
|
|
4
|
+
} from "../chunk-JR7F532L.js";
|
|
20
5
|
|
|
21
6
|
// src/product/product.ts
|
|
22
7
|
import {
|
|
23
8
|
useQuery,
|
|
24
9
|
useMutation
|
|
25
10
|
} from "react-query";
|
|
26
|
-
|
|
27
|
-
// src/custom-instance.ts
|
|
28
|
-
import Axios from "axios";
|
|
29
|
-
var AXIOS_INSTANCE = Axios.create({ baseURL: "" });
|
|
30
|
-
var customInstance = (config, options) => {
|
|
31
|
-
const source = Axios.CancelToken.source();
|
|
32
|
-
const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
|
|
33
|
-
promise.cancel = () => {
|
|
34
|
-
source.cancel("Query was cancelled by React Query");
|
|
35
|
-
};
|
|
36
|
-
return promise;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/product/product.ts
|
|
40
11
|
var getProductTypes = (options) => {
|
|
41
12
|
return customInstance({ url: `/product-type`, method: "get" }, options);
|
|
42
13
|
};
|
|
@@ -141,3 +112,4 @@ export {
|
|
|
141
112
|
useGetProductsForUnit,
|
|
142
113
|
usePatchProduct
|
|
143
114
|
};
|
|
115
|
+
//# sourceMappingURL=product.js.map
|