perspectapi-ts-sdk 2.9.0 → 3.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
@@ -106,21 +106,6 @@ interface PaginatedResponse<T> extends ApiResponse<T[]> {
106
106
  totalPages: number;
107
107
  };
108
108
  }
109
- interface SignUpRequest {
110
- email: string;
111
- password: string;
112
- firstName?: string;
113
- lastName?: string;
114
- }
115
- interface SignInRequest {
116
- email: string;
117
- password: string;
118
- }
119
- interface AuthResponse {
120
- message: string;
121
- user?: User;
122
- token?: string;
123
- }
124
109
  interface User {
125
110
  id: string;
126
111
  email: string;
@@ -486,6 +471,7 @@ interface CreateCheckoutSessionRequest {
486
471
  line_items?: Array<{
487
472
  price?: string;
488
473
  quantity: number;
474
+ sku_id?: number;
489
475
  price_data?: {
490
476
  currency: string;
491
477
  product_data: {
@@ -502,6 +488,7 @@ interface CreateCheckoutSessionRequest {
502
488
  cancelUrl?: string;
503
489
  customer_email?: string;
504
490
  customerEmail?: string;
491
+ site_user_id?: string;
505
492
  currency?: string;
506
493
  metadata?: CheckoutMetadata;
507
494
  mode?: 'payment' | 'subscription' | 'setup';
@@ -812,6 +799,9 @@ declare abstract class BaseClient {
812
799
 
813
800
  /**
814
801
  * Authentication client for PerspectAPI SDK
802
+ *
803
+ * Admin and site user authentication is OTP-based.
804
+ * Site user OTP methods are on SiteUsersClient.
815
805
  */
816
806
 
817
807
  declare class AuthClient extends BaseClient {
@@ -822,35 +812,6 @@ declare class AuthClient extends BaseClient {
822
812
  getCsrfToken(): Promise<ApiResponse<{
823
813
  token: string;
824
814
  }>>;
825
- /**
826
- * Sign up a new user
827
- */
828
- signUp(data: SignUpRequest): Promise<ApiResponse<{
829
- message: string;
830
- userId: string;
831
- }>>;
832
- /**
833
- * Sign in user
834
- */
835
- signIn(data: SignInRequest): Promise<ApiResponse<AuthResponse>>;
836
- /**
837
- * Activate user account
838
- */
839
- activateAccount(activationKey: string): Promise<ApiResponse<{
840
- message: string;
841
- }>>;
842
- /**
843
- * Request password reset
844
- */
845
- forgotPassword(email: string): Promise<ApiResponse<{
846
- message: string;
847
- }>>;
848
- /**
849
- * Reset password with token
850
- */
851
- resetPassword(resetToken: string, password: string): Promise<ApiResponse<{
852
- message: string;
853
- }>>;
854
815
  /**
855
816
  * Get current user profile
856
817
  */
@@ -2794,4 +2755,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
2794
2755
  error: string;
2795
2756
  }>;
2796
2757
 
2797
- export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, type AuthResponse, BaseClient, type BlogPost, 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 CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, DEFAULT_IMAGE_SIZES, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type SignInRequest, type SignUpRequest, 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 };
2758
+ export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, 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 CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, DEFAULT_IMAGE_SIZES, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, 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 };
package/dist/index.d.ts CHANGED
@@ -106,21 +106,6 @@ interface PaginatedResponse<T> extends ApiResponse<T[]> {
106
106
  totalPages: number;
107
107
  };
108
108
  }
109
- interface SignUpRequest {
110
- email: string;
111
- password: string;
112
- firstName?: string;
113
- lastName?: string;
114
- }
115
- interface SignInRequest {
116
- email: string;
117
- password: string;
118
- }
119
- interface AuthResponse {
120
- message: string;
121
- user?: User;
122
- token?: string;
123
- }
124
109
  interface User {
125
110
  id: string;
126
111
  email: string;
@@ -486,6 +471,7 @@ interface CreateCheckoutSessionRequest {
486
471
  line_items?: Array<{
487
472
  price?: string;
488
473
  quantity: number;
474
+ sku_id?: number;
489
475
  price_data?: {
490
476
  currency: string;
491
477
  product_data: {
@@ -502,6 +488,7 @@ interface CreateCheckoutSessionRequest {
502
488
  cancelUrl?: string;
503
489
  customer_email?: string;
504
490
  customerEmail?: string;
491
+ site_user_id?: string;
505
492
  currency?: string;
506
493
  metadata?: CheckoutMetadata;
507
494
  mode?: 'payment' | 'subscription' | 'setup';
@@ -812,6 +799,9 @@ declare abstract class BaseClient {
812
799
 
813
800
  /**
814
801
  * Authentication client for PerspectAPI SDK
802
+ *
803
+ * Admin and site user authentication is OTP-based.
804
+ * Site user OTP methods are on SiteUsersClient.
815
805
  */
816
806
 
817
807
  declare class AuthClient extends BaseClient {
@@ -822,35 +812,6 @@ declare class AuthClient extends BaseClient {
822
812
  getCsrfToken(): Promise<ApiResponse<{
823
813
  token: string;
824
814
  }>>;
825
- /**
826
- * Sign up a new user
827
- */
828
- signUp(data: SignUpRequest): Promise<ApiResponse<{
829
- message: string;
830
- userId: string;
831
- }>>;
832
- /**
833
- * Sign in user
834
- */
835
- signIn(data: SignInRequest): Promise<ApiResponse<AuthResponse>>;
836
- /**
837
- * Activate user account
838
- */
839
- activateAccount(activationKey: string): Promise<ApiResponse<{
840
- message: string;
841
- }>>;
842
- /**
843
- * Request password reset
844
- */
845
- forgotPassword(email: string): Promise<ApiResponse<{
846
- message: string;
847
- }>>;
848
- /**
849
- * Reset password with token
850
- */
851
- resetPassword(resetToken: string, password: string): Promise<ApiResponse<{
852
- message: string;
853
- }>>;
854
815
  /**
855
816
  * Get current user profile
856
817
  */
@@ -2794,4 +2755,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
2794
2755
  error: string;
2795
2756
  }>;
2796
2757
 
2797
- export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, type AuthResponse, BaseClient, type BlogPost, 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 CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, DEFAULT_IMAGE_SIZES, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type SignInRequest, type SignUpRequest, 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 };
2758
+ export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, 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 CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, DEFAULT_IMAGE_SIZES, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, 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 };
package/dist/index.js CHANGED
@@ -716,43 +716,6 @@ var AuthClient = class extends BaseClient {
716
716
  async getCsrfToken() {
717
717
  return this.http.get(this.buildPath("/csrf"));
718
718
  }
719
- /**
720
- * Sign up a new user
721
- */
722
- async signUp(data) {
723
- return this.create("/signup", data);
724
- }
725
- /**
726
- * Sign in user
727
- */
728
- async signIn(data) {
729
- const response = await this.create("/authenticate", data);
730
- if (response.data && "token" in response.data && response.data.token) {
731
- this.http.setAuth(response.data.token);
732
- }
733
- return response;
734
- }
735
- /**
736
- * Activate user account
737
- */
738
- async activateAccount(activationKey) {
739
- return this.getSingle(`/activate/${activationKey}`);
740
- }
741
- /**
742
- * Request password reset
743
- */
744
- async forgotPassword(email) {
745
- return this.create("/forgotpassword", { email });
746
- }
747
- /**
748
- * Reset password with token
749
- */
750
- async resetPassword(resetToken, password) {
751
- return this.create(
752
- `/passwordreset/${resetToken}`,
753
- { password }
754
- );
755
- }
756
719
  /**
757
720
  * Get current user profile
758
721
  */
package/dist/index.mjs CHANGED
@@ -654,43 +654,6 @@ var AuthClient = class extends BaseClient {
654
654
  async getCsrfToken() {
655
655
  return this.http.get(this.buildPath("/csrf"));
656
656
  }
657
- /**
658
- * Sign up a new user
659
- */
660
- async signUp(data) {
661
- return this.create("/signup", data);
662
- }
663
- /**
664
- * Sign in user
665
- */
666
- async signIn(data) {
667
- const response = await this.create("/authenticate", data);
668
- if (response.data && "token" in response.data && response.data.token) {
669
- this.http.setAuth(response.data.token);
670
- }
671
- return response;
672
- }
673
- /**
674
- * Activate user account
675
- */
676
- async activateAccount(activationKey) {
677
- return this.getSingle(`/activate/${activationKey}`);
678
- }
679
- /**
680
- * Request password reset
681
- */
682
- async forgotPassword(email) {
683
- return this.create("/forgotpassword", { email });
684
- }
685
- /**
686
- * Reset password with token
687
- */
688
- async resetPassword(resetToken, password) {
689
- return this.create(
690
- `/passwordreset/${resetToken}`,
691
- { password }
692
- );
693
- }
694
657
  /**
695
658
  * Get current user profile
696
659
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perspectapi-ts-sdk",
3
- "version": "2.9.0",
3
+ "version": "3.0.1",
4
4
  "description": "TypeScript SDK for PerspectAPI - Cloudflare Workers compatible",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Authentication client for PerspectAPI SDK
3
+ *
4
+ * Admin and site user authentication is OTP-based.
5
+ * Site user OTP methods are on SiteUsersClient.
3
6
  */
4
7
 
5
8
  import { BaseClient } from './base-client';
6
9
  import type { CacheManager } from '../cache/cache-manager';
7
10
  import type {
8
- SignUpRequest,
9
- SignInRequest,
10
- AuthResponse,
11
11
  User,
12
12
  ApiResponse,
13
13
  } from '../types';
@@ -24,54 +24,6 @@ export class AuthClient extends BaseClient {
24
24
  return this.http.get<{ token: string }>(this.buildPath('/csrf'));
25
25
  }
26
26
 
27
- /**
28
- * Sign up a new user
29
- */
30
- async signUp(data: SignUpRequest): Promise<ApiResponse<{ message: string; userId: string }>> {
31
- return this.create<SignUpRequest, { message: string; userId: string }>('/signup', data);
32
- }
33
-
34
- /**
35
- * Sign in user
36
- */
37
- async signIn(data: SignInRequest): Promise<ApiResponse<AuthResponse>> {
38
- const response = await this.create<SignInRequest, AuthResponse>('/authenticate', data);
39
-
40
- // Update HTTP client with JWT if provided
41
- if (response.data && 'token' in response.data && response.data.token) {
42
- this.http.setAuth(response.data.token);
43
- }
44
-
45
- return response;
46
- }
47
-
48
- /**
49
- * Activate user account
50
- */
51
- async activateAccount(activationKey: string): Promise<ApiResponse<{ message: string }>> {
52
- return this.getSingle<{ message: string }>(`/activate/${activationKey}`);
53
- }
54
-
55
- /**
56
- * Request password reset
57
- */
58
- async forgotPassword(email: string): Promise<ApiResponse<{ message: string }>> {
59
- return this.create<{ email: string }, { message: string }>('/forgotpassword', { email });
60
- }
61
-
62
- /**
63
- * Reset password with token
64
- */
65
- async resetPassword(
66
- resetToken: string,
67
- password: string
68
- ): Promise<ApiResponse<{ message: string }>> {
69
- return this.create<{ password: string }, { message: string }>(
70
- `/passwordreset/${resetToken}`,
71
- { password }
72
- );
73
- }
74
-
75
27
  /**
76
28
  * Get current user profile
77
29
  */
@@ -29,25 +29,7 @@ export interface PaginatedResponse<T> extends ApiResponse<T[]> {
29
29
  };
30
30
  }
31
31
 
32
- // Authentication
33
- export interface SignUpRequest {
34
- email: string;
35
- password: string;
36
- firstName?: string;
37
- lastName?: string;
38
- }
39
-
40
- export interface SignInRequest {
41
- email: string;
42
- password: string;
43
- }
44
-
45
- export interface AuthResponse {
46
- message: string;
47
- user?: User;
48
- token?: string;
49
- }
50
-
32
+ // Authentication (OTP-based)
51
33
  export interface User {
52
34
  id: string;
53
35
  email: string;
@@ -480,6 +462,8 @@ export interface CreateCheckoutSessionRequest {
480
462
  // Either use existing Stripe price ID
481
463
  price?: string;
482
464
  quantity: number;
465
+ // SKU-based checkout (variant products)
466
+ sku_id?: number;
483
467
  // Or define price data inline
484
468
  price_data?: {
485
469
  currency: string;
@@ -499,6 +483,7 @@ export interface CreateCheckoutSessionRequest {
499
483
  cancelUrl?: string; // Alternative naming
500
484
  customer_email?: string;
501
485
  customerEmail?: string; // Alternative naming
486
+ site_user_id?: string; // Authenticated site user — enables checkout prefill
502
487
  currency?: string;
503
488
  metadata?: CheckoutMetadata;
504
489
  mode?: 'payment' | 'subscription' | 'setup';