perspectapi-ts-sdk 1.3.0 → 1.4.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 +35 -20
- package/dist/index.d.ts +35 -20
- package/dist/index.js +7 -3
- package/dist/index.mjs +7 -3
- package/package.json +1 -1
- package/src/client/contact-client.ts +10 -19
- package/src/client/newsletter-client.ts +4 -3
- package/src/index.ts +3 -0
- package/src/types/index.ts +34 -3
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,8 @@ interface ApiResponse<T = any> {
|
|
|
5
5
|
data?: T;
|
|
6
6
|
message?: string;
|
|
7
7
|
error?: string;
|
|
8
|
-
success
|
|
8
|
+
success: boolean;
|
|
9
|
+
code?: string;
|
|
9
10
|
}
|
|
10
11
|
interface PaginationParams {
|
|
11
12
|
page?: number;
|
|
@@ -121,7 +122,6 @@ interface CreateNewsletterSubscriptionRequest {
|
|
|
121
122
|
source?: string;
|
|
122
123
|
source_url?: string;
|
|
123
124
|
double_opt_in?: boolean;
|
|
124
|
-
turnstile_token?: string;
|
|
125
125
|
metadata?: Record<string, any>;
|
|
126
126
|
}
|
|
127
127
|
interface NewsletterList {
|
|
@@ -142,6 +142,8 @@ interface NewsletterPreferences {
|
|
|
142
142
|
track_clicks?: boolean;
|
|
143
143
|
}
|
|
144
144
|
interface NewsletterStatusResponse {
|
|
145
|
+
success: boolean;
|
|
146
|
+
code?: string;
|
|
145
147
|
subscribed: boolean;
|
|
146
148
|
status: string;
|
|
147
149
|
frequency?: string;
|
|
@@ -149,12 +151,17 @@ interface NewsletterStatusResponse {
|
|
|
149
151
|
confirmed_at?: string;
|
|
150
152
|
}
|
|
151
153
|
interface NewsletterSubscribeResponse {
|
|
154
|
+
success: boolean;
|
|
155
|
+
code: string;
|
|
152
156
|
message: string;
|
|
153
157
|
status: string;
|
|
154
158
|
subscription_id?: string;
|
|
155
159
|
}
|
|
156
160
|
interface NewsletterConfirmResponse {
|
|
161
|
+
success: boolean;
|
|
162
|
+
code: string;
|
|
157
163
|
message: string;
|
|
164
|
+
status?: string;
|
|
158
165
|
subscription?: {
|
|
159
166
|
email: string;
|
|
160
167
|
name?: string;
|
|
@@ -166,6 +173,12 @@ interface NewsletterUnsubscribeRequest {
|
|
|
166
173
|
email?: string;
|
|
167
174
|
reason?: string;
|
|
168
175
|
}
|
|
176
|
+
interface NewsletterUnsubscribeResponse {
|
|
177
|
+
success: boolean;
|
|
178
|
+
code: string;
|
|
179
|
+
message: string;
|
|
180
|
+
status?: string;
|
|
181
|
+
}
|
|
169
182
|
type ContentStatus = 'draft' | 'publish' | 'private' | 'trash';
|
|
170
183
|
type ContentType = 'post' | 'page';
|
|
171
184
|
interface Content {
|
|
@@ -374,7 +387,22 @@ interface CreateContactRequest {
|
|
|
374
387
|
email: string;
|
|
375
388
|
subject?: string;
|
|
376
389
|
message: string;
|
|
377
|
-
|
|
390
|
+
}
|
|
391
|
+
interface ContactSubmitResponse {
|
|
392
|
+
success: boolean;
|
|
393
|
+
code: string;
|
|
394
|
+
contact_id: string;
|
|
395
|
+
message: string;
|
|
396
|
+
status: string;
|
|
397
|
+
}
|
|
398
|
+
interface ContactStatusResponse {
|
|
399
|
+
success: boolean;
|
|
400
|
+
code: string;
|
|
401
|
+
contact_id: string;
|
|
402
|
+
status: string;
|
|
403
|
+
submitted_at: string;
|
|
404
|
+
processed_at?: string;
|
|
405
|
+
metadata?: Record<string, any>;
|
|
378
406
|
}
|
|
379
407
|
interface ApiError {
|
|
380
408
|
message: string;
|
|
@@ -1462,20 +1490,11 @@ declare class ContactClient extends BaseClient {
|
|
|
1462
1490
|
* @param data - Contact form data
|
|
1463
1491
|
* @param csrfToken - CSRF token (required for browser-based submissions)
|
|
1464
1492
|
*/
|
|
1465
|
-
submitContact(siteName: string, data: CreateContactRequest, csrfToken?: string): Promise<ApiResponse<
|
|
1466
|
-
id: string;
|
|
1467
|
-
message: string;
|
|
1468
|
-
status: string;
|
|
1469
|
-
}>>;
|
|
1493
|
+
submitContact(siteName: string, data: CreateContactRequest, csrfToken?: string): Promise<ApiResponse<ContactSubmitResponse>>;
|
|
1470
1494
|
/**
|
|
1471
1495
|
* Get contact submission status
|
|
1472
1496
|
*/
|
|
1473
|
-
getContactStatus(siteName: string, id: string): Promise<ApiResponse<
|
|
1474
|
-
id: string;
|
|
1475
|
-
status: string;
|
|
1476
|
-
submittedAt: string;
|
|
1477
|
-
processedAt?: string;
|
|
1478
|
-
}>>;
|
|
1497
|
+
getContactStatus(siteName: string, id: string): Promise<ApiResponse<ContactStatusResponse>>;
|
|
1479
1498
|
/**
|
|
1480
1499
|
* Get all contact submissions (admin only)
|
|
1481
1500
|
*/
|
|
@@ -1572,7 +1591,6 @@ declare class ContactClient extends BaseClient {
|
|
|
1572
1591
|
* Get contact form configuration
|
|
1573
1592
|
*/
|
|
1574
1593
|
getContactConfig(siteName: string): Promise<ApiResponse<{
|
|
1575
|
-
turnstileEnabled: boolean;
|
|
1576
1594
|
rateLimitEnabled: boolean;
|
|
1577
1595
|
rateLimitWindow: number;
|
|
1578
1596
|
rateLimitMax: number;
|
|
@@ -1588,7 +1606,6 @@ declare class ContactClient extends BaseClient {
|
|
|
1588
1606
|
* Update contact form configuration (admin only)
|
|
1589
1607
|
*/
|
|
1590
1608
|
updateContactConfig(siteName: string, data: {
|
|
1591
|
-
turnstileEnabled?: boolean;
|
|
1592
1609
|
rateLimitEnabled?: boolean;
|
|
1593
1610
|
rateLimitWindow?: number;
|
|
1594
1611
|
rateLimitMax?: number;
|
|
@@ -1631,9 +1648,7 @@ declare class NewsletterClient extends BaseClient {
|
|
|
1631
1648
|
* @param data - Unsubscribe data
|
|
1632
1649
|
* @param csrfToken - CSRF token (required for browser-based submissions)
|
|
1633
1650
|
*/
|
|
1634
|
-
unsubscribe(siteName: string, data: NewsletterUnsubscribeRequest, csrfToken?: string): Promise<ApiResponse<
|
|
1635
|
-
message: string;
|
|
1636
|
-
}>>;
|
|
1651
|
+
unsubscribe(siteName: string, data: NewsletterUnsubscribeRequest, csrfToken?: string): Promise<ApiResponse<NewsletterUnsubscribeResponse>>;
|
|
1637
1652
|
/**
|
|
1638
1653
|
* One-click unsubscribe via token (GET request)
|
|
1639
1654
|
*/
|
|
@@ -2042,4 +2057,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
2042
2057
|
error: string;
|
|
2043
2058
|
}>;
|
|
2044
2059
|
|
|
2045
|
-
export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, type AuthResponse, BaseClient, type BlogPost, CategoriesClient, type Category, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, ContactClient, type ContactSubmission, type Content, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, HttpClient, type HttpMethod, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, ProductsClient, type RequestOptions, type SignInRequest, type SignUpRequest, type Site, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type User, type Webhook, WebhooksClient, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformProduct };
|
|
2060
|
+
export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, type AuthResponse, BaseClient, type BlogPost, CategoriesClient, type Category, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, HttpClient, type HttpMethod, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, ProductsClient, type RequestOptions, type SignInRequest, type SignUpRequest, type Site, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type User, type Webhook, WebhooksClient, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformProduct };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ interface ApiResponse<T = any> {
|
|
|
5
5
|
data?: T;
|
|
6
6
|
message?: string;
|
|
7
7
|
error?: string;
|
|
8
|
-
success
|
|
8
|
+
success: boolean;
|
|
9
|
+
code?: string;
|
|
9
10
|
}
|
|
10
11
|
interface PaginationParams {
|
|
11
12
|
page?: number;
|
|
@@ -121,7 +122,6 @@ interface CreateNewsletterSubscriptionRequest {
|
|
|
121
122
|
source?: string;
|
|
122
123
|
source_url?: string;
|
|
123
124
|
double_opt_in?: boolean;
|
|
124
|
-
turnstile_token?: string;
|
|
125
125
|
metadata?: Record<string, any>;
|
|
126
126
|
}
|
|
127
127
|
interface NewsletterList {
|
|
@@ -142,6 +142,8 @@ interface NewsletterPreferences {
|
|
|
142
142
|
track_clicks?: boolean;
|
|
143
143
|
}
|
|
144
144
|
interface NewsletterStatusResponse {
|
|
145
|
+
success: boolean;
|
|
146
|
+
code?: string;
|
|
145
147
|
subscribed: boolean;
|
|
146
148
|
status: string;
|
|
147
149
|
frequency?: string;
|
|
@@ -149,12 +151,17 @@ interface NewsletterStatusResponse {
|
|
|
149
151
|
confirmed_at?: string;
|
|
150
152
|
}
|
|
151
153
|
interface NewsletterSubscribeResponse {
|
|
154
|
+
success: boolean;
|
|
155
|
+
code: string;
|
|
152
156
|
message: string;
|
|
153
157
|
status: string;
|
|
154
158
|
subscription_id?: string;
|
|
155
159
|
}
|
|
156
160
|
interface NewsletterConfirmResponse {
|
|
161
|
+
success: boolean;
|
|
162
|
+
code: string;
|
|
157
163
|
message: string;
|
|
164
|
+
status?: string;
|
|
158
165
|
subscription?: {
|
|
159
166
|
email: string;
|
|
160
167
|
name?: string;
|
|
@@ -166,6 +173,12 @@ interface NewsletterUnsubscribeRequest {
|
|
|
166
173
|
email?: string;
|
|
167
174
|
reason?: string;
|
|
168
175
|
}
|
|
176
|
+
interface NewsletterUnsubscribeResponse {
|
|
177
|
+
success: boolean;
|
|
178
|
+
code: string;
|
|
179
|
+
message: string;
|
|
180
|
+
status?: string;
|
|
181
|
+
}
|
|
169
182
|
type ContentStatus = 'draft' | 'publish' | 'private' | 'trash';
|
|
170
183
|
type ContentType = 'post' | 'page';
|
|
171
184
|
interface Content {
|
|
@@ -374,7 +387,22 @@ interface CreateContactRequest {
|
|
|
374
387
|
email: string;
|
|
375
388
|
subject?: string;
|
|
376
389
|
message: string;
|
|
377
|
-
|
|
390
|
+
}
|
|
391
|
+
interface ContactSubmitResponse {
|
|
392
|
+
success: boolean;
|
|
393
|
+
code: string;
|
|
394
|
+
contact_id: string;
|
|
395
|
+
message: string;
|
|
396
|
+
status: string;
|
|
397
|
+
}
|
|
398
|
+
interface ContactStatusResponse {
|
|
399
|
+
success: boolean;
|
|
400
|
+
code: string;
|
|
401
|
+
contact_id: string;
|
|
402
|
+
status: string;
|
|
403
|
+
submitted_at: string;
|
|
404
|
+
processed_at?: string;
|
|
405
|
+
metadata?: Record<string, any>;
|
|
378
406
|
}
|
|
379
407
|
interface ApiError {
|
|
380
408
|
message: string;
|
|
@@ -1462,20 +1490,11 @@ declare class ContactClient extends BaseClient {
|
|
|
1462
1490
|
* @param data - Contact form data
|
|
1463
1491
|
* @param csrfToken - CSRF token (required for browser-based submissions)
|
|
1464
1492
|
*/
|
|
1465
|
-
submitContact(siteName: string, data: CreateContactRequest, csrfToken?: string): Promise<ApiResponse<
|
|
1466
|
-
id: string;
|
|
1467
|
-
message: string;
|
|
1468
|
-
status: string;
|
|
1469
|
-
}>>;
|
|
1493
|
+
submitContact(siteName: string, data: CreateContactRequest, csrfToken?: string): Promise<ApiResponse<ContactSubmitResponse>>;
|
|
1470
1494
|
/**
|
|
1471
1495
|
* Get contact submission status
|
|
1472
1496
|
*/
|
|
1473
|
-
getContactStatus(siteName: string, id: string): Promise<ApiResponse<
|
|
1474
|
-
id: string;
|
|
1475
|
-
status: string;
|
|
1476
|
-
submittedAt: string;
|
|
1477
|
-
processedAt?: string;
|
|
1478
|
-
}>>;
|
|
1497
|
+
getContactStatus(siteName: string, id: string): Promise<ApiResponse<ContactStatusResponse>>;
|
|
1479
1498
|
/**
|
|
1480
1499
|
* Get all contact submissions (admin only)
|
|
1481
1500
|
*/
|
|
@@ -1572,7 +1591,6 @@ declare class ContactClient extends BaseClient {
|
|
|
1572
1591
|
* Get contact form configuration
|
|
1573
1592
|
*/
|
|
1574
1593
|
getContactConfig(siteName: string): Promise<ApiResponse<{
|
|
1575
|
-
turnstileEnabled: boolean;
|
|
1576
1594
|
rateLimitEnabled: boolean;
|
|
1577
1595
|
rateLimitWindow: number;
|
|
1578
1596
|
rateLimitMax: number;
|
|
@@ -1588,7 +1606,6 @@ declare class ContactClient extends BaseClient {
|
|
|
1588
1606
|
* Update contact form configuration (admin only)
|
|
1589
1607
|
*/
|
|
1590
1608
|
updateContactConfig(siteName: string, data: {
|
|
1591
|
-
turnstileEnabled?: boolean;
|
|
1592
1609
|
rateLimitEnabled?: boolean;
|
|
1593
1610
|
rateLimitWindow?: number;
|
|
1594
1611
|
rateLimitMax?: number;
|
|
@@ -1631,9 +1648,7 @@ declare class NewsletterClient extends BaseClient {
|
|
|
1631
1648
|
* @param data - Unsubscribe data
|
|
1632
1649
|
* @param csrfToken - CSRF token (required for browser-based submissions)
|
|
1633
1650
|
*/
|
|
1634
|
-
unsubscribe(siteName: string, data: NewsletterUnsubscribeRequest, csrfToken?: string): Promise<ApiResponse<
|
|
1635
|
-
message: string;
|
|
1636
|
-
}>>;
|
|
1651
|
+
unsubscribe(siteName: string, data: NewsletterUnsubscribeRequest, csrfToken?: string): Promise<ApiResponse<NewsletterUnsubscribeResponse>>;
|
|
1637
1652
|
/**
|
|
1638
1653
|
* One-click unsubscribe via token (GET request)
|
|
1639
1654
|
*/
|
|
@@ -2042,4 +2057,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
2042
2057
|
error: string;
|
|
2043
2058
|
}>;
|
|
2044
2059
|
|
|
2045
|
-
export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, type AuthResponse, BaseClient, type BlogPost, CategoriesClient, type Category, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, ContactClient, type ContactSubmission, type Content, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, HttpClient, type HttpMethod, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, ProductsClient, type RequestOptions, type SignInRequest, type SignUpRequest, type Site, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type User, type Webhook, WebhooksClient, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformProduct };
|
|
2060
|
+
export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, type AuthResponse, BaseClient, type BlogPost, CategoriesClient, type Category, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, HttpClient, type HttpMethod, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, ProductsClient, type RequestOptions, type SignInRequest, type SignUpRequest, type Site, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type User, type Webhook, WebhooksClient, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformProduct };
|
package/dist/index.js
CHANGED
|
@@ -1192,10 +1192,14 @@ var ContactClient = class extends BaseClient {
|
|
|
1192
1192
|
* @param csrfToken - CSRF token (required for browser-based submissions)
|
|
1193
1193
|
*/
|
|
1194
1194
|
async submitContact(siteName, data, csrfToken) {
|
|
1195
|
-
if (typeof window !== "undefined" && !csrfToken
|
|
1195
|
+
if (typeof window !== "undefined" && !csrfToken) {
|
|
1196
1196
|
console.warn("CSRF token recommended for browser-based contact form submissions");
|
|
1197
1197
|
}
|
|
1198
|
-
return this.create(
|
|
1198
|
+
return this.create(
|
|
1199
|
+
this.contactEndpoint(siteName, "/contact/submit"),
|
|
1200
|
+
data,
|
|
1201
|
+
csrfToken
|
|
1202
|
+
);
|
|
1199
1203
|
}
|
|
1200
1204
|
/**
|
|
1201
1205
|
* Get contact submission status
|
|
@@ -1295,7 +1299,7 @@ var NewsletterClient = class extends BaseClient {
|
|
|
1295
1299
|
* @param csrfToken - CSRF token (required for browser-based submissions)
|
|
1296
1300
|
*/
|
|
1297
1301
|
async subscribe(siteName, data, csrfToken) {
|
|
1298
|
-
if (typeof window !== "undefined" && !csrfToken
|
|
1302
|
+
if (typeof window !== "undefined" && !csrfToken) {
|
|
1299
1303
|
console.warn("CSRF token recommended for browser-based newsletter subscriptions");
|
|
1300
1304
|
}
|
|
1301
1305
|
return this.create(
|
package/dist/index.mjs
CHANGED
|
@@ -1141,10 +1141,14 @@ var ContactClient = class extends BaseClient {
|
|
|
1141
1141
|
* @param csrfToken - CSRF token (required for browser-based submissions)
|
|
1142
1142
|
*/
|
|
1143
1143
|
async submitContact(siteName, data, csrfToken) {
|
|
1144
|
-
if (typeof window !== "undefined" && !csrfToken
|
|
1144
|
+
if (typeof window !== "undefined" && !csrfToken) {
|
|
1145
1145
|
console.warn("CSRF token recommended for browser-based contact form submissions");
|
|
1146
1146
|
}
|
|
1147
|
-
return this.create(
|
|
1147
|
+
return this.create(
|
|
1148
|
+
this.contactEndpoint(siteName, "/contact/submit"),
|
|
1149
|
+
data,
|
|
1150
|
+
csrfToken
|
|
1151
|
+
);
|
|
1148
1152
|
}
|
|
1149
1153
|
/**
|
|
1150
1154
|
* Get contact submission status
|
|
@@ -1244,7 +1248,7 @@ var NewsletterClient = class extends BaseClient {
|
|
|
1244
1248
|
* @param csrfToken - CSRF token (required for browser-based submissions)
|
|
1245
1249
|
*/
|
|
1246
1250
|
async subscribe(siteName, data, csrfToken) {
|
|
1247
|
-
if (typeof window !== "undefined" && !csrfToken
|
|
1251
|
+
if (typeof window !== "undefined" && !csrfToken) {
|
|
1248
1252
|
console.warn("CSRF token recommended for browser-based newsletter subscriptions");
|
|
1249
1253
|
}
|
|
1250
1254
|
return this.create(
|
package/package.json
CHANGED
|
@@ -6,6 +6,8 @@ import { BaseClient } from './base-client';
|
|
|
6
6
|
import type {
|
|
7
7
|
ContactSubmission,
|
|
8
8
|
CreateContactRequest,
|
|
9
|
+
ContactSubmitResponse,
|
|
10
|
+
ContactStatusResponse,
|
|
9
11
|
PaginatedResponse,
|
|
10
12
|
ApiResponse,
|
|
11
13
|
} from '../types';
|
|
@@ -32,32 +34,23 @@ export class ContactClient extends BaseClient {
|
|
|
32
34
|
siteName: string,
|
|
33
35
|
data: CreateContactRequest,
|
|
34
36
|
csrfToken?: string
|
|
35
|
-
): Promise<ApiResponse<{
|
|
36
|
-
id: string;
|
|
37
|
-
message: string;
|
|
38
|
-
status: string;
|
|
39
|
-
}>> {
|
|
37
|
+
): Promise<ApiResponse<ContactSubmitResponse>> {
|
|
40
38
|
// CSRF token is required for browser submissions
|
|
41
|
-
if (typeof window !== 'undefined' && !csrfToken
|
|
39
|
+
if (typeof window !== 'undefined' && !csrfToken) {
|
|
42
40
|
console.warn('CSRF token recommended for browser-based contact form submissions');
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
return this.create<CreateContactRequest,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
return this.create<CreateContactRequest, ContactSubmitResponse>(
|
|
44
|
+
this.contactEndpoint(siteName, '/contact/submit'),
|
|
45
|
+
data,
|
|
46
|
+
csrfToken
|
|
47
|
+
);
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
/**
|
|
53
51
|
* Get contact submission status
|
|
54
52
|
*/
|
|
55
|
-
async getContactStatus(siteName: string, id: string): Promise<ApiResponse<{
|
|
56
|
-
id: string;
|
|
57
|
-
status: string;
|
|
58
|
-
submittedAt: string;
|
|
59
|
-
processedAt?: string;
|
|
60
|
-
}>> {
|
|
53
|
+
async getContactStatus(siteName: string, id: string): Promise<ApiResponse<ContactStatusResponse>> {
|
|
61
54
|
return this.getSingle(this.contactEndpoint(siteName, `/contact/status/${encodeURIComponent(id)}`));
|
|
62
55
|
}
|
|
63
56
|
|
|
@@ -179,7 +172,6 @@ export class ContactClient extends BaseClient {
|
|
|
179
172
|
* Get contact form configuration
|
|
180
173
|
*/
|
|
181
174
|
async getContactConfig(siteName: string): Promise<ApiResponse<{
|
|
182
|
-
turnstileEnabled: boolean;
|
|
183
175
|
rateLimitEnabled: boolean;
|
|
184
176
|
rateLimitWindow: number;
|
|
185
177
|
rateLimitMax: number;
|
|
@@ -198,7 +190,6 @@ export class ContactClient extends BaseClient {
|
|
|
198
190
|
* Update contact form configuration (admin only)
|
|
199
191
|
*/
|
|
200
192
|
async updateContactConfig(siteName: string, data: {
|
|
201
|
-
turnstileEnabled?: boolean;
|
|
202
193
|
rateLimitEnabled?: boolean;
|
|
203
194
|
rateLimitWindow?: number;
|
|
204
195
|
rateLimitMax?: number;
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
NewsletterSubscribeResponse,
|
|
13
13
|
NewsletterConfirmResponse,
|
|
14
14
|
NewsletterUnsubscribeRequest,
|
|
15
|
+
NewsletterUnsubscribeResponse,
|
|
15
16
|
PaginatedResponse,
|
|
16
17
|
ApiResponse,
|
|
17
18
|
} from '../types';
|
|
@@ -40,7 +41,7 @@ export class NewsletterClient extends BaseClient {
|
|
|
40
41
|
csrfToken?: string
|
|
41
42
|
): Promise<ApiResponse<NewsletterSubscribeResponse>> {
|
|
42
43
|
// CSRF token is required for browser submissions
|
|
43
|
-
if (typeof window !== 'undefined' && !csrfToken
|
|
44
|
+
if (typeof window !== 'undefined' && !csrfToken) {
|
|
44
45
|
console.warn('CSRF token recommended for browser-based newsletter subscriptions');
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -73,8 +74,8 @@ export class NewsletterClient extends BaseClient {
|
|
|
73
74
|
siteName: string,
|
|
74
75
|
data: NewsletterUnsubscribeRequest,
|
|
75
76
|
csrfToken?: string
|
|
76
|
-
): Promise<ApiResponse<
|
|
77
|
-
return this.create<NewsletterUnsubscribeRequest,
|
|
77
|
+
): Promise<ApiResponse<NewsletterUnsubscribeResponse>> {
|
|
78
|
+
return this.create<NewsletterUnsubscribeRequest, NewsletterUnsubscribeResponse>(
|
|
78
79
|
this.newsletterEndpoint(siteName, '/newsletter/unsubscribe'),
|
|
79
80
|
data,
|
|
80
81
|
csrfToken
|
package/src/index.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -7,7 +7,8 @@ export interface ApiResponse<T = any> {
|
|
|
7
7
|
data?: T;
|
|
8
8
|
message?: string;
|
|
9
9
|
error?: string;
|
|
10
|
-
success
|
|
10
|
+
success: boolean;
|
|
11
|
+
code?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
// Pagination
|
|
@@ -144,7 +145,6 @@ export interface CreateNewsletterSubscriptionRequest {
|
|
|
144
145
|
source?: string;
|
|
145
146
|
source_url?: string;
|
|
146
147
|
double_opt_in?: boolean;
|
|
147
|
-
turnstile_token?: string;
|
|
148
148
|
metadata?: Record<string, any>;
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -168,6 +168,8 @@ export interface NewsletterPreferences {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
export interface NewsletterStatusResponse {
|
|
171
|
+
success: boolean;
|
|
172
|
+
code?: string;
|
|
171
173
|
subscribed: boolean;
|
|
172
174
|
status: string;
|
|
173
175
|
frequency?: string;
|
|
@@ -176,13 +178,18 @@ export interface NewsletterStatusResponse {
|
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
export interface NewsletterSubscribeResponse {
|
|
181
|
+
success: boolean;
|
|
182
|
+
code: string;
|
|
179
183
|
message: string;
|
|
180
184
|
status: string;
|
|
181
185
|
subscription_id?: string;
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
export interface NewsletterConfirmResponse {
|
|
189
|
+
success: boolean;
|
|
190
|
+
code: string;
|
|
185
191
|
message: string;
|
|
192
|
+
status?: string;
|
|
186
193
|
subscription?: {
|
|
187
194
|
email: string;
|
|
188
195
|
name?: string;
|
|
@@ -196,6 +203,13 @@ export interface NewsletterUnsubscribeRequest {
|
|
|
196
203
|
reason?: string;
|
|
197
204
|
}
|
|
198
205
|
|
|
206
|
+
export interface NewsletterUnsubscribeResponse {
|
|
207
|
+
success: boolean;
|
|
208
|
+
code: string;
|
|
209
|
+
message: string;
|
|
210
|
+
status?: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
199
213
|
// Content Management
|
|
200
214
|
export type ContentStatus = 'draft' | 'publish' | 'private' | 'trash';
|
|
201
215
|
export type ContentType = 'post' | 'page';
|
|
@@ -442,7 +456,24 @@ export interface CreateContactRequest {
|
|
|
442
456
|
email: string;
|
|
443
457
|
subject?: string;
|
|
444
458
|
message: string;
|
|
445
|
-
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface ContactSubmitResponse {
|
|
462
|
+
success: boolean;
|
|
463
|
+
code: string;
|
|
464
|
+
contact_id: string;
|
|
465
|
+
message: string;
|
|
466
|
+
status: string;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export interface ContactStatusResponse {
|
|
470
|
+
success: boolean;
|
|
471
|
+
code: string;
|
|
472
|
+
contact_id: string;
|
|
473
|
+
status: string;
|
|
474
|
+
submitted_at: string;
|
|
475
|
+
processed_at?: string;
|
|
476
|
+
metadata?: Record<string, any>;
|
|
446
477
|
}
|
|
447
478
|
|
|
448
479
|
// Error Types
|