@squonk/account-server-client 2.1.0-rc.1 → 2.1.0-rc.10
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/admin/admin.cjs +30 -8
- package/admin/admin.cjs.map +1 -1
- package/admin/admin.d.cts +50 -0
- package/admin/admin.d.ts +26 -6
- package/admin/admin.js +30 -8
- package/admin/admin.js.map +1 -1
- package/asset/asset.cjs +62 -22
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.cts +260 -0
- package/asset/asset.d.ts +79 -36
- package/asset/asset.js +54 -14
- package/asset/asset.js.map +1 -1
- package/{chunk-3RNIDX7T.js → chunk-EBOQPVLG.js} +2 -2
- package/{chunk-3RNIDX7T.js.map → chunk-EBOQPVLG.js.map} +1 -1
- package/{chunk-UZTHSGDT.cjs → chunk-TKLTUR4R.cjs} +2 -2
- package/chunk-TKLTUR4R.cjs.map +1 -0
- package/event-stream/event-stream.cjs +64 -19
- package/event-stream/event-stream.cjs.map +1 -1
- package/event-stream/event-stream.d.cts +142 -0
- package/event-stream/event-stream.d.ts +66 -20
- package/event-stream/event-stream.js +61 -16
- package/event-stream/event-stream.js.map +1 -1
- package/index.cjs +10 -10
- package/index.cjs.map +1 -1
- package/{custom-instance-35e5d4fd.d.ts → index.d.cts} +163 -163
- package/index.d.ts +700 -2
- package/index.js +9 -9
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +53 -14
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.cts +91 -0
- package/merchant/merchant.d.ts +48 -8
- package/merchant/merchant.js +52 -13
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +110 -28
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.cts +271 -0
- package/organisation/organisation.d.ts +114 -25
- package/organisation/organisation.js +103 -21
- package/organisation/organisation.js.map +1 -1
- package/package.json +12 -12
- package/product/product.cjs +182 -47
- package/product/product.cjs.map +1 -1
- package/product/product.d.cts +399 -0
- package/product/product.d.ts +180 -31
- package/product/product.js +172 -37
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +272 -280
- package/src/admin/admin.ts +114 -84
- package/src/asset/asset.ts +480 -565
- package/src/custom-instance.ts +3 -4
- package/src/event-stream/event-stream.ts +300 -275
- package/src/merchant/merchant.ts +206 -142
- package/src/organisation/organisation.ts +549 -490
- package/src/product/product.ts +829 -688
- package/src/state/state.ts +112 -75
- package/src/unit/unit.ts +645 -599
- package/src/user/user.ts +489 -469
- package/state/state.cjs +29 -8
- package/state/state.cjs.map +1 -1
- package/state/state.d.cts +46 -0
- package/state/state.d.ts +26 -6
- package/state/state.js +29 -8
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +120 -32
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.cts +322 -0
- package/unit/unit.d.ts +133 -38
- package/unit/unit.js +112 -24
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +96 -22
- package/user/user.cjs.map +1 -1
- package/user/user.d.cts +271 -0
- package/user/user.d.ts +96 -24
- package/user/user.js +90 -16
- package/user/user.js.map +1 -1
- package/chunk-UZTHSGDT.cjs.map +0 -1
package/src/custom-instance.ts
CHANGED
|
@@ -39,10 +39,9 @@ export const customInstance = <TReturn>(
|
|
|
39
39
|
({ data }) => data,
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
source.cancel('Query was cancelled by React Query');
|
|
42
|
+
// @ts-expect-error need to add a cancel method to the promise
|
|
43
|
+
promise.cancel = () => {
|
|
44
|
+
source.cancel('Query was cancelled');
|
|
46
45
|
};
|
|
47
46
|
|
|
48
47
|
return promise;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
2
|
+
* Generated by orval v6.25.0 🍺
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Account Server API
|
|
5
5
|
* The Informatics Matters Account Server API.
|
|
@@ -8,29 +8,31 @@ A service that provides access to the Account Server, which gives *registered* u
|
|
|
8
8
|
|
|
9
9
|
* OpenAPI spec version: 2.1
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useMutation,
|
|
13
|
+
useQuery,
|
|
14
|
+
useSuspenseQuery
|
|
15
|
+
} from '@tanstack/react-query'
|
|
12
16
|
import type {
|
|
13
|
-
UseQueryOptions,
|
|
14
|
-
UseMutationOptions,
|
|
15
|
-
QueryFunction,
|
|
16
17
|
MutationFunction,
|
|
17
|
-
|
|
18
|
+
QueryFunction,
|
|
18
19
|
QueryKey,
|
|
19
|
-
|
|
20
|
+
UseMutationOptions,
|
|
21
|
+
UseQueryOptions,
|
|
22
|
+
UseQueryResult,
|
|
23
|
+
UseSuspenseQueryOptions,
|
|
24
|
+
UseSuspenseQueryResult
|
|
25
|
+
} from '@tanstack/react-query'
|
|
20
26
|
import type {
|
|
21
|
-
EventStreamGetPostResponse,
|
|
22
27
|
AsError,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
) => any
|
|
32
|
-
? P
|
|
33
|
-
: never;
|
|
28
|
+
EventStreamGetPostResponse
|
|
29
|
+
} from '../account-server-api.schemas'
|
|
30
|
+
import { customInstance } from '.././custom-instance';
|
|
31
|
+
import type { ErrorType } from '.././custom-instance';
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
type SecondParameter<T extends (...args: any) => any> = Parameters<T>[1];
|
|
35
|
+
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Gets your EventStream ID and read token, if you have created one.
|
|
@@ -38,69 +40,102 @@ type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
|
38
40
|
* @summary Gets the details of your EventStream
|
|
39
41
|
*/
|
|
40
42
|
export const getEventStream = (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
|
|
44
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
45
|
+
) => {
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
return customInstance<EventStreamGetPostResponse>(
|
|
49
|
+
{url: `/event-stream`, method: 'GET', signal
|
|
50
|
+
},
|
|
51
|
+
options);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
export const getGetEventStreamQueryKey = () => {
|
|
56
|
+
return ["account-server-api", `/event-stream`] as const;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export const getGetEventStreamQueryOptions = <TData = Awaited<ReturnType<typeof getEventStream>>, TError = ErrorType<void | AsError>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getEventStream>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
61
|
+
) => {
|
|
62
|
+
|
|
63
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
64
|
+
|
|
65
|
+
const queryKey = queryOptions?.queryKey ?? getGetEventStreamQueryKey();
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getEventStream>>> = ({ signal }) => getEventStream(requestOptions, signal);
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getEventStream>>, TError, TData> & { queryKey: QueryKey }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type GetEventStreamQueryResult = NonNullable<Awaited<ReturnType<typeof getEventStream>>>
|
|
79
|
+
export type GetEventStreamQueryError = ErrorType<void | AsError>
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @summary Gets the details of your EventStream
|
|
83
|
+
*/
|
|
84
|
+
export const useGetEventStream = <TData = Awaited<ReturnType<typeof getEventStream>>, TError = ErrorType<void | AsError>>(
|
|
85
|
+
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getEventStream>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
86
|
+
|
|
87
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
88
|
+
|
|
89
|
+
const queryOptions = getGetEventStreamQueryOptions(options)
|
|
90
|
+
|
|
91
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
92
|
+
|
|
93
|
+
query.queryKey = queryOptions.queryKey ;
|
|
94
|
+
|
|
95
|
+
return query;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
export const getGetEventStreamSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getEventStream>>, TError = ErrorType<void | AsError>>( options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getEventStream>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
43
101
|
) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export type GetEventStreamQueryResult = NonNullable<
|
|
79
|
-
Awaited<ReturnType<typeof getEventStream>>
|
|
80
|
-
>;
|
|
81
|
-
export type GetEventStreamQueryError = ErrorType<void | AsError>;
|
|
82
|
-
|
|
83
|
-
export const useGetEventStream = <
|
|
84
|
-
TData = Awaited<ReturnType<typeof getEventStream>>,
|
|
85
|
-
TError = ErrorType<void | AsError>
|
|
86
|
-
>(options?: {
|
|
87
|
-
query?: UseQueryOptions<
|
|
88
|
-
Awaited<ReturnType<typeof getEventStream>>,
|
|
89
|
-
TError,
|
|
90
|
-
TData
|
|
91
|
-
>;
|
|
92
|
-
request?: SecondParameter<typeof customInstance>;
|
|
93
|
-
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
94
|
-
const queryOptions = getGetEventStreamQueryOptions(options);
|
|
95
|
-
|
|
96
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
97
|
-
queryKey: QueryKey;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
query.queryKey = queryOptions.queryKey;
|
|
102
|
+
|
|
103
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
104
|
+
|
|
105
|
+
const queryKey = queryOptions?.queryKey ?? getGetEventStreamQueryKey();
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getEventStream>>> = ({ signal }) => getEventStream(requestOptions, signal);
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
return { queryKey, queryFn, ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getEventStream>>, TError, TData> & { queryKey: QueryKey }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type GetEventStreamSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getEventStream>>>
|
|
119
|
+
export type GetEventStreamSuspenseQueryError = ErrorType<void | AsError>
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @summary Gets the details of your EventStream
|
|
123
|
+
*/
|
|
124
|
+
export const useGetEventStreamSuspense = <TData = Awaited<ReturnType<typeof getEventStream>>, TError = ErrorType<void | AsError>>(
|
|
125
|
+
options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getEventStream>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
126
|
+
|
|
127
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
128
|
+
|
|
129
|
+
const queryOptions = getGetEventStreamSuspenseQueryOptions(options)
|
|
130
|
+
|
|
131
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
132
|
+
|
|
133
|
+
query.queryKey = queryOptions.queryKey ;
|
|
101
134
|
|
|
102
135
|
return query;
|
|
103
|
-
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
104
139
|
|
|
105
140
|
/**
|
|
106
141
|
* Creates a new event stream (based on the **Server Sent Events** framework) for the authenticated user.
|
|
@@ -110,151 +145,156 @@ A user is only permitted one event stream.
|
|
|
110
145
|
* @summary Create a new Server-Sent Events EventStream
|
|
111
146
|
*/
|
|
112
147
|
export const createEventStream = (
|
|
113
|
-
|
|
148
|
+
|
|
149
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
return customInstance<EventStreamGetPostResponse>(
|
|
153
|
+
{url: `/event-stream`, method: 'POST'
|
|
154
|
+
},
|
|
155
|
+
options);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
export const getCreateEventStreamMutationOptions = <TError = ErrorType<AsError | void>,
|
|
161
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createEventStream>>, TError,void, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
162
|
+
): UseMutationOptions<Awaited<ReturnType<typeof createEventStream>>, TError,void, TContext> => {
|
|
163
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof createEventStream>>, void> = () => {
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
return createEventStream(requestOptions)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
return { mutationFn, ...mutationOptions }}
|
|
178
|
+
|
|
179
|
+
export type CreateEventStreamMutationResult = NonNullable<Awaited<ReturnType<typeof createEventStream>>>
|
|
180
|
+
|
|
181
|
+
export type CreateEventStreamMutationError = ErrorType<AsError | void>
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @summary Create a new Server-Sent Events EventStream
|
|
185
|
+
*/
|
|
186
|
+
export const useCreateEventStream = <TError = ErrorType<AsError | void>,
|
|
187
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createEventStream>>, TError,void, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
114
188
|
) => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export const getCreateEventStreamMutationOptions = <
|
|
122
|
-
TError = ErrorType<AsError | void>,
|
|
123
|
-
TVariables = void,
|
|
124
|
-
TContext = unknown
|
|
125
|
-
>(options?: {
|
|
126
|
-
mutation?: UseMutationOptions<
|
|
127
|
-
Awaited<ReturnType<typeof createEventStream>>,
|
|
128
|
-
TError,
|
|
129
|
-
TVariables,
|
|
130
|
-
TContext
|
|
131
|
-
>;
|
|
132
|
-
request?: SecondParameter<typeof customInstance>;
|
|
133
|
-
}): UseMutationOptions<
|
|
134
|
-
Awaited<ReturnType<typeof createEventStream>>,
|
|
135
|
-
TError,
|
|
136
|
-
TVariables,
|
|
137
|
-
TContext
|
|
138
|
-
> => {
|
|
139
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
140
|
-
|
|
141
|
-
const mutationFn: MutationFunction<
|
|
142
|
-
Awaited<ReturnType<typeof createEventStream>>,
|
|
143
|
-
TVariables
|
|
144
|
-
> = () => {
|
|
145
|
-
return createEventStream(requestOptions);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
return { mutationFn, ...mutationOptions };
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export type CreateEventStreamMutationResult = NonNullable<
|
|
152
|
-
Awaited<ReturnType<typeof createEventStream>>
|
|
153
|
-
>;
|
|
154
|
-
|
|
155
|
-
export type CreateEventStreamMutationError = ErrorType<AsError | void>;
|
|
156
|
-
|
|
157
|
-
export const useCreateEventStream = <
|
|
158
|
-
TError = ErrorType<AsError | void>,
|
|
159
|
-
TVariables = void,
|
|
160
|
-
TContext = unknown
|
|
161
|
-
>(options?: {
|
|
162
|
-
mutation?: UseMutationOptions<
|
|
163
|
-
Awaited<ReturnType<typeof createEventStream>>,
|
|
164
|
-
TError,
|
|
165
|
-
TVariables,
|
|
166
|
-
TContext
|
|
167
|
-
>;
|
|
168
|
-
request?: SecondParameter<typeof customInstance>;
|
|
169
|
-
}) => {
|
|
170
|
-
const mutationOptions = getCreateEventStreamMutationOptions(options);
|
|
171
|
-
|
|
172
|
-
return useMutation(mutationOptions);
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
189
|
+
|
|
190
|
+
const mutationOptions = getCreateEventStreamMutationOptions(options);
|
|
191
|
+
|
|
192
|
+
return useMutation(mutationOptions);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
175
195
|
* Gets events that you are entitled to receive. Events are delivered as **Server Sent Events** and you are expected to continuously read form this endpoint or it will be closed.
|
|
176
196
|
|
|
177
|
-
This is an un-authenticated endpoint. In order to read from the stream the caller must provide the **read token**
|
|
197
|
+
This is an un-authenticated endpoint. In order to read from the stream the caller must provide either the User access token that belongs to the event stream or the **read token** that was allocated when the stream was created. The **read token** must be provided in the request header property `X-IM-AS-EventStreamReadToken`.
|
|
178
198
|
|
|
179
199
|
* @summary Subscribe to Server-Sent Events events from an EventStream
|
|
180
200
|
*/
|
|
181
201
|
export const getEventStreamEvents = (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
signal?: AbortSignal
|
|
202
|
+
eventStreamId: number,
|
|
203
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
185
204
|
) => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
export const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
return customInstance<string>(
|
|
208
|
+
{url: `/event-stream/${eventStreamId}`, method: 'GET', signal
|
|
209
|
+
},
|
|
210
|
+
options);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
export const getGetEventStreamEventsQueryKey = (eventStreamId: number,) => {
|
|
215
|
+
return ["account-server-api", `/event-stream/${eventStreamId}`] as const;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
export const getGetEventStreamEventsQueryOptions = <TData = Awaited<ReturnType<typeof getEventStreamEvents>>, TError = ErrorType<void | AsError>>(eventStreamId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getEventStreamEvents>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
220
|
+
) => {
|
|
221
|
+
|
|
222
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
223
|
+
|
|
224
|
+
const queryKey = queryOptions?.queryKey ?? getGetEventStreamEventsQueryKey(eventStreamId);
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getEventStreamEvents>>> = ({ signal }) => getEventStreamEvents(eventStreamId, requestOptions, signal);
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
return { queryKey, queryFn, enabled: !!(eventStreamId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getEventStreamEvents>>, TError, TData> & { queryKey: QueryKey }
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export type GetEventStreamEventsQueryResult = NonNullable<Awaited<ReturnType<typeof getEventStreamEvents>>>
|
|
238
|
+
export type GetEventStreamEventsQueryError = ErrorType<void | AsError>
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @summary Subscribe to Server-Sent Events events from an EventStream
|
|
242
|
+
*/
|
|
243
|
+
export const useGetEventStreamEvents = <TData = Awaited<ReturnType<typeof getEventStreamEvents>>, TError = ErrorType<void | AsError>>(
|
|
244
|
+
eventStreamId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getEventStreamEvents>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
245
|
+
|
|
246
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
247
|
+
|
|
248
|
+
const queryOptions = getGetEventStreamEventsQueryOptions(eventStreamId,options)
|
|
249
|
+
|
|
250
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
251
|
+
|
|
252
|
+
query.queryKey = queryOptions.queryKey ;
|
|
253
|
+
|
|
254
|
+
return query;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
export const getGetEventStreamEventsSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getEventStreamEvents>>, TError = ErrorType<void | AsError>>(eventStreamId: number, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getEventStreamEvents>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
260
|
+
) => {
|
|
261
|
+
|
|
262
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
263
|
+
|
|
264
|
+
const queryKey = queryOptions?.queryKey ?? getGetEventStreamEventsQueryKey(eventStreamId);
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getEventStreamEvents>>> = ({ signal }) => getEventStreamEvents(eventStreamId, requestOptions, signal);
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
return { queryKey, queryFn, enabled: !!(eventStreamId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getEventStreamEvents>>, TError, TData> & { queryKey: QueryKey }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export type GetEventStreamEventsSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getEventStreamEvents>>>
|
|
278
|
+
export type GetEventStreamEventsSuspenseQueryError = ErrorType<void | AsError>
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @summary Subscribe to Server-Sent Events events from an EventStream
|
|
282
|
+
*/
|
|
283
|
+
export const useGetEventStreamEventsSuspense = <TData = Awaited<ReturnType<typeof getEventStreamEvents>>, TError = ErrorType<void | AsError>>(
|
|
284
|
+
eventStreamId: number, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getEventStreamEvents>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
285
|
+
|
|
286
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
287
|
+
|
|
288
|
+
const queryOptions = getGetEventStreamEventsSuspenseQueryOptions(eventStreamId,options)
|
|
289
|
+
|
|
290
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
291
|
+
|
|
292
|
+
query.queryKey = queryOptions.queryKey ;
|
|
255
293
|
|
|
256
294
|
return query;
|
|
257
|
-
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
|
|
258
298
|
|
|
259
299
|
/**
|
|
260
300
|
* Deletes an Event Stream.
|
|
@@ -264,65 +304,50 @@ You must be the user who created the event stream.
|
|
|
264
304
|
* @summary Deletes an existing EventStream (that you created)
|
|
265
305
|
*/
|
|
266
306
|
export const deleteEventStream = (
|
|
267
|
-
|
|
268
|
-
|
|
307
|
+
eventStreamId: number,
|
|
308
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
return customInstance<void>(
|
|
312
|
+
{url: `/event-stream/${eventStreamId}`, method: 'DELETE'
|
|
313
|
+
},
|
|
314
|
+
options);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
export const getDeleteEventStreamMutationOptions = <TError = ErrorType<AsError>,
|
|
320
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteEventStream>>, TError,{eventStreamId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
321
|
+
): UseMutationOptions<Awaited<ReturnType<typeof deleteEventStream>>, TError,{eventStreamId: number}, TContext> => {
|
|
322
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteEventStream>>, {eventStreamId: number}> = (props) => {
|
|
328
|
+
const {eventStreamId} = props ?? {};
|
|
329
|
+
|
|
330
|
+
return deleteEventStream(eventStreamId,requestOptions)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
return { mutationFn, ...mutationOptions }}
|
|
337
|
+
|
|
338
|
+
export type DeleteEventStreamMutationResult = NonNullable<Awaited<ReturnType<typeof deleteEventStream>>>
|
|
339
|
+
|
|
340
|
+
export type DeleteEventStreamMutationError = ErrorType<AsError>
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @summary Deletes an existing EventStream (that you created)
|
|
344
|
+
*/
|
|
345
|
+
export const useDeleteEventStream = <TError = ErrorType<AsError>,
|
|
346
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteEventStream>>, TError,{eventStreamId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
269
347
|
) => {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export const getDeleteEventStreamMutationOptions = <
|
|
277
|
-
TError = ErrorType<AsError>,
|
|
278
|
-
TContext = unknown
|
|
279
|
-
>(options?: {
|
|
280
|
-
mutation?: UseMutationOptions<
|
|
281
|
-
Awaited<ReturnType<typeof deleteEventStream>>,
|
|
282
|
-
TError,
|
|
283
|
-
{ eventStreamId: number },
|
|
284
|
-
TContext
|
|
285
|
-
>;
|
|
286
|
-
request?: SecondParameter<typeof customInstance>;
|
|
287
|
-
}): UseMutationOptions<
|
|
288
|
-
Awaited<ReturnType<typeof deleteEventStream>>,
|
|
289
|
-
TError,
|
|
290
|
-
{ eventStreamId: number },
|
|
291
|
-
TContext
|
|
292
|
-
> => {
|
|
293
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
294
|
-
|
|
295
|
-
const mutationFn: MutationFunction<
|
|
296
|
-
Awaited<ReturnType<typeof deleteEventStream>>,
|
|
297
|
-
{ eventStreamId: number }
|
|
298
|
-
> = (props) => {
|
|
299
|
-
const { eventStreamId } = props ?? {};
|
|
300
|
-
|
|
301
|
-
return deleteEventStream(eventStreamId, requestOptions);
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
return { mutationFn, ...mutationOptions };
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
export type DeleteEventStreamMutationResult = NonNullable<
|
|
308
|
-
Awaited<ReturnType<typeof deleteEventStream>>
|
|
309
|
-
>;
|
|
310
|
-
|
|
311
|
-
export type DeleteEventStreamMutationError = ErrorType<AsError>;
|
|
312
|
-
|
|
313
|
-
export const useDeleteEventStream = <
|
|
314
|
-
TError = ErrorType<AsError>,
|
|
315
|
-
TContext = unknown
|
|
316
|
-
>(options?: {
|
|
317
|
-
mutation?: UseMutationOptions<
|
|
318
|
-
Awaited<ReturnType<typeof deleteEventStream>>,
|
|
319
|
-
TError,
|
|
320
|
-
{ eventStreamId: number },
|
|
321
|
-
TContext
|
|
322
|
-
>;
|
|
323
|
-
request?: SecondParameter<typeof customInstance>;
|
|
324
|
-
}) => {
|
|
325
|
-
const mutationOptions = getDeleteEventStreamMutationOptions(options);
|
|
326
|
-
|
|
327
|
-
return useMutation(mutationOptions);
|
|
328
|
-
};
|
|
348
|
+
|
|
349
|
+
const mutationOptions = getDeleteEventStreamMutationOptions(options);
|
|
350
|
+
|
|
351
|
+
return useMutation(mutationOptions);
|
|
352
|
+
}
|
|
353
|
+
|