@squonk/account-server-client 0.1.5-rc.2 → 0.1.8-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/{custom-instance-d8cc704b.d.ts → custom-instance-cc5da68e.d.ts} +169 -120
  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 +28 -123
  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 +8 -8
  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 +60 -241
  18. package/product/product.js +127 -2
  19. package/product/product.js.map +3 -3
  20. package/src/account-server-api.schemas.ts +278 -0
  21. package/src/custom-instance.ts +52 -0
  22. package/src/index.ts +6 -0
  23. package/src/organisation/organisation.ts +181 -0
  24. package/src/product/product.ts +289 -0
  25. package/src/unit/unit.ts +322 -0
  26. package/src/user/user.ts +340 -0
  27. package/unit/package.json +2 -1
  28. package/unit/unit.cjs +168 -2
  29. package/unit/unit.cjs.map +3 -3
  30. package/unit/unit.d.ts +58 -122
  31. package/unit/unit.js +133 -2
  32. package/unit/unit.js.map +3 -3
  33. package/user/package.json +2 -1
  34. package/user/user.cjs +176 -2
  35. package/user/user.cjs.map +3 -3
  36. package/user/user.d.ts +20 -246
  37. package/user/user.js +141 -2
  38. package/user/user.js.map +3 -3
  39. package/chunk-OULWOQLW.cjs +0 -2
  40. package/chunk-OULWOQLW.cjs.map +0 -7
  41. package/chunk-WMX3LCLR.js +0 -2
  42. package/chunk-WMX3LCLR.js.map +0 -7
package/unit/unit.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_query from 'react-query';
2
- import { UseQueryOptions, UseMutationOptions } from 'react-query';
3
- import { z as customInstance, b as OrganisationUnitsGetResponse, E as Error, w as OrganisationUnitPostBodyBody, a as OrganisationUnitPostResponse } from '../custom-instance-d8cc704b';
2
+ import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
3
+ import { H as customInstance, z as OrganisationUnitsGetResponse, I as ErrorType, D as AsError, O as OrganisationUnitPostBodyBody, A as OrganisationUnitPostResponse, s as UnitsGetResponse } from '../custom-instance-cc5da68e';
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;
@@ -11,132 +11,19 @@ declare type SecondParameter<T extends (...args: any) => any> = T extends (confi
11
11
  */
12
12
  declare const getOrganisationUnits: (orgid: string, options?: SecondParameter<typeof customInstance>) => Promise<OrganisationUnitsGetResponse>;
13
13
  declare const getGetOrganisationUnitsQueryKey: (orgid: string) => string[];
14
- declare const useGetOrganisationUnits: <TData = OrganisationUnitsGetResponse, TError = void | Error>(orgid: string, options?: {
15
- query?: UseQueryOptions<OrganisationUnitsGetResponse, TError, TData, react_query.QueryKey> | undefined;
14
+ declare const useGetOrganisationUnits: <TData = OrganisationUnitsGetResponse, TError = ErrorType<void | AsError>>(orgid: string, options?: {
15
+ query?: UseQueryOptions<OrganisationUnitsGetResponse, TError, TData, QueryKey> | undefined;
16
16
  request?: SecondParameter<typeof customInstance>;
17
- } | undefined) => {
18
- data: undefined;
19
- error: null;
20
- isError: false;
21
- isIdle: true;
22
- isLoading: false;
23
- isLoadingError: false;
24
- isRefetchError: false;
25
- isSuccess: false;
26
- status: "idle";
27
- dataUpdatedAt: number;
28
- errorUpdatedAt: number;
29
- failureCount: number;
30
- isFetched: boolean;
31
- isFetchedAfterMount: boolean;
32
- isFetching: boolean;
33
- isPlaceholderData: boolean;
34
- isPreviousData: boolean;
35
- isRefetching: boolean;
36
- isStale: boolean;
37
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
38
- remove: () => void;
39
- queryKey: react_query.QueryKey;
40
- } | {
41
- data: undefined;
42
- error: TError;
43
- isError: true;
44
- isIdle: false;
45
- isLoading: false;
46
- isLoadingError: true;
47
- isRefetchError: false;
48
- isSuccess: false;
49
- status: "error";
50
- dataUpdatedAt: number;
51
- errorUpdatedAt: number;
52
- failureCount: number;
53
- isFetched: boolean;
54
- isFetchedAfterMount: boolean;
55
- isFetching: boolean;
56
- isPlaceholderData: boolean;
57
- isPreviousData: boolean;
58
- isRefetching: boolean;
59
- isStale: boolean;
60
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
61
- remove: () => void;
62
- queryKey: react_query.QueryKey;
63
- } | {
64
- data: undefined;
65
- error: null;
66
- isError: false;
67
- isIdle: false;
68
- isLoading: true;
69
- isLoadingError: false;
70
- isRefetchError: false;
71
- isSuccess: false;
72
- status: "loading";
73
- dataUpdatedAt: number;
74
- errorUpdatedAt: number;
75
- failureCount: number;
76
- isFetched: boolean;
77
- isFetchedAfterMount: boolean;
78
- isFetching: boolean;
79
- isPlaceholderData: boolean;
80
- isPreviousData: boolean;
81
- isRefetching: boolean;
82
- isStale: boolean;
83
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
84
- remove: () => void;
85
- queryKey: react_query.QueryKey;
86
- } | {
87
- data: TData;
88
- error: TError;
89
- isError: true;
90
- isIdle: false;
91
- isLoading: false;
92
- isLoadingError: false;
93
- isRefetchError: true;
94
- isSuccess: false;
95
- status: "error";
96
- dataUpdatedAt: number;
97
- errorUpdatedAt: number;
98
- failureCount: number;
99
- isFetched: boolean;
100
- isFetchedAfterMount: boolean;
101
- isFetching: boolean;
102
- isPlaceholderData: boolean;
103
- isPreviousData: boolean;
104
- isRefetching: boolean;
105
- isStale: boolean;
106
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
107
- remove: () => void;
108
- queryKey: react_query.QueryKey;
109
- } | {
110
- data: TData;
111
- error: null;
112
- isError: false;
113
- isIdle: false;
114
- isLoading: false;
115
- isLoadingError: false;
116
- isRefetchError: false;
117
- isSuccess: true;
118
- status: "success";
119
- dataUpdatedAt: number;
120
- errorUpdatedAt: number;
121
- failureCount: number;
122
- isFetched: boolean;
123
- isFetchedAfterMount: boolean;
124
- isFetching: boolean;
125
- isPlaceholderData: boolean;
126
- isPreviousData: boolean;
127
- isRefetching: boolean;
128
- isStale: boolean;
129
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
130
- remove: () => void;
131
- queryKey: react_query.QueryKey;
17
+ } | undefined) => UseQueryResult<TData, TError> & {
18
+ queryKey: QueryKey;
132
19
  };
133
20
  /**
134
- * Creates a new organisation unit
21
+ * Creates a new organisation unit. You need to be inthe Organisation or an Admin user to use this endpoint
135
22
 
136
23
  * @summary Create a new Organisational Unit
137
24
  */
138
25
  declare const createOrganisationUnit: (orgid: string, organisationUnitPostBodyBody: OrganisationUnitPostBodyBody, options?: SecondParameter<typeof customInstance>) => Promise<OrganisationUnitPostResponse>;
139
- declare const useCreateOrganisationUnit: <TError = void | Error, TContext = unknown>(options?: {
26
+ declare const useCreateOrganisationUnit: <TError = ErrorType<void | AsError>, TContext = unknown>(options?: {
140
27
  mutation?: UseMutationOptions<OrganisationUnitPostResponse, TError, {
141
28
  orgid: string;
142
29
  data: OrganisationUnitPostBodyBody;
@@ -146,5 +33,54 @@ declare const useCreateOrganisationUnit: <TError = void | Error, TContext = unkn
146
33
  orgid: string;
147
34
  data: OrganisationUnitPostBodyBody;
148
35
  }, TContext>;
36
+ /**
37
+ * 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
+
39
+ * @summary Deletes an Organisational Unit
40
+ */
41
+ declare const deleteOrganisationUnit: (orgid: string, unitid: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
42
+ declare const useDeleteOrganisationUnit: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
43
+ mutation?: UseMutationOptions<void, TError, {
44
+ orgid: string;
45
+ unitid: string;
46
+ }, TContext> | undefined;
47
+ request?: SecondParameter<typeof customInstance>;
48
+ } | undefined) => react_query.UseMutationResult<void, TError, {
49
+ orgid: string;
50
+ unitid: string;
51
+ }, TContext>;
52
+ /**
53
+ * Gets all the Units you are a member of. Admin users can see all Units
54
+
55
+ * @summary Gets Units a User has access to
56
+ */
57
+ declare const getUnits: (options?: SecondParameter<typeof customInstance>) => Promise<UnitsGetResponse>;
58
+ declare const getGetUnitsQueryKey: () => string[];
59
+ declare const useGetUnits: <TData = UnitsGetResponse, TError = ErrorType<void | AsError>>(options?: {
60
+ query?: UseQueryOptions<UnitsGetResponse, TError, TData, QueryKey> | undefined;
61
+ request?: SecondParameter<typeof customInstance>;
62
+ } | undefined) => UseQueryResult<TData, TError> & {
63
+ queryKey: QueryKey;
64
+ };
65
+ /**
66
+ * 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
67
+
68
+ * @summary Create a new Independent User Unit
69
+ */
70
+ declare const createDefaultUnit: (options?: SecondParameter<typeof customInstance>) => Promise<OrganisationUnitPostResponse>;
71
+ declare const useCreateDefaultUnit: <TError = ErrorType<void | AsError>, TVariables = void, TContext = unknown>(options?: {
72
+ mutation?: UseMutationOptions<OrganisationUnitPostResponse, TError, TVariables, TContext> | undefined;
73
+ request?: SecondParameter<typeof customInstance>;
74
+ } | undefined) => react_query.UseMutationResult<OrganisationUnitPostResponse, TError, TVariables, TContext>;
75
+ /**
76
+ * Deletes an Independent Unit. It must be your Unit, which belongs to the Default Organisation
77
+
78
+ * @summary Deletes an Independent Unit
79
+ */
80
+ declare const deleteDefaultUnit: (options?: SecondParameter<typeof customInstance>) => Promise<void>;
81
+ declare const useDeleteDefaultUnit: <TError = ErrorType<AsError>, TVariables = void, TContext = unknown>(options?: {
82
+ mutation?: UseMutationOptions<void, TError, TVariables, TContext> | undefined;
83
+ request?: SecondParameter<typeof customInstance>;
84
+ } | undefined) => react_query.UseMutationResult<void, TError, TVariables, TContext>;
149
85
 
150
- export { createOrganisationUnit, getGetOrganisationUnitsQueryKey, getOrganisationUnits, useCreateOrganisationUnit, useGetOrganisationUnits };
86
+ export { createDefaultUnit, createOrganisationUnit, deleteDefaultUnit, deleteOrganisationUnit, getGetOrganisationUnitsQueryKey, getGetUnitsQueryKey, getOrganisationUnits, getUnits, useCreateDefaultUnit, useCreateOrganisationUnit, useDeleteDefaultUnit, useDeleteOrganisationUnit, useGetOrganisationUnits, useGetUnits };
package/unit/unit.js CHANGED
@@ -1,2 +1,133 @@
1
- import{a as s,e as i}from"../chunk-WMX3LCLR.js";import{useQuery as c,useMutation as g}from"react-query";var p=(t,e)=>i({url:`/organisation/${t}/unit`,method:"get"},e),d=t=>[`/organisation/${t}/unit`],q=(t,e)=>{var u;let{query:n,request:a}=e||{},o=(u=n==null?void 0:n.queryKey)!=null?u:d(t),r=c(o,()=>p(t,a),s({enabled:!!t},n));return s({queryKey:o},r)},m=(t,e,n)=>i({url:`/organisation/${t}/unit`,method:"post",data:e},n),x=t=>{let{mutation:e,request:n}=t||{};return g(o=>{let{orgid:y,data:r}=o||{};return m(y,r,n)},e)};export{m as createOrganisationUnit,d as getGetOrganisationUnitsQueryKey,p as getOrganisationUnits,x as useCreateOrganisationUnit,q as useGetOrganisationUnits};
2
- //# sourceMappingURL=unit.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/unit/unit.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/unit/unit.ts
40
+ var getOrganisationUnits = (orgid, options) => {
41
+ return customInstance({ url: `/organisation/${orgid}/unit`, method: "get" }, options);
42
+ };
43
+ var getGetOrganisationUnitsQueryKey = (orgid) => [
44
+ `/organisation/${orgid}/unit`
45
+ ];
46
+ var useGetOrganisationUnits = (orgid, options) => {
47
+ const { query: queryOptions, request: requestOptions } = options || {};
48
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationUnitsQueryKey(orgid);
49
+ const queryFn = () => getOrganisationUnits(orgid, requestOptions);
50
+ const query = useQuery(queryKey, queryFn, __spreadValues({ enabled: !!orgid }, queryOptions));
51
+ return __spreadValues({
52
+ queryKey
53
+ }, query);
54
+ };
55
+ var createOrganisationUnit = (orgid, organisationUnitPostBodyBody, options) => {
56
+ return customInstance({
57
+ url: `/organisation/${orgid}/unit`,
58
+ method: "post",
59
+ data: organisationUnitPostBodyBody
60
+ }, options);
61
+ };
62
+ var useCreateOrganisationUnit = (options) => {
63
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
64
+ const mutationFn = (props) => {
65
+ const { orgid, data } = props || {};
66
+ return createOrganisationUnit(orgid, data, requestOptions);
67
+ };
68
+ return useMutation(mutationFn, mutationOptions);
69
+ };
70
+ var deleteOrganisationUnit = (orgid, unitid, options) => {
71
+ return customInstance({
72
+ url: `/organisation/${orgid}/unit/${unitid}`,
73
+ method: "delete",
74
+ data: void 0
75
+ }, options);
76
+ };
77
+ var useDeleteOrganisationUnit = (options) => {
78
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
79
+ const mutationFn = (props) => {
80
+ const { orgid, unitid } = props || {};
81
+ return deleteOrganisationUnit(orgid, unitid, requestOptions);
82
+ };
83
+ return useMutation(mutationFn, mutationOptions);
84
+ };
85
+ var getUnits = (options) => {
86
+ return customInstance({ url: `/unit`, method: "get" }, options);
87
+ };
88
+ var getGetUnitsQueryKey = () => [`/unit`];
89
+ var useGetUnits = (options) => {
90
+ const { query: queryOptions, request: requestOptions } = options || {};
91
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetUnitsQueryKey();
92
+ const queryFn = () => getUnits(requestOptions);
93
+ const query = useQuery(queryKey, queryFn, queryOptions);
94
+ return __spreadValues({
95
+ queryKey
96
+ }, query);
97
+ };
98
+ var createDefaultUnit = (options) => {
99
+ return customInstance({ url: `/unit`, method: "put", data: void 0 }, options);
100
+ };
101
+ var useCreateDefaultUnit = (options) => {
102
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
103
+ const mutationFn = () => {
104
+ return createDefaultUnit(requestOptions);
105
+ };
106
+ return useMutation(mutationFn, mutationOptions);
107
+ };
108
+ var deleteDefaultUnit = (options) => {
109
+ return customInstance({ url: `/unit`, method: "delete", data: void 0 }, options);
110
+ };
111
+ var useDeleteDefaultUnit = (options) => {
112
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
113
+ const mutationFn = () => {
114
+ return deleteDefaultUnit(requestOptions);
115
+ };
116
+ return useMutation(mutationFn, mutationOptions);
117
+ };
118
+ export {
119
+ createDefaultUnit,
120
+ createOrganisationUnit,
121
+ deleteDefaultUnit,
122
+ deleteOrganisationUnit,
123
+ getGetOrganisationUnitsQueryKey,
124
+ getGetUnitsQueryKey,
125
+ getOrganisationUnits,
126
+ getUnits,
127
+ useCreateDefaultUnit,
128
+ useCreateOrganisationUnit,
129
+ useDeleteDefaultUnit,
130
+ useDeleteOrganisationUnit,
131
+ useGetOrganisationUnits,
132
+ useGetUnits
133
+ };
package/unit/unit.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/unit/unit.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.3.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} from \"react-query\";\nimport type {\n OrganisationUnitsGetResponse,\n Error,\n OrganisationUnitPostResponse,\n OrganisationUnitPostBodyBody,\n} from \"../account-server-api.schemas\";\nimport { customInstance } 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 = void | Error\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) => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUnitsQueryKey(orgid);\n\n const queryFn: QueryFunction<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\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 = Error | 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"],
5
- "mappings": "gDAUA,wDAkCO,GAAM,GAAuB,CAClC,EACA,IAEO,EACL,CAAE,IAAK,iBAAiB,SAAc,OAAQ,OAC9C,GAIS,EAAkC,AAAC,GAAkB,CAChE,iBAAiB,UAGN,EAA0B,CAIrC,EACA,IAQG,CAvEL,MAwEE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EACJ,oBAAc,WAAd,OAA0B,EAAgC,GAKtD,EAAQ,EAIZ,EANA,IAAM,EAAqB,EAAO,GAMf,GAAE,QAAS,CAAC,CAAC,GAAU,IAE5C,MAAO,IACL,YACG,IASM,EAAyB,CACpC,EACA,EACA,IAEO,EACL,CACE,IAAK,iBAAiB,SACtB,OAAQ,OACR,KAAM,GAER,GAIS,EAA4B,AAGvC,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,QAAO,QAAS,GAAS,GAEjC,MAAO,GAAuB,EAAO,EAAM,IAQ/B",
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": "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",
6
6
  "names": []
7
7
  }
package/user/package.json CHANGED
@@ -2,5 +2,6 @@
2
2
  "module": "./user.js",
3
3
  "main": "./user.cjs",
4
4
  "types": "./user.d.ts",
5
- "sideEffects": false
5
+ "sideEffects": false,
6
+ "type": "module"
6
7
  }
package/user/user.cjs CHANGED
@@ -1,2 +1,176 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOULWOQLWcjs = require('../chunk-OULWOQLW.cjs');var _reactquery = require('react-query');var d=(t,n)=>_chunkOULWOQLWcjs.e.call(void 0, {url:`/organisation/${t}/user`,method:"get"},n),p= exports.getGetOrganisationUsersQueryKey =t=>[`/organisation/${t}/user`],I= exports.useGetOrganisationUsers =(t,n)=>{var u;let{query:e,request:i}=n||{},r=(u=e==null?void 0:e.queryKey)!=null?u:p(t),s=_reactquery.useQuery.call(void 0, r,()=>d(t,i),_chunkOULWOQLWcjs.a.call(void 0, {enabled:!!t},e));return _chunkOULWOQLWcjs.a.call(void 0, {queryKey:r},s)},m= exports.addOrganisationUser =(t,n,e)=>_chunkOULWOQLWcjs.e.call(void 0, {url:`/organisation/${t}/user/${n}`,method:"put",data:void 0},e),S= exports.useAddOrganisationUser =t=>{let{mutation:n,request:e}=t||{};return _reactquery.useMutation.call(void 0, r=>{let{orgid:o,userid:s}=r||{};return m(o,s,e)},n)},U= exports.deleteOrganisationUser =(t,n,e)=>_chunkOULWOQLWcjs.e.call(void 0, {url:`/organisation/${t}/user/${n}`,method:"delete"},e),C= exports.useDeleteOrganisationUser =t=>{let{mutation:n,request:e}=t||{};return _reactquery.useMutation.call(void 0, r=>{let{orgid:o,userid:s}=r||{};return U(o,s,e)},n)},T= exports.getOrganisationUnitUsers =(t,n)=>_chunkOULWOQLWcjs.e.call(void 0, {url:`/unit/${t}/user`,method:"get"},n),O= exports.getGetOrganisationUnitUsersQueryKey =t=>[`/unit/${t}/user`],$= exports.useGetOrganisationUnitUsers =(t,n)=>{var u;let{query:e,request:i}=n||{},r=(u=e==null?void 0:e.queryKey)!=null?u:O(t),s=_reactquery.useQuery.call(void 0, r,()=>T(t,i),_chunkOULWOQLWcjs.a.call(void 0, {enabled:!!t},e));return _chunkOULWOQLWcjs.a.call(void 0, {queryKey:r},s)},f= exports.addOrganisationUnitUser =(t,n,e)=>_chunkOULWOQLWcjs.e.call(void 0, {url:`/unit/${t}/user/${n}`,method:"put",data:void 0},e),M= exports.useAddOrganisationUnitUser =t=>{let{mutation:n,request:e}=t||{};return _reactquery.useMutation.call(void 0, r=>{let{unitid:o,userid:s}=r||{};return f(o,s,e)},n)},q= exports.deleteOrganisationUnitUser =(t,n,e)=>_chunkOULWOQLWcjs.e.call(void 0, {url:`/unit/${t}/user/${n}`,method:"delete"},e),Q= exports.useDeleteOrganisationUnitUser =t=>{let{mutation:n,request:e}=t||{};return _reactquery.useMutation.call(void 0, r=>{let{unitid:o,userid:s}=r||{};return q(o,s,e)},n)};exports.addOrganisationUnitUser = f; exports.addOrganisationUser = m; exports.deleteOrganisationUnitUser = q; exports.deleteOrganisationUser = U; exports.getGetOrganisationUnitUsersQueryKey = O; exports.getGetOrganisationUsersQueryKey = p; exports.getOrganisationUnitUsers = T; exports.getOrganisationUsers = d; exports.useAddOrganisationUnitUser = M; exports.useAddOrganisationUser = S; exports.useDeleteOrganisationUnitUser = Q; exports.useDeleteOrganisationUser = C; exports.useGetOrganisationUnitUsers = $; exports.useGetOrganisationUsers = I;
2
- //# sourceMappingURL=user.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/user/user.ts
43
+ __export(exports, {
44
+ addOrganisationUnitUser: () => addOrganisationUnitUser,
45
+ addOrganisationUser: () => addOrganisationUser,
46
+ deleteOrganisationUnitUser: () => deleteOrganisationUnitUser,
47
+ deleteOrganisationUser: () => deleteOrganisationUser,
48
+ getGetOrganisationUnitUsersQueryKey: () => getGetOrganisationUnitUsersQueryKey,
49
+ getGetOrganisationUsersQueryKey: () => getGetOrganisationUsersQueryKey,
50
+ getOrganisationUnitUsers: () => getOrganisationUnitUsers,
51
+ getOrganisationUsers: () => getOrganisationUsers,
52
+ useAddOrganisationUnitUser: () => useAddOrganisationUnitUser,
53
+ useAddOrganisationUser: () => useAddOrganisationUser,
54
+ useDeleteOrganisationUnitUser: () => useDeleteOrganisationUnitUser,
55
+ useDeleteOrganisationUser: () => useDeleteOrganisationUser,
56
+ useGetOrganisationUnitUsers: () => useGetOrganisationUnitUsers,
57
+ useGetOrganisationUsers: () => useGetOrganisationUsers
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
+ };
72
+
73
+ // src/user/user.ts
74
+ var getOrganisationUsers = (orgid, options) => {
75
+ return customInstance({ url: `/organisation/${orgid}/user`, method: "get" }, options);
76
+ };
77
+ var getGetOrganisationUsersQueryKey = (orgid) => [
78
+ `/organisation/${orgid}/user`
79
+ ];
80
+ var useGetOrganisationUsers = (orgid, options) => {
81
+ const { query: queryOptions, request: requestOptions } = options || {};
82
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationUsersQueryKey(orgid);
83
+ const queryFn = () => getOrganisationUsers(orgid, requestOptions);
84
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, __spreadValues({ enabled: !!orgid }, queryOptions));
85
+ return __spreadValues({
86
+ queryKey
87
+ }, query);
88
+ };
89
+ var addOrganisationUser = (orgid, userid, options) => {
90
+ return customInstance({
91
+ url: `/organisation/${orgid}/user/${userid}`,
92
+ method: "put",
93
+ data: void 0
94
+ }, options);
95
+ };
96
+ var useAddOrganisationUser = (options) => {
97
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
98
+ const mutationFn = (props) => {
99
+ const { orgid, userid } = props || {};
100
+ return addOrganisationUser(orgid, userid, requestOptions);
101
+ };
102
+ return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
103
+ };
104
+ var deleteOrganisationUser = (orgid, userid, options) => {
105
+ return customInstance({
106
+ url: `/organisation/${orgid}/user/${userid}`,
107
+ method: "delete",
108
+ data: void 0
109
+ }, options);
110
+ };
111
+ var useDeleteOrganisationUser = (options) => {
112
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
113
+ const mutationFn = (props) => {
114
+ const { orgid, userid } = props || {};
115
+ return deleteOrganisationUser(orgid, userid, requestOptions);
116
+ };
117
+ return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
118
+ };
119
+ var getOrganisationUnitUsers = (unitid, options) => {
120
+ return customInstance({ url: `/unit/${unitid}/user`, method: "get" }, options);
121
+ };
122
+ var getGetOrganisationUnitUsersQueryKey = (unitid) => [
123
+ `/unit/${unitid}/user`
124
+ ];
125
+ var useGetOrganisationUnitUsers = (unitid, options) => {
126
+ const { query: queryOptions, request: requestOptions } = options || {};
127
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationUnitUsersQueryKey(unitid);
128
+ const queryFn = () => getOrganisationUnitUsers(unitid, requestOptions);
129
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, __spreadValues({ enabled: !!unitid }, queryOptions));
130
+ return __spreadValues({
131
+ queryKey
132
+ }, query);
133
+ };
134
+ var addOrganisationUnitUser = (unitid, userid, options) => {
135
+ return customInstance({ url: `/unit/${unitid}/user/${userid}`, method: "put", data: void 0 }, options);
136
+ };
137
+ var useAddOrganisationUnitUser = (options) => {
138
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
139
+ const mutationFn = (props) => {
140
+ const { unitid, userid } = props || {};
141
+ return addOrganisationUnitUser(unitid, userid, requestOptions);
142
+ };
143
+ return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
144
+ };
145
+ var deleteOrganisationUnitUser = (unitid, userid, options) => {
146
+ return customInstance({
147
+ url: `/unit/${unitid}/user/${userid}`,
148
+ method: "delete",
149
+ data: void 0
150
+ }, options);
151
+ };
152
+ var useDeleteOrganisationUnitUser = (options) => {
153
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
154
+ const mutationFn = (props) => {
155
+ const { unitid, userid } = props || {};
156
+ return deleteOrganisationUnitUser(unitid, userid, requestOptions);
157
+ };
158
+ return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
159
+ };
160
+ // Annotate the CommonJS export names for ESM import in node:
161
+ 0 && (module.exports = {
162
+ addOrganisationUnitUser,
163
+ addOrganisationUser,
164
+ deleteOrganisationUnitUser,
165
+ deleteOrganisationUser,
166
+ getGetOrganisationUnitUsersQueryKey,
167
+ getGetOrganisationUsersQueryKey,
168
+ getOrganisationUnitUsers,
169
+ getOrganisationUsers,
170
+ useAddOrganisationUnitUser,
171
+ useAddOrganisationUser,
172
+ useDeleteOrganisationUnitUser,
173
+ useDeleteOrganisationUser,
174
+ useGetOrganisationUnitUsers,
175
+ useGetOrganisationUsers
176
+ });