@back23/promptly-sdk 1.3.2 → 2.0.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 CHANGED
@@ -15,10 +15,40 @@ import { Promptly } from '@back23/promptly-sdk';
15
15
 
16
16
  const client = new Promptly({
17
17
  tenantId: 'demo',
18
- baseUrl: 'https://promptly.webbyon.com',
18
+ apiKey: 'pky_your_api_key_here', // Required - Get from Dashboard > Settings > API Tokens
19
+ baseUrl: 'https://promptly.webbyon.com', // Optional
20
+ });
21
+
22
+ // All API calls require API key
23
+ const { data: posts } = await client.blog.list();
24
+ const products = await client.shop.listProducts();
25
+ ```
26
+
27
+ ## v2.0.0 Breaking Changes
28
+
29
+ ### API Key Required
30
+
31
+ **All API requests now require an API key.** There are no public APIs - this ensures security and proper tenant isolation.
32
+
33
+ ```typescript
34
+ // ❌ v1.x - apiKey was optional
35
+ const client = new Promptly({
36
+ tenantId: 'demo',
37
+ });
38
+
39
+ // ✅ v2.0 - apiKey is REQUIRED
40
+ const client = new Promptly({
41
+ tenantId: 'demo',
42
+ apiKey: 'pky_xxxxxxxxxxxxxxxxxxxxxxxx',
19
43
  });
20
44
  ```
21
45
 
46
+ Get your API key from: **Dashboard > Settings > API Tokens**
47
+
48
+ The SDK automatically includes the `X-API-Key` header in all requests.
49
+
50
+ ---
51
+
22
52
  ## v1.3.0 Changes
23
53
 
24
54
  ### Unified Response Structure
@@ -53,10 +83,11 @@ data.map(post => ...); // data is always an array
53
83
 
54
84
  ## API Overview
55
85
 
56
- | Resource | Public (No Auth) | Protected (Auth Required) |
57
- |----------|------------------|---------------------------|
58
- | **Boards** | list, get | - |
59
- | **Posts** | listPosts, getPost | createPost, updatePost, deletePost |
86
+ > **Note:** All APIs require API key (v2.0+). "Auth Required" means additional member login token is needed.
87
+
88
+ | Resource | Read Operations | Write Operations (Auth Required) |
89
+ |----------|-----------------|----------------------------------|
90
+ | **Boards** | list, get, listPosts, getPost, listComments | createPost, updatePost, deletePost |
60
91
  | **Comments** | listComments | createComment, updateComment, deleteComment |
61
92
  | **Blog** | list, get, featured, byCategory, byTag | - |
62
93
  | **Shop** | listProducts, getProduct, listCategories | getCart, addToCart, listOrders, createOrder |
@@ -68,7 +99,7 @@ data.map(post => ...); // data is always an array
68
99
 
69
100
  ## API Reference
70
101
 
71
- ### Boards (게시판) - Public
102
+ ### Boards (게시판)
72
103
 
73
104
  ```typescript
74
105
  // 게시판 목록
@@ -134,7 +165,7 @@ await client.boards.updateComment(commentId, {
134
165
  await client.boards.deleteComment(commentId);
135
166
  ```
136
167
 
137
- ### Blog (블로그) - Public
168
+ ### Blog (블로그)
138
169
 
139
170
  ```typescript
140
171
  // 블로그 글 목록
@@ -400,7 +431,7 @@ const response = await client.auth.socialCallback('google', code);
400
431
  // Returns: { member: Member, token: string }
401
432
  ```
402
433
 
403
- ### Forms (폼) - Public
434
+ ### Forms (폼)
404
435
 
405
436
  ```typescript
406
437
  // 폼 목록
@@ -529,7 +560,7 @@ await customers.create({
529
560
  });
530
561
  ```
531
562
 
532
- ### Site Settings - Public
563
+ ### Site Settings
533
564
 
534
565
  ```typescript
535
566
  // 테마 설정
@@ -543,6 +574,21 @@ const settings = await client.getSettings();
543
574
 
544
575
  ## Types
545
576
 
577
+ ### Configuration
578
+
579
+ ```typescript
580
+ interface PromptlyConfig {
581
+ /** Tenant ID (subdomain) */
582
+ tenantId: string;
583
+ /** API key (required) - Get from Dashboard > Settings > API Tokens */
584
+ apiKey: string;
585
+ /** Base URL of Promptly API (optional) */
586
+ baseUrl?: string;
587
+ /** Request timeout in milliseconds (optional) */
588
+ timeout?: number;
589
+ }
590
+ ```
591
+
546
592
  ### Common Types
547
593
 
548
594
  ```typescript
@@ -720,6 +766,7 @@ import { Promptly } from '@back23/promptly-sdk';
720
766
 
721
767
  const client = new Promptly({
722
768
  tenantId: 'demo',
769
+ apiKey: process.env.NEXT_PUBLIC_PROMPTLY_API_KEY!, // Required
723
770
  baseUrl: 'https://promptly.webbyon.com',
724
771
  });
725
772
 
package/dist/index.d.mts CHANGED
@@ -4,6 +4,8 @@
4
4
  interface PromptlyConfig {
5
5
  /** Tenant ID (subdomain) */
6
6
  tenantId: string;
7
+ /** API key (required) - Get from Dashboard > Settings > API Tokens */
8
+ apiKey: string;
7
9
  /** Base URL of Promptly API */
8
10
  baseUrl?: string;
9
11
  /** Request timeout in milliseconds */
@@ -744,6 +746,7 @@ declare class HttpClient {
744
746
  private tenantId;
745
747
  private timeout;
746
748
  private token;
749
+ private apiKey;
747
750
  constructor(config: PromptlyConfig);
748
751
  /**
749
752
  * Set authentication token
@@ -757,12 +760,21 @@ declare class HttpClient {
757
760
  * Check if authenticated
758
761
  */
759
762
  isAuthenticated(): boolean;
763
+ /**
764
+ * Set API key for server-to-server authentication
765
+ */
766
+ setApiKey(apiKey: string | null): void;
767
+ /**
768
+ * Get current API key
769
+ */
770
+ getApiKey(): string | null;
760
771
  /**
761
772
  * Build full URL with query params
762
773
  */
763
774
  private buildUrl;
764
775
  /**
765
776
  * Build request headers
777
+ * API key takes precedence over bearer token for server-to-server auth
766
778
  */
767
779
  private buildHeaders;
768
780
  /**
@@ -1354,6 +1366,7 @@ declare class ReservationResource {
1354
1366
  * Promptly SDK
1355
1367
  *
1356
1368
  * A TypeScript/JavaScript SDK for the Promptly AI CMS platform.
1369
+ * API Key is required for all API requests.
1357
1370
  *
1358
1371
  * @example
1359
1372
  * ```typescript
@@ -1361,18 +1374,12 @@ declare class ReservationResource {
1361
1374
  *
1362
1375
  * const client = new Promptly({
1363
1376
  * tenantId: 'my-site',
1364
- * baseUrl: 'https://promptly.webbyon.com',
1377
+ * apiKey: 'pky_your_api_key_here', // Required
1365
1378
  * });
1366
1379
  *
1367
- * // Public API
1380
+ * // All APIs require API key
1368
1381
  * const posts = await client.blog.list();
1369
1382
  * const products = await client.shop.listProducts();
1370
- *
1371
- * // Authentication
1372
- * await client.auth.login({ email: 'user@example.com', password: 'password' });
1373
- *
1374
- * // Protected API
1375
- * const orders = await client.shop.listOrders();
1376
1383
  * ```
1377
1384
  */
1378
1385
 
@@ -1419,6 +1426,26 @@ declare class Promptly {
1419
1426
  * Get current authentication token
1420
1427
  */
1421
1428
  getToken(): string | null;
1429
+ /**
1430
+ * Set API key for server-to-server authentication
1431
+ * Alternative to user token authentication
1432
+ *
1433
+ * @example
1434
+ * ```typescript
1435
+ * const client = new Promptly({
1436
+ * tenantId: 'my-site',
1437
+ * apiKey: 'pky_your_api_key_here',
1438
+ * });
1439
+ *
1440
+ * // Or set later
1441
+ * client.setApiKey('pky_your_api_key_here');
1442
+ * ```
1443
+ */
1444
+ setApiKey(apiKey: string | null): void;
1445
+ /**
1446
+ * Get current API key
1447
+ */
1448
+ getApiKey(): string | null;
1422
1449
  }
1423
1450
 
1424
1451
  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 };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@
4
4
  interface PromptlyConfig {
5
5
  /** Tenant ID (subdomain) */
6
6
  tenantId: string;
7
+ /** API key (required) - Get from Dashboard > Settings > API Tokens */
8
+ apiKey: string;
7
9
  /** Base URL of Promptly API */
8
10
  baseUrl?: string;
9
11
  /** Request timeout in milliseconds */
@@ -744,6 +746,7 @@ declare class HttpClient {
744
746
  private tenantId;
745
747
  private timeout;
746
748
  private token;
749
+ private apiKey;
747
750
  constructor(config: PromptlyConfig);
748
751
  /**
749
752
  * Set authentication token
@@ -757,12 +760,21 @@ declare class HttpClient {
757
760
  * Check if authenticated
758
761
  */
759
762
  isAuthenticated(): boolean;
763
+ /**
764
+ * Set API key for server-to-server authentication
765
+ */
766
+ setApiKey(apiKey: string | null): void;
767
+ /**
768
+ * Get current API key
769
+ */
770
+ getApiKey(): string | null;
760
771
  /**
761
772
  * Build full URL with query params
762
773
  */
763
774
  private buildUrl;
764
775
  /**
765
776
  * Build request headers
777
+ * API key takes precedence over bearer token for server-to-server auth
766
778
  */
767
779
  private buildHeaders;
768
780
  /**
@@ -1354,6 +1366,7 @@ declare class ReservationResource {
1354
1366
  * Promptly SDK
1355
1367
  *
1356
1368
  * A TypeScript/JavaScript SDK for the Promptly AI CMS platform.
1369
+ * API Key is required for all API requests.
1357
1370
  *
1358
1371
  * @example
1359
1372
  * ```typescript
@@ -1361,18 +1374,12 @@ declare class ReservationResource {
1361
1374
  *
1362
1375
  * const client = new Promptly({
1363
1376
  * tenantId: 'my-site',
1364
- * baseUrl: 'https://promptly.webbyon.com',
1377
+ * apiKey: 'pky_your_api_key_here', // Required
1365
1378
  * });
1366
1379
  *
1367
- * // Public API
1380
+ * // All APIs require API key
1368
1381
  * const posts = await client.blog.list();
1369
1382
  * const products = await client.shop.listProducts();
1370
- *
1371
- * // Authentication
1372
- * await client.auth.login({ email: 'user@example.com', password: 'password' });
1373
- *
1374
- * // Protected API
1375
- * const orders = await client.shop.listOrders();
1376
1383
  * ```
1377
1384
  */
1378
1385
 
@@ -1419,6 +1426,26 @@ declare class Promptly {
1419
1426
  * Get current authentication token
1420
1427
  */
1421
1428
  getToken(): string | null;
1429
+ /**
1430
+ * Set API key for server-to-server authentication
1431
+ * Alternative to user token authentication
1432
+ *
1433
+ * @example
1434
+ * ```typescript
1435
+ * const client = new Promptly({
1436
+ * tenantId: 'my-site',
1437
+ * apiKey: 'pky_your_api_key_here',
1438
+ * });
1439
+ *
1440
+ * // Or set later
1441
+ * client.setApiKey('pky_your_api_key_here');
1442
+ * ```
1443
+ */
1444
+ setApiKey(apiKey: string | null): void;
1445
+ /**
1446
+ * Get current API key
1447
+ */
1448
+ getApiKey(): string | null;
1422
1449
  }
1423
1450
 
1424
1451
  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 };
package/dist/index.js CHANGED
@@ -70,9 +70,11 @@ var PromptlyError = class extends Error {
70
70
  var HttpClient = class {
71
71
  constructor(config) {
72
72
  this.token = null;
73
+ this.apiKey = null;
73
74
  this.tenantId = config.tenantId;
74
75
  this.baseUrl = (config.baseUrl || "https://promptly.webbyon.com").replace(/\/$/, "");
75
76
  this.timeout = config.timeout || 3e4;
77
+ this.apiKey = config.apiKey || null;
76
78
  }
77
79
  /**
78
80
  * Set authentication token
@@ -90,7 +92,19 @@ var HttpClient = class {
90
92
  * Check if authenticated
91
93
  */
92
94
  isAuthenticated() {
93
- return this.token !== null;
95
+ return this.token !== null || this.apiKey !== null;
96
+ }
97
+ /**
98
+ * Set API key for server-to-server authentication
99
+ */
100
+ setApiKey(apiKey) {
101
+ this.apiKey = apiKey;
102
+ }
103
+ /**
104
+ * Get current API key
105
+ */
106
+ getApiKey() {
107
+ return this.apiKey;
94
108
  }
95
109
  /**
96
110
  * Build full URL with query params
@@ -108,6 +122,7 @@ var HttpClient = class {
108
122
  }
109
123
  /**
110
124
  * Build request headers
125
+ * API key takes precedence over bearer token for server-to-server auth
111
126
  */
112
127
  buildHeaders(customHeaders) {
113
128
  const headers = {
@@ -115,7 +130,9 @@ var HttpClient = class {
115
130
  "Accept": "application/json",
116
131
  ...customHeaders
117
132
  };
118
- if (this.token) {
133
+ if (this.apiKey) {
134
+ headers["X-API-Key"] = this.apiKey;
135
+ } else if (this.token) {
119
136
  headers["Authorization"] = `Bearer ${this.token}`;
120
137
  }
121
138
  return headers;
@@ -208,7 +225,9 @@ var HttpClient = class {
208
225
  const headers = {
209
226
  "Accept": "application/json"
210
227
  };
211
- if (this.token) {
228
+ if (this.apiKey) {
229
+ headers["X-API-Key"] = this.apiKey;
230
+ } else if (this.token) {
212
231
  headers["Authorization"] = `Bearer ${this.token}`;
213
232
  }
214
233
  const controller = new AbortController();
@@ -1065,6 +1084,9 @@ var ReservationResource = class {
1065
1084
  // src/index.ts
1066
1085
  var Promptly = class {
1067
1086
  constructor(config) {
1087
+ if (!config.apiKey) {
1088
+ throw new Error("API key is required. Get your API key from Dashboard > Settings > API Tokens");
1089
+ }
1068
1090
  this.http = new HttpClient(config);
1069
1091
  this.auth = new AuthResource(this.http);
1070
1092
  this.boards = new BoardsResource(this.http);
@@ -1105,6 +1127,30 @@ var Promptly = class {
1105
1127
  getToken() {
1106
1128
  return this.auth.getToken();
1107
1129
  }
1130
+ /**
1131
+ * Set API key for server-to-server authentication
1132
+ * Alternative to user token authentication
1133
+ *
1134
+ * @example
1135
+ * ```typescript
1136
+ * const client = new Promptly({
1137
+ * tenantId: 'my-site',
1138
+ * apiKey: 'pky_your_api_key_here',
1139
+ * });
1140
+ *
1141
+ * // Or set later
1142
+ * client.setApiKey('pky_your_api_key_here');
1143
+ * ```
1144
+ */
1145
+ setApiKey(apiKey) {
1146
+ this.http.setApiKey(apiKey);
1147
+ }
1148
+ /**
1149
+ * Get current API key
1150
+ */
1151
+ getApiKey() {
1152
+ return this.http.getApiKey();
1153
+ }
1108
1154
  };
1109
1155
  var index_default = Promptly;
1110
1156
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -42,9 +42,11 @@ var PromptlyError = class extends Error {
42
42
  var HttpClient = class {
43
43
  constructor(config) {
44
44
  this.token = null;
45
+ this.apiKey = null;
45
46
  this.tenantId = config.tenantId;
46
47
  this.baseUrl = (config.baseUrl || "https://promptly.webbyon.com").replace(/\/$/, "");
47
48
  this.timeout = config.timeout || 3e4;
49
+ this.apiKey = config.apiKey || null;
48
50
  }
49
51
  /**
50
52
  * Set authentication token
@@ -62,7 +64,19 @@ var HttpClient = class {
62
64
  * Check if authenticated
63
65
  */
64
66
  isAuthenticated() {
65
- return this.token !== null;
67
+ return this.token !== null || this.apiKey !== null;
68
+ }
69
+ /**
70
+ * Set API key for server-to-server authentication
71
+ */
72
+ setApiKey(apiKey) {
73
+ this.apiKey = apiKey;
74
+ }
75
+ /**
76
+ * Get current API key
77
+ */
78
+ getApiKey() {
79
+ return this.apiKey;
66
80
  }
67
81
  /**
68
82
  * Build full URL with query params
@@ -80,6 +94,7 @@ var HttpClient = class {
80
94
  }
81
95
  /**
82
96
  * Build request headers
97
+ * API key takes precedence over bearer token for server-to-server auth
83
98
  */
84
99
  buildHeaders(customHeaders) {
85
100
  const headers = {
@@ -87,7 +102,9 @@ var HttpClient = class {
87
102
  "Accept": "application/json",
88
103
  ...customHeaders
89
104
  };
90
- if (this.token) {
105
+ if (this.apiKey) {
106
+ headers["X-API-Key"] = this.apiKey;
107
+ } else if (this.token) {
91
108
  headers["Authorization"] = `Bearer ${this.token}`;
92
109
  }
93
110
  return headers;
@@ -180,7 +197,9 @@ var HttpClient = class {
180
197
  const headers = {
181
198
  "Accept": "application/json"
182
199
  };
183
- if (this.token) {
200
+ if (this.apiKey) {
201
+ headers["X-API-Key"] = this.apiKey;
202
+ } else if (this.token) {
184
203
  headers["Authorization"] = `Bearer ${this.token}`;
185
204
  }
186
205
  const controller = new AbortController();
@@ -1037,6 +1056,9 @@ var ReservationResource = class {
1037
1056
  // src/index.ts
1038
1057
  var Promptly = class {
1039
1058
  constructor(config) {
1059
+ if (!config.apiKey) {
1060
+ throw new Error("API key is required. Get your API key from Dashboard > Settings > API Tokens");
1061
+ }
1040
1062
  this.http = new HttpClient(config);
1041
1063
  this.auth = new AuthResource(this.http);
1042
1064
  this.boards = new BoardsResource(this.http);
@@ -1077,6 +1099,30 @@ var Promptly = class {
1077
1099
  getToken() {
1078
1100
  return this.auth.getToken();
1079
1101
  }
1102
+ /**
1103
+ * Set API key for server-to-server authentication
1104
+ * Alternative to user token authentication
1105
+ *
1106
+ * @example
1107
+ * ```typescript
1108
+ * const client = new Promptly({
1109
+ * tenantId: 'my-site',
1110
+ * apiKey: 'pky_your_api_key_here',
1111
+ * });
1112
+ *
1113
+ * // Or set later
1114
+ * client.setApiKey('pky_your_api_key_here');
1115
+ * ```
1116
+ */
1117
+ setApiKey(apiKey) {
1118
+ this.http.setApiKey(apiKey);
1119
+ }
1120
+ /**
1121
+ * Get current API key
1122
+ */
1123
+ getApiKey() {
1124
+ return this.http.getApiKey();
1125
+ }
1080
1126
  };
1081
1127
  var index_default = Promptly;
1082
1128
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@back23/promptly-sdk",
3
- "version": "1.3.2",
3
+ "version": "2.0.1",
4
4
  "description": "Promptly AI CMS SDK for JavaScript/TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",