@slotchain/sdk 1.2.4 → 1.4.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.
- package/dist/index.cjs.js +78 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +145 -9
- package/dist/index.d.ts +145 -9
- package/dist/index.esm.js +78 -10
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/booking-client.ts +51 -1
- package/src/clients/slot-client.ts +44 -10
- package/src/index.ts +3 -0
- package/src/types/api.ts +68 -0
package/dist/index.d.mts
CHANGED
|
@@ -160,16 +160,81 @@ interface Service {
|
|
|
160
160
|
created_at: string;
|
|
161
161
|
updated_at: string;
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Metadata bag for a slot — open-ended key/value store, with well-known
|
|
165
|
+
* optional fields for childcare / nursery term-based scheduling.
|
|
166
|
+
*/
|
|
167
|
+
interface SlotMetadata {
|
|
168
|
+
/** Human-readable term name, e.g. "Autumn Term 2024" */
|
|
169
|
+
term_name?: string;
|
|
170
|
+
/** Season identifier, e.g. "autumn" | "spring" | "summer" */
|
|
171
|
+
season?: string;
|
|
172
|
+
/** ISO date string for when the half-term break starts */
|
|
173
|
+
half_term_start?: string;
|
|
174
|
+
/** ISO date string for when the half-term break ends */
|
|
175
|
+
half_term_end?: string;
|
|
176
|
+
/** Maximum number of children / participants in this slot */
|
|
177
|
+
capacity?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Headcount at -2 weeks (used for register generation / staffing).
|
|
180
|
+
* Negative prefix avoids collision with positive operational fields.
|
|
181
|
+
*/
|
|
182
|
+
neg_headcount_neg2?: number;
|
|
183
|
+
/**
|
|
184
|
+
* Headcount at -3 weeks (used for register generation / staffing).
|
|
185
|
+
*/
|
|
186
|
+
neg_headcount_neg3?: number;
|
|
187
|
+
/** Arbitrary additional metadata */
|
|
188
|
+
[key: string]: unknown;
|
|
189
|
+
}
|
|
163
190
|
interface Slot {
|
|
164
191
|
id: string;
|
|
165
192
|
tenant_id: string;
|
|
193
|
+
/** Display name / title of the slot */
|
|
166
194
|
name: string;
|
|
167
195
|
description?: string;
|
|
168
196
|
status?: string;
|
|
169
197
|
is_active?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* ISO 8601 datetime when the slot opens (combines start_date + start_time from the DB).
|
|
200
|
+
* Present when the API serialises scheduled slots.
|
|
201
|
+
*/
|
|
202
|
+
starts_at?: string;
|
|
203
|
+
/**
|
|
204
|
+
* ISO 8601 datetime when the slot closes (combines end_date + end_time from the DB).
|
|
205
|
+
* Absent for open-ended / on-demand slots.
|
|
206
|
+
*/
|
|
207
|
+
ends_at?: string;
|
|
208
|
+
/** Arbitrary metadata bag — see SlotMetadata for well-known keys */
|
|
209
|
+
metadata?: SlotMetadata;
|
|
170
210
|
created_at: string;
|
|
171
211
|
updated_at: string;
|
|
172
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Input shape for creating or updating a slot.
|
|
215
|
+
* Omits server-generated fields; all scheduling fields optional.
|
|
216
|
+
*/
|
|
217
|
+
interface CreateSlotInput {
|
|
218
|
+
name: string;
|
|
219
|
+
description?: string;
|
|
220
|
+
tenant_id: string;
|
|
221
|
+
status?: 'draft' | 'live' | 'archived';
|
|
222
|
+
/**
|
|
223
|
+
* ISO 8601 datetime for when the slot opens.
|
|
224
|
+
* The API splits this into start_date + start_time before persisting.
|
|
225
|
+
*/
|
|
226
|
+
starts_at?: string;
|
|
227
|
+
/**
|
|
228
|
+
* ISO 8601 datetime for when the slot closes.
|
|
229
|
+
* Omit for on-demand / open-ended slots.
|
|
230
|
+
*/
|
|
231
|
+
ends_at?: string;
|
|
232
|
+
metadata?: SlotMetadata;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Partial update shape — all fields optional except id (supplied as path param).
|
|
236
|
+
*/
|
|
237
|
+
type UpdateSlotInput = Partial<Omit<CreateSlotInput, 'tenant_id'>>;
|
|
173
238
|
/**
|
|
174
239
|
* Customer record — matches the `customers` table.
|
|
175
240
|
*/
|
|
@@ -600,9 +665,14 @@ declare class BookingClient {
|
|
|
600
665
|
/**
|
|
601
666
|
* Create a new booking (publishes booking.created event)
|
|
602
667
|
* POST /api/v1/bookings
|
|
668
|
+
*
|
|
669
|
+
* Provide either `slot_id` (explicit) or `tenant_id` (auto-resolve).
|
|
670
|
+
* When only `tenant_id` is given the API resolves the first active slot for that tenant,
|
|
671
|
+
* creating a default slot if none exists — so callers never need to manage slot IDs.
|
|
603
672
|
*/
|
|
604
673
|
create(data: {
|
|
605
|
-
slot_id
|
|
674
|
+
slot_id?: string;
|
|
675
|
+
tenant_id?: string;
|
|
606
676
|
customer_info: {
|
|
607
677
|
name: string;
|
|
608
678
|
email: string;
|
|
@@ -615,6 +685,40 @@ declare class BookingClient {
|
|
|
615
685
|
};
|
|
616
686
|
booking_data?: Record<string, unknown>;
|
|
617
687
|
}): Promise<ApiResponse<Booking>>;
|
|
688
|
+
/**
|
|
689
|
+
* Create a booking for a specific service item (job posting, class, product, etc.)
|
|
690
|
+
* without requiring the caller to supply or know a slot ID.
|
|
691
|
+
*
|
|
692
|
+
* The API resolves the correct slot for the tenant automatically, creating a
|
|
693
|
+
* default slot if none exists. This is the preferred method for application flows
|
|
694
|
+
* where slots are an internal infrastructure concern, not a user-facing concept.
|
|
695
|
+
*
|
|
696
|
+
* POST /api/v1/bookings (with tenant_id instead of slot_id)
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* ```typescript
|
|
700
|
+
* const booking = await slotly.booking.createFromServiceItem({
|
|
701
|
+
* tenantId: 'tenant-123',
|
|
702
|
+
* serviceId: 'service-abc',
|
|
703
|
+
* serviceItemId: 'item-xyz',
|
|
704
|
+
* customerInfo: { name: 'Jane Smith', email: 'jane@example.com' },
|
|
705
|
+
* extraData: { kind: 'job_application', booking_moment: 'submitted' },
|
|
706
|
+
* });
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
createFromServiceItem(data: {
|
|
710
|
+
tenantId: string;
|
|
711
|
+
serviceId: string;
|
|
712
|
+
serviceItemId: string;
|
|
713
|
+
customerInfo: {
|
|
714
|
+
name: string;
|
|
715
|
+
email: string;
|
|
716
|
+
phone?: string;
|
|
717
|
+
isGuestCheckout?: boolean;
|
|
718
|
+
};
|
|
719
|
+
/** Additional fields merged into booking_data alongside service/item IDs */
|
|
720
|
+
extraData?: Record<string, unknown>;
|
|
721
|
+
}): Promise<ApiResponse<Booking>>;
|
|
618
722
|
/**
|
|
619
723
|
* Update booking by ID
|
|
620
724
|
* PUT /api/v1/bookings/:id
|
|
@@ -884,19 +988,41 @@ declare class SlotClient {
|
|
|
884
988
|
limit?: number;
|
|
885
989
|
}): Promise<ApiResponse<Slot[]>>;
|
|
886
990
|
/**
|
|
887
|
-
* Create a new slot
|
|
991
|
+
* Create a new slot.
|
|
888
992
|
* POST /api/v1/slots
|
|
889
993
|
*
|
|
890
|
-
*
|
|
994
|
+
* Accepts any subset of `Slot` fields. For new integrations, prefer the
|
|
995
|
+
* exported `CreateSlotInput` type which documents the recommended shape
|
|
996
|
+
* and will become the enforced signature in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
997
|
+
*
|
|
998
|
+
* New fields available as of v1.4:
|
|
999
|
+
* - `starts_at` — ISO 8601 datetime when the slot opens
|
|
1000
|
+
* - `ends_at` — ISO 8601 datetime when the slot closes (omit for open-ended slots)
|
|
1001
|
+
* - `metadata` — term enrichment bag (term_name, season, half_term_start,
|
|
1002
|
+
* half_term_end, capacity); see `SlotMetadata` type
|
|
1003
|
+
*
|
|
1004
|
+
* @param data - Slot creation data
|
|
891
1005
|
* @returns Created slot
|
|
1006
|
+
*
|
|
1007
|
+
* @example
|
|
1008
|
+
* // Recommended — opt into stricter typing now:
|
|
1009
|
+
* import { CreateSlotInput } from '@slotly/sdk';
|
|
1010
|
+
* const input: CreateSlotInput = { name: 'Autumn Term', tenant_id: '...', starts_at: '...' };
|
|
1011
|
+
* sdk.slots.create(input);
|
|
892
1012
|
*/
|
|
893
1013
|
create(data: Partial<Slot>): Promise<ApiResponse<Slot>>;
|
|
894
1014
|
/**
|
|
895
|
-
* Update slot by ID
|
|
1015
|
+
* Update slot by ID.
|
|
896
1016
|
* PUT /api/v1/slots/:id
|
|
897
1017
|
*
|
|
898
|
-
*
|
|
899
|
-
*
|
|
1018
|
+
* Accepts any subset of `Slot` fields. For new integrations, prefer the
|
|
1019
|
+
* exported `UpdateSlotInput` type — it will become the enforced signature
|
|
1020
|
+
* in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
1021
|
+
*
|
|
1022
|
+
* New fields available as of v1.4: `starts_at`, `ends_at`, `metadata`.
|
|
1023
|
+
*
|
|
1024
|
+
* @param id - Slot ID
|
|
1025
|
+
* @param data - Fields to update
|
|
900
1026
|
* @returns Updated slot
|
|
901
1027
|
*/
|
|
902
1028
|
update(id: string, data: Partial<Slot>): Promise<ApiResponse<Slot>>;
|
|
@@ -915,10 +1041,20 @@ declare class SlotClient {
|
|
|
915
1041
|
* @param slots - Array of slots to create
|
|
916
1042
|
* @returns Created slots
|
|
917
1043
|
*/
|
|
1044
|
+
/**
|
|
1045
|
+
* Bulk create slots.
|
|
1046
|
+
* POST /api/v1/slots/bulk
|
|
1047
|
+
*
|
|
1048
|
+
* For new integrations, prefer passing `CreateSlotInput[]` — it will become
|
|
1049
|
+
* the enforced signature in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
1050
|
+
*/
|
|
918
1051
|
bulkCreate(slots: Partial<Slot>[]): Promise<ApiResponse<Slot[]>>;
|
|
919
1052
|
/**
|
|
920
|
-
* Mark slot as available
|
|
921
|
-
*
|
|
1053
|
+
* Mark slot as available (live) or unavailable (archived).
|
|
1054
|
+
*
|
|
1055
|
+
* Note: previous versions sent 'active'/'inactive' which were not valid DB
|
|
1056
|
+
* enum values. Fixed in v1.4 to use 'live'/'archived' — the only valid
|
|
1057
|
+
* non-draft statuses. If you need 'draft', use update() directly.
|
|
922
1058
|
*/
|
|
923
1059
|
setAvailability(id: string, available: boolean): Promise<ApiResponse<Slot>>;
|
|
924
1060
|
/**
|
|
@@ -1657,4 +1793,4 @@ interface SlotlyApi {
|
|
|
1657
1793
|
*/
|
|
1658
1794
|
declare const useSlotly: (options: SlotlyClientOptions) => SlotlyApi;
|
|
1659
1795
|
|
|
1660
|
-
export { type ApiResponse, type Artifact, type ArtifactEntityType, type ArtifactMimeCategory, type ArtifactWithUrl, type Booking, type BookingWithSlot, type Category, type Customer, type CustomerIdentity, type CustomerWithBookings, type CustomerWithIdentities, type DataQualityIssue, type FindOrCreateCustomerOptions, type Flow, type FlowStep, type GetOrganizationOptions, type ListArtifactsOptions, type ListBookingsOptions, type Notification, type NotificationPreferences, type Organization, type OrganizationFullConfig, type ResolveCustomerOptions, 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, type UploadArtifactOptions, useSlotly as default, getSlotlyContext, useSlotly, validateSlotlyRequest };
|
|
1796
|
+
export { type ApiResponse, type Artifact, type ArtifactEntityType, type ArtifactMimeCategory, type ArtifactWithUrl, type Booking, type BookingWithSlot, type Category, type CreateSlotInput, type Customer, type CustomerIdentity, type CustomerWithBookings, type CustomerWithIdentities, type DataQualityIssue, type FindOrCreateCustomerOptions, type Flow, type FlowStep, type GetOrganizationOptions, type ListArtifactsOptions, type ListBookingsOptions, type Notification, type NotificationPreferences, type Organization, type OrganizationFullConfig, type ResolveCustomerOptions, type Service, type ServiceItem, type ServiceItemWithService, type ServiceWithItems, type Slot, type SlotMetadata, type SlotServiceWithItems, type SlotlyApi, SlotlyApiError, type SlotlyAuthContext, SlotlyAuthError, type SlotlyClientOptions, SlotlyConfigurationError, SlotlyNetworkError, type SlotlyRequest, type Studio, type Tenant, type TenantBranding, type TenantFullConfig, type UpdateSlotInput, type UploadArtifactOptions, useSlotly as default, getSlotlyContext, useSlotly, validateSlotlyRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -160,16 +160,81 @@ interface Service {
|
|
|
160
160
|
created_at: string;
|
|
161
161
|
updated_at: string;
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Metadata bag for a slot — open-ended key/value store, with well-known
|
|
165
|
+
* optional fields for childcare / nursery term-based scheduling.
|
|
166
|
+
*/
|
|
167
|
+
interface SlotMetadata {
|
|
168
|
+
/** Human-readable term name, e.g. "Autumn Term 2024" */
|
|
169
|
+
term_name?: string;
|
|
170
|
+
/** Season identifier, e.g. "autumn" | "spring" | "summer" */
|
|
171
|
+
season?: string;
|
|
172
|
+
/** ISO date string for when the half-term break starts */
|
|
173
|
+
half_term_start?: string;
|
|
174
|
+
/** ISO date string for when the half-term break ends */
|
|
175
|
+
half_term_end?: string;
|
|
176
|
+
/** Maximum number of children / participants in this slot */
|
|
177
|
+
capacity?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Headcount at -2 weeks (used for register generation / staffing).
|
|
180
|
+
* Negative prefix avoids collision with positive operational fields.
|
|
181
|
+
*/
|
|
182
|
+
neg_headcount_neg2?: number;
|
|
183
|
+
/**
|
|
184
|
+
* Headcount at -3 weeks (used for register generation / staffing).
|
|
185
|
+
*/
|
|
186
|
+
neg_headcount_neg3?: number;
|
|
187
|
+
/** Arbitrary additional metadata */
|
|
188
|
+
[key: string]: unknown;
|
|
189
|
+
}
|
|
163
190
|
interface Slot {
|
|
164
191
|
id: string;
|
|
165
192
|
tenant_id: string;
|
|
193
|
+
/** Display name / title of the slot */
|
|
166
194
|
name: string;
|
|
167
195
|
description?: string;
|
|
168
196
|
status?: string;
|
|
169
197
|
is_active?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* ISO 8601 datetime when the slot opens (combines start_date + start_time from the DB).
|
|
200
|
+
* Present when the API serialises scheduled slots.
|
|
201
|
+
*/
|
|
202
|
+
starts_at?: string;
|
|
203
|
+
/**
|
|
204
|
+
* ISO 8601 datetime when the slot closes (combines end_date + end_time from the DB).
|
|
205
|
+
* Absent for open-ended / on-demand slots.
|
|
206
|
+
*/
|
|
207
|
+
ends_at?: string;
|
|
208
|
+
/** Arbitrary metadata bag — see SlotMetadata for well-known keys */
|
|
209
|
+
metadata?: SlotMetadata;
|
|
170
210
|
created_at: string;
|
|
171
211
|
updated_at: string;
|
|
172
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Input shape for creating or updating a slot.
|
|
215
|
+
* Omits server-generated fields; all scheduling fields optional.
|
|
216
|
+
*/
|
|
217
|
+
interface CreateSlotInput {
|
|
218
|
+
name: string;
|
|
219
|
+
description?: string;
|
|
220
|
+
tenant_id: string;
|
|
221
|
+
status?: 'draft' | 'live' | 'archived';
|
|
222
|
+
/**
|
|
223
|
+
* ISO 8601 datetime for when the slot opens.
|
|
224
|
+
* The API splits this into start_date + start_time before persisting.
|
|
225
|
+
*/
|
|
226
|
+
starts_at?: string;
|
|
227
|
+
/**
|
|
228
|
+
* ISO 8601 datetime for when the slot closes.
|
|
229
|
+
* Omit for on-demand / open-ended slots.
|
|
230
|
+
*/
|
|
231
|
+
ends_at?: string;
|
|
232
|
+
metadata?: SlotMetadata;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Partial update shape — all fields optional except id (supplied as path param).
|
|
236
|
+
*/
|
|
237
|
+
type UpdateSlotInput = Partial<Omit<CreateSlotInput, 'tenant_id'>>;
|
|
173
238
|
/**
|
|
174
239
|
* Customer record — matches the `customers` table.
|
|
175
240
|
*/
|
|
@@ -600,9 +665,14 @@ declare class BookingClient {
|
|
|
600
665
|
/**
|
|
601
666
|
* Create a new booking (publishes booking.created event)
|
|
602
667
|
* POST /api/v1/bookings
|
|
668
|
+
*
|
|
669
|
+
* Provide either `slot_id` (explicit) or `tenant_id` (auto-resolve).
|
|
670
|
+
* When only `tenant_id` is given the API resolves the first active slot for that tenant,
|
|
671
|
+
* creating a default slot if none exists — so callers never need to manage slot IDs.
|
|
603
672
|
*/
|
|
604
673
|
create(data: {
|
|
605
|
-
slot_id
|
|
674
|
+
slot_id?: string;
|
|
675
|
+
tenant_id?: string;
|
|
606
676
|
customer_info: {
|
|
607
677
|
name: string;
|
|
608
678
|
email: string;
|
|
@@ -615,6 +685,40 @@ declare class BookingClient {
|
|
|
615
685
|
};
|
|
616
686
|
booking_data?: Record<string, unknown>;
|
|
617
687
|
}): Promise<ApiResponse<Booking>>;
|
|
688
|
+
/**
|
|
689
|
+
* Create a booking for a specific service item (job posting, class, product, etc.)
|
|
690
|
+
* without requiring the caller to supply or know a slot ID.
|
|
691
|
+
*
|
|
692
|
+
* The API resolves the correct slot for the tenant automatically, creating a
|
|
693
|
+
* default slot if none exists. This is the preferred method for application flows
|
|
694
|
+
* where slots are an internal infrastructure concern, not a user-facing concept.
|
|
695
|
+
*
|
|
696
|
+
* POST /api/v1/bookings (with tenant_id instead of slot_id)
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* ```typescript
|
|
700
|
+
* const booking = await slotly.booking.createFromServiceItem({
|
|
701
|
+
* tenantId: 'tenant-123',
|
|
702
|
+
* serviceId: 'service-abc',
|
|
703
|
+
* serviceItemId: 'item-xyz',
|
|
704
|
+
* customerInfo: { name: 'Jane Smith', email: 'jane@example.com' },
|
|
705
|
+
* extraData: { kind: 'job_application', booking_moment: 'submitted' },
|
|
706
|
+
* });
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
createFromServiceItem(data: {
|
|
710
|
+
tenantId: string;
|
|
711
|
+
serviceId: string;
|
|
712
|
+
serviceItemId: string;
|
|
713
|
+
customerInfo: {
|
|
714
|
+
name: string;
|
|
715
|
+
email: string;
|
|
716
|
+
phone?: string;
|
|
717
|
+
isGuestCheckout?: boolean;
|
|
718
|
+
};
|
|
719
|
+
/** Additional fields merged into booking_data alongside service/item IDs */
|
|
720
|
+
extraData?: Record<string, unknown>;
|
|
721
|
+
}): Promise<ApiResponse<Booking>>;
|
|
618
722
|
/**
|
|
619
723
|
* Update booking by ID
|
|
620
724
|
* PUT /api/v1/bookings/:id
|
|
@@ -884,19 +988,41 @@ declare class SlotClient {
|
|
|
884
988
|
limit?: number;
|
|
885
989
|
}): Promise<ApiResponse<Slot[]>>;
|
|
886
990
|
/**
|
|
887
|
-
* Create a new slot
|
|
991
|
+
* Create a new slot.
|
|
888
992
|
* POST /api/v1/slots
|
|
889
993
|
*
|
|
890
|
-
*
|
|
994
|
+
* Accepts any subset of `Slot` fields. For new integrations, prefer the
|
|
995
|
+
* exported `CreateSlotInput` type which documents the recommended shape
|
|
996
|
+
* and will become the enforced signature in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
997
|
+
*
|
|
998
|
+
* New fields available as of v1.4:
|
|
999
|
+
* - `starts_at` — ISO 8601 datetime when the slot opens
|
|
1000
|
+
* - `ends_at` — ISO 8601 datetime when the slot closes (omit for open-ended slots)
|
|
1001
|
+
* - `metadata` — term enrichment bag (term_name, season, half_term_start,
|
|
1002
|
+
* half_term_end, capacity); see `SlotMetadata` type
|
|
1003
|
+
*
|
|
1004
|
+
* @param data - Slot creation data
|
|
891
1005
|
* @returns Created slot
|
|
1006
|
+
*
|
|
1007
|
+
* @example
|
|
1008
|
+
* // Recommended — opt into stricter typing now:
|
|
1009
|
+
* import { CreateSlotInput } from '@slotly/sdk';
|
|
1010
|
+
* const input: CreateSlotInput = { name: 'Autumn Term', tenant_id: '...', starts_at: '...' };
|
|
1011
|
+
* sdk.slots.create(input);
|
|
892
1012
|
*/
|
|
893
1013
|
create(data: Partial<Slot>): Promise<ApiResponse<Slot>>;
|
|
894
1014
|
/**
|
|
895
|
-
* Update slot by ID
|
|
1015
|
+
* Update slot by ID.
|
|
896
1016
|
* PUT /api/v1/slots/:id
|
|
897
1017
|
*
|
|
898
|
-
*
|
|
899
|
-
*
|
|
1018
|
+
* Accepts any subset of `Slot` fields. For new integrations, prefer the
|
|
1019
|
+
* exported `UpdateSlotInput` type — it will become the enforced signature
|
|
1020
|
+
* in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
1021
|
+
*
|
|
1022
|
+
* New fields available as of v1.4: `starts_at`, `ends_at`, `metadata`.
|
|
1023
|
+
*
|
|
1024
|
+
* @param id - Slot ID
|
|
1025
|
+
* @param data - Fields to update
|
|
900
1026
|
* @returns Updated slot
|
|
901
1027
|
*/
|
|
902
1028
|
update(id: string, data: Partial<Slot>): Promise<ApiResponse<Slot>>;
|
|
@@ -915,10 +1041,20 @@ declare class SlotClient {
|
|
|
915
1041
|
* @param slots - Array of slots to create
|
|
916
1042
|
* @returns Created slots
|
|
917
1043
|
*/
|
|
1044
|
+
/**
|
|
1045
|
+
* Bulk create slots.
|
|
1046
|
+
* POST /api/v1/slots/bulk
|
|
1047
|
+
*
|
|
1048
|
+
* For new integrations, prefer passing `CreateSlotInput[]` — it will become
|
|
1049
|
+
* the enforced signature in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
1050
|
+
*/
|
|
918
1051
|
bulkCreate(slots: Partial<Slot>[]): Promise<ApiResponse<Slot[]>>;
|
|
919
1052
|
/**
|
|
920
|
-
* Mark slot as available
|
|
921
|
-
*
|
|
1053
|
+
* Mark slot as available (live) or unavailable (archived).
|
|
1054
|
+
*
|
|
1055
|
+
* Note: previous versions sent 'active'/'inactive' which were not valid DB
|
|
1056
|
+
* enum values. Fixed in v1.4 to use 'live'/'archived' — the only valid
|
|
1057
|
+
* non-draft statuses. If you need 'draft', use update() directly.
|
|
922
1058
|
*/
|
|
923
1059
|
setAvailability(id: string, available: boolean): Promise<ApiResponse<Slot>>;
|
|
924
1060
|
/**
|
|
@@ -1657,4 +1793,4 @@ interface SlotlyApi {
|
|
|
1657
1793
|
*/
|
|
1658
1794
|
declare const useSlotly: (options: SlotlyClientOptions) => SlotlyApi;
|
|
1659
1795
|
|
|
1660
|
-
export { type ApiResponse, type Artifact, type ArtifactEntityType, type ArtifactMimeCategory, type ArtifactWithUrl, type Booking, type BookingWithSlot, type Category, type Customer, type CustomerIdentity, type CustomerWithBookings, type CustomerWithIdentities, type DataQualityIssue, type FindOrCreateCustomerOptions, type Flow, type FlowStep, type GetOrganizationOptions, type ListArtifactsOptions, type ListBookingsOptions, type Notification, type NotificationPreferences, type Organization, type OrganizationFullConfig, type ResolveCustomerOptions, 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, type UploadArtifactOptions, useSlotly as default, getSlotlyContext, useSlotly, validateSlotlyRequest };
|
|
1796
|
+
export { type ApiResponse, type Artifact, type ArtifactEntityType, type ArtifactMimeCategory, type ArtifactWithUrl, type Booking, type BookingWithSlot, type Category, type CreateSlotInput, type Customer, type CustomerIdentity, type CustomerWithBookings, type CustomerWithIdentities, type DataQualityIssue, type FindOrCreateCustomerOptions, type Flow, type FlowStep, type GetOrganizationOptions, type ListArtifactsOptions, type ListBookingsOptions, type Notification, type NotificationPreferences, type Organization, type OrganizationFullConfig, type ResolveCustomerOptions, type Service, type ServiceItem, type ServiceItemWithService, type ServiceWithItems, type Slot, type SlotMetadata, type SlotServiceWithItems, type SlotlyApi, SlotlyApiError, type SlotlyAuthContext, SlotlyAuthError, type SlotlyClientOptions, SlotlyConfigurationError, SlotlyNetworkError, type SlotlyRequest, type Studio, type Tenant, type TenantBranding, type TenantFullConfig, type UpdateSlotInput, type UploadArtifactOptions, useSlotly as default, getSlotlyContext, useSlotly, validateSlotlyRequest };
|
package/dist/index.esm.js
CHANGED
|
@@ -265,6 +265,10 @@ var BookingClient = class {
|
|
|
265
265
|
/**
|
|
266
266
|
* Create a new booking (publishes booking.created event)
|
|
267
267
|
* POST /api/v1/bookings
|
|
268
|
+
*
|
|
269
|
+
* Provide either `slot_id` (explicit) or `tenant_id` (auto-resolve).
|
|
270
|
+
* When only `tenant_id` is given the API resolves the first active slot for that tenant,
|
|
271
|
+
* creating a default slot if none exists — so callers never need to manage slot IDs.
|
|
268
272
|
*/
|
|
269
273
|
async create(data) {
|
|
270
274
|
const response = await this.client.post(
|
|
@@ -273,6 +277,38 @@ var BookingClient = class {
|
|
|
273
277
|
);
|
|
274
278
|
return response.data;
|
|
275
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Create a booking for a specific service item (job posting, class, product, etc.)
|
|
282
|
+
* without requiring the caller to supply or know a slot ID.
|
|
283
|
+
*
|
|
284
|
+
* The API resolves the correct slot for the tenant automatically, creating a
|
|
285
|
+
* default slot if none exists. This is the preferred method for application flows
|
|
286
|
+
* where slots are an internal infrastructure concern, not a user-facing concept.
|
|
287
|
+
*
|
|
288
|
+
* POST /api/v1/bookings (with tenant_id instead of slot_id)
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* const booking = await slotly.booking.createFromServiceItem({
|
|
293
|
+
* tenantId: 'tenant-123',
|
|
294
|
+
* serviceId: 'service-abc',
|
|
295
|
+
* serviceItemId: 'item-xyz',
|
|
296
|
+
* customerInfo: { name: 'Jane Smith', email: 'jane@example.com' },
|
|
297
|
+
* extraData: { kind: 'job_application', booking_moment: 'submitted' },
|
|
298
|
+
* });
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
async createFromServiceItem(data) {
|
|
302
|
+
return this.create({
|
|
303
|
+
tenant_id: data.tenantId,
|
|
304
|
+
customer_info: data.customerInfo,
|
|
305
|
+
booking_data: {
|
|
306
|
+
service_id: data.serviceId,
|
|
307
|
+
service_item_id: data.serviceItemId,
|
|
308
|
+
...data.extraData
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
276
312
|
/**
|
|
277
313
|
* Update booking by ID
|
|
278
314
|
* PUT /api/v1/bookings/:id
|
|
@@ -663,11 +699,27 @@ var SlotClient = class {
|
|
|
663
699
|
return response.data;
|
|
664
700
|
}
|
|
665
701
|
/**
|
|
666
|
-
* Create a new slot
|
|
702
|
+
* Create a new slot.
|
|
667
703
|
* POST /api/v1/slots
|
|
668
|
-
*
|
|
669
|
-
*
|
|
704
|
+
*
|
|
705
|
+
* Accepts any subset of `Slot` fields. For new integrations, prefer the
|
|
706
|
+
* exported `CreateSlotInput` type which documents the recommended shape
|
|
707
|
+
* and will become the enforced signature in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
708
|
+
*
|
|
709
|
+
* New fields available as of v1.4:
|
|
710
|
+
* - `starts_at` — ISO 8601 datetime when the slot opens
|
|
711
|
+
* - `ends_at` — ISO 8601 datetime when the slot closes (omit for open-ended slots)
|
|
712
|
+
* - `metadata` — term enrichment bag (term_name, season, half_term_start,
|
|
713
|
+
* half_term_end, capacity); see `SlotMetadata` type
|
|
714
|
+
*
|
|
715
|
+
* @param data - Slot creation data
|
|
670
716
|
* @returns Created slot
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* // Recommended — opt into stricter typing now:
|
|
720
|
+
* import { CreateSlotInput } from '@slotly/sdk';
|
|
721
|
+
* const input: CreateSlotInput = { name: 'Autumn Term', tenant_id: '...', starts_at: '...' };
|
|
722
|
+
* sdk.slots.create(input);
|
|
671
723
|
*/
|
|
672
724
|
async create(data) {
|
|
673
725
|
const response = await this.client.post(
|
|
@@ -677,11 +729,17 @@ var SlotClient = class {
|
|
|
677
729
|
return response.data;
|
|
678
730
|
}
|
|
679
731
|
/**
|
|
680
|
-
* Update slot by ID
|
|
732
|
+
* Update slot by ID.
|
|
681
733
|
* PUT /api/v1/slots/:id
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
*
|
|
734
|
+
*
|
|
735
|
+
* Accepts any subset of `Slot` fields. For new integrations, prefer the
|
|
736
|
+
* exported `UpdateSlotInput` type — it will become the enforced signature
|
|
737
|
+
* in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
738
|
+
*
|
|
739
|
+
* New fields available as of v1.4: `starts_at`, `ends_at`, `metadata`.
|
|
740
|
+
*
|
|
741
|
+
* @param id - Slot ID
|
|
742
|
+
* @param data - Fields to update
|
|
685
743
|
* @returns Updated slot
|
|
686
744
|
*/
|
|
687
745
|
async update(id, data) {
|
|
@@ -711,6 +769,13 @@ var SlotClient = class {
|
|
|
711
769
|
* @param slots - Array of slots to create
|
|
712
770
|
* @returns Created slots
|
|
713
771
|
*/
|
|
772
|
+
/**
|
|
773
|
+
* Bulk create slots.
|
|
774
|
+
* POST /api/v1/slots/bulk
|
|
775
|
+
*
|
|
776
|
+
* For new integrations, prefer passing `CreateSlotInput[]` — it will become
|
|
777
|
+
* the enforced signature in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
|
|
778
|
+
*/
|
|
714
779
|
async bulkCreate(slots) {
|
|
715
780
|
const response = await this.client.post(
|
|
716
781
|
"/api/v1/slots/bulk",
|
|
@@ -719,11 +784,14 @@ var SlotClient = class {
|
|
|
719
784
|
return response.data;
|
|
720
785
|
}
|
|
721
786
|
/**
|
|
722
|
-
* Mark slot as available
|
|
723
|
-
*
|
|
787
|
+
* Mark slot as available (live) or unavailable (archived).
|
|
788
|
+
*
|
|
789
|
+
* Note: previous versions sent 'active'/'inactive' which were not valid DB
|
|
790
|
+
* enum values. Fixed in v1.4 to use 'live'/'archived' — the only valid
|
|
791
|
+
* non-draft statuses. If you need 'draft', use update() directly.
|
|
724
792
|
*/
|
|
725
793
|
async setAvailability(id, available) {
|
|
726
|
-
return this.update(id, { status: available ? "
|
|
794
|
+
return this.update(id, { status: available ? "live" : "archived" });
|
|
727
795
|
}
|
|
728
796
|
/**
|
|
729
797
|
* Get all active services for a slot with their items
|