@squonk/account-server-client 0.1.10-rc.1 → 0.1.14-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 (43) hide show
  1. package/chunk-3DXYUDZH.cjs +46 -0
  2. package/chunk-3DXYUDZH.cjs.map +1 -0
  3. package/chunk-JR7F532L.js +46 -0
  4. package/chunk-JR7F532L.js.map +1 -0
  5. package/{custom-instance-3334b00b.d.ts → custom-instance-7503296b.d.ts} +28 -16
  6. package/index.cjs +15 -79
  7. package/index.cjs.map +1 -7
  8. package/index.d.ts +1 -1
  9. package/index.js +7 -37
  10. package/index.js.map +1 -7
  11. package/organisation/organisation.cjs +24 -80
  12. package/organisation/organisation.cjs.map +1 -7
  13. package/organisation/organisation.d.ts +1 -1
  14. package/organisation/organisation.js +6 -34
  15. package/organisation/organisation.js.map +1 -7
  16. package/package.json +8 -8
  17. package/product/product.cjs +55 -101
  18. package/product/product.cjs.map +1 -7
  19. package/product/product.d.ts +15 -2
  20. package/product/product.js +20 -32
  21. package/product/product.js.map +1 -7
  22. package/service/service.cjs +22 -78
  23. package/service/service.cjs.map +1 -7
  24. package/service/service.d.ts +2 -2
  25. package/service/service.js +5 -33
  26. package/service/service.js.map +1 -7
  27. package/src/account-server-api.schemas.ts +31 -17
  28. package/src/custom-instance.ts +1 -2
  29. package/src/organisation/organisation.ts +4 -2
  30. package/src/product/product.ts +51 -2
  31. package/src/service/service.ts +3 -1
  32. package/src/unit/unit.ts +57 -11
  33. package/src/user/user.ts +7 -17
  34. package/unit/unit.cjs +58 -107
  35. package/unit/unit.cjs.map +1 -7
  36. package/unit/unit.d.ts +15 -2
  37. package/unit/unit.js +26 -40
  38. package/unit/unit.js.map +1 -7
  39. package/user/user.cjs +40 -115
  40. package/user/user.cjs.map +1 -7
  41. package/user/user.d.ts +1 -1
  42. package/user/user.js +9 -49
  43. package/user/user.js.map +1 -7
package/src/unit/unit.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.4.2 🍺
2
+ * Generated by orval v6.6.0 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -23,16 +23,19 @@ import type {
23
23
  AsError,
24
24
  OrganisationUnitPostResponse,
25
25
  OrganisationUnitPostBodyBody,
26
+ UnitGetResponse,
26
27
  UnitsGetResponse,
27
28
  } from "../account-server-api.schemas";
28
29
  import { customInstance, ErrorType } from ".././custom-instance";
29
30
 
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
32
  type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
31
33
  ...args: any
32
34
  ) => Promise<infer R>
33
35
  ? R
34
36
  : any;
35
37
 
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
39
  type SecondParameter<T extends (...args: any) => any> = T extends (
37
40
  config: any,
38
41
  args: infer P
@@ -144,6 +147,56 @@ export const useCreateOrganisationUnit = <
144
147
  TContext
145
148
  >(mutationFn, mutationOptions);
146
149
  };
150
+ /**
151
+ * Gets the Unit, assuming you are a member of it. Admin users can see all Units
152
+
153
+ * @summary Gets a Unit
154
+ */
155
+ export const getUnit = (
156
+ orgid: string,
157
+ unitid: string,
158
+ options?: SecondParameter<typeof customInstance>
159
+ ) => {
160
+ return customInstance<UnitGetResponse>(
161
+ { url: `/organisation/${orgid}/unit/${unitid}`, method: "get" },
162
+ options
163
+ );
164
+ };
165
+
166
+ export const getGetUnitQueryKey = (orgid: string, unitid: string) => [
167
+ `/organisation/${orgid}/unit/${unitid}`,
168
+ ];
169
+
170
+ export const useGetUnit = <
171
+ TData = AsyncReturnType<typeof getUnit>,
172
+ TError = ErrorType<void | AsError>
173
+ >(
174
+ orgid: string,
175
+ unitid: string,
176
+ options?: {
177
+ query?: UseQueryOptions<AsyncReturnType<typeof getUnit>, TError, TData>;
178
+ request?: SecondParameter<typeof customInstance>;
179
+ }
180
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
181
+ const { query: queryOptions, request: requestOptions } = options || {};
182
+
183
+ const queryKey = queryOptions?.queryKey ?? getGetUnitQueryKey(orgid, unitid);
184
+
185
+ const queryFn: QueryFunction<AsyncReturnType<typeof getUnit>> = () =>
186
+ getUnit(orgid, unitid, requestOptions);
187
+
188
+ const query = useQuery<AsyncReturnType<typeof getUnit>, TError, TData>(
189
+ queryKey,
190
+ queryFn,
191
+ { enabled: !!(orgid && unitid), ...queryOptions }
192
+ );
193
+
194
+ return {
195
+ queryKey,
196
+ ...query,
197
+ };
198
+ };
199
+
147
200
  /**
148
201
  * Deletes an Organisational Unit you have access to. Units can only be deleted by Organisation users or Admin users. You cannot delete a Unit that contains Products
149
202
 
@@ -155,11 +208,7 @@ export const deleteOrganisationUnit = (
155
208
  options?: SecondParameter<typeof customInstance>
156
209
  ) => {
157
210
  return customInstance<void>(
158
- {
159
- url: `/organisation/${orgid}/unit/${unitid}`,
160
- method: "delete",
161
- data: undefined,
162
- },
211
+ { url: `/organisation/${orgid}/unit/${unitid}`, method: "delete" },
163
212
  options
164
213
  );
165
214
  };
@@ -243,7 +292,7 @@ export const createDefaultUnit = (
243
292
  options?: SecondParameter<typeof customInstance>
244
293
  ) => {
245
294
  return customInstance<OrganisationUnitPostResponse>(
246
- { url: `/unit`, method: "put", data: undefined },
295
+ { url: `/unit`, method: "put" },
247
296
  options
248
297
  );
249
298
  };
@@ -285,10 +334,7 @@ export const useCreateDefaultUnit = <
285
334
  export const deleteDefaultUnit = (
286
335
  options?: SecondParameter<typeof customInstance>
287
336
  ) => {
288
- return customInstance<void>(
289
- { url: `/unit`, method: "delete", data: undefined },
290
- options
291
- );
337
+ return customInstance<void>({ url: `/unit`, method: "delete" }, options);
292
338
  };
293
339
 
294
340
  export const useDeleteDefaultUnit = <
package/src/user/user.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.4.2 🍺
2
+ * Generated by orval v6.6.0 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -21,12 +21,14 @@ import {
21
21
  import type { UsersGetResponse, AsError } from "../account-server-api.schemas";
22
22
  import { customInstance, ErrorType } from ".././custom-instance";
23
23
 
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
25
  type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
25
26
  ...args: any
26
27
  ) => Promise<infer R>
27
28
  ? R
28
29
  : any;
29
30
 
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
32
  type SecondParameter<T extends (...args: any) => any> = T extends (
31
33
  config: any,
32
34
  args: infer P
@@ -99,11 +101,7 @@ export const addOrganisationUser = (
99
101
  options?: SecondParameter<typeof customInstance>
100
102
  ) => {
101
103
  return customInstance<void>(
102
- {
103
- url: `/organisation/${orgid}/user/${userid}`,
104
- method: "put",
105
- data: undefined,
106
- },
104
+ { url: `/organisation/${orgid}/user/${userid}`, method: "put" },
107
105
  options
108
106
  );
109
107
  };
@@ -149,11 +147,7 @@ export const deleteOrganisationUser = (
149
147
  options?: SecondParameter<typeof customInstance>
150
148
  ) => {
151
149
  return customInstance<void>(
152
- {
153
- url: `/organisation/${orgid}/user/${userid}`,
154
- method: "delete",
155
- data: undefined,
156
- },
150
+ { url: `/organisation/${orgid}/user/${userid}`, method: "delete" },
157
151
  options
158
152
  );
159
153
  };
@@ -253,7 +247,7 @@ export const addOrganisationUnitUser = (
253
247
  options?: SecondParameter<typeof customInstance>
254
248
  ) => {
255
249
  return customInstance<void>(
256
- { url: `/unit/${unitid}/user/${userid}`, method: "put", data: undefined },
250
+ { url: `/unit/${unitid}/user/${userid}`, method: "put" },
257
251
  options
258
252
  );
259
253
  };
@@ -299,11 +293,7 @@ export const deleteOrganisationUnitUser = (
299
293
  options?: SecondParameter<typeof customInstance>
300
294
  ) => {
301
295
  return customInstance<void>(
302
- {
303
- url: `/unit/${unitid}/user/${userid}`,
304
- method: "delete",
305
- data: undefined,
306
- },
296
+ { url: `/unit/${unitid}/user/${userid}`, method: "delete" },
307
297
  options
308
298
  );
309
299
  };
package/unit/unit.cjs CHANGED
@@ -1,93 +1,30 @@
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
- };
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
41
2
 
42
- // src/unit/unit.ts
43
- __export(exports, {
44
- createDefaultUnit: () => createDefaultUnit,
45
- createOrganisationUnit: () => createOrganisationUnit,
46
- deleteDefaultUnit: () => deleteDefaultUnit,
47
- deleteOrganisationUnit: () => deleteOrganisationUnit,
48
- getGetOrganisationUnitsQueryKey: () => getGetOrganisationUnitsQueryKey,
49
- getGetUnitsQueryKey: () => getGetUnitsQueryKey,
50
- getOrganisationUnits: () => getOrganisationUnits,
51
- getUnits: () => getUnits,
52
- useCreateDefaultUnit: () => useCreateDefaultUnit,
53
- useCreateOrganisationUnit: () => useCreateOrganisationUnit,
54
- useDeleteDefaultUnit: () => useDeleteDefaultUnit,
55
- useDeleteOrganisationUnit: () => useDeleteOrganisationUnit,
56
- useGetOrganisationUnits: () => useGetOrganisationUnits,
57
- useGetUnits: () => useGetUnits
58
- });
59
- var import_react_query = __toModule(require("react-query"));
60
-
61
- // src/custom-instance.ts
62
- var import_axios = __toModule(require("axios"));
63
- var AXIOS_INSTANCE = import_axios.default.create({ baseURL: "" });
64
- var customInstance = (config, options) => {
65
- const source = import_axios.default.CancelToken.source();
66
- const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
67
- promise.cancel = () => {
68
- source.cancel("Query was cancelled by React Query");
69
- };
70
- return promise;
71
- };
3
+
4
+ var _chunk3DXYUDZHcjs = require('../chunk-3DXYUDZH.cjs');
72
5
 
73
6
  // src/unit/unit.ts
7
+
8
+
9
+
10
+ var _reactquery = require('react-query');
74
11
  var getOrganisationUnits = (orgid, options) => {
75
- return customInstance({ url: `/organisation/${orgid}/unit`, method: "get" }, options);
12
+ return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/organisation/${orgid}/unit`, method: "get" }, options);
76
13
  };
77
14
  var getGetOrganisationUnitsQueryKey = (orgid) => [
78
15
  `/organisation/${orgid}/unit`
79
16
  ];
80
17
  var useGetOrganisationUnits = (orgid, options) => {
81
18
  const { query: queryOptions, request: requestOptions } = options || {};
82
- const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationUnitsQueryKey(orgid);
19
+ const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetOrganisationUnitsQueryKey(orgid)));
83
20
  const queryFn = () => getOrganisationUnits(orgid, requestOptions);
84
- const query = (0, import_react_query.useQuery)(queryKey, queryFn, __spreadValues({ enabled: !!orgid }, queryOptions));
85
- return __spreadValues({
21
+ const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, _chunk3DXYUDZHcjs.__spreadValues.call(void 0, { enabled: !!orgid }, queryOptions));
22
+ return _chunk3DXYUDZHcjs.__spreadValues.call(void 0, {
86
23
  queryKey
87
24
  }, query);
88
25
  };
89
26
  var createOrganisationUnit = (orgid, organisationUnitPostBodyBody, options) => {
90
- return customInstance({
27
+ return _chunk3DXYUDZHcjs.customInstance.call(void 0, {
91
28
  url: `/organisation/${orgid}/unit`,
92
29
  method: "post",
93
30
  data: organisationUnitPostBodyBody
@@ -99,14 +36,25 @@ var useCreateOrganisationUnit = (options) => {
99
36
  const { orgid, data } = props || {};
100
37
  return createOrganisationUnit(orgid, data, requestOptions);
101
38
  };
102
- return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
39
+ return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
40
+ };
41
+ var getUnit = (orgid, unitid, options) => {
42
+ return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/organisation/${orgid}/unit/${unitid}`, method: "get" }, options);
43
+ };
44
+ var getGetUnitQueryKey = (orgid, unitid) => [
45
+ `/organisation/${orgid}/unit/${unitid}`
46
+ ];
47
+ var useGetUnit = (orgid, unitid, options) => {
48
+ const { query: queryOptions, request: requestOptions } = options || {};
49
+ const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetUnitQueryKey(orgid, unitid)));
50
+ const queryFn = () => getUnit(orgid, unitid, requestOptions);
51
+ const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, _chunk3DXYUDZHcjs.__spreadValues.call(void 0, { enabled: !!(orgid && unitid) }, queryOptions));
52
+ return _chunk3DXYUDZHcjs.__spreadValues.call(void 0, {
53
+ queryKey
54
+ }, query);
103
55
  };
104
56
  var deleteOrganisationUnit = (orgid, unitid, options) => {
105
- return customInstance({
106
- url: `/organisation/${orgid}/unit/${unitid}`,
107
- method: "delete",
108
- data: void 0
109
- }, options);
57
+ return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/organisation/${orgid}/unit/${unitid}`, method: "delete" }, options);
110
58
  };
111
59
  var useDeleteOrganisationUnit = (options) => {
112
60
  const { mutation: mutationOptions, request: requestOptions } = options || {};
@@ -114,55 +62,58 @@ var useDeleteOrganisationUnit = (options) => {
114
62
  const { orgid, unitid } = props || {};
115
63
  return deleteOrganisationUnit(orgid, unitid, requestOptions);
116
64
  };
117
- return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
65
+ return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
118
66
  };
119
67
  var getUnits = (options) => {
120
- return customInstance({ url: `/unit`, method: "get" }, options);
68
+ return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/unit`, method: "get" }, options);
121
69
  };
122
70
  var getGetUnitsQueryKey = () => [`/unit`];
123
71
  var useGetUnits = (options) => {
124
72
  const { query: queryOptions, request: requestOptions } = options || {};
125
- const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetUnitsQueryKey();
73
+ const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetUnitsQueryKey()));
126
74
  const queryFn = () => getUnits(requestOptions);
127
- const query = (0, import_react_query.useQuery)(queryKey, queryFn, queryOptions);
128
- return __spreadValues({
75
+ const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, queryOptions);
76
+ return _chunk3DXYUDZHcjs.__spreadValues.call(void 0, {
129
77
  queryKey
130
78
  }, query);
131
79
  };
132
80
  var createDefaultUnit = (options) => {
133
- return customInstance({ url: `/unit`, method: "put", data: void 0 }, options);
81
+ return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/unit`, method: "put" }, options);
134
82
  };
135
83
  var useCreateDefaultUnit = (options) => {
136
84
  const { mutation: mutationOptions, request: requestOptions } = options || {};
137
85
  const mutationFn = () => {
138
86
  return createDefaultUnit(requestOptions);
139
87
  };
140
- return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
88
+ return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
141
89
  };
142
90
  var deleteDefaultUnit = (options) => {
143
- return customInstance({ url: `/unit`, method: "delete", data: void 0 }, options);
91
+ return _chunk3DXYUDZHcjs.customInstance.call(void 0, { url: `/unit`, method: "delete" }, options);
144
92
  };
145
93
  var useDeleteDefaultUnit = (options) => {
146
94
  const { mutation: mutationOptions, request: requestOptions } = options || {};
147
95
  const mutationFn = () => {
148
96
  return deleteDefaultUnit(requestOptions);
149
97
  };
150
- return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
98
+ return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
151
99
  };
152
- // Annotate the CommonJS export names for ESM import in node:
153
- 0 && (module.exports = {
154
- createDefaultUnit,
155
- createOrganisationUnit,
156
- deleteDefaultUnit,
157
- deleteOrganisationUnit,
158
- getGetOrganisationUnitsQueryKey,
159
- getGetUnitsQueryKey,
160
- getOrganisationUnits,
161
- getUnits,
162
- useCreateDefaultUnit,
163
- useCreateOrganisationUnit,
164
- useDeleteDefaultUnit,
165
- useDeleteOrganisationUnit,
166
- useGetOrganisationUnits,
167
- useGetUnits
168
- });
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ exports.createDefaultUnit = createDefaultUnit; exports.createOrganisationUnit = createOrganisationUnit; exports.deleteDefaultUnit = deleteDefaultUnit; exports.deleteOrganisationUnit = deleteOrganisationUnit; exports.getGetOrganisationUnitsQueryKey = getGetOrganisationUnitsQueryKey; exports.getGetUnitQueryKey = getGetUnitQueryKey; exports.getGetUnitsQueryKey = getGetUnitsQueryKey; exports.getOrganisationUnits = getOrganisationUnits; exports.getUnit = getUnit; exports.getUnits = getUnits; exports.useCreateDefaultUnit = useCreateDefaultUnit; exports.useCreateOrganisationUnit = useCreateOrganisationUnit; exports.useDeleteDefaultUnit = useDeleteDefaultUnit; exports.useDeleteOrganisationUnit = useDeleteOrganisationUnit; exports.useGetOrganisationUnits = useGetOrganisationUnits; exports.useGetUnit = useGetUnit; exports.useGetUnits = useGetUnits;
119
+ //# sourceMappingURL=unit.cjs.map
package/unit/unit.cjs.map CHANGED
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/unit/unit.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 OrganisationUnitsGetResponse,\n AsError,\n OrganisationUnitPostResponse,\n OrganisationUnitPostBodyBody,\n UnitsGetResponse,\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 Organisational Units you have access to\n\n * @summary Gets Organisational Units\n */\nexport const getOrganisationUnits = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationUnitsGetResponse>(\n { url: `/organisation/${orgid}/unit`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUnitsQueryKey = (orgid: string) => [\n `/organisation/${orgid}/unit`,\n];\n\nexport const useGetOrganisationUnits = <\n TData = AsyncReturnType<typeof getOrganisationUnits>,\n TError = ErrorType<void | AsError>\n>(\n orgid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUnits>,\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 ?? getGetOrganisationUnitsQueryKey(orgid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getOrganisationUnits>\n > = () => getOrganisationUnits(orgid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUnits>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!orgid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a new organisation unit. You need to be inthe Organisation or an Admin user to use this endpoint\n\n * @summary Create a new Organisational Unit\n */\nexport const createOrganisationUnit = (\n orgid: string,\n organisationUnitPostBodyBody: OrganisationUnitPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationUnitPostResponse>(\n {\n url: `/organisation/${orgid}/unit`,\n method: \"post\",\n data: organisationUnitPostBodyBody,\n },\n options\n );\n};\n\nexport const useCreateOrganisationUnit = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createOrganisationUnit>,\n TError,\n { orgid: string; data: OrganisationUnitPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createOrganisationUnit>,\n { orgid: string; data: OrganisationUnitPostBodyBody }\n > = (props) => {\n const { orgid, data } = props || {};\n\n return createOrganisationUnit(orgid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createOrganisationUnit>,\n TError,\n { orgid: string; data: OrganisationUnitPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Deletes an Organisational Unit you have access to. Units can only be deleted by Organisation users or Admin users. You cannot delete a Unit that contains Products\n\n * @summary Deletes an Organisational Unit\n */\nexport const deleteOrganisationUnit = (\n orgid: string,\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/organisation/${orgid}/unit/${unitid}`,\n method: \"delete\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useDeleteOrganisationUnit = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUnit>,\n TError,\n { orgid: string; unitid: 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 deleteOrganisationUnit>,\n { orgid: string; unitid: string }\n > = (props) => {\n const { orgid, unitid } = props || {};\n\n return deleteOrganisationUnit(orgid, unitid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUnit>,\n TError,\n { orgid: string; unitid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets all the Units you are a member of. Admin users can see all Units\n\n * @summary Gets Units a User has access to\n */\nexport const getUnits = (options?: SecondParameter<typeof customInstance>) => {\n return customInstance<UnitsGetResponse>(\n { url: `/unit`, method: \"get\" },\n options\n );\n};\n\nexport const getGetUnitsQueryKey = () => [`/unit`];\n\nexport const useGetUnits = <\n TData = AsyncReturnType<typeof getUnits>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getUnits>, 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 ?? getGetUnitsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getUnits>> = () =>\n getUnits(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getUnits>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a Unit for an independent User. The unit will belong to the built-in **Default** Organisation. Users can only have one Independent Unit and Independent Units cannot have other Users\n\n * @summary Create a new Independent User Unit\n */\nexport const createDefaultUnit = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationUnitPostResponse>(\n { url: `/unit`, method: \"put\", data: undefined },\n options\n );\n};\n\nexport const useCreateDefaultUnit = <\n TError = ErrorType<AsError | void>,\n TVariables = void,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createDefaultUnit>,\n TError,\n TVariables,\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createDefaultUnit>,\n TVariables\n > = () => {\n return createDefaultUnit(requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createDefaultUnit>,\n TError,\n TVariables,\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Deletes an Independent Unit. It must be your Unit, which belongs to the Default Organisation\n\n * @summary Deletes an Independent Unit\n */\nexport const deleteDefaultUnit = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit`, method: \"delete\", data: undefined },\n options\n );\n};\n\nexport const useDeleteDefaultUnit = <\n TError = ErrorType<AsError>,\n TVariables = void,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteDefaultUnit>,\n TError,\n TVariables,\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteDefaultUnit>,\n TVariables\n > = () => {\n return deleteDefaultUnit(requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteDefaultUnit>,\n TError,\n TVariables,\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;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;;;ADDF,IAAM,uBAAuB,CAClC,OACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,cAAc,QAAQ,SAC9C;AAAA;AAIG,IAAM,kCAAkC,CAAC,UAAkB;AAAA,EAChE,iBAAiB;AAAA;AAGZ,IAAM,0BAA0B,CAIrC,OACA,YAQ2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WACJ,8CAAc,aAAY,gCAAgC;AAE5D,QAAM,UAEF,MAAM,qBAAqB,OAAO;AAEtC,QAAM,QAAQ,iCAIZ,UAAU,SAAS,iBAAE,SAAS,CAAC,CAAC,SAAU;AAE5C,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,IAAM,yBAAyB,CACpC,OACA,8BACA,YACG;AACH,SAAO,eACL;AAAA,IACE,KAAK,iBAAiB;AAAA,IACtB,QAAQ;AAAA,IACR,MAAM;AAAA,KAER;AAAA;AAIG,IAAM,4BAA4B,CAGvC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,S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O,YAKL,YAAY;AAAA;AAOT,IAAM,oBAAoB,CAC/B,YACG;AACH,SAAO,eAAqB,EAAE,KAAK,SAAS,QAAQ,YAAY;AAAA;AAG3D,IAAM,uBAAuB,CAIlC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,MAAM;AACR,WAAO,kBAAkB;AAAA;AAG3B,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 OrganisationUnitsGetResponse,\n AsError,\n OrganisationUnitPostResponse,\n OrganisationUnitPostBodyBody,\n UnitGetResponse,\n UnitsGetResponse,\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 Organisational Units you have access to\n\n * @summary Gets Organisational Units\n */\nexport const getOrganisationUnits = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationUnitsGetResponse>(\n { url: `/organisation/${orgid}/unit`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUnitsQueryKey = (orgid: string) => [\n `/organisation/${orgid}/unit`,\n];\n\nexport const useGetOrganisationUnits = <\n TData = AsyncReturnType<typeof getOrganisationUnits>,\n TError = ErrorType<void | AsError>\n>(\n orgid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUnits>,\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 ?? getGetOrganisationUnitsQueryKey(orgid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getOrganisationUnits>\n > = () => getOrganisationUnits(orgid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUnits>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!orgid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a new organisation unit. You need to be inthe Organisation or an Admin user to use this endpoint\n\n * @summary Create a new Organisational Unit\n */\nexport const createOrganisationUnit = (\n orgid: string,\n organisationUnitPostBodyBody: OrganisationUnitPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationUnitPostResponse>(\n {\n url: `/organisation/${orgid}/unit`,\n method: \"post\",\n data: organisationUnitPostBodyBody,\n },\n options\n );\n};\n\nexport const useCreateOrganisationUnit = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createOrganisationUnit>,\n TError,\n { orgid: string; data: OrganisationUnitPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createOrganisationUnit>,\n { orgid: string; data: OrganisationUnitPostBodyBody }\n > = (props) => {\n const { orgid, data } = props || {};\n\n return createOrganisationUnit(orgid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createOrganisationUnit>,\n TError,\n { orgid: string; data: OrganisationUnitPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets the Unit, assuming you are a member of it. Admin users can see all Units\n\n * @summary Gets a Unit\n */\nexport const getUnit = (\n orgid: string,\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UnitGetResponse>(\n { url: `/organisation/${orgid}/unit/${unitid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetUnitQueryKey = (orgid: string, unitid: string) => [\n `/organisation/${orgid}/unit/${unitid}`,\n];\n\nexport const useGetUnit = <\n TData = AsyncReturnType<typeof getUnit>,\n TError = ErrorType<void | AsError>\n>(\n orgid: string,\n unitid: string,\n options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getUnit>, 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 = queryOptions?.queryKey ?? getGetUnitQueryKey(orgid, unitid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getUnit>> = () =>\n getUnit(orgid, unitid, requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getUnit>, TError, TData>(\n queryKey,\n queryFn,\n { enabled: !!(orgid && unitid), ...queryOptions }\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Deletes an Organisational Unit you have access to. Units can only be deleted by Organisation users or Admin users. You cannot delete a Unit that contains Products\n\n * @summary Deletes an Organisational Unit\n */\nexport const deleteOrganisationUnit = (\n orgid: string,\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/organisation/${orgid}/unit/${unitid}`, method: \"delete\" },\n options\n );\n};\n\nexport const useDeleteOrganisationUnit = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUnit>,\n TError,\n { orgid: string; unitid: 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 deleteOrganisationUnit>,\n { orgid: string; unitid: string }\n > = (props) => {\n const { orgid, unitid } = props || {};\n\n return deleteOrganisationUnit(orgid, unitid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUnit>,\n TError,\n { orgid: string; unitid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets all the Units you are a member of. Admin users can see all Units\n\n * @summary Gets Units a User has access to\n */\nexport const getUnits = (options?: SecondParameter<typeof customInstance>) => {\n return customInstance<UnitsGetResponse>(\n { url: `/unit`, method: \"get\" },\n options\n );\n};\n\nexport const getGetUnitsQueryKey = () => [`/unit`];\n\nexport const useGetUnits = <\n TData = AsyncReturnType<typeof getUnits>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getUnits>, 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 ?? getGetUnitsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getUnits>> = () =>\n getUnits(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getUnits>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a Unit for an independent User. The unit will belong to the built-in **Default** Organisation. Users can only have one Independent Unit and Independent Units cannot have other Users\n\n * @summary Create a new Independent User Unit\n */\nexport const createDefaultUnit = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationUnitPostResponse>(\n { url: `/unit`, method: \"put\" },\n options\n );\n};\n\nexport const useCreateDefaultUnit = <\n TError = ErrorType<AsError | void>,\n TVariables = void,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createDefaultUnit>,\n TError,\n TVariables,\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createDefaultUnit>,\n TVariables\n > = () => {\n return createDefaultUnit(requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createDefaultUnit>,\n TError,\n TVariables,\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Deletes an Independent Unit. It must be your Unit, which belongs to the Default Organisation\n\n * @summary Deletes an Independent Unit\n */\nexport const deleteDefaultUnit = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>({ url: `/unit`, method: \"delete\" }, options);\n};\n\nexport const useDeleteDefaultUnit = <\n TError = ErrorType<AsError>,\n TVariables = void,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteDefaultUnit>,\n TError,\n TVariables,\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteDefaultUnit>,\n TVariables\n > = () => {\n return deleteDefaultUnit(requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteDefaultUnit>,\n TError,\n TVariables,\n TContext\n >(mutationFn, mutationOptions);\n};\n"]}
package/unit/unit.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 { I as customInstance, A as OrganisationUnitsGetResponse, J as ErrorType, E as AsError, O as OrganisationUnitPostBodyBody, B as OrganisationUnitPostResponse, t as UnitsGetResponse } from '../custom-instance-3334b00b';
3
+ import { K as customInstance, C as OrganisationUnitsGetResponse, L as ErrorType, G as AsError, O as OrganisationUnitPostBodyBody, D as OrganisationUnitPostResponse, s as UnitGetResponse, r as UnitsGetResponse } from '../custom-instance-7503296b';
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;
@@ -33,6 +33,19 @@ declare const useCreateOrganisationUnit: <TError = ErrorType<void | AsError>, TC
33
33
  orgid: string;
34
34
  data: OrganisationUnitPostBodyBody;
35
35
  }, TContext>;
36
+ /**
37
+ * Gets the Unit, assuming you are a member of it. Admin users can see all Units
38
+
39
+ * @summary Gets a Unit
40
+ */
41
+ declare const getUnit: (orgid: string, unitid: string, options?: SecondParameter<typeof customInstance>) => Promise<UnitGetResponse>;
42
+ declare const getGetUnitQueryKey: (orgid: string, unitid: string) => string[];
43
+ declare const useGetUnit: <TData = UnitGetResponse, TError = ErrorType<void | AsError>>(orgid: string, unitid: string, options?: {
44
+ query?: UseQueryOptions<UnitGetResponse, TError, TData, QueryKey> | undefined;
45
+ request?: SecondParameter<typeof customInstance>;
46
+ } | undefined) => UseQueryResult<TData, TError> & {
47
+ queryKey: QueryKey;
48
+ };
36
49
  /**
37
50
  * Deletes an Organisational Unit you have access to. Units can only be deleted by Organisation users or Admin users. You cannot delete a Unit that contains Products
38
51
 
@@ -83,4 +96,4 @@ declare const useDeleteDefaultUnit: <TError = ErrorType<AsError>, TVariables = v
83
96
  request?: SecondParameter<typeof customInstance>;
84
97
  } | undefined) => react_query.UseMutationResult<void, TError, TVariables, TContext>;
85
98
 
86
- export { createDefaultUnit, createOrganisationUnit, deleteDefaultUnit, deleteOrganisationUnit, getGetOrganisationUnitsQueryKey, getGetUnitsQueryKey, getOrganisationUnits, getUnits, useCreateDefaultUnit, useCreateOrganisationUnit, useDeleteDefaultUnit, useDeleteOrganisationUnit, useGetOrganisationUnits, useGetUnits };
99
+ export { createDefaultUnit, createOrganisationUnit, deleteDefaultUnit, deleteOrganisationUnit, getGetOrganisationUnitsQueryKey, getGetUnitQueryKey, getGetUnitsQueryKey, getOrganisationUnits, getUnit, getUnits, useCreateDefaultUnit, useCreateOrganisationUnit, useDeleteDefaultUnit, useDeleteOrganisationUnit, useGetOrganisationUnits, useGetUnit, useGetUnits };
package/unit/unit.js CHANGED
@@ -1,42 +1,13 @@
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));
1
+ import {
2
+ __spreadValues,
3
+ customInstance
4
+ } from "../chunk-JR7F532L.js";
20
5
 
21
6
  // src/unit/unit.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/unit/unit.ts
40
11
  var getOrganisationUnits = (orgid, options) => {
41
12
  return customInstance({ url: `/organisation/${orgid}/unit`, method: "get" }, options);
42
13
  };
@@ -67,12 +38,23 @@ var useCreateOrganisationUnit = (options) => {
67
38
  };
68
39
  return useMutation(mutationFn, mutationOptions);
69
40
  };
41
+ var getUnit = (orgid, unitid, options) => {
42
+ return customInstance({ url: `/organisation/${orgid}/unit/${unitid}`, method: "get" }, options);
43
+ };
44
+ var getGetUnitQueryKey = (orgid, unitid) => [
45
+ `/organisation/${orgid}/unit/${unitid}`
46
+ ];
47
+ var useGetUnit = (orgid, unitid, options) => {
48
+ const { query: queryOptions, request: requestOptions } = options || {};
49
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetUnitQueryKey(orgid, unitid);
50
+ const queryFn = () => getUnit(orgid, unitid, requestOptions);
51
+ const query = useQuery(queryKey, queryFn, __spreadValues({ enabled: !!(orgid && unitid) }, queryOptions));
52
+ return __spreadValues({
53
+ queryKey
54
+ }, query);
55
+ };
70
56
  var deleteOrganisationUnit = (orgid, unitid, options) => {
71
- return customInstance({
72
- url: `/organisation/${orgid}/unit/${unitid}`,
73
- method: "delete",
74
- data: void 0
75
- }, options);
57
+ return customInstance({ url: `/organisation/${orgid}/unit/${unitid}`, method: "delete" }, options);
76
58
  };
77
59
  var useDeleteOrganisationUnit = (options) => {
78
60
  const { mutation: mutationOptions, request: requestOptions } = options || {};
@@ -96,7 +78,7 @@ var useGetUnits = (options) => {
96
78
  }, query);
97
79
  };
98
80
  var createDefaultUnit = (options) => {
99
- return customInstance({ url: `/unit`, method: "put", data: void 0 }, options);
81
+ return customInstance({ url: `/unit`, method: "put" }, options);
100
82
  };
101
83
  var useCreateDefaultUnit = (options) => {
102
84
  const { mutation: mutationOptions, request: requestOptions } = options || {};
@@ -106,7 +88,7 @@ var useCreateDefaultUnit = (options) => {
106
88
  return useMutation(mutationFn, mutationOptions);
107
89
  };
108
90
  var deleteDefaultUnit = (options) => {
109
- return customInstance({ url: `/unit`, method: "delete", data: void 0 }, options);
91
+ return customInstance({ url: `/unit`, method: "delete" }, options);
110
92
  };
111
93
  var useDeleteDefaultUnit = (options) => {
112
94
  const { mutation: mutationOptions, request: requestOptions } = options || {};
@@ -121,13 +103,17 @@ export {
121
103
  deleteDefaultUnit,
122
104
  deleteOrganisationUnit,
123
105
  getGetOrganisationUnitsQueryKey,
106
+ getGetUnitQueryKey,
124
107
  getGetUnitsQueryKey,
125
108
  getOrganisationUnits,
109
+ getUnit,
126
110
  getUnits,
127
111
  useCreateDefaultUnit,
128
112
  useCreateOrganisationUnit,
129
113
  useDeleteDefaultUnit,
130
114
  useDeleteOrganisationUnit,
131
115
  useGetOrganisationUnits,
116
+ useGetUnit,
132
117
  useGetUnits
133
118
  };
119
+ //# sourceMappingURL=unit.js.map