perspectapi-ts-sdk 4.1.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -1
- package/dist/index.d.mts +637 -11
- package/dist/index.d.ts +637 -11
- package/dist/index.js +447 -5
- package/dist/index.mjs +444 -5
- package/package.json +1 -1
- package/src/client/site-users-client.ts +15 -9
- package/src/index.ts +5 -1
- package/src/types/index.ts +24 -1
- package/src/v2/client/api-keys-client.ts +21 -0
- package/src/v2/client/base-v2-client.ts +146 -0
- package/src/v2/client/categories-client.ts +32 -0
- package/src/v2/client/collections-client.ts +64 -0
- package/src/v2/client/contacts-client.ts +37 -0
- package/src/v2/client/content-client.ts +44 -0
- package/src/v2/client/newsletter-client.ts +95 -0
- package/src/v2/client/orders-client.ts +21 -0
- package/src/v2/client/organizations-client.ts +17 -0
- package/src/v2/client/products-client.ts +36 -0
- package/src/v2/client/site-users-client.ts +53 -0
- package/src/v2/client/sites-client.ts +17 -0
- package/src/v2/client/webhooks-client.ts +32 -0
- package/src/v2/index.ts +105 -0
- package/src/v2/types.ts +395 -0
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
|
|
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,616 @@ 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
|
+
/** GET a single resource. */
|
|
3431
|
+
protected getOne<T>(path: string, params?: object): Promise<T>;
|
|
3432
|
+
/** GET a list of resources with cursor pagination. */
|
|
3433
|
+
protected getList<T>(path: string, params?: object): Promise<V2List<T>>;
|
|
3434
|
+
/** POST to create a resource. */
|
|
3435
|
+
protected post<T>(path: string, body?: unknown): Promise<T>;
|
|
3436
|
+
/** PATCH to update a resource. */
|
|
3437
|
+
protected patchOne<T>(path: string, body?: unknown): Promise<T>;
|
|
3438
|
+
/** DELETE a resource. */
|
|
3439
|
+
protected deleteOne(path: string): Promise<V2Deleted>;
|
|
3440
|
+
/**
|
|
3441
|
+
* Auto-paginating async generator.
|
|
3442
|
+
* Yields every item across all pages.
|
|
3443
|
+
*
|
|
3444
|
+
* Usage:
|
|
3445
|
+
* for await (const item of client.listAutoPaginate(path, params)) { ... }
|
|
3446
|
+
*/
|
|
3447
|
+
protected listAutoPaginate<T extends {
|
|
3448
|
+
id: string;
|
|
3449
|
+
}>(path: string, params?: object): AsyncGenerator<T, void, unknown>;
|
|
3450
|
+
private toError;
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3453
|
+
/**
|
|
3454
|
+
* v2 Content Client
|
|
3455
|
+
*/
|
|
3456
|
+
|
|
3457
|
+
declare class ContentV2Client extends BaseV2Client {
|
|
3458
|
+
list(siteName: string, params?: V2ContentListParams): Promise<V2List<V2Content>>;
|
|
3459
|
+
listAutoPaginated(siteName: string, params?: Omit<V2ContentListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Content, void, unknown>;
|
|
3460
|
+
get(siteName: string, idOrSlug: string): Promise<V2Content>;
|
|
3461
|
+
create(siteName: string, data: V2ContentCreateParams): Promise<V2Content>;
|
|
3462
|
+
update(siteName: string, id: string, data: V2ContentUpdateParams): Promise<V2Content>;
|
|
3463
|
+
del(siteName: string, id: string): Promise<V2Deleted>;
|
|
3464
|
+
publish(siteName: string, id: string): Promise<V2Content>;
|
|
3465
|
+
unpublish(siteName: string, id: string): Promise<V2Content>;
|
|
3466
|
+
}
|
|
3467
|
+
|
|
3468
|
+
/**
|
|
3469
|
+
* v2 Products Client
|
|
3470
|
+
*/
|
|
3471
|
+
|
|
3472
|
+
declare class ProductsV2Client extends BaseV2Client {
|
|
3473
|
+
list(siteName: string, params?: V2ProductListParams): Promise<V2List<V2Product>>;
|
|
3474
|
+
listAutoPaginated(siteName: string, params?: Omit<V2ProductListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Product, void, unknown>;
|
|
3475
|
+
get(siteName: string, idOrSlug: string): Promise<V2Product>;
|
|
3476
|
+
create(siteName: string, data: V2ProductCreateParams): Promise<V2Product>;
|
|
3477
|
+
update(siteName: string, id: string, data: V2ProductUpdateParams): Promise<V2Product>;
|
|
3478
|
+
del(siteName: string, id: string): Promise<V2Deleted>;
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
/**
|
|
3482
|
+
* v2 Categories Client
|
|
3483
|
+
*/
|
|
3484
|
+
|
|
3485
|
+
declare class CategoriesV2Client extends BaseV2Client {
|
|
3486
|
+
list(siteName: string, params?: V2PaginationParams & {
|
|
3487
|
+
type?: string;
|
|
3488
|
+
}): Promise<V2List<V2Category>>;
|
|
3489
|
+
get(siteName: string, id: string): Promise<V2Category>;
|
|
3490
|
+
create(siteName: string, data: V2CategoryCreateParams): Promise<V2Category>;
|
|
3491
|
+
update(siteName: string, id: string, data: V2CategoryUpdateParams): Promise<V2Category>;
|
|
3492
|
+
del(siteName: string, id: string): Promise<V2Deleted>;
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
/**
|
|
3496
|
+
* v2 Collections Client
|
|
3497
|
+
*/
|
|
3498
|
+
|
|
3499
|
+
declare class CollectionsV2Client extends BaseV2Client {
|
|
3500
|
+
list(siteName: string, params?: V2PaginationParams): Promise<V2List<V2Collection>>;
|
|
3501
|
+
getCurrent(siteName: string): Promise<V2Collection | null>;
|
|
3502
|
+
get(siteName: string, id: string): Promise<V2Collection>;
|
|
3503
|
+
create(siteName: string, data: V2CollectionCreateParams): Promise<V2Collection>;
|
|
3504
|
+
update(siteName: string, id: string, data: V2CollectionUpdateParams): Promise<V2Collection>;
|
|
3505
|
+
del(siteName: string, id: string): Promise<V2Deleted>;
|
|
3506
|
+
listItems(siteName: string, collectionId: string): Promise<V2List<V2CollectionItem>>;
|
|
3507
|
+
addItem(siteName: string, collectionId: string, data: {
|
|
3508
|
+
product_id: string;
|
|
3509
|
+
max_quantity?: number | null;
|
|
3510
|
+
position?: number;
|
|
3511
|
+
}): Promise<V2CollectionItem>;
|
|
3512
|
+
removeItem(siteName: string, collectionId: string, itemId: string): Promise<V2Deleted>;
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
/**
|
|
3516
|
+
* v2 Orders Client (checkout sessions)
|
|
3517
|
+
*/
|
|
3518
|
+
|
|
3519
|
+
declare class OrdersV2Client extends BaseV2Client {
|
|
3520
|
+
list(siteName: string, params?: V2OrderListParams): Promise<V2List<V2Order>>;
|
|
3521
|
+
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Order, void, unknown>;
|
|
3522
|
+
get(siteName: string, id: string): Promise<V2Order>;
|
|
3523
|
+
}
|
|
3524
|
+
|
|
3525
|
+
/**
|
|
3526
|
+
* v2 Site Users Client
|
|
3527
|
+
*/
|
|
3528
|
+
|
|
3529
|
+
interface V2OtpRequestResponse {
|
|
3530
|
+
object: 'otp_request';
|
|
3531
|
+
email: string;
|
|
3532
|
+
expires_in: number;
|
|
3533
|
+
}
|
|
3534
|
+
interface V2OtpVerifyResponse extends V2SiteUser {
|
|
3535
|
+
token: string;
|
|
3536
|
+
}
|
|
3537
|
+
declare class SiteUsersV2Client extends BaseV2Client {
|
|
3538
|
+
requestOtp(siteName: string, data: {
|
|
3539
|
+
email: string;
|
|
3540
|
+
waitlist?: boolean;
|
|
3541
|
+
metadata?: Record<string, unknown>;
|
|
3542
|
+
}): Promise<V2OtpRequestResponse>;
|
|
3543
|
+
verifyOtp(siteName: string, data: {
|
|
3544
|
+
email: string;
|
|
3545
|
+
code: string;
|
|
3546
|
+
}): Promise<V2OtpVerifyResponse>;
|
|
3547
|
+
list(siteName: string, params?: V2SiteUserListParams): Promise<V2List<V2SiteUser>>;
|
|
3548
|
+
listAutoPaginated(siteName: string, params?: Omit<V2SiteUserListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2SiteUser, void, unknown>;
|
|
3549
|
+
get(siteName: string, id: string): Promise<V2SiteUser>;
|
|
3550
|
+
update(siteName: string, id: string, data: V2SiteUserUpdateParams): Promise<V2SiteUser>;
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
/**
|
|
3554
|
+
* v2 Newsletter Client
|
|
3555
|
+
*/
|
|
3556
|
+
|
|
3557
|
+
declare class NewsletterV2Client extends BaseV2Client {
|
|
3558
|
+
subscribe(siteName: string, data: {
|
|
3559
|
+
email: string;
|
|
3560
|
+
name?: string;
|
|
3561
|
+
list_ids?: string[];
|
|
3562
|
+
double_opt_in?: boolean;
|
|
3563
|
+
source?: string;
|
|
3564
|
+
source_url?: string;
|
|
3565
|
+
frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
|
|
3566
|
+
topics?: string[];
|
|
3567
|
+
language?: string;
|
|
3568
|
+
metadata?: Record<string, unknown>;
|
|
3569
|
+
}): Promise<V2NewsletterSubscription>;
|
|
3570
|
+
confirm(siteName: string, token: string): Promise<V2NewsletterSubscription>;
|
|
3571
|
+
unsubscribe(siteName: string, data: {
|
|
3572
|
+
token?: string;
|
|
3573
|
+
email?: string;
|
|
3574
|
+
reason?: string;
|
|
3575
|
+
}): Promise<V2NewsletterSubscription>;
|
|
3576
|
+
listSubscriptions(siteName: string, params?: V2PaginationParams & {
|
|
3577
|
+
status?: string;
|
|
3578
|
+
}): Promise<V2List<V2NewsletterSubscription>>;
|
|
3579
|
+
getSubscription(siteName: string, id: string): Promise<V2NewsletterSubscription>;
|
|
3580
|
+
listLists(siteName: string): Promise<V2List<V2NewsletterList>>;
|
|
3581
|
+
listCampaigns(siteName: string, params?: V2PaginationParams & {
|
|
3582
|
+
status?: string;
|
|
3583
|
+
}): Promise<V2List<V2NewsletterCampaign>>;
|
|
3584
|
+
getCampaign(siteName: string, idOrSlug: string): Promise<V2NewsletterCampaign>;
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3587
|
+
/**
|
|
3588
|
+
* v2 Contacts Client
|
|
3589
|
+
*/
|
|
3590
|
+
|
|
3591
|
+
declare class ContactsV2Client extends BaseV2Client {
|
|
3592
|
+
submit(siteName: string, data: {
|
|
3593
|
+
email: string;
|
|
3594
|
+
message: string;
|
|
3595
|
+
name?: string;
|
|
3596
|
+
first_name?: string;
|
|
3597
|
+
last_name?: string;
|
|
3598
|
+
subject?: string;
|
|
3599
|
+
phone?: string;
|
|
3600
|
+
company?: string;
|
|
3601
|
+
metadata?: Record<string, unknown>;
|
|
3602
|
+
}): Promise<V2ContactSubmission>;
|
|
3603
|
+
list(siteName: string, params?: V2PaginationParams & {
|
|
3604
|
+
status?: string;
|
|
3605
|
+
}): Promise<V2List<V2ContactSubmission>>;
|
|
3606
|
+
get(siteName: string, id: string): Promise<V2ContactSubmission>;
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
/**
|
|
3610
|
+
* v2 Organizations Client
|
|
3611
|
+
*/
|
|
3612
|
+
|
|
3613
|
+
declare class OrganizationsV2Client extends BaseV2Client {
|
|
3614
|
+
list(): Promise<V2List<V2Organization>>;
|
|
3615
|
+
get(id: string): Promise<V2Organization>;
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
/**
|
|
3619
|
+
* v2 Sites Client
|
|
3620
|
+
*/
|
|
3621
|
+
|
|
3622
|
+
declare class SitesV2Client extends BaseV2Client {
|
|
3623
|
+
list(params?: V2PaginationParams): Promise<V2List<V2Site>>;
|
|
3624
|
+
get(name: string): Promise<V2Site>;
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
/**
|
|
3628
|
+
* v2 API Keys Client
|
|
3629
|
+
*/
|
|
3630
|
+
|
|
3631
|
+
declare class ApiKeysV2Client extends BaseV2Client {
|
|
3632
|
+
list(params?: V2PaginationParams): Promise<V2List<V2ApiKey>>;
|
|
3633
|
+
get(id: string): Promise<V2ApiKey>;
|
|
3634
|
+
del(id: string): Promise<V2Deleted>;
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
/**
|
|
3638
|
+
* v2 Webhooks Client
|
|
3639
|
+
*/
|
|
3640
|
+
|
|
3641
|
+
declare class WebhooksV2Client extends BaseV2Client {
|
|
3642
|
+
list(siteName: string, params?: V2PaginationParams): Promise<V2List<V2Webhook>>;
|
|
3643
|
+
get(siteName: string, id: string): Promise<V2Webhook>;
|
|
3644
|
+
create(siteName: string, data: V2WebhookCreateParams): Promise<V2Webhook>;
|
|
3645
|
+
update(siteName: string, id: string, data: V2WebhookUpdateParams): Promise<V2Webhook>;
|
|
3646
|
+
del(siteName: string, id: string): Promise<V2Deleted>;
|
|
3647
|
+
}
|
|
3648
|
+
|
|
3649
|
+
/**
|
|
3650
|
+
* PerspectAPI v2 SDK Client
|
|
3651
|
+
*
|
|
3652
|
+
* Stripe-style API with consistent envelopes, prefixed IDs,
|
|
3653
|
+
* cursor pagination, and snake_case responses.
|
|
3654
|
+
*
|
|
3655
|
+
* Usage:
|
|
3656
|
+
* import { PerspectApiV2Client } from 'perspectapi-ts-sdk/v2';
|
|
3657
|
+
* const client = new PerspectApiV2Client({ baseUrl: '...', apiKey: '...' });
|
|
3658
|
+
* const posts = await client.content.list('mysite', { type: 'post', limit: 10 });
|
|
3659
|
+
*/
|
|
3660
|
+
|
|
3661
|
+
declare class PerspectApiV2Client {
|
|
3662
|
+
private http;
|
|
3663
|
+
readonly content: ContentV2Client;
|
|
3664
|
+
readonly products: ProductsV2Client;
|
|
3665
|
+
readonly categories: CategoriesV2Client;
|
|
3666
|
+
readonly collections: CollectionsV2Client;
|
|
3667
|
+
readonly orders: OrdersV2Client;
|
|
3668
|
+
readonly siteUsers: SiteUsersV2Client;
|
|
3669
|
+
readonly newsletter: NewsletterV2Client;
|
|
3670
|
+
readonly contacts: ContactsV2Client;
|
|
3671
|
+
readonly organizations: OrganizationsV2Client;
|
|
3672
|
+
readonly sites: SitesV2Client;
|
|
3673
|
+
readonly apiKeys: ApiKeysV2Client;
|
|
3674
|
+
readonly webhooks: WebhooksV2Client;
|
|
3675
|
+
constructor(config: PerspectApiConfig);
|
|
3676
|
+
/** Update the JWT token for authenticated requests. */
|
|
3677
|
+
setAuth(jwt: string): void;
|
|
3678
|
+
/** Update the API key. */
|
|
3679
|
+
setApiKey(apiKey: string): void;
|
|
3680
|
+
/** Clear authentication. */
|
|
3681
|
+
clearAuth(): void;
|
|
3682
|
+
}
|
|
3683
|
+
declare function createPerspectApiV2Client(config: PerspectApiConfig): PerspectApiV2Client;
|
|
3684
|
+
|
|
3059
3685
|
/**
|
|
3060
3686
|
* Simple in-memory cache adapter primarily suited for development and testing.
|
|
3061
3687
|
*/
|
|
@@ -3374,4 +4000,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
3374
4000
|
error: string;
|
|
3375
4001
|
}>;
|
|
3376
4002
|
|
|
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 };
|
|
4003
|
+
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 };
|