@squonk/account-server-client 0.1.26 → 0.1.27-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 (42) hide show
  1. package/{account-server-api.schemas-078442c3.d.ts → account-server-api.schemas-e6c5f956.d.ts} +13 -0
  2. package/index.cjs.map +1 -1
  3. package/index.d.ts +1 -1
  4. package/index.js.map +1 -1
  5. package/organisation/organisation.cjs +64 -19
  6. package/organisation/organisation.cjs.map +1 -1
  7. package/organisation/organisation.d.ts +67 -18
  8. package/organisation/organisation.js +64 -19
  9. package/organisation/organisation.js.map +1 -1
  10. package/package.json +1 -1
  11. package/product/product.cjs +108 -30
  12. package/product/product.cjs.map +1 -1
  13. package/product/product.d.ts +114 -24
  14. package/product/product.js +108 -30
  15. package/product/product.js.map +1 -1
  16. package/service/service.cjs +39 -10
  17. package/service/service.cjs.map +1 -1
  18. package/service/service.d.ts +34 -8
  19. package/service/service.js +39 -10
  20. package/service/service.js.map +1 -1
  21. package/src/account-server-api.schemas.ts +13 -0
  22. package/src/organisation/organisation.ts +195 -44
  23. package/src/product/product.ts +356 -84
  24. package/src/service/service.ts +108 -16
  25. package/src/state/state.ts +64 -16
  26. package/src/unit/unit.ts +339 -74
  27. package/src/user/user.ts +340 -67
  28. package/state/state.cjs +21 -7
  29. package/state/state.cjs.map +1 -1
  30. package/state/state.d.ts +17 -6
  31. package/state/state.js +21 -7
  32. package/state/state.js.map +1 -1
  33. package/unit/unit.cjs +104 -29
  34. package/unit/unit.cjs.map +1 -1
  35. package/unit/unit.d.ts +107 -25
  36. package/unit/unit.js +104 -29
  37. package/unit/unit.js.map +1 -1
  38. package/user/user.cjs +106 -29
  39. package/user/user.cjs.map +1 -1
  40. package/user/user.d.ts +132 -20
  41. package/user/user.js +106 -29
  42. package/user/user.js.map +1 -1
@@ -1,5 +1,6 @@
1
- import { AxiosResponse, AxiosRequestConfig } from 'axios';
2
- import { h as ServicesGetResponse, g as ServiceGetResponse } from '../account-server-api.schemas-078442c3.js';
1
+ import { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
2
+ import { UseQueryOptions, QueryKey, UseQueryResult } from 'react-query';
3
+ import { h as ServicesGetResponse, N as AsError, g as ServiceGetResponse } from '../account-server-api.schemas-e6c5f956.js';
3
4
 
4
5
  /**
5
6
  * Generated by orval v6.7.1 🍺
@@ -12,11 +13,36 @@ A service that provides access to the Account Server, which gives *registered* u
12
13
  * OpenAPI spec version: 0.1
13
14
  */
14
15
 
15
- declare const getService: () => {
16
- appApiServiceGet: <TData = AxiosResponse<ServicesGetResponse, any>>(options?: AxiosRequestConfig<any> | undefined) => Promise<TData>;
17
- appApiServiceGetId: <TData_1 = AxiosResponse<ServiceGetResponse, any>>(svcId: number, options?: AxiosRequestConfig<any> | undefined) => Promise<TData_1>;
16
+ declare type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
17
+ /**
18
+ * Gets services known to the Account Server
19
+
20
+ * @summary Gets all Services
21
+ */
22
+ declare const appApiServiceGet: (options?: AxiosRequestConfig<any> | undefined) => Promise<AxiosResponse<ServicesGetResponse>>;
23
+ declare const getAppApiServiceGetQueryKey: () => string[];
24
+ declare type AppApiServiceGetQueryResult = NonNullable<AsyncReturnType<typeof appApiServiceGet>>;
25
+ declare type AppApiServiceGetQueryError = AxiosError<AsError | void>;
26
+ declare const useAppApiServiceGet: <TData = AxiosResponse<ServicesGetResponse, any>, TError = AxiosError<void | AsError, any>>(options?: {
27
+ query?: UseQueryOptions<AxiosResponse<ServicesGetResponse, any>, TError, TData, QueryKey> | undefined;
28
+ axios?: AxiosRequestConfig<any> | undefined;
29
+ } | undefined) => UseQueryResult<TData, TError> & {
30
+ queryKey: QueryKey;
31
+ };
32
+ /**
33
+ * Gets a known service
34
+
35
+ * @summary Gets a specific Service
36
+ */
37
+ declare const appApiServiceGetId: (svcId: number, options?: AxiosRequestConfig<any> | undefined) => Promise<AxiosResponse<ServiceGetResponse>>;
38
+ declare const getAppApiServiceGetIdQueryKey: (svcId: number) => string[];
39
+ declare type AppApiServiceGetIdQueryResult = NonNullable<AsyncReturnType<typeof appApiServiceGetId>>;
40
+ declare type AppApiServiceGetIdQueryError = AxiosError<AsError | void>;
41
+ declare const useAppApiServiceGetId: <TData = AxiosResponse<ServiceGetResponse, any>, TError = AxiosError<void | AsError, any>>(svcId: number, options?: {
42
+ query?: UseQueryOptions<AxiosResponse<ServiceGetResponse, any>, TError, TData, QueryKey> | undefined;
43
+ axios?: AxiosRequestConfig<any> | undefined;
44
+ } | undefined) => UseQueryResult<TData, TError> & {
45
+ queryKey: QueryKey;
18
46
  };
19
- declare type AppApiServiceGetResult = AxiosResponse<ServicesGetResponse>;
20
- declare type AppApiServiceGetIdResult = AxiosResponse<ServiceGetResponse>;
21
47
 
22
- export { AppApiServiceGetIdResult, AppApiServiceGetResult, getService };
48
+ export { AppApiServiceGetIdQueryError, AppApiServiceGetIdQueryResult, AppApiServiceGetQueryError, AppApiServiceGetQueryResult, appApiServiceGet, appApiServiceGetId, getAppApiServiceGetIdQueryKey, getAppApiServiceGetQueryKey, useAppApiServiceGet, useAppApiServiceGetId };
@@ -1,17 +1,46 @@
1
- import "../chunk-GWBPVOL2.js";
1
+ import {
2
+ __spreadValues
3
+ } from "../chunk-GWBPVOL2.js";
2
4
 
3
5
  // src/service/service.ts
4
6
  import axios from "axios";
5
- var getService = () => {
6
- const appApiServiceGet = (options) => {
7
- return axios.get(`/service`, options);
8
- };
9
- const appApiServiceGetId = (svcId, options) => {
10
- return axios.get(`/service/${svcId}`, options);
11
- };
12
- return { appApiServiceGet, appApiServiceGetId };
7
+ import {
8
+ useQuery
9
+ } from "react-query";
10
+ var appApiServiceGet = (options) => {
11
+ return axios.get(`/service`, options);
12
+ };
13
+ var getAppApiServiceGetQueryKey = () => [`/service`];
14
+ var useAppApiServiceGet = (options) => {
15
+ const { query: queryOptions, axios: axiosOptions } = options || {};
16
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getAppApiServiceGetQueryKey();
17
+ const queryFn = () => appApiServiceGet(axiosOptions);
18
+ const query = useQuery(queryKey, queryFn, queryOptions);
19
+ return __spreadValues({
20
+ queryKey
21
+ }, query);
22
+ };
23
+ var appApiServiceGetId = (svcId, options) => {
24
+ return axios.get(`/service/${svcId}`, options);
25
+ };
26
+ var getAppApiServiceGetIdQueryKey = (svcId) => [
27
+ `/service/${svcId}`
28
+ ];
29
+ var useAppApiServiceGetId = (svcId, options) => {
30
+ const { query: queryOptions, axios: axiosOptions } = options || {};
31
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getAppApiServiceGetIdQueryKey(svcId);
32
+ const queryFn = () => appApiServiceGetId(svcId, axiosOptions);
33
+ const query = useQuery(queryKey, queryFn, __spreadValues({ enabled: !!svcId }, queryOptions));
34
+ return __spreadValues({
35
+ queryKey
36
+ }, query);
13
37
  };
14
38
  export {
15
- getService
39
+ appApiServiceGet,
40
+ appApiServiceGetId,
41
+ getAppApiServiceGetIdQueryKey,
42
+ getAppApiServiceGetQueryKey,
43
+ useAppApiServiceGet,
44
+ useAppApiServiceGetId
16
45
  };
17
46
  //# sourceMappingURL=service.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/service/service.ts"],"sourcesContent":["/**\n * Generated by orval v6.7.1 🍺\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 axios, { AxiosRequestConfig, AxiosResponse } from \"axios\";\nimport type {\n ServicesGetResponse,\n ServiceGetResponse,\n} from \"../account-server-api.schemas\";\n\nexport const getService = () => {\n /**\n * Gets services known to the Account Server\n\n * @summary Gets all Services\n */\n const appApiServiceGet = <TData = AxiosResponse<ServicesGetResponse>>(\n options?: AxiosRequestConfig\n ): Promise<TData> => {\n return axios.get(`/service`, options);\n };\n /**\n * Gets a known service\n\n * @summary Gets a specific Service\n */\n const appApiServiceGetId = <TData = AxiosResponse<ServiceGetResponse>>(\n svcId: number,\n options?: AxiosRequestConfig\n ): Promise<TData> => {\n return axios.get(`/service/${svcId}`, options);\n };\n return { appApiServiceGet, appApiServiceGetId };\n};\nexport type AppApiServiceGetResult = AxiosResponse<ServicesGetResponse>;\nexport type AppApiServiceGetIdResult = AxiosResponse<ServiceGetResponse>;\n"],"mappings":";;;AAUA;AAMO,IAAM,aAAa,MAAM;AAM9B,QAAM,mBAAmB,CACvB,YACmB;AACnB,WAAO,MAAM,IAAI,YAAY,OAAO;AAAA,EACtC;AAMA,QAAM,qBAAqB,CACzB,OACA,YACmB;AACnB,WAAO,MAAM,IAAI,YAAY,SAAS,OAAO;AAAA,EAC/C;AACA,SAAO,EAAE,kBAAkB,mBAAmB;AAChD;","names":[]}
1
+ {"version":3,"sources":["../../src/service/service.ts"],"sourcesContent":["/**\n * Generated by orval v6.7.1 🍺\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 axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from \"axios\";\nimport {\n useQuery,\n UseQueryOptions,\n QueryFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n ServicesGetResponse,\n AsError,\n ServiceGetResponse,\n} from \"../account-server-api.schemas\";\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/**\n * Gets services known to the Account Server\n\n * @summary Gets all Services\n */\nexport const appApiServiceGet = (\n options?: AxiosRequestConfig\n): Promise<AxiosResponse<ServicesGetResponse>> => {\n return axios.get(`/service`, options);\n};\n\nexport const getAppApiServiceGetQueryKey = () => [`/service`];\n\nexport type AppApiServiceGetQueryResult = NonNullable<\n AsyncReturnType<typeof appApiServiceGet>\n>;\nexport type AppApiServiceGetQueryError = AxiosError<AsError | void>;\n\nexport const useAppApiServiceGet = <\n TData = AsyncReturnType<typeof appApiServiceGet>,\n TError = AxiosError<AsError | void>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof appApiServiceGet>,\n TError,\n TData\n >;\n axios?: AxiosRequestConfig;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, axios: axiosOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getAppApiServiceGetQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof appApiServiceGet>> = () =>\n appApiServiceGet(axiosOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof appApiServiceGet>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets a known service\n\n * @summary Gets a specific Service\n */\nexport const appApiServiceGetId = (\n svcId: number,\n options?: AxiosRequestConfig\n): Promise<AxiosResponse<ServiceGetResponse>> => {\n return axios.get(`/service/${svcId}`, options);\n};\n\nexport const getAppApiServiceGetIdQueryKey = (svcId: number) => [\n `/service/${svcId}`,\n];\n\nexport type AppApiServiceGetIdQueryResult = NonNullable<\n AsyncReturnType<typeof appApiServiceGetId>\n>;\nexport type AppApiServiceGetIdQueryError = AxiosError<AsError | void>;\n\nexport const useAppApiServiceGetId = <\n TData = AsyncReturnType<typeof appApiServiceGetId>,\n TError = AxiosError<AsError | void>\n>(\n svcId: number,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof appApiServiceGetId>,\n TError,\n TData\n >;\n axios?: AxiosRequestConfig;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, axios: axiosOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getAppApiServiceGetIdQueryKey(svcId);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof appApiServiceGetId>\n > = () => appApiServiceGetId(svcId, axiosOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof appApiServiceGetId>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!svcId, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n"],"mappings":";;;;;AAUA;AACA;AAAA;AAAA;AAyBO,IAAM,mBAAmB,CAC9B,YACgD;AAChD,SAAO,MAAM,IAAI,YAAY,OAAO;AACtC;AAEO,IAAM,8BAA8B,MAAM,CAAC,UAAU;AAOrD,IAAM,sBAAsB,CAGjC,YAO4D;AAC5D,QAAM,EAAE,OAAO,cAAc,OAAO,iBAAiB,WAAW,CAAC;AAEjE,QAAM,WAAW,8CAAc,aAAY,4BAA4B;AAEvE,QAAM,UAAmE,MACvE,iBAAiB,YAAY;AAE/B,QAAM,QAAQ,SAIZ,UAAU,SAAS,YAAY;AAEjC,SAAO;AAAA,IACL;AAAA,KACG;AAEP;AAOO,IAAM,qBAAqB,CAChC,OACA,YAC+C;AAC/C,SAAO,MAAM,IAAI,YAAY,SAAS,OAAO;AAC/C;AAEO,IAAM,gCAAgC,CAAC,UAAkB;AAAA,EAC9D,YAAY;AACd;AAOO,IAAM,wBAAwB,CAInC,OACA,YAQ2D;AAC3D,QAAM,EAAE,OAAO,cAAc,OAAO,iBAAiB,WAAW,CAAC;AAEjE,QAAM,WACJ,8CAAc,aAAY,8BAA8B,KAAK;AAE/D,QAAM,UAEF,MAAM,mBAAmB,OAAO,YAAY;AAEhD,QAAM,QAAQ,SAIZ,UAAU,SAAS,iBAAE,SAAS,CAAC,CAAC,SAAU,aAAc;AAE1D,SAAO;AAAA,IACL;AAAA,KACG;AAEP;","names":[]}
@@ -94,12 +94,16 @@ export interface UserAccountDetail {
94
94
  }
95
95
 
96
96
  export interface UnitDetail {
97
+ /** Whether the user making the API call is a member of the Unit */
98
+ caller_is_member: boolean;
97
99
  /** The Unit's unique identity */
98
100
  id: string;
99
101
  /** The Unit's name */
100
102
  name: string;
101
103
  /** The Unit's owner (a username) */
102
104
  owner_id: string;
105
+ /** True if the Unit is private */
106
+ private: boolean;
103
107
  }
104
108
 
105
109
  /**
@@ -128,12 +132,16 @@ export interface ServicesGetResponse {
128
132
  }
129
133
 
130
134
  export interface OrganisationDetail {
135
+ /** Whether the user making the API call is a member of the Unit */
136
+ caller_is_member: boolean;
131
137
  /** The Organisation's unique ID */
132
138
  id: string;
133
139
  /** The Organisation's name */
134
140
  name: string;
135
141
  /** The username of the Organisation's owner. Not all Organisations have an owner. The Default Organisation has no owner. */
136
142
  owner_id?: string;
143
+ /** True if the Unit is private */
144
+ private: boolean;
137
145
  }
138
146
 
139
147
  export interface ProductType {
@@ -349,12 +357,17 @@ export interface OrganisationUnitPostResponse {
349
357
  }
350
358
 
351
359
  export interface OrganisationGetDefaultResponse {
360
+ /** Whether the user making the API call is a member of the Default Organisation. Only admin users are members of the Default organisation */
361
+ caller_is_member: boolean;
352
362
  /** The Default Organisation ID
353
363
  */
354
364
  id: string;
355
365
  /** The Default Organisation Name
356
366
  */
357
367
  name: string;
368
+ /** True if the Organisation is private. The Default organisation is always public, although it does not contain a membership (unless you're admin) and only houses Personal Units
369
+ */
370
+ private: boolean;
358
371
  }
359
372
 
360
373
  export interface UsersGetResponse {
@@ -8,78 +8,229 @@ A service that provides access to the Account Server, which gives *registered* u
8
8
 
9
9
  * OpenAPI spec version: 0.1
10
10
  */
11
- import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
11
+ import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
12
+ import {
13
+ useQuery,
14
+ useMutation,
15
+ UseQueryOptions,
16
+ UseMutationOptions,
17
+ QueryFunction,
18
+ MutationFunction,
19
+ UseQueryResult,
20
+ QueryKey,
21
+ } from "react-query";
12
22
  import type {
13
23
  OrganisationsGetResponse,
24
+ AsError,
14
25
  OrganisationPostResponse,
15
26
  OrganisationPostBodyBody,
16
27
  OrganisationGetDefaultResponse,
17
28
  } from "../account-server-api.schemas";
18
29
 
19
- export const getOrganisation = () => {
20
- /**
21
- * Gets all the Organisations you are a member of. Admin users can see all Organisations
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
32
+ ...args: any
33
+ ) => Promise<infer R>
34
+ ? R
35
+ : any;
36
+
37
+ /**
38
+ * Gets all the Organisations that you are a member of or are public. Admin users are members of all organisation and can see all Organisations
22
39
 
23
40
  * @summary Gets Organisations
24
41
  */
25
- const appApiOrganisationGet = <
26
- TData = AxiosResponse<OrganisationsGetResponse>
27
- >(
28
- options?: AxiosRequestConfig
29
- ): Promise<TData> => {
30
- return axios.get(`/organisation`, options);
42
+ export const appApiOrganisationGet = (
43
+ options?: AxiosRequestConfig
44
+ ): Promise<AxiosResponse<OrganisationsGetResponse>> => {
45
+ return axios.get(`/organisation`, options);
46
+ };
47
+
48
+ export const getAppApiOrganisationGetQueryKey = () => [`/organisation`];
49
+
50
+ export type AppApiOrganisationGetQueryResult = NonNullable<
51
+ AsyncReturnType<typeof appApiOrganisationGet>
52
+ >;
53
+ export type AppApiOrganisationGetQueryError = AxiosError<void | AsError>;
54
+
55
+ export const useAppApiOrganisationGet = <
56
+ TData = AsyncReturnType<typeof appApiOrganisationGet>,
57
+ TError = AxiosError<void | AsError>
58
+ >(options?: {
59
+ query?: UseQueryOptions<
60
+ AsyncReturnType<typeof appApiOrganisationGet>,
61
+ TError,
62
+ TData
63
+ >;
64
+ axios?: AxiosRequestConfig;
65
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
66
+ const { query: queryOptions, axios: axiosOptions } = options || {};
67
+
68
+ const queryKey = queryOptions?.queryKey ?? getAppApiOrganisationGetQueryKey();
69
+
70
+ const queryFn: QueryFunction<
71
+ AsyncReturnType<typeof appApiOrganisationGet>
72
+ > = () => appApiOrganisationGet(axiosOptions);
73
+
74
+ const query = useQuery<
75
+ AsyncReturnType<typeof appApiOrganisationGet>,
76
+ TError,
77
+ TData
78
+ >(queryKey, queryFn, queryOptions);
79
+
80
+ return {
81
+ queryKey,
82
+ ...query,
31
83
  };
32
- /**
84
+ };
85
+
86
+ /**
33
87
  * Creates a new Organisation
34
88
 
35
89
  You need **admin** rights to use this method
36
90
 
37
91
  * @summary Create a new organisation
38
92
  */
39
- const appApiOrganisationPost = <
40
- TData = AxiosResponse<OrganisationPostResponse>
41
- >(
42
- organisationPostBodyBody: OrganisationPostBodyBody,
43
- options?: AxiosRequestConfig
44
- ): Promise<TData> => {
45
- return axios.post(`/organisation`, organisationPostBodyBody, options);
93
+ export const appApiOrganisationPost = (
94
+ organisationPostBodyBody: OrganisationPostBodyBody,
95
+ options?: AxiosRequestConfig
96
+ ): Promise<AxiosResponse<OrganisationPostResponse>> => {
97
+ return axios.post(`/organisation`, organisationPostBodyBody, options);
98
+ };
99
+
100
+ export type AppApiOrganisationPostMutationResult = NonNullable<
101
+ AsyncReturnType<typeof appApiOrganisationPost>
102
+ >;
103
+ export type AppApiOrganisationPostMutationBody = OrganisationPostBodyBody;
104
+ export type AppApiOrganisationPostMutationError = AxiosError<AsError | void>;
105
+
106
+ export const useAppApiOrganisationPost = <
107
+ TError = AxiosError<AsError | void>,
108
+ TContext = unknown
109
+ >(options?: {
110
+ mutation?: UseMutationOptions<
111
+ AsyncReturnType<typeof appApiOrganisationPost>,
112
+ TError,
113
+ { data: OrganisationPostBodyBody },
114
+ TContext
115
+ >;
116
+ axios?: AxiosRequestConfig;
117
+ }) => {
118
+ const { mutation: mutationOptions, axios: axiosOptions } = options || {};
119
+
120
+ const mutationFn: MutationFunction<
121
+ AsyncReturnType<typeof appApiOrganisationPost>,
122
+ { data: OrganisationPostBodyBody }
123
+ > = (props) => {
124
+ const { data } = props || {};
125
+
126
+ return appApiOrganisationPost(data, axiosOptions);
46
127
  };
47
- /**
128
+
129
+ return useMutation<
130
+ AsyncReturnType<typeof appApiOrganisationPost>,
131
+ TError,
132
+ { data: OrganisationPostBodyBody },
133
+ TContext
134
+ >(mutationFn, mutationOptions);
135
+ };
136
+ /**
48
137
  * Units must first be deleted before an Organisation can be deleted
49
138
 
50
139
  You need **admin** rights to use this method
51
140
 
52
141
  * @summary Deletes an Organisation
53
142
  */
54
- const appApiOrganisationDelete = <TData = AxiosResponse<void>>(
55
- orgId: string,
56
- options?: AxiosRequestConfig
57
- ): Promise<TData> => {
58
- return axios.delete(`/organisation/${orgId}`, options);
143
+ export const appApiOrganisationDelete = (
144
+ orgId: string,
145
+ options?: AxiosRequestConfig
146
+ ): Promise<AxiosResponse<void>> => {
147
+ return axios.delete(`/organisation/${orgId}`, options);
148
+ };
149
+
150
+ export type AppApiOrganisationDeleteMutationResult = NonNullable<
151
+ AsyncReturnType<typeof appApiOrganisationDelete>
152
+ >;
153
+
154
+ export type AppApiOrganisationDeleteMutationError = AxiosError<AsError>;
155
+
156
+ export const useAppApiOrganisationDelete = <
157
+ TError = AxiosError<AsError>,
158
+ TContext = unknown
159
+ >(options?: {
160
+ mutation?: UseMutationOptions<
161
+ AsyncReturnType<typeof appApiOrganisationDelete>,
162
+ TError,
163
+ { orgId: string },
164
+ TContext
165
+ >;
166
+ axios?: AxiosRequestConfig;
167
+ }) => {
168
+ const { mutation: mutationOptions, axios: axiosOptions } = options || {};
169
+
170
+ const mutationFn: MutationFunction<
171
+ AsyncReturnType<typeof appApiOrganisationDelete>,
172
+ { orgId: string }
173
+ > = (props) => {
174
+ const { orgId } = props || {};
175
+
176
+ return appApiOrganisationDelete(orgId, axiosOptions);
59
177
  };
60
- /**
61
- * Gets the built-in Default Organisation, used exclusively for Independent Units
178
+
179
+ return useMutation<
180
+ AsyncReturnType<typeof appApiOrganisationDelete>,
181
+ TError,
182
+ { orgId: string },
183
+ TContext
184
+ >(mutationFn, mutationOptions);
185
+ };
186
+ /**
187
+ * Gets the built-in Default Organisation, used exclusively for Personal Units
62
188
 
63
189
  * @summary Gets the (built-in) Default Organisation
64
190
  */
65
- const appApiOrganisationGetDefault = <
66
- TData = AxiosResponse<OrganisationGetDefaultResponse>
67
- >(
68
- options?: AxiosRequestConfig
69
- ): Promise<TData> => {
70
- return axios.get(`/organisation/default`, options);
71
- };
191
+ export const appApiOrganisationGetDefault = (
192
+ options?: AxiosRequestConfig
193
+ ): Promise<AxiosResponse<OrganisationGetDefaultResponse>> => {
194
+ return axios.get(`/organisation/default`, options);
195
+ };
196
+
197
+ export const getAppApiOrganisationGetDefaultQueryKey = () => [
198
+ `/organisation/default`,
199
+ ];
200
+
201
+ export type AppApiOrganisationGetDefaultQueryResult = NonNullable<
202
+ AsyncReturnType<typeof appApiOrganisationGetDefault>
203
+ >;
204
+ export type AppApiOrganisationGetDefaultQueryError = AxiosError<void | AsError>;
205
+
206
+ export const useAppApiOrganisationGetDefault = <
207
+ TData = AsyncReturnType<typeof appApiOrganisationGetDefault>,
208
+ TError = AxiosError<void | AsError>
209
+ >(options?: {
210
+ query?: UseQueryOptions<
211
+ AsyncReturnType<typeof appApiOrganisationGetDefault>,
212
+ TError,
213
+ TData
214
+ >;
215
+ axios?: AxiosRequestConfig;
216
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
217
+ const { query: queryOptions, axios: axiosOptions } = options || {};
218
+
219
+ const queryKey =
220
+ queryOptions?.queryKey ?? getAppApiOrganisationGetDefaultQueryKey();
221
+
222
+ const queryFn: QueryFunction<
223
+ AsyncReturnType<typeof appApiOrganisationGetDefault>
224
+ > = () => appApiOrganisationGetDefault(axiosOptions);
225
+
226
+ const query = useQuery<
227
+ AsyncReturnType<typeof appApiOrganisationGetDefault>,
228
+ TError,
229
+ TData
230
+ >(queryKey, queryFn, queryOptions);
231
+
72
232
  return {
73
- appApiOrganisationGet,
74
- appApiOrganisationPost,
75
- appApiOrganisationDelete,
76
- appApiOrganisationGetDefault,
233
+ queryKey,
234
+ ...query,
77
235
  };
78
236
  };
79
- export type AppApiOrganisationGetResult =
80
- AxiosResponse<OrganisationsGetResponse>;
81
- export type AppApiOrganisationPostResult =
82
- AxiosResponse<OrganisationPostResponse>;
83
- export type AppApiOrganisationDeleteResult = AxiosResponse<void>;
84
- export type AppApiOrganisationGetDefaultResult =
85
- AxiosResponse<OrganisationGetDefaultResponse>;