@back23/promptly-sdk 1.1.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.
@@ -0,0 +1,1221 @@
1
+ /**
2
+ * Common types for Promptly SDK
3
+ */
4
+ interface PromptlyConfig {
5
+ /** Tenant ID (subdomain) */
6
+ tenantId: string;
7
+ /** Base URL of Promptly API */
8
+ baseUrl?: string;
9
+ /** Request timeout in milliseconds */
10
+ timeout?: number;
11
+ }
12
+ interface ApiResponse<T> {
13
+ data: T;
14
+ message?: string;
15
+ }
16
+ interface PaginatedResponse<T> {
17
+ data: T[];
18
+ meta: {
19
+ current_page: number;
20
+ last_page: number;
21
+ per_page: number;
22
+ total: number;
23
+ };
24
+ links?: {
25
+ first: string;
26
+ last: string;
27
+ prev: string | null;
28
+ next: string | null;
29
+ };
30
+ }
31
+ interface ListParams {
32
+ page?: number;
33
+ per_page?: number;
34
+ sort?: string;
35
+ order?: 'asc' | 'desc';
36
+ }
37
+ interface ApiError {
38
+ message: string;
39
+ errors?: Record<string, string[]>;
40
+ status?: number;
41
+ }
42
+ interface Media {
43
+ id: number;
44
+ url: string;
45
+ thumbnail_url?: string;
46
+ filename: string;
47
+ mime_type: string;
48
+ size: number;
49
+ created_at: string;
50
+ }
51
+
52
+ /**
53
+ * Auth types for Promptly SDK
54
+ */
55
+ interface LoginCredentials {
56
+ email: string;
57
+ password: string;
58
+ }
59
+ interface RegisterData {
60
+ name: string;
61
+ email: string;
62
+ password: string;
63
+ password_confirmation: string;
64
+ phone?: string;
65
+ }
66
+ interface Member {
67
+ id: number;
68
+ name: string;
69
+ email: string;
70
+ phone?: string;
71
+ avatar?: string;
72
+ is_active: boolean;
73
+ created_at: string;
74
+ updated_at: string;
75
+ }
76
+ interface AuthResponse {
77
+ member: Member;
78
+ token: string;
79
+ token_type: string;
80
+ }
81
+ interface ForgotPasswordData {
82
+ email: string;
83
+ }
84
+ interface ResetPasswordData {
85
+ email: string;
86
+ token: string;
87
+ password: string;
88
+ password_confirmation: string;
89
+ }
90
+ interface SocialProvider {
91
+ name: string;
92
+ enabled: boolean;
93
+ }
94
+ interface SocialAuthUrl {
95
+ url: string;
96
+ provider: string;
97
+ }
98
+ interface UpdateProfileData {
99
+ name?: string;
100
+ phone?: string;
101
+ avatar?: string;
102
+ current_password?: string;
103
+ password?: string;
104
+ password_confirmation?: string;
105
+ }
106
+
107
+ /**
108
+ * Board types for Promptly SDK
109
+ */
110
+
111
+ interface Board {
112
+ id: number;
113
+ slug: string;
114
+ name: string;
115
+ description?: string;
116
+ settings: BoardSettings;
117
+ posts_count?: number;
118
+ created_at: string;
119
+ updated_at: string;
120
+ }
121
+ interface BoardSettings {
122
+ allow_comments: boolean;
123
+ allow_attachments: boolean;
124
+ require_login_to_view: boolean;
125
+ require_login_to_write: boolean;
126
+ posts_per_page: number;
127
+ }
128
+ interface BoardPost {
129
+ id: number;
130
+ board_id: number;
131
+ board?: Board;
132
+ member_id?: number;
133
+ member?: Member;
134
+ title: string;
135
+ content: string;
136
+ excerpt?: string;
137
+ is_notice: boolean;
138
+ is_private: boolean;
139
+ view_count: number;
140
+ comment_count: number;
141
+ attachments?: Media[];
142
+ created_at: string;
143
+ updated_at: string;
144
+ }
145
+ interface BoardComment {
146
+ id: number;
147
+ post_id: number;
148
+ member_id?: number;
149
+ member?: Member;
150
+ parent_id?: number;
151
+ content: string;
152
+ replies?: BoardComment[];
153
+ created_at: string;
154
+ updated_at: string;
155
+ }
156
+ interface BoardListParams extends ListParams {
157
+ }
158
+ interface PostListParams extends ListParams {
159
+ search?: string;
160
+ is_notice?: boolean;
161
+ }
162
+ interface CreatePostData {
163
+ board_id: number;
164
+ title: string;
165
+ content: string;
166
+ is_notice?: boolean;
167
+ is_private?: boolean;
168
+ attachments?: number[];
169
+ }
170
+ interface UpdatePostData {
171
+ title?: string;
172
+ content?: string;
173
+ is_notice?: boolean;
174
+ is_private?: boolean;
175
+ attachments?: number[];
176
+ }
177
+ interface CreateCommentData {
178
+ content: string;
179
+ parent_id?: number;
180
+ }
181
+ interface UpdateCommentData {
182
+ content: string;
183
+ }
184
+
185
+ /**
186
+ * Blog types for Promptly SDK
187
+ */
188
+
189
+ interface BlogPost {
190
+ id: number;
191
+ slug: string;
192
+ title: string;
193
+ content: string;
194
+ excerpt?: string;
195
+ featured_image?: string;
196
+ category?: string;
197
+ tags?: string[];
198
+ author_name?: string;
199
+ is_published: boolean;
200
+ published_at?: string;
201
+ view_count: number;
202
+ seo_title?: string;
203
+ seo_description?: string;
204
+ created_at: string;
205
+ updated_at: string;
206
+ }
207
+ interface BlogListParams extends ListParams {
208
+ category?: string;
209
+ tag?: string;
210
+ search?: string;
211
+ }
212
+
213
+ /**
214
+ * Form types for Promptly SDK
215
+ */
216
+
217
+ interface Form {
218
+ id: number;
219
+ slug: string;
220
+ name: string;
221
+ description?: string;
222
+ fields: FormField[];
223
+ settings: FormSettings;
224
+ is_active: boolean;
225
+ created_at: string;
226
+ updated_at: string;
227
+ }
228
+ interface FormField {
229
+ id: string;
230
+ type: FormFieldType;
231
+ name: string;
232
+ label: string;
233
+ placeholder?: string;
234
+ required: boolean;
235
+ options?: FormFieldOption[];
236
+ validation?: FormFieldValidation;
237
+ }
238
+ type FormFieldType = 'text' | 'email' | 'phone' | 'number' | 'textarea' | 'select' | 'radio' | 'checkbox' | 'date' | 'time' | 'file';
239
+ interface FormFieldOption {
240
+ label: string;
241
+ value: string;
242
+ }
243
+ interface FormFieldValidation {
244
+ min?: number;
245
+ max?: number;
246
+ pattern?: string;
247
+ message?: string;
248
+ }
249
+ interface FormSettings {
250
+ submit_button_text: string;
251
+ success_message: string;
252
+ redirect_url?: string;
253
+ notify_email?: string;
254
+ }
255
+ interface FormSubmission {
256
+ id: number;
257
+ form_id: number;
258
+ form?: Form;
259
+ member_id?: number;
260
+ data: Record<string, any>;
261
+ status: 'pending' | 'reviewed' | 'completed';
262
+ created_at: string;
263
+ updated_at: string;
264
+ }
265
+ interface SubmitFormData {
266
+ [key: string]: any;
267
+ }
268
+ interface FormListParams extends ListParams {
269
+ }
270
+ interface SubmissionListParams extends ListParams {
271
+ form_id?: number;
272
+ status?: string;
273
+ }
274
+
275
+ /**
276
+ * Shop types for Promptly SDK
277
+ */
278
+
279
+ interface ProductCategory {
280
+ id: number;
281
+ slug: string;
282
+ name: string;
283
+ description?: string;
284
+ image?: string;
285
+ parent_id?: number;
286
+ parent?: ProductCategory;
287
+ children?: ProductCategory[];
288
+ products_count?: number;
289
+ is_active: boolean;
290
+ sort_order: number;
291
+ created_at: string;
292
+ updated_at: string;
293
+ }
294
+ interface ProductOption {
295
+ id: number;
296
+ product_id: number;
297
+ name: string;
298
+ sort_order: number;
299
+ values: ProductOptionValue[];
300
+ }
301
+ interface ProductOptionValue {
302
+ id: number;
303
+ option_id: number;
304
+ value: string;
305
+ sort_order: number;
306
+ }
307
+ interface ProductVariant {
308
+ id: number;
309
+ product_id: number;
310
+ sku?: string;
311
+ price?: number;
312
+ compare_price?: number;
313
+ stock_quantity: number;
314
+ option_values: Record<string, string>;
315
+ is_active: boolean;
316
+ sort_order: number;
317
+ }
318
+ interface Product {
319
+ id: number;
320
+ category_id?: number;
321
+ category?: ProductCategory;
322
+ name: string;
323
+ slug: string;
324
+ description?: string;
325
+ content?: string;
326
+ price: number;
327
+ compare_price?: number;
328
+ cost_price?: number;
329
+ sku?: string;
330
+ stock_quantity: number;
331
+ track_inventory: boolean;
332
+ thumbnail?: string;
333
+ images?: string[];
334
+ status: ProductStatus;
335
+ is_featured: boolean;
336
+ has_options: boolean;
337
+ option_type?: 'single' | 'combination';
338
+ options?: ProductOption[];
339
+ variants?: ProductVariant[];
340
+ weight?: number;
341
+ meta?: Record<string, any>;
342
+ sort_order: number;
343
+ discount_percent?: number;
344
+ in_stock?: boolean;
345
+ min_price?: number;
346
+ max_price?: number;
347
+ created_at: string;
348
+ updated_at: string;
349
+ }
350
+ type ProductStatus = 'draft' | 'active' | 'inactive';
351
+ interface ProductListParams extends ListParams {
352
+ category?: string;
353
+ status?: ProductStatus;
354
+ is_featured?: boolean;
355
+ min_price?: number;
356
+ max_price?: number;
357
+ search?: string;
358
+ in_stock?: boolean;
359
+ }
360
+ interface CartItem {
361
+ id: number;
362
+ cart_id: number;
363
+ product_id: number;
364
+ variant_id?: number;
365
+ product?: Product;
366
+ variant?: ProductVariant;
367
+ quantity: number;
368
+ price: number;
369
+ options?: Record<string, string>;
370
+ created_at: string;
371
+ updated_at: string;
372
+ }
373
+ interface Cart {
374
+ id: number;
375
+ member_id?: number;
376
+ session_id?: string;
377
+ items: CartItem[];
378
+ total: number;
379
+ total_quantity: number;
380
+ item_count: number;
381
+ created_at: string;
382
+ updated_at: string;
383
+ }
384
+ interface AddToCartData {
385
+ product_id: number;
386
+ variant_id?: number;
387
+ quantity: number;
388
+ options?: Record<string, string>;
389
+ }
390
+ interface UpdateCartItemData {
391
+ quantity: number;
392
+ }
393
+ type OrderStatus = 'pending' | 'paid' | 'preparing' | 'shipping' | 'delivered' | 'cancelled' | 'refunded';
394
+ type PaymentStatus = 'pending' | 'ready' | 'done' | 'cancelled' | 'failed';
395
+ interface OrderItem {
396
+ id: number;
397
+ order_id: number;
398
+ product_id: number;
399
+ variant_id?: number;
400
+ product_name: string;
401
+ variant_name?: string;
402
+ thumbnail?: string;
403
+ quantity: number;
404
+ price: number;
405
+ total: number;
406
+ options?: Record<string, string>;
407
+ }
408
+ interface Order {
409
+ id: number;
410
+ member_id?: number;
411
+ order_number: string;
412
+ status: OrderStatus;
413
+ status_label?: string;
414
+ subtotal: number;
415
+ discount_amount: number;
416
+ shipping_fee: number;
417
+ total: number;
418
+ coupon_id?: number;
419
+ coupon_code?: string;
420
+ payment_method?: string;
421
+ payment_status: PaymentStatus;
422
+ payment_status_label?: string;
423
+ paid_at?: string;
424
+ shipping_name: string;
425
+ shipping_phone: string;
426
+ shipping_zipcode: string;
427
+ shipping_address: string;
428
+ shipping_address_detail?: string;
429
+ shipping_memo?: string;
430
+ shipping_company?: string;
431
+ tracking_number?: string;
432
+ shipped_at?: string;
433
+ delivered_at?: string;
434
+ orderer_name: string;
435
+ orderer_email: string;
436
+ orderer_phone: string;
437
+ items?: OrderItem[];
438
+ payment?: Payment;
439
+ created_at: string;
440
+ updated_at: string;
441
+ }
442
+ interface CreateOrderData {
443
+ orderer_name: string;
444
+ orderer_email: string;
445
+ orderer_phone: string;
446
+ shipping_name: string;
447
+ shipping_phone: string;
448
+ shipping_zipcode: string;
449
+ shipping_address: string;
450
+ shipping_address_detail?: string;
451
+ shipping_memo?: string;
452
+ coupon_code?: string;
453
+ payment_method?: string;
454
+ }
455
+ interface OrderListParams extends ListParams {
456
+ status?: OrderStatus;
457
+ payment_status?: PaymentStatus;
458
+ start_date?: string;
459
+ end_date?: string;
460
+ }
461
+ type PaymentMethod = 'CARD' | 'VIRTUAL_ACCOUNT' | 'TRANSFER' | 'MOBILE_PHONE' | 'CULTURE_GIFT_CERTIFICATE' | 'BOOK_GIFT_CERTIFICATE' | 'GAME_GIFT_CERTIFICATE';
462
+ interface Payment {
463
+ id: number;
464
+ order_id: number;
465
+ payment_key?: string;
466
+ order_id_toss?: string;
467
+ method?: PaymentMethod;
468
+ method_label?: string;
469
+ method_detail?: string;
470
+ amount: number;
471
+ status: PaymentStatus;
472
+ status_label?: string;
473
+ approved_at?: string;
474
+ cancelled_at?: string;
475
+ cancel_amount?: number;
476
+ cancel_reason?: string;
477
+ receipt_url?: string;
478
+ card_number?: string;
479
+ card_type?: string;
480
+ installment_months?: number;
481
+ virtual_account_number?: string;
482
+ virtual_account_bank?: string;
483
+ virtual_account_due_date?: string;
484
+ error_code?: string;
485
+ error_message?: string;
486
+ created_at: string;
487
+ updated_at: string;
488
+ }
489
+ interface PaymentReadyData {
490
+ order_id: number;
491
+ amount: number;
492
+ order_name: string;
493
+ customer_name: string;
494
+ customer_email: string;
495
+ success_url: string;
496
+ fail_url: string;
497
+ }
498
+ interface PaymentConfirmData {
499
+ payment_key: string;
500
+ order_id: string;
501
+ amount: number;
502
+ }
503
+ interface PaymentCancelData {
504
+ cancel_reason: string;
505
+ cancel_amount?: number;
506
+ }
507
+ type CouponType = 'fixed' | 'percent';
508
+ interface Coupon {
509
+ id: number;
510
+ code: string;
511
+ name: string;
512
+ description?: string;
513
+ type: CouponType;
514
+ value: number;
515
+ min_order_amount?: number;
516
+ max_discount_amount?: number;
517
+ usage_limit?: number;
518
+ usage_count: number;
519
+ per_user_limit?: number;
520
+ starts_at?: string;
521
+ expires_at?: string;
522
+ is_active: boolean;
523
+ created_at: string;
524
+ updated_at: string;
525
+ }
526
+ interface ApplyCouponData {
527
+ code: string;
528
+ }
529
+ interface CouponValidation {
530
+ valid: boolean;
531
+ message?: string;
532
+ discount_amount?: number;
533
+ coupon?: Coupon;
534
+ }
535
+
536
+ /**
537
+ * Custom Entity types for Promptly SDK
538
+ */
539
+ interface EntityField {
540
+ name: string;
541
+ label: string;
542
+ type: 'text' | 'textarea' | 'number' | 'email' | 'url' | 'date' | 'datetime' | 'boolean' | 'select' | 'multiselect';
543
+ required?: boolean;
544
+ searchable?: boolean;
545
+ default?: any;
546
+ options?: Array<{
547
+ value: string;
548
+ label: string;
549
+ }>;
550
+ }
551
+ interface EntitySchema {
552
+ fields: EntityField[];
553
+ display?: {
554
+ title_field?: string;
555
+ list_fields?: string;
556
+ };
557
+ }
558
+ interface CustomEntity {
559
+ id: number;
560
+ name: string;
561
+ slug: string;
562
+ description?: string;
563
+ schema: EntitySchema;
564
+ icon?: string;
565
+ is_active: boolean;
566
+ records_count?: number;
567
+ created_at: string;
568
+ updated_at: string;
569
+ }
570
+ interface EntityRecord {
571
+ id: number;
572
+ entity_id: number;
573
+ data: Record<string, any>;
574
+ status: 'active' | 'archived' | 'draft';
575
+ created_by?: number;
576
+ updated_by?: number;
577
+ created_at: string;
578
+ updated_at: string;
579
+ }
580
+ interface EntityListParams {
581
+ page?: number;
582
+ per_page?: number;
583
+ status?: 'active' | 'archived' | 'draft';
584
+ search?: string;
585
+ sort?: string;
586
+ order?: 'asc' | 'desc';
587
+ [key: string]: any;
588
+ }
589
+ interface CreateEntityRecordData {
590
+ data: Record<string, any>;
591
+ status?: 'active' | 'archived' | 'draft';
592
+ }
593
+ interface UpdateEntityRecordData {
594
+ data?: Record<string, any>;
595
+ status?: 'active' | 'archived' | 'draft';
596
+ }
597
+
598
+ /**
599
+ * HTTP Client for Promptly SDK
600
+ */
601
+
602
+ interface RequestOptions {
603
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
604
+ body?: Record<string, any>;
605
+ params?: Record<string, any>;
606
+ headers?: Record<string, string>;
607
+ }
608
+ declare class PromptlyError extends Error {
609
+ status: number;
610
+ errors?: Record<string, string[]>;
611
+ constructor(message: string, status: number, errors?: Record<string, string[]>);
612
+ }
613
+ declare class HttpClient {
614
+ private baseUrl;
615
+ private tenantId;
616
+ private timeout;
617
+ private token;
618
+ constructor(config: PromptlyConfig);
619
+ /**
620
+ * Set authentication token
621
+ */
622
+ setToken(token: string | null): void;
623
+ /**
624
+ * Get current token
625
+ */
626
+ getToken(): string | null;
627
+ /**
628
+ * Check if authenticated
629
+ */
630
+ isAuthenticated(): boolean;
631
+ /**
632
+ * Build full URL with query params
633
+ */
634
+ private buildUrl;
635
+ /**
636
+ * Build request headers
637
+ */
638
+ private buildHeaders;
639
+ /**
640
+ * Make HTTP request
641
+ */
642
+ request<T>(endpoint: string, options?: RequestOptions): Promise<T>;
643
+ /**
644
+ * GET request
645
+ */
646
+ get<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
647
+ /**
648
+ * POST request
649
+ */
650
+ post<T>(endpoint: string, body?: Record<string, any>): Promise<T>;
651
+ /**
652
+ * PUT request
653
+ */
654
+ put<T>(endpoint: string, body?: Record<string, any>): Promise<T>;
655
+ /**
656
+ * PATCH request
657
+ */
658
+ patch<T>(endpoint: string, body?: Record<string, any>): Promise<T>;
659
+ /**
660
+ * DELETE request
661
+ */
662
+ delete<T>(endpoint: string): Promise<T>;
663
+ /**
664
+ * Upload file
665
+ */
666
+ upload<T>(endpoint: string, file: File | Blob, fieldName?: string): Promise<T>;
667
+ }
668
+
669
+ /**
670
+ * Auth Resource for Promptly SDK
671
+ */
672
+
673
+ declare class AuthResource {
674
+ private http;
675
+ constructor(http: HttpClient);
676
+ /**
677
+ * Login with email and password
678
+ */
679
+ login(credentials: LoginCredentials): Promise<AuthResponse>;
680
+ /**
681
+ * Register new member
682
+ */
683
+ register(data: RegisterData): Promise<AuthResponse>;
684
+ /**
685
+ * Logout current user
686
+ */
687
+ logout(): Promise<void>;
688
+ /**
689
+ * Get current user profile
690
+ */
691
+ me(): Promise<Member>;
692
+ /**
693
+ * Update profile
694
+ */
695
+ updateProfile(data: UpdateProfileData): Promise<Member>;
696
+ /**
697
+ * Send password reset email
698
+ */
699
+ forgotPassword(data: ForgotPasswordData): Promise<{
700
+ message: string;
701
+ }>;
702
+ /**
703
+ * Reset password with token
704
+ */
705
+ resetPassword(data: ResetPasswordData): Promise<{
706
+ message: string;
707
+ }>;
708
+ /**
709
+ * Get available social login providers
710
+ */
711
+ getSocialProviders(): Promise<SocialProvider[]>;
712
+ /**
713
+ * Get social login redirect URL
714
+ */
715
+ getSocialAuthUrl(provider: string): Promise<SocialAuthUrl>;
716
+ /**
717
+ * Handle social login callback
718
+ */
719
+ socialCallback(provider: string, code: string): Promise<AuthResponse>;
720
+ /**
721
+ * Set token manually (e.g., from localStorage)
722
+ */
723
+ setToken(token: string | null): void;
724
+ /**
725
+ * Get current token
726
+ */
727
+ getToken(): string | null;
728
+ /**
729
+ * Check if user is authenticated
730
+ */
731
+ isAuthenticated(): boolean;
732
+ }
733
+
734
+ /**
735
+ * Board Resource for Promptly SDK
736
+ */
737
+
738
+ declare class BoardsResource {
739
+ private http;
740
+ constructor(http: HttpClient);
741
+ /**
742
+ * List all boards
743
+ */
744
+ list(params?: BoardListParams): Promise<Board[]>;
745
+ /**
746
+ * Get board by ID or slug
747
+ */
748
+ get(idOrSlug: number | string): Promise<Board>;
749
+ /**
750
+ * List posts in a board
751
+ */
752
+ listPosts(boardIdOrSlug: number | string, params?: PostListParams): Promise<PaginatedResponse<BoardPost>>;
753
+ /**
754
+ * Get post by ID
755
+ */
756
+ getPost(postId: number): Promise<BoardPost>;
757
+ /**
758
+ * Create new post
759
+ */
760
+ createPost(data: CreatePostData): Promise<BoardPost>;
761
+ /**
762
+ * Update post
763
+ */
764
+ updatePost(postId: number, data: UpdatePostData): Promise<BoardPost>;
765
+ /**
766
+ * Delete post
767
+ */
768
+ deletePost(postId: number): Promise<void>;
769
+ /**
770
+ * List comments for a post
771
+ */
772
+ listComments(postId: number): Promise<BoardComment[]>;
773
+ /**
774
+ * Create comment on a post
775
+ */
776
+ createComment(postId: number, data: CreateCommentData): Promise<BoardComment>;
777
+ /**
778
+ * Update comment
779
+ */
780
+ updateComment(commentId: number, data: UpdateCommentData): Promise<BoardComment>;
781
+ /**
782
+ * Delete comment
783
+ */
784
+ deleteComment(commentId: number): Promise<void>;
785
+ }
786
+
787
+ /**
788
+ * Blog Resource for Promptly SDK
789
+ */
790
+
791
+ declare class BlogResource {
792
+ private http;
793
+ constructor(http: HttpClient);
794
+ /**
795
+ * List blog posts
796
+ */
797
+ list(params?: BlogListParams): Promise<PaginatedResponse<BlogPost>>;
798
+ /**
799
+ * Get blog post by slug
800
+ */
801
+ get(slug: string): Promise<BlogPost>;
802
+ /**
803
+ * Get blog post by ID
804
+ */
805
+ getById(id: number): Promise<BlogPost>;
806
+ /**
807
+ * Get featured blog posts
808
+ */
809
+ featured(limit?: number): Promise<BlogPost[]>;
810
+ /**
811
+ * Get blog posts by category
812
+ */
813
+ byCategory(category: string, params?: Omit<BlogListParams, 'category'>): Promise<PaginatedResponse<BlogPost>>;
814
+ /**
815
+ * Get blog posts by tag
816
+ */
817
+ byTag(tag: string, params?: Omit<BlogListParams, 'tag'>): Promise<PaginatedResponse<BlogPost>>;
818
+ /**
819
+ * Search blog posts
820
+ */
821
+ search(query: string, params?: Omit<BlogListParams, 'search'>): Promise<PaginatedResponse<BlogPost>>;
822
+ /**
823
+ * Get blog categories
824
+ */
825
+ categories(): Promise<string[]>;
826
+ /**
827
+ * Get blog tags
828
+ */
829
+ tags(): Promise<string[]>;
830
+ }
831
+
832
+ /**
833
+ * Form Resource for Promptly SDK
834
+ */
835
+
836
+ declare class FormsResource {
837
+ private http;
838
+ constructor(http: HttpClient);
839
+ /**
840
+ * List all forms
841
+ */
842
+ list(params?: FormListParams): Promise<Form[]>;
843
+ /**
844
+ * Get form by ID or slug
845
+ */
846
+ get(idOrSlug: number | string): Promise<Form>;
847
+ /**
848
+ * Submit form data
849
+ */
850
+ submit(formIdOrSlug: number | string, data: SubmitFormData): Promise<FormSubmission>;
851
+ /**
852
+ * Get my form submissions
853
+ */
854
+ mySubmissions(params?: SubmissionListParams): Promise<PaginatedResponse<FormSubmission>>;
855
+ /**
856
+ * Get specific submission
857
+ */
858
+ getSubmission(submissionId: number): Promise<FormSubmission>;
859
+ }
860
+
861
+ /**
862
+ * Shop Resource for Promptly SDK
863
+ */
864
+
865
+ declare class ShopResource {
866
+ private http;
867
+ constructor(http: HttpClient);
868
+ /**
869
+ * List products
870
+ */
871
+ listProducts(params?: ProductListParams): Promise<PaginatedResponse<Product>>;
872
+ /**
873
+ * Get product by ID or slug
874
+ */
875
+ getProduct(idOrSlug: number | string): Promise<Product>;
876
+ /**
877
+ * Get featured products
878
+ */
879
+ featuredProducts(limit?: number): Promise<Product[]>;
880
+ /**
881
+ * Search products
882
+ */
883
+ searchProducts(query: string, params?: Omit<ProductListParams, 'search'>): Promise<PaginatedResponse<Product>>;
884
+ /**
885
+ * List product categories
886
+ */
887
+ listCategories(): Promise<ProductCategory[]>;
888
+ /**
889
+ * Get category by ID or slug
890
+ */
891
+ getCategory(idOrSlug: number | string): Promise<ProductCategory>;
892
+ /**
893
+ * Get products in category
894
+ */
895
+ categoryProducts(categoryIdOrSlug: number | string, params?: Omit<ProductListParams, 'category'>): Promise<PaginatedResponse<Product>>;
896
+ /**
897
+ * Get current cart
898
+ */
899
+ getCart(): Promise<Cart>;
900
+ /**
901
+ * Add item to cart
902
+ */
903
+ addToCart(data: AddToCartData): Promise<Cart>;
904
+ /**
905
+ * Update cart item quantity
906
+ */
907
+ updateCartItem(itemId: number, data: UpdateCartItemData): Promise<Cart>;
908
+ /**
909
+ * Remove item from cart
910
+ */
911
+ removeFromCart(itemId: number): Promise<Cart>;
912
+ /**
913
+ * Clear entire cart
914
+ */
915
+ clearCart(): Promise<void>;
916
+ /**
917
+ * List my orders
918
+ */
919
+ listOrders(params?: OrderListParams): Promise<PaginatedResponse<Order>>;
920
+ /**
921
+ * Get order by ID or order number
922
+ */
923
+ getOrder(idOrNumber: number | string): Promise<Order>;
924
+ /**
925
+ * Create order from cart
926
+ */
927
+ createOrder(data: CreateOrderData): Promise<Order>;
928
+ /**
929
+ * Cancel order
930
+ */
931
+ cancelOrder(orderId: number): Promise<Order>;
932
+ /**
933
+ * Get payment for order
934
+ */
935
+ getPayment(orderId: number): Promise<Payment>;
936
+ /**
937
+ * Prepare payment (get payment key)
938
+ */
939
+ preparePayment(data: PaymentReadyData): Promise<{
940
+ paymentKey: string;
941
+ orderId: string;
942
+ }>;
943
+ /**
944
+ * Confirm payment (after Toss redirect)
945
+ */
946
+ confirmPayment(data: PaymentConfirmData): Promise<Payment>;
947
+ /**
948
+ * Cancel payment
949
+ */
950
+ cancelPayment(paymentId: number, data: PaymentCancelData): Promise<Payment>;
951
+ /**
952
+ * Validate coupon code
953
+ */
954
+ validateCoupon(code: string, orderAmount: number): Promise<CouponValidation>;
955
+ /**
956
+ * Get available coupons for current user
957
+ */
958
+ myCoupons(): Promise<Coupon[]>;
959
+ }
960
+
961
+ /**
962
+ * Media Resource for Promptly SDK
963
+ */
964
+
965
+ interface MediaListParams extends ListParams {
966
+ type?: string;
967
+ }
968
+ declare class MediaResource {
969
+ private http;
970
+ constructor(http: HttpClient);
971
+ /**
972
+ * List my media files
973
+ */
974
+ list(params?: MediaListParams): Promise<PaginatedResponse<Media>>;
975
+ /**
976
+ * Get media by ID
977
+ */
978
+ get(mediaId: number): Promise<Media>;
979
+ /**
980
+ * Upload file
981
+ */
982
+ upload(file: File | Blob): Promise<Media>;
983
+ /**
984
+ * Upload multiple files
985
+ */
986
+ uploadMultiple(files: (File | Blob)[]): Promise<Media[]>;
987
+ /**
988
+ * Delete media
989
+ */
990
+ delete(mediaId: number): Promise<void>;
991
+ }
992
+
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
+ declare class EntitiesResource {
1002
+ private http;
1003
+ constructor(http: HttpClient);
1004
+ /**
1005
+ * List all active custom entities
1006
+ *
1007
+ * @example
1008
+ * ```typescript
1009
+ * const entities = await client.entities.list();
1010
+ * // [{ id: 1, name: 'Customer', slug: 'customer', ... }]
1011
+ * ```
1012
+ */
1013
+ list(): Promise<CustomEntity[]>;
1014
+ /**
1015
+ * Get entity schema by slug
1016
+ *
1017
+ * @example
1018
+ * ```typescript
1019
+ * const schema = await client.entities.getSchema('customer');
1020
+ * // { fields: [{ name: 'company', label: '회사명', type: 'text', ... }] }
1021
+ * ```
1022
+ */
1023
+ getSchema(slug: string): Promise<EntitySchema>;
1024
+ /**
1025
+ * List records for an entity
1026
+ *
1027
+ * @example
1028
+ * ```typescript
1029
+ * // Basic listing
1030
+ * const customers = await client.entities.listRecords('customer');
1031
+ *
1032
+ * // With pagination
1033
+ * const customers = await client.entities.listRecords('customer', {
1034
+ * page: 1,
1035
+ * per_page: 20,
1036
+ * status: 'active',
1037
+ * });
1038
+ *
1039
+ * // With filtering by data fields
1040
+ * const vipCustomers = await client.entities.listRecords('customer', {
1041
+ * 'data.tier': 'vip',
1042
+ * });
1043
+ * ```
1044
+ */
1045
+ listRecords(slug: string, params?: EntityListParams): Promise<PaginatedResponse<EntityRecord>>;
1046
+ /**
1047
+ * Get a single record by ID
1048
+ *
1049
+ * @example
1050
+ * ```typescript
1051
+ * const customer = await client.entities.getRecord('customer', 1);
1052
+ * console.log(customer.data.company); // 'ABC Corp'
1053
+ * ```
1054
+ */
1055
+ getRecord(slug: string, id: number): Promise<EntityRecord>;
1056
+ /**
1057
+ * Create a new record
1058
+ *
1059
+ * @example
1060
+ * ```typescript
1061
+ * const newCustomer = await client.entities.createRecord('customer', {
1062
+ * data: {
1063
+ * company: 'ABC Corp',
1064
+ * email: 'contact@abc.com',
1065
+ * tier: 'standard',
1066
+ * },
1067
+ * status: 'active',
1068
+ * });
1069
+ * ```
1070
+ */
1071
+ createRecord(slug: string, data: CreateEntityRecordData): Promise<EntityRecord>;
1072
+ /**
1073
+ * Update a record
1074
+ *
1075
+ * @example
1076
+ * ```typescript
1077
+ * const updated = await client.entities.updateRecord('customer', 1, {
1078
+ * data: {
1079
+ * tier: 'vip',
1080
+ * },
1081
+ * });
1082
+ * ```
1083
+ */
1084
+ updateRecord(slug: string, id: number, data: UpdateEntityRecordData): Promise<EntityRecord>;
1085
+ /**
1086
+ * Delete a record
1087
+ *
1088
+ * @example
1089
+ * ```typescript
1090
+ * await client.entities.deleteRecord('customer', 1);
1091
+ * ```
1092
+ */
1093
+ deleteRecord(slug: string, id: number): Promise<void>;
1094
+ /**
1095
+ * Get a value from a record's data
1096
+ *
1097
+ * @example
1098
+ * ```typescript
1099
+ * const record = await client.entities.getRecord('customer', 1);
1100
+ * const company = client.entities.getValue(record, 'company');
1101
+ * ```
1102
+ */
1103
+ getValue(record: EntityRecord, field: string): any;
1104
+ /**
1105
+ * Create a typed accessor for an entity
1106
+ *
1107
+ * @example
1108
+ * ```typescript
1109
+ * interface Customer {
1110
+ * company: string;
1111
+ * email: string;
1112
+ * tier: 'standard' | 'vip';
1113
+ * }
1114
+ *
1115
+ * const customers = client.entities.typed<Customer>('customer');
1116
+ * const list = await customers.list(); // Typed records
1117
+ * const record = await customers.get(1);
1118
+ * console.log(record.data.company); // TypeScript knows this is string
1119
+ * ```
1120
+ */
1121
+ typed<T extends Record<string, any>>(slug: string): {
1122
+ list: (params?: EntityListParams) => Promise<{
1123
+ data: Array<Omit<EntityRecord, "data"> & {
1124
+ data: T;
1125
+ }>;
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
+ };
1138
+ }>;
1139
+ get: (id: number) => Promise<Omit<EntityRecord, "data"> & {
1140
+ data: T;
1141
+ }>;
1142
+ create: (data: T, status?: EntityRecord["status"]) => Promise<Omit<EntityRecord, "data"> & {
1143
+ data: T;
1144
+ }>;
1145
+ update: (id: number, data: Partial<T>, status?: EntityRecord["status"]) => Promise<Omit<EntityRecord, "data"> & {
1146
+ data: T;
1147
+ }>;
1148
+ delete: (id: number) => Promise<void>;
1149
+ };
1150
+ }
1151
+
1152
+ /**
1153
+ * Promptly SDK
1154
+ *
1155
+ * A TypeScript/JavaScript SDK for the Promptly AI CMS platform.
1156
+ *
1157
+ * @example
1158
+ * ```typescript
1159
+ * import { Promptly } from '@promptly/sdk';
1160
+ *
1161
+ * const client = new Promptly({
1162
+ * tenantId: 'my-site',
1163
+ * baseUrl: 'https://promptly.webbyon.com',
1164
+ * });
1165
+ *
1166
+ * // Public API
1167
+ * const posts = await client.blog.list();
1168
+ * const products = await client.shop.listProducts();
1169
+ *
1170
+ * // Authentication
1171
+ * await client.auth.login({ email: 'user@example.com', password: 'password' });
1172
+ *
1173
+ * // Protected API
1174
+ * const orders = await client.shop.listOrders();
1175
+ * ```
1176
+ */
1177
+
1178
+ declare class Promptly {
1179
+ private http;
1180
+ /** Authentication & user management */
1181
+ readonly auth: AuthResource;
1182
+ /** Board posts and comments */
1183
+ readonly boards: BoardsResource;
1184
+ /** Blog posts */
1185
+ readonly blog: BlogResource;
1186
+ /** Forms and submissions */
1187
+ readonly forms: FormsResource;
1188
+ /** E-commerce: products, cart, orders, payments */
1189
+ readonly shop: ShopResource;
1190
+ /** Media file management */
1191
+ readonly media: MediaResource;
1192
+ /** Custom entities - dynamic data structures created by AI */
1193
+ readonly entities: EntitiesResource;
1194
+ constructor(config: PromptlyConfig);
1195
+ /**
1196
+ * Get site theme settings
1197
+ */
1198
+ getTheme(): Promise<{
1199
+ name: string;
1200
+ colors: Record<string, string>;
1201
+ fonts: Record<string, string>;
1202
+ }>;
1203
+ /**
1204
+ * Get site settings
1205
+ */
1206
+ getSettings(): Promise<Record<string, any>>;
1207
+ /**
1208
+ * Check if user is authenticated
1209
+ */
1210
+ isAuthenticated(): boolean;
1211
+ /**
1212
+ * Set authentication token manually
1213
+ */
1214
+ setToken(token: string | null): void;
1215
+ /**
1216
+ * Get current authentication token
1217
+ */
1218
+ getToken(): string | null;
1219
+ }
1220
+
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 };