@meaple-com/react-query 1.0.6 → 1.1.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/README.md +130 -0
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/package.json +4 -5
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @meaple-com/react-query
|
|
2
|
+
|
|
3
|
+
React Query (TanStack Query) hooks for the [Meaple](https://meaple.com) ticketing platform. Fetch and mutate Meaple data in React with caching, loading and error states.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @meaple-com/react-query @meaple-com/core @meaple-com/types
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @meaple-com/react-query @meaple-com/core @meaple-com/types
|
|
11
|
+
# or
|
|
12
|
+
bun add @meaple-com/react-query @meaple-com/core @meaple-com/types
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Peer dependencies:**
|
|
16
|
+
|
|
17
|
+
- `react` ^19.0.0
|
|
18
|
+
- `@tanstack/react-query` ^5.90.7
|
|
19
|
+
- `axios` ^1.12.2
|
|
20
|
+
- `date-fns` ^4.0.0
|
|
21
|
+
|
|
22
|
+
Install them if not already in your project.
|
|
23
|
+
|
|
24
|
+
## Setup
|
|
25
|
+
|
|
26
|
+
Wrap your app with `QueryClientProvider` (from TanStack Query) and `MeapleSDKProvider`:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
30
|
+
import { MeapleSDKProvider } from '@meaple-com/react-query';
|
|
31
|
+
import { MeapleSDK } from '@meaple-com/core';
|
|
32
|
+
|
|
33
|
+
const queryClient = new QueryClient();
|
|
34
|
+
const sdk = new MeapleSDK({
|
|
35
|
+
publicKey: 'YOUR_CHANNEL_ID',
|
|
36
|
+
baseURL: 'https://api.meaple.com',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function App() {
|
|
40
|
+
return (
|
|
41
|
+
<QueryClientProvider client={queryClient}>
|
|
42
|
+
<MeapleSDKProvider sdk={sdk}>
|
|
43
|
+
{/* Your app */}
|
|
44
|
+
</MeapleSDKProvider>
|
|
45
|
+
</QueryClientProvider>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Optional: set the user token when they log in:
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
sdk.setGlobalToken('user-jwt-token');
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Hooks
|
|
57
|
+
|
|
58
|
+
All hooks use the SDK from `MeapleSDKProvider` and return standard TanStack Query results (`data`, `isPending`, `error`, `refetch`, etc.). You can pass the same options as `useQuery` / `useMutation` (e.g. `enabled`, `staleTime`).
|
|
59
|
+
|
|
60
|
+
### Events
|
|
61
|
+
|
|
62
|
+
- **`useEvents(params?, options?)`** – List events
|
|
63
|
+
- **`useEvent(eventId, slug, options?)`** – Single event
|
|
64
|
+
- **`useEventTickets(eventId, slug, options?)`** – Event tickets
|
|
65
|
+
- **`useEventProducts(eventId, slug, options?)`** – Event products
|
|
66
|
+
|
|
67
|
+
### Categories
|
|
68
|
+
|
|
69
|
+
- **`useCategories(options?)`** – List categories
|
|
70
|
+
|
|
71
|
+
### Coupon
|
|
72
|
+
|
|
73
|
+
- **`useCheckCoupon()`** – Mutation to validate a coupon (code + eventId)
|
|
74
|
+
|
|
75
|
+
### Orders
|
|
76
|
+
|
|
77
|
+
- **`useOrder(orderId, options?)`** – Single order
|
|
78
|
+
- **`useUserOrders(params?, options?)`** – Current user orders
|
|
79
|
+
- **`useCreateOrder()`** – Mutation to create an order
|
|
80
|
+
|
|
81
|
+
### Payments
|
|
82
|
+
|
|
83
|
+
- **`usePlatformFee(eventId, amount?, options?)`** – Platform fee for an amount
|
|
84
|
+
|
|
85
|
+
### Tickets (user)
|
|
86
|
+
|
|
87
|
+
- **`useUserEvents(params?, options?)`** – Current user events
|
|
88
|
+
- **`useUserEventTickets(eventId, options?)`** – Current user tickets for an event
|
|
89
|
+
- **`useTransferTicket()`** – Mutation to transfer a ticket
|
|
90
|
+
- **`useEditUserTicket()`** – Mutation to edit user ticket
|
|
91
|
+
- **`useCreateTicketFile()`** – Mutation to create ticket file
|
|
92
|
+
- **`useRefundUserOrder()`** – Mutation to refund user order
|
|
93
|
+
|
|
94
|
+
### Context
|
|
95
|
+
|
|
96
|
+
- **`useMeapleSDK()`** – Access the Meaple SDK instance (throws if used outside `MeapleSDKProvider`)
|
|
97
|
+
|
|
98
|
+
## Example
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { useEvents, useEvent } from '@meaple-com/react-query';
|
|
102
|
+
|
|
103
|
+
function EventList() {
|
|
104
|
+
const { data, isPending, error } = useEvents({ limit: 20 });
|
|
105
|
+
|
|
106
|
+
if (isPending) return <div>Loading...</div>;
|
|
107
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<ul>
|
|
111
|
+
{data?.events.map((event) => (
|
|
112
|
+
<li key={event.id}>{event.name}</li>
|
|
113
|
+
))}
|
|
114
|
+
</ul>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function EventDetail({ eventId, slug }: { eventId: string; slug: string }) {
|
|
119
|
+
const { data: event } = useEvent(eventId, slug);
|
|
120
|
+
// ...
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## With headless components
|
|
125
|
+
|
|
126
|
+
Use `@meaple-com/react-headless-components` for render-props components that call these hooks and expose `data`, `isPending`, `error` (and mutations where relevant), so you can focus on styling and layout.
|
|
127
|
+
|
|
128
|
+
## Documentation
|
|
129
|
+
|
|
130
|
+
[https://docs.meaple.com.br/](https://docs.meaple.com.br/)
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { MeapleSDK } from '@meaple-com/core';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
5
|
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
6
|
-
import { CategoryProps, CouponProps, CheckCouponProps, EventProps,
|
|
6
|
+
import { CategoryProps, CouponProps, CheckCouponProps, EventProps, GetEventProductsResponseProps, FindEventsParams, FindEventsResponseProps, GetEventTicketsResponseProps, UserTicketProps, CreatedOrderResponseProps, CreateOrderParams, GetOrderResponseProps, GetUserOrderProps, PlatformFeeProps, UpdateUserTicketProps, TransferTicketProps as TransferTicketProps$1, CreateTicketFileProps as CreateTicketFileProps$1, GetUserEventProps } from '@meaple-com/types';
|
|
7
7
|
import { AxiosError } from 'axios';
|
|
8
8
|
|
|
9
9
|
interface MeapleSDKContextValue {
|
|
@@ -25,24 +25,24 @@ type UseEventProps = {
|
|
|
25
25
|
};
|
|
26
26
|
declare const useEvent: ({ eventSlug }: UseEventProps, options?: Omit<UseQueryOptions<EventProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<EventProps, Error>;
|
|
27
27
|
|
|
28
|
-
declare const useEventProducts: (eventId: string, privateToken?: string | null, options?: Omit<UseQueryOptions<
|
|
28
|
+
declare const useEventProducts: (eventId: string, privateToken?: string | null, options?: Omit<UseQueryOptions<GetEventProductsResponseProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetEventProductsResponseProps, Error>;
|
|
29
29
|
|
|
30
|
-
declare const useEvents: (params?: FindEventsParams, options?: Omit<UseQueryOptions<
|
|
30
|
+
declare const useEvents: (params?: FindEventsParams, options?: Omit<UseQueryOptions<FindEventsResponseProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<FindEventsResponseProps, Error>;
|
|
31
31
|
|
|
32
|
-
declare const useEventTickets: (eventId: string, privateToken?: string | null, predecessorIds?: string[], options?: Omit<UseQueryOptions<
|
|
32
|
+
declare const useEventTickets: (eventId: string, privateToken?: string | null, predecessorIds?: string[], options?: Omit<UseQueryOptions<GetEventTicketsResponseProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetEventTicketsResponseProps, Error>;
|
|
33
33
|
|
|
34
34
|
declare const useUserEventTickets: (eventId: string, userId?: string, options?: Omit<UseQueryOptions<UserTicketProps[], Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<UserTicketProps[], Error>;
|
|
35
35
|
|
|
36
|
-
declare const useCreateOrder: (options?: Omit<UseMutationOptions<
|
|
36
|
+
declare const useCreateOrder: (options?: Omit<UseMutationOptions<CreatedOrderResponseProps, AxiosError<any, any>, CreateOrderParams, unknown>, "mutationFn">) => _tanstack_react_query.UseMutationResult<CreatedOrderResponseProps, AxiosError<any, any>, CreateOrderParams, unknown>;
|
|
37
37
|
|
|
38
|
-
declare const useOrder: (orderId: string, options?: Omit<UseQueryOptions<
|
|
38
|
+
declare const useOrder: (orderId: string, options?: Omit<UseQueryOptions<GetOrderResponseProps, AxiosError<any, any>>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetOrderResponseProps, AxiosError<any, any>>;
|
|
39
39
|
|
|
40
40
|
type SectionStatus = 'PAID' | 'REFUNDED';
|
|
41
41
|
type FindUserOrdersProps = {
|
|
42
42
|
status: SectionStatus;
|
|
43
43
|
eventId?: string;
|
|
44
44
|
};
|
|
45
|
-
declare const useUserOrders: (data: FindUserOrdersProps, options?: Omit<UseQueryOptions<
|
|
45
|
+
declare const useUserOrders: (data: FindUserOrdersProps, options?: Omit<UseQueryOptions<GetUserOrderProps[], Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetUserOrderProps[], Error>;
|
|
46
46
|
|
|
47
47
|
declare const usePlatformFee: (eventId?: string, options?: Omit<UseQueryOptions<PlatformFeeProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<PlatformFeeProps, Error>;
|
|
48
48
|
|
|
@@ -65,7 +65,7 @@ type SectionType = 'coming_soon' | 'past' | 'awards';
|
|
|
65
65
|
type FindUserEventsProps = {
|
|
66
66
|
type: SectionType;
|
|
67
67
|
};
|
|
68
|
-
declare const useUserEvents: (data?: FindUserEventsProps, options?: Omit<UseQueryOptions<
|
|
68
|
+
declare const useUserEvents: (data?: FindUserEventsProps, options?: Omit<UseQueryOptions<GetUserEventProps[], Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetUserEventProps[], Error>;
|
|
69
69
|
|
|
70
70
|
declare const useRefundUserOrder: (options?: Omit<UseMutationOptions<void, unknown, string, unknown>, "mutationFn">) => _tanstack_react_query.UseMutationResult<void, unknown, string, unknown>;
|
|
71
71
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { MeapleSDK } from '@meaple-com/core';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
5
|
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
6
|
-
import { CategoryProps, CouponProps, CheckCouponProps, EventProps,
|
|
6
|
+
import { CategoryProps, CouponProps, CheckCouponProps, EventProps, GetEventProductsResponseProps, FindEventsParams, FindEventsResponseProps, GetEventTicketsResponseProps, UserTicketProps, CreatedOrderResponseProps, CreateOrderParams, GetOrderResponseProps, GetUserOrderProps, PlatformFeeProps, UpdateUserTicketProps, TransferTicketProps as TransferTicketProps$1, CreateTicketFileProps as CreateTicketFileProps$1, GetUserEventProps } from '@meaple-com/types';
|
|
7
7
|
import { AxiosError } from 'axios';
|
|
8
8
|
|
|
9
9
|
interface MeapleSDKContextValue {
|
|
@@ -25,24 +25,24 @@ type UseEventProps = {
|
|
|
25
25
|
};
|
|
26
26
|
declare const useEvent: ({ eventSlug }: UseEventProps, options?: Omit<UseQueryOptions<EventProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<EventProps, Error>;
|
|
27
27
|
|
|
28
|
-
declare const useEventProducts: (eventId: string, privateToken?: string | null, options?: Omit<UseQueryOptions<
|
|
28
|
+
declare const useEventProducts: (eventId: string, privateToken?: string | null, options?: Omit<UseQueryOptions<GetEventProductsResponseProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetEventProductsResponseProps, Error>;
|
|
29
29
|
|
|
30
|
-
declare const useEvents: (params?: FindEventsParams, options?: Omit<UseQueryOptions<
|
|
30
|
+
declare const useEvents: (params?: FindEventsParams, options?: Omit<UseQueryOptions<FindEventsResponseProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<FindEventsResponseProps, Error>;
|
|
31
31
|
|
|
32
|
-
declare const useEventTickets: (eventId: string, privateToken?: string | null, predecessorIds?: string[], options?: Omit<UseQueryOptions<
|
|
32
|
+
declare const useEventTickets: (eventId: string, privateToken?: string | null, predecessorIds?: string[], options?: Omit<UseQueryOptions<GetEventTicketsResponseProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetEventTicketsResponseProps, Error>;
|
|
33
33
|
|
|
34
34
|
declare const useUserEventTickets: (eventId: string, userId?: string, options?: Omit<UseQueryOptions<UserTicketProps[], Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<UserTicketProps[], Error>;
|
|
35
35
|
|
|
36
|
-
declare const useCreateOrder: (options?: Omit<UseMutationOptions<
|
|
36
|
+
declare const useCreateOrder: (options?: Omit<UseMutationOptions<CreatedOrderResponseProps, AxiosError<any, any>, CreateOrderParams, unknown>, "mutationFn">) => _tanstack_react_query.UseMutationResult<CreatedOrderResponseProps, AxiosError<any, any>, CreateOrderParams, unknown>;
|
|
37
37
|
|
|
38
|
-
declare const useOrder: (orderId: string, options?: Omit<UseQueryOptions<
|
|
38
|
+
declare const useOrder: (orderId: string, options?: Omit<UseQueryOptions<GetOrderResponseProps, AxiosError<any, any>>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetOrderResponseProps, AxiosError<any, any>>;
|
|
39
39
|
|
|
40
40
|
type SectionStatus = 'PAID' | 'REFUNDED';
|
|
41
41
|
type FindUserOrdersProps = {
|
|
42
42
|
status: SectionStatus;
|
|
43
43
|
eventId?: string;
|
|
44
44
|
};
|
|
45
|
-
declare const useUserOrders: (data: FindUserOrdersProps, options?: Omit<UseQueryOptions<
|
|
45
|
+
declare const useUserOrders: (data: FindUserOrdersProps, options?: Omit<UseQueryOptions<GetUserOrderProps[], Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetUserOrderProps[], Error>;
|
|
46
46
|
|
|
47
47
|
declare const usePlatformFee: (eventId?: string, options?: Omit<UseQueryOptions<PlatformFeeProps, Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<PlatformFeeProps, Error>;
|
|
48
48
|
|
|
@@ -65,7 +65,7 @@ type SectionType = 'coming_soon' | 'past' | 'awards';
|
|
|
65
65
|
type FindUserEventsProps = {
|
|
66
66
|
type: SectionType;
|
|
67
67
|
};
|
|
68
|
-
declare const useUserEvents: (data?: FindUserEventsProps, options?: Omit<UseQueryOptions<
|
|
68
|
+
declare const useUserEvents: (data?: FindUserEventsProps, options?: Omit<UseQueryOptions<GetUserEventProps[], Error>, "queryKey" | "queryFn">) => _tanstack_react_query.UseQueryResult<GetUserEventProps[], Error>;
|
|
69
69
|
|
|
70
70
|
declare const useRefundUserOrder: (options?: Omit<UseMutationOptions<void, unknown, string, unknown>, "mutationFn">) => _tanstack_react_query.UseMutationResult<void, unknown, string, unknown>;
|
|
71
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meaple-com/react-query",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "React Query hooks for Meaple SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,13 +28,12 @@
|
|
|
28
28
|
"clean": "rimraf dist"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@meaple-com/core": "^1.
|
|
32
|
-
"@meaple-com/types": "^
|
|
31
|
+
"@meaple-com/core": "^1.1.1",
|
|
32
|
+
"@meaple-com/types": "^4.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/js": "^9.36.0",
|
|
36
36
|
"@tanstack/eslint-plugin-query": "^5.91.2",
|
|
37
|
-
"@tanstack/react-query": "^5.90.7",
|
|
38
37
|
"@types/node": "^24.10.0",
|
|
39
38
|
"@types/react": "^19.0.0",
|
|
40
39
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
@@ -52,7 +51,7 @@
|
|
|
52
51
|
"@tanstack/react-query": "^5.90.7",
|
|
53
52
|
"axios": "^1.12.2",
|
|
54
53
|
"date-fns": "^4.0.0",
|
|
55
|
-
"react": "^19.
|
|
54
|
+
"react": "^19.2.4"
|
|
56
55
|
},
|
|
57
56
|
"files": [
|
|
58
57
|
"dist"
|