@back23/promptly-sdk 1.1.0 → 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.d.mts CHANGED
@@ -13,6 +13,31 @@ interface ApiResponse<T> {
13
13
  data: T;
14
14
  message?: string;
15
15
  }
16
+ /**
17
+ * Pagination metadata
18
+ */
19
+ interface PaginationMeta {
20
+ current_page: number;
21
+ last_page: number;
22
+ per_page: number;
23
+ total: number;
24
+ from: number | null;
25
+ to: number | null;
26
+ }
27
+ /**
28
+ * Unified list response - ALWAYS returns this structure for list APIs
29
+ * - data is ALWAYS an array (never null/undefined)
30
+ * - meta contains pagination info
31
+ */
32
+ interface ListResponse<T> {
33
+ /** Array of items - guaranteed to be an array (empty if no data) */
34
+ data: T[];
35
+ /** Pagination metadata */
36
+ meta: PaginationMeta;
37
+ }
38
+ /**
39
+ * @deprecated Use ListResponse<T> instead. Kept for backward compatibility.
40
+ */
16
41
  interface PaginatedResponse<T> {
17
42
  data: T[];
18
43
  meta: {
@@ -595,6 +620,110 @@ interface UpdateEntityRecordData {
595
620
  status?: 'active' | 'archived' | 'draft';
596
621
  }
597
622
 
623
+ /**
624
+ * Reservation types for Promptly SDK
625
+ */
626
+ interface ReservationService {
627
+ id: number;
628
+ name: string;
629
+ slug: string;
630
+ description: string | null;
631
+ thumbnail: string | null;
632
+ duration: number;
633
+ price: number;
634
+ requires_staff: boolean;
635
+ requires_payment: boolean;
636
+ deposit: number;
637
+ staffs: ReservationStaffSummary[];
638
+ }
639
+ interface ReservationStaff {
640
+ id: number;
641
+ name: string;
642
+ avatar: string | null;
643
+ bio: string | null;
644
+ }
645
+ interface ReservationStaffSummary {
646
+ id: number;
647
+ name: string;
648
+ avatar: string | null;
649
+ }
650
+ interface ReservationSlot {
651
+ time: string;
652
+ available: boolean;
653
+ staff_id?: number;
654
+ }
655
+ interface ReservationSettings {
656
+ timezone: string;
657
+ slot_interval: number;
658
+ min_notice_hours: number;
659
+ max_advance_days: number;
660
+ cancellation_hours: number;
661
+ allow_online_payment: boolean;
662
+ bookable_date_range: {
663
+ start: string;
664
+ end: string;
665
+ };
666
+ }
667
+ interface Reservation {
668
+ id: number;
669
+ reservation_number: string;
670
+ status: 'pending' | 'confirmed' | 'completed' | 'cancelled' | 'no_show';
671
+ status_label: string;
672
+ reservation_date: string;
673
+ start_time: string;
674
+ end_time: string;
675
+ time_range: string;
676
+ customer_name: string;
677
+ customer_phone: string | null;
678
+ customer_email: string | null;
679
+ price: number;
680
+ deposit: number;
681
+ payment_status: 'pending' | 'paid' | 'refunded' | 'partial';
682
+ payment_status_label: string;
683
+ customer_memo: string | null;
684
+ can_cancel: boolean;
685
+ service: {
686
+ id: number;
687
+ name: string;
688
+ duration: number;
689
+ } | null;
690
+ staff: ReservationStaffSummary | null;
691
+ created_at: string;
692
+ }
693
+ interface CreateReservationData {
694
+ service_id: number;
695
+ staff_id?: number;
696
+ reservation_date: string;
697
+ start_time: string;
698
+ customer_name: string;
699
+ customer_phone?: string;
700
+ customer_email?: string;
701
+ customer_memo?: string;
702
+ }
703
+ interface CreateReservationResult {
704
+ reservation: Reservation;
705
+ requires_payment: boolean;
706
+ deposit: number;
707
+ }
708
+ interface AvailableDatesParams {
709
+ service_id: number;
710
+ staff_id?: number;
711
+ start_date?: string;
712
+ end_date?: string;
713
+ }
714
+ interface AvailableSlotsParams {
715
+ service_id: number;
716
+ date: string;
717
+ staff_id?: number;
718
+ }
719
+ interface ReservationListParams {
720
+ status?: string;
721
+ upcoming?: boolean;
722
+ past?: boolean;
723
+ per_page?: number;
724
+ page?: number;
725
+ }
726
+
598
727
  /**
599
728
  * HTTP Client for Promptly SDK
600
729
  */
@@ -644,6 +773,11 @@ declare class HttpClient {
644
773
  * GET request
645
774
  */
646
775
  get<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
776
+ /**
777
+ * GET request for list endpoints - ALWAYS returns normalized ListResponse
778
+ * Guarantees: data is always an array, meta is always present
779
+ */
780
+ getList<T>(endpoint: string, params?: Record<string, any>): Promise<ListResponse<T>>;
647
781
  /**
648
782
  * POST request
649
783
  */
@@ -740,16 +874,18 @@ declare class BoardsResource {
740
874
  constructor(http: HttpClient);
741
875
  /**
742
876
  * List all boards
877
+ * @returns ListResponse with data array (always defined) and pagination meta
743
878
  */
744
- list(params?: BoardListParams): Promise<Board[]>;
879
+ list(params?: BoardListParams): Promise<ListResponse<Board>>;
745
880
  /**
746
881
  * Get board by ID or slug
747
882
  */
748
883
  get(idOrSlug: number | string): Promise<Board>;
749
884
  /**
750
885
  * List posts in a board
886
+ * @returns ListResponse with data array and pagination meta
751
887
  */
752
- listPosts(boardIdOrSlug: number | string, params?: PostListParams): Promise<PaginatedResponse<BoardPost>>;
888
+ listPosts(boardIdOrSlug: number | string, params?: PostListParams): Promise<ListResponse<BoardPost>>;
753
889
  /**
754
890
  * Get post by ID
755
891
  */
@@ -768,6 +904,7 @@ declare class BoardsResource {
768
904
  deletePost(postId: number): Promise<void>;
769
905
  /**
770
906
  * List comments for a post
907
+ * @returns Array of comments (always an array, never null/undefined)
771
908
  */
772
909
  listComments(postId: number): Promise<BoardComment[]>;
773
910
  /**
@@ -793,8 +930,9 @@ declare class BlogResource {
793
930
  constructor(http: HttpClient);
794
931
  /**
795
932
  * List blog posts
933
+ * @returns ListResponse with data array (always defined) and pagination meta
796
934
  */
797
- list(params?: BlogListParams): Promise<PaginatedResponse<BlogPost>>;
935
+ list(params?: BlogListParams): Promise<ListResponse<BlogPost>>;
798
936
  /**
799
937
  * Get blog post by slug
800
938
  */
@@ -805,26 +943,32 @@ declare class BlogResource {
805
943
  getById(id: number): Promise<BlogPost>;
806
944
  /**
807
945
  * Get featured blog posts
946
+ * @returns Array of featured posts (always an array, never null/undefined)
808
947
  */
809
948
  featured(limit?: number): Promise<BlogPost[]>;
810
949
  /**
811
950
  * Get blog posts by category
951
+ * @returns ListResponse with data array and pagination meta
812
952
  */
813
- byCategory(category: string, params?: Omit<BlogListParams, 'category'>): Promise<PaginatedResponse<BlogPost>>;
953
+ byCategory(category: string, params?: Omit<BlogListParams, 'category'>): Promise<ListResponse<BlogPost>>;
814
954
  /**
815
955
  * Get blog posts by tag
956
+ * @returns ListResponse with data array and pagination meta
816
957
  */
817
- byTag(tag: string, params?: Omit<BlogListParams, 'tag'>): Promise<PaginatedResponse<BlogPost>>;
958
+ byTag(tag: string, params?: Omit<BlogListParams, 'tag'>): Promise<ListResponse<BlogPost>>;
818
959
  /**
819
960
  * Search blog posts
961
+ * @returns ListResponse with data array and pagination meta
820
962
  */
821
- search(query: string, params?: Omit<BlogListParams, 'search'>): Promise<PaginatedResponse<BlogPost>>;
963
+ search(query: string, params?: Omit<BlogListParams, 'search'>): Promise<ListResponse<BlogPost>>;
822
964
  /**
823
965
  * Get blog categories
966
+ * @returns Array of category names (always an array)
824
967
  */
825
968
  categories(): Promise<string[]>;
826
969
  /**
827
970
  * Get blog tags
971
+ * @returns Array of tag names (always an array)
828
972
  */
829
973
  tags(): Promise<string[]>;
830
974
  }
@@ -838,8 +982,9 @@ declare class FormsResource {
838
982
  constructor(http: HttpClient);
839
983
  /**
840
984
  * List all forms
985
+ * @returns ListResponse with data array and pagination meta
841
986
  */
842
- list(params?: FormListParams): Promise<Form[]>;
987
+ list(params?: FormListParams): Promise<ListResponse<Form>>;
843
988
  /**
844
989
  * Get form by ID or slug
845
990
  */
@@ -850,8 +995,9 @@ declare class FormsResource {
850
995
  submit(formIdOrSlug: number | string, data: SubmitFormData): Promise<FormSubmission>;
851
996
  /**
852
997
  * Get my form submissions
998
+ * @returns ListResponse with data array and pagination meta
853
999
  */
854
- mySubmissions(params?: SubmissionListParams): Promise<PaginatedResponse<FormSubmission>>;
1000
+ mySubmissions(params?: SubmissionListParams): Promise<ListResponse<FormSubmission>>;
855
1001
  /**
856
1002
  * Get specific submission
857
1003
  */
@@ -867,22 +1013,26 @@ declare class ShopResource {
867
1013
  constructor(http: HttpClient);
868
1014
  /**
869
1015
  * List products
1016
+ * @returns ListResponse with data array and pagination meta
870
1017
  */
871
- listProducts(params?: ProductListParams): Promise<PaginatedResponse<Product>>;
1018
+ listProducts(params?: ProductListParams): Promise<ListResponse<Product>>;
872
1019
  /**
873
1020
  * Get product by ID or slug
874
1021
  */
875
1022
  getProduct(idOrSlug: number | string): Promise<Product>;
876
1023
  /**
877
1024
  * Get featured products
1025
+ * @returns Array of featured products (always an array)
878
1026
  */
879
1027
  featuredProducts(limit?: number): Promise<Product[]>;
880
1028
  /**
881
1029
  * Search products
1030
+ * @returns ListResponse with data array and pagination meta
882
1031
  */
883
- searchProducts(query: string, params?: Omit<ProductListParams, 'search'>): Promise<PaginatedResponse<Product>>;
1032
+ searchProducts(query: string, params?: Omit<ProductListParams, 'search'>): Promise<ListResponse<Product>>;
884
1033
  /**
885
1034
  * List product categories
1035
+ * @returns Array of categories (always an array)
886
1036
  */
887
1037
  listCategories(): Promise<ProductCategory[]>;
888
1038
  /**
@@ -891,8 +1041,9 @@ declare class ShopResource {
891
1041
  getCategory(idOrSlug: number | string): Promise<ProductCategory>;
892
1042
  /**
893
1043
  * Get products in category
1044
+ * @returns ListResponse with data array and pagination meta
894
1045
  */
895
- categoryProducts(categoryIdOrSlug: number | string, params?: Omit<ProductListParams, 'category'>): Promise<PaginatedResponse<Product>>;
1046
+ categoryProducts(categoryIdOrSlug: number | string, params?: Omit<ProductListParams, 'category'>): Promise<ListResponse<Product>>;
896
1047
  /**
897
1048
  * Get current cart
898
1049
  */
@@ -915,8 +1066,9 @@ declare class ShopResource {
915
1066
  clearCart(): Promise<void>;
916
1067
  /**
917
1068
  * List my orders
1069
+ * @returns ListResponse with data array and pagination meta
918
1070
  */
919
- listOrders(params?: OrderListParams): Promise<PaginatedResponse<Order>>;
1071
+ listOrders(params?: OrderListParams): Promise<ListResponse<Order>>;
920
1072
  /**
921
1073
  * Get order by ID or order number
922
1074
  */
@@ -954,6 +1106,7 @@ declare class ShopResource {
954
1106
  validateCoupon(code: string, orderAmount: number): Promise<CouponValidation>;
955
1107
  /**
956
1108
  * Get available coupons for current user
1109
+ * @returns Array of coupons (always an array)
957
1110
  */
958
1111
  myCoupons(): Promise<Coupon[]>;
959
1112
  }
@@ -990,19 +1143,12 @@ declare class MediaResource {
990
1143
  delete(mediaId: number): Promise<void>;
991
1144
  }
992
1145
 
993
- /**
994
- * Custom Entities Resource for Promptly SDK
995
- *
996
- * Provides access to dynamically created data structures.
997
- * AI can create custom entities through MCP, and this SDK allows
998
- * frontend applications to interact with them.
999
- */
1000
-
1001
1146
  declare class EntitiesResource {
1002
1147
  private http;
1003
1148
  constructor(http: HttpClient);
1004
1149
  /**
1005
1150
  * List all active custom entities
1151
+ * @returns Array of entities (always an array)
1006
1152
  *
1007
1153
  * @example
1008
1154
  * ```typescript
@@ -1023,6 +1169,7 @@ declare class EntitiesResource {
1023
1169
  getSchema(slug: string): Promise<EntitySchema>;
1024
1170
  /**
1025
1171
  * List records for an entity
1172
+ * @returns ListResponse with data array and pagination meta
1026
1173
  *
1027
1174
  * @example
1028
1175
  * ```typescript
@@ -1042,7 +1189,7 @@ declare class EntitiesResource {
1042
1189
  * });
1043
1190
  * ```
1044
1191
  */
1045
- listRecords(slug: string, params?: EntityListParams): Promise<PaginatedResponse<EntityRecord>>;
1192
+ listRecords(slug: string, params?: EntityListParams): Promise<ListResponse<EntityRecord>>;
1046
1193
  /**
1047
1194
  * Get a single record by ID
1048
1195
  *
@@ -1123,18 +1270,7 @@ declare class EntitiesResource {
1123
1270
  data: Array<Omit<EntityRecord, "data"> & {
1124
1271
  data: T;
1125
1272
  }>;
1126
- meta: {
1127
- current_page: number;
1128
- last_page: number;
1129
- per_page: number;
1130
- total: number;
1131
- };
1132
- links?: {
1133
- first: string;
1134
- last: string;
1135
- prev: string | null;
1136
- next: string | null;
1137
- };
1273
+ meta: PaginationMeta;
1138
1274
  }>;
1139
1275
  get: (id: number) => Promise<Omit<EntityRecord, "data"> & {
1140
1276
  data: T;
@@ -1149,6 +1285,71 @@ declare class EntitiesResource {
1149
1285
  };
1150
1286
  }
1151
1287
 
1288
+ /**
1289
+ * Reservation Resource for Promptly SDK
1290
+ */
1291
+
1292
+ declare class ReservationResource {
1293
+ private http;
1294
+ constructor(http: HttpClient);
1295
+ /**
1296
+ * Get reservation settings
1297
+ * @returns Reservation settings for the tenant
1298
+ */
1299
+ getSettings(): Promise<ReservationSettings>;
1300
+ /**
1301
+ * List available services
1302
+ * @returns Array of services (always an array)
1303
+ */
1304
+ listServices(): Promise<ReservationService[]>;
1305
+ /**
1306
+ * List available staff members
1307
+ * @param serviceId - Optional: filter staff by service
1308
+ * @returns Array of staff members (always an array)
1309
+ */
1310
+ listStaff(serviceId?: number): Promise<ReservationStaff[]>;
1311
+ /**
1312
+ * Get available dates for booking
1313
+ * @returns Array of available date strings (YYYY-MM-DD)
1314
+ */
1315
+ getAvailableDates(params: AvailableDatesParams): Promise<string[]>;
1316
+ /**
1317
+ * Get available time slots for a specific date
1318
+ * @returns Array of available slots (always an array)
1319
+ */
1320
+ getAvailableSlots(params: AvailableSlotsParams): Promise<ReservationSlot[]>;
1321
+ /**
1322
+ * Create a new reservation
1323
+ * @returns Created reservation with payment info
1324
+ */
1325
+ create(data: CreateReservationData): Promise<CreateReservationResult>;
1326
+ /**
1327
+ * List my reservations
1328
+ * @returns ListResponse with reservations and pagination meta
1329
+ */
1330
+ list(params?: ReservationListParams): Promise<ListResponse<Reservation>>;
1331
+ /**
1332
+ * Get upcoming reservations
1333
+ * @returns Array of upcoming reservations
1334
+ */
1335
+ upcoming(limit?: number): Promise<Reservation[]>;
1336
+ /**
1337
+ * Get past reservations
1338
+ * @returns Array of past reservations
1339
+ */
1340
+ past(limit?: number): Promise<Reservation[]>;
1341
+ /**
1342
+ * Get reservation by reservation number
1343
+ */
1344
+ get(reservationNumber: string): Promise<Reservation>;
1345
+ /**
1346
+ * Cancel a reservation
1347
+ * @param reservationNumber - Reservation number to cancel
1348
+ * @param reason - Optional cancellation reason
1349
+ */
1350
+ cancel(reservationNumber: string, reason?: string): Promise<Reservation>;
1351
+ }
1352
+
1152
1353
  /**
1153
1354
  * Promptly SDK
1154
1355
  *
@@ -1191,6 +1392,8 @@ declare class Promptly {
1191
1392
  readonly media: MediaResource;
1192
1393
  /** Custom entities - dynamic data structures created by AI */
1193
1394
  readonly entities: EntitiesResource;
1395
+ /** Reservations - booking services and time slots */
1396
+ readonly reservation: ReservationResource;
1194
1397
  constructor(config: PromptlyConfig);
1195
1398
  /**
1196
1399
  * Get site theme settings
@@ -1218,4 +1421,4 @@ declare class Promptly {
1218
1421
  getToken(): string | null;
1219
1422
  }
1220
1423
 
1221
- export { type AddToCartData, type ApiError, type ApiResponse, type ApplyCouponData, type AuthResponse, type BlogListParams, type BlogPost, type Board, type BoardComment, type BoardListParams, type BoardPost, type BoardSettings, type Cart, type CartItem, type Coupon, type CouponType, type CouponValidation, type CreateCommentData, type CreateEntityRecordData, type CreateOrderData, type CreatePostData, type CustomEntity, type EntityField, type EntityListParams, type EntityRecord, type EntitySchema, type ForgotPasswordData, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormListParams, type FormSettings, type FormSubmission, type ListParams, type LoginCredentials, type Media, type Member, type Order, type OrderItem, type OrderListParams, type OrderStatus, type PaginatedResponse, type Payment, type PaymentCancelData, type PaymentConfirmData, type PaymentMethod, type PaymentReadyData, type PaymentStatus, type PostListParams, type Product, type ProductCategory, type ProductListParams, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductVariant, Promptly, type PromptlyConfig, PromptlyError, type RegisterData, type ResetPasswordData, type SocialAuthUrl, type SocialProvider, type SubmissionListParams, type SubmitFormData, type UpdateCartItemData, type UpdateCommentData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
1424
+ export { type AddToCartData, type ApiError, type ApiResponse, type ApplyCouponData, type AuthResponse, type AvailableDatesParams, type AvailableSlotsParams, type BlogListParams, type BlogPost, type Board, type BoardComment, type BoardListParams, type BoardPost, type BoardSettings, type Cart, type CartItem, type Coupon, type CouponType, type CouponValidation, type CreateCommentData, type CreateEntityRecordData, type CreateOrderData, type CreatePostData, type CreateReservationData, type CreateReservationResult, type CustomEntity, type EntityField, type EntityListParams, type EntityRecord, type EntitySchema, type ForgotPasswordData, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormListParams, type FormSettings, type FormSubmission, type ListParams, type ListResponse, type LoginCredentials, type Media, type Member, type Order, type OrderItem, type OrderListParams, type OrderStatus, type PaginatedResponse, type PaginationMeta, type Payment, type PaymentCancelData, type PaymentConfirmData, type PaymentMethod, type PaymentReadyData, type PaymentStatus, type PostListParams, type Product, type ProductCategory, type ProductListParams, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductVariant, Promptly, type PromptlyConfig, PromptlyError, type RegisterData, type Reservation, type ReservationListParams, type ReservationService, type ReservationSettings, type ReservationSlot, type ReservationStaff, type ReservationStaffSummary, type ResetPasswordData, type SocialAuthUrl, type SocialProvider, type SubmissionListParams, type SubmitFormData, type UpdateCartItemData, type UpdateCommentData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };