@slotchain/sdk 1.1.3 → 1.1.4
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.js +75 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +64 -8
- package/dist/index.d.ts +64 -8
- package/dist/index.esm.js +75 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/__tests__/service-client.spec.ts +450 -0
- package/src/clients/service-client.ts +87 -1
- package/src/clients/slot-client.ts +8 -5
- package/src/index.ts +1 -0
- package/src/types/api.ts +22 -6
package/dist/index.d.mts
CHANGED
|
@@ -57,20 +57,32 @@ interface TenantBranding {
|
|
|
57
57
|
*/
|
|
58
58
|
interface ServiceItem {
|
|
59
59
|
id: string;
|
|
60
|
-
|
|
60
|
+
service_id: string;
|
|
61
61
|
name: string;
|
|
62
62
|
description?: string;
|
|
63
63
|
price?: number;
|
|
64
64
|
duration?: number;
|
|
65
|
-
|
|
65
|
+
is_available?: boolean;
|
|
66
|
+
sort_order?: number;
|
|
67
|
+
created_at: string;
|
|
68
|
+
updated_at: string;
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
|
-
* Enhanced Service type with nested service items
|
|
71
|
+
* Enhanced Service type with nested service items (for tenant endpoint)
|
|
72
|
+
* Uses 'serviceItems' property name
|
|
69
73
|
*/
|
|
70
74
|
interface ServiceWithItems extends Service {
|
|
71
75
|
/** Array of service items nested within this service (optional, may be empty array) */
|
|
72
76
|
serviceItems?: ServiceItem[];
|
|
73
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Service with items for slot endpoint
|
|
80
|
+
* Uses 'items' property name (different from tenant endpoint)
|
|
81
|
+
*/
|
|
82
|
+
interface SlotServiceWithItems extends Service {
|
|
83
|
+
/** Array of service items nested within this service (always included for slot endpoint) */
|
|
84
|
+
items: ServiceItem[];
|
|
85
|
+
}
|
|
74
86
|
/**
|
|
75
87
|
* Service item with parent service reference
|
|
76
88
|
*/
|
|
@@ -137,11 +149,16 @@ interface ListBookingsOptions {
|
|
|
137
149
|
}
|
|
138
150
|
interface Service {
|
|
139
151
|
id: string;
|
|
140
|
-
|
|
152
|
+
tenant_id: string;
|
|
153
|
+
slot_id?: string;
|
|
141
154
|
name: string;
|
|
142
155
|
description?: string;
|
|
156
|
+
category?: string;
|
|
157
|
+
is_active?: boolean;
|
|
143
158
|
duration?: number;
|
|
144
159
|
price?: number;
|
|
160
|
+
created_at: string;
|
|
161
|
+
updated_at: string;
|
|
145
162
|
}
|
|
146
163
|
interface Slot {
|
|
147
164
|
id: string;
|
|
@@ -488,10 +505,45 @@ declare class ServiceClient {
|
|
|
488
505
|
* @returns Service details (with items if includeItems=true)
|
|
489
506
|
*/
|
|
490
507
|
getById(id: string, includeItems?: boolean): Promise<ApiResponse<Service | ServiceWithItems>>;
|
|
508
|
+
/**
|
|
509
|
+
* Get services for a tenant (full list with optional filters)
|
|
510
|
+
* GET /api/v1/services
|
|
511
|
+
*
|
|
512
|
+
* @param options - Query options
|
|
513
|
+
* @param options.tenantId - Tenant ID (UUID) - required if tenantSlug not provided
|
|
514
|
+
* @param options.tenantSlug - Tenant slug - required if tenantId not provided
|
|
515
|
+
* @param options.slotId - Slot ID (DEPRECATED - accepted but ignored for API compatibility)
|
|
516
|
+
* @param options.isActive - Filter by active status
|
|
517
|
+
* @param options.includeItems - Include nested service items (default: false)
|
|
518
|
+
* @param options.page - Page number (default: 1)
|
|
519
|
+
* @param options.limit - Items per page (default: 20, max: 100)
|
|
520
|
+
* @returns Services with optional pagination metadata
|
|
521
|
+
*/
|
|
522
|
+
getServicesByTenant(options: {
|
|
523
|
+
tenantId?: string;
|
|
524
|
+
tenantSlug?: string;
|
|
525
|
+
slotId?: string;
|
|
526
|
+
isActive?: boolean;
|
|
527
|
+
includeItems?: boolean;
|
|
528
|
+
page?: number;
|
|
529
|
+
limit?: number;
|
|
530
|
+
}): Promise<ApiResponse<Service[] | ServiceWithItems[]>>;
|
|
531
|
+
/**
|
|
532
|
+
* Get services for a specific slot
|
|
533
|
+
* GET /api/v1/slots/:id/services
|
|
534
|
+
*
|
|
535
|
+
* Note: Services are tenant-level entities. This endpoint returns all active services
|
|
536
|
+
* for the slot's tenant with items included. The response uses 'items' property (not 'serviceItems').
|
|
537
|
+
*
|
|
538
|
+
* @param slotId - Slot ID (UUID)
|
|
539
|
+
* @returns Services with nested items (always includes items, only active services)
|
|
540
|
+
*/
|
|
541
|
+
getServicesBySlot(slotId: string): Promise<ApiResponse<SlotServiceWithItems[]>>;
|
|
491
542
|
/**
|
|
492
543
|
* List services by tenant slug
|
|
493
544
|
* GET /api/v1/services?tenantSlug=:slug
|
|
494
545
|
*
|
|
546
|
+
* @deprecated Consider using getServicesByTenant() for better type safety and validation
|
|
495
547
|
* @param slug - Tenant slug (or use tenant_id in list() method)
|
|
496
548
|
* @param params - Optional parameters (includeItems, page, limit, is_active)
|
|
497
549
|
* @returns List of services for the tenant
|
|
@@ -506,6 +558,7 @@ declare class ServiceClient {
|
|
|
506
558
|
* List services with optional filters
|
|
507
559
|
* GET /api/v1/services
|
|
508
560
|
*
|
|
561
|
+
* @deprecated Consider using getServicesByTenant() for better type safety and validation
|
|
509
562
|
* @param params - Query parameters (tenant_id, tenantSlug, slot_id, page, limit, is_active, includeItems)
|
|
510
563
|
* @returns Paginated list of services
|
|
511
564
|
*/
|
|
@@ -728,10 +781,13 @@ declare class SlotClient {
|
|
|
728
781
|
* Get all active services for a slot with their items
|
|
729
782
|
* GET /api/v1/slots/:id/services
|
|
730
783
|
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
784
|
+
* Note: Services are tenant-level entities. This endpoint returns all active services
|
|
785
|
+
* for the slot's tenant with items included. The response uses 'items' property (not 'serviceItems').
|
|
786
|
+
*
|
|
787
|
+
* @param id - Slot ID (UUID)
|
|
788
|
+
* @returns Services with nested items (always includes items, only active services)
|
|
733
789
|
*/
|
|
734
|
-
getServices(id: string): Promise<ApiResponse<
|
|
790
|
+
getServices(id: string): Promise<ApiResponse<SlotServiceWithItems[]>>;
|
|
735
791
|
/**
|
|
736
792
|
* Get slot with tenant information
|
|
737
793
|
* GET /api/v1/slots/:id/tenant-info
|
|
@@ -1355,4 +1411,4 @@ interface SlotlyApi {
|
|
|
1355
1411
|
*/
|
|
1356
1412
|
declare const useSlotly: (options: SlotlyClientOptions) => SlotlyApi;
|
|
1357
1413
|
|
|
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 };
|
|
1414
|
+
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 SlotServiceWithItems, 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
|
@@ -57,20 +57,32 @@ interface TenantBranding {
|
|
|
57
57
|
*/
|
|
58
58
|
interface ServiceItem {
|
|
59
59
|
id: string;
|
|
60
|
-
|
|
60
|
+
service_id: string;
|
|
61
61
|
name: string;
|
|
62
62
|
description?: string;
|
|
63
63
|
price?: number;
|
|
64
64
|
duration?: number;
|
|
65
|
-
|
|
65
|
+
is_available?: boolean;
|
|
66
|
+
sort_order?: number;
|
|
67
|
+
created_at: string;
|
|
68
|
+
updated_at: string;
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
|
-
* Enhanced Service type with nested service items
|
|
71
|
+
* Enhanced Service type with nested service items (for tenant endpoint)
|
|
72
|
+
* Uses 'serviceItems' property name
|
|
69
73
|
*/
|
|
70
74
|
interface ServiceWithItems extends Service {
|
|
71
75
|
/** Array of service items nested within this service (optional, may be empty array) */
|
|
72
76
|
serviceItems?: ServiceItem[];
|
|
73
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Service with items for slot endpoint
|
|
80
|
+
* Uses 'items' property name (different from tenant endpoint)
|
|
81
|
+
*/
|
|
82
|
+
interface SlotServiceWithItems extends Service {
|
|
83
|
+
/** Array of service items nested within this service (always included for slot endpoint) */
|
|
84
|
+
items: ServiceItem[];
|
|
85
|
+
}
|
|
74
86
|
/**
|
|
75
87
|
* Service item with parent service reference
|
|
76
88
|
*/
|
|
@@ -137,11 +149,16 @@ interface ListBookingsOptions {
|
|
|
137
149
|
}
|
|
138
150
|
interface Service {
|
|
139
151
|
id: string;
|
|
140
|
-
|
|
152
|
+
tenant_id: string;
|
|
153
|
+
slot_id?: string;
|
|
141
154
|
name: string;
|
|
142
155
|
description?: string;
|
|
156
|
+
category?: string;
|
|
157
|
+
is_active?: boolean;
|
|
143
158
|
duration?: number;
|
|
144
159
|
price?: number;
|
|
160
|
+
created_at: string;
|
|
161
|
+
updated_at: string;
|
|
145
162
|
}
|
|
146
163
|
interface Slot {
|
|
147
164
|
id: string;
|
|
@@ -488,10 +505,45 @@ declare class ServiceClient {
|
|
|
488
505
|
* @returns Service details (with items if includeItems=true)
|
|
489
506
|
*/
|
|
490
507
|
getById(id: string, includeItems?: boolean): Promise<ApiResponse<Service | ServiceWithItems>>;
|
|
508
|
+
/**
|
|
509
|
+
* Get services for a tenant (full list with optional filters)
|
|
510
|
+
* GET /api/v1/services
|
|
511
|
+
*
|
|
512
|
+
* @param options - Query options
|
|
513
|
+
* @param options.tenantId - Tenant ID (UUID) - required if tenantSlug not provided
|
|
514
|
+
* @param options.tenantSlug - Tenant slug - required if tenantId not provided
|
|
515
|
+
* @param options.slotId - Slot ID (DEPRECATED - accepted but ignored for API compatibility)
|
|
516
|
+
* @param options.isActive - Filter by active status
|
|
517
|
+
* @param options.includeItems - Include nested service items (default: false)
|
|
518
|
+
* @param options.page - Page number (default: 1)
|
|
519
|
+
* @param options.limit - Items per page (default: 20, max: 100)
|
|
520
|
+
* @returns Services with optional pagination metadata
|
|
521
|
+
*/
|
|
522
|
+
getServicesByTenant(options: {
|
|
523
|
+
tenantId?: string;
|
|
524
|
+
tenantSlug?: string;
|
|
525
|
+
slotId?: string;
|
|
526
|
+
isActive?: boolean;
|
|
527
|
+
includeItems?: boolean;
|
|
528
|
+
page?: number;
|
|
529
|
+
limit?: number;
|
|
530
|
+
}): Promise<ApiResponse<Service[] | ServiceWithItems[]>>;
|
|
531
|
+
/**
|
|
532
|
+
* Get services for a specific slot
|
|
533
|
+
* GET /api/v1/slots/:id/services
|
|
534
|
+
*
|
|
535
|
+
* Note: Services are tenant-level entities. This endpoint returns all active services
|
|
536
|
+
* for the slot's tenant with items included. The response uses 'items' property (not 'serviceItems').
|
|
537
|
+
*
|
|
538
|
+
* @param slotId - Slot ID (UUID)
|
|
539
|
+
* @returns Services with nested items (always includes items, only active services)
|
|
540
|
+
*/
|
|
541
|
+
getServicesBySlot(slotId: string): Promise<ApiResponse<SlotServiceWithItems[]>>;
|
|
491
542
|
/**
|
|
492
543
|
* List services by tenant slug
|
|
493
544
|
* GET /api/v1/services?tenantSlug=:slug
|
|
494
545
|
*
|
|
546
|
+
* @deprecated Consider using getServicesByTenant() for better type safety and validation
|
|
495
547
|
* @param slug - Tenant slug (or use tenant_id in list() method)
|
|
496
548
|
* @param params - Optional parameters (includeItems, page, limit, is_active)
|
|
497
549
|
* @returns List of services for the tenant
|
|
@@ -506,6 +558,7 @@ declare class ServiceClient {
|
|
|
506
558
|
* List services with optional filters
|
|
507
559
|
* GET /api/v1/services
|
|
508
560
|
*
|
|
561
|
+
* @deprecated Consider using getServicesByTenant() for better type safety and validation
|
|
509
562
|
* @param params - Query parameters (tenant_id, tenantSlug, slot_id, page, limit, is_active, includeItems)
|
|
510
563
|
* @returns Paginated list of services
|
|
511
564
|
*/
|
|
@@ -728,10 +781,13 @@ declare class SlotClient {
|
|
|
728
781
|
* Get all active services for a slot with their items
|
|
729
782
|
* GET /api/v1/slots/:id/services
|
|
730
783
|
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
784
|
+
* Note: Services are tenant-level entities. This endpoint returns all active services
|
|
785
|
+
* for the slot's tenant with items included. The response uses 'items' property (not 'serviceItems').
|
|
786
|
+
*
|
|
787
|
+
* @param id - Slot ID (UUID)
|
|
788
|
+
* @returns Services with nested items (always includes items, only active services)
|
|
733
789
|
*/
|
|
734
|
-
getServices(id: string): Promise<ApiResponse<
|
|
790
|
+
getServices(id: string): Promise<ApiResponse<SlotServiceWithItems[]>>;
|
|
735
791
|
/**
|
|
736
792
|
* Get slot with tenant information
|
|
737
793
|
* GET /api/v1/slots/:id/tenant-info
|
|
@@ -1355,4 +1411,4 @@ interface SlotlyApi {
|
|
|
1355
1411
|
*/
|
|
1356
1412
|
declare const useSlotly: (options: SlotlyClientOptions) => SlotlyApi;
|
|
1357
1413
|
|
|
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 };
|
|
1414
|
+
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 SlotServiceWithItems, 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
|
@@ -324,10 +324,79 @@ var ServiceClient = class {
|
|
|
324
324
|
);
|
|
325
325
|
return response.data;
|
|
326
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Get services for a tenant (full list with optional filters)
|
|
329
|
+
* GET /api/v1/services
|
|
330
|
+
*
|
|
331
|
+
* @param options - Query options
|
|
332
|
+
* @param options.tenantId - Tenant ID (UUID) - required if tenantSlug not provided
|
|
333
|
+
* @param options.tenantSlug - Tenant slug - required if tenantId not provided
|
|
334
|
+
* @param options.slotId - Slot ID (DEPRECATED - accepted but ignored for API compatibility)
|
|
335
|
+
* @param options.isActive - Filter by active status
|
|
336
|
+
* @param options.includeItems - Include nested service items (default: false)
|
|
337
|
+
* @param options.page - Page number (default: 1)
|
|
338
|
+
* @param options.limit - Items per page (default: 20, max: 100)
|
|
339
|
+
* @returns Services with optional pagination metadata
|
|
340
|
+
*/
|
|
341
|
+
async getServicesByTenant(options) {
|
|
342
|
+
if (!options.tenantId && !options.tenantSlug) {
|
|
343
|
+
return {
|
|
344
|
+
success: false,
|
|
345
|
+
error: {
|
|
346
|
+
code: "MISSING_TENANT_ID",
|
|
347
|
+
message: "tenantId or tenantSlug is required"
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
const params = {};
|
|
352
|
+
if (options.tenantId) {
|
|
353
|
+
params.tenant_id = options.tenantId;
|
|
354
|
+
}
|
|
355
|
+
if (options.tenantSlug) {
|
|
356
|
+
params.tenantSlug = options.tenantSlug;
|
|
357
|
+
}
|
|
358
|
+
if (options.slotId) {
|
|
359
|
+
params.slot_id = options.slotId;
|
|
360
|
+
}
|
|
361
|
+
if (options.isActive !== void 0) {
|
|
362
|
+
params.is_active = options.isActive;
|
|
363
|
+
}
|
|
364
|
+
if (options.includeItems) {
|
|
365
|
+
params.includeItems = true;
|
|
366
|
+
}
|
|
367
|
+
if (options.page !== void 0) {
|
|
368
|
+
params.page = options.page;
|
|
369
|
+
}
|
|
370
|
+
if (options.limit !== void 0) {
|
|
371
|
+
params.limit = Math.min(options.limit, 100);
|
|
372
|
+
}
|
|
373
|
+
const response = await this.client.get(
|
|
374
|
+
"/api/v1/services",
|
|
375
|
+
{ params }
|
|
376
|
+
);
|
|
377
|
+
return response.data;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Get services for a specific slot
|
|
381
|
+
* GET /api/v1/slots/:id/services
|
|
382
|
+
*
|
|
383
|
+
* Note: Services are tenant-level entities. This endpoint returns all active services
|
|
384
|
+
* for the slot's tenant with items included. The response uses 'items' property (not 'serviceItems').
|
|
385
|
+
*
|
|
386
|
+
* @param slotId - Slot ID (UUID)
|
|
387
|
+
* @returns Services with nested items (always includes items, only active services)
|
|
388
|
+
*/
|
|
389
|
+
async getServicesBySlot(slotId) {
|
|
390
|
+
const response = await this.client.get(
|
|
391
|
+
`/api/v1/slots/${slotId}/services`
|
|
392
|
+
);
|
|
393
|
+
return response.data;
|
|
394
|
+
}
|
|
327
395
|
/**
|
|
328
396
|
* List services by tenant slug
|
|
329
397
|
* GET /api/v1/services?tenantSlug=:slug
|
|
330
398
|
*
|
|
399
|
+
* @deprecated Consider using getServicesByTenant() for better type safety and validation
|
|
331
400
|
* @param slug - Tenant slug (or use tenant_id in list() method)
|
|
332
401
|
* @param params - Optional parameters (includeItems, page, limit, is_active)
|
|
333
402
|
* @returns List of services for the tenant
|
|
@@ -343,6 +412,7 @@ var ServiceClient = class {
|
|
|
343
412
|
* List services with optional filters
|
|
344
413
|
* GET /api/v1/services
|
|
345
414
|
*
|
|
415
|
+
* @deprecated Consider using getServicesByTenant() for better type safety and validation
|
|
346
416
|
* @param params - Query parameters (tenant_id, tenantSlug, slot_id, page, limit, is_active, includeItems)
|
|
347
417
|
* @returns Paginated list of services
|
|
348
418
|
*/
|
|
@@ -659,8 +729,11 @@ var SlotClient = class {
|
|
|
659
729
|
* Get all active services for a slot with their items
|
|
660
730
|
* GET /api/v1/slots/:id/services
|
|
661
731
|
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
732
|
+
* Note: Services are tenant-level entities. This endpoint returns all active services
|
|
733
|
+
* for the slot's tenant with items included. The response uses 'items' property (not 'serviceItems').
|
|
734
|
+
*
|
|
735
|
+
* @param id - Slot ID (UUID)
|
|
736
|
+
* @returns Services with nested items (always includes items, only active services)
|
|
664
737
|
*/
|
|
665
738
|
async getServices(id) {
|
|
666
739
|
const response = await this.client.get(
|