perspectapi-ts-sdk 3.1.0 → 3.2.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/dist/index.d.mts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +15 -0
- package/dist/index.mjs +15 -0
- package/package.json +1 -1
- package/src/client/site-users-client.ts +22 -0
- package/src/types/index.ts +5 -0
package/dist/index.d.mts
CHANGED
|
@@ -628,6 +628,10 @@ interface CreditBalance {
|
|
|
628
628
|
interface CreditBalanceWithTransactions extends CreditBalance {
|
|
629
629
|
transactions: CreditTransaction[];
|
|
630
630
|
}
|
|
631
|
+
interface GrantCreditRequest {
|
|
632
|
+
amount_cents: number;
|
|
633
|
+
description: string;
|
|
634
|
+
}
|
|
631
635
|
interface RequestOtpRequest {
|
|
632
636
|
email: string;
|
|
633
637
|
waitlist?: boolean;
|
|
@@ -2445,6 +2449,18 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2445
2449
|
updateUserStatus(siteName: string, userId: string, status: 'active' | 'suspended' | 'pending_verification', csrfToken?: string): Promise<ApiResponse<{
|
|
2446
2450
|
success: boolean;
|
|
2447
2451
|
}>>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Grant credit to a user (admin only)
|
|
2454
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2455
|
+
* @param siteName - The site name
|
|
2456
|
+
* @param userId - User ID
|
|
2457
|
+
* @param data - Amount in cents and description
|
|
2458
|
+
* @param csrfToken - CSRF token (required)
|
|
2459
|
+
*/
|
|
2460
|
+
grantCredit(siteName: string, userId: string, data: GrantCreditRequest, csrfToken?: string): Promise<ApiResponse<{
|
|
2461
|
+
success: boolean;
|
|
2462
|
+
new_balance_cents: number;
|
|
2463
|
+
}>>;
|
|
2448
2464
|
}
|
|
2449
2465
|
|
|
2450
2466
|
/**
|
|
@@ -2905,4 +2921,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
2905
2921
|
error: string;
|
|
2906
2922
|
}>;
|
|
2907
2923
|
|
|
2908
|
-
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 CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, 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 ProductBundleGroup, 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 };
|
|
2924
|
+
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 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, 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 ProductBundleGroup, 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
|
@@ -628,6 +628,10 @@ interface CreditBalance {
|
|
|
628
628
|
interface CreditBalanceWithTransactions extends CreditBalance {
|
|
629
629
|
transactions: CreditTransaction[];
|
|
630
630
|
}
|
|
631
|
+
interface GrantCreditRequest {
|
|
632
|
+
amount_cents: number;
|
|
633
|
+
description: string;
|
|
634
|
+
}
|
|
631
635
|
interface RequestOtpRequest {
|
|
632
636
|
email: string;
|
|
633
637
|
waitlist?: boolean;
|
|
@@ -2445,6 +2449,18 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2445
2449
|
updateUserStatus(siteName: string, userId: string, status: 'active' | 'suspended' | 'pending_verification', csrfToken?: string): Promise<ApiResponse<{
|
|
2446
2450
|
success: boolean;
|
|
2447
2451
|
}>>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Grant credit to a user (admin only)
|
|
2454
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2455
|
+
* @param siteName - The site name
|
|
2456
|
+
* @param userId - User ID
|
|
2457
|
+
* @param data - Amount in cents and description
|
|
2458
|
+
* @param csrfToken - CSRF token (required)
|
|
2459
|
+
*/
|
|
2460
|
+
grantCredit(siteName: string, userId: string, data: GrantCreditRequest, csrfToken?: string): Promise<ApiResponse<{
|
|
2461
|
+
success: boolean;
|
|
2462
|
+
new_balance_cents: number;
|
|
2463
|
+
}>>;
|
|
2448
2464
|
}
|
|
2449
2465
|
|
|
2450
2466
|
/**
|
|
@@ -2905,4 +2921,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
2905
2921
|
error: string;
|
|
2906
2922
|
}>;
|
|
2907
2923
|
|
|
2908
|
-
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 CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, 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 ProductBundleGroup, 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 };
|
|
2924
|
+
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 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, 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 ProductBundleGroup, 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
|
@@ -2589,6 +2589,21 @@ var SiteUsersClient = class extends BaseClient {
|
|
|
2589
2589
|
csrfToken
|
|
2590
2590
|
);
|
|
2591
2591
|
}
|
|
2592
|
+
/**
|
|
2593
|
+
* Grant credit to a user (admin only)
|
|
2594
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2595
|
+
* @param siteName - The site name
|
|
2596
|
+
* @param userId - User ID
|
|
2597
|
+
* @param data - Amount in cents and description
|
|
2598
|
+
* @param csrfToken - CSRF token (required)
|
|
2599
|
+
*/
|
|
2600
|
+
async grantCredit(siteName, userId, data, csrfToken) {
|
|
2601
|
+
return this.create(
|
|
2602
|
+
this.siteUserEndpoint(siteName, `/users/${encodeURIComponent(userId)}/credits/grant`),
|
|
2603
|
+
data,
|
|
2604
|
+
csrfToken
|
|
2605
|
+
);
|
|
2606
|
+
}
|
|
2592
2607
|
};
|
|
2593
2608
|
|
|
2594
2609
|
// src/client/bundles-client.ts
|
package/dist/index.mjs
CHANGED
|
@@ -2526,6 +2526,21 @@ var SiteUsersClient = class extends BaseClient {
|
|
|
2526
2526
|
csrfToken
|
|
2527
2527
|
);
|
|
2528
2528
|
}
|
|
2529
|
+
/**
|
|
2530
|
+
* Grant credit to a user (admin only)
|
|
2531
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2532
|
+
* @param siteName - The site name
|
|
2533
|
+
* @param userId - User ID
|
|
2534
|
+
* @param data - Amount in cents and description
|
|
2535
|
+
* @param csrfToken - CSRF token (required)
|
|
2536
|
+
*/
|
|
2537
|
+
async grantCredit(siteName, userId, data, csrfToken) {
|
|
2538
|
+
return this.create(
|
|
2539
|
+
this.siteUserEndpoint(siteName, `/users/${encodeURIComponent(userId)}/credits/grant`),
|
|
2540
|
+
data,
|
|
2541
|
+
csrfToken
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2529
2544
|
};
|
|
2530
2545
|
|
|
2531
2546
|
// src/client/bundles-client.ts
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
SiteUserOrder,
|
|
13
13
|
CreditBalance,
|
|
14
14
|
CreditBalanceWithTransactions,
|
|
15
|
+
GrantCreditRequest,
|
|
15
16
|
RequestOtpRequest,
|
|
16
17
|
VerifyOtpRequest,
|
|
17
18
|
VerifyOtpResponse,
|
|
@@ -442,4 +443,25 @@ export class SiteUsersClient extends BaseClient {
|
|
|
442
443
|
csrfToken
|
|
443
444
|
);
|
|
444
445
|
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Grant credit to a user (admin only)
|
|
449
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
450
|
+
* @param siteName - The site name
|
|
451
|
+
* @param userId - User ID
|
|
452
|
+
* @param data - Amount in cents and description
|
|
453
|
+
* @param csrfToken - CSRF token (required)
|
|
454
|
+
*/
|
|
455
|
+
async grantCredit(
|
|
456
|
+
siteName: string,
|
|
457
|
+
userId: string,
|
|
458
|
+
data: GrantCreditRequest,
|
|
459
|
+
csrfToken?: string
|
|
460
|
+
): Promise<ApiResponse<{ success: boolean; new_balance_cents: number }>> {
|
|
461
|
+
return this.create<GrantCreditRequest, { success: boolean; new_balance_cents: number }>(
|
|
462
|
+
this.siteUserEndpoint(siteName, `/users/${encodeURIComponent(userId)}/credits/grant`),
|
|
463
|
+
data,
|
|
464
|
+
csrfToken
|
|
465
|
+
);
|
|
466
|
+
}
|
|
445
467
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -642,6 +642,11 @@ export interface CreditBalanceWithTransactions extends CreditBalance {
|
|
|
642
642
|
transactions: CreditTransaction[];
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
export interface GrantCreditRequest {
|
|
646
|
+
amount_cents: number;
|
|
647
|
+
description: string;
|
|
648
|
+
}
|
|
649
|
+
|
|
645
650
|
export interface RequestOtpRequest {
|
|
646
651
|
email: string;
|
|
647
652
|
waitlist?: boolean; // Mark user as waitlist signup
|