perspectapi-ts-sdk 4.1.0 → 5.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 CHANGED
@@ -916,7 +916,7 @@ interface SiteUserSubscription {
916
916
  provider_subscription_id?: string;
917
917
  plan_name?: string;
918
918
  plan_id?: string;
919
- status: 'active' | 'past_due' | 'canceled' | 'paused' | 'trialing' | 'expired';
919
+ status: 'active' | 'past_due' | 'canceled' | 'paused' | 'trialing' | 'expired' | 'incomplete';
920
920
  amount?: number;
921
921
  currency?: string;
922
922
  billing_interval?: string;
@@ -938,10 +938,30 @@ interface SiteUserOrder {
938
938
  currency: string;
939
939
  status: string;
940
940
  payment_status?: string;
941
+ fulfillment_status?: string;
941
942
  line_items: any[];
942
943
  created_at: string;
943
944
  completed_at?: string;
944
945
  }
946
+ type SubscriptionCancellationMode = 'immediate' | 'period_end' | 'scheduled';
947
+ interface CancelSubscriptionRequest {
948
+ mode?: SubscriptionCancellationMode;
949
+ cancel_at?: string;
950
+ delay_days?: number;
951
+ delay_hours?: number;
952
+ delay_minutes?: number;
953
+ }
954
+ interface CancelSubscriptionResponse {
955
+ success: boolean;
956
+ message: string;
957
+ cancellation?: {
958
+ mode: SubscriptionCancellationMode;
959
+ status: string;
960
+ cancel_at_period_end: boolean;
961
+ effective_at: string | null;
962
+ scheduled_cancel_at: string | null;
963
+ };
964
+ }
945
965
  interface CreditTransaction {
946
966
  id: number;
947
967
  amount_cents: number;
@@ -2721,15 +2741,13 @@ declare class SiteUsersClient extends BaseClient {
2721
2741
  subscription: SiteUserSubscription;
2722
2742
  }>>;
2723
2743
  /**
2724
- * Cancel a subscription (marks for cancellation at period end)
2744
+ * Cancel a subscription.
2725
2745
  * @param siteName - The site name
2726
2746
  * @param id - Subscription ID
2727
2747
  * @param csrfToken - CSRF token (required)
2748
+ * @param options - Cancellation mode/details
2728
2749
  */
2729
- cancelSubscription(siteName: string, id: string, csrfToken?: string): Promise<ApiResponse<{
2730
- success: boolean;
2731
- message: string;
2732
- }>>;
2750
+ cancelSubscription(siteName: string, id: string, csrfToken?: string, options?: CancelSubscriptionRequest): Promise<ApiResponse<CancelSubscriptionResponse>>;
2733
2751
  /**
2734
2752
  * Pause a subscription via Stripe pause_collection
2735
2753
  * @param siteName - The site name
@@ -2902,11 +2920,9 @@ declare class SiteUsersClient extends BaseClient {
2902
2920
  * @param siteName - The site name
2903
2921
  * @param userId - User ID
2904
2922
  * @param subscriptionId - Subscription ID
2923
+ * @param options - Cancellation mode/details
2905
2924
  */
2906
- cancelUserSubscription(siteName: string, userId: string, subscriptionId: string): Promise<ApiResponse<{
2907
- success: boolean;
2908
- message: string;
2909
- }>>;
2925
+ cancelUserSubscription(siteName: string, userId: string, subscriptionId: string, options?: CancelSubscriptionRequest): Promise<ApiResponse<CancelSubscriptionResponse>>;
2910
2926
  /**
2911
2927
  * Get a user's credit balance (admin only)
2912
2928
  * @param siteName - The site name
@@ -3056,6 +3072,628 @@ declare class PerspectApiClient {
3056
3072
  */
3057
3073
  declare function createPerspectApiClient(config: PerspectApiConfig): PerspectApiClient;
3058
3074
 
3075
+ /**
3076
+ * v2 SDK Types — matches the API wire format exactly (snake_case).
3077
+ *
3078
+ * These types reflect the actual JSON returned by /api/v2/ endpoints.
3079
+ * No transformation layer is needed in the SDK.
3080
+ */
3081
+ interface V2Object {
3082
+ object: string;
3083
+ id: string;
3084
+ }
3085
+ interface V2List<T> {
3086
+ object: "list";
3087
+ data: T[];
3088
+ has_more: boolean;
3089
+ url: string;
3090
+ }
3091
+ interface V2Deleted {
3092
+ object: string;
3093
+ id: string;
3094
+ deleted: true;
3095
+ }
3096
+ interface V2Error {
3097
+ error: {
3098
+ type: V2ErrorType;
3099
+ code: string;
3100
+ message: string;
3101
+ param?: string;
3102
+ };
3103
+ }
3104
+ type V2ErrorType = "invalid_request_error" | "authentication_error" | "permission_error" | "not_found_error" | "rate_limit_error" | "api_error";
3105
+ interface V2PaginationParams {
3106
+ limit?: number;
3107
+ starting_after?: string;
3108
+ ending_before?: string;
3109
+ }
3110
+ interface V2Content extends V2Object {
3111
+ object: "content";
3112
+ title: string;
3113
+ content: string;
3114
+ markdown: string | null;
3115
+ slug: string;
3116
+ slug_prefix: string | null;
3117
+ type: "post" | "page" | "block";
3118
+ status: "draft" | "publish" | "private" | "trash" | "scheduled";
3119
+ author: string | null;
3120
+ custom: Record<string, unknown> | null;
3121
+ featured_image?: string | null;
3122
+ scheduled_at: string | null;
3123
+ published_at: string;
3124
+ updated_at: string;
3125
+ }
3126
+ interface V2ContentCreateParams {
3127
+ title: string;
3128
+ content: string;
3129
+ markdown?: string;
3130
+ custom?: Record<string, unknown>;
3131
+ slug?: string;
3132
+ slug_prefix?: string;
3133
+ published_at?: string;
3134
+ scheduled_at?: string | null;
3135
+ status?: "draft" | "publish" | "private" | "trash" | "scheduled";
3136
+ type?: "post" | "page" | "block";
3137
+ }
3138
+ interface V2ContentUpdateParams extends Partial<V2ContentCreateParams> {
3139
+ }
3140
+ interface V2ContentListParams extends V2PaginationParams {
3141
+ status?: "draft" | "publish" | "private" | "trash" | "scheduled";
3142
+ type?: "post" | "page" | "block";
3143
+ search?: string;
3144
+ slug_prefix?: string;
3145
+ }
3146
+ interface V2Product extends V2Object {
3147
+ object: "product";
3148
+ name: string;
3149
+ description: string | null;
3150
+ excerpt: string | null;
3151
+ meta_description: string | null;
3152
+ price: number;
3153
+ unit_amount: number;
3154
+ currency: string;
3155
+ sku: string | null;
3156
+ slug: string | null;
3157
+ slug_prefix: string | null;
3158
+ published: boolean;
3159
+ stock_quantity: number | null;
3160
+ custom: Record<string, unknown> | null;
3161
+ recurring: {
3162
+ interval: string;
3163
+ interval_count?: number;
3164
+ } | null;
3165
+ tax_behavior: "inclusive" | "exclusive" | "unspecified" | null;
3166
+ category_id: string | null;
3167
+ created_at: string | null;
3168
+ updated_at: string | null;
3169
+ }
3170
+ interface V2ProductCreateParams {
3171
+ name: string;
3172
+ description?: string;
3173
+ excerpt?: string;
3174
+ meta_description?: string;
3175
+ category_id?: string;
3176
+ price: number;
3177
+ unit_amount: number;
3178
+ currency?: string;
3179
+ sku?: string;
3180
+ custom?: Record<string, unknown>;
3181
+ slug?: string;
3182
+ slug_prefix?: string;
3183
+ published?: boolean;
3184
+ stock_quantity?: number | null;
3185
+ recurring?: {
3186
+ interval: "day" | "week" | "month" | "year";
3187
+ interval_count?: number;
3188
+ };
3189
+ tax_behavior?: "inclusive" | "exclusive" | "unspecified";
3190
+ attachment_ids?: number[];
3191
+ }
3192
+ interface V2ProductUpdateParams extends Partial<V2ProductCreateParams> {
3193
+ }
3194
+ interface V2ProductListParams extends V2PaginationParams {
3195
+ published?: boolean;
3196
+ category_id?: string;
3197
+ search?: string;
3198
+ slug_prefix?: string;
3199
+ }
3200
+ interface V2Category extends V2Object {
3201
+ object: "category";
3202
+ name: string;
3203
+ description: string | null;
3204
+ slug: string | null;
3205
+ slug_prefix: string | null;
3206
+ parent_id: string | null;
3207
+ type: "post" | "product" | null;
3208
+ created_at: string | null;
3209
+ updated_at: string | null;
3210
+ }
3211
+ interface V2CategoryCreateParams {
3212
+ name: string;
3213
+ description?: string;
3214
+ slug?: string;
3215
+ slug_prefix?: string;
3216
+ parent_id?: string;
3217
+ type?: "post" | "product";
3218
+ }
3219
+ interface V2CategoryUpdateParams extends Partial<V2CategoryCreateParams> {
3220
+ }
3221
+ interface V2Collection extends V2Object {
3222
+ object: "collection";
3223
+ name: string;
3224
+ description: string | null;
3225
+ available_from: string | null;
3226
+ available_until: string | null;
3227
+ published: boolean;
3228
+ created_at: string | null;
3229
+ updated_at: string | null;
3230
+ }
3231
+ interface V2CollectionItem extends V2Object {
3232
+ object: "collection_item";
3233
+ collection_id: string;
3234
+ product_id: string;
3235
+ max_quantity: number | null;
3236
+ position: number;
3237
+ }
3238
+ interface V2CollectionCreateParams {
3239
+ name: string;
3240
+ description?: string | null;
3241
+ available_from?: string | null;
3242
+ available_until?: string | null;
3243
+ published?: boolean;
3244
+ }
3245
+ interface V2CollectionUpdateParams extends Partial<V2CollectionCreateParams> {
3246
+ }
3247
+ interface V2Order extends V2Object {
3248
+ object: "checkout_session";
3249
+ customer_email: string;
3250
+ customer_name: string | null;
3251
+ customer_phone: string | null;
3252
+ customer_details: Record<string, unknown> | null;
3253
+ shipping_details: Record<string, unknown> | null;
3254
+ order_id: string | null;
3255
+ line_items: unknown[] | null;
3256
+ amount_total: number;
3257
+ currency: string;
3258
+ tax_summary: Record<string, unknown> | null;
3259
+ status: string;
3260
+ payment_status: string | null;
3261
+ fulfillment_status: string | null;
3262
+ tracking_number: string | null;
3263
+ notes: string | null;
3264
+ live_mode: boolean;
3265
+ metadata: Record<string, unknown> | null;
3266
+ created_at: string;
3267
+ completed_at: string | null;
3268
+ expires_at: string | null;
3269
+ }
3270
+ interface V2OrderListParams extends V2PaginationParams {
3271
+ status?: string;
3272
+ customer_email?: string;
3273
+ date_from?: string;
3274
+ date_to?: string;
3275
+ }
3276
+ interface V2SiteUser extends V2Object {
3277
+ object: "site_user";
3278
+ email: string;
3279
+ email_verified: boolean;
3280
+ first_name: string | null;
3281
+ last_name: string | null;
3282
+ avatar_url: string | null;
3283
+ status: string;
3284
+ waitlist: boolean;
3285
+ metadata: Record<string, unknown> | null;
3286
+ created_at: string | null;
3287
+ updated_at: string | null;
3288
+ last_login_at: string | null;
3289
+ }
3290
+ interface V2SiteUserUpdateParams {
3291
+ first_name?: string;
3292
+ last_name?: string;
3293
+ avatar_url?: string;
3294
+ status?: "active" | "suspended" | "pending_verification";
3295
+ metadata?: Record<string, unknown>;
3296
+ }
3297
+ interface V2SiteUserListParams extends V2PaginationParams {
3298
+ status?: "active" | "suspended" | "pending_verification";
3299
+ email?: string;
3300
+ }
3301
+ interface V2NewsletterSubscription extends V2Object {
3302
+ object: "newsletter_subscription";
3303
+ email: string;
3304
+ name: string | null;
3305
+ status: string;
3306
+ double_opt_in: boolean;
3307
+ confirmed_at: string | null;
3308
+ source: string | null;
3309
+ frequency: string | null;
3310
+ topics: string[] | null;
3311
+ language: string | null;
3312
+ tags: string[] | null;
3313
+ custom_fields: Record<string, unknown> | null;
3314
+ unsubscribed_at: string | null;
3315
+ created_at: string | null;
3316
+ updated_at: string | null;
3317
+ }
3318
+ interface V2NewsletterList extends V2Object {
3319
+ object: "newsletter_list";
3320
+ name: string;
3321
+ slug: string;
3322
+ description: string | null;
3323
+ is_default: boolean;
3324
+ subscriber_count: number;
3325
+ created_at: string | null;
3326
+ updated_at: string | null;
3327
+ }
3328
+ interface V2NewsletterCampaign extends V2Object {
3329
+ object: "newsletter_campaign";
3330
+ name: string;
3331
+ slug: string | null;
3332
+ subject: string;
3333
+ preview_text: string | null;
3334
+ status: string;
3335
+ sent_at: string | null;
3336
+ completed_at: string | null;
3337
+ total_recipients: number;
3338
+ sent_count: number;
3339
+ opened_count: number;
3340
+ clicked_count: number;
3341
+ created_at: string | null;
3342
+ updated_at: string | null;
3343
+ }
3344
+ interface V2ContactSubmission extends V2Object {
3345
+ object: "contact_submission";
3346
+ name: string | null;
3347
+ first_name: string | null;
3348
+ last_name: string | null;
3349
+ email: string;
3350
+ subject: string | null;
3351
+ message: string;
3352
+ phone: string | null;
3353
+ company: string | null;
3354
+ status: string;
3355
+ metadata: Record<string, unknown> | null;
3356
+ created_at: string | null;
3357
+ processed_at: string | null;
3358
+ }
3359
+ interface V2Organization extends V2Object {
3360
+ object: "organization";
3361
+ name: string;
3362
+ slug: string | null;
3363
+ endpoint_status: string | null;
3364
+ endpoint_url: string | null;
3365
+ created_at: string | null;
3366
+ updated_at: string | null;
3367
+ }
3368
+ interface V2Site extends V2Object {
3369
+ object: "site";
3370
+ name: string;
3371
+ title: string | null;
3372
+ description: string | null;
3373
+ domain: string | null;
3374
+ custom_domain: string | null;
3375
+ organization_id: string | null;
3376
+ tax_enabled: boolean;
3377
+ lifecycle_status: string | null;
3378
+ created_at: string | null;
3379
+ updated_at: string | null;
3380
+ }
3381
+ interface V2ApiKey extends V2Object {
3382
+ object: "api_key";
3383
+ name: string;
3384
+ description: string | null;
3385
+ organization_id: string | null;
3386
+ site_name: string | null;
3387
+ permissions: string[] | null;
3388
+ is_active: boolean;
3389
+ expires_at: string | null;
3390
+ last_used_at: string | null;
3391
+ created_at: string | null;
3392
+ updated_at: string | null;
3393
+ }
3394
+ interface V2Webhook extends V2Object {
3395
+ object: "webhook";
3396
+ url: string;
3397
+ description: string | null;
3398
+ events: string[] | null;
3399
+ is_active: boolean;
3400
+ created_at: string | null;
3401
+ updated_at: string | null;
3402
+ }
3403
+ interface V2WebhookCreateParams {
3404
+ url: string;
3405
+ description?: string;
3406
+ events?: string[];
3407
+ is_active?: boolean;
3408
+ }
3409
+ interface V2WebhookUpdateParams extends Partial<V2WebhookCreateParams> {
3410
+ }
3411
+
3412
+ /**
3413
+ * v2 Base Client — cursor pagination, expand support, typed errors.
3414
+ */
3415
+
3416
+ declare class PerspectV2Error extends Error {
3417
+ readonly type: string;
3418
+ readonly code: string;
3419
+ readonly param?: string;
3420
+ readonly status: number;
3421
+ constructor(error: V2Error['error'], status: number);
3422
+ }
3423
+ declare abstract class BaseV2Client {
3424
+ protected http: HttpClient;
3425
+ protected basePath: string;
3426
+ constructor(http: HttpClient, basePath: string);
3427
+ protected buildPath(endpoint: string): string;
3428
+ protected sitePath(siteName: string, resource: string, suffix?: string): string;
3429
+ private toParams;
3430
+ /**
3431
+ * Extract v2 payload from HttpClient response.
3432
+ *
3433
+ * The shared HttpClient wraps responses in a v1-style { success, data } envelope.
3434
+ * v2 API responses don't have a `success` field — the HttpClient already throws
3435
+ * on HTTP errors, so if we reach this point the request succeeded.
3436
+ *
3437
+ * The HttpClient may return the v2 payload nested under `data` (when the response
3438
+ * JSON contains a `data` key, which v2 list responses do) or as a direct wrap.
3439
+ * We unwrap accordingly.
3440
+ */
3441
+ private extractData;
3442
+ /** GET a single resource. */
3443
+ protected getOne<T>(path: string, params?: object): Promise<T>;
3444
+ /** GET a list of resources with cursor pagination. */
3445
+ protected getList<T>(path: string, params?: object): Promise<V2List<T>>;
3446
+ /** POST to create a resource. */
3447
+ protected post<T>(path: string, body?: unknown): Promise<T>;
3448
+ /** PATCH to update a resource. */
3449
+ protected patchOne<T>(path: string, body?: unknown): Promise<T>;
3450
+ /** DELETE a resource. */
3451
+ protected deleteOne(path: string): Promise<V2Deleted>;
3452
+ /**
3453
+ * Auto-paginating async generator.
3454
+ * Yields every item across all pages.
3455
+ *
3456
+ * Usage:
3457
+ * for await (const item of client.listAutoPaginate(path, params)) { ... }
3458
+ */
3459
+ protected listAutoPaginate<T extends {
3460
+ id: string;
3461
+ }>(path: string, params?: object): AsyncGenerator<T, void, unknown>;
3462
+ private toError;
3463
+ }
3464
+
3465
+ /**
3466
+ * v2 Content Client
3467
+ */
3468
+
3469
+ declare class ContentV2Client extends BaseV2Client {
3470
+ list(siteName: string, params?: V2ContentListParams): Promise<V2List<V2Content>>;
3471
+ listAutoPaginated(siteName: string, params?: Omit<V2ContentListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Content, void, unknown>;
3472
+ get(siteName: string, idOrSlug: string): Promise<V2Content>;
3473
+ create(siteName: string, data: V2ContentCreateParams): Promise<V2Content>;
3474
+ update(siteName: string, id: string, data: V2ContentUpdateParams): Promise<V2Content>;
3475
+ del(siteName: string, id: string): Promise<V2Deleted>;
3476
+ publish(siteName: string, id: string): Promise<V2Content>;
3477
+ unpublish(siteName: string, id: string): Promise<V2Content>;
3478
+ }
3479
+
3480
+ /**
3481
+ * v2 Products Client
3482
+ */
3483
+
3484
+ declare class ProductsV2Client extends BaseV2Client {
3485
+ list(siteName: string, params?: V2ProductListParams): Promise<V2List<V2Product>>;
3486
+ listAutoPaginated(siteName: string, params?: Omit<V2ProductListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Product, void, unknown>;
3487
+ get(siteName: string, idOrSlug: string): Promise<V2Product>;
3488
+ create(siteName: string, data: V2ProductCreateParams): Promise<V2Product>;
3489
+ update(siteName: string, id: string, data: V2ProductUpdateParams): Promise<V2Product>;
3490
+ del(siteName: string, id: string): Promise<V2Deleted>;
3491
+ }
3492
+
3493
+ /**
3494
+ * v2 Categories Client
3495
+ */
3496
+
3497
+ declare class CategoriesV2Client extends BaseV2Client {
3498
+ list(siteName: string, params?: V2PaginationParams & {
3499
+ type?: string;
3500
+ }): Promise<V2List<V2Category>>;
3501
+ get(siteName: string, id: string): Promise<V2Category>;
3502
+ create(siteName: string, data: V2CategoryCreateParams): Promise<V2Category>;
3503
+ update(siteName: string, id: string, data: V2CategoryUpdateParams): Promise<V2Category>;
3504
+ del(siteName: string, id: string): Promise<V2Deleted>;
3505
+ }
3506
+
3507
+ /**
3508
+ * v2 Collections Client
3509
+ */
3510
+
3511
+ declare class CollectionsV2Client extends BaseV2Client {
3512
+ list(siteName: string, params?: V2PaginationParams): Promise<V2List<V2Collection>>;
3513
+ getCurrent(siteName: string): Promise<V2Collection | null>;
3514
+ get(siteName: string, id: string): Promise<V2Collection>;
3515
+ create(siteName: string, data: V2CollectionCreateParams): Promise<V2Collection>;
3516
+ update(siteName: string, id: string, data: V2CollectionUpdateParams): Promise<V2Collection>;
3517
+ del(siteName: string, id: string): Promise<V2Deleted>;
3518
+ listItems(siteName: string, collectionId: string): Promise<V2List<V2CollectionItem>>;
3519
+ addItem(siteName: string, collectionId: string, data: {
3520
+ product_id: string;
3521
+ max_quantity?: number | null;
3522
+ position?: number;
3523
+ }): Promise<V2CollectionItem>;
3524
+ removeItem(siteName: string, collectionId: string, itemId: string): Promise<V2Deleted>;
3525
+ }
3526
+
3527
+ /**
3528
+ * v2 Orders Client (checkout sessions)
3529
+ */
3530
+
3531
+ declare class OrdersV2Client extends BaseV2Client {
3532
+ list(siteName: string, params?: V2OrderListParams): Promise<V2List<V2Order>>;
3533
+ listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Order, void, unknown>;
3534
+ get(siteName: string, id: string): Promise<V2Order>;
3535
+ }
3536
+
3537
+ /**
3538
+ * v2 Site Users Client
3539
+ */
3540
+
3541
+ interface V2OtpRequestResponse {
3542
+ object: 'otp_request';
3543
+ email: string;
3544
+ expires_in: number;
3545
+ }
3546
+ interface V2OtpVerifyResponse extends V2SiteUser {
3547
+ token: string;
3548
+ }
3549
+ declare class SiteUsersV2Client extends BaseV2Client {
3550
+ requestOtp(siteName: string, data: {
3551
+ email: string;
3552
+ waitlist?: boolean;
3553
+ metadata?: Record<string, unknown>;
3554
+ }): Promise<V2OtpRequestResponse>;
3555
+ verifyOtp(siteName: string, data: {
3556
+ email: string;
3557
+ code: string;
3558
+ }): Promise<V2OtpVerifyResponse>;
3559
+ list(siteName: string, params?: V2SiteUserListParams): Promise<V2List<V2SiteUser>>;
3560
+ listAutoPaginated(siteName: string, params?: Omit<V2SiteUserListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2SiteUser, void, unknown>;
3561
+ get(siteName: string, id: string): Promise<V2SiteUser>;
3562
+ update(siteName: string, id: string, data: V2SiteUserUpdateParams): Promise<V2SiteUser>;
3563
+ }
3564
+
3565
+ /**
3566
+ * v2 Newsletter Client
3567
+ */
3568
+
3569
+ declare class NewsletterV2Client extends BaseV2Client {
3570
+ subscribe(siteName: string, data: {
3571
+ email: string;
3572
+ name?: string;
3573
+ list_ids?: string[];
3574
+ double_opt_in?: boolean;
3575
+ source?: string;
3576
+ source_url?: string;
3577
+ frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
3578
+ topics?: string[];
3579
+ language?: string;
3580
+ metadata?: Record<string, unknown>;
3581
+ }): Promise<V2NewsletterSubscription>;
3582
+ confirm(siteName: string, token: string): Promise<V2NewsletterSubscription>;
3583
+ unsubscribe(siteName: string, data: {
3584
+ token?: string;
3585
+ email?: string;
3586
+ reason?: string;
3587
+ }): Promise<V2NewsletterSubscription>;
3588
+ listSubscriptions(siteName: string, params?: V2PaginationParams & {
3589
+ status?: string;
3590
+ }): Promise<V2List<V2NewsletterSubscription>>;
3591
+ getSubscription(siteName: string, id: string): Promise<V2NewsletterSubscription>;
3592
+ listLists(siteName: string): Promise<V2List<V2NewsletterList>>;
3593
+ listCampaigns(siteName: string, params?: V2PaginationParams & {
3594
+ status?: string;
3595
+ }): Promise<V2List<V2NewsletterCampaign>>;
3596
+ getCampaign(siteName: string, idOrSlug: string): Promise<V2NewsletterCampaign>;
3597
+ }
3598
+
3599
+ /**
3600
+ * v2 Contacts Client
3601
+ */
3602
+
3603
+ declare class ContactsV2Client extends BaseV2Client {
3604
+ submit(siteName: string, data: {
3605
+ email: string;
3606
+ message: string;
3607
+ name?: string;
3608
+ first_name?: string;
3609
+ last_name?: string;
3610
+ subject?: string;
3611
+ phone?: string;
3612
+ company?: string;
3613
+ metadata?: Record<string, unknown>;
3614
+ }): Promise<V2ContactSubmission>;
3615
+ list(siteName: string, params?: V2PaginationParams & {
3616
+ status?: string;
3617
+ }): Promise<V2List<V2ContactSubmission>>;
3618
+ get(siteName: string, id: string): Promise<V2ContactSubmission>;
3619
+ }
3620
+
3621
+ /**
3622
+ * v2 Organizations Client
3623
+ */
3624
+
3625
+ declare class OrganizationsV2Client extends BaseV2Client {
3626
+ list(): Promise<V2List<V2Organization>>;
3627
+ get(id: string): Promise<V2Organization>;
3628
+ }
3629
+
3630
+ /**
3631
+ * v2 Sites Client
3632
+ */
3633
+
3634
+ declare class SitesV2Client extends BaseV2Client {
3635
+ list(params?: V2PaginationParams): Promise<V2List<V2Site>>;
3636
+ get(name: string): Promise<V2Site>;
3637
+ }
3638
+
3639
+ /**
3640
+ * v2 API Keys Client
3641
+ */
3642
+
3643
+ declare class ApiKeysV2Client extends BaseV2Client {
3644
+ list(params?: V2PaginationParams): Promise<V2List<V2ApiKey>>;
3645
+ get(id: string): Promise<V2ApiKey>;
3646
+ del(id: string): Promise<V2Deleted>;
3647
+ }
3648
+
3649
+ /**
3650
+ * v2 Webhooks Client
3651
+ */
3652
+
3653
+ declare class WebhooksV2Client extends BaseV2Client {
3654
+ list(siteName: string, params?: V2PaginationParams): Promise<V2List<V2Webhook>>;
3655
+ get(siteName: string, id: string): Promise<V2Webhook>;
3656
+ create(siteName: string, data: V2WebhookCreateParams): Promise<V2Webhook>;
3657
+ update(siteName: string, id: string, data: V2WebhookUpdateParams): Promise<V2Webhook>;
3658
+ del(siteName: string, id: string): Promise<V2Deleted>;
3659
+ }
3660
+
3661
+ /**
3662
+ * PerspectAPI v2 SDK Client
3663
+ *
3664
+ * Stripe-style API with consistent envelopes, prefixed IDs,
3665
+ * cursor pagination, and snake_case responses.
3666
+ *
3667
+ * Usage:
3668
+ * import { PerspectApiV2Client } from 'perspectapi-ts-sdk/v2';
3669
+ * const client = new PerspectApiV2Client({ baseUrl: '...', apiKey: '...' });
3670
+ * const posts = await client.content.list('mysite', { type: 'post', limit: 10 });
3671
+ */
3672
+
3673
+ declare class PerspectApiV2Client {
3674
+ private http;
3675
+ readonly content: ContentV2Client;
3676
+ readonly products: ProductsV2Client;
3677
+ readonly categories: CategoriesV2Client;
3678
+ readonly collections: CollectionsV2Client;
3679
+ readonly orders: OrdersV2Client;
3680
+ readonly siteUsers: SiteUsersV2Client;
3681
+ readonly newsletter: NewsletterV2Client;
3682
+ readonly contacts: ContactsV2Client;
3683
+ readonly organizations: OrganizationsV2Client;
3684
+ readonly sites: SitesV2Client;
3685
+ readonly apiKeys: ApiKeysV2Client;
3686
+ readonly webhooks: WebhooksV2Client;
3687
+ constructor(config: PerspectApiConfig);
3688
+ /** Update the JWT token for authenticated requests. */
3689
+ setAuth(jwt: string): void;
3690
+ /** Update the API key. */
3691
+ setApiKey(apiKey: string): void;
3692
+ /** Clear authentication. */
3693
+ clearAuth(): void;
3694
+ }
3695
+ declare function createPerspectApiV2Client(config: PerspectApiConfig): PerspectApiV2Client;
3696
+
3059
3697
  /**
3060
3698
  * Simple in-memory cache adapter primarily suited for development and testing.
3061
3699
  */
@@ -3374,4 +4012,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
3374
4012
  error: string;
3375
4013
  }>;
3376
4014
 
3377
- export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, 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, type Product, type ProductBundleGroup, type ProductQueryParams, type ProductSku, type ProductSkuMediaItem, type ProductSkuOption, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
4015
+ 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, 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 };