@slotchain/sdk 1.0.0

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.
@@ -0,0 +1,98 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ApiResponse, Booking } from '../types/api';
3
+
4
+ export class BookingClient {
5
+ constructor(private client: AxiosInstance) {}
6
+
7
+ /**
8
+ * Get booking by ID
9
+ * GET /api/v1/bookings/:id
10
+ */
11
+ async getById(id: string): Promise<ApiResponse<Booking>> {
12
+ const response = await this.client.get<ApiResponse<Booking>>(
13
+ `/api/v1/bookings/${id}`
14
+ );
15
+ return response.data;
16
+ }
17
+
18
+ /**
19
+ * List bookings
20
+ * GET /api/v1/bookings
21
+ */
22
+ async list(params?: {
23
+ slot_id?: string;
24
+ customer_id?: string;
25
+ status?: string;
26
+ page?: number;
27
+ limit?: number;
28
+ }): Promise<ApiResponse<Booking[]>> {
29
+ const response = await this.client.get<ApiResponse<Booking[]>>(
30
+ '/api/v1/bookings',
31
+ { params }
32
+ );
33
+ return response.data;
34
+ }
35
+
36
+ /**
37
+ * Create a new booking (publishes booking.created event)
38
+ * POST /api/v1/bookings
39
+ */
40
+ async create(data: {
41
+ slot_id: string;
42
+ customer_info: {
43
+ name: string;
44
+ email: string;
45
+ phone?: string;
46
+ address?: string;
47
+ city?: string;
48
+ state?: string;
49
+ zipCode?: string;
50
+ isGuestCheckout?: boolean;
51
+ };
52
+ booking_data?: Record<string, unknown>;
53
+ }): Promise<ApiResponse<Booking>> {
54
+ const response = await this.client.post<ApiResponse<Booking>>(
55
+ '/api/v1/bookings',
56
+ data
57
+ );
58
+ return response.data;
59
+ }
60
+
61
+ /**
62
+ * Update booking by ID
63
+ * PUT /api/v1/bookings/:id
64
+ */
65
+ async update(id: string, data: {
66
+ status?: string;
67
+ customer_info?: Record<string, unknown>;
68
+ booking_data?: Record<string, unknown>;
69
+ }): Promise<ApiResponse<Booking>> {
70
+ const response = await this.client.put<ApiResponse<Booking>>(
71
+ `/api/v1/bookings/${id}`,
72
+ data
73
+ );
74
+ return response.data;
75
+ }
76
+
77
+ /**
78
+ * Cancel booking by ID
79
+ * Note: Cancel is typically done via update with status change
80
+ * If dedicated cancel endpoint exists, update this method
81
+ */
82
+ async cancel(id: string): Promise<ApiResponse<Booking>> {
83
+ // Use update to change status to cancelled
84
+ return this.update(id, { status: 'cancelled' });
85
+ }
86
+
87
+ /**
88
+ * Delete booking by ID (soft delete)
89
+ * DELETE /api/v1/bookings/:id
90
+ */
91
+ async delete(id: string): Promise<ApiResponse<void>> {
92
+ const response = await this.client.delete<ApiResponse<void>>(
93
+ `/api/v1/bookings/${id}`
94
+ );
95
+ return response.data;
96
+ }
97
+ }
98
+
@@ -0,0 +1,165 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ApiResponse, Customer, Booking } from '../types/api';
3
+
4
+ export class CustomerClient {
5
+ constructor(private client: AxiosInstance) {}
6
+
7
+ /**
8
+ * Get customer by ID
9
+ * GET /api/v1/customers/:id
10
+ *
11
+ * @param id - Customer ID
12
+ * @returns Customer details
13
+ */
14
+ async getById(id: string): Promise<ApiResponse<Customer>> {
15
+ const response = await this.client.get<ApiResponse<Customer>>(
16
+ `/api/v1/customers/${id}`
17
+ );
18
+ return response.data;
19
+ }
20
+
21
+ /**
22
+ * Get customer by email
23
+ * GET /api/v1/customers?email=:email&tenant_id=:id
24
+ *
25
+ * @param email - Customer email
26
+ * @param tenantId - Required tenant ID for scoping
27
+ * @returns Customer details
28
+ */
29
+ async getByEmail(email: string, tenantId: string): Promise<ApiResponse<Customer>> {
30
+ const response = await this.client.get<ApiResponse<Customer>>(
31
+ '/api/v1/customers',
32
+ { params: { email, tenant_id: tenantId } }
33
+ );
34
+ return response.data;
35
+ }
36
+
37
+ /**
38
+ * List customers with optional filters
39
+ * GET /api/v1/customers
40
+ *
41
+ * @param params - Query parameters (tenant_id required, page, limit, search, is_guest)
42
+ * @returns Paginated list of customers
43
+ */
44
+ async list(params: {
45
+ tenant_id: string;
46
+ page?: number;
47
+ limit?: number;
48
+ search?: string;
49
+ is_guest?: boolean;
50
+ }): Promise<ApiResponse<Customer[]>> {
51
+ const response = await this.client.get<ApiResponse<Customer[]>>(
52
+ '/api/v1/customers',
53
+ { params }
54
+ );
55
+ return response.data;
56
+ }
57
+
58
+ /**
59
+ * Create a new customer
60
+ * POST /api/v1/customers
61
+ *
62
+ * @param data - Customer creation data (tenant_id, name, email required)
63
+ * @returns Created customer
64
+ */
65
+ async create(data: Partial<Customer>): Promise<ApiResponse<Customer>> {
66
+ const response = await this.client.post<ApiResponse<Customer>>(
67
+ '/api/v1/customers',
68
+ data
69
+ );
70
+ return response.data;
71
+ }
72
+
73
+ /**
74
+ * Update customer by ID
75
+ * PUT /api/v1/customers/:id
76
+ *
77
+ * @param id - Customer ID
78
+ * @param data - Customer update data
79
+ * @returns Updated customer
80
+ */
81
+ async update(id: string, data: Partial<Customer>): Promise<ApiResponse<Customer>> {
82
+ const response = await this.client.put<ApiResponse<Customer>>(
83
+ `/api/v1/customers/${id}`,
84
+ data
85
+ );
86
+ return response.data;
87
+ }
88
+
89
+ /**
90
+ * Delete customer by ID
91
+ * DELETE /api/v1/customers/:id
92
+ *
93
+ * @param id - Customer ID
94
+ * @returns Empty response on success
95
+ */
96
+ async delete(id: string): Promise<ApiResponse<void>> {
97
+ const response = await this.client.delete<ApiResponse<void>>(
98
+ `/api/v1/customers/${id}`
99
+ );
100
+ return response.data;
101
+ }
102
+
103
+ /**
104
+ * Lookup customer by userId or tenantId
105
+ * GET /api/v1/customers/lookup
106
+ *
107
+ * @param params - Query parameters (userId optional, tenantId required)
108
+ * @returns Customer or null
109
+ */
110
+ async lookup(params: {
111
+ userId?: string;
112
+ tenantId: string;
113
+ }): Promise<ApiResponse<Customer | null>> {
114
+ const response = await this.client.get<ApiResponse<Customer | null>>(
115
+ '/api/v1/customers/lookup',
116
+ { params: { userId: params.userId, tenantId: params.tenantId } }
117
+ );
118
+ return response.data;
119
+ }
120
+
121
+ /**
122
+ * Get autocomplete data from existing customers and bookings
123
+ * GET /api/v1/customers/autocomplete
124
+ *
125
+ * @param tenantId - Tenant ID (required)
126
+ * @returns Autocomplete data
127
+ */
128
+ async autocomplete(tenantId: string): Promise<ApiResponse<any>> {
129
+ const response = await this.client.get<ApiResponse<any>>(
130
+ '/api/v1/customers/autocomplete',
131
+ { params: { tenantId } }
132
+ );
133
+ return response.data;
134
+ }
135
+
136
+ /**
137
+ * Get all bookings for a customer
138
+ * GET /api/v1/customers/bookings
139
+ *
140
+ * @param params - Query parameters (email optional, userId optional, tenantId required)
141
+ * @returns Customer bookings data
142
+ */
143
+ async getBookings(params: {
144
+ email?: string;
145
+ userId?: string;
146
+ tenantId: string;
147
+ }): Promise<ApiResponse<{
148
+ customer: Customer | null;
149
+ bookings: Booking[];
150
+ groupedBySlot: Record<string, Booking[]>;
151
+ total: number;
152
+ }>> {
153
+ const response = await this.client.get<ApiResponse<{
154
+ customer: Customer | null;
155
+ bookings: Booking[];
156
+ groupedBySlot: Record<string, Booking[]>;
157
+ total: number;
158
+ }>>(
159
+ '/api/v1/customers/bookings',
160
+ { params }
161
+ );
162
+ return response.data;
163
+ }
164
+ }
165
+
@@ -0,0 +1,93 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ApiResponse, DataQualityIssue } from '../types/api';
3
+
4
+ export class DataQualityClient {
5
+ constructor(private client: AxiosInstance) {}
6
+
7
+ /**
8
+ * Get data quality issue by ID
9
+ * GET /api/v1/data-quality/:id
10
+ *
11
+ * @param id - Issue ID
12
+ * @returns Data quality issue details
13
+ */
14
+ async getById(id: string): Promise<ApiResponse<DataQualityIssue>> {
15
+ // TODO: Replace with actual endpoint when available
16
+ const response = await this.client.get<ApiResponse<DataQualityIssue>>(
17
+ `/api/v1/data-quality/${id}`
18
+ );
19
+ return response.data;
20
+ }
21
+
22
+ /**
23
+ * List data quality issues with optional filters
24
+ * GET /api/v1/data-quality
25
+ *
26
+ * @param params - Query parameters (tenantId, type, severity, resolved, page, limit)
27
+ * @returns Paginated list of data quality issues
28
+ */
29
+ async list(params?: {
30
+ tenantId?: string;
31
+ type?: string;
32
+ severity?: 'low' | 'medium' | 'high';
33
+ resolved?: boolean;
34
+ page?: number;
35
+ limit?: number;
36
+ }): Promise<ApiResponse<DataQualityIssue[]>> {
37
+ // TODO: Replace with actual endpoint when available
38
+ const response = await this.client.get<ApiResponse<DataQualityIssue[]>>(
39
+ '/api/v1/data-quality',
40
+ { params }
41
+ );
42
+ return response.data;
43
+ }
44
+
45
+ /**
46
+ * Run data quality check for a tenant
47
+ * POST /api/v1/data-quality/check
48
+ *
49
+ * @param tenantId - Tenant ID to check
50
+ * @returns List of detected issues
51
+ */
52
+ async runCheck(tenantId: string): Promise<ApiResponse<DataQualityIssue[]>> {
53
+ // TODO: Replace with actual endpoint when available
54
+ const response = await this.client.post<ApiResponse<DataQualityIssue[]>>(
55
+ '/api/v1/data-quality/check',
56
+ { tenantId }
57
+ );
58
+ return response.data;
59
+ }
60
+
61
+ /**
62
+ * Resolve a data quality issue
63
+ * PATCH /api/v1/data-quality/:id/resolve
64
+ *
65
+ * @param id - Issue ID
66
+ * @returns Resolved issue
67
+ */
68
+ async resolve(id: string): Promise<ApiResponse<DataQualityIssue>> {
69
+ // TODO: Replace with actual endpoint when available
70
+ const response = await this.client.patch<ApiResponse<DataQualityIssue>>(
71
+ `/api/v1/data-quality/${id}/resolve`,
72
+ { resolved: true }
73
+ );
74
+ return response.data;
75
+ }
76
+
77
+ /**
78
+ * Get data quality summary for a tenant
79
+ * GET /api/v1/data-quality/summary?tenantId=:id
80
+ *
81
+ * @param tenantId - Tenant ID
82
+ * @returns Summary of data quality issues
83
+ */
84
+ async getSummary(tenantId: string): Promise<ApiResponse<any>> {
85
+ // TODO: Replace with actual endpoint when available
86
+ const response = await this.client.get<ApiResponse<any>>(
87
+ '/api/v1/data-quality/summary',
88
+ { params: { tenantId } }
89
+ );
90
+ return response.data;
91
+ }
92
+ }
93
+
@@ -0,0 +1,107 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ApiResponse, Flow } from '../types/api';
3
+
4
+ export class FlowClient {
5
+ constructor(private client: AxiosInstance) {}
6
+
7
+ /**
8
+ * Get flow by ID
9
+ * GET /api/v1/flows/:id
10
+ *
11
+ * @param id - Flow ID
12
+ * @returns Flow details
13
+ */
14
+ async getById(id: string): Promise<ApiResponse<Flow>> {
15
+ // TODO: Replace with actual endpoint when available
16
+ const response = await this.client.get<ApiResponse<Flow>>(
17
+ `/api/v1/flows/${id}`
18
+ );
19
+ return response.data;
20
+ }
21
+
22
+ /**
23
+ * List flows with optional filters
24
+ * GET /api/v1/flows
25
+ *
26
+ * @param params - Query parameters (tenantId, page, limit)
27
+ * @returns Paginated list of flows
28
+ */
29
+ async list(params?: {
30
+ tenantId?: string;
31
+ page?: number;
32
+ limit?: number;
33
+ }): Promise<ApiResponse<Flow[]>> {
34
+ // TODO: Replace with actual endpoint when available
35
+ const response = await this.client.get<ApiResponse<Flow[]>>(
36
+ '/api/v1/flows',
37
+ { params }
38
+ );
39
+ return response.data;
40
+ }
41
+
42
+ /**
43
+ * Create a new flow
44
+ * POST /api/v1/flows
45
+ *
46
+ * @param data - Flow creation data
47
+ * @returns Created flow
48
+ */
49
+ async create(data: Partial<Flow>): Promise<ApiResponse<Flow>> {
50
+ // TODO: Replace with actual endpoint when available
51
+ const response = await this.client.post<ApiResponse<Flow>>(
52
+ '/api/v1/flows',
53
+ data
54
+ );
55
+ return response.data;
56
+ }
57
+
58
+ /**
59
+ * Update flow by ID
60
+ * PATCH /api/v1/flows/:id
61
+ *
62
+ * @param id - Flow ID
63
+ * @param data - Flow update data
64
+ * @returns Updated flow
65
+ */
66
+ async update(id: string, data: Partial<Flow>): Promise<ApiResponse<Flow>> {
67
+ // TODO: Replace with actual endpoint when available
68
+ const response = await this.client.patch<ApiResponse<Flow>>(
69
+ `/api/v1/flows/${id}`,
70
+ data
71
+ );
72
+ return response.data;
73
+ }
74
+
75
+ /**
76
+ * Delete flow by ID
77
+ * DELETE /api/v1/flows/:id
78
+ *
79
+ * @param id - Flow ID
80
+ * @returns Empty response on success
81
+ */
82
+ async delete(id: string): Promise<ApiResponse<void>> {
83
+ // TODO: Replace with actual endpoint when available
84
+ const response = await this.client.delete<ApiResponse<void>>(
85
+ `/api/v1/flows/${id}`
86
+ );
87
+ return response.data;
88
+ }
89
+
90
+ /**
91
+ * Execute a flow
92
+ * POST /api/v1/flows/:id/execute
93
+ *
94
+ * @param id - Flow ID
95
+ * @param input - Optional input data for flow execution
96
+ * @returns Flow execution result
97
+ */
98
+ async execute(id: string, input?: Record<string, any>): Promise<ApiResponse<any>> {
99
+ // TODO: Replace with actual endpoint when available
100
+ const response = await this.client.post<ApiResponse<any>>(
101
+ `/api/v1/flows/${id}/execute`,
102
+ { input }
103
+ );
104
+ return response.data;
105
+ }
106
+ }
107
+
@@ -0,0 +1,108 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ApiResponse, Notification } from '../types/api';
3
+
4
+ export class NotificationClient {
5
+ constructor(private client: AxiosInstance) {}
6
+
7
+ /**
8
+ * Get notification by ID
9
+ * GET /api/v1/notifications/:id
10
+ *
11
+ * @param id - Notification ID
12
+ * @returns Notification details
13
+ */
14
+ async getById(id: string): Promise<ApiResponse<Notification>> {
15
+ // TODO: Replace with actual endpoint when available
16
+ const response = await this.client.get<ApiResponse<Notification>>(
17
+ `/api/v1/notifications/${id}`
18
+ );
19
+ return response.data;
20
+ }
21
+
22
+ /**
23
+ * List notifications with optional filters
24
+ * GET /api/v1/notifications
25
+ *
26
+ * @param params - Query parameters (tenantId, type, recipient, page, limit)
27
+ * @returns Paginated list of notifications
28
+ */
29
+ async list(params?: {
30
+ tenantId?: string;
31
+ type?: string;
32
+ recipient?: string;
33
+ page?: number;
34
+ limit?: number;
35
+ }): Promise<ApiResponse<Notification[]>> {
36
+ // TODO: Replace with actual endpoint when available
37
+ const response = await this.client.get<ApiResponse<Notification[]>>(
38
+ '/api/v1/notifications',
39
+ { params }
40
+ );
41
+ return response.data;
42
+ }
43
+
44
+ /**
45
+ * Create a new notification
46
+ * POST /api/v1/notifications
47
+ *
48
+ * @param data - Notification creation data
49
+ * @returns Created notification
50
+ */
51
+ async create(data: Partial<Notification>): Promise<ApiResponse<Notification>> {
52
+ // TODO: Replace with actual endpoint when available
53
+ const response = await this.client.post<ApiResponse<Notification>>(
54
+ '/api/v1/notifications',
55
+ data
56
+ );
57
+ return response.data;
58
+ }
59
+
60
+ /**
61
+ * Send notification immediately
62
+ * POST /api/v1/notifications/send
63
+ *
64
+ * @param data - Notification data to send
65
+ * @returns Sent notification
66
+ */
67
+ async send(data: Partial<Notification>): Promise<ApiResponse<Notification>> {
68
+ // TODO: Replace with actual endpoint when available
69
+ const response = await this.client.post<ApiResponse<Notification>>(
70
+ '/api/v1/notifications/send',
71
+ data
72
+ );
73
+ return response.data;
74
+ }
75
+
76
+ /**
77
+ * Update notification by ID
78
+ * PATCH /api/v1/notifications/:id
79
+ *
80
+ * @param id - Notification ID
81
+ * @param data - Notification update data
82
+ * @returns Updated notification
83
+ */
84
+ async update(id: string, data: Partial<Notification>): Promise<ApiResponse<Notification>> {
85
+ // TODO: Replace with actual endpoint when available
86
+ const response = await this.client.patch<ApiResponse<Notification>>(
87
+ `/api/v1/notifications/${id}`,
88
+ data
89
+ );
90
+ return response.data;
91
+ }
92
+
93
+ /**
94
+ * Delete notification by ID
95
+ * DELETE /api/v1/notifications/:id
96
+ *
97
+ * @param id - Notification ID
98
+ * @returns Empty response on success
99
+ */
100
+ async delete(id: string): Promise<ApiResponse<void>> {
101
+ // TODO: Replace with actual endpoint when available
102
+ const response = await this.client.delete<ApiResponse<void>>(
103
+ `/api/v1/notifications/${id}`
104
+ );
105
+ return response.data;
106
+ }
107
+ }
108
+
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @deprecated RegisterClient has been moved to @slotly/studio-sdk
3
+ *
4
+ * RegisterClient (studio-specific booking register operations) is now available
5
+ * in the separate @slotly/studio-sdk package. This ensures clear separation:
6
+ * studio-level register operations live in their own SDK, while tenant &
7
+ * platform scopes remain in the core @slotly/sdk.
8
+ *
9
+ * To use register operations, install and import from @slotly/studio-sdk:
10
+ * ```ts
11
+ * import { useStudioSlotly } from '@slotly/studio-sdk';
12
+ * const studio = useStudioSlotly({ getClientKey, getUserToken });
13
+ * await studio.register.getRegisters(...);
14
+ * ```
15
+ */
16
+
17
+ // This file is kept for backwards compatibility but should not be imported.
18
+ // RegisterClient functionality has been moved to @slotly/studio-sdk
19
+