perspectapi-ts-sdk 3.1.0 → 3.3.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 +40 -5
- package/dist/index.d.ts +40 -5
- package/dist/index.js +31 -6
- package/dist/index.mjs +31 -6
- package/package.json +1 -1
- package/src/client/products-client.ts +16 -6
- package/src/client/site-users-client.ts +22 -0
- package/src/types/index.ts +15 -1
package/dist/index.d.mts
CHANGED
|
@@ -355,11 +355,23 @@ interface Product {
|
|
|
355
355
|
[key: string]: any;
|
|
356
356
|
}
|
|
357
357
|
interface CreateProductRequest {
|
|
358
|
-
|
|
358
|
+
product: string;
|
|
359
|
+
name?: string;
|
|
359
360
|
description?: string;
|
|
361
|
+
excerpt?: string;
|
|
360
362
|
price: number;
|
|
363
|
+
unit_amount: number;
|
|
361
364
|
currency?: string;
|
|
362
365
|
sku?: string;
|
|
366
|
+
slug?: string;
|
|
367
|
+
slug_prefix?: string;
|
|
368
|
+
published?: boolean;
|
|
369
|
+
custom?: Record<string, any>;
|
|
370
|
+
recurring?: {
|
|
371
|
+
interval: "day" | "week" | "month" | "year";
|
|
372
|
+
interval_count?: number;
|
|
373
|
+
};
|
|
374
|
+
stock_quantity?: number | null;
|
|
363
375
|
isActive?: boolean;
|
|
364
376
|
}
|
|
365
377
|
interface ProductQueryParams extends PaginationParams {
|
|
@@ -628,6 +640,10 @@ interface CreditBalance {
|
|
|
628
640
|
interface CreditBalanceWithTransactions extends CreditBalance {
|
|
629
641
|
transactions: CreditTransaction[];
|
|
630
642
|
}
|
|
643
|
+
interface GrantCreditRequest {
|
|
644
|
+
amount_cents: number;
|
|
645
|
+
description: string;
|
|
646
|
+
}
|
|
631
647
|
interface RequestOtpRequest {
|
|
632
648
|
email: string;
|
|
633
649
|
waitlist?: boolean;
|
|
@@ -1240,16 +1256,23 @@ declare class ProductsClient extends BaseClient {
|
|
|
1240
1256
|
}>>;
|
|
1241
1257
|
/**
|
|
1242
1258
|
* Create new product
|
|
1259
|
+
* @param siteName - The site name
|
|
1260
|
+
* @param data - Product data
|
|
1243
1261
|
*/
|
|
1244
|
-
createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>>;
|
|
1262
|
+
createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>>;
|
|
1245
1263
|
/**
|
|
1246
1264
|
* Update product
|
|
1265
|
+
* @param siteName - The site name
|
|
1266
|
+
* @param id - Product ID
|
|
1267
|
+
* @param data - Fields to update
|
|
1247
1268
|
*/
|
|
1248
|
-
updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
|
|
1269
|
+
updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
|
|
1249
1270
|
/**
|
|
1250
1271
|
* Delete product
|
|
1272
|
+
* @param siteName - The site name
|
|
1273
|
+
* @param id - Product ID
|
|
1251
1274
|
*/
|
|
1252
|
-
deleteProduct(id: number): Promise<ApiResponse<{
|
|
1275
|
+
deleteProduct(siteName: string, id: number): Promise<ApiResponse<{
|
|
1253
1276
|
message: string;
|
|
1254
1277
|
}>>;
|
|
1255
1278
|
/**
|
|
@@ -2445,6 +2468,18 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2445
2468
|
updateUserStatus(siteName: string, userId: string, status: 'active' | 'suspended' | 'pending_verification', csrfToken?: string): Promise<ApiResponse<{
|
|
2446
2469
|
success: boolean;
|
|
2447
2470
|
}>>;
|
|
2471
|
+
/**
|
|
2472
|
+
* Grant credit to a user (admin only)
|
|
2473
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2474
|
+
* @param siteName - The site name
|
|
2475
|
+
* @param userId - User ID
|
|
2476
|
+
* @param data - Amount in cents and description
|
|
2477
|
+
* @param csrfToken - CSRF token (required)
|
|
2478
|
+
*/
|
|
2479
|
+
grantCredit(siteName: string, userId: string, data: GrantCreditRequest, csrfToken?: string): Promise<ApiResponse<{
|
|
2480
|
+
success: boolean;
|
|
2481
|
+
new_balance_cents: number;
|
|
2482
|
+
}>>;
|
|
2448
2483
|
}
|
|
2449
2484
|
|
|
2450
2485
|
/**
|
|
@@ -2905,4 +2940,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
2905
2940
|
error: string;
|
|
2906
2941
|
}>;
|
|
2907
2942
|
|
|
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 };
|
|
2943
|
+
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
|
@@ -355,11 +355,23 @@ interface Product {
|
|
|
355
355
|
[key: string]: any;
|
|
356
356
|
}
|
|
357
357
|
interface CreateProductRequest {
|
|
358
|
-
|
|
358
|
+
product: string;
|
|
359
|
+
name?: string;
|
|
359
360
|
description?: string;
|
|
361
|
+
excerpt?: string;
|
|
360
362
|
price: number;
|
|
363
|
+
unit_amount: number;
|
|
361
364
|
currency?: string;
|
|
362
365
|
sku?: string;
|
|
366
|
+
slug?: string;
|
|
367
|
+
slug_prefix?: string;
|
|
368
|
+
published?: boolean;
|
|
369
|
+
custom?: Record<string, any>;
|
|
370
|
+
recurring?: {
|
|
371
|
+
interval: "day" | "week" | "month" | "year";
|
|
372
|
+
interval_count?: number;
|
|
373
|
+
};
|
|
374
|
+
stock_quantity?: number | null;
|
|
363
375
|
isActive?: boolean;
|
|
364
376
|
}
|
|
365
377
|
interface ProductQueryParams extends PaginationParams {
|
|
@@ -628,6 +640,10 @@ interface CreditBalance {
|
|
|
628
640
|
interface CreditBalanceWithTransactions extends CreditBalance {
|
|
629
641
|
transactions: CreditTransaction[];
|
|
630
642
|
}
|
|
643
|
+
interface GrantCreditRequest {
|
|
644
|
+
amount_cents: number;
|
|
645
|
+
description: string;
|
|
646
|
+
}
|
|
631
647
|
interface RequestOtpRequest {
|
|
632
648
|
email: string;
|
|
633
649
|
waitlist?: boolean;
|
|
@@ -1240,16 +1256,23 @@ declare class ProductsClient extends BaseClient {
|
|
|
1240
1256
|
}>>;
|
|
1241
1257
|
/**
|
|
1242
1258
|
* Create new product
|
|
1259
|
+
* @param siteName - The site name
|
|
1260
|
+
* @param data - Product data
|
|
1243
1261
|
*/
|
|
1244
|
-
createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>>;
|
|
1262
|
+
createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>>;
|
|
1245
1263
|
/**
|
|
1246
1264
|
* Update product
|
|
1265
|
+
* @param siteName - The site name
|
|
1266
|
+
* @param id - Product ID
|
|
1267
|
+
* @param data - Fields to update
|
|
1247
1268
|
*/
|
|
1248
|
-
updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
|
|
1269
|
+
updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
|
|
1249
1270
|
/**
|
|
1250
1271
|
* Delete product
|
|
1272
|
+
* @param siteName - The site name
|
|
1273
|
+
* @param id - Product ID
|
|
1251
1274
|
*/
|
|
1252
|
-
deleteProduct(id: number): Promise<ApiResponse<{
|
|
1275
|
+
deleteProduct(siteName: string, id: number): Promise<ApiResponse<{
|
|
1253
1276
|
message: string;
|
|
1254
1277
|
}>>;
|
|
1255
1278
|
/**
|
|
@@ -2445,6 +2468,18 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2445
2468
|
updateUserStatus(siteName: string, userId: string, status: 'active' | 'suspended' | 'pending_verification', csrfToken?: string): Promise<ApiResponse<{
|
|
2446
2469
|
success: boolean;
|
|
2447
2470
|
}>>;
|
|
2471
|
+
/**
|
|
2472
|
+
* Grant credit to a user (admin only)
|
|
2473
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2474
|
+
* @param siteName - The site name
|
|
2475
|
+
* @param userId - User ID
|
|
2476
|
+
* @param data - Amount in cents and description
|
|
2477
|
+
* @param csrfToken - CSRF token (required)
|
|
2478
|
+
*/
|
|
2479
|
+
grantCredit(siteName: string, userId: string, data: GrantCreditRequest, csrfToken?: string): Promise<ApiResponse<{
|
|
2480
|
+
success: boolean;
|
|
2481
|
+
new_balance_cents: number;
|
|
2482
|
+
}>>;
|
|
2448
2483
|
}
|
|
2449
2484
|
|
|
2450
2485
|
/**
|
|
@@ -2905,4 +2940,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
2905
2940
|
error: string;
|
|
2906
2941
|
}>;
|
|
2907
2942
|
|
|
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 };
|
|
2943
|
+
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
|
@@ -1356,21 +1356,31 @@ var ProductsClient = class extends BaseClient {
|
|
|
1356
1356
|
}
|
|
1357
1357
|
/**
|
|
1358
1358
|
* Create new product
|
|
1359
|
+
* @param siteName - The site name
|
|
1360
|
+
* @param data - Product data
|
|
1359
1361
|
*/
|
|
1360
|
-
async createProduct(data) {
|
|
1361
|
-
|
|
1362
|
+
async createProduct(siteName, data) {
|
|
1363
|
+
const endpoint = this.siteScopedEndpoint(siteName, "/products", { includeSitesSegment: false });
|
|
1364
|
+
return this.create(endpoint, data);
|
|
1362
1365
|
}
|
|
1363
1366
|
/**
|
|
1364
1367
|
* Update product
|
|
1368
|
+
* @param siteName - The site name
|
|
1369
|
+
* @param id - Product ID
|
|
1370
|
+
* @param data - Fields to update
|
|
1365
1371
|
*/
|
|
1366
|
-
async updateProduct(id, data) {
|
|
1367
|
-
|
|
1372
|
+
async updateProduct(siteName, id, data) {
|
|
1373
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
1374
|
+
return this.update(endpoint, data);
|
|
1368
1375
|
}
|
|
1369
1376
|
/**
|
|
1370
1377
|
* Delete product
|
|
1378
|
+
* @param siteName - The site name
|
|
1379
|
+
* @param id - Product ID
|
|
1371
1380
|
*/
|
|
1372
|
-
async deleteProduct(id) {
|
|
1373
|
-
|
|
1381
|
+
async deleteProduct(siteName, id) {
|
|
1382
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
1383
|
+
return this.delete(endpoint);
|
|
1374
1384
|
}
|
|
1375
1385
|
/**
|
|
1376
1386
|
* Activate product
|
|
@@ -2589,6 +2599,21 @@ var SiteUsersClient = class extends BaseClient {
|
|
|
2589
2599
|
csrfToken
|
|
2590
2600
|
);
|
|
2591
2601
|
}
|
|
2602
|
+
/**
|
|
2603
|
+
* Grant credit to a user (admin only)
|
|
2604
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2605
|
+
* @param siteName - The site name
|
|
2606
|
+
* @param userId - User ID
|
|
2607
|
+
* @param data - Amount in cents and description
|
|
2608
|
+
* @param csrfToken - CSRF token (required)
|
|
2609
|
+
*/
|
|
2610
|
+
async grantCredit(siteName, userId, data, csrfToken) {
|
|
2611
|
+
return this.create(
|
|
2612
|
+
this.siteUserEndpoint(siteName, `/users/${encodeURIComponent(userId)}/credits/grant`),
|
|
2613
|
+
data,
|
|
2614
|
+
csrfToken
|
|
2615
|
+
);
|
|
2616
|
+
}
|
|
2592
2617
|
};
|
|
2593
2618
|
|
|
2594
2619
|
// src/client/bundles-client.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1293,21 +1293,31 @@ var ProductsClient = class extends BaseClient {
|
|
|
1293
1293
|
}
|
|
1294
1294
|
/**
|
|
1295
1295
|
* Create new product
|
|
1296
|
+
* @param siteName - The site name
|
|
1297
|
+
* @param data - Product data
|
|
1296
1298
|
*/
|
|
1297
|
-
async createProduct(data) {
|
|
1298
|
-
|
|
1299
|
+
async createProduct(siteName, data) {
|
|
1300
|
+
const endpoint = this.siteScopedEndpoint(siteName, "/products", { includeSitesSegment: false });
|
|
1301
|
+
return this.create(endpoint, data);
|
|
1299
1302
|
}
|
|
1300
1303
|
/**
|
|
1301
1304
|
* Update product
|
|
1305
|
+
* @param siteName - The site name
|
|
1306
|
+
* @param id - Product ID
|
|
1307
|
+
* @param data - Fields to update
|
|
1302
1308
|
*/
|
|
1303
|
-
async updateProduct(id, data) {
|
|
1304
|
-
|
|
1309
|
+
async updateProduct(siteName, id, data) {
|
|
1310
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
1311
|
+
return this.update(endpoint, data);
|
|
1305
1312
|
}
|
|
1306
1313
|
/**
|
|
1307
1314
|
* Delete product
|
|
1315
|
+
* @param siteName - The site name
|
|
1316
|
+
* @param id - Product ID
|
|
1308
1317
|
*/
|
|
1309
|
-
async deleteProduct(id) {
|
|
1310
|
-
|
|
1318
|
+
async deleteProduct(siteName, id) {
|
|
1319
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
1320
|
+
return this.delete(endpoint);
|
|
1311
1321
|
}
|
|
1312
1322
|
/**
|
|
1313
1323
|
* Activate product
|
|
@@ -2526,6 +2536,21 @@ var SiteUsersClient = class extends BaseClient {
|
|
|
2526
2536
|
csrfToken
|
|
2527
2537
|
);
|
|
2528
2538
|
}
|
|
2539
|
+
/**
|
|
2540
|
+
* Grant credit to a user (admin only)
|
|
2541
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2542
|
+
* @param siteName - The site name
|
|
2543
|
+
* @param userId - User ID
|
|
2544
|
+
* @param data - Amount in cents and description
|
|
2545
|
+
* @param csrfToken - CSRF token (required)
|
|
2546
|
+
*/
|
|
2547
|
+
async grantCredit(siteName, userId, data, csrfToken) {
|
|
2548
|
+
return this.create(
|
|
2549
|
+
this.siteUserEndpoint(siteName, `/users/${encodeURIComponent(userId)}/credits/grant`),
|
|
2550
|
+
data,
|
|
2551
|
+
csrfToken
|
|
2552
|
+
);
|
|
2553
|
+
}
|
|
2529
2554
|
};
|
|
2530
2555
|
|
|
2531
2556
|
// src/client/bundles-client.ts
|
package/package.json
CHANGED
|
@@ -138,23 +138,33 @@ export class ProductsClient extends BaseClient {
|
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Create new product
|
|
141
|
+
* @param siteName - The site name
|
|
142
|
+
* @param data - Product data
|
|
141
143
|
*/
|
|
142
|
-
async createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>> {
|
|
143
|
-
|
|
144
|
+
async createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>> {
|
|
145
|
+
const endpoint = this.siteScopedEndpoint(siteName, '/products', { includeSitesSegment: false });
|
|
146
|
+
return this.create<CreateProductRequest, Product>(endpoint, data);
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
/**
|
|
147
150
|
* Update product
|
|
151
|
+
* @param siteName - The site name
|
|
152
|
+
* @param id - Product ID
|
|
153
|
+
* @param data - Fields to update
|
|
148
154
|
*/
|
|
149
|
-
async updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>> {
|
|
150
|
-
|
|
155
|
+
async updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>> {
|
|
156
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
157
|
+
return this.update<Partial<CreateProductRequest>, Product>(endpoint, data);
|
|
151
158
|
}
|
|
152
159
|
|
|
153
160
|
/**
|
|
154
161
|
* Delete product
|
|
162
|
+
* @param siteName - The site name
|
|
163
|
+
* @param id - Product ID
|
|
155
164
|
*/
|
|
156
|
-
async deleteProduct(id: number): Promise<ApiResponse<{ message: string }>> {
|
|
157
|
-
|
|
165
|
+
async deleteProduct(siteName: string, id: number): Promise<ApiResponse<{ message: string }>> {
|
|
166
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
167
|
+
return this.delete<{ message: string }>(endpoint);
|
|
158
168
|
}
|
|
159
169
|
|
|
160
170
|
/**
|
|
@@ -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
|
@@ -314,11 +314,20 @@ export interface Product {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
export interface CreateProductRequest {
|
|
317
|
-
|
|
317
|
+
product: string;
|
|
318
|
+
name?: string;
|
|
318
319
|
description?: string;
|
|
320
|
+
excerpt?: string;
|
|
319
321
|
price: number;
|
|
322
|
+
unit_amount: number;
|
|
320
323
|
currency?: string;
|
|
321
324
|
sku?: string;
|
|
325
|
+
slug?: string;
|
|
326
|
+
slug_prefix?: string;
|
|
327
|
+
published?: boolean;
|
|
328
|
+
custom?: Record<string, any>;
|
|
329
|
+
recurring?: { interval: "day" | "week" | "month" | "year"; interval_count?: number };
|
|
330
|
+
stock_quantity?: number | null;
|
|
322
331
|
isActive?: boolean;
|
|
323
332
|
}
|
|
324
333
|
|
|
@@ -642,6 +651,11 @@ export interface CreditBalanceWithTransactions extends CreditBalance {
|
|
|
642
651
|
transactions: CreditTransaction[];
|
|
643
652
|
}
|
|
644
653
|
|
|
654
|
+
export interface GrantCreditRequest {
|
|
655
|
+
amount_cents: number;
|
|
656
|
+
description: string;
|
|
657
|
+
}
|
|
658
|
+
|
|
645
659
|
export interface RequestOtpRequest {
|
|
646
660
|
email: string;
|
|
647
661
|
waitlist?: boolean; // Mark user as waitlist signup
|