perspectapi-ts-sdk
Interfaces
CheckoutSessionOptionsLoadBlockBySlugOptionsLoadContentBySlugOptionsLoadContentOptionsLoaderLoggerLoaderOptionsLoadProductBySlugOptionsLoadProductsOptions
Functions
createCheckoutSessionloadAllContentloadBlockBySlugloadBlocksloadContentBySlugloadPagesloadPostsloadProductBySlugloadProductstransformContenttransformProduct
Interface: CheckoutSessionOptions
Properties
billingAddress?
optionalbillingAddress?:CheckoutAddress
Billing address forwarded to the checkout API for tax estimation.
cancelUrl
cancelUrl:
string
client?
optionalclient?:PerspectApiClient|null
currency?
optionalcurrency?:string
Optional currency override; defaults to the currency defined on each Stripe price.
customerEmail?
optionalcustomerEmail?:string
fallbackProducts?
optionalfallbackProducts?:Product[]
items
items:
object[]
productId
productId:
string
quantity
quantity:
number
logger?
optionallogger?:LoaderLogger
metadata?
optionalmetadata?:CheckoutMetadata
mode?
optionalmode?:"live"|"test"
priceIdResolver?
optionalpriceIdResolver?: (product,mode) =>string|undefined
Optional resolver to convert a product record into a Stripe price ID.
Parameters
product
Product
mode
"live" | "test"
Returns
string | undefined
shippingAddress?
optionalshippingAddress?:CheckoutAddress
Shipping address forwarded to the checkout API for tax estimation.
shippingAmount?
optionalshippingAmount?:number
Optional shipping amount (in the smallest currency unit).
siteName
siteName:
string
successUrl
successUrl:
string
tax?
optionaltax?:CheckoutTaxRequest
Optional tax configuration that will be forwarded to the checkout API.
Interface: LoadBlockBySlugOptions
Extends
LoaderOptions
Properties
client?
optionalclient?:PerspectApiClient|null
Pre-configured PerspectAPI client. Pass null/undefined to force fallback behaviour.
Inherited from
LoaderOptions.client
fallbackPosts?
optionalfallbackPosts?:BlogPost[]
Inherited from
LoaderOptions.fallbackPosts
fallbackProducts?
optionalfallbackProducts?:Product[]
Optional fallback datasets.
Inherited from
LoaderOptions.fallbackProducts
limit?
optionallimit?:number
Limit for list fetching (defaults to 100).
Inherited from
LoaderOptions.limit
logger?
optionallogger?:LoaderLogger
Optional logger to capture debug/warn/error output.
Inherited from
LoaderOptions.logger
siteName
siteName:
string
Site name used for API calls and fallback data generation.
Inherited from
LoaderOptions.siteName
slug
slug:
string
Interface: LoadContentBySlugOptions
Extends
LoaderOptions
Properties
client?
optionalclient?:PerspectApiClient|null
Pre-configured PerspectAPI client. Pass null/undefined to force fallback behaviour.
Inherited from
LoaderOptions.client
fallbackPosts?
optionalfallbackPosts?:BlogPost[]
Inherited from
LoaderOptions.fallbackPosts
fallbackProducts?
optionalfallbackProducts?:Product[]
Optional fallback datasets.
Inherited from
LoaderOptions.fallbackProducts
limit?
optionallimit?:number
Limit for list fetching (defaults to 100).
Inherited from
LoaderOptions.limit
logger?
optionallogger?:LoaderLogger
Optional logger to capture debug/warn/error output.
Inherited from
LoaderOptions.logger
siteName
siteName:
string
Site name used for API calls and fallback data generation.
Inherited from
LoaderOptions.siteName
slug
slug:
string
Interface: LoadContentOptions
Extends
LoaderOptions
Properties
client?
optionalclient?:PerspectApiClient|null
Pre-configured PerspectAPI client. Pass null/undefined to force fallback behaviour.
Inherited from
LoaderOptions.client
fallbackPosts?
optionalfallbackPosts?:BlogPost[]
Inherited from
LoaderOptions.fallbackPosts
fallbackProducts?
optionalfallbackProducts?:Product[]
Optional fallback datasets.
Inherited from
LoaderOptions.fallbackProducts
limit?
optionallimit?:number
Limit for list fetching (defaults to 100).
Inherited from
LoaderOptions.limit
logger?
optionallogger?:LoaderLogger
Optional logger to capture debug/warn/error output.
Inherited from
LoaderOptions.logger
params?
optionalparams?:Partial<{limit:number;page_status:string;page_type:string;search:string; }>
Additional query parameters for content filtering.
siteName
siteName:
string
Site name used for API calls and fallback data generation.
Inherited from
LoaderOptions.siteName
Interface: LoaderLogger
Logger interface so consumers can supply custom logging behaviour (or noop).
Methods
debug()?
optionaldebug(...args):void
Parameters
args
...unknown[]
Returns
void
error()?
optionalerror(...args):void
Parameters
args
...unknown[]
Returns
void
info()?
optionalinfo(...args):void
Parameters
args
...unknown[]
Returns
void
warn()?
optionalwarn(...args):void
Parameters
args
...unknown[]
Returns
void
Interface: LoaderOptions
Extended by
LoadProductsOptionsLoadProductBySlugOptionsLoadContentOptionsLoadContentBySlugOptionsLoadBlockBySlugOptions
Properties
client?
optionalclient?:PerspectApiClient|null
Pre-configured PerspectAPI client. Pass null/undefined to force fallback behaviour.
fallbackPosts?
optionalfallbackPosts?:BlogPost[]
fallbackProducts?
optionalfallbackProducts?:Product[]
Optional fallback datasets.
limit?
optionallimit?:number
Limit for list fetching (defaults to 100).
logger?
optionallogger?:LoaderLogger
Optional logger to capture debug/warn/error output.
siteName
siteName:
string
Site name used for API calls and fallback data generation.
Interface: LoadProductBySlugOptions
Extends
LoaderOptions
Properties
client?
optionalclient?:PerspectApiClient|null
Pre-configured PerspectAPI client. Pass null/undefined to force fallback behaviour.
Inherited from
LoaderOptions.client
fallbackPosts?
optionalfallbackPosts?:BlogPost[]
Inherited from
LoaderOptions.fallbackPosts
fallbackProducts?
optionalfallbackProducts?:Product[]
Optional fallback datasets.
Inherited from
LoaderOptions.fallbackProducts
limit?
optionallimit?:number
Limit for list fetching (defaults to 100).
Inherited from
LoaderOptions.limit
logger?
optionallogger?:LoaderLogger
Optional logger to capture debug/warn/error output.
Inherited from
LoaderOptions.logger
siteName
siteName:
string
Site name used for API calls and fallback data generation.
Inherited from
LoaderOptions.siteName
slug
slug:
string
Interface: LoadProductsOptions
Extends
LoaderOptions
Properties
category?
optionalcategory?:string|string[]
Filter products by category name (case-insensitive). Accepts a single name or multiple names.
categoryIds?
optionalcategoryIds?: (string|number)[]
Filter products by category IDs (mixed string/number values supported).
client?
optionalclient?:PerspectApiClient|null
Pre-configured PerspectAPI client. Pass null/undefined to force fallback behaviour.
Inherited from
LoaderOptions.client
fallbackPosts?
optionalfallbackPosts?:BlogPost[]
Inherited from
LoaderOptions.fallbackPosts
fallbackProducts?
optionalfallbackProducts?:Product[]
Optional fallback datasets.
Inherited from
LoaderOptions.fallbackProducts
limit?
optionallimit?:number
Limit for list fetching (defaults to 100).
Inherited from
LoaderOptions.limit
logger?
optionallogger?:LoaderLogger
Optional logger to capture debug/warn/error output.
Inherited from
LoaderOptions.logger
offset?
optionaloffset?:number
Offset for manual pagination.
search?
optionalsearch?:string
Optional search term applied server-side.
siteName
siteName:
string
Site name used for API calls and fallback data generation.
Inherited from
LoaderOptions.siteName
Function: createCheckoutSession()
createCheckoutSession(
options):Promise<ApiResponse<CheckoutSession> | {error:string; }>
Convenience helper that creates a checkout session by looking up Stripe price IDs from product metadata. Falls back to gateway price IDs if Stripe IDs are missing.
Parameters
options
CheckoutSessionOptions
Returns
Promise<ApiResponse<CheckoutSession> | { error: string; }>
Function: loadAllContent()
loadAllContent(
options):Promise<BlogPost[]>
Load all published content (pages + posts).
Parameters
options
LoaderOptions
Returns
Promise<BlogPost[]>
Function: loadBlockBySlug()
loadBlockBySlug(
options):Promise<BlogPost|null>
Load a single block by slug.
Parameters
options
LoadBlockBySlugOptions
Returns
Promise<BlogPost | null>
Function: loadBlocks()
loadBlocks(
options):Promise<BlogPost[]>
Load published blocks for a site.
Parameters
options
LoadContentOptions
Returns
Promise<BlogPost[]>
Function: loadContentBySlug()
loadContentBySlug(
options):Promise<BlogPost|null>
Load a single content item (post or page) by slug.
Parameters
options
LoadContentBySlugOptions
Returns
Promise<BlogPost | null>
Function: loadPages()
loadPages(
options):Promise<BlogPost[]>
Load published pages for a site.
Parameters
options
LoadContentOptions
Returns
Promise<BlogPost[]>
Function: loadPosts()
loadPosts(
options):Promise<BlogPost[]>
Load published blog posts for a site.
Parameters
options
LoadContentOptions
Returns
Promise<BlogPost[]>
Function: loadProductBySlug()
loadProductBySlug(
options):Promise<Product|null>
Load single product by slug.
Parameters
options
LoadProductBySlugOptions
Returns
Promise<Product | null>
Function: loadProducts()
loadProducts(
options):Promise<Product[]>
Load products for a site with graceful fallbacks.
Parameters
options
LoadProductsOptions
Returns
Promise<Product[]>
Function: transformContent()
transformContent(
perspectContent,logger?):BlogPost
Transform PerspectAPI content payload to a simplified BlogPost structure.
Parameters
perspectContent
Content | Content & Record<string, unknown>
logger?
LoaderLogger
Returns
BlogPost
Function: transformProduct()
transformProduct(
perspectProduct,logger?):Product
Transform a PerspectAPI product payload into a friendlier shape for UI layers.
Parameters
perspectProduct
any
logger?
LoaderLogger
Returns
Product