@squonk/account-server-client 0.1.6-rc.2 → 0.1.10-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/{custom-instance-d52e4104.d.ts → custom-instance-3334b00b.d.ts} +28 -6
  2. package/index.cjs +103 -2
  3. package/index.cjs.map +3 -3
  4. package/index.d.ts +1 -1
  5. package/index.js +69 -2
  6. package/index.js.map +3 -3
  7. package/organisation/organisation.cjs +111 -2
  8. package/organisation/organisation.cjs.map +3 -3
  9. package/organisation/organisation.d.ts +21 -7
  10. package/organisation/organisation.js +83 -2
  11. package/organisation/organisation.js.map +3 -3
  12. package/organisation/package.json +2 -1
  13. package/package.json +7 -7
  14. package/product/package.json +2 -1
  15. package/product/product.cjs +161 -2
  16. package/product/product.cjs.map +3 -3
  17. package/product/product.d.ts +7 -7
  18. package/product/product.js +127 -2
  19. package/product/product.js.map +3 -3
  20. package/service/package.json +7 -0
  21. package/service/service.cjs +100 -0
  22. package/service/service.cjs.map +7 -0
  23. package/service/service.d.ts +44 -0
  24. package/service/service.js +72 -0
  25. package/service/service.js.map +7 -0
  26. package/src/account-server-api.schemas.ts +295 -0
  27. package/src/custom-instance.ts +52 -0
  28. package/src/index.ts +6 -0
  29. package/src/organisation/organisation.ts +181 -0
  30. package/src/product/product.ts +289 -0
  31. package/src/service/service.ts +124 -0
  32. package/src/unit/unit.ts +322 -0
  33. package/src/user/user.ts +340 -0
  34. package/unit/package.json +2 -1
  35. package/unit/unit.cjs +168 -2
  36. package/unit/unit.cjs.map +3 -3
  37. package/unit/unit.d.ts +54 -5
  38. package/unit/unit.js +133 -2
  39. package/unit/unit.js.map +3 -3
  40. package/user/package.json +2 -1
  41. package/user/user.cjs +176 -2
  42. package/user/user.cjs.map +3 -3
  43. package/user/user.d.ts +13 -13
  44. package/user/user.js +141 -2
  45. package/user/user.js.map +3 -3
  46. package/chunk-33VR3IML.js +0 -2
  47. package/chunk-33VR3IML.js.map +0 -7
  48. package/chunk-3KO3PKBX.cjs +0 -2
  49. package/chunk-3KO3PKBX.cjs.map +0 -7
@@ -1,2 +1,83 @@
1
- import{a as y,e as s}from"../chunk-33VR3IML.js";import{useQuery as u,useMutation as c}from"react-query";var p=e=>s({url:"/organisation",method:"get"},e),g=()=>["/organisation"],B=e=>{var i;let{query:t,request:n}=e||{},r=(i=t==null?void 0:t.queryKey)!=null?i:g(),o=u(r,()=>p(n),t);return y({queryKey:r},o)},T=(e,t)=>s({url:"/organisation",method:"post",data:e},t),Q=e=>{let{mutation:t,request:n}=e||{};return c(a=>{let{data:o}=a||{};return T(o,n)},t)};export{T as createOrganisation,g as getGetOrganisationsQueryKey,p as getOrganisations,Q as useCreateOrganisation,B as useGetOrganisations};
2
- //# sourceMappingURL=organisation.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
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));
20
+
21
+ // src/organisation/organisation.ts
22
+ import {
23
+ useQuery,
24
+ useMutation
25
+ } 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
+ var getOrganisations = (options) => {
41
+ return customInstance({ url: `/organisation`, method: "get" }, options);
42
+ };
43
+ var getGetOrganisationsQueryKey = () => [`/organisation`];
44
+ var useGetOrganisations = (options) => {
45
+ const { query: queryOptions, request: requestOptions } = options || {};
46
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationsQueryKey();
47
+ const queryFn = () => getOrganisations(requestOptions);
48
+ const query = useQuery(queryKey, queryFn, queryOptions);
49
+ return __spreadValues({
50
+ queryKey
51
+ }, query);
52
+ };
53
+ var createOrganisation = (organisationPostBodyBody, options) => {
54
+ return customInstance({ url: `/organisation`, method: "post", data: organisationPostBodyBody }, options);
55
+ };
56
+ var useCreateOrganisation = (options) => {
57
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
58
+ const mutationFn = (props) => {
59
+ const { data } = props || {};
60
+ return createOrganisation(data, requestOptions);
61
+ };
62
+ return useMutation(mutationFn, mutationOptions);
63
+ };
64
+ var deleteOrganisation = (orgid, options) => {
65
+ return customInstance({ url: `/organisation/${orgid}`, method: "delete", data: void 0 }, options);
66
+ };
67
+ var useDeleteOrganisation = (options) => {
68
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
69
+ const mutationFn = (props) => {
70
+ const { orgid } = props || {};
71
+ return deleteOrganisation(orgid, requestOptions);
72
+ };
73
+ return useMutation(mutationFn, mutationOptions);
74
+ };
75
+ export {
76
+ createOrganisation,
77
+ deleteOrganisation,
78
+ getGetOrganisationsQueryKey,
79
+ getOrganisations,
80
+ useCreateOrganisation,
81
+ useDeleteOrganisation,
82
+ useGetOrganisations
83
+ };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/organisation/organisation.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.4.0 \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 **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 Error,\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\n\nYou need **admin** rights to use this method\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 | Error>\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<Error | 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"],
5
- "mappings": "gDAUA,wDAsCO,GAAM,GAAmB,AAC9B,GAEO,EACL,CAAE,IAAK,gBAAiB,OAAQ,OAChC,GAIS,EAA8B,IAAM,CAAC,iBAErC,EAAsB,AAGjC,GAO4D,CArE9D,MAsEE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EAAW,oBAAc,WAAd,OAA0B,IAKrC,EAAQ,EAIZ,EAPuE,IACvE,EAAiB,GAME,GAErB,MAAO,IACL,YACG,IAWM,EAAqB,CAChC,EACA,IAEO,EACL,CAAE,IAAK,gBAAiB,OAAQ,OAAQ,KAAM,GAC9C,GAIS,EAAwB,AAGnC,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,QAAS,GAAS,GAE1B,MAAO,GAAmB,EAAM,IAQpB",
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,UAAhB,EAAyB,aAAa,OAAO,UAAS,KACnF,CAAC,EAAE,WAAW;AAKhB,EAAC,QAAgB,SAAS,MAAM;AAC9B,WAAO,OAAO;AAAA;AAGhB,SAAO;AAAA;;;ADFF,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,UAAU,MAAM,UACzD;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;",
6
6
  "names": []
7
7
  }
@@ -2,5 +2,6 @@
2
2
  "module": "./organisation.js",
3
3
  "main": "./organisation.cjs",
4
4
  "types": "./organisation.d.ts",
5
- "sideEffects": false
5
+ "sideEffects": false,
6
+ "type": "module"
6
7
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.6-rc.2",
2
+ "version": "0.1.10-rc.1",
3
3
  "author": "Oliver Dudgeon",
4
4
  "name": "@squonk/account-server-client",
5
5
  "private": false,
@@ -15,16 +15,16 @@
15
15
  "orval": "orval --config ./orval.config.cjs"
16
16
  },
17
17
  "devDependencies": {
18
- "@typescript-eslint/eslint-plugin": "^5.4.0",
18
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
19
19
  "axios": "^0.24.0",
20
- "eslint": "^8.3.0",
20
+ "eslint": "^8.4.1",
21
21
  "eslint-plugin-prettier": "^4.0.0",
22
22
  "js-yaml": "^4.1.0",
23
- "orval": "^6.4.0",
24
- "prettier": "^2.5.0",
25
- "react-query": "^3.33.7",
23
+ "orval": "^6.4.2",
24
+ "prettier": "^2.5.1",
25
+ "react-query": "^3.34.0",
26
26
  "tslib": "^2.3.1",
27
- "tsup": "^5.10.0",
27
+ "tsup": "^5.10.3",
28
28
  "typescript": "^4.5.2"
29
29
  },
30
30
  "peerDependencies": {
@@ -2,5 +2,6 @@
2
2
  "module": "./product.js",
3
3
  "main": "./product.cjs",
4
4
  "types": "./product.d.ts",
5
- "sideEffects": false
5
+ "sideEffects": false,
6
+ "type": "module"
6
7
  }
@@ -1,2 +1,161 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3KO3PKBXcjs = require('../chunk-3KO3PKBX.cjs');var _reactquery = require('react-query');var P=t=>_chunk3KO3PKBXcjs.e.call(void 0, {url:"/product",method:"get"},t),T= exports.getGetProductsQueryKey =()=>["/product"],G= exports.useGetProducts =t=>{var s;let{query:e,request:r}=t||{},o=(s=e==null?void 0:e.queryKey)!=null?s:T(),u=_reactquery.useQuery.call(void 0, o,()=>P(r),e);return _chunk3KO3PKBXcjs.a.call(void 0, {queryKey:o},u)},g= exports.createUnitProduct =(t,e,r)=>_chunk3KO3PKBXcjs.e.call(void 0, {url:`/product/unit/${t}`,method:"post",data:e},r),I= exports.useCreateUnitProduct =t=>{let{mutation:e,request:r}=t||{};return _reactquery.useMutation.call(void 0, n=>{let{unitid:u,data:s}=n||{};return g(u,s,r)},e)},m= exports.getProductsForUnit =(t,e)=>_chunk3KO3PKBXcjs.e.call(void 0, {url:`/product/unit/${t}`,method:"get"},e),q= exports.getGetProductsForUnitQueryKey =t=>[`/product/unit/${t}`],O= exports.useGetProductsForUnit =(t,e)=>{var c;let{query:r,request:o}=e||{},n=(c=r==null?void 0:r.queryKey)!=null?c:q(t),s=_reactquery.useQuery.call(void 0, n,()=>m(t,o),_chunk3KO3PKBXcjs.a.call(void 0, {enabled:!!t},r));return _chunk3KO3PKBXcjs.a.call(void 0, {queryKey:n},s)},f= exports.getProduct =(t,e,r)=>_chunk3KO3PKBXcjs.e.call(void 0, {url:`/product/unit/${t}/product/${e}`,method:"get"},r),R= exports.getGetProductQueryKey =(t,e)=>[`/product/unit/${t}/product/${e}`],S= exports.useGetProduct =(t,e,r)=>{var p;let{query:o,request:n}=r||{},u=(p=o==null?void 0:o.queryKey)!=null?p:R(t,e),c=_reactquery.useQuery.call(void 0, u,()=>f(t,e,n),_chunk3KO3PKBXcjs.a.call(void 0, {enabled:!!(t&&e)},o));return _chunk3KO3PKBXcjs.a.call(void 0, {queryKey:u},c)},U= exports.patchProduct =(t,e,r,o)=>_chunk3KO3PKBXcjs.e.call(void 0, {url:`/product/unit/${t}/product/${e}`,method:"patch",data:r},o),$= exports.usePatchProduct =t=>{let{mutation:e,request:r}=t||{};return _reactquery.useMutation.call(void 0, n=>{let{unitid:u,productid:s,data:c}=n||{};return U(u,s,c,r)},e)};exports.createUnitProduct = g; exports.getGetProductQueryKey = R; exports.getGetProductsForUnitQueryKey = q; exports.getGetProductsQueryKey = T; exports.getProduct = f; exports.getProducts = P; exports.getProductsForUnit = m; exports.patchProduct = U; exports.useCreateUnitProduct = I; exports.useGetProduct = S; exports.useGetProducts = G; exports.useGetProductsForUnit = O; exports.usePatchProduct = $;
2
- //# sourceMappingURL=product.cjs.map
1
+ var __create = Object.create;
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
+ };
41
+
42
+ // src/product/product.ts
43
+ __export(exports, {
44
+ createUnitProduct: () => createUnitProduct,
45
+ getGetProductQueryKey: () => getGetProductQueryKey,
46
+ getGetProductsForUnitQueryKey: () => getGetProductsForUnitQueryKey,
47
+ getGetProductsQueryKey: () => getGetProductsQueryKey,
48
+ getProduct: () => getProduct,
49
+ getProducts: () => getProducts,
50
+ getProductsForUnit: () => getProductsForUnit,
51
+ patchProduct: () => patchProduct,
52
+ useCreateUnitProduct: () => useCreateUnitProduct,
53
+ useGetProduct: () => useGetProduct,
54
+ useGetProducts: () => useGetProducts,
55
+ useGetProductsForUnit: () => useGetProductsForUnit,
56
+ usePatchProduct: () => usePatchProduct
57
+ });
58
+ var import_react_query = __toModule(require("react-query"));
59
+
60
+ // src/custom-instance.ts
61
+ var import_axios = __toModule(require("axios"));
62
+ var AXIOS_INSTANCE = import_axios.default.create({ baseURL: "" });
63
+ var customInstance = (config, options) => {
64
+ const source = import_axios.default.CancelToken.source();
65
+ const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
66
+ promise.cancel = () => {
67
+ source.cancel("Query was cancelled by React Query");
68
+ };
69
+ return promise;
70
+ };
71
+
72
+ // src/product/product.ts
73
+ var getProducts = (options) => {
74
+ return customInstance({ url: `/product`, method: "get" }, options);
75
+ };
76
+ var getGetProductsQueryKey = () => [`/product`];
77
+ var useGetProducts = (options) => {
78
+ const { query: queryOptions, request: requestOptions } = options || {};
79
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetProductsQueryKey();
80
+ const queryFn = () => getProducts(requestOptions);
81
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, queryOptions);
82
+ return __spreadValues({
83
+ queryKey
84
+ }, query);
85
+ };
86
+ var createUnitProduct = (unitid, unitProductPostBodyBody, options) => {
87
+ return customInstance({
88
+ url: `/product/unit/${unitid}`,
89
+ method: "post",
90
+ data: unitProductPostBodyBody
91
+ }, options);
92
+ };
93
+ var useCreateUnitProduct = (options) => {
94
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
95
+ const mutationFn = (props) => {
96
+ const { unitid, data } = props || {};
97
+ return createUnitProduct(unitid, data, requestOptions);
98
+ };
99
+ return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
100
+ };
101
+ var getProductsForUnit = (unitid, options) => {
102
+ return customInstance({ url: `/product/unit/${unitid}`, method: "get" }, options);
103
+ };
104
+ var getGetProductsForUnitQueryKey = (unitid) => [
105
+ `/product/unit/${unitid}`
106
+ ];
107
+ var useGetProductsForUnit = (unitid, options) => {
108
+ const { query: queryOptions, request: requestOptions } = options || {};
109
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetProductsForUnitQueryKey(unitid);
110
+ const queryFn = () => getProductsForUnit(unitid, requestOptions);
111
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, __spreadValues({ enabled: !!unitid }, queryOptions));
112
+ return __spreadValues({
113
+ queryKey
114
+ }, query);
115
+ };
116
+ var getProduct = (unitid, productid, options) => {
117
+ return customInstance({ url: `/product/unit/${unitid}/product/${productid}`, method: "get" }, options);
118
+ };
119
+ var getGetProductQueryKey = (unitid, productid) => [
120
+ `/product/unit/${unitid}/product/${productid}`
121
+ ];
122
+ var useGetProduct = (unitid, productid, options) => {
123
+ const { query: queryOptions, request: requestOptions } = options || {};
124
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetProductQueryKey(unitid, productid);
125
+ const queryFn = () => getProduct(unitid, productid, requestOptions);
126
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, __spreadValues({ enabled: !!(unitid && productid) }, queryOptions));
127
+ return __spreadValues({
128
+ queryKey
129
+ }, query);
130
+ };
131
+ var patchProduct = (unitid, productid, productPatchBodyBody, options) => {
132
+ return customInstance({
133
+ url: `/product/unit/${unitid}/product/${productid}`,
134
+ method: "patch",
135
+ data: productPatchBodyBody
136
+ }, options);
137
+ };
138
+ var usePatchProduct = (options) => {
139
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
140
+ const mutationFn = (props) => {
141
+ const { unitid, productid, data } = props || {};
142
+ return patchProduct(unitid, productid, data, requestOptions);
143
+ };
144
+ return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
145
+ };
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ createUnitProduct,
149
+ getGetProductQueryKey,
150
+ getGetProductsForUnitQueryKey,
151
+ getGetProductsQueryKey,
152
+ getProduct,
153
+ getProducts,
154
+ getProductsForUnit,
155
+ patchProduct,
156
+ useCreateUnitProduct,
157
+ useGetProduct,
158
+ useGetProducts,
159
+ useGetProductsForUnit,
160
+ usePatchProduct
161
+ });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/product/product.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.4.0 \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 **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 ProductsGetResponse,\n Error,\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 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<Error | 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<Error | 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 | Error>\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<Error | 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<Error>,\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"],
5
- "mappings": "iDAUA,wDAsCO,GAAM,GAAc,AACzB,GAEO,EACL,CAAE,IAAK,WAAY,OAAQ,OAC3B,GAIS,EAAyB,IAAM,CAAC,YAEhC,EAAiB,AAG5B,GAG4D,CAjE9D,MAkEE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EAAW,oBAAc,WAAd,OAA0B,IAKrC,EAAQ,EACZ,EAJkE,IAClE,EAAY,GAKZ,GAGF,MAAO,IACL,YACG,IAOM,EAAoB,CAC/B,EACA,EACA,IAEO,EACL,CACE,IAAK,iBAAiB,IACtB,OAAQ,OACR,KAAM,GAER,GAIS,EAAuB,AAGlC,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,SAAQ,QAAS,GAAS,GAElC,MAAO,GAAkB,EAAQ,EAAM,IAQ3B,IAOH,EAAqB,CAChC,EACA,IAEO,EACL,CAAE,IAAK,iBAAiB,IAAU,OAAQ,OAC1C,GAIS,EAAgC,AAAC,GAAmB,CAC/D,iBAAiB,KAGN,EAAwB,CAInC,EACA,IAQ2D,CArK7D,MAsKE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EACJ,oBAAc,WAAd,OAA0B,EAA8B,GAMpD,EAAQ,EAIZ,EANE,IAAM,EAAmB,EAAQ,GAMhB,GAAE,QAAS,CAAC,CAAC,GAAW,IAE7C,MAAO,IACL,YACG,IASM,EAAa,CACxB,EACA,EACA,IAEO,EACL,CAAE,IAAK,iBAAiB,aAAkB,IAAa,OAAQ,OAC/D,GAIS,EAAwB,CAAC,EAAgB,IAAsB,CAC1E,iBAAiB,aAAkB,KAGxB,EAAgB,CAI3B,EACA,EACA,IAI2D,CAzN7D,MA0NE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EACJ,oBAAc,WAAd,OAA0B,EAAsB,EAAQ,GAKpD,EAAQ,EACZ,EAJiE,IACjE,EAAW,EAAQ,EAAW,GAK9B,GAAE,QAAS,CAAC,CAAE,IAAU,IAAe,IAGzC,MAAO,IACL,YACG,IASM,EAAe,CAC1B,EACA,EACA,EACA,IAEO,EACL,CACE,IAAK,iBAAiB,aAAkB,IACxC,OAAQ,QACR,KAAM,GAER,GAIS,EAAkB,AAG7B,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,SAAQ,YAAW,QAAS,GAAS,GAE7C,MAAO,GAAa,EAAQ,EAAW,EAAM,IAQjC",
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 ProductsGetResponse,\n AsError,\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 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;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;;;ADAF,IAAM,cAAc,CACzB,YACG;AACH,SAAO,eACL,EAAE,KAAK,YAAY,QAAQ,SAC3B;AAAA;AAIG,IAAM,yBAAyB,MAAM,CAAC;AAEtC,IAAM,iBAAiB,CAG5B,YAG4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY;AAE3C,QAAM,UAA8D,MAClE,YAAY;AAEd,QAAM,QAAQ,iCACZ,UACA,SACA;AAGF,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AAOA,IAAM,oBAAoB,CAC/B,QACA,yBACA,YACG;AACH,SAAO,eACL;AAAA,IACE,KAAK,iBAAiB;AAAA,IACtB,QAAQ;AAAA,IACR,MAAM;AAAA,KAER;AAAA;AAIG,IAAM,uBAAuB,CAGlC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,QAAQ,SAAS,SAAS;AAElC,WAAO,kBAAkB,QAAQ,MAAM;AAAA;AAGzC,SAAO,oCAKL,YAAY;AAAA;AAOT,IAAM,qBAAqB,CAChC,QACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,UAAU,QAAQ,SAC1C;AAAA;AAIG,IAAM,gCAAgC,CAAC,WAAmB;AAAA,EAC/D,iBAAiB;AAAA;AAGZ,IAAM,wBAAwB,CAInC,QACA,YAQ2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WACJ,8CAAc,aAAY,8BAA8B;AAE1D,QAAM,UAEF,MAAM,mBAAmB,QAAQ;AAErC,QAAM,QAAQ,iCAIZ,UAAU,SAAS,iBAAE,SAAS,CAAC,CAAC,UAAW;AAE7C,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,IAAM,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,iCACZ,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,oCAKL,YAAY;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,17 +1,17 @@
1
1
  import * as react_query from 'react-query';
2
2
  import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
3
- import { G as customInstance, w as ProductsGetResponse, H as ErrorType, E as Error, b as UnitProductPostBodyBody, s as UnitProductPostResponse, u as ProductUnitGetResponse, P as ProductPatchBodyBody } from '../custom-instance-d52e4104';
3
+ import { I as customInstance, y as ProductsGetResponse, J as ErrorType, E as AsError, b as UnitProductPostBodyBody, u as UnitProductPostResponse, w as ProductUnitGetResponse, P as ProductPatchBodyBody } from '../custom-instance-3334b00b';
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;
7
7
  /**
8
- * Gets products you have access to across all Units and Organisations
8
+ * Gets products you have access to, across all Units and Organisations
9
9
 
10
10
  * @summary Gets all Products
11
11
  */
12
12
  declare const getProducts: (options?: SecondParameter<typeof customInstance>) => Promise<ProductsGetResponse>;
13
13
  declare const getGetProductsQueryKey: () => string[];
14
- declare const useGetProducts: <TData = ProductsGetResponse, TError = ErrorType<void | Error>>(options?: {
14
+ declare const useGetProducts: <TData = ProductsGetResponse, TError = ErrorType<void | AsError>>(options?: {
15
15
  query?: UseQueryOptions<ProductsGetResponse, TError, TData, QueryKey> | undefined;
16
16
  request?: SecondParameter<typeof customInstance>;
17
17
  } | undefined) => UseQueryResult<TData, TError> & {
@@ -21,7 +21,7 @@ declare const useGetProducts: <TData = ProductsGetResponse, TError = ErrorType<v
21
21
  * @summary Creates a Product for an Organisational Unit
22
22
  */
23
23
  declare const createUnitProduct: (unitid: string, unitProductPostBodyBody: UnitProductPostBodyBody, options?: SecondParameter<typeof customInstance>) => Promise<UnitProductPostResponse>;
24
- declare const useCreateUnitProduct: <TError = ErrorType<void | Error>, TContext = unknown>(options?: {
24
+ declare const useCreateUnitProduct: <TError = ErrorType<void | AsError>, TContext = unknown>(options?: {
25
25
  mutation?: UseMutationOptions<UnitProductPostResponse, TError, {
26
26
  unitid: string;
27
27
  data: UnitProductPostBodyBody;
@@ -38,7 +38,7 @@ declare const useCreateUnitProduct: <TError = ErrorType<void | Error>, TContext
38
38
  */
39
39
  declare const getProductsForUnit: (unitid: string, options?: SecondParameter<typeof customInstance>) => Promise<ProductsGetResponse>;
40
40
  declare const getGetProductsForUnitQueryKey: (unitid: string) => string[];
41
- declare const useGetProductsForUnit: <TData = ProductsGetResponse, TError = ErrorType<void | Error>>(unitid: string, options?: {
41
+ declare const useGetProductsForUnit: <TData = ProductsGetResponse, TError = ErrorType<void | AsError>>(unitid: string, options?: {
42
42
  query?: UseQueryOptions<ProductsGetResponse, TError, TData, QueryKey> | undefined;
43
43
  request?: SecondParameter<typeof customInstance>;
44
44
  } | undefined) => UseQueryResult<TData, TError> & {
@@ -51,7 +51,7 @@ declare const useGetProductsForUnit: <TData = ProductsGetResponse, TError = Erro
51
51
  */
52
52
  declare const getProduct: (unitid: string, productid: string, options?: SecondParameter<typeof customInstance>) => Promise<ProductUnitGetResponse>;
53
53
  declare const getGetProductQueryKey: (unitid: string, productid: string) => string[];
54
- declare const useGetProduct: <TData = ProductUnitGetResponse, TError = ErrorType<void | Error>>(unitid: string, productid: string, options?: {
54
+ declare const useGetProduct: <TData = ProductUnitGetResponse, TError = ErrorType<void | AsError>>(unitid: string, productid: string, options?: {
55
55
  query?: UseQueryOptions<ProductUnitGetResponse, TError, TData, QueryKey> | undefined;
56
56
  request?: SecondParameter<typeof customInstance>;
57
57
  } | undefined) => UseQueryResult<TData, TError> & {
@@ -63,7 +63,7 @@ declare const useGetProduct: <TData = ProductUnitGetResponse, TError = ErrorType
63
63
  * @summary Adjust an existing Product
64
64
  */
65
65
  declare const patchProduct: (unitid: string, productid: string, productPatchBodyBody: ProductPatchBodyBody, options?: SecondParameter<typeof customInstance>) => Promise<void>;
66
- declare const usePatchProduct: <TError = ErrorType<Error>, TContext = unknown>(options?: {
66
+ declare const usePatchProduct: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
67
67
  mutation?: UseMutationOptions<void, TError, {
68
68
  unitid: string;
69
69
  productid: string;
@@ -1,2 +1,127 @@
1
- import{a as y,e as a}from"../chunk-33VR3IML.js";import{useQuery as d,useMutation as i}from"react-query";var P=t=>a({url:"/product",method:"get"},t),T=()=>["/product"],l=t=>{var s;let{query:e,request:r}=t||{},o=(s=e==null?void 0:e.queryKey)!=null?s:T(),u=d(o,()=>P(r),e);return y({queryKey:o},u)},g=(t,e,r)=>a({url:`/product/unit/${t}`,method:"post",data:e},r),G=t=>{let{mutation:e,request:r}=t||{};return i(n=>{let{unitid:u,data:s}=n||{};return g(u,s,r)},e)},m=(t,e)=>a({url:`/product/unit/${t}`,method:"get"},e),q=t=>[`/product/unit/${t}`],I=(t,e)=>{var c;let{query:r,request:o}=e||{},n=(c=r==null?void 0:r.queryKey)!=null?c:q(t),s=d(n,()=>m(t,o),y({enabled:!!t},r));return y({queryKey:n},s)},f=(t,e,r)=>a({url:`/product/unit/${t}/product/${e}`,method:"get"},r),R=(t,e)=>[`/product/unit/${t}/product/${e}`],O=(t,e,r)=>{var p;let{query:o,request:n}=r||{},u=(p=o==null?void 0:o.queryKey)!=null?p:R(t,e),c=d(u,()=>f(t,e,n),y({enabled:!!(t&&e)},o));return y({queryKey:u},c)},U=(t,e,r,o)=>a({url:`/product/unit/${t}/product/${e}`,method:"patch",data:r},o),S=t=>{let{mutation:e,request:r}=t||{};return i(n=>{let{unitid:u,productid:s,data:c}=n||{};return U(u,s,c,r)},e)};export{g as createUnitProduct,R as getGetProductQueryKey,q as getGetProductsForUnitQueryKey,T as getGetProductsQueryKey,f as getProduct,P as getProducts,m as getProductsForUnit,U as patchProduct,G as useCreateUnitProduct,O as useGetProduct,l as useGetProducts,I as useGetProductsForUnit,S as usePatchProduct};
2
- //# sourceMappingURL=product.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
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));
20
+
21
+ // src/product/product.ts
22
+ import {
23
+ useQuery,
24
+ useMutation
25
+ } 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
+ var getProducts = (options) => {
41
+ return customInstance({ url: `/product`, method: "get" }, options);
42
+ };
43
+ var getGetProductsQueryKey = () => [`/product`];
44
+ var useGetProducts = (options) => {
45
+ const { query: queryOptions, request: requestOptions } = options || {};
46
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetProductsQueryKey();
47
+ const queryFn = () => getProducts(requestOptions);
48
+ const query = useQuery(queryKey, queryFn, queryOptions);
49
+ return __spreadValues({
50
+ queryKey
51
+ }, query);
52
+ };
53
+ var createUnitProduct = (unitid, unitProductPostBodyBody, options) => {
54
+ return customInstance({
55
+ url: `/product/unit/${unitid}`,
56
+ method: "post",
57
+ data: unitProductPostBodyBody
58
+ }, options);
59
+ };
60
+ var useCreateUnitProduct = (options) => {
61
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
62
+ const mutationFn = (props) => {
63
+ const { unitid, data } = props || {};
64
+ return createUnitProduct(unitid, data, requestOptions);
65
+ };
66
+ return useMutation(mutationFn, mutationOptions);
67
+ };
68
+ var getProductsForUnit = (unitid, options) => {
69
+ return customInstance({ url: `/product/unit/${unitid}`, method: "get" }, options);
70
+ };
71
+ var getGetProductsForUnitQueryKey = (unitid) => [
72
+ `/product/unit/${unitid}`
73
+ ];
74
+ var useGetProductsForUnit = (unitid, options) => {
75
+ const { query: queryOptions, request: requestOptions } = options || {};
76
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetProductsForUnitQueryKey(unitid);
77
+ const queryFn = () => getProductsForUnit(unitid, requestOptions);
78
+ const query = useQuery(queryKey, queryFn, __spreadValues({ enabled: !!unitid }, queryOptions));
79
+ return __spreadValues({
80
+ queryKey
81
+ }, query);
82
+ };
83
+ var getProduct = (unitid, productid, options) => {
84
+ return customInstance({ url: `/product/unit/${unitid}/product/${productid}`, method: "get" }, options);
85
+ };
86
+ var getGetProductQueryKey = (unitid, productid) => [
87
+ `/product/unit/${unitid}/product/${productid}`
88
+ ];
89
+ var useGetProduct = (unitid, productid, options) => {
90
+ const { query: queryOptions, request: requestOptions } = options || {};
91
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetProductQueryKey(unitid, productid);
92
+ const queryFn = () => getProduct(unitid, productid, requestOptions);
93
+ const query = useQuery(queryKey, queryFn, __spreadValues({ enabled: !!(unitid && productid) }, queryOptions));
94
+ return __spreadValues({
95
+ queryKey
96
+ }, query);
97
+ };
98
+ var patchProduct = (unitid, productid, productPatchBodyBody, options) => {
99
+ return customInstance({
100
+ url: `/product/unit/${unitid}/product/${productid}`,
101
+ method: "patch",
102
+ data: productPatchBodyBody
103
+ }, options);
104
+ };
105
+ var usePatchProduct = (options) => {
106
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
107
+ const mutationFn = (props) => {
108
+ const { unitid, productid, data } = props || {};
109
+ return patchProduct(unitid, productid, data, requestOptions);
110
+ };
111
+ return useMutation(mutationFn, mutationOptions);
112
+ };
113
+ export {
114
+ createUnitProduct,
115
+ getGetProductQueryKey,
116
+ getGetProductsForUnitQueryKey,
117
+ getGetProductsQueryKey,
118
+ getProduct,
119
+ getProducts,
120
+ getProductsForUnit,
121
+ patchProduct,
122
+ useCreateUnitProduct,
123
+ useGetProduct,
124
+ useGetProducts,
125
+ useGetProductsForUnit,
126
+ usePatchProduct
127
+ };