perspectapi-ts-sdk 3.6.0 → 3.7.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 +58 -26
- package/dist/index.d.ts +58 -26
- package/dist/index.js +30 -1
- package/dist/index.mjs +30 -1
- package/package.json +1 -1
- package/src/client/products-client.ts +59 -27
- package/src/types/index.ts +59 -0
package/dist/index.d.mts
CHANGED
|
@@ -359,6 +359,46 @@ interface MediaItem {
|
|
|
359
359
|
r2_key: string;
|
|
360
360
|
site_name: string;
|
|
361
361
|
}
|
|
362
|
+
interface ProductSkuMediaItem {
|
|
363
|
+
id?: string;
|
|
364
|
+
media_id: string;
|
|
365
|
+
file_name?: string;
|
|
366
|
+
fileName?: string;
|
|
367
|
+
link?: string;
|
|
368
|
+
url?: string;
|
|
369
|
+
content_type?: string;
|
|
370
|
+
contentType?: string;
|
|
371
|
+
width?: number;
|
|
372
|
+
height?: number;
|
|
373
|
+
filesize?: number;
|
|
374
|
+
r2_key?: string;
|
|
375
|
+
site_name?: string;
|
|
376
|
+
}
|
|
377
|
+
interface ProductSkuOption {
|
|
378
|
+
name: string;
|
|
379
|
+
key: string;
|
|
380
|
+
value: string;
|
|
381
|
+
label: string;
|
|
382
|
+
value_id: number;
|
|
383
|
+
}
|
|
384
|
+
interface ProductSku {
|
|
385
|
+
sku_id: number;
|
|
386
|
+
sku?: string | null;
|
|
387
|
+
combination_key: string;
|
|
388
|
+
media_id?: string | null;
|
|
389
|
+
media?: ProductSkuMediaItem | null;
|
|
390
|
+
options?: ProductSkuOption[];
|
|
391
|
+
unit_amount?: number;
|
|
392
|
+
currency?: string;
|
|
393
|
+
quantity_available?: number | null;
|
|
394
|
+
price?: number;
|
|
395
|
+
sale_price?: number;
|
|
396
|
+
stock_quantity?: number;
|
|
397
|
+
value_ids: number[];
|
|
398
|
+
created_at?: string;
|
|
399
|
+
updated_at?: string;
|
|
400
|
+
[key: string]: any;
|
|
401
|
+
}
|
|
362
402
|
interface Product {
|
|
363
403
|
id: number | string;
|
|
364
404
|
name?: string;
|
|
@@ -372,6 +412,7 @@ interface Product {
|
|
|
372
412
|
slug_prefix?: string;
|
|
373
413
|
image?: string;
|
|
374
414
|
media?: MediaItem[] | MediaItem[][];
|
|
415
|
+
skus?: ProductSku[];
|
|
375
416
|
isActive?: boolean;
|
|
376
417
|
organizationId?: number;
|
|
377
418
|
createdAt?: string;
|
|
@@ -402,6 +443,20 @@ interface CreateProductRequest {
|
|
|
402
443
|
stock_quantity?: number | null;
|
|
403
444
|
isActive?: boolean;
|
|
404
445
|
}
|
|
446
|
+
interface CreateProductSkuRequest {
|
|
447
|
+
sku?: string | null;
|
|
448
|
+
media_id?: string | null;
|
|
449
|
+
unit_amount?: number;
|
|
450
|
+
currency?: string;
|
|
451
|
+
quantity_available?: number | null;
|
|
452
|
+
price?: number | null;
|
|
453
|
+
stock_quantity?: number | null;
|
|
454
|
+
sale_price?: number | null;
|
|
455
|
+
published?: boolean;
|
|
456
|
+
gateway_price_id_test?: string | null;
|
|
457
|
+
gateway_price_id_live?: string | null;
|
|
458
|
+
value_ids: number[];
|
|
459
|
+
}
|
|
405
460
|
interface ProductQueryParams extends PaginationParams {
|
|
406
461
|
organizationId?: number;
|
|
407
462
|
isActive?: boolean;
|
|
@@ -1459,34 +1514,11 @@ declare class ProductsClient extends BaseClient {
|
|
|
1459
1514
|
/**
|
|
1460
1515
|
* Get all SKUs for a product (with their option value combinations)
|
|
1461
1516
|
*/
|
|
1462
|
-
getProductSkus(siteName: string, productId: number): Promise<ApiResponse<
|
|
1463
|
-
sku_id: number;
|
|
1464
|
-
sku: string;
|
|
1465
|
-
price?: number;
|
|
1466
|
-
sale_price?: number;
|
|
1467
|
-
stock_quantity?: number;
|
|
1468
|
-
combination_key: string;
|
|
1469
|
-
value_ids: number[];
|
|
1470
|
-
created_at: string;
|
|
1471
|
-
updated_at: string;
|
|
1472
|
-
}>>>;
|
|
1517
|
+
getProductSkus(siteName: string, productId: number): Promise<ApiResponse<ProductSku[]>>;
|
|
1473
1518
|
/**
|
|
1474
1519
|
* Create or update a SKU for a product variant combination
|
|
1475
1520
|
*/
|
|
1476
|
-
createProductSku(siteName: string, productId: number, data:
|
|
1477
|
-
sku: string;
|
|
1478
|
-
price?: number | null;
|
|
1479
|
-
sale_price?: number | null;
|
|
1480
|
-
stock_quantity?: number | null;
|
|
1481
|
-
value_ids: number[];
|
|
1482
|
-
}): Promise<ApiResponse<{
|
|
1483
|
-
sku_id: number;
|
|
1484
|
-
sku: string;
|
|
1485
|
-
price?: number;
|
|
1486
|
-
sale_price?: number;
|
|
1487
|
-
stock_quantity?: number;
|
|
1488
|
-
combination_key: string;
|
|
1489
|
-
}>>;
|
|
1521
|
+
createProductSku(siteName: string, productId: number, data: CreateProductSkuRequest): Promise<ApiResponse<ProductSku>>;
|
|
1490
1522
|
}
|
|
1491
1523
|
|
|
1492
1524
|
/**
|
|
@@ -3087,4 +3119,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
3087
3119
|
error: string;
|
|
3088
3120
|
}>;
|
|
3089
3121
|
|
|
3090
|
-
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, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, 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 };
|
|
3122
|
+
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, 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, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -359,6 +359,46 @@ interface MediaItem {
|
|
|
359
359
|
r2_key: string;
|
|
360
360
|
site_name: string;
|
|
361
361
|
}
|
|
362
|
+
interface ProductSkuMediaItem {
|
|
363
|
+
id?: string;
|
|
364
|
+
media_id: string;
|
|
365
|
+
file_name?: string;
|
|
366
|
+
fileName?: string;
|
|
367
|
+
link?: string;
|
|
368
|
+
url?: string;
|
|
369
|
+
content_type?: string;
|
|
370
|
+
contentType?: string;
|
|
371
|
+
width?: number;
|
|
372
|
+
height?: number;
|
|
373
|
+
filesize?: number;
|
|
374
|
+
r2_key?: string;
|
|
375
|
+
site_name?: string;
|
|
376
|
+
}
|
|
377
|
+
interface ProductSkuOption {
|
|
378
|
+
name: string;
|
|
379
|
+
key: string;
|
|
380
|
+
value: string;
|
|
381
|
+
label: string;
|
|
382
|
+
value_id: number;
|
|
383
|
+
}
|
|
384
|
+
interface ProductSku {
|
|
385
|
+
sku_id: number;
|
|
386
|
+
sku?: string | null;
|
|
387
|
+
combination_key: string;
|
|
388
|
+
media_id?: string | null;
|
|
389
|
+
media?: ProductSkuMediaItem | null;
|
|
390
|
+
options?: ProductSkuOption[];
|
|
391
|
+
unit_amount?: number;
|
|
392
|
+
currency?: string;
|
|
393
|
+
quantity_available?: number | null;
|
|
394
|
+
price?: number;
|
|
395
|
+
sale_price?: number;
|
|
396
|
+
stock_quantity?: number;
|
|
397
|
+
value_ids: number[];
|
|
398
|
+
created_at?: string;
|
|
399
|
+
updated_at?: string;
|
|
400
|
+
[key: string]: any;
|
|
401
|
+
}
|
|
362
402
|
interface Product {
|
|
363
403
|
id: number | string;
|
|
364
404
|
name?: string;
|
|
@@ -372,6 +412,7 @@ interface Product {
|
|
|
372
412
|
slug_prefix?: string;
|
|
373
413
|
image?: string;
|
|
374
414
|
media?: MediaItem[] | MediaItem[][];
|
|
415
|
+
skus?: ProductSku[];
|
|
375
416
|
isActive?: boolean;
|
|
376
417
|
organizationId?: number;
|
|
377
418
|
createdAt?: string;
|
|
@@ -402,6 +443,20 @@ interface CreateProductRequest {
|
|
|
402
443
|
stock_quantity?: number | null;
|
|
403
444
|
isActive?: boolean;
|
|
404
445
|
}
|
|
446
|
+
interface CreateProductSkuRequest {
|
|
447
|
+
sku?: string | null;
|
|
448
|
+
media_id?: string | null;
|
|
449
|
+
unit_amount?: number;
|
|
450
|
+
currency?: string;
|
|
451
|
+
quantity_available?: number | null;
|
|
452
|
+
price?: number | null;
|
|
453
|
+
stock_quantity?: number | null;
|
|
454
|
+
sale_price?: number | null;
|
|
455
|
+
published?: boolean;
|
|
456
|
+
gateway_price_id_test?: string | null;
|
|
457
|
+
gateway_price_id_live?: string | null;
|
|
458
|
+
value_ids: number[];
|
|
459
|
+
}
|
|
405
460
|
interface ProductQueryParams extends PaginationParams {
|
|
406
461
|
organizationId?: number;
|
|
407
462
|
isActive?: boolean;
|
|
@@ -1459,34 +1514,11 @@ declare class ProductsClient extends BaseClient {
|
|
|
1459
1514
|
/**
|
|
1460
1515
|
* Get all SKUs for a product (with their option value combinations)
|
|
1461
1516
|
*/
|
|
1462
|
-
getProductSkus(siteName: string, productId: number): Promise<ApiResponse<
|
|
1463
|
-
sku_id: number;
|
|
1464
|
-
sku: string;
|
|
1465
|
-
price?: number;
|
|
1466
|
-
sale_price?: number;
|
|
1467
|
-
stock_quantity?: number;
|
|
1468
|
-
combination_key: string;
|
|
1469
|
-
value_ids: number[];
|
|
1470
|
-
created_at: string;
|
|
1471
|
-
updated_at: string;
|
|
1472
|
-
}>>>;
|
|
1517
|
+
getProductSkus(siteName: string, productId: number): Promise<ApiResponse<ProductSku[]>>;
|
|
1473
1518
|
/**
|
|
1474
1519
|
* Create or update a SKU for a product variant combination
|
|
1475
1520
|
*/
|
|
1476
|
-
createProductSku(siteName: string, productId: number, data:
|
|
1477
|
-
sku: string;
|
|
1478
|
-
price?: number | null;
|
|
1479
|
-
sale_price?: number | null;
|
|
1480
|
-
stock_quantity?: number | null;
|
|
1481
|
-
value_ids: number[];
|
|
1482
|
-
}): Promise<ApiResponse<{
|
|
1483
|
-
sku_id: number;
|
|
1484
|
-
sku: string;
|
|
1485
|
-
price?: number;
|
|
1486
|
-
sale_price?: number;
|
|
1487
|
-
stock_quantity?: number;
|
|
1488
|
-
combination_key: string;
|
|
1489
|
-
}>>;
|
|
1521
|
+
createProductSku(siteName: string, productId: number, data: CreateProductSkuRequest): Promise<ApiResponse<ProductSku>>;
|
|
1490
1522
|
}
|
|
1491
1523
|
|
|
1492
1524
|
/**
|
|
@@ -3087,4 +3119,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
3087
3119
|
error: string;
|
|
3088
3120
|
}>;
|
|
3089
3121
|
|
|
3090
|
-
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, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, 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 };
|
|
3122
|
+
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, 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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1553,7 +1553,36 @@ var ProductsClient = class extends BaseClient {
|
|
|
1553
1553
|
`/products/${productId}/skus`,
|
|
1554
1554
|
{ includeSitesSegment: false }
|
|
1555
1555
|
);
|
|
1556
|
-
|
|
1556
|
+
const unitAmountCandidate = typeof data.unit_amount === "number" ? data.unit_amount : typeof data.price === "number" ? Math.round(data.price * 100) : void 0;
|
|
1557
|
+
if (typeof unitAmountCandidate !== "number" || !Number.isFinite(unitAmountCandidate)) {
|
|
1558
|
+
throw new Error("createProductSku requires unit_amount or price");
|
|
1559
|
+
}
|
|
1560
|
+
const unitAmount = unitAmountCandidate;
|
|
1561
|
+
const quantityAvailable = data.quantity_available !== void 0 ? data.quantity_available : data.stock_quantity ?? null;
|
|
1562
|
+
const payload = {
|
|
1563
|
+
sku: data.sku ?? null,
|
|
1564
|
+
unit_amount: unitAmount,
|
|
1565
|
+
currency: data.currency || "usd",
|
|
1566
|
+
quantity_available: quantityAvailable,
|
|
1567
|
+
published: data.published,
|
|
1568
|
+
gateway_price_id_test: data.gateway_price_id_test,
|
|
1569
|
+
gateway_price_id_live: data.gateway_price_id_live,
|
|
1570
|
+
value_ids: data.value_ids
|
|
1571
|
+
};
|
|
1572
|
+
if (Object.prototype.hasOwnProperty.call(data, "media_id")) {
|
|
1573
|
+
if (data.media_id === null) {
|
|
1574
|
+
payload.media_id = null;
|
|
1575
|
+
} else if (typeof data.media_id === "string") {
|
|
1576
|
+
const trimmed = data.media_id.trim();
|
|
1577
|
+
if (!trimmed) {
|
|
1578
|
+
throw new Error("createProductSku media_id cannot be empty");
|
|
1579
|
+
}
|
|
1580
|
+
payload.media_id = trimmed;
|
|
1581
|
+
} else if (data.media_id !== void 0) {
|
|
1582
|
+
throw new Error("createProductSku media_id must be a string or null");
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
return this.create(endpoint, payload);
|
|
1557
1586
|
}
|
|
1558
1587
|
};
|
|
1559
1588
|
|
package/dist/index.mjs
CHANGED
|
@@ -1490,7 +1490,36 @@ var ProductsClient = class extends BaseClient {
|
|
|
1490
1490
|
`/products/${productId}/skus`,
|
|
1491
1491
|
{ includeSitesSegment: false }
|
|
1492
1492
|
);
|
|
1493
|
-
|
|
1493
|
+
const unitAmountCandidate = typeof data.unit_amount === "number" ? data.unit_amount : typeof data.price === "number" ? Math.round(data.price * 100) : void 0;
|
|
1494
|
+
if (typeof unitAmountCandidate !== "number" || !Number.isFinite(unitAmountCandidate)) {
|
|
1495
|
+
throw new Error("createProductSku requires unit_amount or price");
|
|
1496
|
+
}
|
|
1497
|
+
const unitAmount = unitAmountCandidate;
|
|
1498
|
+
const quantityAvailable = data.quantity_available !== void 0 ? data.quantity_available : data.stock_quantity ?? null;
|
|
1499
|
+
const payload = {
|
|
1500
|
+
sku: data.sku ?? null,
|
|
1501
|
+
unit_amount: unitAmount,
|
|
1502
|
+
currency: data.currency || "usd",
|
|
1503
|
+
quantity_available: quantityAvailable,
|
|
1504
|
+
published: data.published,
|
|
1505
|
+
gateway_price_id_test: data.gateway_price_id_test,
|
|
1506
|
+
gateway_price_id_live: data.gateway_price_id_live,
|
|
1507
|
+
value_ids: data.value_ids
|
|
1508
|
+
};
|
|
1509
|
+
if (Object.prototype.hasOwnProperty.call(data, "media_id")) {
|
|
1510
|
+
if (data.media_id === null) {
|
|
1511
|
+
payload.media_id = null;
|
|
1512
|
+
} else if (typeof data.media_id === "string") {
|
|
1513
|
+
const trimmed = data.media_id.trim();
|
|
1514
|
+
if (!trimmed) {
|
|
1515
|
+
throw new Error("createProductSku media_id cannot be empty");
|
|
1516
|
+
}
|
|
1517
|
+
payload.media_id = trimmed;
|
|
1518
|
+
} else if (data.media_id !== void 0) {
|
|
1519
|
+
throw new Error("createProductSku media_id must be a string or null");
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
return this.create(endpoint, payload);
|
|
1494
1523
|
}
|
|
1495
1524
|
};
|
|
1496
1525
|
|
package/package.json
CHANGED
|
@@ -8,6 +8,8 @@ import type { CachePolicy } from '../cache/types';
|
|
|
8
8
|
import type {
|
|
9
9
|
Product,
|
|
10
10
|
CreateProductRequest,
|
|
11
|
+
CreateProductSkuRequest,
|
|
12
|
+
ProductSku,
|
|
11
13
|
PaginatedResponse,
|
|
12
14
|
ApiResponse,
|
|
13
15
|
ProductQueryParams,
|
|
@@ -457,17 +459,7 @@ export class ProductsClient extends BaseClient {
|
|
|
457
459
|
async getProductSkus(
|
|
458
460
|
siteName: string,
|
|
459
461
|
productId: number
|
|
460
|
-
): Promise<ApiResponse<
|
|
461
|
-
sku_id: number;
|
|
462
|
-
sku: string;
|
|
463
|
-
price?: number;
|
|
464
|
-
sale_price?: number;
|
|
465
|
-
stock_quantity?: number;
|
|
466
|
-
combination_key: string;
|
|
467
|
-
value_ids: number[];
|
|
468
|
-
created_at: string;
|
|
469
|
-
updated_at: string;
|
|
470
|
-
}>>> {
|
|
462
|
+
): Promise<ApiResponse<ProductSku[]>> {
|
|
471
463
|
const endpoint = this.siteScopedEndpoint(
|
|
472
464
|
siteName,
|
|
473
465
|
`/products/${productId}/skus`,
|
|
@@ -482,26 +474,66 @@ export class ProductsClient extends BaseClient {
|
|
|
482
474
|
async createProductSku(
|
|
483
475
|
siteName: string,
|
|
484
476
|
productId: number,
|
|
485
|
-
data:
|
|
486
|
-
|
|
487
|
-
price?: number | null;
|
|
488
|
-
sale_price?: number | null;
|
|
489
|
-
stock_quantity?: number | null;
|
|
490
|
-
value_ids: number[];
|
|
491
|
-
}
|
|
492
|
-
): Promise<ApiResponse<{
|
|
493
|
-
sku_id: number;
|
|
494
|
-
sku: string;
|
|
495
|
-
price?: number;
|
|
496
|
-
sale_price?: number;
|
|
497
|
-
stock_quantity?: number;
|
|
498
|
-
combination_key: string;
|
|
499
|
-
}>> {
|
|
477
|
+
data: CreateProductSkuRequest
|
|
478
|
+
): Promise<ApiResponse<ProductSku>> {
|
|
500
479
|
const endpoint = this.siteScopedEndpoint(
|
|
501
480
|
siteName,
|
|
502
481
|
`/products/${productId}/skus`,
|
|
503
482
|
{ includeSitesSegment: false }
|
|
504
483
|
);
|
|
505
|
-
|
|
484
|
+
|
|
485
|
+
const unitAmountCandidate =
|
|
486
|
+
typeof data.unit_amount === 'number'
|
|
487
|
+
? data.unit_amount
|
|
488
|
+
: typeof data.price === 'number'
|
|
489
|
+
? Math.round(data.price * 100)
|
|
490
|
+
: undefined;
|
|
491
|
+
|
|
492
|
+
if (typeof unitAmountCandidate !== 'number' || !Number.isFinite(unitAmountCandidate)) {
|
|
493
|
+
throw new Error('createProductSku requires unit_amount or price');
|
|
494
|
+
}
|
|
495
|
+
const unitAmount = unitAmountCandidate;
|
|
496
|
+
|
|
497
|
+
const quantityAvailable =
|
|
498
|
+
data.quantity_available !== undefined
|
|
499
|
+
? data.quantity_available
|
|
500
|
+
: (data.stock_quantity ?? null);
|
|
501
|
+
|
|
502
|
+
const payload: {
|
|
503
|
+
sku: string | null;
|
|
504
|
+
media_id?: string | null;
|
|
505
|
+
unit_amount: number;
|
|
506
|
+
currency: string;
|
|
507
|
+
quantity_available: number | null;
|
|
508
|
+
published?: boolean;
|
|
509
|
+
gateway_price_id_test?: string | null;
|
|
510
|
+
gateway_price_id_live?: string | null;
|
|
511
|
+
value_ids: number[];
|
|
512
|
+
} = {
|
|
513
|
+
sku: data.sku ?? null,
|
|
514
|
+
unit_amount: unitAmount,
|
|
515
|
+
currency: data.currency || 'usd',
|
|
516
|
+
quantity_available: quantityAvailable,
|
|
517
|
+
published: data.published,
|
|
518
|
+
gateway_price_id_test: data.gateway_price_id_test,
|
|
519
|
+
gateway_price_id_live: data.gateway_price_id_live,
|
|
520
|
+
value_ids: data.value_ids,
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
if (Object.prototype.hasOwnProperty.call(data, 'media_id')) {
|
|
524
|
+
if (data.media_id === null) {
|
|
525
|
+
payload.media_id = null;
|
|
526
|
+
} else if (typeof data.media_id === 'string') {
|
|
527
|
+
const trimmed = data.media_id.trim();
|
|
528
|
+
if (!trimmed) {
|
|
529
|
+
throw new Error('createProductSku media_id cannot be empty');
|
|
530
|
+
}
|
|
531
|
+
payload.media_id = trimmed;
|
|
532
|
+
} else if (data.media_id !== undefined) {
|
|
533
|
+
throw new Error('createProductSku media_id must be a string or null');
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return this.create(endpoint, payload);
|
|
506
538
|
}
|
|
507
539
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -320,6 +320,49 @@ export interface MediaItem {
|
|
|
320
320
|
site_name: string;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
+
export interface ProductSkuMediaItem {
|
|
324
|
+
id?: string;
|
|
325
|
+
media_id: string;
|
|
326
|
+
file_name?: string;
|
|
327
|
+
fileName?: string;
|
|
328
|
+
link?: string;
|
|
329
|
+
url?: string;
|
|
330
|
+
content_type?: string;
|
|
331
|
+
contentType?: string;
|
|
332
|
+
width?: number;
|
|
333
|
+
height?: number;
|
|
334
|
+
filesize?: number;
|
|
335
|
+
r2_key?: string;
|
|
336
|
+
site_name?: string;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export interface ProductSkuOption {
|
|
340
|
+
name: string;
|
|
341
|
+
key: string;
|
|
342
|
+
value: string;
|
|
343
|
+
label: string;
|
|
344
|
+
value_id: number;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface ProductSku {
|
|
348
|
+
sku_id: number;
|
|
349
|
+
sku?: string | null;
|
|
350
|
+
combination_key: string;
|
|
351
|
+
media_id?: string | null;
|
|
352
|
+
media?: ProductSkuMediaItem | null;
|
|
353
|
+
options?: ProductSkuOption[];
|
|
354
|
+
unit_amount?: number;
|
|
355
|
+
currency?: string;
|
|
356
|
+
quantity_available?: number | null;
|
|
357
|
+
price?: number;
|
|
358
|
+
sale_price?: number;
|
|
359
|
+
stock_quantity?: number;
|
|
360
|
+
value_ids: number[];
|
|
361
|
+
created_at?: string;
|
|
362
|
+
updated_at?: string;
|
|
363
|
+
[key: string]: any;
|
|
364
|
+
}
|
|
365
|
+
|
|
323
366
|
export interface Product {
|
|
324
367
|
id: number | string;
|
|
325
368
|
name?: string;
|
|
@@ -333,6 +376,7 @@ export interface Product {
|
|
|
333
376
|
slug_prefix?: string;
|
|
334
377
|
image?: string;
|
|
335
378
|
media?: MediaItem[] | MediaItem[][];
|
|
379
|
+
skus?: ProductSku[];
|
|
336
380
|
isActive?: boolean;
|
|
337
381
|
organizationId?: number;
|
|
338
382
|
createdAt?: string;
|
|
@@ -362,6 +406,21 @@ export interface CreateProductRequest {
|
|
|
362
406
|
isActive?: boolean;
|
|
363
407
|
}
|
|
364
408
|
|
|
409
|
+
export interface CreateProductSkuRequest {
|
|
410
|
+
sku?: string | null;
|
|
411
|
+
media_id?: string | null;
|
|
412
|
+
unit_amount?: number;
|
|
413
|
+
currency?: string;
|
|
414
|
+
quantity_available?: number | null;
|
|
415
|
+
price?: number | null;
|
|
416
|
+
stock_quantity?: number | null;
|
|
417
|
+
sale_price?: number | null;
|
|
418
|
+
published?: boolean;
|
|
419
|
+
gateway_price_id_test?: string | null;
|
|
420
|
+
gateway_price_id_live?: string | null;
|
|
421
|
+
value_ids: number[];
|
|
422
|
+
}
|
|
423
|
+
|
|
365
424
|
export interface ProductQueryParams extends PaginationParams {
|
|
366
425
|
organizationId?: number;
|
|
367
426
|
isActive?: boolean;
|