@turtleclub/hooks 0.5.0-beta.95 → 0.5.0-beta.97

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turtleclub/hooks",
3
3
  "type": "module",
4
- "version": "0.5.0-beta.95",
4
+ "version": "0.5.0-beta.97",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "3f7a4a79294f72108d38af5653822077f29b661e"
57
+ "gitHead": "103e26a0d2f6b4679c7d6a78c9b02041098aa4bd"
58
58
  }
@@ -7,6 +7,16 @@ export const organizationSchema = z.object({
7
7
  landingUrl: z.string().optional().nullable(),
8
8
  iconUrl: z.string().optional().nullable(),
9
9
  organizationType: z.string().optional().nullable(),
10
+ organizationPermissions: z
11
+ .array(
12
+ z.object({
13
+ id: z.string().uuid(),
14
+ permissionId: z.string().uuid(),
15
+ status: z.enum(["revoked", "approved"]),
16
+ permissionName: z.string(),
17
+ })
18
+ )
19
+ .optional(),
10
20
  turtleRefCode: z.string().optional().nullable(),
11
21
  twitterHandle: z.string().optional().nullable(),
12
22
  status: z.string().optional().nullable(),
@@ -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, {
@@ -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, streamsQueries } from "./queries";
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.delete,
134
+ mutationFn: streamsMutations.deleteStream,
120
135
  ...options,
121
136
  });
122
137
  }
@@ -4,6 +4,9 @@ export * from "./hooks";
4
4
  // Query keys
5
5
  export * from "./queries";
6
6
 
7
+ // Mutations
8
+ export * from "./mutations";
9
+
7
10
  // API functions
8
11
  export * from "./api";
9
12
 
@@ -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
- };
@@ -316,18 +316,30 @@ export const pauseStreamSnapshotComputationBodySchema = z.object({
316
316
  snapshotComputationPaused: z.boolean(),
317
317
  });
318
318
 
319
- export const outputSchema = z.object({
320
- success: z.boolean(),
321
- message: z.string(),
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(),
322
328
  });
323
329
 
324
- export const pauseStreamSnapshotComputationOutputSchema = outputSchema;
325
330
  export const deleteStreamInputSchema = z.object({
326
331
  organizationId: z.string().uuid(),
327
332
  streamId: z.string().uuid(),
328
333
  });
329
334
 
330
- export const deleteStreamOutputSchema = outputSchema;
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;
331
343
 
332
344
  // --- Types ---
333
345
 
@@ -355,5 +367,8 @@ export type PauseStreamSnapshotComputationBody = z.infer<
355
367
  export type PauseStreamSnapshotComputationOutput = z.infer<
356
368
  typeof pauseStreamSnapshotComputationOutputSchema
357
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>;
358
373
  export type DeleteStreamInput = z.infer<typeof deleteStreamInputSchema>;
359
374
  export type DeleteStreamOutput = z.infer<typeof deleteStreamOutputSchema>;