@slotchain/sdk 1.2.3 → 1.3.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 +36 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.esm.js +36 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/booking-client.ts +51 -1
- package/src/types/api.ts +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -257,6 +257,8 @@ interface FindOrCreateCustomerOptions {
|
|
|
257
257
|
customer_type?: 'individual' | 'organization';
|
|
258
258
|
is_guest?: boolean;
|
|
259
259
|
metadata?: Record<string, unknown>;
|
|
260
|
+
/** IDP user ID (Auth0 sub, Clerk userId, etc.) — if provided, a customer_users row is upserted server-side */
|
|
261
|
+
idp_id?: string;
|
|
260
262
|
}
|
|
261
263
|
interface Flow {
|
|
262
264
|
id: string;
|
|
@@ -598,9 +600,14 @@ declare class BookingClient {
|
|
|
598
600
|
/**
|
|
599
601
|
* Create a new booking (publishes booking.created event)
|
|
600
602
|
* POST /api/v1/bookings
|
|
603
|
+
*
|
|
604
|
+
* Provide either `slot_id` (explicit) or `tenant_id` (auto-resolve).
|
|
605
|
+
* When only `tenant_id` is given the API resolves the first active slot for that tenant,
|
|
606
|
+
* creating a default slot if none exists — so callers never need to manage slot IDs.
|
|
601
607
|
*/
|
|
602
608
|
create(data: {
|
|
603
|
-
slot_id
|
|
609
|
+
slot_id?: string;
|
|
610
|
+
tenant_id?: string;
|
|
604
611
|
customer_info: {
|
|
605
612
|
name: string;
|
|
606
613
|
email: string;
|
|
@@ -613,6 +620,40 @@ declare class BookingClient {
|
|
|
613
620
|
};
|
|
614
621
|
booking_data?: Record<string, unknown>;
|
|
615
622
|
}): Promise<ApiResponse<Booking>>;
|
|
623
|
+
/**
|
|
624
|
+
* Create a booking for a specific service item (job posting, class, product, etc.)
|
|
625
|
+
* without requiring the caller to supply or know a slot ID.
|
|
626
|
+
*
|
|
627
|
+
* The API resolves the correct slot for the tenant automatically, creating a
|
|
628
|
+
* default slot if none exists. This is the preferred method for application flows
|
|
629
|
+
* where slots are an internal infrastructure concern, not a user-facing concept.
|
|
630
|
+
*
|
|
631
|
+
* POST /api/v1/bookings (with tenant_id instead of slot_id)
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* const booking = await slotly.booking.createFromServiceItem({
|
|
636
|
+
* tenantId: 'tenant-123',
|
|
637
|
+
* serviceId: 'service-abc',
|
|
638
|
+
* serviceItemId: 'item-xyz',
|
|
639
|
+
* customerInfo: { name: 'Jane Smith', email: 'jane@example.com' },
|
|
640
|
+
* extraData: { kind: 'job_application', booking_moment: 'submitted' },
|
|
641
|
+
* });
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
createFromServiceItem(data: {
|
|
645
|
+
tenantId: string;
|
|
646
|
+
serviceId: string;
|
|
647
|
+
serviceItemId: string;
|
|
648
|
+
customerInfo: {
|
|
649
|
+
name: string;
|
|
650
|
+
email: string;
|
|
651
|
+
phone?: string;
|
|
652
|
+
isGuestCheckout?: boolean;
|
|
653
|
+
};
|
|
654
|
+
/** Additional fields merged into booking_data alongside service/item IDs */
|
|
655
|
+
extraData?: Record<string, unknown>;
|
|
656
|
+
}): Promise<ApiResponse<Booking>>;
|
|
616
657
|
/**
|
|
617
658
|
* Update booking by ID
|
|
618
659
|
* PUT /api/v1/bookings/:id
|
package/dist/index.d.ts
CHANGED
|
@@ -257,6 +257,8 @@ interface FindOrCreateCustomerOptions {
|
|
|
257
257
|
customer_type?: 'individual' | 'organization';
|
|
258
258
|
is_guest?: boolean;
|
|
259
259
|
metadata?: Record<string, unknown>;
|
|
260
|
+
/** IDP user ID (Auth0 sub, Clerk userId, etc.) — if provided, a customer_users row is upserted server-side */
|
|
261
|
+
idp_id?: string;
|
|
260
262
|
}
|
|
261
263
|
interface Flow {
|
|
262
264
|
id: string;
|
|
@@ -598,9 +600,14 @@ declare class BookingClient {
|
|
|
598
600
|
/**
|
|
599
601
|
* Create a new booking (publishes booking.created event)
|
|
600
602
|
* POST /api/v1/bookings
|
|
603
|
+
*
|
|
604
|
+
* Provide either `slot_id` (explicit) or `tenant_id` (auto-resolve).
|
|
605
|
+
* When only `tenant_id` is given the API resolves the first active slot for that tenant,
|
|
606
|
+
* creating a default slot if none exists — so callers never need to manage slot IDs.
|
|
601
607
|
*/
|
|
602
608
|
create(data: {
|
|
603
|
-
slot_id
|
|
609
|
+
slot_id?: string;
|
|
610
|
+
tenant_id?: string;
|
|
604
611
|
customer_info: {
|
|
605
612
|
name: string;
|
|
606
613
|
email: string;
|
|
@@ -613,6 +620,40 @@ declare class BookingClient {
|
|
|
613
620
|
};
|
|
614
621
|
booking_data?: Record<string, unknown>;
|
|
615
622
|
}): Promise<ApiResponse<Booking>>;
|
|
623
|
+
/**
|
|
624
|
+
* Create a booking for a specific service item (job posting, class, product, etc.)
|
|
625
|
+
* without requiring the caller to supply or know a slot ID.
|
|
626
|
+
*
|
|
627
|
+
* The API resolves the correct slot for the tenant automatically, creating a
|
|
628
|
+
* default slot if none exists. This is the preferred method for application flows
|
|
629
|
+
* where slots are an internal infrastructure concern, not a user-facing concept.
|
|
630
|
+
*
|
|
631
|
+
* POST /api/v1/bookings (with tenant_id instead of slot_id)
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* const booking = await slotly.booking.createFromServiceItem({
|
|
636
|
+
* tenantId: 'tenant-123',
|
|
637
|
+
* serviceId: 'service-abc',
|
|
638
|
+
* serviceItemId: 'item-xyz',
|
|
639
|
+
* customerInfo: { name: 'Jane Smith', email: 'jane@example.com' },
|
|
640
|
+
* extraData: { kind: 'job_application', booking_moment: 'submitted' },
|
|
641
|
+
* });
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
createFromServiceItem(data: {
|
|
645
|
+
tenantId: string;
|
|
646
|
+
serviceId: string;
|
|
647
|
+
serviceItemId: string;
|
|
648
|
+
customerInfo: {
|
|
649
|
+
name: string;
|
|
650
|
+
email: string;
|
|
651
|
+
phone?: string;
|
|
652
|
+
isGuestCheckout?: boolean;
|
|
653
|
+
};
|
|
654
|
+
/** Additional fields merged into booking_data alongside service/item IDs */
|
|
655
|
+
extraData?: Record<string, unknown>;
|
|
656
|
+
}): Promise<ApiResponse<Booking>>;
|
|
616
657
|
/**
|
|
617
658
|
* Update booking by ID
|
|
618
659
|
* PUT /api/v1/bookings/:id
|
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
|