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/src/v2/types.ts
CHANGED
|
@@ -250,6 +250,96 @@ export interface V2OrderListParams extends V2PaginationParams {
|
|
|
250
250
|
date_to?: string;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
// --- Order create (checkout session creation) ---
|
|
254
|
+
|
|
255
|
+
export interface V2OrderLineItemPriceData {
|
|
256
|
+
currency: string;
|
|
257
|
+
product_data: {
|
|
258
|
+
name: string;
|
|
259
|
+
description?: string;
|
|
260
|
+
images?: string[];
|
|
261
|
+
};
|
|
262
|
+
unit_amount: number;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface V2OrderLineItem {
|
|
266
|
+
sku_id?: number;
|
|
267
|
+
product_id?: number;
|
|
268
|
+
price_data?: V2OrderLineItemPriceData;
|
|
269
|
+
price?: string;
|
|
270
|
+
quantity: number;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface V2OrderAddress {
|
|
274
|
+
line1?: string;
|
|
275
|
+
line2?: string;
|
|
276
|
+
city?: string;
|
|
277
|
+
state?: string;
|
|
278
|
+
postal_code?: string;
|
|
279
|
+
country?: string;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface V2OrderTaxRequest {
|
|
283
|
+
strategy?: string;
|
|
284
|
+
customer_identifier?: string;
|
|
285
|
+
customer_profile_id?: string;
|
|
286
|
+
customer_display_name?: string;
|
|
287
|
+
allow_exemption?: boolean;
|
|
288
|
+
save_profile?: boolean;
|
|
289
|
+
customer_exemption?: {
|
|
290
|
+
status?: "none" | "exempt" | "reverse_charge";
|
|
291
|
+
reason?: string;
|
|
292
|
+
tax_id?: string;
|
|
293
|
+
tax_id_type?: string;
|
|
294
|
+
certificate_url?: string;
|
|
295
|
+
metadata?: Record<string, unknown>;
|
|
296
|
+
expires_at?: string;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface V2OrderCreateParams {
|
|
301
|
+
line_items: V2OrderLineItem[];
|
|
302
|
+
success_url: string;
|
|
303
|
+
cancel_url: string;
|
|
304
|
+
customer_email?: string;
|
|
305
|
+
site_user_id?: string;
|
|
306
|
+
mode?: "payment" | "subscription";
|
|
307
|
+
metadata?: Record<string, string | number | boolean>;
|
|
308
|
+
tax?: V2OrderTaxRequest;
|
|
309
|
+
shipping_amount?: number;
|
|
310
|
+
shipping_address?: V2OrderAddress;
|
|
311
|
+
billing_address?: V2OrderAddress;
|
|
312
|
+
currency?: string;
|
|
313
|
+
referral_code?: string;
|
|
314
|
+
referrer_site_user_id?: string;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface V2OrderFulfillmentUpdate {
|
|
318
|
+
fulfillment_status: string;
|
|
319
|
+
tracking_number?: string;
|
|
320
|
+
notes?: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface V2OrderCreateResult extends V2Object {
|
|
324
|
+
object: "checkout_session";
|
|
325
|
+
checkout_url: string | null;
|
|
326
|
+
payment_status: string | null;
|
|
327
|
+
tax: {
|
|
328
|
+
amount: number;
|
|
329
|
+
currency: string;
|
|
330
|
+
strategy: string;
|
|
331
|
+
exemption_applied: boolean;
|
|
332
|
+
exemption_status: string;
|
|
333
|
+
breakdown: Array<{
|
|
334
|
+
jurisdiction?: string;
|
|
335
|
+
rate_percent: number;
|
|
336
|
+
tax_amount: number;
|
|
337
|
+
taxable_amount: number;
|
|
338
|
+
source: string;
|
|
339
|
+
}>;
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
253
343
|
// --- Site Users ---
|
|
254
344
|
|
|
255
345
|
export interface V2SiteUser extends V2Object {
|
|
@@ -275,11 +365,41 @@ export interface V2SiteUserUpdateParams {
|
|
|
275
365
|
metadata?: Record<string, unknown>;
|
|
276
366
|
}
|
|
277
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Patch shape for the authenticated `/me` endpoint. Unlike the admin update,
|
|
370
|
+
* end users cannot change their own `status`.
|
|
371
|
+
*/
|
|
372
|
+
export interface V2SiteUserMeUpdateParams {
|
|
373
|
+
first_name?: string;
|
|
374
|
+
last_name?: string;
|
|
375
|
+
avatar_url?: string;
|
|
376
|
+
metadata?: Record<string, unknown>;
|
|
377
|
+
}
|
|
378
|
+
|
|
278
379
|
export interface V2SiteUserListParams extends V2PaginationParams {
|
|
279
380
|
status?: "active" | "suspended" | "pending_verification";
|
|
280
381
|
email?: string;
|
|
281
382
|
}
|
|
282
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Response shape of `GET /sites/{siteName}/users/me`. Extends V2SiteUser with
|
|
386
|
+
* a `profile` side-channel populated from the `site_user_profiles` KV table.
|
|
387
|
+
*/
|
|
388
|
+
export interface V2SiteUserWithProfile extends V2SiteUser {
|
|
389
|
+
profile: Record<string, unknown>;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Standalone profile envelope returned by
|
|
394
|
+
* `GET|PUT /sites/{siteName}/users/me/profile[/:key]`. Each `data` entry is a
|
|
395
|
+
* parsed value (arbitrary JSON).
|
|
396
|
+
*/
|
|
397
|
+
export interface V2SiteUserProfile {
|
|
398
|
+
object: "site_user_profile";
|
|
399
|
+
site_user_id: string;
|
|
400
|
+
data: Record<string, unknown>;
|
|
401
|
+
}
|
|
402
|
+
|
|
283
403
|
// --- Newsletter ---
|
|
284
404
|
|
|
285
405
|
export interface V2NewsletterSubscription extends V2Object {
|
|
@@ -332,6 +452,84 @@ export interface V2NewsletterTrackingResponse {
|
|
|
332
452
|
success: boolean;
|
|
333
453
|
}
|
|
334
454
|
|
|
455
|
+
// --- Newsletter admin writes ---
|
|
456
|
+
|
|
457
|
+
export interface V2NewsletterListCreateParams {
|
|
458
|
+
list_name: string;
|
|
459
|
+
slug: string;
|
|
460
|
+
description?: string | null;
|
|
461
|
+
is_public?: boolean;
|
|
462
|
+
is_default?: boolean;
|
|
463
|
+
welcome_email_enabled?: boolean;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface V2NewsletterListUpdateParams {
|
|
467
|
+
list_name?: string;
|
|
468
|
+
slug?: string;
|
|
469
|
+
description?: string | null;
|
|
470
|
+
is_public?: boolean;
|
|
471
|
+
is_default?: boolean;
|
|
472
|
+
welcome_email_enabled?: boolean;
|
|
473
|
+
status?: "active" | "archived";
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export interface V2NewsletterSyncInput {
|
|
477
|
+
email: string;
|
|
478
|
+
name?: string | null;
|
|
479
|
+
status?: "pending" | "confirmed" | "unsubscribed" | "bounced" | "complained";
|
|
480
|
+
list_ids?: string[];
|
|
481
|
+
frequency?: "instant" | "daily" | "weekly" | "monthly";
|
|
482
|
+
topics?: string[];
|
|
483
|
+
language?: string | null;
|
|
484
|
+
source?: string | null;
|
|
485
|
+
source_url?: string | null;
|
|
486
|
+
notes?: string | null;
|
|
487
|
+
tags?: string[];
|
|
488
|
+
metadata?: Record<string, unknown>;
|
|
489
|
+
resubscribe_override?: boolean;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export interface V2NewsletterSyncResult {
|
|
493
|
+
object: "newsletter_sync_result";
|
|
494
|
+
applied: boolean;
|
|
495
|
+
code: "CREATED" | "UPDATED" | "RESUBSCRIBED" | "ALREADY_UNSUBSCRIBED";
|
|
496
|
+
skipped_unsubscribed: boolean;
|
|
497
|
+
resubscribed: boolean;
|
|
498
|
+
created: boolean;
|
|
499
|
+
updated: boolean;
|
|
500
|
+
subscription: Record<string, unknown>;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export interface V2NewsletterSubscriptionListMembershipUpdate {
|
|
504
|
+
mode: "add" | "remove" | "replace";
|
|
505
|
+
list_ids: string[];
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
export interface V2NewsletterImportRequest {
|
|
509
|
+
rows: V2NewsletterSyncInput[];
|
|
510
|
+
resubscribe_override?: boolean;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export interface V2NewsletterImportResult {
|
|
514
|
+
object: "newsletter_import_result";
|
|
515
|
+
total: number;
|
|
516
|
+
processed: number;
|
|
517
|
+
applied: number;
|
|
518
|
+
created: number;
|
|
519
|
+
updated: number;
|
|
520
|
+
resubscribed: number;
|
|
521
|
+
skipped_unsubscribed: number;
|
|
522
|
+
rows: Array<{
|
|
523
|
+
index: number;
|
|
524
|
+
email: string;
|
|
525
|
+
applied: boolean;
|
|
526
|
+
code: V2NewsletterSyncResult["code"];
|
|
527
|
+
skipped_unsubscribed: boolean;
|
|
528
|
+
resubscribed: boolean;
|
|
529
|
+
subscription_id: string;
|
|
530
|
+
}>;
|
|
531
|
+
}
|
|
532
|
+
|
|
335
533
|
// --- Contact ---
|
|
336
534
|
|
|
337
535
|
export interface V2ContactSubmission extends V2Object {
|
|
@@ -414,3 +612,81 @@ export interface V2WebhookCreateParams {
|
|
|
414
612
|
}
|
|
415
613
|
|
|
416
614
|
export interface V2WebhookUpdateParams extends Partial<V2WebhookCreateParams> {}
|
|
615
|
+
|
|
616
|
+
// --- Site User Subscriptions ---
|
|
617
|
+
|
|
618
|
+
export interface V2SiteUserSubscription extends V2Object {
|
|
619
|
+
object: "site_user_subscription";
|
|
620
|
+
site_user_id: string;
|
|
621
|
+
provider: string | null;
|
|
622
|
+
provider_subscription_id: string | null;
|
|
623
|
+
plan_name: string | null;
|
|
624
|
+
plan_id: string | null;
|
|
625
|
+
status: string;
|
|
626
|
+
amount: number | null;
|
|
627
|
+
currency: string | null;
|
|
628
|
+
billing_interval: string | null;
|
|
629
|
+
billing_interval_count: number | null;
|
|
630
|
+
current_period_start: string | null;
|
|
631
|
+
current_period_end: string | null;
|
|
632
|
+
trial_start: string | null;
|
|
633
|
+
trial_end: string | null;
|
|
634
|
+
canceled_at: string | null;
|
|
635
|
+
cancel_at_period_end: boolean;
|
|
636
|
+
metadata: Record<string, unknown> | null;
|
|
637
|
+
created_at: string | null;
|
|
638
|
+
updated_at: string | null;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export interface V2SubscriptionPauseParams {
|
|
642
|
+
resumes_at?: number;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export interface V2SubscriptionCancelParams {
|
|
646
|
+
mode?: "immediate" | "period_end" | "scheduled";
|
|
647
|
+
cancel_at?: string;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export interface V2SubscriptionChangePlanParams {
|
|
651
|
+
product_id: string;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
export interface V2CancelSubscriptionResult {
|
|
655
|
+
object: "subscription_cancel_result";
|
|
656
|
+
mode: string;
|
|
657
|
+
status: string;
|
|
658
|
+
cancel_at_period_end: boolean;
|
|
659
|
+
effective_at: string | null;
|
|
660
|
+
scheduled_cancel_at: string | null;
|
|
661
|
+
message: string;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// --- Credits ---
|
|
665
|
+
|
|
666
|
+
export interface V2CreditTransaction extends V2Object {
|
|
667
|
+
object: "credit_transaction";
|
|
668
|
+
site_user_id: string;
|
|
669
|
+
amount_cents: number;
|
|
670
|
+
balance_after_cents: number;
|
|
671
|
+
type: string;
|
|
672
|
+
description: string | null;
|
|
673
|
+
reference_id: string | null;
|
|
674
|
+
reference_type: string | null;
|
|
675
|
+
created_at: string | null;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
export interface V2CreditBalance {
|
|
679
|
+
object: "credit_balance";
|
|
680
|
+
balance_cents: number;
|
|
681
|
+
transactions?: V2CreditTransaction[];
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
export interface V2GrantCreditParams {
|
|
685
|
+
amount_cents: number;
|
|
686
|
+
description: string;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export interface V2GrantCreditResult {
|
|
690
|
+
object: "grant_credit_result";
|
|
691
|
+
new_balance_cents: number;
|
|
692
|
+
}
|