@slotchain/sdk 1.1.1 → 1.1.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.d.mts CHANGED
@@ -93,10 +93,47 @@ interface Category {
93
93
  }
94
94
  interface Booking {
95
95
  id: string;
96
- tenantId: string;
97
- slotId?: string;
98
- customerId?: string;
96
+ slot_id: string;
97
+ customer_id?: string;
98
+ customer_info: {
99
+ name: string;
100
+ email: string;
101
+ phone?: string;
102
+ address?: string;
103
+ city?: string;
104
+ state?: string;
105
+ zipCode?: string;
106
+ isGuestCheckout?: boolean;
107
+ };
108
+ booking_data: {
109
+ services?: string[];
110
+ selected_services?: string[];
111
+ service_items?: string[];
112
+ total?: number;
113
+ delivery_type?: string;
114
+ [key: string]: unknown;
115
+ };
99
116
  status?: string;
117
+ created_at: string;
118
+ updated_at: string;
119
+ }
120
+ /**
121
+ * Booking with nested slot information
122
+ */
123
+ interface BookingWithSlot extends Booking {
124
+ slots?: Slot;
125
+ }
126
+ /**
127
+ * Options for listing bookings
128
+ */
129
+ interface ListBookingsOptions {
130
+ tenant_id?: string;
131
+ slot_id?: string;
132
+ customer_id?: string;
133
+ status?: string;
134
+ includeSlot?: boolean;
135
+ page?: number;
136
+ limit?: number;
100
137
  }
101
138
  interface Service {
102
139
  id: string;
@@ -108,11 +145,13 @@ interface Service {
108
145
  }
109
146
  interface Slot {
110
147
  id: string;
111
- tenantId: string;
112
- serviceId?: string;
113
- startTime: string;
114
- endTime: string;
115
- available: boolean;
148
+ tenant_id: string;
149
+ name: string;
150
+ description?: string;
151
+ status?: string;
152
+ is_active?: boolean;
153
+ created_at: string;
154
+ updated_at: string;
116
155
  }
117
156
  interface Customer {
118
157
  id: string;
@@ -329,16 +368,74 @@ declare class BookingClient {
329
368
  */
330
369
  getById(id: string): Promise<ApiResponse<Booking>>;
331
370
  /**
332
- * List bookings
371
+ * List bookings with enhanced filtering
333
372
  * GET /api/v1/bookings
373
+ *
374
+ * Supports filtering by tenant_id, slot_id, customer_id, status, and optional nested slot information.
375
+ *
376
+ * @param params - Query options (tenant_id, slot_id, customer_id, status, includeSlot, page, limit)
377
+ * @returns Bookings or BookingsWithSlot based on includeSlot parameter
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * // List bookings by tenant (single query - fast!)
382
+ * const bookings = await slotly.booking.list({
383
+ * tenant_id: 'tenant-123',
384
+ * includeSlot: true,
385
+ * page: 1,
386
+ * limit: 20
387
+ * });
388
+ *
389
+ * // List bookings by slot
390
+ * const slotBookings = await slotly.booking.list({
391
+ * slot_id: 'slot-456',
392
+ * status: 'confirmed'
393
+ * });
394
+ * ```
334
395
  */
335
- list(params?: {
336
- slot_id?: string;
337
- customer_id?: string;
338
- status?: string;
339
- page?: number;
340
- limit?: number;
341
- }): Promise<ApiResponse<Booking[]>>;
396
+ list(params?: ListBookingsOptions): Promise<ApiResponse<Booking[] | BookingWithSlot[]>>;
397
+ /**
398
+ * List bookings by tenant (convenience method)
399
+ * GET /api/v1/bookings?tenant_id=:id
400
+ *
401
+ * @param tenantId - Tenant ID
402
+ * @param options - Additional options (includeSlot, page, limit, status)
403
+ * @returns Bookings or BookingsWithSlot based on includeSlot parameter
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * const bookings = await slotly.booking.listByTenant('tenant-123', {
408
+ * page: 1,
409
+ * limit: 20,
410
+ * status: 'confirmed'
411
+ * });
412
+ * ```
413
+ */
414
+ listByTenant(tenantId: string, options?: Omit<ListBookingsOptions, 'tenant_id'>): Promise<ApiResponse<Booking[] | BookingWithSlot[]>>;
415
+ /**
416
+ * List bookings by tenant with nested slot information (convenience method)
417
+ * GET /api/v1/bookings?tenant_id=:id&includeSlot=true
418
+ *
419
+ * @param tenantId - Tenant ID
420
+ * @param options - Additional options (page, limit, status)
421
+ * @returns BookingsWithSlot (includes nested slot information)
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * const bookings = await slotly.booking.listByTenantWithSlots('tenant-123', {
426
+ * page: 1,
427
+ * limit: 20
428
+ * });
429
+ *
430
+ * // Access slot information
431
+ * bookings.data.forEach(booking => {
432
+ * if (booking.slots) {
433
+ * console.log('Slot name:', booking.slots.name);
434
+ * }
435
+ * });
436
+ * ```
437
+ */
438
+ listByTenantWithSlots(tenantId: string, options?: Omit<ListBookingsOptions, 'tenant_id' | 'includeSlot'>): Promise<ApiResponse<BookingWithSlot[]>>;
342
439
  /**
343
440
  * Create a new booking (publishes booking.created event)
344
441
  * POST /api/v1/bookings
@@ -1258,4 +1355,4 @@ interface SlotlyApi {
1258
1355
  */
1259
1356
  declare const useSlotly: (options: SlotlyClientOptions) => SlotlyApi;
1260
1357
 
1261
- export { type ApiResponse, type Booking, type Category, type Customer, type DataQualityIssue, type Flow, type FlowStep, type GetOrganizationOptions, type Notification, type Organization, type OrganizationFullConfig, type Service, type ServiceItem, type ServiceItemWithService, type ServiceWithItems, type Slot, type SlotlyApi, SlotlyApiError, type SlotlyAuthContext, SlotlyAuthError, type SlotlyClientOptions, SlotlyConfigurationError, SlotlyNetworkError, type SlotlyRequest, type Studio, type Tenant, type TenantBranding, type TenantFullConfig, useSlotly as default, getSlotlyContext, useSlotly, validateSlotlyRequest };
1358
+ export { type ApiResponse, type Booking, type BookingWithSlot, type Category, type Customer, type DataQualityIssue, type Flow, type FlowStep, type GetOrganizationOptions, type ListBookingsOptions, type Notification, type Organization, type OrganizationFullConfig, type Service, type ServiceItem, type ServiceItemWithService, type ServiceWithItems, type Slot, type SlotlyApi, SlotlyApiError, type SlotlyAuthContext, SlotlyAuthError, type SlotlyClientOptions, SlotlyConfigurationError, SlotlyNetworkError, type SlotlyRequest, type Studio, type Tenant, type TenantBranding, type TenantFullConfig, useSlotly as default, getSlotlyContext, useSlotly, validateSlotlyRequest };
package/dist/index.d.ts CHANGED
@@ -93,10 +93,47 @@ interface Category {
93
93
  }
94
94
  interface Booking {
95
95
  id: string;
96
- tenantId: string;
97
- slotId?: string;
98
- customerId?: string;
96
+ slot_id: string;
97
+ customer_id?: string;
98
+ customer_info: {
99
+ name: string;
100
+ email: string;
101
+ phone?: string;
102
+ address?: string;
103
+ city?: string;
104
+ state?: string;
105
+ zipCode?: string;
106
+ isGuestCheckout?: boolean;
107
+ };
108
+ booking_data: {
109
+ services?: string[];
110
+ selected_services?: string[];
111
+ service_items?: string[];
112
+ total?: number;
113
+ delivery_type?: string;
114
+ [key: string]: unknown;
115
+ };
99
116
  status?: string;
117
+ created_at: string;
118
+ updated_at: string;
119
+ }
120
+ /**
121
+ * Booking with nested slot information
122
+ */
123
+ interface BookingWithSlot extends Booking {
124
+ slots?: Slot;
125
+ }
126
+ /**
127
+ * Options for listing bookings
128
+ */
129
+ interface ListBookingsOptions {
130
+ tenant_id?: string;
131
+ slot_id?: string;
132
+ customer_id?: string;
133
+ status?: string;
134
+ includeSlot?: boolean;
135
+ page?: number;
136
+ limit?: number;
100
137
  }
101
138
  interface Service {
102
139
  id: string;
@@ -108,11 +145,13 @@ interface Service {
108
145
  }
109
146
  interface Slot {
110
147
  id: string;
111
- tenantId: string;
112
- serviceId?: string;
113
- startTime: string;
114
- endTime: string;
115
- available: boolean;
148
+ tenant_id: string;
149
+ name: string;
150
+ description?: string;
151
+ status?: string;
152
+ is_active?: boolean;
153
+ created_at: string;
154
+ updated_at: string;
116
155
  }
117
156
  interface Customer {
118
157
  id: string;
@@ -329,16 +368,74 @@ declare class BookingClient {
329
368
  */
330
369
  getById(id: string): Promise<ApiResponse<Booking>>;
331
370
  /**
332
- * List bookings
371
+ * List bookings with enhanced filtering
333
372
  * GET /api/v1/bookings
373
+ *
374
+ * Supports filtering by tenant_id, slot_id, customer_id, status, and optional nested slot information.
375
+ *
376
+ * @param params - Query options (tenant_id, slot_id, customer_id, status, includeSlot, page, limit)
377
+ * @returns Bookings or BookingsWithSlot based on includeSlot parameter
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * // List bookings by tenant (single query - fast!)
382
+ * const bookings = await slotly.booking.list({
383
+ * tenant_id: 'tenant-123',
384
+ * includeSlot: true,
385
+ * page: 1,
386
+ * limit: 20
387
+ * });
388
+ *
389
+ * // List bookings by slot
390
+ * const slotBookings = await slotly.booking.list({
391
+ * slot_id: 'slot-456',
392
+ * status: 'confirmed'
393
+ * });
394
+ * ```
334
395
  */
335
- list(params?: {
336
- slot_id?: string;
337
- customer_id?: string;
338
- status?: string;
339
- page?: number;
340
- limit?: number;
341
- }): Promise<ApiResponse<Booking[]>>;
396
+ list(params?: ListBookingsOptions): Promise<ApiResponse<Booking[] | BookingWithSlot[]>>;
397
+ /**
398
+ * List bookings by tenant (convenience method)
399
+ * GET /api/v1/bookings?tenant_id=:id
400
+ *
401
+ * @param tenantId - Tenant ID
402
+ * @param options - Additional options (includeSlot, page, limit, status)
403
+ * @returns Bookings or BookingsWithSlot based on includeSlot parameter
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * const bookings = await slotly.booking.listByTenant('tenant-123', {
408
+ * page: 1,
409
+ * limit: 20,
410
+ * status: 'confirmed'
411
+ * });
412
+ * ```
413
+ */
414
+ listByTenant(tenantId: string, options?: Omit<ListBookingsOptions, 'tenant_id'>): Promise<ApiResponse<Booking[] | BookingWithSlot[]>>;
415
+ /**
416
+ * List bookings by tenant with nested slot information (convenience method)
417
+ * GET /api/v1/bookings?tenant_id=:id&includeSlot=true
418
+ *
419
+ * @param tenantId - Tenant ID
420
+ * @param options - Additional options (page, limit, status)
421
+ * @returns BookingsWithSlot (includes nested slot information)
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * const bookings = await slotly.booking.listByTenantWithSlots('tenant-123', {
426
+ * page: 1,
427
+ * limit: 20
428
+ * });
429
+ *
430
+ * // Access slot information
431
+ * bookings.data.forEach(booking => {
432
+ * if (booking.slots) {
433
+ * console.log('Slot name:', booking.slots.name);
434
+ * }
435
+ * });
436
+ * ```
437
+ */
438
+ listByTenantWithSlots(tenantId: string, options?: Omit<ListBookingsOptions, 'tenant_id' | 'includeSlot'>): Promise<ApiResponse<BookingWithSlot[]>>;
342
439
  /**
343
440
  * Create a new booking (publishes booking.created event)
344
441
  * POST /api/v1/bookings
@@ -1258,4 +1355,4 @@ interface SlotlyApi {
1258
1355
  */
1259
1356
  declare const useSlotly: (options: SlotlyClientOptions) => SlotlyApi;
1260
1357
 
1261
- export { type ApiResponse, type Booking, type Category, type Customer, type DataQualityIssue, type Flow, type FlowStep, type GetOrganizationOptions, type Notification, type Organization, type OrganizationFullConfig, type Service, type ServiceItem, type ServiceItemWithService, type ServiceWithItems, type Slot, type SlotlyApi, SlotlyApiError, type SlotlyAuthContext, SlotlyAuthError, type SlotlyClientOptions, SlotlyConfigurationError, SlotlyNetworkError, type SlotlyRequest, type Studio, type Tenant, type TenantBranding, type TenantFullConfig, useSlotly as default, getSlotlyContext, useSlotly, validateSlotlyRequest };
1358
+ export { type ApiResponse, type Booking, type BookingWithSlot, type Category, type Customer, type DataQualityIssue, type Flow, type FlowStep, type GetOrganizationOptions, type ListBookingsOptions, type Notification, type Organization, type OrganizationFullConfig, type Service, type ServiceItem, type ServiceItemWithService, type ServiceWithItems, type Slot, type SlotlyApi, SlotlyApiError, type SlotlyAuthContext, SlotlyAuthError, type SlotlyClientOptions, SlotlyConfigurationError, SlotlyNetworkError, type SlotlyRequest, type Studio, type Tenant, type TenantBranding, type TenantFullConfig, useSlotly as default, getSlotlyContext, useSlotly, validateSlotlyRequest };
package/dist/index.esm.js CHANGED
@@ -177,8 +177,30 @@ var BookingClient = class {
177
177
  return response.data;
178
178
  }
179
179
  /**
180
- * List bookings
180
+ * List bookings with enhanced filtering
181
181
  * GET /api/v1/bookings
182
+ *
183
+ * Supports filtering by tenant_id, slot_id, customer_id, status, and optional nested slot information.
184
+ *
185
+ * @param params - Query options (tenant_id, slot_id, customer_id, status, includeSlot, page, limit)
186
+ * @returns Bookings or BookingsWithSlot based on includeSlot parameter
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * // List bookings by tenant (single query - fast!)
191
+ * const bookings = await slotly.booking.list({
192
+ * tenant_id: 'tenant-123',
193
+ * includeSlot: true,
194
+ * page: 1,
195
+ * limit: 20
196
+ * });
197
+ *
198
+ * // List bookings by slot
199
+ * const slotBookings = await slotly.booking.list({
200
+ * slot_id: 'slot-456',
201
+ * status: 'confirmed'
202
+ * });
203
+ * ```
182
204
  */
183
205
  async list(params) {
184
206
  const response = await this.client.get(
@@ -187,6 +209,59 @@ var BookingClient = class {
187
209
  );
188
210
  return response.data;
189
211
  }
212
+ /**
213
+ * List bookings by tenant (convenience method)
214
+ * GET /api/v1/bookings?tenant_id=:id
215
+ *
216
+ * @param tenantId - Tenant ID
217
+ * @param options - Additional options (includeSlot, page, limit, status)
218
+ * @returns Bookings or BookingsWithSlot based on includeSlot parameter
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * const bookings = await slotly.booking.listByTenant('tenant-123', {
223
+ * page: 1,
224
+ * limit: 20,
225
+ * status: 'confirmed'
226
+ * });
227
+ * ```
228
+ */
229
+ async listByTenant(tenantId, options) {
230
+ return this.list({
231
+ tenant_id: tenantId,
232
+ ...options
233
+ });
234
+ }
235
+ /**
236
+ * List bookings by tenant with nested slot information (convenience method)
237
+ * GET /api/v1/bookings?tenant_id=:id&includeSlot=true
238
+ *
239
+ * @param tenantId - Tenant ID
240
+ * @param options - Additional options (page, limit, status)
241
+ * @returns BookingsWithSlot (includes nested slot information)
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * const bookings = await slotly.booking.listByTenantWithSlots('tenant-123', {
246
+ * page: 1,
247
+ * limit: 20
248
+ * });
249
+ *
250
+ * // Access slot information
251
+ * bookings.data.forEach(booking => {
252
+ * if (booking.slots) {
253
+ * console.log('Slot name:', booking.slots.name);
254
+ * }
255
+ * });
256
+ * ```
257
+ */
258
+ async listByTenantWithSlots(tenantId, options) {
259
+ return this.list({
260
+ tenant_id: tenantId,
261
+ includeSlot: true,
262
+ ...options
263
+ });
264
+ }
190
265
  /**
191
266
  * Create a new booking (publishes booking.created event)
192
267
  * POST /api/v1/bookings