commerce-kit
Version:
119 lines (114 loc) • 11.6 kB
TypeScript
import { APIMeGetResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, APIProductGetByIdParams, APIProductGetByIdResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APICartCreateBody, APICartCreateResult, APICartGetResult, APICollectionGetByIdParams, APICollectionGetByIdResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APICollectionCreateBody, APICollectionCreateResult, APICategoryGetByIdParams, APICategoryGetByIdResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APIPostsBrowseQueryParams, APIPostsBrowseResult, APIPostGetByIdParams, APIPostGetByIdResult, APIPostCreateBody, APIPostCreateResult, APIPostUpdateBody, APIPostUpdateResult, APIPostDeleteResult, APIPostCommentsBrowseQueryParams, APIPostCommentsBrowseResult, APIPostCommentCreateBody, APIPostCommentCreateResult, APIBlogCategoriesBrowseQueryParams, APIBlogCategoriesBrowseResult, APIBlogCategoryGetByIdParams, APIBlogCategoryGetByIdResult, APICustomersBrowseQueryParams, APICustomersBrowseResult, APICustomerGetByIdParams, APICustomerGetByIdResult, APICustomerUpdateBody, APICustomerUpdateResult, APICustomerAddressCreateBody, APICustomerAddressCreateResult, APICustomerOrdersBrowseQueryParams, APICustomerOrdersBrowseResult, APIInventoryBrowseQueryParams, APIInventoryBrowseResult, APIInventoryAdjustBody, APIInventoryAdjustResult, APIVariantGetByIdParams, APIVariantGetByIdResult, APIVariantUpdateBody, APIVariantUpdateResult, APIVariantCreateBody, APIVariantCreateResult, APISubscriberCreateBody, APISubscriberCreateResult, APISubscriberDeleteResult, APIContactMessageCreateBody, APIContactMessageCreateResult, APIProductCreateBody, APIProductCreateResult, APIProductUpdateBody, APIProductUpdateResult, APIProductDeleteResult, APIProductReviewsBrowseQueryParams, APIProductReviewsBrowseResult, APIProductReviewCreateBody, APIProductReviewCreateResult, APICategoryCreateBody, APICategoryCreateResult, APICategoryUpdateBody, APICategoryUpdateResult, APIOrderUpdateBody, APIOrderUpdateResult, APILegalPagesBrowseResult, APILegalPageGetByPathResult, APISearchQueryParams, APISearchResult, APIInstaviewImagesBrowseParams, APIInstaviewImagesBrowseQueryParams, APIInstaviewImagesBrowseResult } from './api-types.js';
export { APICartAddBody, APICartAddResult, APICartRemoveItemQueryParams, APICartRemoveItemResult, APICategoryGetByIdQueryParams, APICategoryUpdateQueryParams, APICollectionGetByIdQueryParams, APIProductDeleteQueryParams, APIProductGetByIdQueryParams, APIProductUpdateQueryParams, APIVariantGetByIdQueryParams, JSONContent } from './api-types.js';
interface CommerceConfig {
/** API key. Defaults to process.env.YNS_API_KEY */
token?: string;
endpoint?: string;
version?: "v1";
}
type APICollectionImportMembershipsBody = {
file: File | Blob;
};
type APICollectionImportMembershipsResult = {
ok: true;
processed: number;
inserted: number;
skipped_existing: number;
errors: Array<{
row: number;
collection_slug?: string;
product_slug?: string;
reason: string;
}>;
};
declare class YNSProvider {
#private;
constructor(config?: CommerceConfig);
meGet(): Promise<APIMeGetResult>;
productBrowse(params: APIProductsBrowseQueryParams): Promise<APIProductsBrowseResult>;
productGet(params: APIProductGetByIdParams): Promise<APIProductGetByIdResult | null>;
orderBrowse(params: APIOrdersBrowseQueryParams): Promise<APIOrdersBrowseResult>;
orderGet(params: APIOrderGetByIdParams): Promise<APIOrderGetByIdResult | null>;
cartUpsert(body: APICartCreateBody): Promise<APICartCreateResult>;
cartRemoveItem(params: {
cartId: string;
variantId: string;
}): Promise<null>;
cartGet(params: {
cartId: string;
}): Promise<APICartGetResult | null>;
collectionGet(params: APICollectionGetByIdParams): Promise<APICollectionGetByIdResult | null>;
collectionBrowse(params: APICollectionsBrowseQueryParams): Promise<APICollectionsBrowseResult>;
collectionCreate(body: APICollectionCreateBody): Promise<APICollectionCreateResult>;
collectionImportMemberships(body: APICollectionImportMembershipsBody): Promise<APICollectionImportMembershipsResult>;
categoryGet(params: APICategoryGetByIdParams): Promise<APICategoryGetByIdResult | null>;
categoriesBrowse(params: APICategoriesBrowseQueryParams): Promise<APICategoriesBrowseResult>;
postBrowse(params?: APIPostsBrowseQueryParams): Promise<APIPostsBrowseResult>;
postGet(params: APIPostGetByIdParams): Promise<APIPostGetByIdResult | null>;
postCreate(body: APIPostCreateBody): Promise<APIPostCreateResult>;
postUpdate(params: APIPostGetByIdParams, body: APIPostUpdateBody): Promise<APIPostUpdateResult>;
postDelete(params: APIPostGetByIdParams): Promise<APIPostDeleteResult>;
postCommentsBrowse(params: APIPostGetByIdParams, queryParams?: APIPostCommentsBrowseQueryParams): Promise<APIPostCommentsBrowseResult>;
postCommentCreate(params: APIPostGetByIdParams, body: APIPostCommentCreateBody): Promise<APIPostCommentCreateResult>;
blogCategoryBrowse(params?: APIBlogCategoriesBrowseQueryParams): Promise<APIBlogCategoriesBrowseResult>;
blogCategoryGet(params: APIBlogCategoryGetByIdParams): Promise<APIBlogCategoryGetByIdResult | null>;
customerBrowse(params?: APICustomersBrowseQueryParams): Promise<APICustomersBrowseResult>;
customerGet(params: APICustomerGetByIdParams): Promise<APICustomerGetByIdResult | null>;
customerUpdate(params: APICustomerGetByIdParams, body: APICustomerUpdateBody): Promise<APICustomerUpdateResult>;
customerAddressCreate(params: APICustomerGetByIdParams, body: APICustomerAddressCreateBody): Promise<APICustomerAddressCreateResult>;
customerAddressDelete(params: {
customerId: string;
addressId: string;
}): Promise<void>;
customerOrdersBrowse(params: APICustomerGetByIdParams, queryParams?: APICustomerOrdersBrowseQueryParams): Promise<APICustomerOrdersBrowseResult>;
inventoryBrowse(params?: APIInventoryBrowseQueryParams): Promise<APIInventoryBrowseResult>;
inventoryAdjust(sku: string, body: APIInventoryAdjustBody): Promise<APIInventoryAdjustResult>;
variantGet(params: APIVariantGetByIdParams): Promise<APIVariantGetByIdResult | null>;
variantUpdate(params: APIVariantGetByIdParams, body: APIVariantUpdateBody): Promise<APIVariantUpdateResult>;
variantDelete(params: APIVariantGetByIdParams): Promise<void>;
variantCreate(productId: string, body: APIVariantCreateBody): Promise<APIVariantCreateResult>;
subscriberCreate(body: APISubscriberCreateBody): Promise<APISubscriberCreateResult>;
subscriberDelete(email: string): Promise<APISubscriberDeleteResult>;
contactMessageCreate(body: APIContactMessageCreateBody): Promise<APIContactMessageCreateResult>;
productCreate(body: APIProductCreateBody): Promise<APIProductCreateResult>;
productUpdate(params: APIProductGetByIdParams, body: APIProductUpdateBody): Promise<APIProductUpdateResult>;
productDelete(params: APIProductGetByIdParams): Promise<APIProductDeleteResult>;
productReviewsBrowse(params: APIProductGetByIdParams, queryParams?: APIProductReviewsBrowseQueryParams): Promise<APIProductReviewsBrowseResult>;
productReviewCreate(params: APIProductGetByIdParams, body: APIProductReviewCreateBody): Promise<APIProductReviewCreateResult>;
categoryCreate(body: APICategoryCreateBody): Promise<APICategoryCreateResult>;
categoryUpdate(params: APICategoryGetByIdParams, body: APICategoryUpdateBody): Promise<APICategoryUpdateResult>;
orderUpdate(params: APIOrderGetByIdParams, body: APIOrderUpdateBody): Promise<APIOrderUpdateResult>;
legalPageBrowse(): Promise<APILegalPagesBrowseResult>;
legalPageGet(path: string): Promise<APILegalPageGetByPathResult>;
search(params: APISearchQueryParams): Promise<APISearchResult>;
instaviewImagesBrowse(params: APIInstaviewImagesBrowseParams, queryParams?: APIInstaviewImagesBrowseQueryParams): Promise<APIInstaviewImagesBrowseResult>;
/**
* Make a raw API request to any endpoint.
* Use this for new API features not yet supported by typed methods.
*
* @example
* // GET request (default method)
* const webhooks = await provider.request<Webhook[]>('/webhooks');
*
* // POST with typed body
* const webhook = await provider.request<Webhook, CreateWebhookBody>('/webhooks', {
* method: 'POST',
* body: { url: 'https://...' }
* });
*
* // GET with query parameters
* const products = await provider.request<Product[]>('/products', {
* query: { limit: 10, category: 'shoes' }
* });
*
* // Path parameters via template literals
* const product = await provider.request<Product>(`/products/${id}`);
*/
request<TResponse = unknown, TBody = unknown>(pathname: `/${string}`, options?: {
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
body?: TBody;
query?: Record<string, string | number | boolean>;
}): Promise<TResponse>;
}
declare function Commerce(config?: CommerceConfig): YNSProvider;
export { APIBlogCategoriesBrowseQueryParams, APIBlogCategoriesBrowseResult, APIBlogCategoryGetByIdParams, APIBlogCategoryGetByIdResult, APICartCreateBody, APICartCreateResult, APICartGetResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APICategoryCreateBody, APICategoryCreateResult, APICategoryGetByIdParams, APICategoryGetByIdResult, APICategoryUpdateBody, APICategoryUpdateResult, APICollectionCreateBody, APICollectionCreateResult, APICollectionGetByIdParams, APICollectionGetByIdResult, type APICollectionImportMembershipsBody, type APICollectionImportMembershipsResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APIContactMessageCreateBody, APIContactMessageCreateResult, APICustomerAddressCreateBody, APICustomerAddressCreateResult, APICustomerGetByIdParams, APICustomerGetByIdResult, APICustomerOrdersBrowseQueryParams, APICustomerOrdersBrowseResult, APICustomerUpdateBody, APICustomerUpdateResult, APICustomersBrowseQueryParams, APICustomersBrowseResult, APIInstaviewImagesBrowseParams, APIInstaviewImagesBrowseQueryParams, APIInstaviewImagesBrowseResult, APIInventoryAdjustBody, APIInventoryAdjustResult, APIInventoryBrowseQueryParams, APIInventoryBrowseResult, APILegalPageGetByPathResult, APILegalPagesBrowseResult, APIMeGetResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APIOrderUpdateBody, APIOrderUpdateResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIPostCommentCreateBody, APIPostCommentCreateResult, APIPostCommentsBrowseQueryParams, APIPostCommentsBrowseResult, APIPostCreateBody, APIPostCreateResult, APIPostDeleteResult, APIPostGetByIdParams, APIPostGetByIdResult, APIPostUpdateBody, APIPostUpdateResult, APIPostsBrowseQueryParams, APIPostsBrowseResult, APIProductCreateBody, APIProductCreateResult, APIProductDeleteResult, APIProductGetByIdParams, APIProductGetByIdResult, APIProductReviewCreateBody, APIProductReviewCreateResult, APIProductReviewsBrowseQueryParams, APIProductReviewsBrowseResult, APIProductUpdateBody, APIProductUpdateResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, APISearchQueryParams, APISearchResult, APISubscriberCreateBody, APISubscriberCreateResult, APISubscriberDeleteResult, APIVariantCreateBody, APIVariantCreateResult, APIVariantGetByIdParams, APIVariantGetByIdResult, APIVariantUpdateBody, APIVariantUpdateResult, Commerce, type CommerceConfig, YNSProvider };