@squonk/account-server-client 1.0.12 → 2.0.0-beta.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/README.md +1 -1
- package/asset/asset.cjs +1 -1
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.ts +9 -9
- package/asset/asset.js +1 -1
- package/asset/asset.js.map +1 -1
- package/{custom-instance-0608552a.d.ts → custom-instance-379e9b57.d.ts} +68 -8
- package/index.cjs +6 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +1 -1
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.ts +2 -2
- package/merchant/merchant.js +1 -1
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +24 -2
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +21 -6
- package/organisation/organisation.js +23 -1
- package/organisation/organisation.js.map +1 -1
- package/package.json +4 -4
- package/product/product.cjs +1 -1
- package/product/product.cjs.map +1 -1
- package/product/product.d.ts +8 -8
- package/product/product.js +1 -1
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +78 -6
- package/src/asset/asset.ts +3 -3
- package/src/merchant/merchant.ts +3 -3
- package/src/organisation/organisation.ts +65 -3
- package/src/product/product.ts +5 -5
- package/src/state/state.ts +3 -3
- package/src/unit/unit.ts +90 -11
- package/src/user/user.ts +3 -3
- package/state/state.cjs +1 -1
- package/state/state.cjs.map +1 -1
- package/state/state.d.ts +2 -2
- package/state/state.js +1 -1
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +35 -6
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +36 -11
- package/unit/unit.js +34 -5
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +1 -1
- package/user/user.cjs.map +1 -1
- package/user/user.d.ts +7 -7
- package/user/user.js +1 -1
- package/user/user.js.map +1 -1
package/src/unit/unit.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
A service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.
|
|
8
8
|
|
|
9
|
-
* OpenAPI spec version:
|
|
9
|
+
* OpenAPI spec version: 2.0
|
|
10
10
|
*/
|
|
11
|
-
import { useQuery, useMutation } from "react-query";
|
|
11
|
+
import { useQuery, useMutation } from "@tanstack/react-query";
|
|
12
12
|
import type {
|
|
13
13
|
UseQueryOptions,
|
|
14
14
|
UseMutationOptions,
|
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
MutationFunction,
|
|
17
17
|
UseQueryResult,
|
|
18
18
|
QueryKey,
|
|
19
|
-
} from "react-query";
|
|
19
|
+
} from "@tanstack/react-query";
|
|
20
20
|
import type {
|
|
21
21
|
OrganisationUnitsGetResponse,
|
|
22
22
|
AsError,
|
|
@@ -25,6 +25,9 @@ import type {
|
|
|
25
25
|
UnitGetResponse,
|
|
26
26
|
UnitsGetResponse,
|
|
27
27
|
PersonalUnitPutResponse,
|
|
28
|
+
PersonalUnitPutBodyBody,
|
|
29
|
+
UnitChargesGetResponse,
|
|
30
|
+
GetUnitChargesParams,
|
|
28
31
|
} from "../account-server-api.schemas";
|
|
29
32
|
import { customInstance } from ".././custom-instance";
|
|
30
33
|
import type { ErrorType } from ".././custom-instance";
|
|
@@ -313,10 +316,16 @@ export const useGetUnits = <
|
|
|
313
316
|
* @summary Create a new Personal Unit
|
|
314
317
|
*/
|
|
315
318
|
export const createDefaultUnit = (
|
|
319
|
+
personalUnitPutBodyBody: PersonalUnitPutBodyBody,
|
|
316
320
|
options?: SecondParameter<typeof customInstance>
|
|
317
321
|
) => {
|
|
318
322
|
return customInstance<PersonalUnitPutResponse>(
|
|
319
|
-
{
|
|
323
|
+
{
|
|
324
|
+
url: `/unit`,
|
|
325
|
+
method: "put",
|
|
326
|
+
headers: { "Content-Type": "application/json" },
|
|
327
|
+
data: personalUnitPutBodyBody,
|
|
328
|
+
},
|
|
320
329
|
options
|
|
321
330
|
);
|
|
322
331
|
};
|
|
@@ -324,18 +333,17 @@ export const createDefaultUnit = (
|
|
|
324
333
|
export type CreateDefaultUnitMutationResult = NonNullable<
|
|
325
334
|
Awaited<ReturnType<typeof createDefaultUnit>>
|
|
326
335
|
>;
|
|
327
|
-
|
|
336
|
+
export type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody;
|
|
328
337
|
export type CreateDefaultUnitMutationError = ErrorType<AsError | void>;
|
|
329
338
|
|
|
330
339
|
export const useCreateDefaultUnit = <
|
|
331
340
|
TError = ErrorType<AsError | void>,
|
|
332
|
-
TVariables = void,
|
|
333
341
|
TContext = unknown
|
|
334
342
|
>(options?: {
|
|
335
343
|
mutation?: UseMutationOptions<
|
|
336
344
|
Awaited<ReturnType<typeof createDefaultUnit>>,
|
|
337
345
|
TError,
|
|
338
|
-
|
|
346
|
+
{ data: PersonalUnitPutBodyBody },
|
|
339
347
|
TContext
|
|
340
348
|
>;
|
|
341
349
|
request?: SecondParameter<typeof customInstance>;
|
|
@@ -344,15 +352,17 @@ export const useCreateDefaultUnit = <
|
|
|
344
352
|
|
|
345
353
|
const mutationFn: MutationFunction<
|
|
346
354
|
Awaited<ReturnType<typeof createDefaultUnit>>,
|
|
347
|
-
|
|
348
|
-
> = () => {
|
|
349
|
-
|
|
355
|
+
{ data: PersonalUnitPutBodyBody }
|
|
356
|
+
> = (props) => {
|
|
357
|
+
const { data } = props ?? {};
|
|
358
|
+
|
|
359
|
+
return createDefaultUnit(data, requestOptions);
|
|
350
360
|
};
|
|
351
361
|
|
|
352
362
|
return useMutation<
|
|
353
363
|
Awaited<ReturnType<typeof createDefaultUnit>>,
|
|
354
364
|
TError,
|
|
355
|
-
|
|
365
|
+
{ data: PersonalUnitPutBodyBody },
|
|
356
366
|
TContext
|
|
357
367
|
>(mutationFn, mutationOptions);
|
|
358
368
|
};
|
|
@@ -402,3 +412,72 @@ export const useDeleteDefaultUnit = <
|
|
|
402
412
|
TContext
|
|
403
413
|
>(mutationFn, mutationOptions);
|
|
404
414
|
};
|
|
415
|
+
/**
|
|
416
|
+
* 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.
|
|
417
|
+
|
|
418
|
+
Dates are interpreted using the Python dateutil parser so the input strings are extremely flexible, i.e. `1 December 2021` is an acceptable format.
|
|
419
|
+
|
|
420
|
+
**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).
|
|
421
|
+
|
|
422
|
+
You need to be part of the **Unit** or **Organisation** to use this method
|
|
423
|
+
* @summary Get charges made against a Unit
|
|
424
|
+
*/
|
|
425
|
+
export const getUnitCharges = (
|
|
426
|
+
unitId: string,
|
|
427
|
+
params?: GetUnitChargesParams,
|
|
428
|
+
options?: SecondParameter<typeof customInstance>,
|
|
429
|
+
signal?: AbortSignal
|
|
430
|
+
) => {
|
|
431
|
+
return customInstance<UnitChargesGetResponse>(
|
|
432
|
+
{ url: `/unit/${unitId}/charges`, method: "get", params, signal },
|
|
433
|
+
options
|
|
434
|
+
);
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
export const getGetUnitChargesQueryKey = (
|
|
438
|
+
unitId: string,
|
|
439
|
+
params?: GetUnitChargesParams
|
|
440
|
+
) => [`/unit/${unitId}/charges`, ...(params ? [params] : [])];
|
|
441
|
+
|
|
442
|
+
export type GetUnitChargesQueryResult = NonNullable<
|
|
443
|
+
Awaited<ReturnType<typeof getUnitCharges>>
|
|
444
|
+
>;
|
|
445
|
+
export type GetUnitChargesQueryError = ErrorType<AsError | void>;
|
|
446
|
+
|
|
447
|
+
export const useGetUnitCharges = <
|
|
448
|
+
TData = Awaited<ReturnType<typeof getUnitCharges>>,
|
|
449
|
+
TError = ErrorType<AsError | void>
|
|
450
|
+
>(
|
|
451
|
+
unitId: string,
|
|
452
|
+
params?: GetUnitChargesParams,
|
|
453
|
+
options?: {
|
|
454
|
+
query?: UseQueryOptions<
|
|
455
|
+
Awaited<ReturnType<typeof getUnitCharges>>,
|
|
456
|
+
TError,
|
|
457
|
+
TData
|
|
458
|
+
>;
|
|
459
|
+
request?: SecondParameter<typeof customInstance>;
|
|
460
|
+
}
|
|
461
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
462
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
463
|
+
|
|
464
|
+
const queryKey =
|
|
465
|
+
queryOptions?.queryKey ?? getGetUnitChargesQueryKey(unitId, params);
|
|
466
|
+
|
|
467
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnitCharges>>> = ({
|
|
468
|
+
signal,
|
|
469
|
+
}) => getUnitCharges(unitId, params, requestOptions, signal);
|
|
470
|
+
|
|
471
|
+
const query = useQuery<
|
|
472
|
+
Awaited<ReturnType<typeof getUnitCharges>>,
|
|
473
|
+
TError,
|
|
474
|
+
TData
|
|
475
|
+
>(queryKey, queryFn, {
|
|
476
|
+
enabled: !!unitId,
|
|
477
|
+
...queryOptions,
|
|
478
|
+
}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
479
|
+
|
|
480
|
+
query.queryKey = queryKey;
|
|
481
|
+
|
|
482
|
+
return query;
|
|
483
|
+
};
|
package/src/user/user.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
A service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.
|
|
8
8
|
|
|
9
|
-
* OpenAPI spec version:
|
|
9
|
+
* OpenAPI spec version: 2.0
|
|
10
10
|
*/
|
|
11
|
-
import { useQuery, useMutation } from "react-query";
|
|
11
|
+
import { useQuery, useMutation } from "@tanstack/react-query";
|
|
12
12
|
import type {
|
|
13
13
|
UseQueryOptions,
|
|
14
14
|
UseMutationOptions,
|
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
MutationFunction,
|
|
17
17
|
UseQueryResult,
|
|
18
18
|
QueryKey,
|
|
19
|
-
} from "react-query";
|
|
19
|
+
} from "@tanstack/react-query";
|
|
20
20
|
import type {
|
|
21
21
|
UserAccountGetResponse,
|
|
22
22
|
AsError,
|
package/state/state.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkIUEU2LYCcjs = require('../chunk-IUEU2LYC.cjs');
|
|
4
4
|
|
|
5
5
|
// src/state/state.ts
|
|
6
|
-
var _reactquery = require('react-query');
|
|
6
|
+
var _reactquery = require('@tanstack/react-query');
|
|
7
7
|
var getVersion = (options, signal) => {
|
|
8
8
|
return _chunkIUEU2LYCcjs.customInstance.call(void 0,
|
|
9
9
|
{ url: `/version`, method: "get", signal },
|
package/state/state.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/state/state.ts"],"names":[],"mappings":";;;;;AAUA,SAAS,gBAAgB;AAyBlB,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,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,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:
|
|
1
|
+
{"version":3,"sources":["../../src/state/state.ts"],"names":[],"mappings":";;;;;AAUA,SAAS,gBAAgB;AAyBlB,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,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,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 } 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\";\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 query = useQuery<Awaited<ReturnType<typeof getVersion>>, 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"]}
|
package/state/state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UseQueryOptions, QueryKey, UseQueryResult } from 'react-query';
|
|
2
|
-
import {
|
|
1
|
+
import { UseQueryOptions, QueryKey, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { av as customInstance, ao as StateGetVersionResponse, aw as ErrorType, ar as AsError } from '../custom-instance-379e9b57.js';
|
|
3
3
|
import 'axios';
|
|
4
4
|
|
|
5
5
|
declare type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
|
package/state/state.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "../chunk-3O5KIRV4.js";
|
|
4
4
|
|
|
5
5
|
// src/state/state.ts
|
|
6
|
-
import { useQuery } from "react-query";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
7
|
var getVersion = (options, signal) => {
|
|
8
8
|
return customInstance(
|
|
9
9
|
{ url: `/version`, method: "get", signal },
|
package/state/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/state/state.ts"],"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:
|
|
1
|
+
{"version":3,"sources":["../../src/state/state.ts"],"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 } 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\";\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 query = useQuery<Awaited<ReturnType<typeof getVersion>>, 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"],"mappings":";;;;;AAUA,SAAS,gBAAgB;AAyBlB,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,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,WAAW;AAEjB,SAAO;AACT;","names":[]}
|
package/unit/unit.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkIUEU2LYCcjs = require('../chunk-IUEU2LYC.cjs');
|
|
4
4
|
|
|
5
5
|
// src/unit/unit.ts
|
|
6
|
-
var _reactquery = require('react-query');
|
|
6
|
+
var _reactquery = require('@tanstack/react-query');
|
|
7
7
|
var getOrganisationUnits = (orgId, options, signal) => {
|
|
8
8
|
return _chunkIUEU2LYCcjs.customInstance.call(void 0,
|
|
9
9
|
{ url: `/organisation/${orgId}/unit`, method: "get", signal },
|
|
@@ -96,16 +96,22 @@ var useGetUnits = (options) => {
|
|
|
96
96
|
query.queryKey = queryKey;
|
|
97
97
|
return query;
|
|
98
98
|
};
|
|
99
|
-
var createDefaultUnit = (options) => {
|
|
99
|
+
var createDefaultUnit = (personalUnitPutBodyBody, options) => {
|
|
100
100
|
return _chunkIUEU2LYCcjs.customInstance.call(void 0,
|
|
101
|
-
{
|
|
101
|
+
{
|
|
102
|
+
url: `/unit`,
|
|
103
|
+
method: "put",
|
|
104
|
+
headers: { "Content-Type": "application/json" },
|
|
105
|
+
data: personalUnitPutBodyBody
|
|
106
|
+
},
|
|
102
107
|
options
|
|
103
108
|
);
|
|
104
109
|
};
|
|
105
110
|
var useCreateDefaultUnit = (options) => {
|
|
106
111
|
const { mutation: mutationOptions, request: requestOptions } = _nullishCoalesce(options, () => ( {}));
|
|
107
|
-
const mutationFn = () => {
|
|
108
|
-
|
|
112
|
+
const mutationFn = (props) => {
|
|
113
|
+
const { data } = _nullishCoalesce(props, () => ( {}));
|
|
114
|
+
return createDefaultUnit(data, requestOptions);
|
|
109
115
|
};
|
|
110
116
|
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
111
117
|
};
|
|
@@ -119,6 +125,29 @@ var useDeleteDefaultUnit = (options) => {
|
|
|
119
125
|
};
|
|
120
126
|
return _reactquery.useMutation.call(void 0, mutationFn, mutationOptions);
|
|
121
127
|
};
|
|
128
|
+
var getUnitCharges = (unitId, params, options, signal) => {
|
|
129
|
+
return _chunkIUEU2LYCcjs.customInstance.call(void 0,
|
|
130
|
+
{ url: `/unit/${unitId}/charges`, method: "get", params, signal },
|
|
131
|
+
options
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
var getGetUnitChargesQueryKey = (unitId, params) => [`/unit/${unitId}/charges`, ...params ? [params] : []];
|
|
135
|
+
var useGetUnitCharges = (unitId, params, options) => {
|
|
136
|
+
const { query: queryOptions, request: requestOptions } = _nullishCoalesce(options, () => ( {}));
|
|
137
|
+
const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetUnitChargesQueryKey(unitId, params)));
|
|
138
|
+
const queryFn = ({
|
|
139
|
+
signal
|
|
140
|
+
}) => getUnitCharges(unitId, params, requestOptions, signal);
|
|
141
|
+
const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, {
|
|
142
|
+
enabled: !!unitId,
|
|
143
|
+
...queryOptions
|
|
144
|
+
});
|
|
145
|
+
query.queryKey = queryKey;
|
|
146
|
+
return query;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
122
151
|
|
|
123
152
|
|
|
124
153
|
|
|
@@ -137,5 +166,5 @@ var useDeleteDefaultUnit = (options) => {
|
|
|
137
166
|
|
|
138
167
|
|
|
139
168
|
|
|
140
|
-
exports.createDefaultUnit = createDefaultUnit; exports.createOrganisationUnit = createOrganisationUnit; exports.deleteDefaultUnit = deleteDefaultUnit; exports.deleteOrganisationUnit = deleteOrganisationUnit; exports.getGetOrganisationUnitsQueryKey = getGetOrganisationUnitsQueryKey; exports.getGetUnitQueryKey = getGetUnitQueryKey; exports.getGetUnitsQueryKey = getGetUnitsQueryKey; exports.getOrganisationUnits = getOrganisationUnits; exports.getUnit = getUnit; exports.getUnits = getUnits; exports.useCreateDefaultUnit = useCreateDefaultUnit; exports.useCreateOrganisationUnit = useCreateOrganisationUnit; exports.useDeleteDefaultUnit = useDeleteDefaultUnit; exports.useDeleteOrganisationUnit = useDeleteOrganisationUnit; exports.useGetOrganisationUnits = useGetOrganisationUnits; exports.useGetUnit = useGetUnit; exports.useGetUnits = useGetUnits;
|
|
169
|
+
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.useCreateDefaultUnit = useCreateDefaultUnit; exports.useCreateOrganisationUnit = useCreateOrganisationUnit; exports.useDeleteDefaultUnit = useDeleteDefaultUnit; exports.useDeleteOrganisationUnit = useDeleteOrganisationUnit; exports.useGetOrganisationUnits = useGetOrganisationUnits; exports.useGetUnit = useGetUnit; exports.useGetUnitCharges = useGetUnitCharges; exports.useGetUnits = useGetUnits;
|
|
141
170
|
//# sourceMappingURL=unit.cjs.map
|
package/unit/unit.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/unit/unit.ts"],"names":[],"mappings":"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","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: 1.0\n */\nimport { useQuery, useMutation } from \"react-query\";\nimport type {\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n OrganisationUnitsGetResponse,\n AsError,\n OrganisationUnitPostResponse,\n OrganisationUnitPostBodyBody,\n UnitGetResponse,\n UnitsGetResponse,\n PersonalUnitPutResponse,\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 options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<PersonalUnitPutResponse>(\n { url: `/unit`, method: \"put\" },\n options\n );\n};\n\nexport type CreateDefaultUnitMutationResult = NonNullable<\n Awaited<ReturnType<typeof createDefaultUnit>>\n>;\n\nexport type CreateDefaultUnitMutationError = ErrorType<AsError | void>;\n\nexport const useCreateDefaultUnit = <\n TError = ErrorType<AsError | void>,\n TVariables = void,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n Awaited<ReturnType<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 Awaited<ReturnType<typeof createDefaultUnit>>,\n TVariables\n > = () => {\n return createDefaultUnit(requestOptions);\n };\n\n return useMutation<\n Awaited<ReturnType<typeof createDefaultUnit>>,\n TError,\n TVariables,\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"]}
|
|
1
|
+
{"version":3,"sources":["../../src/unit/unit.ts"],"names":[],"mappings":"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","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"]}
|
package/unit/unit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
|
|
1
|
+
import { av as customInstance, ai as OrganisationUnitsGetResponse, aw as ErrorType, ar as AsError, O as OrganisationUnitPostBodyBody, ak as OrganisationUnitPostResponse, r as UnitDetail, $ as UnitsGetResponse, l as PersonalUnitPutBodyBody, aj as PersonalUnitPutResponse, G as GetUnitChargesParams, a6 as UnitChargesGetResponse } from '../custom-instance-379e9b57.js';
|
|
2
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
|
+
import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from '@tanstack/react-query';
|
|
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;
|
|
@@ -34,7 +34,7 @@ declare const useCreateOrganisationUnit: <TError = ErrorType<void | AsError>, TC
|
|
|
34
34
|
data: OrganisationUnitPostBodyBody;
|
|
35
35
|
}, TContext> | undefined;
|
|
36
36
|
request?: SecondParameter<typeof customInstance>;
|
|
37
|
-
} | undefined) =>
|
|
37
|
+
} | undefined) => _tanstack_react_query.UseMutationResult<OrganisationUnitPostResponse, TError, {
|
|
38
38
|
orgId: string;
|
|
39
39
|
data: OrganisationUnitPostBodyBody;
|
|
40
40
|
}, TContext>;
|
|
@@ -66,7 +66,7 @@ declare const useDeleteOrganisationUnit: <TError = ErrorType<AsError>, TContext
|
|
|
66
66
|
unitId: string;
|
|
67
67
|
}, TContext> | undefined;
|
|
68
68
|
request?: SecondParameter<typeof customInstance>;
|
|
69
|
-
} | undefined) =>
|
|
69
|
+
} | undefined) => _tanstack_react_query.UseMutationResult<void, TError, {
|
|
70
70
|
unitId: string;
|
|
71
71
|
}, TContext>;
|
|
72
72
|
/**
|
|
@@ -89,13 +89,18 @@ declare const useGetUnits: <TData = UnitsGetResponse, TError = ErrorType<void |
|
|
|
89
89
|
|
|
90
90
|
* @summary Create a new Personal Unit
|
|
91
91
|
*/
|
|
92
|
-
declare const createDefaultUnit: (options?: SecondParameter<typeof customInstance>) => Promise<PersonalUnitPutResponse>;
|
|
92
|
+
declare const createDefaultUnit: (personalUnitPutBodyBody: PersonalUnitPutBodyBody, options?: SecondParameter<typeof customInstance>) => Promise<PersonalUnitPutResponse>;
|
|
93
93
|
declare type CreateDefaultUnitMutationResult = NonNullable<Awaited<ReturnType<typeof createDefaultUnit>>>;
|
|
94
|
+
declare type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody;
|
|
94
95
|
declare type CreateDefaultUnitMutationError = ErrorType<AsError | void>;
|
|
95
|
-
declare const useCreateDefaultUnit: <TError = ErrorType<void | AsError>,
|
|
96
|
-
mutation?: UseMutationOptions<PersonalUnitPutResponse, TError,
|
|
96
|
+
declare const useCreateDefaultUnit: <TError = ErrorType<void | AsError>, TContext = unknown>(options?: {
|
|
97
|
+
mutation?: UseMutationOptions<PersonalUnitPutResponse, TError, {
|
|
98
|
+
data: PersonalUnitPutBodyBody;
|
|
99
|
+
}, TContext> | undefined;
|
|
97
100
|
request?: SecondParameter<typeof customInstance>;
|
|
98
|
-
} | undefined) =>
|
|
101
|
+
} | undefined) => _tanstack_react_query.UseMutationResult<PersonalUnitPutResponse, TError, {
|
|
102
|
+
data: PersonalUnitPutBodyBody;
|
|
103
|
+
}, TContext>;
|
|
99
104
|
/**
|
|
100
105
|
* Deletes a 'Personal' Unit. It must be your Unit, which belongs to the Default Organisation
|
|
101
106
|
|
|
@@ -107,6 +112,26 @@ declare type DeleteDefaultUnitMutationError = ErrorType<AsError>;
|
|
|
107
112
|
declare const useDeleteDefaultUnit: <TError = ErrorType<AsError>, TVariables = void, TContext = unknown>(options?: {
|
|
108
113
|
mutation?: UseMutationOptions<void, TError, TVariables, TContext> | undefined;
|
|
109
114
|
request?: SecondParameter<typeof customInstance>;
|
|
110
|
-
} | undefined) =>
|
|
115
|
+
} | undefined) => _tanstack_react_query.UseMutationResult<void, TError, TVariables, TContext>;
|
|
116
|
+
/**
|
|
117
|
+
* 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.
|
|
118
|
+
|
|
119
|
+
Dates are interpreted using the Python dateutil parser so the input strings are extremely flexible, i.e. `1 December 2021` is an acceptable format.
|
|
120
|
+
|
|
121
|
+
**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).
|
|
122
|
+
|
|
123
|
+
You need to be part of the **Unit** or **Organisation** to use this method
|
|
124
|
+
* @summary Get charges made against a Unit
|
|
125
|
+
*/
|
|
126
|
+
declare const getUnitCharges: (unitId: string, params?: GetUnitChargesParams, options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => Promise<UnitChargesGetResponse>;
|
|
127
|
+
declare const getGetUnitChargesQueryKey: (unitId: string, params?: GetUnitChargesParams) => (string | GetUnitChargesParams)[];
|
|
128
|
+
declare type GetUnitChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getUnitCharges>>>;
|
|
129
|
+
declare type GetUnitChargesQueryError = ErrorType<AsError | void>;
|
|
130
|
+
declare const useGetUnitCharges: <TData = UnitChargesGetResponse, TError = ErrorType<void | AsError>>(unitId: string, params?: GetUnitChargesParams, options?: {
|
|
131
|
+
query?: UseQueryOptions<UnitChargesGetResponse, TError, TData, QueryKey> | undefined;
|
|
132
|
+
request?: SecondParameter<typeof customInstance>;
|
|
133
|
+
} | undefined) => UseQueryResult<TData, TError> & {
|
|
134
|
+
queryKey: QueryKey;
|
|
135
|
+
};
|
|
111
136
|
|
|
112
|
-
export { CreateDefaultUnitMutationError, CreateDefaultUnitMutationResult, CreateOrganisationUnitMutationBody, CreateOrganisationUnitMutationError, CreateOrganisationUnitMutationResult, DeleteDefaultUnitMutationError, DeleteDefaultUnitMutationResult, DeleteOrganisationUnitMutationError, DeleteOrganisationUnitMutationResult, GetOrganisationUnitsQueryError, GetOrganisationUnitsQueryResult, GetUnitQueryError, GetUnitQueryResult, GetUnitsQueryError, GetUnitsQueryResult, createDefaultUnit, createOrganisationUnit, deleteDefaultUnit, deleteOrganisationUnit, getGetOrganisationUnitsQueryKey, getGetUnitQueryKey, getGetUnitsQueryKey, getOrganisationUnits, getUnit, getUnits, useCreateDefaultUnit, useCreateOrganisationUnit, useDeleteDefaultUnit, useDeleteOrganisationUnit, useGetOrganisationUnits, useGetUnit, useGetUnits };
|
|
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 };
|
package/unit/unit.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "../chunk-3O5KIRV4.js";
|
|
4
4
|
|
|
5
5
|
// src/unit/unit.ts
|
|
6
|
-
import { useQuery, useMutation } from "react-query";
|
|
6
|
+
import { useQuery, useMutation } from "@tanstack/react-query";
|
|
7
7
|
var getOrganisationUnits = (orgId, options, signal) => {
|
|
8
8
|
return customInstance(
|
|
9
9
|
{ url: `/organisation/${orgId}/unit`, method: "get", signal },
|
|
@@ -96,16 +96,22 @@ var useGetUnits = (options) => {
|
|
|
96
96
|
query.queryKey = queryKey;
|
|
97
97
|
return query;
|
|
98
98
|
};
|
|
99
|
-
var createDefaultUnit = (options) => {
|
|
99
|
+
var createDefaultUnit = (personalUnitPutBodyBody, options) => {
|
|
100
100
|
return customInstance(
|
|
101
|
-
{
|
|
101
|
+
{
|
|
102
|
+
url: `/unit`,
|
|
103
|
+
method: "put",
|
|
104
|
+
headers: { "Content-Type": "application/json" },
|
|
105
|
+
data: personalUnitPutBodyBody
|
|
106
|
+
},
|
|
102
107
|
options
|
|
103
108
|
);
|
|
104
109
|
};
|
|
105
110
|
var useCreateDefaultUnit = (options) => {
|
|
106
111
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
107
|
-
const mutationFn = () => {
|
|
108
|
-
|
|
112
|
+
const mutationFn = (props) => {
|
|
113
|
+
const { data } = props ?? {};
|
|
114
|
+
return createDefaultUnit(data, requestOptions);
|
|
109
115
|
};
|
|
110
116
|
return useMutation(mutationFn, mutationOptions);
|
|
111
117
|
};
|
|
@@ -119,16 +125,38 @@ var useDeleteDefaultUnit = (options) => {
|
|
|
119
125
|
};
|
|
120
126
|
return useMutation(mutationFn, mutationOptions);
|
|
121
127
|
};
|
|
128
|
+
var getUnitCharges = (unitId, params, options, signal) => {
|
|
129
|
+
return customInstance(
|
|
130
|
+
{ url: `/unit/${unitId}/charges`, method: "get", params, signal },
|
|
131
|
+
options
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
var getGetUnitChargesQueryKey = (unitId, params) => [`/unit/${unitId}/charges`, ...params ? [params] : []];
|
|
135
|
+
var useGetUnitCharges = (unitId, params, options) => {
|
|
136
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
137
|
+
const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetUnitChargesQueryKey(unitId, params);
|
|
138
|
+
const queryFn = ({
|
|
139
|
+
signal
|
|
140
|
+
}) => getUnitCharges(unitId, params, requestOptions, signal);
|
|
141
|
+
const query = useQuery(queryKey, queryFn, {
|
|
142
|
+
enabled: !!unitId,
|
|
143
|
+
...queryOptions
|
|
144
|
+
});
|
|
145
|
+
query.queryKey = queryKey;
|
|
146
|
+
return query;
|
|
147
|
+
};
|
|
122
148
|
export {
|
|
123
149
|
createDefaultUnit,
|
|
124
150
|
createOrganisationUnit,
|
|
125
151
|
deleteDefaultUnit,
|
|
126
152
|
deleteOrganisationUnit,
|
|
127
153
|
getGetOrganisationUnitsQueryKey,
|
|
154
|
+
getGetUnitChargesQueryKey,
|
|
128
155
|
getGetUnitQueryKey,
|
|
129
156
|
getGetUnitsQueryKey,
|
|
130
157
|
getOrganisationUnits,
|
|
131
158
|
getUnit,
|
|
159
|
+
getUnitCharges,
|
|
132
160
|
getUnits,
|
|
133
161
|
useCreateDefaultUnit,
|
|
134
162
|
useCreateOrganisationUnit,
|
|
@@ -136,6 +164,7 @@ export {
|
|
|
136
164
|
useDeleteOrganisationUnit,
|
|
137
165
|
useGetOrganisationUnits,
|
|
138
166
|
useGetUnit,
|
|
167
|
+
useGetUnitCharges,
|
|
139
168
|
useGetUnits
|
|
140
169
|
};
|
|
141
170
|
//# sourceMappingURL=unit.js.map
|