perspectapi-ts-sdk 5.4.5 → 6.0.1
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 +357 -2
- package/dist/index.d.ts +357 -2
- package/dist/index.js +314 -12
- package/dist/index.mjs +314 -12
- package/package.json +1 -1
- package/src/cache/cache-manager.ts +2 -8
- package/src/index.ts +1 -0
- package/src/v2/client/base-v2-client.ts +6 -0
- package/src/v2/client/content-client.ts +125 -4
- package/src/v2/client/credits-client.ts +57 -0
- package/src/v2/client/newsletter-client.ts +85 -1
- package/src/v2/client/orders-client.ts +40 -1
- package/src/v2/client/site-users-client.ts +76 -3
- package/src/v2/client/subscriptions-client.ts +126 -0
- package/src/v2/index.ts +8 -0
- package/src/v2/types.ts +276 -0
package/dist/index.d.ts
CHANGED
|
@@ -3284,6 +3284,87 @@ interface V2OrderListParams extends V2PaginationParams {
|
|
|
3284
3284
|
date_from?: string;
|
|
3285
3285
|
date_to?: string;
|
|
3286
3286
|
}
|
|
3287
|
+
interface V2OrderLineItemPriceData {
|
|
3288
|
+
currency: string;
|
|
3289
|
+
product_data: {
|
|
3290
|
+
name: string;
|
|
3291
|
+
description?: string;
|
|
3292
|
+
images?: string[];
|
|
3293
|
+
};
|
|
3294
|
+
unit_amount: number;
|
|
3295
|
+
}
|
|
3296
|
+
interface V2OrderLineItem {
|
|
3297
|
+
sku_id?: number;
|
|
3298
|
+
product_id?: number;
|
|
3299
|
+
price_data?: V2OrderLineItemPriceData;
|
|
3300
|
+
price?: string;
|
|
3301
|
+
quantity: number;
|
|
3302
|
+
}
|
|
3303
|
+
interface V2OrderAddress {
|
|
3304
|
+
line1?: string;
|
|
3305
|
+
line2?: string;
|
|
3306
|
+
city?: string;
|
|
3307
|
+
state?: string;
|
|
3308
|
+
postal_code?: string;
|
|
3309
|
+
country?: string;
|
|
3310
|
+
}
|
|
3311
|
+
interface V2OrderTaxRequest {
|
|
3312
|
+
strategy?: string;
|
|
3313
|
+
customer_identifier?: string;
|
|
3314
|
+
customer_profile_id?: string;
|
|
3315
|
+
customer_display_name?: string;
|
|
3316
|
+
allow_exemption?: boolean;
|
|
3317
|
+
save_profile?: boolean;
|
|
3318
|
+
customer_exemption?: {
|
|
3319
|
+
status?: "none" | "exempt" | "reverse_charge";
|
|
3320
|
+
reason?: string;
|
|
3321
|
+
tax_id?: string;
|
|
3322
|
+
tax_id_type?: string;
|
|
3323
|
+
certificate_url?: string;
|
|
3324
|
+
metadata?: Record<string, unknown>;
|
|
3325
|
+
expires_at?: string;
|
|
3326
|
+
};
|
|
3327
|
+
}
|
|
3328
|
+
interface V2OrderCreateParams {
|
|
3329
|
+
line_items: V2OrderLineItem[];
|
|
3330
|
+
success_url: string;
|
|
3331
|
+
cancel_url: string;
|
|
3332
|
+
customer_email?: string;
|
|
3333
|
+
site_user_id?: string;
|
|
3334
|
+
mode?: "payment" | "subscription";
|
|
3335
|
+
metadata?: Record<string, string | number | boolean>;
|
|
3336
|
+
tax?: V2OrderTaxRequest;
|
|
3337
|
+
shipping_amount?: number;
|
|
3338
|
+
shipping_address?: V2OrderAddress;
|
|
3339
|
+
billing_address?: V2OrderAddress;
|
|
3340
|
+
currency?: string;
|
|
3341
|
+
referral_code?: string;
|
|
3342
|
+
referrer_site_user_id?: string;
|
|
3343
|
+
}
|
|
3344
|
+
interface V2OrderFulfillmentUpdate {
|
|
3345
|
+
fulfillment_status: string;
|
|
3346
|
+
tracking_number?: string;
|
|
3347
|
+
notes?: string;
|
|
3348
|
+
}
|
|
3349
|
+
interface V2OrderCreateResult extends V2Object {
|
|
3350
|
+
object: "checkout_session";
|
|
3351
|
+
checkout_url: string | null;
|
|
3352
|
+
payment_status: string | null;
|
|
3353
|
+
tax: {
|
|
3354
|
+
amount: number;
|
|
3355
|
+
currency: string;
|
|
3356
|
+
strategy: string;
|
|
3357
|
+
exemption_applied: boolean;
|
|
3358
|
+
exemption_status: string;
|
|
3359
|
+
breakdown: Array<{
|
|
3360
|
+
jurisdiction?: string;
|
|
3361
|
+
rate_percent: number;
|
|
3362
|
+
tax_amount: number;
|
|
3363
|
+
taxable_amount: number;
|
|
3364
|
+
source: string;
|
|
3365
|
+
}>;
|
|
3366
|
+
};
|
|
3367
|
+
}
|
|
3287
3368
|
interface V2SiteUser extends V2Object {
|
|
3288
3369
|
object: "site_user";
|
|
3289
3370
|
email: string;
|
|
@@ -3305,10 +3386,37 @@ interface V2SiteUserUpdateParams {
|
|
|
3305
3386
|
status?: "active" | "suspended" | "pending_verification";
|
|
3306
3387
|
metadata?: Record<string, unknown>;
|
|
3307
3388
|
}
|
|
3389
|
+
/**
|
|
3390
|
+
* Patch shape for the authenticated `/me` endpoint. Unlike the admin update,
|
|
3391
|
+
* end users cannot change their own `status`.
|
|
3392
|
+
*/
|
|
3393
|
+
interface V2SiteUserMeUpdateParams {
|
|
3394
|
+
first_name?: string;
|
|
3395
|
+
last_name?: string;
|
|
3396
|
+
avatar_url?: string;
|
|
3397
|
+
metadata?: Record<string, unknown>;
|
|
3398
|
+
}
|
|
3308
3399
|
interface V2SiteUserListParams extends V2PaginationParams {
|
|
3309
3400
|
status?: "active" | "suspended" | "pending_verification";
|
|
3310
3401
|
email?: string;
|
|
3311
3402
|
}
|
|
3403
|
+
/**
|
|
3404
|
+
* Response shape of `GET /sites/{siteName}/users/me`. Extends V2SiteUser with
|
|
3405
|
+
* a `profile` side-channel populated from the `site_user_profiles` KV table.
|
|
3406
|
+
*/
|
|
3407
|
+
interface V2SiteUserWithProfile extends V2SiteUser {
|
|
3408
|
+
profile: Record<string, unknown>;
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* Standalone profile envelope returned by
|
|
3412
|
+
* `GET|PUT /sites/{siteName}/users/me/profile[/:key]`. Each `data` entry is a
|
|
3413
|
+
* parsed value (arbitrary JSON).
|
|
3414
|
+
*/
|
|
3415
|
+
interface V2SiteUserProfile {
|
|
3416
|
+
object: "site_user_profile";
|
|
3417
|
+
site_user_id: string;
|
|
3418
|
+
data: Record<string, unknown>;
|
|
3419
|
+
}
|
|
3312
3420
|
interface V2NewsletterSubscription extends V2Object {
|
|
3313
3421
|
object: "newsletter_subscription";
|
|
3314
3422
|
email: string;
|
|
@@ -3355,6 +3463,75 @@ interface V2NewsletterCampaign extends V2Object {
|
|
|
3355
3463
|
interface V2NewsletterTrackingResponse {
|
|
3356
3464
|
success: boolean;
|
|
3357
3465
|
}
|
|
3466
|
+
interface V2NewsletterListCreateParams {
|
|
3467
|
+
list_name: string;
|
|
3468
|
+
slug: string;
|
|
3469
|
+
description?: string | null;
|
|
3470
|
+
is_public?: boolean;
|
|
3471
|
+
is_default?: boolean;
|
|
3472
|
+
welcome_email_enabled?: boolean;
|
|
3473
|
+
}
|
|
3474
|
+
interface V2NewsletterListUpdateParams {
|
|
3475
|
+
list_name?: string;
|
|
3476
|
+
slug?: string;
|
|
3477
|
+
description?: string | null;
|
|
3478
|
+
is_public?: boolean;
|
|
3479
|
+
is_default?: boolean;
|
|
3480
|
+
welcome_email_enabled?: boolean;
|
|
3481
|
+
status?: "active" | "archived";
|
|
3482
|
+
}
|
|
3483
|
+
interface V2NewsletterSyncInput {
|
|
3484
|
+
email: string;
|
|
3485
|
+
name?: string | null;
|
|
3486
|
+
status?: "pending" | "confirmed" | "unsubscribed" | "bounced" | "complained";
|
|
3487
|
+
list_ids?: string[];
|
|
3488
|
+
frequency?: "instant" | "daily" | "weekly" | "monthly";
|
|
3489
|
+
topics?: string[];
|
|
3490
|
+
language?: string | null;
|
|
3491
|
+
source?: string | null;
|
|
3492
|
+
source_url?: string | null;
|
|
3493
|
+
notes?: string | null;
|
|
3494
|
+
tags?: string[];
|
|
3495
|
+
metadata?: Record<string, unknown>;
|
|
3496
|
+
resubscribe_override?: boolean;
|
|
3497
|
+
}
|
|
3498
|
+
interface V2NewsletterSyncResult {
|
|
3499
|
+
object: "newsletter_sync_result";
|
|
3500
|
+
applied: boolean;
|
|
3501
|
+
code: "CREATED" | "UPDATED" | "RESUBSCRIBED" | "ALREADY_UNSUBSCRIBED";
|
|
3502
|
+
skipped_unsubscribed: boolean;
|
|
3503
|
+
resubscribed: boolean;
|
|
3504
|
+
created: boolean;
|
|
3505
|
+
updated: boolean;
|
|
3506
|
+
subscription: Record<string, unknown>;
|
|
3507
|
+
}
|
|
3508
|
+
interface V2NewsletterSubscriptionListMembershipUpdate {
|
|
3509
|
+
mode: "add" | "remove" | "replace";
|
|
3510
|
+
list_ids: string[];
|
|
3511
|
+
}
|
|
3512
|
+
interface V2NewsletterImportRequest {
|
|
3513
|
+
rows: V2NewsletterSyncInput[];
|
|
3514
|
+
resubscribe_override?: boolean;
|
|
3515
|
+
}
|
|
3516
|
+
interface V2NewsletterImportResult {
|
|
3517
|
+
object: "newsletter_import_result";
|
|
3518
|
+
total: number;
|
|
3519
|
+
processed: number;
|
|
3520
|
+
applied: number;
|
|
3521
|
+
created: number;
|
|
3522
|
+
updated: number;
|
|
3523
|
+
resubscribed: number;
|
|
3524
|
+
skipped_unsubscribed: number;
|
|
3525
|
+
rows: Array<{
|
|
3526
|
+
index: number;
|
|
3527
|
+
email: string;
|
|
3528
|
+
applied: boolean;
|
|
3529
|
+
code: V2NewsletterSyncResult["code"];
|
|
3530
|
+
skipped_unsubscribed: boolean;
|
|
3531
|
+
resubscribed: boolean;
|
|
3532
|
+
subscription_id: string;
|
|
3533
|
+
}>;
|
|
3534
|
+
}
|
|
3358
3535
|
interface V2ContactSubmission extends V2Object {
|
|
3359
3536
|
object: "contact_submission";
|
|
3360
3537
|
name: string | null;
|
|
@@ -3422,6 +3599,71 @@ interface V2WebhookCreateParams {
|
|
|
3422
3599
|
}
|
|
3423
3600
|
interface V2WebhookUpdateParams extends Partial<V2WebhookCreateParams> {
|
|
3424
3601
|
}
|
|
3602
|
+
interface V2SiteUserSubscription extends V2Object {
|
|
3603
|
+
object: "site_user_subscription";
|
|
3604
|
+
site_user_id: string;
|
|
3605
|
+
provider: string | null;
|
|
3606
|
+
provider_subscription_id: string | null;
|
|
3607
|
+
plan_name: string | null;
|
|
3608
|
+
plan_id: string | null;
|
|
3609
|
+
status: string;
|
|
3610
|
+
amount: number | null;
|
|
3611
|
+
currency: string | null;
|
|
3612
|
+
billing_interval: string | null;
|
|
3613
|
+
billing_interval_count: number | null;
|
|
3614
|
+
current_period_start: string | null;
|
|
3615
|
+
current_period_end: string | null;
|
|
3616
|
+
trial_start: string | null;
|
|
3617
|
+
trial_end: string | null;
|
|
3618
|
+
canceled_at: string | null;
|
|
3619
|
+
cancel_at_period_end: boolean;
|
|
3620
|
+
metadata: Record<string, unknown> | null;
|
|
3621
|
+
created_at: string | null;
|
|
3622
|
+
updated_at: string | null;
|
|
3623
|
+
}
|
|
3624
|
+
interface V2SubscriptionPauseParams {
|
|
3625
|
+
resumes_at?: number;
|
|
3626
|
+
}
|
|
3627
|
+
interface V2SubscriptionCancelParams {
|
|
3628
|
+
mode?: "immediate" | "period_end" | "scheduled";
|
|
3629
|
+
cancel_at?: string;
|
|
3630
|
+
}
|
|
3631
|
+
interface V2SubscriptionChangePlanParams {
|
|
3632
|
+
product_id: string;
|
|
3633
|
+
}
|
|
3634
|
+
interface V2CancelSubscriptionResult {
|
|
3635
|
+
object: "subscription_cancel_result";
|
|
3636
|
+
mode: string;
|
|
3637
|
+
status: string;
|
|
3638
|
+
cancel_at_period_end: boolean;
|
|
3639
|
+
effective_at: string | null;
|
|
3640
|
+
scheduled_cancel_at: string | null;
|
|
3641
|
+
message: string;
|
|
3642
|
+
}
|
|
3643
|
+
interface V2CreditTransaction extends V2Object {
|
|
3644
|
+
object: "credit_transaction";
|
|
3645
|
+
site_user_id: string;
|
|
3646
|
+
amount_cents: number;
|
|
3647
|
+
balance_after_cents: number;
|
|
3648
|
+
type: string;
|
|
3649
|
+
description: string | null;
|
|
3650
|
+
reference_id: string | null;
|
|
3651
|
+
reference_type: string | null;
|
|
3652
|
+
created_at: string | null;
|
|
3653
|
+
}
|
|
3654
|
+
interface V2CreditBalance {
|
|
3655
|
+
object: "credit_balance";
|
|
3656
|
+
balance_cents: number;
|
|
3657
|
+
transactions?: V2CreditTransaction[];
|
|
3658
|
+
}
|
|
3659
|
+
interface V2GrantCreditParams {
|
|
3660
|
+
amount_cents: number;
|
|
3661
|
+
description: string;
|
|
3662
|
+
}
|
|
3663
|
+
interface V2GrantCreditResult {
|
|
3664
|
+
object: "grant_credit_result";
|
|
3665
|
+
new_balance_cents: number;
|
|
3666
|
+
}
|
|
3425
3667
|
|
|
3426
3668
|
/**
|
|
3427
3669
|
* v2 Base Client — cursor pagination, expand support, caching, typed errors.
|
|
@@ -3462,6 +3704,8 @@ declare abstract class BaseV2Client {
|
|
|
3462
3704
|
protected post<T>(path: string, body?: unknown): Promise<T>;
|
|
3463
3705
|
/** PATCH to update a resource. */
|
|
3464
3706
|
protected patchOne<T>(path: string, body?: unknown): Promise<T>;
|
|
3707
|
+
/** PUT to upsert a resource. */
|
|
3708
|
+
protected putOne<T>(path: string, body?: unknown): Promise<T>;
|
|
3465
3709
|
/** DELETE a resource. */
|
|
3466
3710
|
protected deleteOne(path: string): Promise<V2Deleted>;
|
|
3467
3711
|
/** Fetch with optional cache. Bypasses cache for writes or when no cache is configured. */
|
|
@@ -3488,13 +3732,18 @@ declare abstract class BaseV2Client {
|
|
|
3488
3732
|
|
|
3489
3733
|
declare class ContentV2Client extends BaseV2Client {
|
|
3490
3734
|
list(siteName: string, params?: V2ContentListParams, cachePolicy?: CachePolicy): Promise<V2List<V2Content>>;
|
|
3491
|
-
listAutoPaginated(siteName: string, params?: Omit<V2ContentListParams, 'starting_after' | 'ending_before'
|
|
3735
|
+
listAutoPaginated(siteName: string, params?: Omit<V2ContentListParams, 'starting_after' | 'ending_before'>, cachePolicy?: CachePolicy): AsyncGenerator<V2Content, void, unknown>;
|
|
3492
3736
|
get(siteName: string, idOrSlug: string, cachePolicy?: CachePolicy): Promise<V2Content>;
|
|
3493
3737
|
create(siteName: string, data: V2ContentCreateParams): Promise<V2Content>;
|
|
3494
3738
|
update(siteName: string, id: string, data: V2ContentUpdateParams): Promise<V2Content>;
|
|
3495
3739
|
del(siteName: string, id: string): Promise<V2Deleted>;
|
|
3496
3740
|
publish(siteName: string, id: string): Promise<V2Content>;
|
|
3497
3741
|
unpublish(siteName: string, id: string): Promise<V2Content>;
|
|
3742
|
+
private withContentTags;
|
|
3743
|
+
private buildContentTags;
|
|
3744
|
+
private normalizeTagPart;
|
|
3745
|
+
private extractSlugPrefix;
|
|
3746
|
+
private isContentId;
|
|
3498
3747
|
}
|
|
3499
3748
|
|
|
3500
3749
|
/**
|
|
@@ -3546,16 +3795,35 @@ declare class CollectionsV2Client extends BaseV2Client {
|
|
|
3546
3795
|
|
|
3547
3796
|
/**
|
|
3548
3797
|
* v2 Orders Client (checkout sessions)
|
|
3798
|
+
*
|
|
3799
|
+
* `create()` initiates a Stripe checkout session and returns the checkout URL.
|
|
3800
|
+
* No CSRF token is needed — v2 uses API-key auth only.
|
|
3549
3801
|
*/
|
|
3550
3802
|
|
|
3551
3803
|
declare class OrdersV2Client extends BaseV2Client {
|
|
3552
3804
|
list(siteName: string, params?: V2OrderListParams, cachePolicy?: CachePolicy): Promise<V2List<V2Order>>;
|
|
3553
3805
|
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Order, void, unknown>;
|
|
3554
3806
|
get(siteName: string, id: string, cachePolicy?: CachePolicy): Promise<V2Order>;
|
|
3807
|
+
/**
|
|
3808
|
+
* Create a checkout session via Stripe. Returns the session ID and a
|
|
3809
|
+
* `checkout_url` that the client should redirect to (or open in a new tab).
|
|
3810
|
+
*
|
|
3811
|
+
* This replaces the v1 `checkout.createCheckoutSession()` + `getCsrfToken()`
|
|
3812
|
+
* dance — v2 is API-key-only and requires no CSRF token.
|
|
3813
|
+
*/
|
|
3814
|
+
create(siteName: string, data: V2OrderCreateParams): Promise<V2OrderCreateResult>;
|
|
3815
|
+
/** Update fulfillment status, tracking number, and/or notes on an order. */
|
|
3816
|
+
updateFulfillment(siteName: string, id: string, data: V2OrderFulfillmentUpdate): Promise<V2Order>;
|
|
3555
3817
|
}
|
|
3556
3818
|
|
|
3557
3819
|
/**
|
|
3558
3820
|
* v2 Site Users Client
|
|
3821
|
+
*
|
|
3822
|
+
* Two classes of endpoints:
|
|
3823
|
+
* - Admin paths (list/get/update/OTP flows) require an API key. Use the
|
|
3824
|
+
* usual `setApiKey(...)` on the main `PerspectApiV2Client` before calling.
|
|
3825
|
+
* - `/me*` paths require a site-user JWT (minted by `verifyOtp`). Call
|
|
3826
|
+
* `setAuth(jwt)` on the main client before calling these.
|
|
3559
3827
|
*/
|
|
3560
3828
|
|
|
3561
3829
|
interface V2OtpRequestResponse {
|
|
@@ -3580,6 +3848,23 @@ declare class SiteUsersV2Client extends BaseV2Client {
|
|
|
3580
3848
|
listAutoPaginated(siteName: string, params?: Omit<V2SiteUserListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2SiteUser, void, unknown>;
|
|
3581
3849
|
get(siteName: string, id: string): Promise<V2SiteUser>;
|
|
3582
3850
|
update(siteName: string, id: string, data: V2SiteUserUpdateParams): Promise<V2SiteUser>;
|
|
3851
|
+
/**
|
|
3852
|
+
* Load the currently-authenticated site user's canonical record plus their
|
|
3853
|
+
* profile KV map. Requires `client.setAuth(jwt)` to have been called with
|
|
3854
|
+
* the token returned from `verifyOtp`.
|
|
3855
|
+
*/
|
|
3856
|
+
getMe(siteName: string): Promise<V2SiteUserWithProfile>;
|
|
3857
|
+
/** Update the authenticated user's own fields. */
|
|
3858
|
+
updateMe(siteName: string, data: V2SiteUserMeUpdateParams): Promise<V2SiteUser>;
|
|
3859
|
+
/** Fetch the profile KV map as a dedicated `site_user_profile` envelope. */
|
|
3860
|
+
getProfile(siteName: string): Promise<V2SiteUserProfile>;
|
|
3861
|
+
/**
|
|
3862
|
+
* Set a single profile key. The value is persisted verbatim — callers wanting
|
|
3863
|
+
* structured data should JSON-stringify their value first.
|
|
3864
|
+
*/
|
|
3865
|
+
setProfileValue(siteName: string, key: string, value: string): Promise<V2SiteUserProfile>;
|
|
3866
|
+
/** Delete a single profile key. */
|
|
3867
|
+
deleteProfileValue(siteName: string, key: string): Promise<V2Deleted>;
|
|
3583
3868
|
}
|
|
3584
3869
|
|
|
3585
3870
|
/**
|
|
@@ -3615,6 +3900,26 @@ declare class NewsletterV2Client extends BaseV2Client {
|
|
|
3615
3900
|
status?: string;
|
|
3616
3901
|
}, cachePolicy?: CachePolicy): Promise<V2List<V2NewsletterCampaign>>;
|
|
3617
3902
|
getCampaign(siteName: string, idOrSlug: string, cachePolicy?: CachePolicy): Promise<V2NewsletterCampaign>;
|
|
3903
|
+
createList(siteName: string, data: V2NewsletterListCreateParams): Promise<V2NewsletterList>;
|
|
3904
|
+
updateList(siteName: string, id: string, data: V2NewsletterListUpdateParams): Promise<V2NewsletterList>;
|
|
3905
|
+
deleteList(siteName: string, id: string): Promise<V2Deleted>;
|
|
3906
|
+
/**
|
|
3907
|
+
* Upsert a subscription by email and (optionally) replace its list
|
|
3908
|
+
* memberships. Returns a `newsletter_sync_result` envelope with the
|
|
3909
|
+
* outcome (created / updated / resubscribed / already-unsubscribed).
|
|
3910
|
+
*/
|
|
3911
|
+
syncSubscription(siteName: string, data: V2NewsletterSyncInput): Promise<V2NewsletterSyncResult>;
|
|
3912
|
+
/**
|
|
3913
|
+
* Add/remove/replace the list memberships for an existing subscription.
|
|
3914
|
+
* Returns the refreshed subscription record.
|
|
3915
|
+
*/
|
|
3916
|
+
updateSubscriptionListMembership(siteName: string, subscriptionId: string, data: V2NewsletterSubscriptionListMembershipUpdate): Promise<V2NewsletterSubscription>;
|
|
3917
|
+
/**
|
|
3918
|
+
* Bulk import subscriptions. Each row is upserted via the same sync
|
|
3919
|
+
* path; `refreshListCounts` is deferred until after all rows are
|
|
3920
|
+
* processed on the server.
|
|
3921
|
+
*/
|
|
3922
|
+
importSubscriptions(siteName: string, data: V2NewsletterImportRequest): Promise<V2NewsletterImportResult>;
|
|
3618
3923
|
}
|
|
3619
3924
|
|
|
3620
3925
|
/**
|
|
@@ -3679,6 +3984,54 @@ declare class WebhooksV2Client extends BaseV2Client {
|
|
|
3679
3984
|
del(siteName: string, id: string): Promise<V2Deleted>;
|
|
3680
3985
|
}
|
|
3681
3986
|
|
|
3987
|
+
/**
|
|
3988
|
+
* v2 Subscriptions Client — lifecycle operations for site user subscriptions.
|
|
3989
|
+
*
|
|
3990
|
+
* Two classes of endpoints:
|
|
3991
|
+
* - /me paths require a site-user JWT (call `setAuth(jwt)` first)
|
|
3992
|
+
* - Admin paths require an API key (call `setApiKey(key)` first)
|
|
3993
|
+
*/
|
|
3994
|
+
|
|
3995
|
+
declare class SubscriptionsV2Client extends BaseV2Client {
|
|
3996
|
+
/** List all subscriptions for the authenticated user. */
|
|
3997
|
+
listMySubscriptions(siteName: string): Promise<V2List<V2SiteUserSubscription>>;
|
|
3998
|
+
/** Pause a subscription. */
|
|
3999
|
+
pauseSubscription(siteName: string, subId: string, params?: V2SubscriptionPauseParams): Promise<V2SiteUserSubscription>;
|
|
4000
|
+
/** Resume a paused subscription. */
|
|
4001
|
+
resumeSubscription(siteName: string, subId: string): Promise<V2SiteUserSubscription>;
|
|
4002
|
+
/** Cancel a subscription. */
|
|
4003
|
+
cancelSubscription(siteName: string, subId: string, params?: V2SubscriptionCancelParams): Promise<V2CancelSubscriptionResult>;
|
|
4004
|
+
/** Change the plan (price) of a subscription. */
|
|
4005
|
+
changeSubscriptionPlan(siteName: string, subId: string, params: V2SubscriptionChangePlanParams): Promise<V2SiteUserSubscription>;
|
|
4006
|
+
/** List subscriptions for a specific user (admin). */
|
|
4007
|
+
listUserSubscriptions(siteName: string, userId: string): Promise<V2List<V2SiteUserSubscription>>;
|
|
4008
|
+
/** Pause a user's subscription (admin). */
|
|
4009
|
+
pauseUserSubscription(siteName: string, userId: string, subId: string, params?: V2SubscriptionPauseParams): Promise<V2SiteUserSubscription>;
|
|
4010
|
+
/** Resume a user's paused subscription (admin). */
|
|
4011
|
+
resumeUserSubscription(siteName: string, userId: string, subId: string): Promise<V2SiteUserSubscription>;
|
|
4012
|
+
/** Cancel a user's subscription (admin). */
|
|
4013
|
+
cancelUserSubscription(siteName: string, userId: string, subId: string, params?: V2SubscriptionCancelParams): Promise<V2CancelSubscriptionResult>;
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
/**
|
|
4017
|
+
* v2 Credits Client — balance queries and admin grant operations.
|
|
4018
|
+
*
|
|
4019
|
+
* Two classes of endpoints:
|
|
4020
|
+
* - /me paths require a site-user JWT (call `setAuth(jwt)` first)
|
|
4021
|
+
* - Admin paths require an API key (call `setApiKey(key)` first)
|
|
4022
|
+
*/
|
|
4023
|
+
|
|
4024
|
+
declare class CreditsV2Client extends BaseV2Client {
|
|
4025
|
+
/** Get the current credit balance for the authenticated user. */
|
|
4026
|
+
getMyBalance(siteName: string): Promise<V2CreditBalance>;
|
|
4027
|
+
/** Get credit balance and transaction history for the authenticated user. */
|
|
4028
|
+
getMyCredits(siteName: string): Promise<V2CreditBalance>;
|
|
4029
|
+
/** Get the credit balance for a specific user (admin). */
|
|
4030
|
+
getUserBalance(siteName: string, userId: string): Promise<V2CreditBalance>;
|
|
4031
|
+
/** Grant credit to a specific user (admin). */
|
|
4032
|
+
grantCredit(siteName: string, userId: string, data: V2GrantCreditParams): Promise<V2GrantCreditResult>;
|
|
4033
|
+
}
|
|
4034
|
+
|
|
3682
4035
|
/**
|
|
3683
4036
|
* PerspectAPI v2 SDK Client
|
|
3684
4037
|
*
|
|
@@ -3709,6 +4062,8 @@ declare class PerspectApiV2Client {
|
|
|
3709
4062
|
readonly sites: SitesV2Client;
|
|
3710
4063
|
readonly apiKeys: ApiKeysV2Client;
|
|
3711
4064
|
readonly webhooks: WebhooksV2Client;
|
|
4065
|
+
readonly subscriptions: SubscriptionsV2Client;
|
|
4066
|
+
readonly credits: CreditsV2Client;
|
|
3712
4067
|
constructor(config: PerspectApiV2Config);
|
|
3713
4068
|
/** Update the JWT token for authenticated requests. */
|
|
3714
4069
|
setAuth(jwt: string): void;
|
|
@@ -4075,4 +4430,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
4075
4430
|
error: string;
|
|
4076
4431
|
}>;
|
|
4077
4432
|
|
|
4078
|
-
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, InMemoryCacheAdapter, 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, 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 };
|
|
4433
|
+
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, InMemoryCacheAdapter, 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, 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 };
|