perspectapi-ts-sdk 6.1.1 → 6.1.2
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 +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +54 -0
- package/dist/index.mjs +52 -0
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/loaders.ts +77 -0
package/dist/index.d.mts
CHANGED
|
@@ -4383,6 +4383,17 @@ interface LoadContentBySlugOptions extends LoaderOptions {
|
|
|
4383
4383
|
* Load a single content item (post or page) by slug.
|
|
4384
4384
|
*/
|
|
4385
4385
|
declare function loadContentBySlug(options: LoadContentBySlugOptions): Promise<BlogPost | null>;
|
|
4386
|
+
interface LoadBlockBySlugOptions extends LoaderOptions {
|
|
4387
|
+
slug: string;
|
|
4388
|
+
}
|
|
4389
|
+
/**
|
|
4390
|
+
* Load published blocks for a site.
|
|
4391
|
+
*/
|
|
4392
|
+
declare function loadBlocks(options: LoadContentOptions): Promise<BlogPost[]>;
|
|
4393
|
+
/**
|
|
4394
|
+
* Load a single block by slug.
|
|
4395
|
+
*/
|
|
4396
|
+
declare function loadBlockBySlug(options: LoadBlockBySlugOptions): Promise<BlogPost | null>;
|
|
4386
4397
|
/**
|
|
4387
4398
|
* Load all published content (pages + posts).
|
|
4388
4399
|
*/
|
|
@@ -4434,4 +4445,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
4434
4445
|
error: string;
|
|
4435
4446
|
}>;
|
|
4436
4447
|
|
|
4437
|
-
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, 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 CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, 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, 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, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
|
4448
|
+
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, 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 CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, 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, 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, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadBlockBySlug, loadBlocks, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
package/dist/index.d.ts
CHANGED
|
@@ -4383,6 +4383,17 @@ interface LoadContentBySlugOptions extends LoaderOptions {
|
|
|
4383
4383
|
* Load a single content item (post or page) by slug.
|
|
4384
4384
|
*/
|
|
4385
4385
|
declare function loadContentBySlug(options: LoadContentBySlugOptions): Promise<BlogPost | null>;
|
|
4386
|
+
interface LoadBlockBySlugOptions extends LoaderOptions {
|
|
4387
|
+
slug: string;
|
|
4388
|
+
}
|
|
4389
|
+
/**
|
|
4390
|
+
* Load published blocks for a site.
|
|
4391
|
+
*/
|
|
4392
|
+
declare function loadBlocks(options: LoadContentOptions): Promise<BlogPost[]>;
|
|
4393
|
+
/**
|
|
4394
|
+
* Load a single block by slug.
|
|
4395
|
+
*/
|
|
4396
|
+
declare function loadBlockBySlug(options: LoadBlockBySlugOptions): Promise<BlogPost | null>;
|
|
4386
4397
|
/**
|
|
4387
4398
|
* Load all published content (pages + posts).
|
|
4388
4399
|
*/
|
|
@@ -4434,4 +4445,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
4434
4445
|
error: string;
|
|
4435
4446
|
}>;
|
|
4436
4447
|
|
|
4437
|
-
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, 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 CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, 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, 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, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
|
4448
|
+
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, 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 CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, 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, 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, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadBlockBySlug, loadBlocks, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
package/dist/index.js
CHANGED
|
@@ -56,6 +56,8 @@ __export(index_exports, {
|
|
|
56
56
|
generateSizesAttribute: () => generateSizesAttribute,
|
|
57
57
|
generateSrcSet: () => generateSrcSet,
|
|
58
58
|
loadAllContent: () => loadAllContent,
|
|
59
|
+
loadBlockBySlug: () => loadBlockBySlug,
|
|
60
|
+
loadBlocks: () => loadBlocks,
|
|
59
61
|
loadContentBySlug: () => loadContentBySlug,
|
|
60
62
|
loadPages: () => loadPages,
|
|
61
63
|
loadPosts: () => loadPosts,
|
|
@@ -4639,6 +4641,56 @@ async function loadContentBySlug(options) {
|
|
|
4639
4641
|
return null;
|
|
4640
4642
|
}
|
|
4641
4643
|
}
|
|
4644
|
+
async function loadBlocks(options) {
|
|
4645
|
+
const { client, siteName, logger = noopLogger, params } = options;
|
|
4646
|
+
if (!client) {
|
|
4647
|
+
log(logger, "warn", "[PerspectAPI] No client configured, cannot load blocks");
|
|
4648
|
+
return [];
|
|
4649
|
+
}
|
|
4650
|
+
try {
|
|
4651
|
+
log(logger, "info", `[PerspectAPI] Loading blocks for site "${siteName}"`);
|
|
4652
|
+
const requestedLimit = options.limit !== void 0 ? options.limit : params?.limit;
|
|
4653
|
+
const resolvedLimit = validateLimit(
|
|
4654
|
+
requestedLimit ?? MAX_API_QUERY_LIMIT,
|
|
4655
|
+
"blocks query"
|
|
4656
|
+
);
|
|
4657
|
+
const response = await client.content.getContent(
|
|
4658
|
+
siteName,
|
|
4659
|
+
{
|
|
4660
|
+
...params,
|
|
4661
|
+
page_status: params?.page_status ?? "publish",
|
|
4662
|
+
page_type: "block",
|
|
4663
|
+
limit: resolvedLimit
|
|
4664
|
+
}
|
|
4665
|
+
);
|
|
4666
|
+
if (!response.data) {
|
|
4667
|
+
return [];
|
|
4668
|
+
}
|
|
4669
|
+
return response.data.map((content) => transformContent(content, logger));
|
|
4670
|
+
} catch (error) {
|
|
4671
|
+
log(logger, "error", "[PerspectAPI] Error loading blocks", error);
|
|
4672
|
+
return [];
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
async function loadBlockBySlug(options) {
|
|
4676
|
+
const { client, siteName, slug, logger = noopLogger } = options;
|
|
4677
|
+
if (!client) {
|
|
4678
|
+
log(logger, "warn", "[PerspectAPI] No client configured, cannot load block");
|
|
4679
|
+
return null;
|
|
4680
|
+
}
|
|
4681
|
+
try {
|
|
4682
|
+
log(logger, "info", `[PerspectAPI] Loading block slug "${slug}" for site "${siteName}"`);
|
|
4683
|
+
const response = await client.content.getContentBySlug(siteName, slug);
|
|
4684
|
+
if (!response.data) {
|
|
4685
|
+
log(logger, "warn", `[PerspectAPI] Block not found for slug "${slug}"`);
|
|
4686
|
+
return null;
|
|
4687
|
+
}
|
|
4688
|
+
return transformContent(response.data, logger);
|
|
4689
|
+
} catch (error) {
|
|
4690
|
+
log(logger, "error", `[PerspectAPI] Error loading block slug "${slug}"`, error);
|
|
4691
|
+
return null;
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4642
4694
|
async function loadAllContent(options) {
|
|
4643
4695
|
const { logger = noopLogger } = options;
|
|
4644
4696
|
const [pages, posts] = await Promise.all([
|
|
@@ -4781,6 +4833,8 @@ async function createCheckoutSession(options) {
|
|
|
4781
4833
|
generateSizesAttribute,
|
|
4782
4834
|
generateSrcSet,
|
|
4783
4835
|
loadAllContent,
|
|
4836
|
+
loadBlockBySlug,
|
|
4837
|
+
loadBlocks,
|
|
4784
4838
|
loadContentBySlug,
|
|
4785
4839
|
loadPages,
|
|
4786
4840
|
loadPosts,
|
package/dist/index.mjs
CHANGED
|
@@ -4570,6 +4570,56 @@ async function loadContentBySlug(options) {
|
|
|
4570
4570
|
return null;
|
|
4571
4571
|
}
|
|
4572
4572
|
}
|
|
4573
|
+
async function loadBlocks(options) {
|
|
4574
|
+
const { client, siteName, logger = noopLogger, params } = options;
|
|
4575
|
+
if (!client) {
|
|
4576
|
+
log(logger, "warn", "[PerspectAPI] No client configured, cannot load blocks");
|
|
4577
|
+
return [];
|
|
4578
|
+
}
|
|
4579
|
+
try {
|
|
4580
|
+
log(logger, "info", `[PerspectAPI] Loading blocks for site "${siteName}"`);
|
|
4581
|
+
const requestedLimit = options.limit !== void 0 ? options.limit : params?.limit;
|
|
4582
|
+
const resolvedLimit = validateLimit(
|
|
4583
|
+
requestedLimit ?? MAX_API_QUERY_LIMIT,
|
|
4584
|
+
"blocks query"
|
|
4585
|
+
);
|
|
4586
|
+
const response = await client.content.getContent(
|
|
4587
|
+
siteName,
|
|
4588
|
+
{
|
|
4589
|
+
...params,
|
|
4590
|
+
page_status: params?.page_status ?? "publish",
|
|
4591
|
+
page_type: "block",
|
|
4592
|
+
limit: resolvedLimit
|
|
4593
|
+
}
|
|
4594
|
+
);
|
|
4595
|
+
if (!response.data) {
|
|
4596
|
+
return [];
|
|
4597
|
+
}
|
|
4598
|
+
return response.data.map((content) => transformContent(content, logger));
|
|
4599
|
+
} catch (error) {
|
|
4600
|
+
log(logger, "error", "[PerspectAPI] Error loading blocks", error);
|
|
4601
|
+
return [];
|
|
4602
|
+
}
|
|
4603
|
+
}
|
|
4604
|
+
async function loadBlockBySlug(options) {
|
|
4605
|
+
const { client, siteName, slug, logger = noopLogger } = options;
|
|
4606
|
+
if (!client) {
|
|
4607
|
+
log(logger, "warn", "[PerspectAPI] No client configured, cannot load block");
|
|
4608
|
+
return null;
|
|
4609
|
+
}
|
|
4610
|
+
try {
|
|
4611
|
+
log(logger, "info", `[PerspectAPI] Loading block slug "${slug}" for site "${siteName}"`);
|
|
4612
|
+
const response = await client.content.getContentBySlug(siteName, slug);
|
|
4613
|
+
if (!response.data) {
|
|
4614
|
+
log(logger, "warn", `[PerspectAPI] Block not found for slug "${slug}"`);
|
|
4615
|
+
return null;
|
|
4616
|
+
}
|
|
4617
|
+
return transformContent(response.data, logger);
|
|
4618
|
+
} catch (error) {
|
|
4619
|
+
log(logger, "error", `[PerspectAPI] Error loading block slug "${slug}"`, error);
|
|
4620
|
+
return null;
|
|
4621
|
+
}
|
|
4622
|
+
}
|
|
4573
4623
|
async function loadAllContent(options) {
|
|
4574
4624
|
const { logger = noopLogger } = options;
|
|
4575
4625
|
const [pages, posts] = await Promise.all([
|
|
@@ -4712,6 +4762,8 @@ export {
|
|
|
4712
4762
|
generateSizesAttribute,
|
|
4713
4763
|
generateSrcSet,
|
|
4714
4764
|
loadAllContent,
|
|
4765
|
+
loadBlockBySlug,
|
|
4766
|
+
loadBlocks,
|
|
4715
4767
|
loadContentBySlug,
|
|
4716
4768
|
loadPages,
|
|
4717
4769
|
loadPosts,
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -87,6 +87,8 @@ export {
|
|
|
87
87
|
loadProductBySlug,
|
|
88
88
|
loadPosts,
|
|
89
89
|
loadPages,
|
|
90
|
+
loadBlocks,
|
|
91
|
+
loadBlockBySlug,
|
|
90
92
|
loadContentBySlug,
|
|
91
93
|
loadAllContent,
|
|
92
94
|
createCheckoutSession,
|
|
@@ -100,6 +102,7 @@ export type {
|
|
|
100
102
|
LoadProductBySlugOptions,
|
|
101
103
|
LoadContentOptions,
|
|
102
104
|
LoadContentBySlugOptions,
|
|
105
|
+
LoadBlockBySlugOptions,
|
|
103
106
|
CheckoutSessionOptions,
|
|
104
107
|
LoaderLogger
|
|
105
108
|
} from './loaders';
|
package/src/loaders.ts
CHANGED
|
@@ -615,6 +615,83 @@ export async function loadContentBySlug(
|
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
+
export interface LoadBlockBySlugOptions extends LoaderOptions {
|
|
619
|
+
slug: string;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Load published blocks for a site.
|
|
624
|
+
*/
|
|
625
|
+
export async function loadBlocks(
|
|
626
|
+
options: LoadContentOptions
|
|
627
|
+
): Promise<BlogPost[]> {
|
|
628
|
+
const { client, siteName, logger = noopLogger, params } = options;
|
|
629
|
+
|
|
630
|
+
if (!client) {
|
|
631
|
+
log(logger, 'warn', '[PerspectAPI] No client configured, cannot load blocks');
|
|
632
|
+
return [];
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
try {
|
|
636
|
+
log(logger, 'info', `[PerspectAPI] Loading blocks for site "${siteName}"`);
|
|
637
|
+
const requestedLimit =
|
|
638
|
+
options.limit !== undefined ? options.limit : params?.limit;
|
|
639
|
+
const resolvedLimit = validateLimit(
|
|
640
|
+
requestedLimit ?? MAX_API_QUERY_LIMIT,
|
|
641
|
+
'blocks query',
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
const response: PaginatedResponse<Content> = await client.content.getContent(
|
|
645
|
+
siteName,
|
|
646
|
+
{
|
|
647
|
+
...params,
|
|
648
|
+
page_status: (params?.page_status ?? 'publish') as ContentStatus,
|
|
649
|
+
page_type: 'block' as ContentType,
|
|
650
|
+
limit: resolvedLimit
|
|
651
|
+
}
|
|
652
|
+
);
|
|
653
|
+
|
|
654
|
+
if (!response.data) {
|
|
655
|
+
return [];
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return response.data.map(content => transformContent(content, logger));
|
|
659
|
+
} catch (error) {
|
|
660
|
+
log(logger, 'error', '[PerspectAPI] Error loading blocks', error);
|
|
661
|
+
return [];
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Load a single block by slug.
|
|
667
|
+
*/
|
|
668
|
+
export async function loadBlockBySlug(
|
|
669
|
+
options: LoadBlockBySlugOptions
|
|
670
|
+
): Promise<BlogPost | null> {
|
|
671
|
+
const { client, siteName, slug, logger = noopLogger } = options;
|
|
672
|
+
|
|
673
|
+
if (!client) {
|
|
674
|
+
log(logger, 'warn', '[PerspectAPI] No client configured, cannot load block');
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
try {
|
|
679
|
+
log(logger, 'info', `[PerspectAPI] Loading block slug "${slug}" for site "${siteName}"`);
|
|
680
|
+
const response: ApiResponse<Content> =
|
|
681
|
+
await client.content.getContentBySlug(siteName, slug);
|
|
682
|
+
|
|
683
|
+
if (!response.data) {
|
|
684
|
+
log(logger, 'warn', `[PerspectAPI] Block not found for slug "${slug}"`);
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
return transformContent(response.data, logger);
|
|
689
|
+
} catch (error) {
|
|
690
|
+
log(logger, 'error', `[PerspectAPI] Error loading block slug "${slug}"`, error);
|
|
691
|
+
return null;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
618
695
|
/**
|
|
619
696
|
* Load all published content (pages + posts).
|
|
620
697
|
*/
|