@squonk/account-server-client 0.1.27-rc.1 → 0.1.28-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/{chunk-GWBPVOL2.js → chunk-6EEIAH4R.js} +23 -2
  2. package/chunk-6EEIAH4R.js.map +1 -0
  3. package/chunk-NGBTCJWS.cjs +46 -0
  4. package/chunk-NGBTCJWS.cjs.map +1 -0
  5. package/{account-server-api.schemas-e6c5f956.d.ts → custom-instance-13412a15.d.ts} +19 -1
  6. package/index.cjs +5 -21
  7. package/index.cjs.map +1 -1
  8. package/index.d.ts +2 -20
  9. package/index.js +5 -21
  10. package/index.js.map +1 -1
  11. package/organisation/organisation.cjs +35 -30
  12. package/organisation/organisation.cjs.map +1 -1
  13. package/organisation/organisation.d.ts +33 -32
  14. package/organisation/organisation.js +42 -37
  15. package/organisation/organisation.js.map +1 -1
  16. package/package.json +1 -1
  17. package/product/product.cjs +65 -53
  18. package/product/product.cjs.map +1 -1
  19. package/product/product.d.ts +55 -54
  20. package/product/product.js +76 -64
  21. package/product/product.js.map +1 -1
  22. package/service/service.cjs +21 -23
  23. package/service/service.cjs.map +1 -1
  24. package/service/service.d.ts +18 -17
  25. package/service/service.js +23 -25
  26. package/service/service.js.map +1 -1
  27. package/src/organisation/organisation.ts +93 -69
  28. package/src/product/product.ts +165 -146
  29. package/src/service/service.ts +59 -57
  30. package/src/state/state.ts +34 -28
  31. package/src/unit/unit.ts +145 -130
  32. package/src/user/user.ts +148 -120
  33. package/state/state.cjs +12 -12
  34. package/state/state.cjs.map +1 -1
  35. package/state/state.d.ts +11 -10
  36. package/state/state.js +13 -13
  37. package/state/state.js.map +1 -1
  38. package/unit/unit.cjs +55 -50
  39. package/unit/unit.cjs.map +1 -1
  40. package/unit/unit.d.ts +54 -53
  41. package/unit/unit.js +66 -61
  42. package/unit/unit.js.map +1 -1
  43. package/user/user.cjs +50 -50
  44. package/user/user.cjs.map +1 -1
  45. package/user/user.d.ts +53 -52
  46. package/user/user.js +61 -61
  47. package/user/user.js.map +1 -1
  48. package/chunk-GWBPVOL2.js.map +0 -1
  49. package/chunk-N3RLW53G.cjs +0 -25
  50. package/chunk-N3RLW53G.cjs.map +0 -1
@@ -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 appApiServiceGet = (
38
- options?: AxiosRequestConfig
39
- ): Promise<AxiosResponse<ServicesGetResponse>> => {
40
- return axios.get(`/service`, options);
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 getAppApiServiceGetQueryKey = () => [`/service`];
54
+ export const getGetServicesQueryKey = () => [`/service`];
44
55
 
45
- export type AppApiServiceGetQueryResult = NonNullable<
46
- AsyncReturnType<typeof appApiServiceGet>
56
+ export type GetServicesQueryResult = NonNullable<
57
+ AsyncReturnType<typeof getServices>
47
58
  >;
48
- export type AppApiServiceGetQueryError = AxiosError<AsError | void>;
59
+ export type GetServicesQueryError = ErrorType<AsError | void>;
49
60
 
50
- export const useAppApiServiceGet = <
51
- TData = AsyncReturnType<typeof appApiServiceGet>,
52
- TError = AxiosError<AsError | void>
61
+ export const useGetServices = <
62
+ TData = AsyncReturnType<typeof getServices>,
63
+ TError = ErrorType<AsError | void>
53
64
  >(options?: {
54
- query?: UseQueryOptions<
55
- AsyncReturnType<typeof appApiServiceGet>,
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, axios: axiosOptions } = options || {};
68
+ const { query: queryOptions, request: requestOptions } = options || {};
62
69
 
63
- const queryKey = queryOptions?.queryKey ?? getAppApiServiceGetQueryKey();
70
+ const queryKey = queryOptions?.queryKey ?? getGetServicesQueryKey();
64
71
 
65
- const queryFn: QueryFunction<AsyncReturnType<typeof appApiServiceGet>> = () =>
66
- appApiServiceGet(axiosOptions);
72
+ const queryFn: QueryFunction<AsyncReturnType<typeof getServices>> = () =>
73
+ getServices(requestOptions);
67
74
 
68
- const query = useQuery<
69
- AsyncReturnType<typeof appApiServiceGet>,
70
- TError,
71
- TData
72
- >(queryKey, queryFn, queryOptions);
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 appApiServiceGetId = (
92
+ export const getService = (
86
93
  svcId: number,
87
- options?: AxiosRequestConfig
88
- ): Promise<AxiosResponse<ServiceGetResponse>> => {
89
- return axios.get(`/service/${svcId}`, options);
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 getAppApiServiceGetIdQueryKey = (svcId: number) => [
93
- `/service/${svcId}`,
94
- ];
102
+ export const getGetServiceQueryKey = (svcId: number) => [`/service/${svcId}`];
95
103
 
96
- export type AppApiServiceGetIdQueryResult = NonNullable<
97
- AsyncReturnType<typeof appApiServiceGetId>
104
+ export type GetServiceQueryResult = NonNullable<
105
+ AsyncReturnType<typeof getService>
98
106
  >;
99
- export type AppApiServiceGetIdQueryError = AxiosError<AsError | void>;
107
+ export type GetServiceQueryError = ErrorType<AsError | void>;
100
108
 
101
- export const useAppApiServiceGetId = <
102
- TData = AsyncReturnType<typeof appApiServiceGetId>,
103
- TError = AxiosError<AsError | void>
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
- AsyncReturnType<typeof appApiServiceGetId>,
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, axios: axiosOptions } = options || {};
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
- AsyncReturnType<typeof appApiServiceGetId>
122
- > = () => appApiServiceGetId(svcId, axiosOptions);
123
+ const queryFn: QueryFunction<AsyncReturnType<typeof getService>> = () =>
124
+ getService(svcId, requestOptions);
123
125
 
124
- const query = useQuery<
125
- AsyncReturnType<typeof appApiServiceGetId>,
126
- TError,
127
- TData
128
- >(queryKey, queryFn, { enabled: !!svcId, ...queryOptions });
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,
@@ -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 appApiStateGetVersion = (
35
- options?: AxiosRequestConfig
36
- ): Promise<AxiosResponse<StateGetVersionResponse>> => {
37
- return axios.get(`/version`, options);
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 getAppApiStateGetVersionQueryKey = () => [`/version`];
51
+ export const getGetVersionQueryKey = () => [`/version`];
41
52
 
42
- export type AppApiStateGetVersionQueryResult = NonNullable<
43
- AsyncReturnType<typeof appApiStateGetVersion>
53
+ export type GetVersionQueryResult = NonNullable<
54
+ AsyncReturnType<typeof getVersion>
44
55
  >;
45
- export type AppApiStateGetVersionQueryError = AxiosError<AsError | void>;
56
+ export type GetVersionQueryError = ErrorType<AsError | void>;
46
57
 
47
- export const useAppApiStateGetVersion = <
48
- TData = AsyncReturnType<typeof appApiStateGetVersion>,
49
- TError = AxiosError<AsError | void>
58
+ export const useGetVersion = <
59
+ TData = AsyncReturnType<typeof getVersion>,
60
+ TError = ErrorType<AsError | void>
50
61
  >(options?: {
51
- query?: UseQueryOptions<
52
- AsyncReturnType<typeof appApiStateGetVersion>,
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, axios: axiosOptions } = options || {};
65
+ const { query: queryOptions, request: requestOptions } = options || {};
59
66
 
60
- const queryKey = queryOptions?.queryKey ?? getAppApiStateGetVersionQueryKey();
67
+ const queryKey = queryOptions?.queryKey ?? getGetVersionQueryKey();
61
68
 
62
- const queryFn: QueryFunction<
63
- AsyncReturnType<typeof appApiStateGetVersion>
64
- > = () => appApiStateGetVersion(axiosOptions);
69
+ const queryFn: QueryFunction<AsyncReturnType<typeof getVersion>> = () =>
70
+ getVersion(requestOptions);
65
71
 
66
- const query = useQuery<
67
- AsyncReturnType<typeof appApiStateGetVersion>,
68
- TError,
69
- TData
70
- >(queryKey, queryFn, queryOptions);
72
+ const query = useQuery<AsyncReturnType<typeof getVersion>, TError, TData>(
73
+ queryKey,
74
+ queryFn,
75
+ queryOptions
76
+ );
71
77
 
72
78
  return {
73
79
  queryKey,