perspectapi-ts-sdk 6.2.0 → 6.3.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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +47 -7
- package/dist/index.mjs +46 -7
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/types/index.ts +14 -0
- package/src/utils/http-client.ts +8 -7
- package/src/v2/client/collections-client.ts +29 -5
package/dist/index.d.mts
CHANGED
|
@@ -1079,6 +1079,12 @@ interface ApiError {
|
|
|
1079
1079
|
status?: number;
|
|
1080
1080
|
details?: any;
|
|
1081
1081
|
}
|
|
1082
|
+
declare class PerspectApiError extends Error implements ApiError {
|
|
1083
|
+
code?: string;
|
|
1084
|
+
status?: number;
|
|
1085
|
+
details?: any;
|
|
1086
|
+
constructor({ message, code, status, details }: ApiError);
|
|
1087
|
+
}
|
|
1082
1088
|
interface PerspectApiConfig {
|
|
1083
1089
|
baseUrl: string;
|
|
1084
1090
|
apiKey?: string;
|
|
@@ -4518,4 +4524,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
4518
4524
|
error: string;
|
|
4519
4525
|
}>;
|
|
4520
4526
|
|
|
4521
|
-
export { type AbClient, type AbForRequestResult, type AbVariantResult, type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheAdapter, type CacheConfig, CacheManager, type CancelSubscriptionRequest, type CancelSubscriptionResponse, 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, CloudflareKVCacheAdapter, 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 CreatePerspectAbOptions, 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 LoadBlockBySlugOptions, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, type NewsletterCampaignTestSendRequest, type NewsletterCampaignTestSendResponse, NewsletterClient, type NewsletterConfirmResponse, type NewsletterExportCreateRequest, type NewsletterExportCreateResponse, type NewsletterList, type NewsletterManagementCampaign, type NewsletterManagementCampaignListResponse, NewsletterManagementClient, type NewsletterManagementList, type NewsletterManagementListMembership, type NewsletterManagementPagination, type NewsletterManagementSeries, type NewsletterManagementStatsResponse, type NewsletterManagementSubscription, type NewsletterManagementSubscriptionsListResponse, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterSubscriptionImportRowRequest, type NewsletterSubscriptionMembershipUpdateRequest, type NewsletterSubscriptionSyncRequest, type NewsletterSubscriptionSyncResponse, type NewsletterSubscriptionsBulkAction, type NewsletterSubscriptionsBulkOutcome, type NewsletterSubscriptionsBulkUpdateRequest, type NewsletterSubscriptionsBulkUpdateResponse, type NewsletterSubscriptionsImportRequest, type NewsletterSubscriptionsImportResponse, type NewsletterSubscriptionsImportRowResult, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, type PerspectAb, PerspectApiClient, type PerspectApiConfig, PerspectApiV2Client, PerspectV2Error, 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 SubscriptionCancellationMode, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, V1_DEPRECATION_NOTICE, V1_SUNSET_DATE, type V2ApiKey, type V2CancelSubscriptionResult, type V2Category, type V2CategoryCreateParams, type V2CategoryUpdateParams, type V2Collection, type V2CollectionCreateParams, type V2CollectionItem, type V2CollectionUpdateParams, type V2ContactSubmission, type V2Content, type V2ContentCreateParams, type V2ContentListParams, type V2ContentUpdateParams, type V2CreditBalance, type V2CreditTransaction, type V2Deleted, type V2Error, type V2ErrorType, type V2GrantCreditParams, type V2GrantCreditResult, type V2List, type V2Media, type V2NewsletterCampaign, type V2NewsletterImportRequest, type V2NewsletterImportResult, type V2NewsletterList, type V2NewsletterListCreateParams, type V2NewsletterListUpdateParams, type V2NewsletterSubscription, type V2NewsletterSubscriptionListMembershipUpdate, type V2NewsletterSyncInput, type V2NewsletterSyncResult, type V2NewsletterTrackingResponse, type V2Object, type V2Order, type V2OrderAddress, type V2OrderCreateParams, type V2OrderCreateResult, type V2OrderFulfillmentUpdate, type V2OrderLineItem, type V2OrderLineItemPriceData, type V2OrderListParams, type V2OrderTaxRequest, type V2Organization, type V2PaginationParams, type V2Product, type V2ProductCreateParams, type V2ProductListParams, type V2ProductUpdateParams, type V2Site, type V2SiteUser, type V2SiteUserListParams, type V2SiteUserMeUpdateParams, type V2SiteUserProfile, type V2SiteUserSubscription, type V2SiteUserUpdateParams, type V2SiteUserWithProfile, type V2SubscriptionCancelParams, type V2SubscriptionChangePlanParams, type V2SubscriptionPauseParams, type V2Webhook, type V2WebhookCreateParams, type V2WebhookUpdateParams, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, bucketFor, buildImageUrl, createApiError, createCheckoutSession, createPerspectAb, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadBlockBySlug, loadBlocks, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct, variantForBucket };
|
|
4527
|
+
export { type AbClient, type AbForRequestResult, type AbVariantResult, type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheAdapter, type CacheConfig, CacheManager, type CancelSubscriptionRequest, type CancelSubscriptionResponse, 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, CloudflareKVCacheAdapter, 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 CreatePerspectAbOptions, 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 LoadBlockBySlugOptions, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, type NewsletterCampaignTestSendRequest, type NewsletterCampaignTestSendResponse, NewsletterClient, type NewsletterConfirmResponse, type NewsletterExportCreateRequest, type NewsletterExportCreateResponse, type NewsletterList, type NewsletterManagementCampaign, type NewsletterManagementCampaignListResponse, NewsletterManagementClient, type NewsletterManagementList, type NewsletterManagementListMembership, type NewsletterManagementPagination, type NewsletterManagementSeries, type NewsletterManagementStatsResponse, type NewsletterManagementSubscription, type NewsletterManagementSubscriptionsListResponse, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterSubscriptionImportRowRequest, type NewsletterSubscriptionMembershipUpdateRequest, type NewsletterSubscriptionSyncRequest, type NewsletterSubscriptionSyncResponse, type NewsletterSubscriptionsBulkAction, type NewsletterSubscriptionsBulkOutcome, type NewsletterSubscriptionsBulkUpdateRequest, type NewsletterSubscriptionsBulkUpdateResponse, type NewsletterSubscriptionsImportRequest, type NewsletterSubscriptionsImportResponse, type NewsletterSubscriptionsImportRowResult, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, type PerspectAb, PerspectApiClient, type PerspectApiConfig, PerspectApiError, PerspectApiV2Client, PerspectV2Error, 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 SubscriptionCancellationMode, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, V1_DEPRECATION_NOTICE, V1_SUNSET_DATE, type V2ApiKey, type V2CancelSubscriptionResult, type V2Category, type V2CategoryCreateParams, type V2CategoryUpdateParams, type V2Collection, type V2CollectionCreateParams, type V2CollectionItem, type V2CollectionUpdateParams, type V2ContactSubmission, type V2Content, type V2ContentCreateParams, type V2ContentListParams, type V2ContentUpdateParams, type V2CreditBalance, type V2CreditTransaction, type V2Deleted, type V2Error, type V2ErrorType, type V2GrantCreditParams, type V2GrantCreditResult, type V2List, type V2Media, type V2NewsletterCampaign, type V2NewsletterImportRequest, type V2NewsletterImportResult, type V2NewsletterList, type V2NewsletterListCreateParams, type V2NewsletterListUpdateParams, type V2NewsletterSubscription, type V2NewsletterSubscriptionListMembershipUpdate, type V2NewsletterSyncInput, type V2NewsletterSyncResult, type V2NewsletterTrackingResponse, type V2Object, type V2Order, type V2OrderAddress, type V2OrderCreateParams, type V2OrderCreateResult, type V2OrderFulfillmentUpdate, type V2OrderLineItem, type V2OrderLineItemPriceData, type V2OrderListParams, type V2OrderTaxRequest, type V2Organization, type V2PaginationParams, type V2Product, type V2ProductCreateParams, type V2ProductListParams, type V2ProductUpdateParams, type V2Site, type V2SiteUser, type V2SiteUserListParams, type V2SiteUserMeUpdateParams, type V2SiteUserProfile, type V2SiteUserSubscription, type V2SiteUserUpdateParams, type V2SiteUserWithProfile, type V2SubscriptionCancelParams, type V2SubscriptionChangePlanParams, type V2SubscriptionPauseParams, type V2Webhook, type V2WebhookCreateParams, type V2WebhookUpdateParams, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, bucketFor, buildImageUrl, createApiError, createCheckoutSession, createPerspectAb, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadBlockBySlug, loadBlocks, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct, variantForBucket };
|
package/dist/index.d.ts
CHANGED
|
@@ -1079,6 +1079,12 @@ interface ApiError {
|
|
|
1079
1079
|
status?: number;
|
|
1080
1080
|
details?: any;
|
|
1081
1081
|
}
|
|
1082
|
+
declare class PerspectApiError extends Error implements ApiError {
|
|
1083
|
+
code?: string;
|
|
1084
|
+
status?: number;
|
|
1085
|
+
details?: any;
|
|
1086
|
+
constructor({ message, code, status, details }: ApiError);
|
|
1087
|
+
}
|
|
1082
1088
|
interface PerspectApiConfig {
|
|
1083
1089
|
baseUrl: string;
|
|
1084
1090
|
apiKey?: string;
|
|
@@ -4518,4 +4524,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
4518
4524
|
error: string;
|
|
4519
4525
|
}>;
|
|
4520
4526
|
|
|
4521
|
-
export { type AbClient, type AbForRequestResult, type AbVariantResult, type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheAdapter, type CacheConfig, CacheManager, type CancelSubscriptionRequest, type CancelSubscriptionResponse, 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, CloudflareKVCacheAdapter, 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 CreatePerspectAbOptions, 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 LoadBlockBySlugOptions, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, type NewsletterCampaignTestSendRequest, type NewsletterCampaignTestSendResponse, NewsletterClient, type NewsletterConfirmResponse, type NewsletterExportCreateRequest, type NewsletterExportCreateResponse, type NewsletterList, type NewsletterManagementCampaign, type NewsletterManagementCampaignListResponse, NewsletterManagementClient, type NewsletterManagementList, type NewsletterManagementListMembership, type NewsletterManagementPagination, type NewsletterManagementSeries, type NewsletterManagementStatsResponse, type NewsletterManagementSubscription, type NewsletterManagementSubscriptionsListResponse, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterSubscriptionImportRowRequest, type NewsletterSubscriptionMembershipUpdateRequest, type NewsletterSubscriptionSyncRequest, type NewsletterSubscriptionSyncResponse, type NewsletterSubscriptionsBulkAction, type NewsletterSubscriptionsBulkOutcome, type NewsletterSubscriptionsBulkUpdateRequest, type NewsletterSubscriptionsBulkUpdateResponse, type NewsletterSubscriptionsImportRequest, type NewsletterSubscriptionsImportResponse, type NewsletterSubscriptionsImportRowResult, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, type PerspectAb, PerspectApiClient, type PerspectApiConfig, PerspectApiV2Client, PerspectV2Error, 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 SubscriptionCancellationMode, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, V1_DEPRECATION_NOTICE, V1_SUNSET_DATE, type V2ApiKey, type V2CancelSubscriptionResult, type V2Category, type V2CategoryCreateParams, type V2CategoryUpdateParams, type V2Collection, type V2CollectionCreateParams, type V2CollectionItem, type V2CollectionUpdateParams, type V2ContactSubmission, type V2Content, type V2ContentCreateParams, type V2ContentListParams, type V2ContentUpdateParams, type V2CreditBalance, type V2CreditTransaction, type V2Deleted, type V2Error, type V2ErrorType, type V2GrantCreditParams, type V2GrantCreditResult, type V2List, type V2Media, type V2NewsletterCampaign, type V2NewsletterImportRequest, type V2NewsletterImportResult, type V2NewsletterList, type V2NewsletterListCreateParams, type V2NewsletterListUpdateParams, type V2NewsletterSubscription, type V2NewsletterSubscriptionListMembershipUpdate, type V2NewsletterSyncInput, type V2NewsletterSyncResult, type V2NewsletterTrackingResponse, type V2Object, type V2Order, type V2OrderAddress, type V2OrderCreateParams, type V2OrderCreateResult, type V2OrderFulfillmentUpdate, type V2OrderLineItem, type V2OrderLineItemPriceData, type V2OrderListParams, type V2OrderTaxRequest, type V2Organization, type V2PaginationParams, type V2Product, type V2ProductCreateParams, type V2ProductListParams, type V2ProductUpdateParams, type V2Site, type V2SiteUser, type V2SiteUserListParams, type V2SiteUserMeUpdateParams, type V2SiteUserProfile, type V2SiteUserSubscription, type V2SiteUserUpdateParams, type V2SiteUserWithProfile, type V2SubscriptionCancelParams, type V2SubscriptionChangePlanParams, type V2SubscriptionPauseParams, type V2Webhook, type V2WebhookCreateParams, type V2WebhookUpdateParams, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, bucketFor, buildImageUrl, createApiError, createCheckoutSession, createPerspectAb, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadBlockBySlug, loadBlocks, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct, variantForBucket };
|
|
4527
|
+
export { type AbClient, type AbForRequestResult, type AbVariantResult, type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheAdapter, type CacheConfig, CacheManager, type CancelSubscriptionRequest, type CancelSubscriptionResponse, 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, CloudflareKVCacheAdapter, 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 CreatePerspectAbOptions, 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 LoadBlockBySlugOptions, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, type NewsletterCampaignTestSendRequest, type NewsletterCampaignTestSendResponse, NewsletterClient, type NewsletterConfirmResponse, type NewsletterExportCreateRequest, type NewsletterExportCreateResponse, type NewsletterList, type NewsletterManagementCampaign, type NewsletterManagementCampaignListResponse, NewsletterManagementClient, type NewsletterManagementList, type NewsletterManagementListMembership, type NewsletterManagementPagination, type NewsletterManagementSeries, type NewsletterManagementStatsResponse, type NewsletterManagementSubscription, type NewsletterManagementSubscriptionsListResponse, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterSubscriptionImportRowRequest, type NewsletterSubscriptionMembershipUpdateRequest, type NewsletterSubscriptionSyncRequest, type NewsletterSubscriptionSyncResponse, type NewsletterSubscriptionsBulkAction, type NewsletterSubscriptionsBulkOutcome, type NewsletterSubscriptionsBulkUpdateRequest, type NewsletterSubscriptionsBulkUpdateResponse, type NewsletterSubscriptionsImportRequest, type NewsletterSubscriptionsImportResponse, type NewsletterSubscriptionsImportRowResult, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, type PerspectAb, PerspectApiClient, type PerspectApiConfig, PerspectApiError, PerspectApiV2Client, PerspectV2Error, 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 SubscriptionCancellationMode, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, V1_DEPRECATION_NOTICE, V1_SUNSET_DATE, type V2ApiKey, type V2CancelSubscriptionResult, type V2Category, type V2CategoryCreateParams, type V2CategoryUpdateParams, type V2Collection, type V2CollectionCreateParams, type V2CollectionItem, type V2CollectionUpdateParams, type V2ContactSubmission, type V2Content, type V2ContentCreateParams, type V2ContentListParams, type V2ContentUpdateParams, type V2CreditBalance, type V2CreditTransaction, type V2Deleted, type V2Error, type V2ErrorType, type V2GrantCreditParams, type V2GrantCreditResult, type V2List, type V2Media, type V2NewsletterCampaign, type V2NewsletterImportRequest, type V2NewsletterImportResult, type V2NewsletterList, type V2NewsletterListCreateParams, type V2NewsletterListUpdateParams, type V2NewsletterSubscription, type V2NewsletterSubscriptionListMembershipUpdate, type V2NewsletterSyncInput, type V2NewsletterSyncResult, type V2NewsletterTrackingResponse, type V2Object, type V2Order, type V2OrderAddress, type V2OrderCreateParams, type V2OrderCreateResult, type V2OrderFulfillmentUpdate, type V2OrderLineItem, type V2OrderLineItemPriceData, type V2OrderListParams, type V2OrderTaxRequest, type V2Organization, type V2PaginationParams, type V2Product, type V2ProductCreateParams, type V2ProductListParams, type V2ProductUpdateParams, type V2Site, type V2SiteUser, type V2SiteUserListParams, type V2SiteUserMeUpdateParams, type V2SiteUserProfile, type V2SiteUserSubscription, type V2SiteUserUpdateParams, type V2SiteUserWithProfile, type V2SubscriptionCancelParams, type V2SubscriptionChangePlanParams, type V2SubscriptionPauseParams, type V2Webhook, type V2WebhookCreateParams, type V2WebhookUpdateParams, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, bucketFor, buildImageUrl, createApiError, createCheckoutSession, createPerspectAb, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadBlockBySlug, loadBlocks, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct, variantForBucket };
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
NoopCacheAdapter: () => NoopCacheAdapter,
|
|
39
39
|
OrganizationsClient: () => OrganizationsClient,
|
|
40
40
|
PerspectApiClient: () => PerspectApiClient,
|
|
41
|
+
PerspectApiError: () => PerspectApiError,
|
|
41
42
|
PerspectApiV2Client: () => PerspectApiV2Client,
|
|
42
43
|
PerspectV2Error: () => PerspectV2Error,
|
|
43
44
|
ProductsClient: () => ProductsClient,
|
|
@@ -83,6 +84,20 @@ function warnV1Deprecated() {
|
|
|
83
84
|
console.warn(`[perspectapi-ts-sdk] ${V1_DEPRECATION_NOTICE}`);
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
// src/types/index.ts
|
|
88
|
+
var PerspectApiError = class extends Error {
|
|
89
|
+
code;
|
|
90
|
+
status;
|
|
91
|
+
details;
|
|
92
|
+
constructor({ message, code, status, details }) {
|
|
93
|
+
super(message);
|
|
94
|
+
this.name = "PerspectApiError";
|
|
95
|
+
this.code = code;
|
|
96
|
+
this.status = status;
|
|
97
|
+
this.details = details;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
86
101
|
// src/utils/http-client.ts
|
|
87
102
|
var HttpClient = class {
|
|
88
103
|
baseUrl;
|
|
@@ -286,12 +301,12 @@ var HttpClient = class {
|
|
|
286
301
|
}
|
|
287
302
|
if (!response.ok) {
|
|
288
303
|
console.error(`[HTTP Client - Response] Error response received`);
|
|
289
|
-
const error = {
|
|
304
|
+
const error = new PerspectApiError({
|
|
290
305
|
message: data?.error || data?.message || `HTTP ${response.status}: ${response.statusText}`,
|
|
291
306
|
status: response.status,
|
|
292
307
|
code: data?.code,
|
|
293
308
|
details: data
|
|
294
|
-
};
|
|
309
|
+
});
|
|
295
310
|
console.error(`[HTTP Client - Response] Throwing error:`, error);
|
|
296
311
|
throw error;
|
|
297
312
|
}
|
|
@@ -900,13 +915,29 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
900
915
|
return this.getOne(this.sitePath(siteName, "collections", id));
|
|
901
916
|
}
|
|
902
917
|
async create(siteName, data) {
|
|
903
|
-
|
|
918
|
+
const result = await this.post(this.sitePath(siteName, "collections"), data);
|
|
919
|
+
await this.invalidateCache({ keys: [this.sitePath(siteName, "collections")] });
|
|
920
|
+
return result;
|
|
904
921
|
}
|
|
905
922
|
async update(siteName, id, data) {
|
|
906
|
-
|
|
923
|
+
const result = await this.patchOne(this.sitePath(siteName, "collections", id), data);
|
|
924
|
+
await this.invalidateCache({
|
|
925
|
+
keys: [
|
|
926
|
+
this.sitePath(siteName, "collections"),
|
|
927
|
+
this.sitePath(siteName, "collections", id)
|
|
928
|
+
]
|
|
929
|
+
});
|
|
930
|
+
return result;
|
|
907
931
|
}
|
|
908
932
|
async del(siteName, id) {
|
|
909
|
-
|
|
933
|
+
const result = await this.deleteOne(this.sitePath(siteName, "collections", id));
|
|
934
|
+
await this.invalidateCache({
|
|
935
|
+
keys: [
|
|
936
|
+
this.sitePath(siteName, "collections"),
|
|
937
|
+
this.sitePath(siteName, "collections", id)
|
|
938
|
+
]
|
|
939
|
+
});
|
|
940
|
+
return result;
|
|
910
941
|
}
|
|
911
942
|
// --- Items ---
|
|
912
943
|
async listItems(siteName, collectionId) {
|
|
@@ -915,15 +946,23 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
915
946
|
);
|
|
916
947
|
}
|
|
917
948
|
async addItem(siteName, collectionId, data) {
|
|
918
|
-
|
|
949
|
+
const result = await this.post(
|
|
919
950
|
this.sitePath(siteName, "collections", `${collectionId}/items`),
|
|
920
951
|
data
|
|
921
952
|
);
|
|
953
|
+
await this.invalidateCache({
|
|
954
|
+
keys: [this.sitePath(siteName, "collections", `${collectionId}/items`)]
|
|
955
|
+
});
|
|
956
|
+
return result;
|
|
922
957
|
}
|
|
923
958
|
async removeItem(siteName, collectionId, itemId) {
|
|
924
|
-
|
|
959
|
+
const result = await this.deleteOne(
|
|
925
960
|
this.sitePath(siteName, "collections", `${collectionId}/items/${itemId}`)
|
|
926
961
|
);
|
|
962
|
+
await this.invalidateCache({
|
|
963
|
+
keys: [this.sitePath(siteName, "collections", `${collectionId}/items`)]
|
|
964
|
+
});
|
|
965
|
+
return result;
|
|
927
966
|
}
|
|
928
967
|
};
|
|
929
968
|
|
|
@@ -4994,6 +5033,7 @@ async function createCheckoutSession(options) {
|
|
|
4994
5033
|
NoopCacheAdapter,
|
|
4995
5034
|
OrganizationsClient,
|
|
4996
5035
|
PerspectApiClient,
|
|
5036
|
+
PerspectApiError,
|
|
4997
5037
|
PerspectApiV2Client,
|
|
4998
5038
|
PerspectV2Error,
|
|
4999
5039
|
ProductsClient,
|
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,20 @@ function warnV1Deprecated() {
|
|
|
8
8
|
console.warn(`[perspectapi-ts-sdk] ${V1_DEPRECATION_NOTICE}`);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
// src/types/index.ts
|
|
12
|
+
var PerspectApiError = class extends Error {
|
|
13
|
+
code;
|
|
14
|
+
status;
|
|
15
|
+
details;
|
|
16
|
+
constructor({ message, code, status, details }) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "PerspectApiError";
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.status = status;
|
|
21
|
+
this.details = details;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
11
25
|
// src/utils/http-client.ts
|
|
12
26
|
var HttpClient = class {
|
|
13
27
|
baseUrl;
|
|
@@ -211,12 +225,12 @@ var HttpClient = class {
|
|
|
211
225
|
}
|
|
212
226
|
if (!response.ok) {
|
|
213
227
|
console.error(`[HTTP Client - Response] Error response received`);
|
|
214
|
-
const error = {
|
|
228
|
+
const error = new PerspectApiError({
|
|
215
229
|
message: data?.error || data?.message || `HTTP ${response.status}: ${response.statusText}`,
|
|
216
230
|
status: response.status,
|
|
217
231
|
code: data?.code,
|
|
218
232
|
details: data
|
|
219
|
-
};
|
|
233
|
+
});
|
|
220
234
|
console.error(`[HTTP Client - Response] Throwing error:`, error);
|
|
221
235
|
throw error;
|
|
222
236
|
}
|
|
@@ -825,13 +839,29 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
825
839
|
return this.getOne(this.sitePath(siteName, "collections", id));
|
|
826
840
|
}
|
|
827
841
|
async create(siteName, data) {
|
|
828
|
-
|
|
842
|
+
const result = await this.post(this.sitePath(siteName, "collections"), data);
|
|
843
|
+
await this.invalidateCache({ keys: [this.sitePath(siteName, "collections")] });
|
|
844
|
+
return result;
|
|
829
845
|
}
|
|
830
846
|
async update(siteName, id, data) {
|
|
831
|
-
|
|
847
|
+
const result = await this.patchOne(this.sitePath(siteName, "collections", id), data);
|
|
848
|
+
await this.invalidateCache({
|
|
849
|
+
keys: [
|
|
850
|
+
this.sitePath(siteName, "collections"),
|
|
851
|
+
this.sitePath(siteName, "collections", id)
|
|
852
|
+
]
|
|
853
|
+
});
|
|
854
|
+
return result;
|
|
832
855
|
}
|
|
833
856
|
async del(siteName, id) {
|
|
834
|
-
|
|
857
|
+
const result = await this.deleteOne(this.sitePath(siteName, "collections", id));
|
|
858
|
+
await this.invalidateCache({
|
|
859
|
+
keys: [
|
|
860
|
+
this.sitePath(siteName, "collections"),
|
|
861
|
+
this.sitePath(siteName, "collections", id)
|
|
862
|
+
]
|
|
863
|
+
});
|
|
864
|
+
return result;
|
|
835
865
|
}
|
|
836
866
|
// --- Items ---
|
|
837
867
|
async listItems(siteName, collectionId) {
|
|
@@ -840,15 +870,23 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
840
870
|
);
|
|
841
871
|
}
|
|
842
872
|
async addItem(siteName, collectionId, data) {
|
|
843
|
-
|
|
873
|
+
const result = await this.post(
|
|
844
874
|
this.sitePath(siteName, "collections", `${collectionId}/items`),
|
|
845
875
|
data
|
|
846
876
|
);
|
|
877
|
+
await this.invalidateCache({
|
|
878
|
+
keys: [this.sitePath(siteName, "collections", `${collectionId}/items`)]
|
|
879
|
+
});
|
|
880
|
+
return result;
|
|
847
881
|
}
|
|
848
882
|
async removeItem(siteName, collectionId, itemId) {
|
|
849
|
-
|
|
883
|
+
const result = await this.deleteOne(
|
|
850
884
|
this.sitePath(siteName, "collections", `${collectionId}/items/${itemId}`)
|
|
851
885
|
);
|
|
886
|
+
await this.invalidateCache({
|
|
887
|
+
keys: [this.sitePath(siteName, "collections", `${collectionId}/items`)]
|
|
888
|
+
});
|
|
889
|
+
return result;
|
|
852
890
|
}
|
|
853
891
|
};
|
|
854
892
|
|
|
@@ -4918,6 +4956,7 @@ export {
|
|
|
4918
4956
|
NoopCacheAdapter,
|
|
4919
4957
|
OrganizationsClient,
|
|
4920
4958
|
PerspectApiClient,
|
|
4959
|
+
PerspectApiError,
|
|
4921
4960
|
PerspectApiV2Client,
|
|
4922
4961
|
PerspectV2Error,
|
|
4923
4962
|
ProductsClient,
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ export { BaseClient } from './client/base-client';
|
|
|
58
58
|
|
|
59
59
|
// Utilities
|
|
60
60
|
export { HttpClient, createApiError } from './utils/http-client';
|
|
61
|
+
export { PerspectApiError } from './types';
|
|
61
62
|
|
|
62
63
|
// Cache utilities
|
|
63
64
|
export { CacheManager } from './cache/cache-manager';
|
package/src/types/index.ts
CHANGED
|
@@ -1138,6 +1138,20 @@ export interface ApiError {
|
|
|
1138
1138
|
details?: any;
|
|
1139
1139
|
}
|
|
1140
1140
|
|
|
1141
|
+
export class PerspectApiError extends Error implements ApiError {
|
|
1142
|
+
code?: string;
|
|
1143
|
+
status?: number;
|
|
1144
|
+
details?: any;
|
|
1145
|
+
|
|
1146
|
+
constructor({ message, code, status, details }: ApiError) {
|
|
1147
|
+
super(message);
|
|
1148
|
+
this.name = 'PerspectApiError';
|
|
1149
|
+
this.code = code;
|
|
1150
|
+
this.status = status;
|
|
1151
|
+
this.details = details;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1141
1155
|
// SDK Configuration
|
|
1142
1156
|
export interface PerspectApiConfig {
|
|
1143
1157
|
baseUrl: string;
|
package/src/utils/http-client.ts
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* Cloudflare Workers compatible - uses native fetch API
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
7
|
-
ApiResponse,
|
|
8
|
-
ApiError,
|
|
9
|
-
RequestOptions,
|
|
10
|
-
PerspectApiConfig
|
|
6
|
+
import type {
|
|
7
|
+
ApiResponse,
|
|
8
|
+
ApiError,
|
|
9
|
+
RequestOptions,
|
|
10
|
+
PerspectApiConfig
|
|
11
11
|
} from '../types';
|
|
12
|
+
import { PerspectApiError } from '../types';
|
|
12
13
|
|
|
13
14
|
export class HttpClient {
|
|
14
15
|
private baseUrl: string;
|
|
@@ -266,12 +267,12 @@ export class HttpClient {
|
|
|
266
267
|
|
|
267
268
|
if (!response.ok) {
|
|
268
269
|
console.error(`[HTTP Client - Response] Error response received`);
|
|
269
|
-
const error
|
|
270
|
+
const error = new PerspectApiError({
|
|
270
271
|
message: data?.error || data?.message || `HTTP ${response.status}: ${response.statusText}`,
|
|
271
272
|
status: response.status,
|
|
272
273
|
code: data?.code,
|
|
273
274
|
details: data,
|
|
274
|
-
};
|
|
275
|
+
});
|
|
275
276
|
console.error(`[HTTP Client - Response] Throwing error:`, error);
|
|
276
277
|
throw error;
|
|
277
278
|
}
|
|
@@ -26,15 +26,31 @@ export class CollectionsV2Client extends BaseV2Client {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async create(siteName: string, data: V2CollectionCreateParams): Promise<V2Collection> {
|
|
29
|
-
|
|
29
|
+
const result = await this.post<V2Collection>(this.sitePath(siteName, 'collections'), data);
|
|
30
|
+
await this.invalidateCache({ keys: [this.sitePath(siteName, 'collections')] });
|
|
31
|
+
return result;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
async update(siteName: string, id: string, data: V2CollectionUpdateParams): Promise<V2Collection> {
|
|
33
|
-
|
|
35
|
+
const result = await this.patchOne<V2Collection>(this.sitePath(siteName, 'collections', id), data);
|
|
36
|
+
await this.invalidateCache({
|
|
37
|
+
keys: [
|
|
38
|
+
this.sitePath(siteName, 'collections'),
|
|
39
|
+
this.sitePath(siteName, 'collections', id),
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
async del(siteName: string, id: string): Promise<V2Deleted> {
|
|
37
|
-
|
|
46
|
+
const result = await this.deleteOne(this.sitePath(siteName, 'collections', id));
|
|
47
|
+
await this.invalidateCache({
|
|
48
|
+
keys: [
|
|
49
|
+
this.sitePath(siteName, 'collections'),
|
|
50
|
+
this.sitePath(siteName, 'collections', id),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
return result;
|
|
38
54
|
}
|
|
39
55
|
|
|
40
56
|
// --- Items ---
|
|
@@ -50,15 +66,23 @@ export class CollectionsV2Client extends BaseV2Client {
|
|
|
50
66
|
collectionId: string,
|
|
51
67
|
data: { product_id: string; max_quantity?: number | null; position?: number },
|
|
52
68
|
): Promise<V2CollectionItem> {
|
|
53
|
-
|
|
69
|
+
const result = await this.post<V2CollectionItem>(
|
|
54
70
|
this.sitePath(siteName, 'collections', `${collectionId}/items`),
|
|
55
71
|
data,
|
|
56
72
|
);
|
|
73
|
+
await this.invalidateCache({
|
|
74
|
+
keys: [this.sitePath(siteName, 'collections', `${collectionId}/items`)],
|
|
75
|
+
});
|
|
76
|
+
return result;
|
|
57
77
|
}
|
|
58
78
|
|
|
59
79
|
async removeItem(siteName: string, collectionId: string, itemId: string): Promise<V2Deleted> {
|
|
60
|
-
|
|
80
|
+
const result = await this.deleteOne(
|
|
61
81
|
this.sitePath(siteName, 'collections', `${collectionId}/items/${itemId}`),
|
|
62
82
|
);
|
|
83
|
+
await this.invalidateCache({
|
|
84
|
+
keys: [this.sitePath(siteName, 'collections', `${collectionId}/items`)],
|
|
85
|
+
});
|
|
86
|
+
return result;
|
|
63
87
|
}
|
|
64
88
|
}
|