perspectapi-ts-sdk 3.5.0 → 3.6.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/README.md +32 -4
- package/dist/index.d.mts +75 -9
- package/dist/index.d.ts +75 -9
- package/dist/index.js +229 -3
- package/dist/index.mjs +229 -3
- package/package.json +1 -1
- package/src/client/newsletter-client.ts +343 -3
- package/src/client/site-users-client.ts +18 -0
- package/src/index.ts +3 -0
- package/src/types/index.ts +31 -0
- package/src/utils/image-transform.ts +7 -7
package/src/types/index.ts
CHANGED
|
@@ -141,6 +141,37 @@ export interface NewsletterList {
|
|
|
141
141
|
subscriber_count?: number;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
export interface NewsletterCampaignSummary {
|
|
145
|
+
id: string;
|
|
146
|
+
campaign_name: string;
|
|
147
|
+
slug: string;
|
|
148
|
+
slug_prefix?: string | null;
|
|
149
|
+
subject: string;
|
|
150
|
+
preview_text?: string | null;
|
|
151
|
+
status: string;
|
|
152
|
+
sent_at?: string | null;
|
|
153
|
+
completed_at?: string | null;
|
|
154
|
+
created_at: string;
|
|
155
|
+
updated_at: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface NewsletterCampaignDetail extends NewsletterCampaignSummary {
|
|
159
|
+
markdown_content?: string | null;
|
|
160
|
+
html_content?: string | null;
|
|
161
|
+
text_content?: string | null;
|
|
162
|
+
excerpt?: string | null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface NewsletterCampaignListResponse {
|
|
166
|
+
items: NewsletterCampaignSummary[];
|
|
167
|
+
pagination: {
|
|
168
|
+
page: number;
|
|
169
|
+
limit: number;
|
|
170
|
+
total: number;
|
|
171
|
+
pages: number;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
144
175
|
export interface NewsletterPreferences {
|
|
145
176
|
frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
146
177
|
topics?: string[];
|
|
@@ -70,7 +70,7 @@ export const DEFAULT_IMAGE_SIZES: ResponsiveImageSizes = {
|
|
|
70
70
|
/**
|
|
71
71
|
* Build Cloudflare Image Resizing URL
|
|
72
72
|
*
|
|
73
|
-
* @param baseUrl - The base URL of your API (e.g., "https://api.perspect.
|
|
73
|
+
* @param baseUrl - The base URL of your API (e.g., "https://api.perspect.comm")
|
|
74
74
|
* @param mediaPath - The path to the media file (e.g., "media/site/image.jpg")
|
|
75
75
|
* @param options - Transform options
|
|
76
76
|
* @returns Cloudflare Image Resizing URL
|
|
@@ -78,11 +78,11 @@ export const DEFAULT_IMAGE_SIZES: ResponsiveImageSizes = {
|
|
|
78
78
|
* @example
|
|
79
79
|
* ```typescript
|
|
80
80
|
* const url = buildImageUrl(
|
|
81
|
-
* 'https://api.perspect.
|
|
81
|
+
* 'https://api.perspect.comm',
|
|
82
82
|
* 'media/mysite/photo.jpg',
|
|
83
83
|
* { width: 400, format: 'webp', quality: 85 }
|
|
84
84
|
* );
|
|
85
|
-
* // Returns: '/cdn-cgi/image/width=400,format=webp,quality=85/https://api.perspect.
|
|
85
|
+
* // Returns: '/cdn-cgi/image/width=400,format=webp,quality=85/https://api.perspect.comm/media/mysite/photo.jpg'
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
88
88
|
export function buildImageUrl(
|
|
@@ -139,7 +139,7 @@ export function buildImageUrl(
|
|
|
139
139
|
* @example
|
|
140
140
|
* ```typescript
|
|
141
141
|
* const urls = generateResponsiveUrls(
|
|
142
|
-
* 'https://api.perspect.
|
|
142
|
+
* 'https://api.perspect.comm',
|
|
143
143
|
* 'media/mysite/photo.jpg'
|
|
144
144
|
* );
|
|
145
145
|
* // Returns: { thumbnail: '...', small: '...', medium: '...', large: '...', original: '...' }
|
|
@@ -165,7 +165,7 @@ export function generateResponsiveUrls(
|
|
|
165
165
|
* @example
|
|
166
166
|
* ```typescript
|
|
167
167
|
* const srcset = generateSrcSet(
|
|
168
|
-
* 'https://api.perspect.
|
|
168
|
+
* 'https://api.perspect.comm',
|
|
169
169
|
* 'media/mysite/photo.jpg',
|
|
170
170
|
* [400, 800, 1200]
|
|
171
171
|
* );
|
|
@@ -220,7 +220,7 @@ export function generateSizesAttribute(
|
|
|
220
220
|
* @example
|
|
221
221
|
* ```typescript
|
|
222
222
|
* const html = generateResponsiveImageHtml(
|
|
223
|
-
* 'https://api.perspect.
|
|
223
|
+
* 'https://api.perspect.comm',
|
|
224
224
|
* 'media/mysite/photo.jpg',
|
|
225
225
|
* 'My photo',
|
|
226
226
|
* { className: 'rounded-lg', loading: 'lazy' }
|
|
@@ -271,7 +271,7 @@ export function generateResponsiveImageHtml(
|
|
|
271
271
|
* const media = product.data.media?.[0];
|
|
272
272
|
*
|
|
273
273
|
* if (media) {
|
|
274
|
-
* const urls = transformMediaItem('https://api.perspect.
|
|
274
|
+
* const urls = transformMediaItem('https://api.perspect.comm', media);
|
|
275
275
|
* console.log(urls.thumbnail); // Cloudflare-transformed thumbnail URL
|
|
276
276
|
* }
|
|
277
277
|
* ```
|