@squonk/account-server-client 2.0.3 → 2.0.4-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/admin.cjs +8 -6
- package/admin/admin.cjs.map +1 -1
- package/admin/admin.d.ts +4 -4
- package/admin/admin.js +7 -5
- package/admin/admin.js.map +1 -1
- package/asset/asset.cjs +15 -13
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.ts +20 -20
- package/asset/asset.js +7 -5
- package/asset/asset.js.map +1 -1
- package/{chunk-3O5KIRV4.js → chunk-3RNIDX7T.js} +1 -1
- package/{chunk-3O5KIRV4.js.map → chunk-3RNIDX7T.js.map} +1 -1
- package/chunk-7XN3IQYV.cjs +13 -0
- package/chunk-7XN3IQYV.cjs.map +1 -0
- package/{chunk-IUEU2LYC.cjs → chunk-UZTHSGDT.cjs} +1 -1
- package/chunk-UZTHSGDT.cjs.map +1 -0
- package/chunk-YEX2SGER.js +13 -0
- package/chunk-YEX2SGER.js.map +1 -0
- package/{custom-instance-dad9d28e.d.ts → custom-instance-85497958.d.ts} +110 -48
- package/index.cjs +2 -2
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +12 -9
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.ts +6 -6
- package/merchant/merchant.js +10 -7
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +44 -16
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +37 -16
- package/organisation/organisation.js +38 -10
- package/organisation/organisation.js.map +1 -1
- package/package.json +12 -12
- package/product/product.cjs +35 -33
- package/product/product.cjs.map +1 -1
- package/product/product.d.ts +24 -24
- package/product/product.js +25 -23
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +85 -17
- package/src/admin/admin.ts +6 -5
- package/src/asset/asset.ts +6 -5
- package/src/merchant/merchant.ts +10 -9
- package/src/organisation/organisation.ts +78 -19
- package/src/product/product.ts +30 -32
- package/src/queryMutator.ts +12 -0
- package/src/state/state.ts +6 -5
- package/src/unit/unit.ts +78 -19
- package/src/user/user.ts +14 -15
- package/state/state.cjs +8 -6
- package/state/state.cjs.map +1 -1
- package/state/state.d.ts +4 -4
- package/state/state.js +7 -5
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +46 -25
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +42 -21
- package/unit/unit.js +38 -17
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +20 -17
- package/user/user.cjs.map +1 -1
- package/user/user.d.ts +16 -16
- package/user/user.js +13 -10
- package/user/user.js.map +1 -1
- package/chunk-IUEU2LYC.cjs.map +0 -1
package/state/state.cjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk7XN3IQYVcjs = require('../chunk-7XN3IQYV.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkUZTHSGDTcjs = require('../chunk-UZTHSGDT.cjs');
|
|
4
7
|
|
|
5
8
|
// src/state/state.ts
|
|
6
9
|
var _reactquery = require('@tanstack/react-query');
|
|
7
10
|
var getVersion = (options, signal) => {
|
|
8
|
-
return
|
|
11
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
9
12
|
{ url: `/version`, method: "get", signal },
|
|
10
13
|
options
|
|
11
14
|
);
|
|
@@ -17,12 +20,11 @@ var useGetVersion = (options) => {
|
|
|
17
20
|
const queryFn = ({
|
|
18
21
|
signal
|
|
19
22
|
}) => getVersion(requestOptions, signal);
|
|
23
|
+
const customOptions = _chunk7XN3IQYVcjs.queryMutator.call(void 0, { ...queryOptions, queryKey, queryFn });
|
|
20
24
|
const query = _reactquery.useQuery.call(void 0,
|
|
21
|
-
|
|
22
|
-
queryFn,
|
|
23
|
-
queryOptions
|
|
25
|
+
customOptions
|
|
24
26
|
);
|
|
25
|
-
query.queryKey = queryKey;
|
|
27
|
+
query.queryKey = customOptions.queryKey;
|
|
26
28
|
return query;
|
|
27
29
|
};
|
|
28
30
|
|
package/state/state.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/state/state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/state/state.ts"],"names":[],"mappings":";;;;;;;;AAUA,SAAS,gBAAgB;AA0BlB,IAAM,aAAa,CACxB,SACA,WACG;AACH,SAAO;AAAA,IACL,EAAE,KAAK,YAAY,QAAQ,OAAO,OAAO;AAAA,IACzC;AAAA,EACF;AACF;AAEO,IAAM,wBAAwB,MAAM,CAAC,UAAU;AAO/C,IAAM,gBAAgB,CAG3B,YAO4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,eAAe,IAAI,WAAW,CAAC;AAErE,QAAM,YAAW,6CAAc,aAAY,sBAAsB;AAEjE,QAAM,UAAiE,CAAC;AAAA,IACtE;AAAA,EACF,MAAM,WAAW,gBAAgB,MAAM;AAEvC,QAAM,gBAAgB,aAAa,EAAE,GAAG,cAAc,UAAU,QAAQ,CAAC;AAEzE,QAAM,QAAQ;AAAA,IACZ;AAAA,EACF;AAEA,QAAM,WAAW,cAAc;AAE/B,SAAO;AACT","sourcesContent":["/**\n * Generated by orval v6.12.1 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 2.0\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport type {\n UseQueryOptions,\n QueryFunction,\n UseQueryResult,\n QueryKey,\n} from \"@tanstack/react-query\";\nimport type {\n StateGetVersionResponse,\n AsError,\n} from \"../account-server-api.schemas\";\nimport { customInstance } from \".././custom-instance\";\nimport type { ErrorType } from \".././custom-instance\";\nimport { queryMutator } from \".././queryMutator\";\n\n// eslint-disable-next-line\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 * @summary Gets the Account Server version\n */\nexport const getVersion = (\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<StateGetVersionResponse>(\n { url: `/version`, method: \"get\", signal },\n options\n );\n};\n\nexport const getGetVersionQueryKey = () => [`/version`];\n\nexport type GetVersionQueryResult = NonNullable<\n Awaited<ReturnType<typeof getVersion>>\n>;\nexport type GetVersionQueryError = ErrorType<AsError | void>;\n\nexport const useGetVersion = <\n TData = Awaited<ReturnType<typeof getVersion>>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<\n Awaited<ReturnType<typeof getVersion>>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getGetVersionQueryKey();\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof getVersion>>> = ({\n signal,\n }) => getVersion(requestOptions, signal);\n\n const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });\n\n const query = useQuery<Awaited<ReturnType<typeof getVersion>>, TError, TData>(\n customOptions\n ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = customOptions.queryKey;\n\n return query;\n};\n"]}
|
package/state/state.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { UseQueryOptions, QueryKey, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
2
|
+
import { aE as customInstance, aw as StateGetVersionResponse, aF as ErrorType, aA as AsError } from '../custom-instance-85497958.js';
|
|
3
3
|
import 'axios';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
|
|
6
6
|
/**
|
|
7
7
|
* @summary Gets the Account Server version
|
|
8
8
|
*/
|
|
9
9
|
declare const getVersion: (options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => Promise<StateGetVersionResponse>;
|
|
10
10
|
declare const getGetVersionQueryKey: () => string[];
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
type GetVersionQueryResult = NonNullable<Awaited<ReturnType<typeof getVersion>>>;
|
|
12
|
+
type GetVersionQueryError = ErrorType<AsError | void>;
|
|
13
13
|
declare const useGetVersion: <TData = StateGetVersionResponse, TError = ErrorType<void | AsError>>(options?: {
|
|
14
14
|
query?: UseQueryOptions<StateGetVersionResponse, TError, TData, QueryKey> | undefined;
|
|
15
15
|
request?: SecondParameter<typeof customInstance>;
|
package/state/state.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
queryMutator
|
|
3
|
+
} from "../chunk-YEX2SGER.js";
|
|
1
4
|
import {
|
|
2
5
|
customInstance
|
|
3
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-3RNIDX7T.js";
|
|
4
7
|
|
|
5
8
|
// src/state/state.ts
|
|
6
9
|
import { useQuery } from "@tanstack/react-query";
|
|
@@ -17,12 +20,11 @@ var useGetVersion = (options) => {
|
|
|
17
20
|
const queryFn = ({
|
|
18
21
|
signal
|
|
19
22
|
}) => getVersion(requestOptions, signal);
|
|
23
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
20
24
|
const query = useQuery(
|
|
21
|
-
|
|
22
|
-
queryFn,
|
|
23
|
-
queryOptions
|
|
25
|
+
customOptions
|
|
24
26
|
);
|
|
25
|
-
query.queryKey = queryKey;
|
|
27
|
+
query.queryKey = customOptions.queryKey;
|
|
26
28
|
return query;
|
|
27
29
|
};
|
|
28
30
|
export {
|
package/state/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/state/state.ts"],"sourcesContent":["/**\n * Generated by orval v6.
|
|
1
|
+
{"version":3,"sources":["../../src/state/state.ts"],"sourcesContent":["/**\n * Generated by orval v6.12.1 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 2.0\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport type {\n UseQueryOptions,\n QueryFunction,\n UseQueryResult,\n QueryKey,\n} from \"@tanstack/react-query\";\nimport type {\n StateGetVersionResponse,\n AsError,\n} from \"../account-server-api.schemas\";\nimport { customInstance } from \".././custom-instance\";\nimport type { ErrorType } from \".././custom-instance\";\nimport { queryMutator } from \".././queryMutator\";\n\n// eslint-disable-next-line\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 * @summary Gets the Account Server version\n */\nexport const getVersion = (\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<StateGetVersionResponse>(\n { url: `/version`, method: \"get\", signal },\n options\n );\n};\n\nexport const getGetVersionQueryKey = () => [`/version`];\n\nexport type GetVersionQueryResult = NonNullable<\n Awaited<ReturnType<typeof getVersion>>\n>;\nexport type GetVersionQueryError = ErrorType<AsError | void>;\n\nexport const useGetVersion = <\n TData = Awaited<ReturnType<typeof getVersion>>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<\n Awaited<ReturnType<typeof getVersion>>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getGetVersionQueryKey();\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof getVersion>>> = ({\n signal,\n }) => getVersion(requestOptions, signal);\n\n const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });\n\n const query = useQuery<Awaited<ReturnType<typeof getVersion>>, TError, TData>(\n customOptions\n ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = customOptions.queryKey;\n\n return query;\n};\n"],"mappings":";;;;;;;;AAUA,SAAS,gBAAgB;AA0BlB,IAAM,aAAa,CACxB,SACA,WACG;AACH,SAAO;AAAA,IACL,EAAE,KAAK,YAAY,QAAQ,OAAO,OAAO;AAAA,IACzC;AAAA,EACF;AACF;AAEO,IAAM,wBAAwB,MAAM,CAAC,UAAU;AAO/C,IAAM,gBAAgB,CAG3B,YAO4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,eAAe,IAAI,WAAW,CAAC;AAErE,QAAM,YAAW,6CAAc,aAAY,sBAAsB;AAEjE,QAAM,UAAiE,CAAC;AAAA,IACtE;AAAA,EACF,MAAM,WAAW,gBAAgB,MAAM;AAEvC,QAAM,gBAAgB,aAAa,EAAE,GAAG,cAAc,UAAU,QAAQ,CAAC;AAEzE,QAAM,QAAQ;AAAA,IACZ;AAAA,EACF;AAEA,QAAM,WAAW,cAAc;AAE/B,SAAO;AACT;","names":[]}
|
package/unit/unit.cjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk7XN3IQYVcjs = require('../chunk-7XN3IQYV.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkUZTHSGDTcjs = require('../chunk-UZTHSGDT.cjs');
|
|
4
7
|
|
|
5
8
|
// src/unit/unit.ts
|
|
6
9
|
var _reactquery = require('@tanstack/react-query');
|
|
7
10
|
var getOrganisationUnits = (orgId, options, signal) => {
|
|
8
|
-
return
|
|
11
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
9
12
|
{ url: `/organisation/${orgId}/unit`, method: "get", signal },
|
|
10
13
|
options
|
|
11
14
|
);
|
|
@@ -17,12 +20,13 @@ var useGetOrganisationUnits = (orgId, options) => {
|
|
|
17
20
|
const { query: queryOptions, request: requestOptions } = _nullishCoalesce(options, () => ( {}));
|
|
18
21
|
const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetOrganisationUnitsQueryKey(orgId)));
|
|
19
22
|
const queryFn = ({ signal }) => getOrganisationUnits(orgId, requestOptions, signal);
|
|
20
|
-
const
|
|
21
|
-
query
|
|
23
|
+
const customOptions = _chunk7XN3IQYVcjs.queryMutator.call(void 0, { ...queryOptions, queryKey, queryFn });
|
|
24
|
+
const query = _reactquery.useQuery.call(void 0, customOptions);
|
|
25
|
+
query.queryKey = customOptions.queryKey;
|
|
22
26
|
return query;
|
|
23
27
|
};
|
|
24
28
|
var createOrganisationUnit = (orgId, organisationUnitPostBodyBody, options) => {
|
|
25
|
-
return
|
|
29
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
26
30
|
{
|
|
27
31
|
url: `/organisation/${orgId}/unit`,
|
|
28
32
|
method: "post",
|
|
@@ -41,7 +45,7 @@ var useCreateOrganisationUnit = (options) => {
|
|
|
41
45
|
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
42
46
|
};
|
|
43
47
|
var getUnit = (unitId, options, signal) => {
|
|
44
|
-
return
|
|
48
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
45
49
|
{ url: `/unit/${unitId}`, method: "get", signal },
|
|
46
50
|
options
|
|
47
51
|
);
|
|
@@ -53,16 +57,34 @@ var useGetUnit = (unitId, options) => {
|
|
|
53
57
|
const queryFn = ({
|
|
54
58
|
signal
|
|
55
59
|
}) => getUnit(unitId, requestOptions, signal);
|
|
60
|
+
const customOptions = _chunk7XN3IQYVcjs.queryMutator.call(void 0, { ...queryOptions, queryKey, queryFn });
|
|
56
61
|
const query = _reactquery.useQuery.call(void 0,
|
|
57
|
-
|
|
58
|
-
queryFn,
|
|
59
|
-
{ enabled: !!unitId, ...queryOptions }
|
|
62
|
+
customOptions
|
|
60
63
|
);
|
|
61
|
-
query.queryKey = queryKey;
|
|
64
|
+
query.queryKey = customOptions.queryKey;
|
|
62
65
|
return query;
|
|
63
66
|
};
|
|
67
|
+
var patchUnit = (unitId, unitPatchBodyBody, options) => {
|
|
68
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
69
|
+
{
|
|
70
|
+
url: `/unit/${unitId}`,
|
|
71
|
+
method: "patch",
|
|
72
|
+
headers: { "Content-Type": "application/json" },
|
|
73
|
+
data: unitPatchBodyBody
|
|
74
|
+
},
|
|
75
|
+
options
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
var usePatchUnit = (options) => {
|
|
79
|
+
const { mutation: mutationOptions, request: requestOptions } = _nullishCoalesce(options, () => ( {}));
|
|
80
|
+
const mutationFn = (props) => {
|
|
81
|
+
const { unitId, data } = _nullishCoalesce(props, () => ( {}));
|
|
82
|
+
return patchUnit(unitId, data, requestOptions);
|
|
83
|
+
};
|
|
84
|
+
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
85
|
+
};
|
|
64
86
|
var deleteOrganisationUnit = (unitId, options) => {
|
|
65
|
-
return
|
|
87
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
66
88
|
{ url: `/unit/${unitId}`, method: "delete" },
|
|
67
89
|
options
|
|
68
90
|
);
|
|
@@ -76,7 +98,7 @@ var useDeleteOrganisationUnit = (options) => {
|
|
|
76
98
|
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
77
99
|
};
|
|
78
100
|
var getUnits = (options, signal) => {
|
|
79
|
-
return
|
|
101
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
80
102
|
{ url: `/unit`, method: "get", signal },
|
|
81
103
|
options
|
|
82
104
|
);
|
|
@@ -88,16 +110,15 @@ var useGetUnits = (options) => {
|
|
|
88
110
|
const queryFn = ({
|
|
89
111
|
signal
|
|
90
112
|
}) => getUnits(requestOptions, signal);
|
|
113
|
+
const customOptions = _chunk7XN3IQYVcjs.queryMutator.call(void 0, { ...queryOptions, queryKey, queryFn });
|
|
91
114
|
const query = _reactquery.useQuery.call(void 0,
|
|
92
|
-
|
|
93
|
-
queryFn,
|
|
94
|
-
queryOptions
|
|
115
|
+
customOptions
|
|
95
116
|
);
|
|
96
|
-
query.queryKey = queryKey;
|
|
117
|
+
query.queryKey = customOptions.queryKey;
|
|
97
118
|
return query;
|
|
98
119
|
};
|
|
99
120
|
var createDefaultUnit = (personalUnitPutBodyBody, options) => {
|
|
100
|
-
return
|
|
121
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
101
122
|
{
|
|
102
123
|
url: `/unit`,
|
|
103
124
|
method: "put",
|
|
@@ -116,7 +137,7 @@ var useCreateDefaultUnit = (options) => {
|
|
|
116
137
|
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
117
138
|
};
|
|
118
139
|
var deleteDefaultUnit = (options) => {
|
|
119
|
-
return
|
|
140
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0, { url: `/unit`, method: "delete" }, options);
|
|
120
141
|
};
|
|
121
142
|
var useDeleteDefaultUnit = (options) => {
|
|
122
143
|
const { mutation: mutationOptions, request: requestOptions } = _nullishCoalesce(options, () => ( {}));
|
|
@@ -126,7 +147,7 @@ var useDeleteDefaultUnit = (options) => {
|
|
|
126
147
|
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
127
148
|
};
|
|
128
149
|
var getUnitCharges = (unitId, params, options, signal) => {
|
|
129
|
-
return
|
|
150
|
+
return _chunkUZTHSGDTcjs.customInstance.call(void 0,
|
|
130
151
|
{ url: `/unit/${unitId}/charges`, method: "get", params, signal },
|
|
131
152
|
options
|
|
132
153
|
);
|
|
@@ -138,11 +159,9 @@ var useGetUnitCharges = (unitId, params, options) => {
|
|
|
138
159
|
const queryFn = ({
|
|
139
160
|
signal
|
|
140
161
|
}) => getUnitCharges(unitId, params, requestOptions, signal);
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
query.queryKey = queryKey;
|
|
162
|
+
const customOptions = _chunk7XN3IQYVcjs.queryMutator.call(void 0, { ...queryOptions, queryKey, queryFn });
|
|
163
|
+
const query = _reactquery.useQuery.call(void 0, customOptions);
|
|
164
|
+
query.queryKey = customOptions.queryKey;
|
|
146
165
|
return query;
|
|
147
166
|
};
|
|
148
167
|
|
|
@@ -166,5 +185,7 @@ var useGetUnitCharges = (unitId, params, options) => {
|
|
|
166
185
|
|
|
167
186
|
|
|
168
187
|
|
|
169
|
-
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
exports.createDefaultUnit = createDefaultUnit; exports.createOrganisationUnit = createOrganisationUnit; exports.deleteDefaultUnit = deleteDefaultUnit; exports.deleteOrganisationUnit = deleteOrganisationUnit; exports.getGetOrganisationUnitsQueryKey = getGetOrganisationUnitsQueryKey; exports.getGetUnitChargesQueryKey = getGetUnitChargesQueryKey; exports.getGetUnitQueryKey = getGetUnitQueryKey; exports.getGetUnitsQueryKey = getGetUnitsQueryKey; exports.getOrganisationUnits = getOrganisationUnits; exports.getUnit = getUnit; exports.getUnitCharges = getUnitCharges; exports.getUnits = getUnits; exports.patchUnit = patchUnit; exports.useCreateDefaultUnit = useCreateDefaultUnit; exports.useCreateOrganisationUnit = useCreateOrganisationUnit; exports.useDeleteDefaultUnit = useDeleteDefaultUnit; exports.useDeleteOrganisationUnit = useDeleteOrganisationUnit; exports.useGetOrganisationUnits = useGetOrganisationUnits; exports.useGetUnit = useGetUnit; exports.useGetUnitCharges = useGetUnitCharges; exports.useGetUnits = useGetUnits; exports.usePatchUnit = usePatchUnit;
|
|
170
191
|
//# sourceMappingURL=unit.cjs.map
|
package/unit/unit.cjs.map
CHANGED
|
@@ -1 +1 @@
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AAAA,EACF,MAAM,eAAe,QAAQ,QAAQ,gBAAgB,MAAM;AAE3D,QAAM,QAAQ,SAIZ,UAAU,SAAS;AAAA,IACnB,SAAS,CAAC,CAAC;AAAA,IACX,GAAG;AAAA,EACL,CAAC;AAED,QAAM,WAAW;AAEjB,SAAO;AACT","sourcesContent":["/**\n * Generated by orval v6.10.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: 2.0\n */\nimport { useQuery, useMutation } from \"@tanstack/react-query\";\nimport type {\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"@tanstack/react-query\";\nimport type {\n OrganisationUnitsGetResponse,\n AsError,\n OrganisationUnitPostResponse,\n OrganisationUnitPostBodyBody,\n UnitGetResponse,\n UnitsGetResponse,\n PersonalUnitPutResponse,\n PersonalUnitPutBodyBody,\n UnitChargesGetResponse,\n GetUnitChargesParams,\n} from \"../account-server-api.schemas\";\nimport { customInstance } from \".././custom-instance\";\nimport type { ErrorType } from \".././custom-instance\";\n\n// eslint-disable-next-line\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 or that are public\n\n * @summary Gets Organisational Units\n */\nexport const getOrganisationUnits = (\n orgId: string,\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<OrganisationUnitsGetResponse>(\n { url: `/organisation/${orgId}/unit`, method: \"get\", signal },\n options\n );\n};\n\nexport const getGetOrganisationUnitsQueryKey = (orgId: string) => [\n `/organisation/${orgId}/unit`,\n];\n\nexport type GetOrganisationUnitsQueryResult = NonNullable<\n Awaited<ReturnType<typeof getOrganisationUnits>>\n>;\nexport type GetOrganisationUnitsQueryError = ErrorType<void | AsError>;\n\nexport const useGetOrganisationUnits = <\n TData = Awaited<ReturnType<typeof getOrganisationUnits>>,\n TError = ErrorType<void | AsError>\n>(\n orgId: string,\n options?: {\n query?: UseQueryOptions<\n Awaited<ReturnType<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 Awaited<ReturnType<typeof getOrganisationUnits>>\n > = ({ signal }) => getOrganisationUnits(orgId, requestOptions, signal);\n\n const query = useQuery<\n Awaited<ReturnType<typeof getOrganisationUnits>>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions }) as UseQueryResult<\n TData,\n TError\n > & { queryKey: QueryKey };\n\n query.queryKey = queryKey;\n\n return query;\n};\n\n/**\n * Creates a new organisation unit. You need to be in the 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 headers: { \"Content-Type\": \"application/json\" },\n data: organisationUnitPostBodyBody,\n },\n options\n );\n};\n\nexport type CreateOrganisationUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof createOrganisationUnit>>\n>;\nexport type CreateOrganisationUnitMutationBody = OrganisationUnitPostBodyBody;\nexport type CreateOrganisationUnitMutationError = ErrorType<AsError | void>;\n\nexport const useCreateOrganisationUnit = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<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 Awaited<ReturnType<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 Awaited<ReturnType<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 or it is public. Admin users can see all Units\n\n * @summary Gets an Organisational Unit\n */\nexport const getUnit = (\n unitId: string,\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<UnitGetResponse>(\n { url: `/unit/${unitId}`, method: \"get\", signal },\n options\n );\n};\n\nexport const getGetUnitQueryKey = (unitId: string) => [`/unit/${unitId}`];\n\nexport type GetUnitQueryResult = NonNullable<\n Awaited<ReturnType<typeof getUnit>>\n>;\nexport type GetUnitQueryError = ErrorType<void | AsError>;\n\nexport const useGetUnit = <\n TData = Awaited<ReturnType<typeof getUnit>>,\n TError = ErrorType<void | AsError>\n>(\n unitId: string,\n options?: {\n query?: UseQueryOptions<Awaited<ReturnType<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(unitId);\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnit>>> = ({\n signal,\n }) => getUnit(unitId, requestOptions, signal);\n\n const query = useQuery<Awaited<ReturnType<typeof getUnit>>, TError, TData>(\n queryKey,\n queryFn,\n { enabled: !!unitId, ...queryOptions }\n ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = queryKey;\n\n return query;\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 unitId: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit/${unitId}`, method: \"delete\" },\n options\n );\n};\n\nexport type DeleteOrganisationUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof deleteOrganisationUnit>>\n>;\n\nexport type DeleteOrganisationUnitMutationError = ErrorType<AsError>;\n\nexport const useDeleteOrganisationUnit = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<typeof deleteOrganisationUnit>>,\n TError,\n { unitId: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options ?? {};\n\n const mutationFn: MutationFunction<\n Awaited<ReturnType<typeof deleteOrganisationUnit>>,\n { unitId: string }\n > = (props) => {\n const { unitId } = props ?? {};\n\n return deleteOrganisationUnit(unitId, requestOptions);\n };\n\n return useMutation<\n Awaited<ReturnType<typeof deleteOrganisationUnit>>,\n TError,\n { unitId: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets all the Units that are public or you are a member of. Admin users can see all Units\n\n * @summary Gets Units\n */\nexport const getUnits = (\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<UnitsGetResponse>(\n { url: `/unit`, method: \"get\", signal },\n options\n );\n};\n\nexport const getGetUnitsQueryKey = () => [`/unit`];\n\nexport type GetUnitsQueryResult = NonNullable<\n Awaited<ReturnType<typeof getUnits>>\n>;\nexport type GetUnitsQueryError = ErrorType<void | AsError>;\n\nexport const useGetUnits = <\n TData = Awaited<ReturnType<typeof getUnits>>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<Awaited<ReturnType<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<Awaited<ReturnType<typeof getUnits>>> = ({\n signal,\n }) => getUnits(requestOptions, signal);\n\n const query = useQuery<Awaited<ReturnType<typeof getUnits>>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = queryKey;\n\n return query;\n};\n\n/**\n * Creates a 'Personal' Unit for a User. The unit will belong to the built-in **Default** Organisation. Users can only have one Personal Unit and Personal Units cannot have other Users\n\n * @summary Create a new Personal Unit\n */\nexport const createDefaultUnit = (\n personalUnitPutBodyBody: PersonalUnitPutBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<PersonalUnitPutResponse>(\n {\n url: `/unit`,\n method: \"put\",\n headers: { \"Content-Type\": \"application/json\" },\n data: personalUnitPutBodyBody,\n },\n options\n );\n};\n\nexport type CreateDefaultUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof createDefaultUnit>>\n>;\nexport type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody;\nexport type CreateDefaultUnitMutationError = ErrorType<AsError | void>;\n\nexport const useCreateDefaultUnit = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<typeof createDefaultUnit>>,\n TError,\n { data: PersonalUnitPutBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options ?? {};\n\n const mutationFn: MutationFunction<\n Awaited<ReturnType<typeof createDefaultUnit>>,\n { data: PersonalUnitPutBodyBody }\n > = (props) => {\n const { data } = props ?? {};\n\n return createDefaultUnit(data, requestOptions);\n };\n\n return useMutation<\n Awaited<ReturnType<typeof createDefaultUnit>>,\n TError,\n { data: PersonalUnitPutBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Deletes a 'Personal' Unit. It must be your Unit, which belongs to the Default Organisation\n\n * @summary Deletes a Personal Unit\n */\nexport const deleteDefaultUnit = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>({ url: `/unit`, method: \"delete\" }, options);\n};\n\nexport type DeleteDefaultUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof deleteDefaultUnit>>\n>;\n\nexport type DeleteDefaultUnitMutationError = ErrorType<AsError>;\n\nexport const useDeleteDefaultUnit = <\n TError = ErrorType<AsError>,\n TVariables = void,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<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 Awaited<ReturnType<typeof deleteDefaultUnit>>,\n TVariables\n > = () => {\n return deleteDefaultUnit(requestOptions);\n };\n\n return useMutation<\n Awaited<ReturnType<typeof deleteDefaultUnit>>,\n TError,\n TVariables,\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Get the charges made against a Unit with optional **from** (inclusive) and **until** (exclusive) dates. If no dates are provided, the charges for the current billing period are returned.\n\nDates are interpreted using the Python dateutil parser so the input strings are extremely flexible, i.e. `1 December 2021` is an acceptable format.\n\n**from** must be a date (day) prior to **until**. For example, to see the charges for the 11th July 2022 set **from** to `11 July 2022` and **until** to `12 July 2022`. As an alternative to **From** and **Until** you can provide a **Prior Billing Period**, a value that identifies the prior period to retrieve. A value of `-1` would indicate the *prior period* (month) with an oldest retrieval value of `-23` (approximately two years).\n\nYou need to be part of the **Unit** or **Organisation** to use this method\n * @summary Get charges made against a Unit\n */\nexport const getUnitCharges = (\n unitId: string,\n params?: GetUnitChargesParams,\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<UnitChargesGetResponse>(\n { url: `/unit/${unitId}/charges`, method: \"get\", params, signal },\n options\n );\n};\n\nexport const getGetUnitChargesQueryKey = (\n unitId: string,\n params?: GetUnitChargesParams\n) => [`/unit/${unitId}/charges`, ...(params ? [params] : [])];\n\nexport type GetUnitChargesQueryResult = NonNullable<\n Awaited<ReturnType<typeof getUnitCharges>>\n>;\nexport type GetUnitChargesQueryError = ErrorType<AsError | void>;\n\nexport const useGetUnitCharges = <\n TData = Awaited<ReturnType<typeof getUnitCharges>>,\n TError = ErrorType<AsError | void>\n>(\n unitId: string,\n params?: GetUnitChargesParams,\n options?: {\n query?: UseQueryOptions<\n Awaited<ReturnType<typeof getUnitCharges>>,\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 ?? getGetUnitChargesQueryKey(unitId, params);\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnitCharges>>> = ({\n signal,\n }) => getUnitCharges(unitId, params, requestOptions, signal);\n\n const query = useQuery<\n Awaited<ReturnType<typeof getUnitCharges>>,\n TError,\n TData\n >(queryKey, queryFn, {\n enabled: !!unitId,\n ...queryOptions,\n }) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = queryKey;\n\n return query;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/unit/unit.ts"],"names":[],"mappings":";;;;;;;;AAUA,SAAS,UAAU,mBAAmB;AAuC/B,IAAM,uBAAuB,CAClC,OACA,SACA,WACG;AACH,SAAO;AAAA,IACL,EAAE,KAAK,iBAAiB,cAAc,QAAQ,OAAO,OAAO;AAAA,IAC5D;AAAA,EACF;AACF;AAEO,IAAM,kCAAkC,CAAC,UAAkB;AAAA,EAChE,iBAAiB;AACnB;AAOO,IAAM,0BAA0B,CAIrC,OACA,YAQ2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,eAAe,IAAI,WAAW,CAA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EAAE,OAAO,cAAc,SAAS,eAAe,IAAI,WAAW,CAAC;AAErE,QAAM,YACJ,6CAAc,aAAY,0BAA0B,QAAQ,MAAM;AAEpE,QAAM,UAAqE,CAAC;AAAA,IAC1E;AAAA,EACF,MAAM,eAAe,QAAQ,QAAQ,gBAAgB,MAAM;AAE3D,QAAM,gBAAgB,aAAa,EAAE,GAAG,cAAc,UAAU,QAAQ,CAAC;AAEzE,QAAM,QAAQ,SAIZ,aAAa;AAEf,QAAM,WAAW,cAAc;AAE/B,SAAO;AACT","sourcesContent":["/**\n * Generated by orval v6.12.1 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 2.0\n */\nimport { useQuery, useMutation } from \"@tanstack/react-query\";\nimport type {\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"@tanstack/react-query\";\nimport type {\n OrganisationUnitsGetResponse,\n AsError,\n OrganisationUnitPostResponse,\n OrganisationUnitPostBodyBody,\n UnitGetResponse,\n UnitPatchBodyBody,\n UnitsGetResponse,\n PersonalUnitPutResponse,\n PersonalUnitPutBodyBody,\n UnitChargesGetResponse,\n GetUnitChargesParams,\n} from \"../account-server-api.schemas\";\nimport { customInstance } from \".././custom-instance\";\nimport type { ErrorType } from \".././custom-instance\";\nimport { queryMutator } from \".././queryMutator\";\n\n// eslint-disable-next-line\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 or that are public\n\n * @summary Gets Organisational Units\n */\nexport const getOrganisationUnits = (\n orgId: string,\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<OrganisationUnitsGetResponse>(\n { url: `/organisation/${orgId}/unit`, method: \"get\", signal },\n options\n );\n};\n\nexport const getGetOrganisationUnitsQueryKey = (orgId: string) => [\n `/organisation/${orgId}/unit`,\n];\n\nexport type GetOrganisationUnitsQueryResult = NonNullable<\n Awaited<ReturnType<typeof getOrganisationUnits>>\n>;\nexport type GetOrganisationUnitsQueryError = ErrorType<void | AsError>;\n\nexport const useGetOrganisationUnits = <\n TData = Awaited<ReturnType<typeof getOrganisationUnits>>,\n TError = ErrorType<void | AsError>\n>(\n orgId: string,\n options?: {\n query?: UseQueryOptions<\n Awaited<ReturnType<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 Awaited<ReturnType<typeof getOrganisationUnits>>\n > = ({ signal }) => getOrganisationUnits(orgId, requestOptions, signal);\n\n const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });\n\n const query = useQuery<\n Awaited<ReturnType<typeof getOrganisationUnits>>,\n TError,\n TData\n >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = customOptions.queryKey;\n\n return query;\n};\n\n/**\n * Creates a new organisation unit. You need to be in the 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 headers: { \"Content-Type\": \"application/json\" },\n data: organisationUnitPostBodyBody,\n },\n options\n );\n};\n\nexport type CreateOrganisationUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof createOrganisationUnit>>\n>;\nexport type CreateOrganisationUnitMutationBody = OrganisationUnitPostBodyBody;\nexport type CreateOrganisationUnitMutationError = ErrorType<AsError | void>;\n\nexport const useCreateOrganisationUnit = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<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 Awaited<ReturnType<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 Awaited<ReturnType<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 or it is public. Admin users can see all Units\n\n * @summary Gets an Organisational Unit\n */\nexport const getUnit = (\n unitId: string,\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<UnitGetResponse>(\n { url: `/unit/${unitId}`, method: \"get\", signal },\n options\n );\n};\n\nexport const getGetUnitQueryKey = (unitId: string) => [`/unit/${unitId}`];\n\nexport type GetUnitQueryResult = NonNullable<\n Awaited<ReturnType<typeof getUnit>>\n>;\nexport type GetUnitQueryError = ErrorType<void | AsError>;\n\nexport const useGetUnit = <\n TData = Awaited<ReturnType<typeof getUnit>>,\n TError = ErrorType<void | AsError>\n>(\n unitId: string,\n options?: {\n query?: UseQueryOptions<Awaited<ReturnType<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(unitId);\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnit>>> = ({\n signal,\n }) => getUnit(unitId, requestOptions, signal);\n\n const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });\n\n const query = useQuery<Awaited<ReturnType<typeof getUnit>>, TError, TData>(\n customOptions\n ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = customOptions.queryKey;\n\n return query;\n};\n\n/**\n * Used to update existing **Unit**.\n\nYou have to be the Unit owner (or an administrator) to patch a Unit.\n\n * @summary Adjust an existing Unit\n */\nexport const patchUnit = (\n unitId: string,\n unitPatchBodyBody: UnitPatchBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/unit/${unitId}`,\n method: \"patch\",\n headers: { \"Content-Type\": \"application/json\" },\n data: unitPatchBodyBody,\n },\n options\n );\n};\n\nexport type PatchUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof patchUnit>>\n>;\nexport type PatchUnitMutationBody = UnitPatchBodyBody;\nexport type PatchUnitMutationError = ErrorType<AsError>;\n\nexport const usePatchUnit = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<typeof patchUnit>>,\n TError,\n { unitId: string; data: UnitPatchBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options ?? {};\n\n const mutationFn: MutationFunction<\n Awaited<ReturnType<typeof patchUnit>>,\n { unitId: string; data: UnitPatchBodyBody }\n > = (props) => {\n const { unitId, data } = props ?? {};\n\n return patchUnit(unitId, data, requestOptions);\n };\n\n return useMutation<\n Awaited<ReturnType<typeof patchUnit>>,\n TError,\n { unitId: string; data: UnitPatchBodyBody },\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 unitId: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit/${unitId}`, method: \"delete\" },\n options\n );\n};\n\nexport type DeleteOrganisationUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof deleteOrganisationUnit>>\n>;\n\nexport type DeleteOrganisationUnitMutationError = ErrorType<AsError>;\n\nexport const useDeleteOrganisationUnit = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<typeof deleteOrganisationUnit>>,\n TError,\n { unitId: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options ?? {};\n\n const mutationFn: MutationFunction<\n Awaited<ReturnType<typeof deleteOrganisationUnit>>,\n { unitId: string }\n > = (props) => {\n const { unitId } = props ?? {};\n\n return deleteOrganisationUnit(unitId, requestOptions);\n };\n\n return useMutation<\n Awaited<ReturnType<typeof deleteOrganisationUnit>>,\n TError,\n { unitId: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets all the Units that are public or you are a member of. Admin users can see all Units\n\n * @summary Gets Units\n */\nexport const getUnits = (\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<UnitsGetResponse>(\n { url: `/unit`, method: \"get\", signal },\n options\n );\n};\n\nexport const getGetUnitsQueryKey = () => [`/unit`];\n\nexport type GetUnitsQueryResult = NonNullable<\n Awaited<ReturnType<typeof getUnits>>\n>;\nexport type GetUnitsQueryError = ErrorType<void | AsError>;\n\nexport const useGetUnits = <\n TData = Awaited<ReturnType<typeof getUnits>>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<Awaited<ReturnType<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<Awaited<ReturnType<typeof getUnits>>> = ({\n signal,\n }) => getUnits(requestOptions, signal);\n\n const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });\n\n const query = useQuery<Awaited<ReturnType<typeof getUnits>>, TError, TData>(\n customOptions\n ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = customOptions.queryKey;\n\n return query;\n};\n\n/**\n * Creates a 'Personal' Unit for a User. The unit will belong to the built-in **Default** Organisation. Users can only have one Personal Unit and Personal Units cannot have other Users\n\n * @summary Create a new Personal Unit\n */\nexport const createDefaultUnit = (\n personalUnitPutBodyBody: PersonalUnitPutBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<PersonalUnitPutResponse>(\n {\n url: `/unit`,\n method: \"put\",\n headers: { \"Content-Type\": \"application/json\" },\n data: personalUnitPutBodyBody,\n },\n options\n );\n};\n\nexport type CreateDefaultUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof createDefaultUnit>>\n>;\nexport type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody;\nexport type CreateDefaultUnitMutationError = ErrorType<AsError | void>;\n\nexport const useCreateDefaultUnit = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<typeof createDefaultUnit>>,\n TError,\n { data: PersonalUnitPutBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options ?? {};\n\n const mutationFn: MutationFunction<\n Awaited<ReturnType<typeof createDefaultUnit>>,\n { data: PersonalUnitPutBodyBody }\n > = (props) => {\n const { data } = props ?? {};\n\n return createDefaultUnit(data, requestOptions);\n };\n\n return useMutation<\n Awaited<ReturnType<typeof createDefaultUnit>>,\n TError,\n { data: PersonalUnitPutBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Deletes a 'Personal' Unit. It must be your Unit, which belongs to the Default Organisation\n\n * @summary Deletes a Personal Unit\n */\nexport const deleteDefaultUnit = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>({ url: `/unit`, method: \"delete\" }, options);\n};\n\nexport type DeleteDefaultUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof deleteDefaultUnit>>\n>;\n\nexport type DeleteDefaultUnitMutationError = ErrorType<AsError>;\n\nexport const useDeleteDefaultUnit = <\n TError = ErrorType<AsError>,\n TVariables = void,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<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 Awaited<ReturnType<typeof deleteDefaultUnit>>,\n TVariables\n > = () => {\n return deleteDefaultUnit(requestOptions);\n };\n\n return useMutation<\n Awaited<ReturnType<typeof deleteDefaultUnit>>,\n TError,\n TVariables,\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Get the charges made against a Unit with optional **from** (inclusive) and **until** (exclusive) dates. If no dates are provided, the charges for the current billing period are returned.\n\nDates are interpreted using the Python dateutil parser so the input strings are extremely flexible, i.e. `1 December 2021` is an acceptable format.\n\n**from** must be a date (day) prior to **until**. For example, to see the charges for the 11th July 2022 set **from** to `11 July 2022` and **until** to `12 July 2022`. As an alternative to **From** and **Until** you can provide a **Prior Billing Period**, a value that identifies the prior period to retrieve. A value of `-1` would indicate the *prior period* (month) with an oldest retrieval value of `-23` (approximately two years).\n\nYou need to be part of the **Unit** or **Organisation** to use this method\n * @summary Get charges made against a Unit\n */\nexport const getUnitCharges = (\n unitId: string,\n params?: GetUnitChargesParams,\n options?: SecondParameter<typeof customInstance>,\n signal?: AbortSignal\n) => {\n return customInstance<UnitChargesGetResponse>(\n { url: `/unit/${unitId}/charges`, method: \"get\", params, signal },\n options\n );\n};\n\nexport const getGetUnitChargesQueryKey = (\n unitId: string,\n params?: GetUnitChargesParams\n) => [`/unit/${unitId}/charges`, ...(params ? [params] : [])];\n\nexport type GetUnitChargesQueryResult = NonNullable<\n Awaited<ReturnType<typeof getUnitCharges>>\n>;\nexport type GetUnitChargesQueryError = ErrorType<AsError | void>;\n\nexport const useGetUnitCharges = <\n TData = Awaited<ReturnType<typeof getUnitCharges>>,\n TError = ErrorType<AsError | void>\n>(\n unitId: string,\n params?: GetUnitChargesParams,\n options?: {\n query?: UseQueryOptions<\n Awaited<ReturnType<typeof getUnitCharges>>,\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 ?? getGetUnitChargesQueryKey(unitId, params);\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnitCharges>>> = ({\n signal,\n }) => getUnitCharges(unitId, params, requestOptions, signal);\n\n const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });\n\n const query = useQuery<\n Awaited<ReturnType<typeof getUnitCharges>>,\n TError,\n TData\n >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };\n\n query.queryKey = customOptions.queryKey;\n\n return query;\n};\n"]}
|
package/unit/unit.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aE as customInstance, ap as OrganisationUnitsGetResponse, aF as ErrorType, aA as AsError, o as OrganisationUnitPostBodyBody, as as OrganisationUnitPostResponse, w as UnitDetail, n as UnitPatchBodyBody, a4 as UnitsGetResponse, p as PersonalUnitPutBodyBody, ar as PersonalUnitPutResponse, k as GetUnitChargesParams, ab as UnitChargesGetResponse } from '../custom-instance-85497958.js';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from '@tanstack/react-query';
|
|
4
4
|
import 'axios';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
|
|
7
7
|
/**
|
|
8
8
|
* Gets Organisational Units you have access to or that are public
|
|
9
9
|
|
|
@@ -11,8 +11,8 @@ declare type SecondParameter<T extends (...args: any) => any> = T extends (confi
|
|
|
11
11
|
*/
|
|
12
12
|
declare const getOrganisationUnits: (orgId: string, options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => Promise<OrganisationUnitsGetResponse>;
|
|
13
13
|
declare const getGetOrganisationUnitsQueryKey: (orgId: string) => string[];
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
type GetOrganisationUnitsQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganisationUnits>>>;
|
|
15
|
+
type GetOrganisationUnitsQueryError = ErrorType<void | AsError>;
|
|
16
16
|
declare const useGetOrganisationUnits: <TData = OrganisationUnitsGetResponse, TError = ErrorType<void | AsError>>(orgId: string, options?: {
|
|
17
17
|
query?: UseQueryOptions<OrganisationUnitsGetResponse, TError, TData, QueryKey> | undefined;
|
|
18
18
|
request?: SecondParameter<typeof customInstance>;
|
|
@@ -25,9 +25,9 @@ declare const useGetOrganisationUnits: <TData = OrganisationUnitsGetResponse, TE
|
|
|
25
25
|
* @summary Create a new Organisational Unit
|
|
26
26
|
*/
|
|
27
27
|
declare const createOrganisationUnit: (orgId: string, organisationUnitPostBodyBody: OrganisationUnitPostBodyBody, options?: SecondParameter<typeof customInstance>) => Promise<OrganisationUnitPostResponse>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
type CreateOrganisationUnitMutationResult = NonNullable<Awaited<ReturnType<typeof createOrganisationUnit>>>;
|
|
29
|
+
type CreateOrganisationUnitMutationBody = OrganisationUnitPostBodyBody;
|
|
30
|
+
type CreateOrganisationUnitMutationError = ErrorType<AsError | void>;
|
|
31
31
|
declare const useCreateOrganisationUnit: <TError = ErrorType<void | AsError>, TContext = unknown>(options?: {
|
|
32
32
|
mutation?: UseMutationOptions<OrganisationUnitPostResponse, TError, {
|
|
33
33
|
orgId: string;
|
|
@@ -45,22 +45,43 @@ declare const useCreateOrganisationUnit: <TError = ErrorType<void | AsError>, TC
|
|
|
45
45
|
*/
|
|
46
46
|
declare const getUnit: (unitId: string, options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => Promise<UnitDetail>;
|
|
47
47
|
declare const getGetUnitQueryKey: (unitId: string) => string[];
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
type GetUnitQueryResult = NonNullable<Awaited<ReturnType<typeof getUnit>>>;
|
|
49
|
+
type GetUnitQueryError = ErrorType<void | AsError>;
|
|
50
50
|
declare const useGetUnit: <TData = UnitDetail, TError = ErrorType<void | AsError>>(unitId: string, options?: {
|
|
51
51
|
query?: UseQueryOptions<UnitDetail, TError, TData, QueryKey> | undefined;
|
|
52
52
|
request?: SecondParameter<typeof customInstance>;
|
|
53
53
|
} | undefined) => UseQueryResult<TData, TError> & {
|
|
54
54
|
queryKey: QueryKey;
|
|
55
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Used to update existing **Unit**.
|
|
58
|
+
|
|
59
|
+
You have to be the Unit owner (or an administrator) to patch a Unit.
|
|
60
|
+
|
|
61
|
+
* @summary Adjust an existing Unit
|
|
62
|
+
*/
|
|
63
|
+
declare const patchUnit: (unitId: string, unitPatchBodyBody: UnitPatchBodyBody, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
64
|
+
type PatchUnitMutationResult = NonNullable<Awaited<ReturnType<typeof patchUnit>>>;
|
|
65
|
+
type PatchUnitMutationBody = UnitPatchBodyBody;
|
|
66
|
+
type PatchUnitMutationError = ErrorType<AsError>;
|
|
67
|
+
declare const usePatchUnit: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
|
|
68
|
+
mutation?: UseMutationOptions<void, TError, {
|
|
69
|
+
unitId: string;
|
|
70
|
+
data: UnitPatchBodyBody;
|
|
71
|
+
}, TContext> | undefined;
|
|
72
|
+
request?: SecondParameter<typeof customInstance>;
|
|
73
|
+
} | undefined) => _tanstack_react_query.UseMutationResult<void, TError, {
|
|
74
|
+
unitId: string;
|
|
75
|
+
data: UnitPatchBodyBody;
|
|
76
|
+
}, TContext>;
|
|
56
77
|
/**
|
|
57
78
|
* 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
|
|
58
79
|
|
|
59
80
|
* @summary Deletes an Organisational Unit
|
|
60
81
|
*/
|
|
61
82
|
declare const deleteOrganisationUnit: (unitId: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
type DeleteOrganisationUnitMutationResult = NonNullable<Awaited<ReturnType<typeof deleteOrganisationUnit>>>;
|
|
84
|
+
type DeleteOrganisationUnitMutationError = ErrorType<AsError>;
|
|
64
85
|
declare const useDeleteOrganisationUnit: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
|
|
65
86
|
mutation?: UseMutationOptions<void, TError, {
|
|
66
87
|
unitId: string;
|
|
@@ -76,8 +97,8 @@ declare const useDeleteOrganisationUnit: <TError = ErrorType<AsError>, TContext
|
|
|
76
97
|
*/
|
|
77
98
|
declare const getUnits: (options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => Promise<UnitsGetResponse>;
|
|
78
99
|
declare const getGetUnitsQueryKey: () => string[];
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
type GetUnitsQueryResult = NonNullable<Awaited<ReturnType<typeof getUnits>>>;
|
|
101
|
+
type GetUnitsQueryError = ErrorType<void | AsError>;
|
|
81
102
|
declare const useGetUnits: <TData = UnitsGetResponse, TError = ErrorType<void | AsError>>(options?: {
|
|
82
103
|
query?: UseQueryOptions<UnitsGetResponse, TError, TData, QueryKey> | undefined;
|
|
83
104
|
request?: SecondParameter<typeof customInstance>;
|
|
@@ -90,9 +111,9 @@ declare const useGetUnits: <TData = UnitsGetResponse, TError = ErrorType<void |
|
|
|
90
111
|
* @summary Create a new Personal Unit
|
|
91
112
|
*/
|
|
92
113
|
declare const createDefaultUnit: (personalUnitPutBodyBody: PersonalUnitPutBodyBody, options?: SecondParameter<typeof customInstance>) => Promise<PersonalUnitPutResponse>;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
114
|
+
type CreateDefaultUnitMutationResult = NonNullable<Awaited<ReturnType<typeof createDefaultUnit>>>;
|
|
115
|
+
type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody;
|
|
116
|
+
type CreateDefaultUnitMutationError = ErrorType<AsError | void>;
|
|
96
117
|
declare const useCreateDefaultUnit: <TError = ErrorType<void | AsError>, TContext = unknown>(options?: {
|
|
97
118
|
mutation?: UseMutationOptions<PersonalUnitPutResponse, TError, {
|
|
98
119
|
data: PersonalUnitPutBodyBody;
|
|
@@ -107,8 +128,8 @@ declare const useCreateDefaultUnit: <TError = ErrorType<void | AsError>, TContex
|
|
|
107
128
|
* @summary Deletes a Personal Unit
|
|
108
129
|
*/
|
|
109
130
|
declare const deleteDefaultUnit: (options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
110
|
-
|
|
111
|
-
|
|
131
|
+
type DeleteDefaultUnitMutationResult = NonNullable<Awaited<ReturnType<typeof deleteDefaultUnit>>>;
|
|
132
|
+
type DeleteDefaultUnitMutationError = ErrorType<AsError>;
|
|
112
133
|
declare const useDeleteDefaultUnit: <TError = ErrorType<AsError>, TVariables = void, TContext = unknown>(options?: {
|
|
113
134
|
mutation?: UseMutationOptions<void, TError, TVariables, TContext> | undefined;
|
|
114
135
|
request?: SecondParameter<typeof customInstance>;
|
|
@@ -125,8 +146,8 @@ You need to be part of the **Unit** or **Organisation** to use this method
|
|
|
125
146
|
*/
|
|
126
147
|
declare const getUnitCharges: (unitId: string, params?: GetUnitChargesParams, options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => Promise<UnitChargesGetResponse>;
|
|
127
148
|
declare const getGetUnitChargesQueryKey: (unitId: string, params?: GetUnitChargesParams) => (string | GetUnitChargesParams)[];
|
|
128
|
-
|
|
129
|
-
|
|
149
|
+
type GetUnitChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getUnitCharges>>>;
|
|
150
|
+
type GetUnitChargesQueryError = ErrorType<AsError | void>;
|
|
130
151
|
declare const useGetUnitCharges: <TData = UnitChargesGetResponse, TError = ErrorType<void | AsError>>(unitId: string, params?: GetUnitChargesParams, options?: {
|
|
131
152
|
query?: UseQueryOptions<UnitChargesGetResponse, TError, TData, QueryKey> | undefined;
|
|
132
153
|
request?: SecondParameter<typeof customInstance>;
|
|
@@ -134,4 +155,4 @@ declare const useGetUnitCharges: <TData = UnitChargesGetResponse, TError = Error
|
|
|
134
155
|
queryKey: QueryKey;
|
|
135
156
|
};
|
|
136
157
|
|
|
137
|
-
export { CreateDefaultUnitMutationBody, CreateDefaultUnitMutationError, CreateDefaultUnitMutationResult, CreateOrganisationUnitMutationBody, CreateOrganisationUnitMutationError, CreateOrganisationUnitMutationResult, DeleteDefaultUnitMutationError, DeleteDefaultUnitMutationResult, DeleteOrganisationUnitMutationError, DeleteOrganisationUnitMutationResult, GetOrganisationUnitsQueryError, GetOrganisationUnitsQueryResult, GetUnitChargesQueryError, GetUnitChargesQueryResult, GetUnitQueryError, GetUnitQueryResult, GetUnitsQueryError, GetUnitsQueryResult, createDefaultUnit, createOrganisationUnit, deleteDefaultUnit, deleteOrganisationUnit, getGetOrganisationUnitsQueryKey, getGetUnitChargesQueryKey, getGetUnitQueryKey, getGetUnitsQueryKey, getOrganisationUnits, getUnit, getUnitCharges, getUnits, useCreateDefaultUnit, useCreateOrganisationUnit, useDeleteDefaultUnit, useDeleteOrganisationUnit, useGetOrganisationUnits, useGetUnit, useGetUnitCharges, useGetUnits };
|
|
158
|
+
export { CreateDefaultUnitMutationBody, CreateDefaultUnitMutationError, CreateDefaultUnitMutationResult, CreateOrganisationUnitMutationBody, CreateOrganisationUnitMutationError, CreateOrganisationUnitMutationResult, DeleteDefaultUnitMutationError, DeleteDefaultUnitMutationResult, DeleteOrganisationUnitMutationError, DeleteOrganisationUnitMutationResult, GetOrganisationUnitsQueryError, GetOrganisationUnitsQueryResult, GetUnitChargesQueryError, GetUnitChargesQueryResult, GetUnitQueryError, GetUnitQueryResult, GetUnitsQueryError, GetUnitsQueryResult, PatchUnitMutationBody, PatchUnitMutationError, PatchUnitMutationResult, createDefaultUnit, createOrganisationUnit, deleteDefaultUnit, deleteOrganisationUnit, getGetOrganisationUnitsQueryKey, getGetUnitChargesQueryKey, getGetUnitQueryKey, getGetUnitsQueryKey, getOrganisationUnits, getUnit, getUnitCharges, getUnits, patchUnit, useCreateDefaultUnit, useCreateOrganisationUnit, useDeleteDefaultUnit, useDeleteOrganisationUnit, useGetOrganisationUnits, useGetUnit, useGetUnitCharges, useGetUnits, usePatchUnit };
|
package/unit/unit.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
queryMutator
|
|
3
|
+
} from "../chunk-YEX2SGER.js";
|
|
1
4
|
import {
|
|
2
5
|
customInstance
|
|
3
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-3RNIDX7T.js";
|
|
4
7
|
|
|
5
8
|
// src/unit/unit.ts
|
|
6
9
|
import { useQuery, useMutation } from "@tanstack/react-query";
|
|
@@ -17,8 +20,9 @@ var useGetOrganisationUnits = (orgId, options) => {
|
|
|
17
20
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
18
21
|
const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationUnitsQueryKey(orgId);
|
|
19
22
|
const queryFn = ({ signal }) => getOrganisationUnits(orgId, requestOptions, signal);
|
|
20
|
-
const
|
|
21
|
-
query
|
|
23
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
24
|
+
const query = useQuery(customOptions);
|
|
25
|
+
query.queryKey = customOptions.queryKey;
|
|
22
26
|
return query;
|
|
23
27
|
};
|
|
24
28
|
var createOrganisationUnit = (orgId, organisationUnitPostBodyBody, options) => {
|
|
@@ -53,14 +57,32 @@ var useGetUnit = (unitId, options) => {
|
|
|
53
57
|
const queryFn = ({
|
|
54
58
|
signal
|
|
55
59
|
}) => getUnit(unitId, requestOptions, signal);
|
|
60
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
56
61
|
const query = useQuery(
|
|
57
|
-
|
|
58
|
-
queryFn,
|
|
59
|
-
{ enabled: !!unitId, ...queryOptions }
|
|
62
|
+
customOptions
|
|
60
63
|
);
|
|
61
|
-
query.queryKey = queryKey;
|
|
64
|
+
query.queryKey = customOptions.queryKey;
|
|
62
65
|
return query;
|
|
63
66
|
};
|
|
67
|
+
var patchUnit = (unitId, unitPatchBodyBody, options) => {
|
|
68
|
+
return customInstance(
|
|
69
|
+
{
|
|
70
|
+
url: `/unit/${unitId}`,
|
|
71
|
+
method: "patch",
|
|
72
|
+
headers: { "Content-Type": "application/json" },
|
|
73
|
+
data: unitPatchBodyBody
|
|
74
|
+
},
|
|
75
|
+
options
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
var usePatchUnit = (options) => {
|
|
79
|
+
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
80
|
+
const mutationFn = (props) => {
|
|
81
|
+
const { unitId, data } = props ?? {};
|
|
82
|
+
return patchUnit(unitId, data, requestOptions);
|
|
83
|
+
};
|
|
84
|
+
return useMutation(mutationFn, mutationOptions);
|
|
85
|
+
};
|
|
64
86
|
var deleteOrganisationUnit = (unitId, options) => {
|
|
65
87
|
return customInstance(
|
|
66
88
|
{ url: `/unit/${unitId}`, method: "delete" },
|
|
@@ -88,12 +110,11 @@ var useGetUnits = (options) => {
|
|
|
88
110
|
const queryFn = ({
|
|
89
111
|
signal
|
|
90
112
|
}) => getUnits(requestOptions, signal);
|
|
113
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
91
114
|
const query = useQuery(
|
|
92
|
-
|
|
93
|
-
queryFn,
|
|
94
|
-
queryOptions
|
|
115
|
+
customOptions
|
|
95
116
|
);
|
|
96
|
-
query.queryKey = queryKey;
|
|
117
|
+
query.queryKey = customOptions.queryKey;
|
|
97
118
|
return query;
|
|
98
119
|
};
|
|
99
120
|
var createDefaultUnit = (personalUnitPutBodyBody, options) => {
|
|
@@ -138,11 +159,9 @@ var useGetUnitCharges = (unitId, params, options) => {
|
|
|
138
159
|
const queryFn = ({
|
|
139
160
|
signal
|
|
140
161
|
}) => getUnitCharges(unitId, params, requestOptions, signal);
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
query.queryKey = queryKey;
|
|
162
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
163
|
+
const query = useQuery(customOptions);
|
|
164
|
+
query.queryKey = customOptions.queryKey;
|
|
146
165
|
return query;
|
|
147
166
|
};
|
|
148
167
|
export {
|
|
@@ -158,6 +177,7 @@ export {
|
|
|
158
177
|
getUnit,
|
|
159
178
|
getUnitCharges,
|
|
160
179
|
getUnits,
|
|
180
|
+
patchUnit,
|
|
161
181
|
useCreateDefaultUnit,
|
|
162
182
|
useCreateOrganisationUnit,
|
|
163
183
|
useDeleteDefaultUnit,
|
|
@@ -165,6 +185,7 @@ export {
|
|
|
165
185
|
useGetOrganisationUnits,
|
|
166
186
|
useGetUnit,
|
|
167
187
|
useGetUnitCharges,
|
|
168
|
-
useGetUnits
|
|
188
|
+
useGetUnits,
|
|
189
|
+
usePatchUnit
|
|
169
190
|
};
|
|
170
191
|
//# sourceMappingURL=unit.js.map
|