@squonk/account-server-client 0.1.27-rc.1 → 0.1.29-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{chunk-GWBPVOL2.js → chunk-6EEIAH4R.js} +23 -2
- package/chunk-6EEIAH4R.js.map +1 -0
- package/chunk-NGBTCJWS.cjs +46 -0
- package/chunk-NGBTCJWS.cjs.map +1 -0
- package/{account-server-api.schemas-e6c5f956.d.ts → custom-instance-13412a15.d.ts} +19 -1
- package/index.cjs +5 -21
- package/index.cjs.map +1 -1
- package/index.d.ts +2 -20
- package/index.js +5 -21
- package/index.js.map +1 -1
- package/organisation/organisation.cjs +35 -30
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +33 -32
- package/organisation/organisation.js +42 -37
- package/organisation/organisation.js.map +1 -1
- package/package.json +1 -1
- package/product/product.cjs +65 -53
- package/product/product.cjs.map +1 -1
- package/product/product.d.ts +55 -54
- package/product/product.js +76 -64
- package/product/product.js.map +1 -1
- package/service/service.cjs +21 -23
- package/service/service.cjs.map +1 -1
- package/service/service.d.ts +18 -17
- package/service/service.js +23 -25
- package/service/service.js.map +1 -1
- package/src/organisation/organisation.ts +93 -69
- package/src/product/product.ts +165 -146
- package/src/service/service.ts +59 -57
- package/src/state/state.ts +34 -28
- package/src/unit/unit.ts +145 -130
- package/src/user/user.ts +148 -120
- package/state/state.cjs +12 -12
- package/state/state.cjs.map +1 -1
- package/state/state.d.ts +11 -10
- package/state/state.js +13 -13
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +55 -50
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +54 -53
- package/unit/unit.js +66 -61
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +50 -50
- package/user/user.cjs.map +1 -1
- package/user/user.d.ts +53 -52
- package/user/user.js +61 -61
- package/user/user.js.map +1 -1
- package/chunk-GWBPVOL2.js.map +0 -1
- package/chunk-N3RLW53G.cjs +0 -25
- package/chunk-N3RLW53G.cjs.map +0 -1
package/src/service/service.ts
CHANGED
|
@@ -8,7 +8,6 @@ A service that provides access to the Account Server, which gives *registered* u
|
|
|
8
8
|
|
|
9
9
|
* OpenAPI spec version: 0.1
|
|
10
10
|
*/
|
|
11
|
-
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
|
|
12
11
|
import {
|
|
13
12
|
useQuery,
|
|
14
13
|
UseQueryOptions,
|
|
@@ -21,6 +20,7 @@ import type {
|
|
|
21
20
|
AsError,
|
|
22
21
|
ServiceGetResponse,
|
|
23
22
|
} from "../account-server-api.schemas";
|
|
23
|
+
import { customInstance, ErrorType } from ".././custom-instance";
|
|
24
24
|
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
26
|
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
|
|
@@ -29,47 +29,54 @@ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
|
|
|
29
29
|
? R
|
|
30
30
|
: any;
|
|
31
31
|
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
34
|
+
config: any,
|
|
35
|
+
args: infer P
|
|
36
|
+
) => any
|
|
37
|
+
? P
|
|
38
|
+
: never;
|
|
39
|
+
|
|
32
40
|
/**
|
|
33
41
|
* Gets services known to the Account Server
|
|
34
42
|
|
|
35
43
|
* @summary Gets all Services
|
|
36
44
|
*/
|
|
37
|
-
export const
|
|
38
|
-
options?:
|
|
39
|
-
)
|
|
40
|
-
return
|
|
45
|
+
export const getServices = (
|
|
46
|
+
options?: SecondParameter<typeof customInstance>
|
|
47
|
+
) => {
|
|
48
|
+
return customInstance<ServicesGetResponse>(
|
|
49
|
+
{ url: `/service`, method: "get" },
|
|
50
|
+
options
|
|
51
|
+
);
|
|
41
52
|
};
|
|
42
53
|
|
|
43
|
-
export const
|
|
54
|
+
export const getGetServicesQueryKey = () => [`/service`];
|
|
44
55
|
|
|
45
|
-
export type
|
|
46
|
-
AsyncReturnType<typeof
|
|
56
|
+
export type GetServicesQueryResult = NonNullable<
|
|
57
|
+
AsyncReturnType<typeof getServices>
|
|
47
58
|
>;
|
|
48
|
-
export type
|
|
59
|
+
export type GetServicesQueryError = ErrorType<AsError | void>;
|
|
49
60
|
|
|
50
|
-
export const
|
|
51
|
-
TData = AsyncReturnType<typeof
|
|
52
|
-
TError =
|
|
61
|
+
export const useGetServices = <
|
|
62
|
+
TData = AsyncReturnType<typeof getServices>,
|
|
63
|
+
TError = ErrorType<AsError | void>
|
|
53
64
|
>(options?: {
|
|
54
|
-
query?: UseQueryOptions<
|
|
55
|
-
|
|
56
|
-
TError,
|
|
57
|
-
TData
|
|
58
|
-
>;
|
|
59
|
-
axios?: AxiosRequestConfig;
|
|
65
|
+
query?: UseQueryOptions<AsyncReturnType<typeof getServices>, TError, TData>;
|
|
66
|
+
request?: SecondParameter<typeof customInstance>;
|
|
60
67
|
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
61
|
-
const { query: queryOptions,
|
|
68
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
62
69
|
|
|
63
|
-
const queryKey = queryOptions?.queryKey ??
|
|
70
|
+
const queryKey = queryOptions?.queryKey ?? getGetServicesQueryKey();
|
|
64
71
|
|
|
65
|
-
const queryFn: QueryFunction<AsyncReturnType<typeof
|
|
66
|
-
|
|
72
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof getServices>> = () =>
|
|
73
|
+
getServices(requestOptions);
|
|
67
74
|
|
|
68
|
-
const query = useQuery<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
const query = useQuery<AsyncReturnType<typeof getServices>, TError, TData>(
|
|
76
|
+
queryKey,
|
|
77
|
+
queryFn,
|
|
78
|
+
queryOptions
|
|
79
|
+
);
|
|
73
80
|
|
|
74
81
|
return {
|
|
75
82
|
queryKey,
|
|
@@ -82,50 +89,45 @@ export const useAppApiServiceGet = <
|
|
|
82
89
|
|
|
83
90
|
* @summary Gets a specific Service
|
|
84
91
|
*/
|
|
85
|
-
export const
|
|
92
|
+
export const getService = (
|
|
86
93
|
svcId: number,
|
|
87
|
-
options?:
|
|
88
|
-
)
|
|
89
|
-
return
|
|
94
|
+
options?: SecondParameter<typeof customInstance>
|
|
95
|
+
) => {
|
|
96
|
+
return customInstance<ServiceGetResponse>(
|
|
97
|
+
{ url: `/service/${svcId}`, method: "get" },
|
|
98
|
+
options
|
|
99
|
+
);
|
|
90
100
|
};
|
|
91
101
|
|
|
92
|
-
export const
|
|
93
|
-
`/service/${svcId}`,
|
|
94
|
-
];
|
|
102
|
+
export const getGetServiceQueryKey = (svcId: number) => [`/service/${svcId}`];
|
|
95
103
|
|
|
96
|
-
export type
|
|
97
|
-
AsyncReturnType<typeof
|
|
104
|
+
export type GetServiceQueryResult = NonNullable<
|
|
105
|
+
AsyncReturnType<typeof getService>
|
|
98
106
|
>;
|
|
99
|
-
export type
|
|
107
|
+
export type GetServiceQueryError = ErrorType<AsError | void>;
|
|
100
108
|
|
|
101
|
-
export const
|
|
102
|
-
TData = AsyncReturnType<typeof
|
|
103
|
-
TError =
|
|
109
|
+
export const useGetService = <
|
|
110
|
+
TData = AsyncReturnType<typeof getService>,
|
|
111
|
+
TError = ErrorType<AsError | void>
|
|
104
112
|
>(
|
|
105
113
|
svcId: number,
|
|
106
114
|
options?: {
|
|
107
|
-
query?: UseQueryOptions<
|
|
108
|
-
|
|
109
|
-
TError,
|
|
110
|
-
TData
|
|
111
|
-
>;
|
|
112
|
-
axios?: AxiosRequestConfig;
|
|
115
|
+
query?: UseQueryOptions<AsyncReturnType<typeof getService>, TError, TData>;
|
|
116
|
+
request?: SecondParameter<typeof customInstance>;
|
|
113
117
|
}
|
|
114
118
|
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
115
|
-
const { query: queryOptions,
|
|
119
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
116
120
|
|
|
117
|
-
const queryKey =
|
|
118
|
-
queryOptions?.queryKey ?? getAppApiServiceGetIdQueryKey(svcId);
|
|
121
|
+
const queryKey = queryOptions?.queryKey ?? getGetServiceQueryKey(svcId);
|
|
119
122
|
|
|
120
|
-
const queryFn: QueryFunction<
|
|
121
|
-
|
|
122
|
-
> = () => appApiServiceGetId(svcId, axiosOptions);
|
|
123
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof getService>> = () =>
|
|
124
|
+
getService(svcId, requestOptions);
|
|
123
125
|
|
|
124
|
-
const query = useQuery<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
const query = useQuery<AsyncReturnType<typeof getService>, TError, TData>(
|
|
127
|
+
queryKey,
|
|
128
|
+
queryFn,
|
|
129
|
+
{ enabled: !!svcId, ...queryOptions }
|
|
130
|
+
);
|
|
129
131
|
|
|
130
132
|
return {
|
|
131
133
|
queryKey,
|
package/src/state/state.ts
CHANGED
|
@@ -8,7 +8,6 @@ A service that provides access to the Account Server, which gives *registered* u
|
|
|
8
8
|
|
|
9
9
|
* OpenAPI spec version: 0.1
|
|
10
10
|
*/
|
|
11
|
-
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
|
|
12
11
|
import {
|
|
13
12
|
useQuery,
|
|
14
13
|
UseQueryOptions,
|
|
@@ -20,6 +19,7 @@ import type {
|
|
|
20
19
|
StateGetVersionResponse,
|
|
21
20
|
AsError,
|
|
22
21
|
} from "../account-server-api.schemas";
|
|
22
|
+
import { customInstance, ErrorType } from ".././custom-instance";
|
|
23
23
|
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
25
|
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
|
|
@@ -28,46 +28,52 @@ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
|
|
|
28
28
|
? R
|
|
29
29
|
: any;
|
|
30
30
|
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
33
|
+
config: any,
|
|
34
|
+
args: infer P
|
|
35
|
+
) => any
|
|
36
|
+
? P
|
|
37
|
+
: never;
|
|
38
|
+
|
|
31
39
|
/**
|
|
32
40
|
* @summary Gets the Account Server version
|
|
33
41
|
*/
|
|
34
|
-
export const
|
|
35
|
-
options?:
|
|
36
|
-
)
|
|
37
|
-
return
|
|
42
|
+
export const getVersion = (
|
|
43
|
+
options?: SecondParameter<typeof customInstance>
|
|
44
|
+
) => {
|
|
45
|
+
return customInstance<StateGetVersionResponse>(
|
|
46
|
+
{ url: `/version`, method: "get" },
|
|
47
|
+
options
|
|
48
|
+
);
|
|
38
49
|
};
|
|
39
50
|
|
|
40
|
-
export const
|
|
51
|
+
export const getGetVersionQueryKey = () => [`/version`];
|
|
41
52
|
|
|
42
|
-
export type
|
|
43
|
-
AsyncReturnType<typeof
|
|
53
|
+
export type GetVersionQueryResult = NonNullable<
|
|
54
|
+
AsyncReturnType<typeof getVersion>
|
|
44
55
|
>;
|
|
45
|
-
export type
|
|
56
|
+
export type GetVersionQueryError = ErrorType<AsError | void>;
|
|
46
57
|
|
|
47
|
-
export const
|
|
48
|
-
TData = AsyncReturnType<typeof
|
|
49
|
-
TError =
|
|
58
|
+
export const useGetVersion = <
|
|
59
|
+
TData = AsyncReturnType<typeof getVersion>,
|
|
60
|
+
TError = ErrorType<AsError | void>
|
|
50
61
|
>(options?: {
|
|
51
|
-
query?: UseQueryOptions<
|
|
52
|
-
|
|
53
|
-
TError,
|
|
54
|
-
TData
|
|
55
|
-
>;
|
|
56
|
-
axios?: AxiosRequestConfig;
|
|
62
|
+
query?: UseQueryOptions<AsyncReturnType<typeof getVersion>, TError, TData>;
|
|
63
|
+
request?: SecondParameter<typeof customInstance>;
|
|
57
64
|
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
58
|
-
const { query: queryOptions,
|
|
65
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
59
66
|
|
|
60
|
-
const queryKey = queryOptions?.queryKey ??
|
|
67
|
+
const queryKey = queryOptions?.queryKey ?? getGetVersionQueryKey();
|
|
61
68
|
|
|
62
|
-
const queryFn: QueryFunction<
|
|
63
|
-
|
|
64
|
-
> = () => appApiStateGetVersion(axiosOptions);
|
|
69
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof getVersion>> = () =>
|
|
70
|
+
getVersion(requestOptions);
|
|
65
71
|
|
|
66
|
-
const query = useQuery<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
const query = useQuery<AsyncReturnType<typeof getVersion>, TError, TData>(
|
|
73
|
+
queryKey,
|
|
74
|
+
queryFn,
|
|
75
|
+
queryOptions
|
|
76
|
+
);
|
|
71
77
|
|
|
72
78
|
return {
|
|
73
79
|
queryKey,
|