@turtleclub/hooks 0.5.0-beta.94 → 0.5.0-beta.96
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/dist/index.cjs +59 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -19
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/v2/streams/api.ts +22 -0
- package/src/v2/streams/hooks.ts +17 -2
- package/src/v2/streams/index.ts +3 -0
- package/src/v2/streams/mutations.ts +20 -0
- package/src/v2/streams/queries.ts +1 -18
- package/src/v2/streams/schemas.ts +21 -7
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turtleclub/hooks",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.0-beta.
|
|
4
|
+
"version": "0.5.0-beta.96",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "692a517d98fafdf8193eb54c8bbf91988c84dd46"
|
|
58
58
|
}
|
package/src/v2/streams/api.ts
CHANGED
|
@@ -23,6 +23,9 @@ import {
|
|
|
23
23
|
PauseStreamSnapshotComputationBody,
|
|
24
24
|
PauseStreamSnapshotComputationOutput,
|
|
25
25
|
pauseStreamSnapshotComputationOutputSchema,
|
|
26
|
+
StopStreamBody,
|
|
27
|
+
StopStreamOutput,
|
|
28
|
+
stopStreamOutputSchema,
|
|
26
29
|
DeleteStreamOutput,
|
|
27
30
|
deleteStreamOutputSchema,
|
|
28
31
|
} from "./schemas";
|
|
@@ -183,6 +186,25 @@ export async function pauseStreamSnapshotComputation(
|
|
|
183
186
|
return result.data;
|
|
184
187
|
}
|
|
185
188
|
|
|
189
|
+
export async function stopStream(
|
|
190
|
+
organizationId: string,
|
|
191
|
+
body: StopStreamBody
|
|
192
|
+
): Promise<StopStreamOutput> {
|
|
193
|
+
const endpoint = `/streams/${organizationId}`;
|
|
194
|
+
const data = await apiClient.fetch(endpoint, {
|
|
195
|
+
method: "PATCH",
|
|
196
|
+
body,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const result = stopStreamOutputSchema.safeParse(data);
|
|
200
|
+
|
|
201
|
+
if (!result.success) {
|
|
202
|
+
throw new Error(`Failed to parse stop stream response: ${result.error.message}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return result.data;
|
|
206
|
+
}
|
|
207
|
+
|
|
186
208
|
export async function deleteStream(organizationId: string, streamId: string): Promise<DeleteStreamOutput> {
|
|
187
209
|
const endpoint = `/streams/${organizationId}/${streamId}`;
|
|
188
210
|
const data = await apiClient.fetch(endpoint, {
|
package/src/v2/streams/hooks.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { useMutation, useQuery, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
2
2
|
import { createQueryOptions } from "../lib/query-config";
|
|
3
|
-
import { streamsMutations
|
|
3
|
+
import { streamsMutations } from "./mutations";
|
|
4
|
+
import { streamsQueries } from "./queries";
|
|
4
5
|
import {
|
|
5
6
|
DeleteStreamOutput,
|
|
6
7
|
DeleteStreamInput,
|
|
7
8
|
GetStreamsQuery,
|
|
8
9
|
PauseStreamSnapshotComputationInput,
|
|
9
10
|
PauseStreamSnapshotComputationOutput,
|
|
11
|
+
StopStreamInput,
|
|
12
|
+
StopStreamOutput,
|
|
10
13
|
Stream,
|
|
11
14
|
StreamsSupportedChainsResponse,
|
|
12
15
|
StreamWallet,
|
|
@@ -50,6 +53,11 @@ export type UsePauseStreamSnapshotComputationOptions = Omit<
|
|
|
50
53
|
"mutationFn"
|
|
51
54
|
>;
|
|
52
55
|
|
|
56
|
+
export type UseStopStreamOptions = Omit<
|
|
57
|
+
UseMutationOptions<StopStreamOutput, Error, StopStreamInput>,
|
|
58
|
+
"mutationFn"
|
|
59
|
+
>;
|
|
60
|
+
|
|
53
61
|
export type UseDeleteStreamOptions = Omit<
|
|
54
62
|
UseMutationOptions<DeleteStreamOutput, Error, DeleteStreamInput>,
|
|
55
63
|
"mutationFn"
|
|
@@ -114,9 +122,16 @@ export function usePauseStreamSnapshotComputation(
|
|
|
114
122
|
});
|
|
115
123
|
}
|
|
116
124
|
|
|
125
|
+
export function useStopStream(options?: UseStopStreamOptions) {
|
|
126
|
+
return useMutation({
|
|
127
|
+
mutationFn: streamsMutations.stop,
|
|
128
|
+
...options,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
117
132
|
export function useDeleteStream(options?: UseDeleteStreamOptions) {
|
|
118
133
|
return useMutation({
|
|
119
|
-
mutationFn: streamsMutations.
|
|
134
|
+
mutationFn: streamsMutations.deleteStream,
|
|
120
135
|
...options,
|
|
121
136
|
});
|
|
122
137
|
}
|
package/src/v2/streams/index.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { deleteStream, pauseStreamSnapshotComputation, stopStream } from "./api";
|
|
2
|
+
import {
|
|
3
|
+
DeleteStreamInput,
|
|
4
|
+
PauseStreamSnapshotComputationInput,
|
|
5
|
+
StopStreamInput,
|
|
6
|
+
} from "./schemas";
|
|
7
|
+
|
|
8
|
+
export const streamsMutations = {
|
|
9
|
+
pauseSnapshotComputation: (input: PauseStreamSnapshotComputationInput) =>
|
|
10
|
+
pauseStreamSnapshotComputation(input.organizationId, {
|
|
11
|
+
streamId: input.streamId,
|
|
12
|
+
snapshotComputationPaused: input.snapshotComputationPaused,
|
|
13
|
+
}),
|
|
14
|
+
stop: (input: StopStreamInput) =>
|
|
15
|
+
stopStream(input.organizationId, {
|
|
16
|
+
streamId: input.streamId,
|
|
17
|
+
stopStream: input.stopStream,
|
|
18
|
+
}),
|
|
19
|
+
deleteStream: (input: DeleteStreamInput) => deleteStream(input.organizationId, input.streamId),
|
|
20
|
+
};
|
|
@@ -5,16 +5,8 @@ import {
|
|
|
5
5
|
getStreamWallets,
|
|
6
6
|
getStreamWalletDetails,
|
|
7
7
|
getStreamPoints,
|
|
8
|
-
pauseStreamSnapshotComputation,
|
|
9
|
-
deleteStream,
|
|
10
8
|
} from "./api";
|
|
11
|
-
import {
|
|
12
|
-
DeleteStreamInput,
|
|
13
|
-
GetStreamPointsQuery,
|
|
14
|
-
GetStreamsQuery,
|
|
15
|
-
GetStreamsWalletsQuery,
|
|
16
|
-
PauseStreamSnapshotComputationInput,
|
|
17
|
-
} from "./schemas";
|
|
9
|
+
import { GetStreamPointsQuery, GetStreamsQuery, GetStreamsWalletsQuery } from "./schemas";
|
|
18
10
|
|
|
19
11
|
export const streamsQueries = createQueryKeys("streams", {
|
|
20
12
|
list: (query?: GetStreamsQuery) => ({
|
|
@@ -38,12 +30,3 @@ export const streamsQueries = createQueryKeys("streams", {
|
|
|
38
30
|
queryFn: () => getStreamsSupportedChains(),
|
|
39
31
|
},
|
|
40
32
|
});
|
|
41
|
-
|
|
42
|
-
export const streamsMutations = {
|
|
43
|
-
pauseSnapshotComputation: (input: PauseStreamSnapshotComputationInput) =>
|
|
44
|
-
pauseStreamSnapshotComputation(input.organizationId, {
|
|
45
|
-
streamId: input.streamId,
|
|
46
|
-
snapshotComputationPaused: input.snapshotComputationPaused,
|
|
47
|
-
}),
|
|
48
|
-
delete: (input: DeleteStreamInput) => deleteStream(input.organizationId, input.streamId),
|
|
49
|
-
};
|
|
@@ -206,8 +206,7 @@ export const streamSignatureRequestInputSchema = z.object({
|
|
|
206
206
|
chainId: z.number().nullable(),
|
|
207
207
|
customArgs: z.intersection(
|
|
208
208
|
z.object({
|
|
209
|
-
|
|
210
|
-
targetTokenAddress: z.string(),
|
|
209
|
+
targetTokenId: z.string().uuid(),
|
|
211
210
|
}),
|
|
212
211
|
z.union([
|
|
213
212
|
z.object({ tokensPerUSD: z.string() }),
|
|
@@ -317,18 +316,30 @@ export const pauseStreamSnapshotComputationBodySchema = z.object({
|
|
|
317
316
|
snapshotComputationPaused: z.boolean(),
|
|
318
317
|
});
|
|
319
318
|
|
|
320
|
-
export const
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
export const stopStreamInputSchema = z.object({
|
|
320
|
+
organizationId: z.string().uuid(),
|
|
321
|
+
streamId: z.string().uuid(),
|
|
322
|
+
stopStream: z.boolean(),
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
export const stopStreamBodySchema = z.object({
|
|
326
|
+
streamId: z.string().uuid(),
|
|
327
|
+
stopStream: z.boolean(),
|
|
323
328
|
});
|
|
324
329
|
|
|
325
|
-
export const pauseStreamSnapshotComputationOutputSchema = outputSchema;
|
|
326
330
|
export const deleteStreamInputSchema = z.object({
|
|
327
331
|
organizationId: z.string().uuid(),
|
|
328
332
|
streamId: z.string().uuid(),
|
|
329
333
|
});
|
|
330
334
|
|
|
331
|
-
|
|
335
|
+
const updateStreamOutputSchema = z.object({
|
|
336
|
+
success: z.boolean(),
|
|
337
|
+
message: z.string(),
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
export const pauseStreamSnapshotComputationOutputSchema = updateStreamOutputSchema;
|
|
341
|
+
export const stopStreamOutputSchema = updateStreamOutputSchema;
|
|
342
|
+
export const deleteStreamOutputSchema = updateStreamOutputSchema;
|
|
332
343
|
|
|
333
344
|
// --- Types ---
|
|
334
345
|
|
|
@@ -356,5 +367,8 @@ export type PauseStreamSnapshotComputationBody = z.infer<
|
|
|
356
367
|
export type PauseStreamSnapshotComputationOutput = z.infer<
|
|
357
368
|
typeof pauseStreamSnapshotComputationOutputSchema
|
|
358
369
|
>;
|
|
370
|
+
export type StopStreamInput = z.infer<typeof stopStreamInputSchema>;
|
|
371
|
+
export type StopStreamBody = z.infer<typeof stopStreamBodySchema>;
|
|
372
|
+
export type StopStreamOutput = z.infer<typeof stopStreamOutputSchema>;
|
|
359
373
|
export type DeleteStreamInput = z.infer<typeof deleteStreamInputSchema>;
|
|
360
374
|
export type DeleteStreamOutput = z.infer<typeof deleteStreamOutputSchema>;
|