@spotsdev/sdk 1.4.0 → 1.5.2
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 +2166 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1656 -0
- package/dist/index.d.ts +1655 -36
- package/dist/index.js +2021 -64
- package/dist/index.js.map +1 -0
- package/package.json +22 -6
- package/src/api/entities.ts +171 -170
- package/src/api/mutations/products.ts +18 -2
- package/src/api/queries/index.ts +4 -0
- package/src/api/queries/payments.ts +67 -0
- package/dist/api/client.d.ts +0 -12
- package/dist/api/client.js +0 -72
- package/dist/api/entities.d.ts +0 -305
- package/dist/api/entities.js +0 -13
- package/dist/api/mutations/clubs.d.ts +0 -47
- package/dist/api/mutations/clubs.js +0 -97
- package/dist/api/mutations/conversations.d.ts +0 -45
- package/dist/api/mutations/conversations.js +0 -114
- package/dist/api/mutations/index.d.ts +0 -14
- package/dist/api/mutations/index.js +0 -40
- package/dist/api/mutations/notifications.d.ts +0 -38
- package/dist/api/mutations/notifications.js +0 -64
- package/dist/api/mutations/orders.d.ts +0 -73
- package/dist/api/mutations/orders.js +0 -114
- package/dist/api/mutations/posts.d.ts +0 -123
- package/dist/api/mutations/posts.js +0 -242
- package/dist/api/mutations/products.d.ts +0 -81
- package/dist/api/mutations/products.js +0 -98
- package/dist/api/mutations/redemptions.d.ts +0 -33
- package/dist/api/mutations/redemptions.js +0 -63
- package/dist/api/mutations/spots.d.ts +0 -93
- package/dist/api/mutations/spots.js +0 -167
- package/dist/api/mutations/users.d.ts +0 -73
- package/dist/api/mutations/users.js +0 -175
- package/dist/api/queries/auth.d.ts +0 -37
- package/dist/api/queries/auth.js +0 -61
- package/dist/api/queries/clubs.d.ts +0 -52
- package/dist/api/queries/clubs.js +0 -116
- package/dist/api/queries/conversations.d.ts +0 -52
- package/dist/api/queries/conversations.js +0 -83
- package/dist/api/queries/index.d.ts +0 -28
- package/dist/api/queries/index.js +0 -69
- package/dist/api/queries/misc.d.ts +0 -30
- package/dist/api/queries/misc.js +0 -91
- package/dist/api/queries/notifications.d.ts +0 -34
- package/dist/api/queries/notifications.js +0 -62
- package/dist/api/queries/orders.d.ts +0 -45
- package/dist/api/queries/orders.js +0 -93
- package/dist/api/queries/posts.d.ts +0 -92
- package/dist/api/queries/posts.js +0 -233
- package/dist/api/queries/products.d.ts +0 -48
- package/dist/api/queries/products.js +0 -87
- package/dist/api/queries/spots.d.ts +0 -93
- package/dist/api/queries/spots.js +0 -250
- package/dist/api/queries/templates.d.ts +0 -39
- package/dist/api/queries/templates.js +0 -81
- package/dist/api/queries/users.d.ts +0 -104
- package/dist/api/queries/users.js +0 -235
- package/dist/api/queries/wallet.d.ts +0 -109
- package/dist/api/queries/wallet.js +0 -136
- package/dist/api/services/index.d.ts +0 -2
- package/dist/api/services/index.js +0 -8
- package/dist/api/services/marketplace.d.ts +0 -129
- package/dist/api/services/marketplace.js +0 -168
- package/dist/api/types.d.ts +0 -57
- package/dist/api/types.js +0 -33
package/src/api/entities.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Spots SDK Entity Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* This
|
|
4
|
+
* ALL entity and enum types are imported from @spotsdev/types (generated from OpenAPI spec).
|
|
5
|
+
* This file re-exports them with SDK-friendly aliases and adds SDK-specific types.
|
|
6
6
|
*
|
|
7
|
-
* IMPORTANT:
|
|
8
|
-
* types.ts handles re-exporting from spots-types - this file only defines entity interfaces
|
|
9
|
-
* and SDK-specific types not in the OpenAPI spec.
|
|
7
|
+
* IMPORTANT: Do NOT define entity types here - they come from spots-types.
|
|
10
8
|
*/
|
|
11
9
|
|
|
12
10
|
// ============================================================================
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// RE-EXPORTS FROM @spotsdev/types
|
|
12
|
+
// All entity types come from the generated OpenAPI types
|
|
15
13
|
// ============================================================================
|
|
16
|
-
|
|
14
|
+
export type {
|
|
15
|
+
// Enums
|
|
17
16
|
SpotType,
|
|
18
17
|
AccountStatus,
|
|
19
18
|
PostType,
|
|
@@ -22,101 +21,143 @@ import type {
|
|
|
22
21
|
ReportReason,
|
|
23
22
|
ProductType,
|
|
24
23
|
ProductStatus,
|
|
25
|
-
|
|
24
|
+
FulfillmentType,
|
|
26
25
|
ClaimStatus,
|
|
27
26
|
OrderStatus,
|
|
28
27
|
NotificationType,
|
|
28
|
+
MediaType,
|
|
29
|
+
|
|
30
|
+
// Spot types
|
|
31
|
+
SpotResponseDto,
|
|
32
|
+
PaginatedSpotsResponseDto,
|
|
33
|
+
SpotClaimResponseDto,
|
|
34
|
+
SpotCityDto,
|
|
35
|
+
SpotImageDto,
|
|
36
|
+
SpotVibeDto,
|
|
37
|
+
SpotIntentionDto,
|
|
38
|
+
SpotOwnerDto,
|
|
39
|
+
CreateSpotDto,
|
|
40
|
+
UpdateSpotDto,
|
|
41
|
+
ClaimSpotDto,
|
|
42
|
+
|
|
43
|
+
// Post types
|
|
44
|
+
PostResponseDto,
|
|
45
|
+
PaginatedPostsResponseDto,
|
|
46
|
+
PostReportResponseDto,
|
|
47
|
+
UpvoteResponseDto,
|
|
48
|
+
PostStatusResponseDto,
|
|
49
|
+
PostUserDto,
|
|
50
|
+
PostSpotDto,
|
|
51
|
+
PostReplyDto,
|
|
52
|
+
CreatePostDto,
|
|
53
|
+
UpdatePostDto,
|
|
54
|
+
CreateReplyDto,
|
|
55
|
+
CreateResponseDto,
|
|
56
|
+
UpdateResponseDto,
|
|
57
|
+
CreateReportDto,
|
|
58
|
+
PostStatusDto,
|
|
59
|
+
|
|
60
|
+
// User types
|
|
61
|
+
UserResponseDto,
|
|
62
|
+
UpdateUserDto,
|
|
63
|
+
AuthUserDto,
|
|
64
|
+
AuthTokensDto,
|
|
65
|
+
|
|
66
|
+
// Product/Marketplace types
|
|
67
|
+
ProductResponseDto,
|
|
68
|
+
CreateProductDto,
|
|
69
|
+
UpdateProductDto,
|
|
70
|
+
PaginatedProductsResponseDto,
|
|
71
|
+
AdjustStockDto,
|
|
72
|
+
|
|
73
|
+
// Order types
|
|
74
|
+
CreateOrderDto,
|
|
75
|
+
OrderItemDto,
|
|
76
|
+
UpdateOrderStatusDto,
|
|
77
|
+
|
|
78
|
+
// Notification types
|
|
79
|
+
NotificationResponseDto,
|
|
80
|
+
NotificationsListResponseDto,
|
|
81
|
+
|
|
82
|
+
// Auth types
|
|
83
|
+
SendOtpDto,
|
|
84
|
+
VerifyOtpDto,
|
|
85
|
+
RefreshTokenDto,
|
|
86
|
+
SendOtpResponseDto,
|
|
87
|
+
RefreshTokenResponseDto,
|
|
88
|
+
|
|
89
|
+
// Other types
|
|
90
|
+
CreateMediaDto,
|
|
91
|
+
CreateConversationDto,
|
|
92
|
+
CreateMessageDto,
|
|
93
|
+
CreateInterestDto,
|
|
94
|
+
UpdateInterestDto,
|
|
95
|
+
AddUserInterestDto,
|
|
96
|
+
CreateIntentionDto,
|
|
97
|
+
UpdateIntentionDto,
|
|
98
|
+
|
|
99
|
+
// Generic API response
|
|
100
|
+
ApiResponse,
|
|
29
101
|
} from '@spotsdev/types'
|
|
30
102
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
103
|
+
import type {
|
|
104
|
+
PostType,
|
|
105
|
+
SpotResponseDto,
|
|
106
|
+
PostResponseDto,
|
|
107
|
+
PostReplyDto as PostReplyDtoType,
|
|
108
|
+
ProductResponseDto,
|
|
109
|
+
SpotImageDto as SpotImageDtoType,
|
|
110
|
+
SpotVibeDto as SpotVibeDtoType,
|
|
111
|
+
SpotIntentionDto as SpotIntentionDtoType,
|
|
112
|
+
OrderItemDto as OrderItemDtoType,
|
|
113
|
+
NotificationResponseDto,
|
|
114
|
+
SpotOwnerDto,
|
|
115
|
+
PostUserDto,
|
|
116
|
+
ResponseStatus,
|
|
117
|
+
ReportReason,
|
|
118
|
+
ClaimStatus,
|
|
119
|
+
OrderStatus,
|
|
120
|
+
} from '@spotsdev/types'
|
|
36
121
|
|
|
37
122
|
// ============================================================================
|
|
38
|
-
//
|
|
123
|
+
// TYPE ALIASES FOR SDK BACKWARDS COMPATIBILITY
|
|
124
|
+
// These map old SDK names to new spots-types names
|
|
39
125
|
// ============================================================================
|
|
40
126
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
name: string
|
|
44
|
-
emoji: string | null
|
|
45
|
-
slug?: string
|
|
46
|
-
category?: string
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface User {
|
|
50
|
-
id: string
|
|
51
|
-
phone: string | null
|
|
52
|
-
email: string | null
|
|
53
|
-
name: string | null
|
|
54
|
-
bio: string | null
|
|
55
|
-
avatarUrl: string | null
|
|
56
|
-
status: AccountStatus
|
|
57
|
-
onboardingCompleted: boolean
|
|
58
|
-
vibes?: UserVibe[]
|
|
59
|
-
lastActiveAt: Date | null
|
|
60
|
-
createdAt: Date
|
|
61
|
-
updatedAt: Date
|
|
62
|
-
}
|
|
127
|
+
// SpotPostType is the SDK's name for PostType
|
|
128
|
+
export type SpotPostType = PostType
|
|
63
129
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
marketplaceEnabled: boolean
|
|
85
|
-
// Dates as strings for JSON serialization compatibility
|
|
86
|
-
createdAt: Date | string
|
|
87
|
-
updatedAt: Date | string
|
|
130
|
+
// Entity type aliases - map to response DTOs
|
|
131
|
+
export type Spot = SpotResponseDto
|
|
132
|
+
export type SpotPost = PostResponseDto
|
|
133
|
+
export type PostReply = PostReplyDtoType
|
|
134
|
+
export type Product = ProductResponseDto
|
|
135
|
+
export type SpotImage = SpotImageDtoType
|
|
136
|
+
export type SpotVibe = SpotVibeDtoType
|
|
137
|
+
export type SpotIntention = SpotIntentionDtoType
|
|
138
|
+
export type OrderItem = OrderItemDtoType
|
|
139
|
+
export type Notification = NotificationResponseDto
|
|
140
|
+
|
|
141
|
+
// User alias from SpotOwnerDto (simplified user in spot responses)
|
|
142
|
+
export type User = SpotOwnerDto & {
|
|
143
|
+
phone?: string | null
|
|
144
|
+
email?: string | null
|
|
145
|
+
bio?: string | null
|
|
146
|
+
onboardingCompleted?: boolean
|
|
147
|
+
lastActiveAt?: Date | null
|
|
148
|
+
createdAt?: Date
|
|
149
|
+
updatedAt?: Date
|
|
88
150
|
}
|
|
89
151
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
userId: string
|
|
94
|
-
postType: SpotPostType
|
|
95
|
-
title: string
|
|
96
|
-
content: string | null
|
|
97
|
-
emoji: string | null
|
|
98
|
-
expiresAt: Date | null
|
|
99
|
-
status: 'ACTIVE' | 'FULFILLED' | 'EXPIRED' | 'DELETED'
|
|
100
|
-
upvoteCount: number
|
|
101
|
-
responseCount: number
|
|
102
|
-
replyCount: number
|
|
103
|
-
createdAt: Date
|
|
104
|
-
updatedAt: Date
|
|
105
|
-
// Relations (optional, populated by API)
|
|
106
|
-
user?: User
|
|
107
|
-
spot?: Spot
|
|
108
|
-
}
|
|
152
|
+
// ============================================================================
|
|
153
|
+
// SDK-SPECIFIC TYPES (not in OpenAPI spec)
|
|
154
|
+
// ============================================================================
|
|
109
155
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
userId: string
|
|
114
|
-
content: string
|
|
115
|
-
createdAt: Date
|
|
116
|
-
updatedAt: Date
|
|
117
|
-
user?: User
|
|
118
|
-
}
|
|
156
|
+
// Enums not yet exposed via API DTOs
|
|
157
|
+
export type ReportStatus = 'PENDING' | 'REVIEWED' | 'RESOLVED' | 'DISMISSED'
|
|
158
|
+
export type ClubMemberRole = 'MEMBER' | 'ADMIN' | 'OWNER'
|
|
119
159
|
|
|
160
|
+
// PostResponse entity (different from CreateResponseDto/UpdateResponseDto)
|
|
120
161
|
export interface PostResponse {
|
|
121
162
|
id: string
|
|
122
163
|
postId: string
|
|
@@ -129,6 +170,7 @@ export interface PostResponse {
|
|
|
129
170
|
post?: SpotPost
|
|
130
171
|
}
|
|
131
172
|
|
|
173
|
+
// PostUpvote entity
|
|
132
174
|
export interface PostUpvote {
|
|
133
175
|
id: string
|
|
134
176
|
postId: string
|
|
@@ -136,9 +178,7 @@ export interface PostUpvote {
|
|
|
136
178
|
createdAt: Date
|
|
137
179
|
}
|
|
138
180
|
|
|
139
|
-
|
|
140
|
-
* PostUpvoter - user who upvoted a post (from /posts/:id/upvotes endpoint)
|
|
141
|
-
*/
|
|
181
|
+
// PostUpvoter for /posts/:id/upvotes endpoint
|
|
142
182
|
export interface PostUpvoter {
|
|
143
183
|
id: string
|
|
144
184
|
userId: string
|
|
@@ -147,9 +187,7 @@ export interface PostUpvoter {
|
|
|
147
187
|
createdAt: Date
|
|
148
188
|
}
|
|
149
189
|
|
|
150
|
-
|
|
151
|
-
* PostUpvotesResponse - response from /posts/:id/upvotes endpoint
|
|
152
|
-
*/
|
|
190
|
+
// PostUpvotesResponse from /posts/:id/upvotes endpoint
|
|
153
191
|
export interface PostUpvotesResponse {
|
|
154
192
|
data: PostUpvoter[]
|
|
155
193
|
meta: {
|
|
@@ -162,6 +200,7 @@ export interface PostUpvotesResponse {
|
|
|
162
200
|
}
|
|
163
201
|
}
|
|
164
202
|
|
|
203
|
+
// PostReport entity
|
|
165
204
|
export interface PostReport {
|
|
166
205
|
id: string
|
|
167
206
|
postId: string
|
|
@@ -173,6 +212,7 @@ export interface PostReport {
|
|
|
173
212
|
updatedAt: Date
|
|
174
213
|
}
|
|
175
214
|
|
|
215
|
+
// Club entities (not yet in API DTOs)
|
|
176
216
|
export interface Club {
|
|
177
217
|
id: string
|
|
178
218
|
name: string
|
|
@@ -189,10 +229,11 @@ export interface ClubMember {
|
|
|
189
229
|
id: string
|
|
190
230
|
clubId: string
|
|
191
231
|
userId: string
|
|
192
|
-
role:
|
|
232
|
+
role: ClubMemberRole
|
|
193
233
|
joinedAt: Date
|
|
194
234
|
}
|
|
195
235
|
|
|
236
|
+
// Conversation entities (not yet in API DTOs)
|
|
196
237
|
export interface Conversation {
|
|
197
238
|
id: string
|
|
198
239
|
createdAt: Date
|
|
@@ -210,17 +251,7 @@ export interface Message {
|
|
|
210
251
|
sender?: User
|
|
211
252
|
}
|
|
212
253
|
|
|
213
|
-
|
|
214
|
-
id: string
|
|
215
|
-
userId: string
|
|
216
|
-
type: NotificationType
|
|
217
|
-
title: string
|
|
218
|
-
body: string | null
|
|
219
|
-
data: Record<string, unknown> | null
|
|
220
|
-
isRead: boolean
|
|
221
|
-
createdAt: Date
|
|
222
|
-
}
|
|
223
|
-
|
|
254
|
+
// Template entity (not yet in API DTOs)
|
|
224
255
|
export interface PostTemplate {
|
|
225
256
|
id: string
|
|
226
257
|
postType: SpotPostType
|
|
@@ -233,6 +264,7 @@ export interface PostTemplate {
|
|
|
233
264
|
updatedAt: Date
|
|
234
265
|
}
|
|
235
266
|
|
|
267
|
+
// Reference entities (not yet in API DTOs)
|
|
236
268
|
export interface Vibe {
|
|
237
269
|
id: string
|
|
238
270
|
name: string
|
|
@@ -262,6 +294,16 @@ export interface LifeSituation {
|
|
|
262
294
|
createdAt: Date
|
|
263
295
|
}
|
|
264
296
|
|
|
297
|
+
// User vibe (simplified vibe attached to user)
|
|
298
|
+
export interface UserVibe {
|
|
299
|
+
id: string
|
|
300
|
+
name: string
|
|
301
|
+
emoji: string | null
|
|
302
|
+
slug?: string
|
|
303
|
+
category?: string
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Favorites and subscriptions (not yet in API DTOs)
|
|
265
307
|
export interface FavoriteSpot {
|
|
266
308
|
id: string
|
|
267
309
|
userId: string
|
|
@@ -270,29 +312,15 @@ export interface FavoriteSpot {
|
|
|
270
312
|
spot?: Spot
|
|
271
313
|
}
|
|
272
314
|
|
|
273
|
-
export interface
|
|
315
|
+
export interface SpotSubscription {
|
|
274
316
|
id: string
|
|
275
317
|
spotId: string
|
|
276
|
-
|
|
277
|
-
caption: string | null
|
|
278
|
-
sortOrder: number
|
|
318
|
+
userId: string
|
|
279
319
|
createdAt: Date
|
|
320
|
+
spot?: Spot
|
|
280
321
|
}
|
|
281
322
|
|
|
282
|
-
|
|
283
|
-
id: string
|
|
284
|
-
spotId: string
|
|
285
|
-
vibeId: string
|
|
286
|
-
vibe?: Vibe
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export interface SpotIntention {
|
|
290
|
-
id: string
|
|
291
|
-
spotId: string
|
|
292
|
-
intentionId: string
|
|
293
|
-
intention?: Intention
|
|
294
|
-
}
|
|
295
|
-
|
|
323
|
+
// SpotClaim entity
|
|
296
324
|
export interface SpotClaim {
|
|
297
325
|
id: string
|
|
298
326
|
spotId: string
|
|
@@ -303,14 +331,7 @@ export interface SpotClaim {
|
|
|
303
331
|
updatedAt: Date
|
|
304
332
|
}
|
|
305
333
|
|
|
306
|
-
|
|
307
|
-
id: string
|
|
308
|
-
spotId: string
|
|
309
|
-
userId: string
|
|
310
|
-
createdAt: Date
|
|
311
|
-
spot?: Spot
|
|
312
|
-
}
|
|
313
|
-
|
|
334
|
+
// City entity
|
|
314
335
|
export interface City {
|
|
315
336
|
id: string
|
|
316
337
|
name: string
|
|
@@ -321,36 +342,7 @@ export interface City {
|
|
|
321
342
|
createdAt: Date
|
|
322
343
|
}
|
|
323
344
|
|
|
324
|
-
//
|
|
325
|
-
// API RESPONSE TYPES
|
|
326
|
-
// ============================================================================
|
|
327
|
-
|
|
328
|
-
// NOTE: ApiResponse is re-exported from @spots/types in types.ts
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Paginated response with meta information
|
|
332
|
-
*/
|
|
333
|
-
export interface PaginatedResponse<T> {
|
|
334
|
-
data: T[]
|
|
335
|
-
meta: PaginationMeta
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export interface PaginationMeta {
|
|
339
|
-
total: number
|
|
340
|
-
page: number
|
|
341
|
-
limit: number
|
|
342
|
-
totalPages: number
|
|
343
|
-
hasNextPage: boolean
|
|
344
|
-
hasPreviousPage: boolean
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// ============================================================================
|
|
348
|
-
// MARKETPLACE TYPES
|
|
349
|
-
// ============================================================================
|
|
350
|
-
|
|
351
|
-
// Use ProductResponseDto from spots-types directly
|
|
352
|
-
export type Product = ProductResponseDto
|
|
353
|
-
|
|
345
|
+
// Order entity (full order, not just OrderItemDto)
|
|
354
346
|
export interface Order {
|
|
355
347
|
id: string
|
|
356
348
|
spotId: string
|
|
@@ -364,14 +356,23 @@ export interface Order {
|
|
|
364
356
|
metadata: Record<string, unknown> | null
|
|
365
357
|
createdAt: Date
|
|
366
358
|
updatedAt: Date
|
|
359
|
+
items?: OrderItem[]
|
|
367
360
|
}
|
|
368
361
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
unitPrice: number
|
|
362
|
+
// ============================================================================
|
|
363
|
+
// PAGINATION TYPES
|
|
364
|
+
// ============================================================================
|
|
365
|
+
|
|
366
|
+
export interface PaginationMeta {
|
|
375
367
|
total: number
|
|
376
|
-
|
|
368
|
+
page: number
|
|
369
|
+
limit: number
|
|
370
|
+
totalPages: number
|
|
371
|
+
hasNextPage: boolean
|
|
372
|
+
hasPreviousPage: boolean
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export interface PaginatedResponse<T> {
|
|
376
|
+
data: T[]
|
|
377
|
+
meta: PaginationMeta
|
|
377
378
|
}
|
|
@@ -21,6 +21,7 @@ import type {Product, ProductType, ProductStatus, ApiResponse} from '../types'
|
|
|
21
21
|
export interface CreateProductRequest {
|
|
22
22
|
spotId: string
|
|
23
23
|
name: string
|
|
24
|
+
slug?: string // Optional - auto-generated from name if not provided
|
|
24
25
|
description?: string
|
|
25
26
|
type: ProductType
|
|
26
27
|
price: number
|
|
@@ -37,6 +38,17 @@ export interface CreateProductRequest {
|
|
|
37
38
|
metadata?: Record<string, unknown>
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Generate URL-friendly slug from name
|
|
43
|
+
*/
|
|
44
|
+
function generateSlug(name: string): string {
|
|
45
|
+
return name
|
|
46
|
+
.toLowerCase()
|
|
47
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
48
|
+
.replace(/^-|-$/g, '')
|
|
49
|
+
.slice(0, 100)
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
export interface UpdateProductRequest {
|
|
41
53
|
name?: string
|
|
42
54
|
description?: string
|
|
@@ -74,10 +86,14 @@ export function useCreateProduct(
|
|
|
74
86
|
return useMutation({
|
|
75
87
|
mutationFn: async (data: CreateProductRequest): Promise<Product> => {
|
|
76
88
|
const client = getApiClient()
|
|
77
|
-
const {spotId, ...productData} = data
|
|
89
|
+
const {spotId, slug, ...productData} = data
|
|
90
|
+
|
|
91
|
+
// Auto-generate slug from name if not provided
|
|
92
|
+
const productSlug = slug || generateSlug(productData.name)
|
|
93
|
+
|
|
78
94
|
const response = await client.post<ApiResponse<Product>>(
|
|
79
95
|
`/spots/${spotId}/products`,
|
|
80
|
-
productData,
|
|
96
|
+
{...productData, slug: productSlug},
|
|
81
97
|
)
|
|
82
98
|
return response.data.data
|
|
83
99
|
},
|
package/src/api/queries/index.ts
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payments Query Hooks
|
|
3
|
+
*
|
|
4
|
+
* TanStack Query hooks for payment configuration.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
useQuery,
|
|
9
|
+
type UseQueryOptions,
|
|
10
|
+
type UseQueryResult,
|
|
11
|
+
} from '@tanstack/react-query'
|
|
12
|
+
import {getApiClient} from '../client'
|
|
13
|
+
import type {ApiResponse} from '../types'
|
|
14
|
+
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// QUERY KEYS
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
export const paymentKeys = {
|
|
20
|
+
all: ['payments'] as const,
|
|
21
|
+
config: () => [...paymentKeys.all, 'config'] as const,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// TYPES
|
|
26
|
+
// ============================================================================
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Payment configuration returned by GET /payments/config
|
|
30
|
+
*/
|
|
31
|
+
export interface PaymentConfig {
|
|
32
|
+
stripe: {
|
|
33
|
+
publishableKey: string | null
|
|
34
|
+
enabled: boolean
|
|
35
|
+
}
|
|
36
|
+
coinbase: {
|
|
37
|
+
enabled: boolean
|
|
38
|
+
}
|
|
39
|
+
supportedMethods: Array<'card' | 'apple_pay' | 'google_pay' | 'crypto'>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// QUERY HOOKS
|
|
44
|
+
// ============================================================================
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get payment configuration
|
|
48
|
+
* Returns publishable keys and enabled payment methods
|
|
49
|
+
*
|
|
50
|
+
* @endpoint GET /payments/config
|
|
51
|
+
*/
|
|
52
|
+
export function usePaymentConfig(
|
|
53
|
+
options?: Omit<UseQueryOptions<PaymentConfig>, 'queryKey' | 'queryFn'>,
|
|
54
|
+
): UseQueryResult<PaymentConfig> {
|
|
55
|
+
return useQuery({
|
|
56
|
+
queryKey: paymentKeys.config(),
|
|
57
|
+
queryFn: async (): Promise<PaymentConfig> => {
|
|
58
|
+
const client = getApiClient()
|
|
59
|
+
const response = await client.get<ApiResponse<PaymentConfig>>(
|
|
60
|
+
'/payments/config',
|
|
61
|
+
)
|
|
62
|
+
return response.data.data
|
|
63
|
+
},
|
|
64
|
+
staleTime: 1000 * 60 * 60, // 1 hour - config rarely changes
|
|
65
|
+
...options,
|
|
66
|
+
})
|
|
67
|
+
}
|
package/dist/api/client.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type AxiosInstance } from 'axios';
|
|
2
|
-
export interface SDKConfig {
|
|
3
|
-
baseURL: string;
|
|
4
|
-
getAccessToken: () => string | null | Promise<string | null>;
|
|
5
|
-
refreshAccessToken?: () => Promise<string>;
|
|
6
|
-
onUnauthorized?: () => void;
|
|
7
|
-
}
|
|
8
|
-
declare let apiClient: AxiosInstance | null;
|
|
9
|
-
export declare function configureSDK(sdkConfig: SDKConfig): void;
|
|
10
|
-
export declare function getApiClient(): AxiosInstance;
|
|
11
|
-
export declare function getConfig(): SDKConfig;
|
|
12
|
-
export { apiClient };
|
package/dist/api/client.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.apiClient = void 0;
|
|
7
|
-
exports.configureSDK = configureSDK;
|
|
8
|
-
exports.getApiClient = getApiClient;
|
|
9
|
-
exports.getConfig = getConfig;
|
|
10
|
-
const axios_1 = __importDefault(require("axios"));
|
|
11
|
-
let config = null;
|
|
12
|
-
let apiClient = null;
|
|
13
|
-
exports.apiClient = apiClient;
|
|
14
|
-
function configureSDK(sdkConfig) {
|
|
15
|
-
config = sdkConfig;
|
|
16
|
-
exports.apiClient = apiClient = createApiClient(sdkConfig);
|
|
17
|
-
}
|
|
18
|
-
function getApiClient() {
|
|
19
|
-
if (!apiClient) {
|
|
20
|
-
throw new Error('SDK not configured. Call configureSDK() first.');
|
|
21
|
-
}
|
|
22
|
-
return apiClient;
|
|
23
|
-
}
|
|
24
|
-
function getConfig() {
|
|
25
|
-
if (!config) {
|
|
26
|
-
throw new Error('SDK not configured. Call configureSDK() first.');
|
|
27
|
-
}
|
|
28
|
-
return config;
|
|
29
|
-
}
|
|
30
|
-
function createApiClient(sdkConfig) {
|
|
31
|
-
const client = axios_1.default.create({
|
|
32
|
-
baseURL: sdkConfig.baseURL,
|
|
33
|
-
headers: {
|
|
34
|
-
'Content-Type': 'application/json',
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
// Request interceptor - add auth token
|
|
38
|
-
client.interceptors.request.use(async (requestConfig) => {
|
|
39
|
-
const token = await sdkConfig.getAccessToken();
|
|
40
|
-
if (token) {
|
|
41
|
-
requestConfig.headers.Authorization = `Bearer ${token}`;
|
|
42
|
-
}
|
|
43
|
-
// Debug logging
|
|
44
|
-
console.log(`[SDK] ${requestConfig.method?.toUpperCase()} ${sdkConfig.baseURL}${requestConfig.url}`);
|
|
45
|
-
return requestConfig;
|
|
46
|
-
}, error => Promise.reject(error));
|
|
47
|
-
// Response interceptor - handle 401
|
|
48
|
-
client.interceptors.response.use(response => response, async (error) => {
|
|
49
|
-
console.log(`[SDK] Error: ${error.response?.status} ${error.config?.url}`, error.message);
|
|
50
|
-
// Handle auth token expiration (401)
|
|
51
|
-
if (error.response?.status === 401) {
|
|
52
|
-
if (sdkConfig.refreshAccessToken) {
|
|
53
|
-
try {
|
|
54
|
-
const newToken = await sdkConfig.refreshAccessToken();
|
|
55
|
-
if (newToken && error.config) {
|
|
56
|
-
error.config.headers.Authorization = `Bearer ${newToken}`;
|
|
57
|
-
return client.request(error.config);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
sdkConfig.onUnauthorized?.();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
sdkConfig.onUnauthorized?.();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return Promise.reject(error);
|
|
69
|
-
});
|
|
70
|
-
return client;
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=data:application/json;base64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5zdGF0dXMgPT09IDQwMSkge1xuICAgICAgICBpZiAoc2RrQ29uZmlnLnJlZnJlc2hBY2Nlc3NUb2tlbikge1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBjb25zdCBuZXdUb2tlbiA9IGF3YWl0IHNka0NvbmZpZy5yZWZyZXNoQWNjZXNzVG9rZW4oKVxuICAgICAgICAgICAgaWYgKG5ld1Rva2VuICYmIGVycm9yLmNvbmZpZykge1xuICAgICAgICAgICAgICBlcnJvci5jb25maWcuaGVhZGVycy5BdXRob3JpemF0aW9uID0gYEJlYXJlciAke25ld1Rva2VufWBcbiAgICAgICAgICAgICAgcmV0dXJuIGNsaWVudC5yZXF1ZXN0KGVycm9yLmNvbmZpZylcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGNhdGNoIHtcbiAgICAgICAgICAgIHNka0NvbmZpZy5vblVuYXV0aG9yaXplZD8uKClcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgc2RrQ29uZmlnLm9uVW5hdXRob3JpemVkPy4oKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QoZXJyb3IpXG4gICAgfSxcbiAgKVxuXG4gIHJldHVybiBjbGllbnRcbn1cblxuZXhwb3J0IHthcGlDbGllbnR9XG4iXX0=
|