@back23/promptly-sdk 2.2.0 → 2.3.1
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/README.md +241 -32
- package/dist/index.d.mts +84 -3
- package/dist/index.d.ts +84 -3
- package/dist/index.js +67 -3
- package/dist/index.mjs +67 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,115 @@ const { data: posts } = await client.blog.list();
|
|
|
24
24
|
const products = await client.shop.listProducts();
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## v2.3.1 Changes (Bug Fix)
|
|
28
|
+
|
|
29
|
+
### Dual Authentication Support Fixed
|
|
30
|
+
|
|
31
|
+
API Key와 Bearer Token이 동시에 전송되도록 수정되었습니다. 이전 버전에서는 API Key가 설정되어 있으면 Authorization 헤더가 무시되어 로그인 후 멤버 전용 API 호출이 실패하는 문제가 있었습니다.
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// 이제 API Key + Bearer Token 동시 사용 가능
|
|
35
|
+
const client = new Promptly({
|
|
36
|
+
tenantId: 'demo',
|
|
37
|
+
apiKey: 'pky_xxx', // X-API-Key 헤더
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// 로그인 후 토큰 설정
|
|
41
|
+
await client.auth.login({ email, password });
|
|
42
|
+
|
|
43
|
+
// 멤버 전용 API 정상 동작 (Authorization: Bearer xxx 헤더 포함)
|
|
44
|
+
const profile = await client.members.getProfile();
|
|
45
|
+
const orders = await client.orders.list();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## v2.3.0 Changes
|
|
51
|
+
|
|
52
|
+
### Polymorphic Comments API
|
|
53
|
+
|
|
54
|
+
댓글 시스템이 재설계되어 게시판, 블로그, 방명록(독립 페이지) 등 다양한 곳에서 사용할 수 있습니다.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// 게시판 글 댓글
|
|
58
|
+
const boardComments = await client.comments.boardPost(postId);
|
|
59
|
+
await client.comments.createBoardPost(postId, {
|
|
60
|
+
author_name: '홍길동',
|
|
61
|
+
content: '댓글 내용',
|
|
62
|
+
password: '1234', // 비회원 댓글용
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// 블로그 글 댓글
|
|
66
|
+
const blogComments = await client.comments.blogPost('post-slug');
|
|
67
|
+
await client.comments.createBlogPost('post-slug', {
|
|
68
|
+
author_name: 'Jane',
|
|
69
|
+
content: 'Great post!',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// 방명록 (독립 페이지)
|
|
73
|
+
const guestbook = await client.comments.standalone('guestbook');
|
|
74
|
+
await client.comments.createStandalone('guestbook', {
|
|
75
|
+
author_name: '방문자',
|
|
76
|
+
content: '안녕하세요!',
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// 공통 기능
|
|
80
|
+
await client.comments.update(commentId, { content: '수정된 댓글' });
|
|
81
|
+
await client.comments.delete(commentId, { password: '1234' });
|
|
82
|
+
await client.comments.like(commentId);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## v2.2.0 Changes
|
|
88
|
+
|
|
89
|
+
### Entity Definition CRUD
|
|
90
|
+
|
|
91
|
+
이제 API/SDK에서 직접 커스텀 엔티티 정의를 생성/수정/삭제할 수 있습니다.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// 엔티티 정의 생성
|
|
95
|
+
const entity = await client.entities.create({
|
|
96
|
+
name: '고객',
|
|
97
|
+
slug: 'customers', // optional, auto-generated from name
|
|
98
|
+
description: '고객 관리',
|
|
99
|
+
schema: {
|
|
100
|
+
fields: [
|
|
101
|
+
{ name: 'company', label: '회사명', type: 'text', required: true },
|
|
102
|
+
{ name: 'email', label: '이메일', type: 'email', required: true },
|
|
103
|
+
{ name: 'status', label: '상태', type: 'select', options: [
|
|
104
|
+
{ value: 'active', label: '활성' },
|
|
105
|
+
{ value: 'inactive', label: '비활성' }
|
|
106
|
+
]}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
icon: 'users'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// 엔티티 정의 조회
|
|
113
|
+
const entity = await client.entities.get('customers');
|
|
114
|
+
|
|
115
|
+
// 엔티티 정의 수정
|
|
116
|
+
await client.entities.update('customers', { name: '고객사' });
|
|
117
|
+
|
|
118
|
+
// 엔티티 정의 삭제 (레코드 있으면 force 필요)
|
|
119
|
+
await client.entities.delete('customers', true);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Record API Path Change
|
|
123
|
+
|
|
124
|
+
레코드 API 경로가 변경되었습니다:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// v2.1.0 이전
|
|
128
|
+
await client.entities.createRecord('customers', { data: { company: 'ACME' } });
|
|
129
|
+
|
|
130
|
+
// v2.2.0 이후 - data wrapper 불필요
|
|
131
|
+
await client.entities.createRecord('customers', { company: 'ACME' });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
27
136
|
## v2.0.0 Breaking Changes
|
|
28
137
|
|
|
29
138
|
### API Key Required
|
|
@@ -87,14 +196,14 @@ data.map(post => ...); // data is always an array
|
|
|
87
196
|
|
|
88
197
|
| Resource | Read Operations | Write Operations (Auth Required) |
|
|
89
198
|
|----------|-----------------|----------------------------------|
|
|
90
|
-
| **Boards** | list, get, listPosts, getPost
|
|
91
|
-
| **Comments** | listComments | createComment, updateComment, deleteComment |
|
|
199
|
+
| **Boards** | list, get, listPosts, getPost | createPost, updatePost, deletePost |
|
|
92
200
|
| **Blog** | list, get, featured, byCategory, byTag | - |
|
|
201
|
+
| **Comments** | boardPost, blogPost, standalone | createBoardPost, createBlogPost, createStandalone, update, delete, like |
|
|
93
202
|
| **Shop** | listProducts, getProduct, listCategories | getCart, addToCart, listOrders, createOrder |
|
|
94
203
|
| **Forms** | list, get, submit | mySubmissions |
|
|
95
204
|
| **Auth** | login, register | logout, me, updateProfile |
|
|
96
205
|
| **Media** | - | upload, list, delete |
|
|
97
|
-
| **Entities** | list,
|
|
206
|
+
| **Entities** | list, get, listRecords, getRecord | create, update, delete, createRecord, updateRecord, deleteRecord |
|
|
98
207
|
| **Reservation** | getSettings, listServices, listStaff, getAvailableDates, getAvailableSlots | create, list, get, cancel |
|
|
99
208
|
|
|
100
209
|
## API Reference
|
|
@@ -201,6 +310,67 @@ const tags = await client.blog.tags();
|
|
|
201
310
|
// Returns: string[] (always an array)
|
|
202
311
|
```
|
|
203
312
|
|
|
313
|
+
### Comments (댓글)
|
|
314
|
+
|
|
315
|
+
3가지 댓글 유형을 지원합니다:
|
|
316
|
+
- **게시판 댓글** (`board_post`)
|
|
317
|
+
- **블로그 댓글** (`blog_post`)
|
|
318
|
+
- **방명록/독립 댓글** (`page`)
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
// 게시판 글 댓글 조회
|
|
322
|
+
const { data: comments, meta } = await client.comments.boardPost(postId, {
|
|
323
|
+
page: 1,
|
|
324
|
+
per_page: 20,
|
|
325
|
+
});
|
|
326
|
+
// Returns: ListResponse<Comment>
|
|
327
|
+
|
|
328
|
+
// 게시판 글 댓글 작성
|
|
329
|
+
await client.comments.createBoardPost(postId, {
|
|
330
|
+
author_name: '홍길동',
|
|
331
|
+
author_email: 'user@example.com',
|
|
332
|
+
content: '댓글 내용',
|
|
333
|
+
password: '1234', // 비회원용
|
|
334
|
+
parent_id: null, // 대댓글이면 부모 댓글 ID
|
|
335
|
+
is_secret: false, // 비밀 댓글 여부
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// 블로그 글 댓글 조회
|
|
339
|
+
const { data: blogComments } = await client.comments.blogPost('post-slug');
|
|
340
|
+
// Returns: ListResponse<Comment>
|
|
341
|
+
|
|
342
|
+
// 블로그 글 댓글 작성
|
|
343
|
+
await client.comments.createBlogPost('post-slug', {
|
|
344
|
+
author_name: 'Jane',
|
|
345
|
+
content: 'Great post!',
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// 방명록 댓글 조회 (page_slug로 구분)
|
|
349
|
+
const { data: guestbook } = await client.comments.standalone('guestbook');
|
|
350
|
+
// Returns: ListResponse<Comment>
|
|
351
|
+
|
|
352
|
+
// 방명록 댓글 작성
|
|
353
|
+
await client.comments.createStandalone('guestbook', {
|
|
354
|
+
author_name: '방문자',
|
|
355
|
+
content: '안녕하세요!',
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// 댓글 수정
|
|
359
|
+
await client.comments.update(commentId, {
|
|
360
|
+
content: '수정된 댓글',
|
|
361
|
+
password: '1234', // 비회원이 작성한 댓글인 경우
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// 댓글 삭제
|
|
365
|
+
await client.comments.delete(commentId, {
|
|
366
|
+
password: '1234', // 비회원이 작성한 댓글인 경우
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// 댓글 좋아요
|
|
370
|
+
const result = await client.comments.like(commentId);
|
|
371
|
+
// Returns: { data: { likes: number } }
|
|
372
|
+
```
|
|
373
|
+
|
|
204
374
|
### Shop (쇼핑)
|
|
205
375
|
|
|
206
376
|
#### Public (로그인 불필요)
|
|
@@ -477,60 +647,84 @@ const { data: mediaList, meta } = await client.media.list({
|
|
|
477
647
|
await client.media.delete(mediaId);
|
|
478
648
|
```
|
|
479
649
|
|
|
480
|
-
### Entities (커스텀 엔티티) -
|
|
650
|
+
### Entities (커스텀 엔티티) - 동적 데이터 구조
|
|
481
651
|
|
|
482
|
-
|
|
652
|
+
API/SDK에서 직접 엔티티 정의를 생성하고 데이터를 관리할 수 있습니다.
|
|
483
653
|
|
|
484
|
-
####
|
|
654
|
+
#### Entity Definition CRUD
|
|
485
655
|
|
|
486
656
|
```typescript
|
|
487
657
|
// 엔티티 목록 조회
|
|
488
658
|
const entities = await client.entities.list();
|
|
489
659
|
// Returns: CustomEntity[] (always an array)
|
|
490
660
|
|
|
491
|
-
// 엔티티
|
|
492
|
-
const
|
|
493
|
-
|
|
661
|
+
// 엔티티 정의 생성
|
|
662
|
+
const entity = await client.entities.create({
|
|
663
|
+
name: '고객',
|
|
664
|
+
slug: 'customers',
|
|
665
|
+
description: '고객 관리',
|
|
666
|
+
schema: {
|
|
667
|
+
fields: [
|
|
668
|
+
{ name: 'company', label: '회사명', type: 'text', required: true },
|
|
669
|
+
{ name: 'email', label: '이메일', type: 'email', required: true },
|
|
670
|
+
{ name: 'status', label: '상태', type: 'select', options: [
|
|
671
|
+
{ value: 'active', label: '활성' },
|
|
672
|
+
{ value: 'inactive', label: '비활성' }
|
|
673
|
+
]}
|
|
674
|
+
]
|
|
675
|
+
},
|
|
676
|
+
icon: 'users'
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
// 엔티티 정의 조회 (스키마 포함)
|
|
680
|
+
const entity = await client.entities.get('customers');
|
|
681
|
+
// Returns: CustomEntity (includes schema)
|
|
682
|
+
|
|
683
|
+
// 엔티티 정의 수정
|
|
684
|
+
await client.entities.update('customers', {
|
|
685
|
+
name: '고객사',
|
|
686
|
+
description: '고객사 관리'
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
// 엔티티 정의 삭제 (레코드가 있으면 force 필요)
|
|
690
|
+
await client.entities.delete('customers'); // 레코드 없을 때
|
|
691
|
+
await client.entities.delete('customers', true); // 레코드 있어도 강제 삭제
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
#### Record CRUD
|
|
494
695
|
|
|
696
|
+
```typescript
|
|
495
697
|
// 레코드 목록 조회
|
|
496
|
-
const { data: customers, meta } = await client.entities.listRecords('
|
|
698
|
+
const { data: customers, meta } = await client.entities.listRecords('customers', {
|
|
497
699
|
page: 1,
|
|
498
700
|
per_page: 20,
|
|
499
|
-
|
|
701
|
+
search: 'ACME', // 검색
|
|
702
|
+
sort: 'company', // 정렬 필드
|
|
703
|
+
dir: 'asc', // 정렬 방향
|
|
704
|
+
filters: JSON.stringify({ status: 'active' }) // JSON 필터
|
|
500
705
|
});
|
|
501
706
|
// Returns: ListResponse<EntityRecord>
|
|
502
707
|
|
|
503
|
-
// 데이터 필드로 필터링
|
|
504
|
-
const { data: vipCustomers } = await client.entities.listRecords('customer', {
|
|
505
|
-
'data.tier': 'vip',
|
|
506
|
-
});
|
|
507
|
-
|
|
508
708
|
// 단일 레코드 조회
|
|
509
|
-
const customer = await client.entities.getRecord('
|
|
709
|
+
const customer = await client.entities.getRecord('customers', 1);
|
|
510
710
|
// Returns: EntityRecord
|
|
511
711
|
console.log(customer.data.company); // 'ABC Corp'
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
#### Protected (로그인 필요)
|
|
515
712
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
company: 'ABC Corp',
|
|
521
|
-
email: 'contact@abc.com',
|
|
522
|
-
tier: 'standard',
|
|
523
|
-
},
|
|
713
|
+
// 레코드 생성 (스키마 필드 직접 전달)
|
|
714
|
+
const newCustomer = await client.entities.createRecord('customers', {
|
|
715
|
+
company: 'ABC Corp',
|
|
716
|
+
email: 'contact@abc.com',
|
|
524
717
|
status: 'active',
|
|
525
718
|
});
|
|
526
719
|
|
|
527
|
-
// 레코드 수정
|
|
528
|
-
await client.entities.updateRecord('
|
|
529
|
-
|
|
720
|
+
// 레코드 수정 (부분 업데이트 - 기존 데이터와 병합)
|
|
721
|
+
await client.entities.updateRecord('customers', 1, {
|
|
722
|
+
status: 'inactive',
|
|
723
|
+
email: 'new@abc.com'
|
|
530
724
|
});
|
|
531
725
|
|
|
532
726
|
// 레코드 삭제
|
|
533
|
-
await client.entities.deleteRecord('
|
|
727
|
+
await client.entities.deleteRecord('customers', 1);
|
|
534
728
|
```
|
|
535
729
|
|
|
536
730
|
#### TypeScript 타입 지원
|
|
@@ -651,6 +845,21 @@ interface BlogPost {
|
|
|
651
845
|
created_at: string;
|
|
652
846
|
}
|
|
653
847
|
|
|
848
|
+
interface Comment {
|
|
849
|
+
id: number;
|
|
850
|
+
type: 'board_post' | 'blog_post' | 'page';
|
|
851
|
+
author_name: string;
|
|
852
|
+
author_avatar: string | null;
|
|
853
|
+
content: string;
|
|
854
|
+
is_approved: boolean;
|
|
855
|
+
is_pinned: boolean;
|
|
856
|
+
is_secret: boolean;
|
|
857
|
+
likes: number;
|
|
858
|
+
depth: number;
|
|
859
|
+
created_at: string;
|
|
860
|
+
replies: Comment[];
|
|
861
|
+
}
|
|
862
|
+
|
|
654
863
|
interface Product {
|
|
655
864
|
id: number;
|
|
656
865
|
slug: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -237,6 +237,42 @@ interface BlogListParams extends ListParams {
|
|
|
237
237
|
search?: string;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
type CommentType = 'board_post' | 'blog_post' | 'page';
|
|
241
|
+
interface Comment {
|
|
242
|
+
id: number;
|
|
243
|
+
type: CommentType;
|
|
244
|
+
author_name: string;
|
|
245
|
+
author_avatar: string | null;
|
|
246
|
+
content: string;
|
|
247
|
+
is_approved: boolean;
|
|
248
|
+
is_pinned: boolean;
|
|
249
|
+
is_secret: boolean;
|
|
250
|
+
likes: number;
|
|
251
|
+
depth: number;
|
|
252
|
+
created_at: string;
|
|
253
|
+
replies: Comment[];
|
|
254
|
+
}
|
|
255
|
+
interface CommentListResponse extends ListResponse<Comment> {
|
|
256
|
+
}
|
|
257
|
+
interface CommentListParams extends ListParams {
|
|
258
|
+
include_unapproved?: boolean;
|
|
259
|
+
}
|
|
260
|
+
interface CommentCreateData {
|
|
261
|
+
author_name?: string;
|
|
262
|
+
author_email?: string;
|
|
263
|
+
content: string;
|
|
264
|
+
password?: string;
|
|
265
|
+
parent_id?: number | null;
|
|
266
|
+
is_secret?: boolean;
|
|
267
|
+
}
|
|
268
|
+
interface CommentUpdateData {
|
|
269
|
+
content: string;
|
|
270
|
+
password?: string;
|
|
271
|
+
}
|
|
272
|
+
interface CommentDeleteData {
|
|
273
|
+
password?: string;
|
|
274
|
+
}
|
|
275
|
+
|
|
240
276
|
/**
|
|
241
277
|
* Form types for Promptly SDK
|
|
242
278
|
*/
|
|
@@ -793,7 +829,7 @@ declare class HttpClient {
|
|
|
793
829
|
private buildUrl;
|
|
794
830
|
/**
|
|
795
831
|
* Build request headers
|
|
796
|
-
* API key
|
|
832
|
+
* Both API key and bearer token can be sent together
|
|
797
833
|
*/
|
|
798
834
|
private buildHeaders;
|
|
799
835
|
/**
|
|
@@ -1004,6 +1040,49 @@ declare class BlogResource {
|
|
|
1004
1040
|
tags(): Promise<string[]>;
|
|
1005
1041
|
}
|
|
1006
1042
|
|
|
1043
|
+
declare class CommentsResource {
|
|
1044
|
+
private http;
|
|
1045
|
+
constructor(http: HttpClient);
|
|
1046
|
+
/**
|
|
1047
|
+
* Get comments for a board post
|
|
1048
|
+
*/
|
|
1049
|
+
boardPost(postId: number, params?: CommentListParams): Promise<CommentListResponse>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Create a comment on a board post
|
|
1052
|
+
*/
|
|
1053
|
+
createBoardPost(postId: number, data: CommentCreateData): Promise<ApiResponse<Comment>>;
|
|
1054
|
+
/**
|
|
1055
|
+
* Get comments for a blog post
|
|
1056
|
+
*/
|
|
1057
|
+
blogPost(slug: string, params?: CommentListParams): Promise<CommentListResponse>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Create a comment on a blog post
|
|
1060
|
+
*/
|
|
1061
|
+
createBlogPost(slug: string, data: CommentCreateData): Promise<ApiResponse<Comment>>;
|
|
1062
|
+
/**
|
|
1063
|
+
* Get standalone comments (guestbook, feedback, etc.)
|
|
1064
|
+
*/
|
|
1065
|
+
standalone(pageSlug: string, params?: CommentListParams): Promise<CommentListResponse>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Create a standalone comment
|
|
1068
|
+
*/
|
|
1069
|
+
createStandalone(pageSlug: string, data: CommentCreateData): Promise<ApiResponse<Comment>>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Update a comment
|
|
1072
|
+
*/
|
|
1073
|
+
update(commentId: number, data: CommentUpdateData): Promise<ApiResponse<Comment>>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Delete a comment
|
|
1076
|
+
*/
|
|
1077
|
+
delete(commentId: number, data?: CommentDeleteData): Promise<ApiResponse<void>>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Like a comment
|
|
1080
|
+
*/
|
|
1081
|
+
like(commentId: number): Promise<ApiResponse<{
|
|
1082
|
+
likes: number;
|
|
1083
|
+
}>>;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1007
1086
|
/**
|
|
1008
1087
|
* Form Resource for Promptly SDK
|
|
1009
1088
|
*/
|
|
@@ -1461,10 +1540,12 @@ declare class Promptly {
|
|
|
1461
1540
|
private http;
|
|
1462
1541
|
/** Authentication & user management */
|
|
1463
1542
|
readonly auth: AuthResource;
|
|
1464
|
-
/** Board posts
|
|
1543
|
+
/** Board posts */
|
|
1465
1544
|
readonly boards: BoardsResource;
|
|
1466
1545
|
/** Blog posts */
|
|
1467
1546
|
readonly blog: BlogResource;
|
|
1547
|
+
/** Comments for boards, blogs, and standalone pages */
|
|
1548
|
+
readonly comments: CommentsResource;
|
|
1468
1549
|
/** Forms and submissions */
|
|
1469
1550
|
readonly forms: FormsResource;
|
|
1470
1551
|
/** E-commerce: products, cart, orders, payments */
|
|
@@ -1522,4 +1603,4 @@ declare class Promptly {
|
|
|
1522
1603
|
getApiKey(): string | null;
|
|
1523
1604
|
}
|
|
1524
1605
|
|
|
1525
|
-
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 CreateEntityData, 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 UpdateEntityData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
|
|
1606
|
+
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 Comment, type CommentCreateData, type CommentDeleteData, type CommentListParams, type CommentListResponse, type CommentType, type CommentUpdateData, type Coupon, type CouponType, type CouponValidation, type CreateCommentData, type CreateEntityData, 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 UpdateEntityData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -237,6 +237,42 @@ interface BlogListParams extends ListParams {
|
|
|
237
237
|
search?: string;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
type CommentType = 'board_post' | 'blog_post' | 'page';
|
|
241
|
+
interface Comment {
|
|
242
|
+
id: number;
|
|
243
|
+
type: CommentType;
|
|
244
|
+
author_name: string;
|
|
245
|
+
author_avatar: string | null;
|
|
246
|
+
content: string;
|
|
247
|
+
is_approved: boolean;
|
|
248
|
+
is_pinned: boolean;
|
|
249
|
+
is_secret: boolean;
|
|
250
|
+
likes: number;
|
|
251
|
+
depth: number;
|
|
252
|
+
created_at: string;
|
|
253
|
+
replies: Comment[];
|
|
254
|
+
}
|
|
255
|
+
interface CommentListResponse extends ListResponse<Comment> {
|
|
256
|
+
}
|
|
257
|
+
interface CommentListParams extends ListParams {
|
|
258
|
+
include_unapproved?: boolean;
|
|
259
|
+
}
|
|
260
|
+
interface CommentCreateData {
|
|
261
|
+
author_name?: string;
|
|
262
|
+
author_email?: string;
|
|
263
|
+
content: string;
|
|
264
|
+
password?: string;
|
|
265
|
+
parent_id?: number | null;
|
|
266
|
+
is_secret?: boolean;
|
|
267
|
+
}
|
|
268
|
+
interface CommentUpdateData {
|
|
269
|
+
content: string;
|
|
270
|
+
password?: string;
|
|
271
|
+
}
|
|
272
|
+
interface CommentDeleteData {
|
|
273
|
+
password?: string;
|
|
274
|
+
}
|
|
275
|
+
|
|
240
276
|
/**
|
|
241
277
|
* Form types for Promptly SDK
|
|
242
278
|
*/
|
|
@@ -793,7 +829,7 @@ declare class HttpClient {
|
|
|
793
829
|
private buildUrl;
|
|
794
830
|
/**
|
|
795
831
|
* Build request headers
|
|
796
|
-
* API key
|
|
832
|
+
* Both API key and bearer token can be sent together
|
|
797
833
|
*/
|
|
798
834
|
private buildHeaders;
|
|
799
835
|
/**
|
|
@@ -1004,6 +1040,49 @@ declare class BlogResource {
|
|
|
1004
1040
|
tags(): Promise<string[]>;
|
|
1005
1041
|
}
|
|
1006
1042
|
|
|
1043
|
+
declare class CommentsResource {
|
|
1044
|
+
private http;
|
|
1045
|
+
constructor(http: HttpClient);
|
|
1046
|
+
/**
|
|
1047
|
+
* Get comments for a board post
|
|
1048
|
+
*/
|
|
1049
|
+
boardPost(postId: number, params?: CommentListParams): Promise<CommentListResponse>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Create a comment on a board post
|
|
1052
|
+
*/
|
|
1053
|
+
createBoardPost(postId: number, data: CommentCreateData): Promise<ApiResponse<Comment>>;
|
|
1054
|
+
/**
|
|
1055
|
+
* Get comments for a blog post
|
|
1056
|
+
*/
|
|
1057
|
+
blogPost(slug: string, params?: CommentListParams): Promise<CommentListResponse>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Create a comment on a blog post
|
|
1060
|
+
*/
|
|
1061
|
+
createBlogPost(slug: string, data: CommentCreateData): Promise<ApiResponse<Comment>>;
|
|
1062
|
+
/**
|
|
1063
|
+
* Get standalone comments (guestbook, feedback, etc.)
|
|
1064
|
+
*/
|
|
1065
|
+
standalone(pageSlug: string, params?: CommentListParams): Promise<CommentListResponse>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Create a standalone comment
|
|
1068
|
+
*/
|
|
1069
|
+
createStandalone(pageSlug: string, data: CommentCreateData): Promise<ApiResponse<Comment>>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Update a comment
|
|
1072
|
+
*/
|
|
1073
|
+
update(commentId: number, data: CommentUpdateData): Promise<ApiResponse<Comment>>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Delete a comment
|
|
1076
|
+
*/
|
|
1077
|
+
delete(commentId: number, data?: CommentDeleteData): Promise<ApiResponse<void>>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Like a comment
|
|
1080
|
+
*/
|
|
1081
|
+
like(commentId: number): Promise<ApiResponse<{
|
|
1082
|
+
likes: number;
|
|
1083
|
+
}>>;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1007
1086
|
/**
|
|
1008
1087
|
* Form Resource for Promptly SDK
|
|
1009
1088
|
*/
|
|
@@ -1461,10 +1540,12 @@ declare class Promptly {
|
|
|
1461
1540
|
private http;
|
|
1462
1541
|
/** Authentication & user management */
|
|
1463
1542
|
readonly auth: AuthResource;
|
|
1464
|
-
/** Board posts
|
|
1543
|
+
/** Board posts */
|
|
1465
1544
|
readonly boards: BoardsResource;
|
|
1466
1545
|
/** Blog posts */
|
|
1467
1546
|
readonly blog: BlogResource;
|
|
1547
|
+
/** Comments for boards, blogs, and standalone pages */
|
|
1548
|
+
readonly comments: CommentsResource;
|
|
1468
1549
|
/** Forms and submissions */
|
|
1469
1550
|
readonly forms: FormsResource;
|
|
1470
1551
|
/** E-commerce: products, cart, orders, payments */
|
|
@@ -1522,4 +1603,4 @@ declare class Promptly {
|
|
|
1522
1603
|
getApiKey(): string | null;
|
|
1523
1604
|
}
|
|
1524
1605
|
|
|
1525
|
-
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 CreateEntityData, 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 UpdateEntityData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
|
|
1606
|
+
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 Comment, type CommentCreateData, type CommentDeleteData, type CommentListParams, type CommentListResponse, type CommentType, type CommentUpdateData, type Coupon, type CouponType, type CouponValidation, type CreateCommentData, type CreateEntityData, 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 UpdateEntityData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
|
package/dist/index.js
CHANGED
|
@@ -122,7 +122,7 @@ var HttpClient = class {
|
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* Build request headers
|
|
125
|
-
* API key
|
|
125
|
+
* Both API key and bearer token can be sent together
|
|
126
126
|
*/
|
|
127
127
|
buildHeaders(customHeaders) {
|
|
128
128
|
const headers = {
|
|
@@ -132,7 +132,8 @@ var HttpClient = class {
|
|
|
132
132
|
};
|
|
133
133
|
if (this.apiKey) {
|
|
134
134
|
headers["X-API-Key"] = this.apiKey;
|
|
135
|
-
}
|
|
135
|
+
}
|
|
136
|
+
if (this.token) {
|
|
136
137
|
headers["Authorization"] = `Bearer ${this.token}`;
|
|
137
138
|
}
|
|
138
139
|
return headers;
|
|
@@ -227,7 +228,8 @@ var HttpClient = class {
|
|
|
227
228
|
};
|
|
228
229
|
if (this.apiKey) {
|
|
229
230
|
headers["X-API-Key"] = this.apiKey;
|
|
230
|
-
}
|
|
231
|
+
}
|
|
232
|
+
if (this.token) {
|
|
231
233
|
headers["Authorization"] = `Bearer ${this.token}`;
|
|
232
234
|
}
|
|
233
235
|
const controller = new AbortController();
|
|
@@ -538,6 +540,67 @@ var BlogResource = class {
|
|
|
538
540
|
}
|
|
539
541
|
};
|
|
540
542
|
|
|
543
|
+
// src/resources/comments.ts
|
|
544
|
+
var CommentsResource = class {
|
|
545
|
+
constructor(http) {
|
|
546
|
+
this.http = http;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Get comments for a board post
|
|
550
|
+
*/
|
|
551
|
+
async boardPost(postId, params) {
|
|
552
|
+
return this.http.get(`/posts/${postId}/comments`, params);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Create a comment on a board post
|
|
556
|
+
*/
|
|
557
|
+
async createBoardPost(postId, data) {
|
|
558
|
+
return this.http.post(`/posts/${postId}/comments`, data);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Get comments for a blog post
|
|
562
|
+
*/
|
|
563
|
+
async blogPost(slug, params) {
|
|
564
|
+
return this.http.get(`/blog/${slug}/comments`, params);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Create a comment on a blog post
|
|
568
|
+
*/
|
|
569
|
+
async createBlogPost(slug, data) {
|
|
570
|
+
return this.http.post(`/blog/${slug}/comments`, data);
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Get standalone comments (guestbook, feedback, etc.)
|
|
574
|
+
*/
|
|
575
|
+
async standalone(pageSlug, params) {
|
|
576
|
+
return this.http.get(`/comments/${pageSlug}`, params);
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Create a standalone comment
|
|
580
|
+
*/
|
|
581
|
+
async createStandalone(pageSlug, data) {
|
|
582
|
+
return this.http.post(`/comments/${pageSlug}`, data);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Update a comment
|
|
586
|
+
*/
|
|
587
|
+
async update(commentId, data) {
|
|
588
|
+
return this.http.put(`/comments/${commentId}`, data);
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Delete a comment
|
|
592
|
+
*/
|
|
593
|
+
async delete(commentId, data) {
|
|
594
|
+
return this.http.delete(`/comments/${commentId}`, data);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Like a comment
|
|
598
|
+
*/
|
|
599
|
+
async like(commentId) {
|
|
600
|
+
return this.http.post(`/comments/${commentId}/like`);
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
|
|
541
604
|
// src/resources/forms.ts
|
|
542
605
|
var FormsResource = class {
|
|
543
606
|
constructor(http) {
|
|
@@ -1153,6 +1216,7 @@ var Promptly = class {
|
|
|
1153
1216
|
this.auth = new AuthResource(this.http);
|
|
1154
1217
|
this.boards = new BoardsResource(this.http);
|
|
1155
1218
|
this.blog = new BlogResource(this.http);
|
|
1219
|
+
this.comments = new CommentsResource(this.http);
|
|
1156
1220
|
this.forms = new FormsResource(this.http);
|
|
1157
1221
|
this.shop = new ShopResource(this.http);
|
|
1158
1222
|
this.media = new MediaResource(this.http);
|
package/dist/index.mjs
CHANGED
|
@@ -94,7 +94,7 @@ var HttpClient = class {
|
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* Build request headers
|
|
97
|
-
* API key
|
|
97
|
+
* Both API key and bearer token can be sent together
|
|
98
98
|
*/
|
|
99
99
|
buildHeaders(customHeaders) {
|
|
100
100
|
const headers = {
|
|
@@ -104,7 +104,8 @@ var HttpClient = class {
|
|
|
104
104
|
};
|
|
105
105
|
if (this.apiKey) {
|
|
106
106
|
headers["X-API-Key"] = this.apiKey;
|
|
107
|
-
}
|
|
107
|
+
}
|
|
108
|
+
if (this.token) {
|
|
108
109
|
headers["Authorization"] = `Bearer ${this.token}`;
|
|
109
110
|
}
|
|
110
111
|
return headers;
|
|
@@ -199,7 +200,8 @@ var HttpClient = class {
|
|
|
199
200
|
};
|
|
200
201
|
if (this.apiKey) {
|
|
201
202
|
headers["X-API-Key"] = this.apiKey;
|
|
202
|
-
}
|
|
203
|
+
}
|
|
204
|
+
if (this.token) {
|
|
203
205
|
headers["Authorization"] = `Bearer ${this.token}`;
|
|
204
206
|
}
|
|
205
207
|
const controller = new AbortController();
|
|
@@ -510,6 +512,67 @@ var BlogResource = class {
|
|
|
510
512
|
}
|
|
511
513
|
};
|
|
512
514
|
|
|
515
|
+
// src/resources/comments.ts
|
|
516
|
+
var CommentsResource = class {
|
|
517
|
+
constructor(http) {
|
|
518
|
+
this.http = http;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get comments for a board post
|
|
522
|
+
*/
|
|
523
|
+
async boardPost(postId, params) {
|
|
524
|
+
return this.http.get(`/posts/${postId}/comments`, params);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Create a comment on a board post
|
|
528
|
+
*/
|
|
529
|
+
async createBoardPost(postId, data) {
|
|
530
|
+
return this.http.post(`/posts/${postId}/comments`, data);
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Get comments for a blog post
|
|
534
|
+
*/
|
|
535
|
+
async blogPost(slug, params) {
|
|
536
|
+
return this.http.get(`/blog/${slug}/comments`, params);
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Create a comment on a blog post
|
|
540
|
+
*/
|
|
541
|
+
async createBlogPost(slug, data) {
|
|
542
|
+
return this.http.post(`/blog/${slug}/comments`, data);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Get standalone comments (guestbook, feedback, etc.)
|
|
546
|
+
*/
|
|
547
|
+
async standalone(pageSlug, params) {
|
|
548
|
+
return this.http.get(`/comments/${pageSlug}`, params);
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Create a standalone comment
|
|
552
|
+
*/
|
|
553
|
+
async createStandalone(pageSlug, data) {
|
|
554
|
+
return this.http.post(`/comments/${pageSlug}`, data);
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Update a comment
|
|
558
|
+
*/
|
|
559
|
+
async update(commentId, data) {
|
|
560
|
+
return this.http.put(`/comments/${commentId}`, data);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Delete a comment
|
|
564
|
+
*/
|
|
565
|
+
async delete(commentId, data) {
|
|
566
|
+
return this.http.delete(`/comments/${commentId}`, data);
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Like a comment
|
|
570
|
+
*/
|
|
571
|
+
async like(commentId) {
|
|
572
|
+
return this.http.post(`/comments/${commentId}/like`);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
|
|
513
576
|
// src/resources/forms.ts
|
|
514
577
|
var FormsResource = class {
|
|
515
578
|
constructor(http) {
|
|
@@ -1125,6 +1188,7 @@ var Promptly = class {
|
|
|
1125
1188
|
this.auth = new AuthResource(this.http);
|
|
1126
1189
|
this.boards = new BoardsResource(this.http);
|
|
1127
1190
|
this.blog = new BlogResource(this.http);
|
|
1191
|
+
this.comments = new CommentsResource(this.http);
|
|
1128
1192
|
this.forms = new FormsResource(this.http);
|
|
1129
1193
|
this.shop = new ShopResource(this.http);
|
|
1130
1194
|
this.media = new MediaResource(this.http);
|