perspectapi-ts-sdk 1.1.1 → 1.2.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 +262 -1
- package/dist/index.d.ts +262 -1
- package/dist/index.js +183 -0
- package/dist/index.mjs +182 -0
- package/package.json +1 -1
- package/src/client/newsletter-client.ts +360 -0
- package/src/index.ts +9 -0
- package/src/perspect-api-client.ts +3 -0
- package/src/types/index.ts +77 -0
package/dist/index.d.mts
CHANGED
|
@@ -98,6 +98,74 @@ interface CreateSiteRequest {
|
|
|
98
98
|
description?: string;
|
|
99
99
|
organizationId: number;
|
|
100
100
|
}
|
|
101
|
+
interface NewsletterSubscription {
|
|
102
|
+
id: string;
|
|
103
|
+
email: string;
|
|
104
|
+
name?: string;
|
|
105
|
+
status: 'pending' | 'confirmed' | 'unsubscribed' | 'bounced' | 'complained';
|
|
106
|
+
frequency: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
107
|
+
topics?: string[];
|
|
108
|
+
language: string;
|
|
109
|
+
confirmedAt?: string;
|
|
110
|
+
unsubscribedAt?: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
updatedAt: string;
|
|
113
|
+
}
|
|
114
|
+
interface CreateNewsletterSubscriptionRequest {
|
|
115
|
+
email: string;
|
|
116
|
+
name?: string;
|
|
117
|
+
list_ids?: string[];
|
|
118
|
+
frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
119
|
+
topics?: string[];
|
|
120
|
+
language?: string;
|
|
121
|
+
source?: string;
|
|
122
|
+
source_url?: string;
|
|
123
|
+
double_opt_in?: boolean;
|
|
124
|
+
turnstile_token?: string;
|
|
125
|
+
metadata?: Record<string, any>;
|
|
126
|
+
}
|
|
127
|
+
interface NewsletterList {
|
|
128
|
+
id: string;
|
|
129
|
+
list_name: string;
|
|
130
|
+
slug: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
is_default: boolean;
|
|
133
|
+
subscriber_count?: number;
|
|
134
|
+
}
|
|
135
|
+
interface NewsletterPreferences {
|
|
136
|
+
frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
137
|
+
topics?: string[];
|
|
138
|
+
language?: string;
|
|
139
|
+
email_format?: 'html' | 'text' | 'both';
|
|
140
|
+
timezone?: string;
|
|
141
|
+
track_opens?: boolean;
|
|
142
|
+
track_clicks?: boolean;
|
|
143
|
+
}
|
|
144
|
+
interface NewsletterStatusResponse {
|
|
145
|
+
subscribed: boolean;
|
|
146
|
+
status: string;
|
|
147
|
+
frequency?: string;
|
|
148
|
+
created_at?: string;
|
|
149
|
+
confirmed_at?: string;
|
|
150
|
+
}
|
|
151
|
+
interface NewsletterSubscribeResponse {
|
|
152
|
+
message: string;
|
|
153
|
+
status: string;
|
|
154
|
+
subscription_id?: string;
|
|
155
|
+
}
|
|
156
|
+
interface NewsletterConfirmResponse {
|
|
157
|
+
message: string;
|
|
158
|
+
subscription?: {
|
|
159
|
+
email: string;
|
|
160
|
+
name?: string;
|
|
161
|
+
frequency: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
interface NewsletterUnsubscribeRequest {
|
|
165
|
+
token?: string;
|
|
166
|
+
email?: string;
|
|
167
|
+
reason?: string;
|
|
168
|
+
}
|
|
101
169
|
type ContentStatus = 'draft' | 'publish' | 'private' | 'trash';
|
|
102
170
|
type ContentType = 'post' | 'page';
|
|
103
171
|
interface Content {
|
|
@@ -1532,6 +1600,198 @@ declare class ContactClient extends BaseClient {
|
|
|
1532
1600
|
}>>;
|
|
1533
1601
|
}
|
|
1534
1602
|
|
|
1603
|
+
/**
|
|
1604
|
+
* Newsletter subscription client for PerspectAPI SDK
|
|
1605
|
+
*/
|
|
1606
|
+
|
|
1607
|
+
declare class NewsletterClient extends BaseClient {
|
|
1608
|
+
constructor(http: any);
|
|
1609
|
+
/**
|
|
1610
|
+
* Build a newsletter endpoint scoped to a site (without /sites prefix)
|
|
1611
|
+
*/
|
|
1612
|
+
private newsletterEndpoint;
|
|
1613
|
+
/**
|
|
1614
|
+
* Subscribe to newsletter
|
|
1615
|
+
*/
|
|
1616
|
+
subscribe(siteName: string, data: CreateNewsletterSubscriptionRequest): Promise<ApiResponse<NewsletterSubscribeResponse>>;
|
|
1617
|
+
/**
|
|
1618
|
+
* Confirm newsletter subscription via token
|
|
1619
|
+
*/
|
|
1620
|
+
confirmSubscription(siteName: string, token: string): Promise<ApiResponse<NewsletterConfirmResponse>>;
|
|
1621
|
+
/**
|
|
1622
|
+
* Unsubscribe from newsletter
|
|
1623
|
+
*/
|
|
1624
|
+
unsubscribe(siteName: string, data: NewsletterUnsubscribeRequest): Promise<ApiResponse<{
|
|
1625
|
+
message: string;
|
|
1626
|
+
}>>;
|
|
1627
|
+
/**
|
|
1628
|
+
* One-click unsubscribe via token (GET request)
|
|
1629
|
+
*/
|
|
1630
|
+
unsubscribeByToken(siteName: string, token: string): Promise<ApiResponse<string>>;
|
|
1631
|
+
/**
|
|
1632
|
+
* Update subscription preferences
|
|
1633
|
+
*/
|
|
1634
|
+
updatePreferences(siteName: string, email: string, preferences: NewsletterPreferences): Promise<ApiResponse<{
|
|
1635
|
+
message: string;
|
|
1636
|
+
preferences: NewsletterPreferences;
|
|
1637
|
+
}>>;
|
|
1638
|
+
/**
|
|
1639
|
+
* Get available newsletter lists
|
|
1640
|
+
*/
|
|
1641
|
+
getLists(siteName: string): Promise<ApiResponse<{
|
|
1642
|
+
lists: NewsletterList[];
|
|
1643
|
+
total: number;
|
|
1644
|
+
}>>;
|
|
1645
|
+
/**
|
|
1646
|
+
* Check subscription status by email
|
|
1647
|
+
*/
|
|
1648
|
+
getStatus(siteName: string, email: string): Promise<ApiResponse<NewsletterStatusResponse>>;
|
|
1649
|
+
/**
|
|
1650
|
+
* Get all newsletter subscriptions (admin only)
|
|
1651
|
+
*/
|
|
1652
|
+
getSubscriptions(siteName: string, params?: {
|
|
1653
|
+
page?: number;
|
|
1654
|
+
limit?: number;
|
|
1655
|
+
status?: string;
|
|
1656
|
+
list_id?: string;
|
|
1657
|
+
search?: string;
|
|
1658
|
+
startDate?: string;
|
|
1659
|
+
endDate?: string;
|
|
1660
|
+
}): Promise<PaginatedResponse<NewsletterSubscription>>;
|
|
1661
|
+
/**
|
|
1662
|
+
* Get subscription by ID (admin only)
|
|
1663
|
+
*/
|
|
1664
|
+
getSubscriptionById(siteName: string, id: string): Promise<ApiResponse<NewsletterSubscription>>;
|
|
1665
|
+
/**
|
|
1666
|
+
* Update subscription status (admin only)
|
|
1667
|
+
*/
|
|
1668
|
+
updateSubscriptionStatus(siteName: string, id: string, status: 'confirmed' | 'unsubscribed' | 'bounced' | 'complained', notes?: string): Promise<ApiResponse<{
|
|
1669
|
+
message: string;
|
|
1670
|
+
}>>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Delete subscription (admin only)
|
|
1673
|
+
*/
|
|
1674
|
+
deleteSubscription(siteName: string, id: string): Promise<ApiResponse<{
|
|
1675
|
+
message: string;
|
|
1676
|
+
}>>;
|
|
1677
|
+
/**
|
|
1678
|
+
* Bulk update subscriptions (admin only)
|
|
1679
|
+
*/
|
|
1680
|
+
bulkUpdateSubscriptions(siteName: string, data: {
|
|
1681
|
+
ids: string[];
|
|
1682
|
+
action: 'confirm' | 'unsubscribe' | 'delete' | 'add_to_list' | 'remove_from_list';
|
|
1683
|
+
list_id?: string;
|
|
1684
|
+
}): Promise<ApiResponse<{
|
|
1685
|
+
success: boolean;
|
|
1686
|
+
updatedCount: number;
|
|
1687
|
+
failedCount: number;
|
|
1688
|
+
}>>;
|
|
1689
|
+
/**
|
|
1690
|
+
* Create newsletter list (admin only)
|
|
1691
|
+
*/
|
|
1692
|
+
createList(siteName: string, data: {
|
|
1693
|
+
list_name: string;
|
|
1694
|
+
slug: string;
|
|
1695
|
+
description?: string;
|
|
1696
|
+
is_public?: boolean;
|
|
1697
|
+
is_default?: boolean;
|
|
1698
|
+
double_opt_in?: boolean;
|
|
1699
|
+
welcome_email_enabled?: boolean;
|
|
1700
|
+
}): Promise<ApiResponse<NewsletterList>>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Update newsletter list (admin only)
|
|
1703
|
+
*/
|
|
1704
|
+
updateList(siteName: string, listId: string, data: Partial<{
|
|
1705
|
+
list_name: string;
|
|
1706
|
+
description: string;
|
|
1707
|
+
is_public: boolean;
|
|
1708
|
+
is_default: boolean;
|
|
1709
|
+
double_opt_in: boolean;
|
|
1710
|
+
welcome_email_enabled: boolean;
|
|
1711
|
+
}>): Promise<ApiResponse<{
|
|
1712
|
+
message: string;
|
|
1713
|
+
}>>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Delete newsletter list (admin only)
|
|
1716
|
+
*/
|
|
1717
|
+
deleteList(siteName: string, listId: string): Promise<ApiResponse<{
|
|
1718
|
+
message: string;
|
|
1719
|
+
}>>;
|
|
1720
|
+
/**
|
|
1721
|
+
* Get newsletter statistics (admin only)
|
|
1722
|
+
*/
|
|
1723
|
+
getStatistics(siteName: string, params?: {
|
|
1724
|
+
startDate?: string;
|
|
1725
|
+
endDate?: string;
|
|
1726
|
+
list_id?: string;
|
|
1727
|
+
}): Promise<ApiResponse<{
|
|
1728
|
+
totalSubscribers: number;
|
|
1729
|
+
confirmedSubscribers: number;
|
|
1730
|
+
pendingSubscribers: number;
|
|
1731
|
+
unsubscribedCount: number;
|
|
1732
|
+
bouncedCount: number;
|
|
1733
|
+
subscribersByDay: Array<{
|
|
1734
|
+
date: string;
|
|
1735
|
+
count: number;
|
|
1736
|
+
}>;
|
|
1737
|
+
subscribersByList: Array<{
|
|
1738
|
+
list_id: string;
|
|
1739
|
+
list_name: string;
|
|
1740
|
+
count: number;
|
|
1741
|
+
}>;
|
|
1742
|
+
engagementMetrics: {
|
|
1743
|
+
averageOpenRate: number;
|
|
1744
|
+
averageClickRate: number;
|
|
1745
|
+
};
|
|
1746
|
+
}>>;
|
|
1747
|
+
/**
|
|
1748
|
+
* Export newsletter subscriptions (admin only)
|
|
1749
|
+
*/
|
|
1750
|
+
exportSubscriptions(siteName: string, params?: {
|
|
1751
|
+
format?: 'csv' | 'json' | 'xlsx';
|
|
1752
|
+
status?: string;
|
|
1753
|
+
list_id?: string;
|
|
1754
|
+
startDate?: string;
|
|
1755
|
+
endDate?: string;
|
|
1756
|
+
}): Promise<ApiResponse<{
|
|
1757
|
+
downloadUrl: string;
|
|
1758
|
+
expiresAt: string;
|
|
1759
|
+
}>>;
|
|
1760
|
+
/**
|
|
1761
|
+
* Import newsletter subscriptions (admin only)
|
|
1762
|
+
*/
|
|
1763
|
+
importSubscriptions(siteName: string, data: {
|
|
1764
|
+
subscriptions: Array<{
|
|
1765
|
+
email: string;
|
|
1766
|
+
name?: string;
|
|
1767
|
+
status?: string;
|
|
1768
|
+
lists?: string[];
|
|
1769
|
+
}>;
|
|
1770
|
+
skip_confirmation?: boolean;
|
|
1771
|
+
update_existing?: boolean;
|
|
1772
|
+
}): Promise<ApiResponse<{
|
|
1773
|
+
imported: number;
|
|
1774
|
+
updated: number;
|
|
1775
|
+
failed: number;
|
|
1776
|
+
errors?: Array<{
|
|
1777
|
+
email: string;
|
|
1778
|
+
error: string;
|
|
1779
|
+
}>;
|
|
1780
|
+
}>>;
|
|
1781
|
+
/**
|
|
1782
|
+
* Send test newsletter (admin only)
|
|
1783
|
+
*/
|
|
1784
|
+
sendTestNewsletter(siteName: string, data: {
|
|
1785
|
+
to: string;
|
|
1786
|
+
subject: string;
|
|
1787
|
+
html_content: string;
|
|
1788
|
+
text_content?: string;
|
|
1789
|
+
}): Promise<ApiResponse<{
|
|
1790
|
+
message: string;
|
|
1791
|
+
sent: boolean;
|
|
1792
|
+
}>>;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1535
1795
|
/**
|
|
1536
1796
|
* Main PerspectAPI SDK Client
|
|
1537
1797
|
* Cloudflare Workers compatible TypeScript SDK
|
|
@@ -1549,6 +1809,7 @@ declare class PerspectApiClient {
|
|
|
1549
1809
|
readonly webhooks: WebhooksClient;
|
|
1550
1810
|
readonly checkout: CheckoutClient;
|
|
1551
1811
|
readonly contact: ContactClient;
|
|
1812
|
+
readonly newsletter: NewsletterClient;
|
|
1552
1813
|
constructor(config: PerspectApiConfig);
|
|
1553
1814
|
/**
|
|
1554
1815
|
* Update authentication token
|
|
@@ -1767,4 +2028,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
1767
2028
|
error: string;
|
|
1768
2029
|
}>;
|
|
1769
2030
|
|
|
1770
|
-
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 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, 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 };
|
|
2031
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -98,6 +98,74 @@ interface CreateSiteRequest {
|
|
|
98
98
|
description?: string;
|
|
99
99
|
organizationId: number;
|
|
100
100
|
}
|
|
101
|
+
interface NewsletterSubscription {
|
|
102
|
+
id: string;
|
|
103
|
+
email: string;
|
|
104
|
+
name?: string;
|
|
105
|
+
status: 'pending' | 'confirmed' | 'unsubscribed' | 'bounced' | 'complained';
|
|
106
|
+
frequency: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
107
|
+
topics?: string[];
|
|
108
|
+
language: string;
|
|
109
|
+
confirmedAt?: string;
|
|
110
|
+
unsubscribedAt?: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
updatedAt: string;
|
|
113
|
+
}
|
|
114
|
+
interface CreateNewsletterSubscriptionRequest {
|
|
115
|
+
email: string;
|
|
116
|
+
name?: string;
|
|
117
|
+
list_ids?: string[];
|
|
118
|
+
frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
119
|
+
topics?: string[];
|
|
120
|
+
language?: string;
|
|
121
|
+
source?: string;
|
|
122
|
+
source_url?: string;
|
|
123
|
+
double_opt_in?: boolean;
|
|
124
|
+
turnstile_token?: string;
|
|
125
|
+
metadata?: Record<string, any>;
|
|
126
|
+
}
|
|
127
|
+
interface NewsletterList {
|
|
128
|
+
id: string;
|
|
129
|
+
list_name: string;
|
|
130
|
+
slug: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
is_default: boolean;
|
|
133
|
+
subscriber_count?: number;
|
|
134
|
+
}
|
|
135
|
+
interface NewsletterPreferences {
|
|
136
|
+
frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
137
|
+
topics?: string[];
|
|
138
|
+
language?: string;
|
|
139
|
+
email_format?: 'html' | 'text' | 'both';
|
|
140
|
+
timezone?: string;
|
|
141
|
+
track_opens?: boolean;
|
|
142
|
+
track_clicks?: boolean;
|
|
143
|
+
}
|
|
144
|
+
interface NewsletterStatusResponse {
|
|
145
|
+
subscribed: boolean;
|
|
146
|
+
status: string;
|
|
147
|
+
frequency?: string;
|
|
148
|
+
created_at?: string;
|
|
149
|
+
confirmed_at?: string;
|
|
150
|
+
}
|
|
151
|
+
interface NewsletterSubscribeResponse {
|
|
152
|
+
message: string;
|
|
153
|
+
status: string;
|
|
154
|
+
subscription_id?: string;
|
|
155
|
+
}
|
|
156
|
+
interface NewsletterConfirmResponse {
|
|
157
|
+
message: string;
|
|
158
|
+
subscription?: {
|
|
159
|
+
email: string;
|
|
160
|
+
name?: string;
|
|
161
|
+
frequency: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
interface NewsletterUnsubscribeRequest {
|
|
165
|
+
token?: string;
|
|
166
|
+
email?: string;
|
|
167
|
+
reason?: string;
|
|
168
|
+
}
|
|
101
169
|
type ContentStatus = 'draft' | 'publish' | 'private' | 'trash';
|
|
102
170
|
type ContentType = 'post' | 'page';
|
|
103
171
|
interface Content {
|
|
@@ -1532,6 +1600,198 @@ declare class ContactClient extends BaseClient {
|
|
|
1532
1600
|
}>>;
|
|
1533
1601
|
}
|
|
1534
1602
|
|
|
1603
|
+
/**
|
|
1604
|
+
* Newsletter subscription client for PerspectAPI SDK
|
|
1605
|
+
*/
|
|
1606
|
+
|
|
1607
|
+
declare class NewsletterClient extends BaseClient {
|
|
1608
|
+
constructor(http: any);
|
|
1609
|
+
/**
|
|
1610
|
+
* Build a newsletter endpoint scoped to a site (without /sites prefix)
|
|
1611
|
+
*/
|
|
1612
|
+
private newsletterEndpoint;
|
|
1613
|
+
/**
|
|
1614
|
+
* Subscribe to newsletter
|
|
1615
|
+
*/
|
|
1616
|
+
subscribe(siteName: string, data: CreateNewsletterSubscriptionRequest): Promise<ApiResponse<NewsletterSubscribeResponse>>;
|
|
1617
|
+
/**
|
|
1618
|
+
* Confirm newsletter subscription via token
|
|
1619
|
+
*/
|
|
1620
|
+
confirmSubscription(siteName: string, token: string): Promise<ApiResponse<NewsletterConfirmResponse>>;
|
|
1621
|
+
/**
|
|
1622
|
+
* Unsubscribe from newsletter
|
|
1623
|
+
*/
|
|
1624
|
+
unsubscribe(siteName: string, data: NewsletterUnsubscribeRequest): Promise<ApiResponse<{
|
|
1625
|
+
message: string;
|
|
1626
|
+
}>>;
|
|
1627
|
+
/**
|
|
1628
|
+
* One-click unsubscribe via token (GET request)
|
|
1629
|
+
*/
|
|
1630
|
+
unsubscribeByToken(siteName: string, token: string): Promise<ApiResponse<string>>;
|
|
1631
|
+
/**
|
|
1632
|
+
* Update subscription preferences
|
|
1633
|
+
*/
|
|
1634
|
+
updatePreferences(siteName: string, email: string, preferences: NewsletterPreferences): Promise<ApiResponse<{
|
|
1635
|
+
message: string;
|
|
1636
|
+
preferences: NewsletterPreferences;
|
|
1637
|
+
}>>;
|
|
1638
|
+
/**
|
|
1639
|
+
* Get available newsletter lists
|
|
1640
|
+
*/
|
|
1641
|
+
getLists(siteName: string): Promise<ApiResponse<{
|
|
1642
|
+
lists: NewsletterList[];
|
|
1643
|
+
total: number;
|
|
1644
|
+
}>>;
|
|
1645
|
+
/**
|
|
1646
|
+
* Check subscription status by email
|
|
1647
|
+
*/
|
|
1648
|
+
getStatus(siteName: string, email: string): Promise<ApiResponse<NewsletterStatusResponse>>;
|
|
1649
|
+
/**
|
|
1650
|
+
* Get all newsletter subscriptions (admin only)
|
|
1651
|
+
*/
|
|
1652
|
+
getSubscriptions(siteName: string, params?: {
|
|
1653
|
+
page?: number;
|
|
1654
|
+
limit?: number;
|
|
1655
|
+
status?: string;
|
|
1656
|
+
list_id?: string;
|
|
1657
|
+
search?: string;
|
|
1658
|
+
startDate?: string;
|
|
1659
|
+
endDate?: string;
|
|
1660
|
+
}): Promise<PaginatedResponse<NewsletterSubscription>>;
|
|
1661
|
+
/**
|
|
1662
|
+
* Get subscription by ID (admin only)
|
|
1663
|
+
*/
|
|
1664
|
+
getSubscriptionById(siteName: string, id: string): Promise<ApiResponse<NewsletterSubscription>>;
|
|
1665
|
+
/**
|
|
1666
|
+
* Update subscription status (admin only)
|
|
1667
|
+
*/
|
|
1668
|
+
updateSubscriptionStatus(siteName: string, id: string, status: 'confirmed' | 'unsubscribed' | 'bounced' | 'complained', notes?: string): Promise<ApiResponse<{
|
|
1669
|
+
message: string;
|
|
1670
|
+
}>>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Delete subscription (admin only)
|
|
1673
|
+
*/
|
|
1674
|
+
deleteSubscription(siteName: string, id: string): Promise<ApiResponse<{
|
|
1675
|
+
message: string;
|
|
1676
|
+
}>>;
|
|
1677
|
+
/**
|
|
1678
|
+
* Bulk update subscriptions (admin only)
|
|
1679
|
+
*/
|
|
1680
|
+
bulkUpdateSubscriptions(siteName: string, data: {
|
|
1681
|
+
ids: string[];
|
|
1682
|
+
action: 'confirm' | 'unsubscribe' | 'delete' | 'add_to_list' | 'remove_from_list';
|
|
1683
|
+
list_id?: string;
|
|
1684
|
+
}): Promise<ApiResponse<{
|
|
1685
|
+
success: boolean;
|
|
1686
|
+
updatedCount: number;
|
|
1687
|
+
failedCount: number;
|
|
1688
|
+
}>>;
|
|
1689
|
+
/**
|
|
1690
|
+
* Create newsletter list (admin only)
|
|
1691
|
+
*/
|
|
1692
|
+
createList(siteName: string, data: {
|
|
1693
|
+
list_name: string;
|
|
1694
|
+
slug: string;
|
|
1695
|
+
description?: string;
|
|
1696
|
+
is_public?: boolean;
|
|
1697
|
+
is_default?: boolean;
|
|
1698
|
+
double_opt_in?: boolean;
|
|
1699
|
+
welcome_email_enabled?: boolean;
|
|
1700
|
+
}): Promise<ApiResponse<NewsletterList>>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Update newsletter list (admin only)
|
|
1703
|
+
*/
|
|
1704
|
+
updateList(siteName: string, listId: string, data: Partial<{
|
|
1705
|
+
list_name: string;
|
|
1706
|
+
description: string;
|
|
1707
|
+
is_public: boolean;
|
|
1708
|
+
is_default: boolean;
|
|
1709
|
+
double_opt_in: boolean;
|
|
1710
|
+
welcome_email_enabled: boolean;
|
|
1711
|
+
}>): Promise<ApiResponse<{
|
|
1712
|
+
message: string;
|
|
1713
|
+
}>>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Delete newsletter list (admin only)
|
|
1716
|
+
*/
|
|
1717
|
+
deleteList(siteName: string, listId: string): Promise<ApiResponse<{
|
|
1718
|
+
message: string;
|
|
1719
|
+
}>>;
|
|
1720
|
+
/**
|
|
1721
|
+
* Get newsletter statistics (admin only)
|
|
1722
|
+
*/
|
|
1723
|
+
getStatistics(siteName: string, params?: {
|
|
1724
|
+
startDate?: string;
|
|
1725
|
+
endDate?: string;
|
|
1726
|
+
list_id?: string;
|
|
1727
|
+
}): Promise<ApiResponse<{
|
|
1728
|
+
totalSubscribers: number;
|
|
1729
|
+
confirmedSubscribers: number;
|
|
1730
|
+
pendingSubscribers: number;
|
|
1731
|
+
unsubscribedCount: number;
|
|
1732
|
+
bouncedCount: number;
|
|
1733
|
+
subscribersByDay: Array<{
|
|
1734
|
+
date: string;
|
|
1735
|
+
count: number;
|
|
1736
|
+
}>;
|
|
1737
|
+
subscribersByList: Array<{
|
|
1738
|
+
list_id: string;
|
|
1739
|
+
list_name: string;
|
|
1740
|
+
count: number;
|
|
1741
|
+
}>;
|
|
1742
|
+
engagementMetrics: {
|
|
1743
|
+
averageOpenRate: number;
|
|
1744
|
+
averageClickRate: number;
|
|
1745
|
+
};
|
|
1746
|
+
}>>;
|
|
1747
|
+
/**
|
|
1748
|
+
* Export newsletter subscriptions (admin only)
|
|
1749
|
+
*/
|
|
1750
|
+
exportSubscriptions(siteName: string, params?: {
|
|
1751
|
+
format?: 'csv' | 'json' | 'xlsx';
|
|
1752
|
+
status?: string;
|
|
1753
|
+
list_id?: string;
|
|
1754
|
+
startDate?: string;
|
|
1755
|
+
endDate?: string;
|
|
1756
|
+
}): Promise<ApiResponse<{
|
|
1757
|
+
downloadUrl: string;
|
|
1758
|
+
expiresAt: string;
|
|
1759
|
+
}>>;
|
|
1760
|
+
/**
|
|
1761
|
+
* Import newsletter subscriptions (admin only)
|
|
1762
|
+
*/
|
|
1763
|
+
importSubscriptions(siteName: string, data: {
|
|
1764
|
+
subscriptions: Array<{
|
|
1765
|
+
email: string;
|
|
1766
|
+
name?: string;
|
|
1767
|
+
status?: string;
|
|
1768
|
+
lists?: string[];
|
|
1769
|
+
}>;
|
|
1770
|
+
skip_confirmation?: boolean;
|
|
1771
|
+
update_existing?: boolean;
|
|
1772
|
+
}): Promise<ApiResponse<{
|
|
1773
|
+
imported: number;
|
|
1774
|
+
updated: number;
|
|
1775
|
+
failed: number;
|
|
1776
|
+
errors?: Array<{
|
|
1777
|
+
email: string;
|
|
1778
|
+
error: string;
|
|
1779
|
+
}>;
|
|
1780
|
+
}>>;
|
|
1781
|
+
/**
|
|
1782
|
+
* Send test newsletter (admin only)
|
|
1783
|
+
*/
|
|
1784
|
+
sendTestNewsletter(siteName: string, data: {
|
|
1785
|
+
to: string;
|
|
1786
|
+
subject: string;
|
|
1787
|
+
html_content: string;
|
|
1788
|
+
text_content?: string;
|
|
1789
|
+
}): Promise<ApiResponse<{
|
|
1790
|
+
message: string;
|
|
1791
|
+
sent: boolean;
|
|
1792
|
+
}>>;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1535
1795
|
/**
|
|
1536
1796
|
* Main PerspectAPI SDK Client
|
|
1537
1797
|
* Cloudflare Workers compatible TypeScript SDK
|
|
@@ -1549,6 +1809,7 @@ declare class PerspectApiClient {
|
|
|
1549
1809
|
readonly webhooks: WebhooksClient;
|
|
1550
1810
|
readonly checkout: CheckoutClient;
|
|
1551
1811
|
readonly contact: ContactClient;
|
|
1812
|
+
readonly newsletter: NewsletterClient;
|
|
1552
1813
|
constructor(config: PerspectApiConfig);
|
|
1553
1814
|
/**
|
|
1554
1815
|
* Update authentication token
|
|
@@ -1767,4 +2028,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
1767
2028
|
error: string;
|
|
1768
2029
|
}>;
|
|
1769
2030
|
|
|
1770
|
-
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 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, 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 };
|
|
2031
|
+
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 };
|