perspectapi-ts-sdk 3.5.1 → 3.7.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 +29 -1
- package/dist/index.d.mts +116 -27
- package/dist/index.d.ts +116 -27
- package/dist/index.js +246 -4
- package/dist/index.mjs +246 -4
- package/package.json +1 -1
- package/src/client/newsletter-client.ts +343 -3
- package/src/client/products-client.ts +59 -27
- package/src/index.ts +3 -0
- package/src/types/index.ts +90 -0
package/README.md
CHANGED
|
@@ -148,7 +148,7 @@ export default {
|
|
|
148
148
|
};
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
When PerspectAPI sends a webhook—or when your Worker mutates data directly—call `perspect.cache.invalidate({ tags: [...] })` using the tags emitted by the SDK (`products:site:<site>`, `content:slug:<site>:<slug>`, `
|
|
151
|
+
When PerspectAPI sends a webhook—or when your Worker mutates data directly—call `perspect.cache.invalidate({ tags: [...] })` using the tags emitted by the SDK (`products:site:<site>`, `content:slug:<site>:<slug>`, `newsletter:campaigns:slug:<site>:<slug>`, etc.) so stale entries are purged immediately.
|
|
152
152
|
|
|
153
153
|
### Webhook-driven cache invalidation
|
|
154
154
|
|
|
@@ -233,6 +233,34 @@ export default {
|
|
|
233
233
|
```
|
|
234
234
|
|
|
235
235
|
> 🔁 Adjust the `WebhookEvent` union and `tagMap` to match the actual payloads you receive. PerspectAPI webhooks also carry version IDs and environment metadata that you can use for more granular targeting if needed.
|
|
236
|
+
|
|
237
|
+
### Newsletter Publish Invalidation
|
|
238
|
+
|
|
239
|
+
Newsletter list and campaign reads are cache-aware:
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
const campaigns = await perspect.newsletter.getPublishedCampaigns('museum-indian-art', {
|
|
243
|
+
page: 1,
|
|
244
|
+
limit: 20,
|
|
245
|
+
});
|
|
246
|
+
const campaign = await perspect.newsletter.getPublishedCampaignBySlug(
|
|
247
|
+
'museum-indian-art',
|
|
248
|
+
'spring-launch',
|
|
249
|
+
{ slugPrefix: 'updates' }
|
|
250
|
+
);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
For webhook handling, use the newsletter helper so invalidation happens only when campaigns are published (not when drafts are created):
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
const result = await perspect.newsletter.invalidatePublishedCampaignCacheFromWebhook(
|
|
257
|
+
webhookPayload,
|
|
258
|
+
'museum-indian-art'
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
if (result.invalidated) {
|
|
262
|
+
console.log(result.tags);
|
|
263
|
+
}
|
|
236
264
|
```
|
|
237
265
|
|
|
238
266
|
## Image Transformations
|
package/dist/index.d.mts
CHANGED
|
@@ -202,6 +202,34 @@ interface NewsletterList {
|
|
|
202
202
|
is_default: boolean;
|
|
203
203
|
subscriber_count?: number;
|
|
204
204
|
}
|
|
205
|
+
interface NewsletterCampaignSummary {
|
|
206
|
+
id: string;
|
|
207
|
+
campaign_name: string;
|
|
208
|
+
slug: string;
|
|
209
|
+
slug_prefix?: string | null;
|
|
210
|
+
subject: string;
|
|
211
|
+
preview_text?: string | null;
|
|
212
|
+
status: string;
|
|
213
|
+
sent_at?: string | null;
|
|
214
|
+
completed_at?: string | null;
|
|
215
|
+
created_at: string;
|
|
216
|
+
updated_at: string;
|
|
217
|
+
}
|
|
218
|
+
interface NewsletterCampaignDetail extends NewsletterCampaignSummary {
|
|
219
|
+
markdown_content?: string | null;
|
|
220
|
+
html_content?: string | null;
|
|
221
|
+
text_content?: string | null;
|
|
222
|
+
excerpt?: string | null;
|
|
223
|
+
}
|
|
224
|
+
interface NewsletterCampaignListResponse {
|
|
225
|
+
items: NewsletterCampaignSummary[];
|
|
226
|
+
pagination: {
|
|
227
|
+
page: number;
|
|
228
|
+
limit: number;
|
|
229
|
+
total: number;
|
|
230
|
+
pages: number;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
205
233
|
interface NewsletterPreferences {
|
|
206
234
|
frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
207
235
|
topics?: string[];
|
|
@@ -331,6 +359,46 @@ interface MediaItem {
|
|
|
331
359
|
r2_key: string;
|
|
332
360
|
site_name: string;
|
|
333
361
|
}
|
|
362
|
+
interface ProductSkuMediaItem {
|
|
363
|
+
id?: string;
|
|
364
|
+
media_id: string;
|
|
365
|
+
file_name?: string;
|
|
366
|
+
fileName?: string;
|
|
367
|
+
link?: string;
|
|
368
|
+
url?: string;
|
|
369
|
+
content_type?: string;
|
|
370
|
+
contentType?: string;
|
|
371
|
+
width?: number;
|
|
372
|
+
height?: number;
|
|
373
|
+
filesize?: number;
|
|
374
|
+
r2_key?: string;
|
|
375
|
+
site_name?: string;
|
|
376
|
+
}
|
|
377
|
+
interface ProductSkuOption {
|
|
378
|
+
name: string;
|
|
379
|
+
key: string;
|
|
380
|
+
value: string;
|
|
381
|
+
label: string;
|
|
382
|
+
value_id: number;
|
|
383
|
+
}
|
|
384
|
+
interface ProductSku {
|
|
385
|
+
sku_id: number;
|
|
386
|
+
sku?: string | null;
|
|
387
|
+
combination_key: string;
|
|
388
|
+
media_id?: string | null;
|
|
389
|
+
media?: ProductSkuMediaItem | null;
|
|
390
|
+
options?: ProductSkuOption[];
|
|
391
|
+
unit_amount?: number;
|
|
392
|
+
currency?: string;
|
|
393
|
+
quantity_available?: number | null;
|
|
394
|
+
price?: number;
|
|
395
|
+
sale_price?: number;
|
|
396
|
+
stock_quantity?: number;
|
|
397
|
+
value_ids: number[];
|
|
398
|
+
created_at?: string;
|
|
399
|
+
updated_at?: string;
|
|
400
|
+
[key: string]: any;
|
|
401
|
+
}
|
|
334
402
|
interface Product {
|
|
335
403
|
id: number | string;
|
|
336
404
|
name?: string;
|
|
@@ -344,6 +412,7 @@ interface Product {
|
|
|
344
412
|
slug_prefix?: string;
|
|
345
413
|
image?: string;
|
|
346
414
|
media?: MediaItem[] | MediaItem[][];
|
|
415
|
+
skus?: ProductSku[];
|
|
347
416
|
isActive?: boolean;
|
|
348
417
|
organizationId?: number;
|
|
349
418
|
createdAt?: string;
|
|
@@ -374,6 +443,20 @@ interface CreateProductRequest {
|
|
|
374
443
|
stock_quantity?: number | null;
|
|
375
444
|
isActive?: boolean;
|
|
376
445
|
}
|
|
446
|
+
interface CreateProductSkuRequest {
|
|
447
|
+
sku?: string | null;
|
|
448
|
+
media_id?: string | null;
|
|
449
|
+
unit_amount?: number;
|
|
450
|
+
currency?: string;
|
|
451
|
+
quantity_available?: number | null;
|
|
452
|
+
price?: number | null;
|
|
453
|
+
stock_quantity?: number | null;
|
|
454
|
+
sale_price?: number | null;
|
|
455
|
+
published?: boolean;
|
|
456
|
+
gateway_price_id_test?: string | null;
|
|
457
|
+
gateway_price_id_live?: string | null;
|
|
458
|
+
value_ids: number[];
|
|
459
|
+
}
|
|
377
460
|
interface ProductQueryParams extends PaginationParams {
|
|
378
461
|
organizationId?: number;
|
|
379
462
|
isActive?: boolean;
|
|
@@ -1431,34 +1514,11 @@ declare class ProductsClient extends BaseClient {
|
|
|
1431
1514
|
/**
|
|
1432
1515
|
* Get all SKUs for a product (with their option value combinations)
|
|
1433
1516
|
*/
|
|
1434
|
-
getProductSkus(siteName: string, productId: number): Promise<ApiResponse<
|
|
1435
|
-
sku_id: number;
|
|
1436
|
-
sku: string;
|
|
1437
|
-
price?: number;
|
|
1438
|
-
sale_price?: number;
|
|
1439
|
-
stock_quantity?: number;
|
|
1440
|
-
combination_key: string;
|
|
1441
|
-
value_ids: number[];
|
|
1442
|
-
created_at: string;
|
|
1443
|
-
updated_at: string;
|
|
1444
|
-
}>>>;
|
|
1517
|
+
getProductSkus(siteName: string, productId: number): Promise<ApiResponse<ProductSku[]>>;
|
|
1445
1518
|
/**
|
|
1446
1519
|
* Create or update a SKU for a product variant combination
|
|
1447
1520
|
*/
|
|
1448
|
-
createProductSku(siteName: string, productId: number, data:
|
|
1449
|
-
sku: string;
|
|
1450
|
-
price?: number | null;
|
|
1451
|
-
sale_price?: number | null;
|
|
1452
|
-
stock_quantity?: number | null;
|
|
1453
|
-
value_ids: number[];
|
|
1454
|
-
}): Promise<ApiResponse<{
|
|
1455
|
-
sku_id: number;
|
|
1456
|
-
sku: string;
|
|
1457
|
-
price?: number;
|
|
1458
|
-
sale_price?: number;
|
|
1459
|
-
stock_quantity?: number;
|
|
1460
|
-
combination_key: string;
|
|
1461
|
-
}>>;
|
|
1521
|
+
createProductSku(siteName: string, productId: number, data: CreateProductSkuRequest): Promise<ApiResponse<ProductSku>>;
|
|
1462
1522
|
}
|
|
1463
1523
|
|
|
1464
1524
|
/**
|
|
@@ -2043,10 +2103,33 @@ declare class NewsletterClient extends BaseClient {
|
|
|
2043
2103
|
/**
|
|
2044
2104
|
* Get available newsletter lists
|
|
2045
2105
|
*/
|
|
2046
|
-
getLists(siteName: string): Promise<ApiResponse<{
|
|
2106
|
+
getLists(siteName: string, cachePolicy?: CachePolicy): Promise<ApiResponse<{
|
|
2047
2107
|
lists: NewsletterList[];
|
|
2048
2108
|
total: number;
|
|
2049
2109
|
}>>;
|
|
2110
|
+
/**
|
|
2111
|
+
* List publicly available (sent) newsletter campaigns
|
|
2112
|
+
*/
|
|
2113
|
+
getPublishedCampaigns(siteName: string, params?: {
|
|
2114
|
+
page?: number;
|
|
2115
|
+
limit?: number;
|
|
2116
|
+
search?: string;
|
|
2117
|
+
}, cachePolicy?: CachePolicy): Promise<ApiResponse<NewsletterCampaignListResponse>>;
|
|
2118
|
+
/**
|
|
2119
|
+
* Fetch a publicly available (sent) newsletter campaign by slug
|
|
2120
|
+
*/
|
|
2121
|
+
getPublishedCampaignBySlug(siteName: string, slug: string, optionsOrPolicy?: {
|
|
2122
|
+
slugPrefix?: string;
|
|
2123
|
+
} | CachePolicy, cachePolicy?: CachePolicy): Promise<ApiResponse<NewsletterCampaignDetail>>;
|
|
2124
|
+
/**
|
|
2125
|
+
* Invalidate cached published newsletter campaign data from a webhook payload.
|
|
2126
|
+
* Only publish events (and legacy sent aliases) trigger invalidation.
|
|
2127
|
+
*/
|
|
2128
|
+
invalidatePublishedCampaignCacheFromWebhook(payload: Record<string, unknown>, fallbackSiteName?: string): Promise<{
|
|
2129
|
+
invalidated: boolean;
|
|
2130
|
+
tags: string[];
|
|
2131
|
+
reason?: string;
|
|
2132
|
+
}>;
|
|
2050
2133
|
/**
|
|
2051
2134
|
* Check subscription status by email
|
|
2052
2135
|
*/
|
|
@@ -2221,6 +2304,12 @@ declare class NewsletterClient extends BaseClient {
|
|
|
2221
2304
|
* Client sites can use this to serve the tracking pixel response.
|
|
2222
2305
|
*/
|
|
2223
2306
|
static getTrackingPixel(): Uint8Array;
|
|
2307
|
+
private buildNewsletterTags;
|
|
2308
|
+
private extractSlugPrefix;
|
|
2309
|
+
private normalizeNewsletterWebhookPayload;
|
|
2310
|
+
private isPublishEvent;
|
|
2311
|
+
private pickString;
|
|
2312
|
+
private isCachePolicy;
|
|
2224
2313
|
}
|
|
2225
2314
|
|
|
2226
2315
|
/**
|
|
@@ -3030,4 +3119,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
3030
3119
|
error: string;
|
|
3031
3120
|
}>;
|
|
3032
3121
|
|
|
3033
|
-
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, 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, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductBundleGroup, type ProductQueryParams, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
|
3122
|
+
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductBundleGroup, type ProductQueryParams, type ProductSku, type ProductSkuMediaItem, type ProductSkuOption, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
package/dist/index.d.ts
CHANGED
|
@@ -202,6 +202,34 @@ interface NewsletterList {
|
|
|
202
202
|
is_default: boolean;
|
|
203
203
|
subscriber_count?: number;
|
|
204
204
|
}
|
|
205
|
+
interface NewsletterCampaignSummary {
|
|
206
|
+
id: string;
|
|
207
|
+
campaign_name: string;
|
|
208
|
+
slug: string;
|
|
209
|
+
slug_prefix?: string | null;
|
|
210
|
+
subject: string;
|
|
211
|
+
preview_text?: string | null;
|
|
212
|
+
status: string;
|
|
213
|
+
sent_at?: string | null;
|
|
214
|
+
completed_at?: string | null;
|
|
215
|
+
created_at: string;
|
|
216
|
+
updated_at: string;
|
|
217
|
+
}
|
|
218
|
+
interface NewsletterCampaignDetail extends NewsletterCampaignSummary {
|
|
219
|
+
markdown_content?: string | null;
|
|
220
|
+
html_content?: string | null;
|
|
221
|
+
text_content?: string | null;
|
|
222
|
+
excerpt?: string | null;
|
|
223
|
+
}
|
|
224
|
+
interface NewsletterCampaignListResponse {
|
|
225
|
+
items: NewsletterCampaignSummary[];
|
|
226
|
+
pagination: {
|
|
227
|
+
page: number;
|
|
228
|
+
limit: number;
|
|
229
|
+
total: number;
|
|
230
|
+
pages: number;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
205
233
|
interface NewsletterPreferences {
|
|
206
234
|
frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
207
235
|
topics?: string[];
|
|
@@ -331,6 +359,46 @@ interface MediaItem {
|
|
|
331
359
|
r2_key: string;
|
|
332
360
|
site_name: string;
|
|
333
361
|
}
|
|
362
|
+
interface ProductSkuMediaItem {
|
|
363
|
+
id?: string;
|
|
364
|
+
media_id: string;
|
|
365
|
+
file_name?: string;
|
|
366
|
+
fileName?: string;
|
|
367
|
+
link?: string;
|
|
368
|
+
url?: string;
|
|
369
|
+
content_type?: string;
|
|
370
|
+
contentType?: string;
|
|
371
|
+
width?: number;
|
|
372
|
+
height?: number;
|
|
373
|
+
filesize?: number;
|
|
374
|
+
r2_key?: string;
|
|
375
|
+
site_name?: string;
|
|
376
|
+
}
|
|
377
|
+
interface ProductSkuOption {
|
|
378
|
+
name: string;
|
|
379
|
+
key: string;
|
|
380
|
+
value: string;
|
|
381
|
+
label: string;
|
|
382
|
+
value_id: number;
|
|
383
|
+
}
|
|
384
|
+
interface ProductSku {
|
|
385
|
+
sku_id: number;
|
|
386
|
+
sku?: string | null;
|
|
387
|
+
combination_key: string;
|
|
388
|
+
media_id?: string | null;
|
|
389
|
+
media?: ProductSkuMediaItem | null;
|
|
390
|
+
options?: ProductSkuOption[];
|
|
391
|
+
unit_amount?: number;
|
|
392
|
+
currency?: string;
|
|
393
|
+
quantity_available?: number | null;
|
|
394
|
+
price?: number;
|
|
395
|
+
sale_price?: number;
|
|
396
|
+
stock_quantity?: number;
|
|
397
|
+
value_ids: number[];
|
|
398
|
+
created_at?: string;
|
|
399
|
+
updated_at?: string;
|
|
400
|
+
[key: string]: any;
|
|
401
|
+
}
|
|
334
402
|
interface Product {
|
|
335
403
|
id: number | string;
|
|
336
404
|
name?: string;
|
|
@@ -344,6 +412,7 @@ interface Product {
|
|
|
344
412
|
slug_prefix?: string;
|
|
345
413
|
image?: string;
|
|
346
414
|
media?: MediaItem[] | MediaItem[][];
|
|
415
|
+
skus?: ProductSku[];
|
|
347
416
|
isActive?: boolean;
|
|
348
417
|
organizationId?: number;
|
|
349
418
|
createdAt?: string;
|
|
@@ -374,6 +443,20 @@ interface CreateProductRequest {
|
|
|
374
443
|
stock_quantity?: number | null;
|
|
375
444
|
isActive?: boolean;
|
|
376
445
|
}
|
|
446
|
+
interface CreateProductSkuRequest {
|
|
447
|
+
sku?: string | null;
|
|
448
|
+
media_id?: string | null;
|
|
449
|
+
unit_amount?: number;
|
|
450
|
+
currency?: string;
|
|
451
|
+
quantity_available?: number | null;
|
|
452
|
+
price?: number | null;
|
|
453
|
+
stock_quantity?: number | null;
|
|
454
|
+
sale_price?: number | null;
|
|
455
|
+
published?: boolean;
|
|
456
|
+
gateway_price_id_test?: string | null;
|
|
457
|
+
gateway_price_id_live?: string | null;
|
|
458
|
+
value_ids: number[];
|
|
459
|
+
}
|
|
377
460
|
interface ProductQueryParams extends PaginationParams {
|
|
378
461
|
organizationId?: number;
|
|
379
462
|
isActive?: boolean;
|
|
@@ -1431,34 +1514,11 @@ declare class ProductsClient extends BaseClient {
|
|
|
1431
1514
|
/**
|
|
1432
1515
|
* Get all SKUs for a product (with their option value combinations)
|
|
1433
1516
|
*/
|
|
1434
|
-
getProductSkus(siteName: string, productId: number): Promise<ApiResponse<
|
|
1435
|
-
sku_id: number;
|
|
1436
|
-
sku: string;
|
|
1437
|
-
price?: number;
|
|
1438
|
-
sale_price?: number;
|
|
1439
|
-
stock_quantity?: number;
|
|
1440
|
-
combination_key: string;
|
|
1441
|
-
value_ids: number[];
|
|
1442
|
-
created_at: string;
|
|
1443
|
-
updated_at: string;
|
|
1444
|
-
}>>>;
|
|
1517
|
+
getProductSkus(siteName: string, productId: number): Promise<ApiResponse<ProductSku[]>>;
|
|
1445
1518
|
/**
|
|
1446
1519
|
* Create or update a SKU for a product variant combination
|
|
1447
1520
|
*/
|
|
1448
|
-
createProductSku(siteName: string, productId: number, data:
|
|
1449
|
-
sku: string;
|
|
1450
|
-
price?: number | null;
|
|
1451
|
-
sale_price?: number | null;
|
|
1452
|
-
stock_quantity?: number | null;
|
|
1453
|
-
value_ids: number[];
|
|
1454
|
-
}): Promise<ApiResponse<{
|
|
1455
|
-
sku_id: number;
|
|
1456
|
-
sku: string;
|
|
1457
|
-
price?: number;
|
|
1458
|
-
sale_price?: number;
|
|
1459
|
-
stock_quantity?: number;
|
|
1460
|
-
combination_key: string;
|
|
1461
|
-
}>>;
|
|
1521
|
+
createProductSku(siteName: string, productId: number, data: CreateProductSkuRequest): Promise<ApiResponse<ProductSku>>;
|
|
1462
1522
|
}
|
|
1463
1523
|
|
|
1464
1524
|
/**
|
|
@@ -2043,10 +2103,33 @@ declare class NewsletterClient extends BaseClient {
|
|
|
2043
2103
|
/**
|
|
2044
2104
|
* Get available newsletter lists
|
|
2045
2105
|
*/
|
|
2046
|
-
getLists(siteName: string): Promise<ApiResponse<{
|
|
2106
|
+
getLists(siteName: string, cachePolicy?: CachePolicy): Promise<ApiResponse<{
|
|
2047
2107
|
lists: NewsletterList[];
|
|
2048
2108
|
total: number;
|
|
2049
2109
|
}>>;
|
|
2110
|
+
/**
|
|
2111
|
+
* List publicly available (sent) newsletter campaigns
|
|
2112
|
+
*/
|
|
2113
|
+
getPublishedCampaigns(siteName: string, params?: {
|
|
2114
|
+
page?: number;
|
|
2115
|
+
limit?: number;
|
|
2116
|
+
search?: string;
|
|
2117
|
+
}, cachePolicy?: CachePolicy): Promise<ApiResponse<NewsletterCampaignListResponse>>;
|
|
2118
|
+
/**
|
|
2119
|
+
* Fetch a publicly available (sent) newsletter campaign by slug
|
|
2120
|
+
*/
|
|
2121
|
+
getPublishedCampaignBySlug(siteName: string, slug: string, optionsOrPolicy?: {
|
|
2122
|
+
slugPrefix?: string;
|
|
2123
|
+
} | CachePolicy, cachePolicy?: CachePolicy): Promise<ApiResponse<NewsletterCampaignDetail>>;
|
|
2124
|
+
/**
|
|
2125
|
+
* Invalidate cached published newsletter campaign data from a webhook payload.
|
|
2126
|
+
* Only publish events (and legacy sent aliases) trigger invalidation.
|
|
2127
|
+
*/
|
|
2128
|
+
invalidatePublishedCampaignCacheFromWebhook(payload: Record<string, unknown>, fallbackSiteName?: string): Promise<{
|
|
2129
|
+
invalidated: boolean;
|
|
2130
|
+
tags: string[];
|
|
2131
|
+
reason?: string;
|
|
2132
|
+
}>;
|
|
2050
2133
|
/**
|
|
2051
2134
|
* Check subscription status by email
|
|
2052
2135
|
*/
|
|
@@ -2221,6 +2304,12 @@ declare class NewsletterClient extends BaseClient {
|
|
|
2221
2304
|
* Client sites can use this to serve the tracking pixel response.
|
|
2222
2305
|
*/
|
|
2223
2306
|
static getTrackingPixel(): Uint8Array;
|
|
2307
|
+
private buildNewsletterTags;
|
|
2308
|
+
private extractSlugPrefix;
|
|
2309
|
+
private normalizeNewsletterWebhookPayload;
|
|
2310
|
+
private isPublishEvent;
|
|
2311
|
+
private pickString;
|
|
2312
|
+
private isCachePolicy;
|
|
2224
2313
|
}
|
|
2225
2314
|
|
|
2226
2315
|
/**
|
|
@@ -3030,4 +3119,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
3030
3119
|
error: string;
|
|
3031
3120
|
}>;
|
|
3032
3121
|
|
|
3033
|
-
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, 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, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductBundleGroup, type ProductQueryParams, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
|
3122
|
+
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductBundleGroup, type ProductQueryParams, type ProductSku, type ProductSkuMediaItem, type ProductSkuOption, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|