@commercengine/pos 0.4.2 → 0.4.3
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 +132 -44
- package/dist/index.mjs +71 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -570,7 +570,7 @@ interface paths {
|
|
|
570
570
|
patch?: never;
|
|
571
571
|
trace?: never;
|
|
572
572
|
};
|
|
573
|
-
"/pos/catalog/products/{
|
|
573
|
+
"/pos/catalog/products/{product_id}": {
|
|
574
574
|
parameters: {
|
|
575
575
|
query?: never;
|
|
576
576
|
header?: never;
|
|
@@ -579,7 +579,7 @@ interface paths {
|
|
|
579
579
|
};
|
|
580
580
|
/**
|
|
581
581
|
* Retrieve a product detail
|
|
582
|
-
* @description Retrieves the details of an existing product.
|
|
582
|
+
* @description Retrieves the details of an existing product. Product slug is supported in place of product ID in the path. Commerce Engine returns the corresponding product information.
|
|
583
583
|
*/
|
|
584
584
|
get: operations["pos-get-product-detail"];
|
|
585
585
|
put?: never;
|
|
@@ -619,7 +619,7 @@ interface paths {
|
|
|
619
619
|
};
|
|
620
620
|
/**
|
|
621
621
|
* Retrieve product variants
|
|
622
|
-
* @description Retrieves the variants of an existing product.
|
|
622
|
+
* @description Retrieves the variants of an existing product. Product slug is supported in place of product ID in the path. Commerce Engine returns the corresponding product variants information.
|
|
623
623
|
*/
|
|
624
624
|
get: operations["pos-list-product-variants"];
|
|
625
625
|
put?: never;
|
|
@@ -639,7 +639,7 @@ interface paths {
|
|
|
639
639
|
};
|
|
640
640
|
/**
|
|
641
641
|
* Retrieve variant detail
|
|
642
|
-
* @description Retrieves the details of a particular variant.
|
|
642
|
+
* @description Retrieves the details of a particular variant. Product slug is supported in place of product ID, and variant slug in place of variant ID, in the path.
|
|
643
643
|
*/
|
|
644
644
|
get: operations["pos-get-variant-detail"];
|
|
645
645
|
put?: never;
|
|
@@ -1576,7 +1576,8 @@ interface components {
|
|
|
1576
1576
|
product_id: string;
|
|
1577
1577
|
variant_id: string | null;
|
|
1578
1578
|
sku: string;
|
|
1579
|
-
|
|
1579
|
+
product_slug: string;
|
|
1580
|
+
variant_slug: string;
|
|
1580
1581
|
product_name: string;
|
|
1581
1582
|
variant_name: string | null;
|
|
1582
1583
|
/**
|
|
@@ -1590,7 +1591,8 @@ interface components {
|
|
|
1590
1591
|
backorder?: boolean;
|
|
1591
1592
|
on_subscription: boolean;
|
|
1592
1593
|
on_promotion: boolean;
|
|
1593
|
-
category_ids: string[];
|
|
1594
|
+
category_ids: string[]; /** @description Expanded category objects. */
|
|
1595
|
+
categories?: components["schemas"]["Category"][];
|
|
1594
1596
|
tags: string[] | null;
|
|
1595
1597
|
reviews_count: number;
|
|
1596
1598
|
reviews_rating_sum: number | null;
|
|
@@ -2209,17 +2211,55 @@ interface components {
|
|
|
2209
2211
|
* @description Maximum number of records returned for a page.
|
|
2210
2212
|
* @default 25
|
|
2211
2213
|
*/
|
|
2212
|
-
limit: number;
|
|
2214
|
+
limit: number; /** @description provide list of attributes for specific facets or * for all facets. All attributes supported in the filter parameter are also supported here. */
|
|
2215
|
+
facets?: string[];
|
|
2213
2216
|
/**
|
|
2214
|
-
* @description
|
|
2215
|
-
*
|
|
2216
|
-
*
|
|
2217
|
-
*
|
|
2218
|
-
*
|
|
2219
|
-
*
|
|
2220
|
-
*
|
|
2217
|
+
* @description Filter expression(s) to narrow results. Omit for no filtering.
|
|
2218
|
+
*
|
|
2219
|
+
* **Syntax:** `attribute OPERATOR value`
|
|
2220
|
+
*
|
|
2221
|
+
* **Operators:**
|
|
2222
|
+
*
|
|
2223
|
+
* | Operator | Description | Example |
|
|
2224
|
+
* |---|---|---|
|
|
2225
|
+
* | `=` | Equal to | `product_type = physical` |
|
|
2226
|
+
* | `!=` | Not equal to | `product_type != bundle` |
|
|
2227
|
+
* | `>`, `>=`, `<`, `<=` | Comparison | `rating > 4` |
|
|
2228
|
+
* | `TO` | Inclusive range (`>=` AND `<=`) | `pricing.selling_price 100 TO 500` |
|
|
2229
|
+
* | `IN [...]` | Matches any value in the list | `product_type IN [physical,bundle]` |
|
|
2230
|
+
* | `NOT IN [...]` | Excludes all values in the list | `product_type NOT IN [physical,bundle]` |
|
|
2231
|
+
* | `EXISTS` | Attribute is present (even if `null` or empty) | `tags EXISTS` |
|
|
2232
|
+
* | `NOT EXISTS` | Attribute is absent | `tags NOT EXISTS` |
|
|
2233
|
+
* | `IS NULL` | Value is `null` | `variant_id IS NULL` |
|
|
2234
|
+
* | `IS NOT NULL` | Value is not `null` | `variant_id IS NOT NULL` |
|
|
2235
|
+
* | `IS EMPTY` | Value is `""`, `[]`, or `{}` | `tags IS EMPTY` |
|
|
2236
|
+
* | `IS NOT EMPTY` | Value is not empty | `tags IS NOT EMPTY` |
|
|
2237
|
+
* | `AND` | Both conditions must match | `rating > 4 AND product_type = physical` |
|
|
2238
|
+
* | `OR` | Either condition must match | `product_type = physical OR product_type = bundle` |
|
|
2239
|
+
* | `NOT` | Negates a condition | `NOT product_type = bundle` |
|
|
2240
|
+
*
|
|
2241
|
+
* **Important rules:**
|
|
2242
|
+
* - Operators are **case-sensitive** — must be uppercase (`AND`, not `and`).
|
|
2243
|
+
* - String value comparison is **case-insensitive** — `product_type = Physical` matches `physical`.
|
|
2244
|
+
* - Operator precedence: `NOT` > `AND` > `OR`. Use parentheses to override.
|
|
2245
|
+
* - String values containing whitespace must be wrapped in single quotes.
|
|
2246
|
+
* - `IN` takes comma-separated values in square brackets.
|
|
2247
|
+
* - Maximum array nesting depth is **2 levels**.
|
|
2248
|
+
*
|
|
2249
|
+
* **Supported attributes:** `product_type`, `categories.name`, `attributes.key`, `pricing.listing_price`, `pricing.selling_price`, `pricing.tax_rate`, `product_id`, `variant_id`, `product_name`, `variant_name`, `tags`, `sku`, `stock_available`, `rating`
|
|
2250
|
+
*
|
|
2251
|
+
* **Combining conditions:**
|
|
2252
|
+
* - **String:** Use `AND`/`OR` operators inline — `"rating > 4 AND product_type = physical"`
|
|
2253
|
+
* - **Array of strings:** Conditions are combined with AND — `["rating > 4", "product_type = physical"]`
|
|
2254
|
+
* - **Nested arrays:** Inner arrays express OR, outer array expresses AND — `["product_type = physical", ["product_type = bundle", "rating > 4"]]`
|
|
2221
2255
|
*/
|
|
2222
|
-
|
|
2256
|
+
filter?: string | (string | string[])[];
|
|
2257
|
+
/**
|
|
2258
|
+
* @description Sort results by attributes. Use `asc` for ascending order and `desc` for descending order.
|
|
2259
|
+
* @example product_type:desc
|
|
2260
|
+
* @example product_name:asc
|
|
2261
|
+
*/
|
|
2262
|
+
sort?: string[];
|
|
2223
2263
|
}; /** SellerInfo */
|
|
2224
2264
|
SellerInfo: {
|
|
2225
2265
|
id: string;
|
|
@@ -2229,7 +2269,6 @@ interface components {
|
|
|
2229
2269
|
tax_identification_number: string;
|
|
2230
2270
|
}; /** Seo */
|
|
2231
2271
|
Seo: {
|
|
2232
|
-
slug: string;
|
|
2233
2272
|
title: string | null;
|
|
2234
2273
|
description: string | null;
|
|
2235
2274
|
keywords: string[] | null;
|
|
@@ -3557,7 +3596,7 @@ interface operations {
|
|
|
3557
3596
|
/** @description This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned. */"x-customer-group-id"?: components["parameters"]["CustomerGroupId"];
|
|
3558
3597
|
};
|
|
3559
3598
|
path: {
|
|
3560
|
-
/** @description
|
|
3599
|
+
/** @description Product ID or product slug. Either is accepted in the path. */product_id: string;
|
|
3561
3600
|
};
|
|
3562
3601
|
cookie?: never;
|
|
3563
3602
|
};
|
|
@@ -3627,7 +3666,7 @@ interface operations {
|
|
|
3627
3666
|
/** @description This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned. */"x-customer-group-id"?: components["parameters"]["CustomerGroupId"];
|
|
3628
3667
|
};
|
|
3629
3668
|
path: {
|
|
3630
|
-
/** @description ID
|
|
3669
|
+
/** @description Product ID or product slug. Either is accepted in the path. */product_id: string;
|
|
3631
3670
|
};
|
|
3632
3671
|
cookie?: never;
|
|
3633
3672
|
};
|
|
@@ -3660,7 +3699,7 @@ interface operations {
|
|
|
3660
3699
|
/** @description This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned. */"x-customer-group-id"?: components["parameters"]["CustomerGroupId"];
|
|
3661
3700
|
};
|
|
3662
3701
|
path: {
|
|
3663
|
-
/** @description product
|
|
3702
|
+
/** @description Product ID or product slug. Either is accepted in the path. */product_id: string; /** @description Variant ID or variant slug. Either is accepted in the path. */
|
|
3664
3703
|
variant_id: string;
|
|
3665
3704
|
};
|
|
3666
3705
|
cookie?: never;
|
|
@@ -6711,11 +6750,11 @@ type PosListUpsellProductsResponse = Readable<paths['/pos/catalog/products/up-se
|
|
|
6711
6750
|
type PosListUpsellProductsContent = PosListUpsellProductsResponse['content'];
|
|
6712
6751
|
type PosListUpsellProductsQuery = paths['/pos/catalog/products/up-sell']['get']['parameters']['query'];
|
|
6713
6752
|
type PosListUpsellProductsHeaderParams = paths['/pos/catalog/products/up-sell']['get']['parameters']['header'];
|
|
6714
|
-
type PosGetProductDetailResponse = Readable<paths['/pos/catalog/products/{
|
|
6753
|
+
type PosGetProductDetailResponse = Readable<paths['/pos/catalog/products/{product_id}']['get']['responses'][200]['content']['application/json']>;
|
|
6715
6754
|
type PosGetProductDetailContent = PosGetProductDetailResponse['content'];
|
|
6716
|
-
type PosGetProductDetailQuery = paths['/pos/catalog/products/{
|
|
6717
|
-
type PosGetProductDetailPathParams = paths['/pos/catalog/products/{
|
|
6718
|
-
type PosGetProductDetailHeaderParams = paths['/pos/catalog/products/{
|
|
6755
|
+
type PosGetProductDetailQuery = paths['/pos/catalog/products/{product_id}']['get']['parameters']['query'];
|
|
6756
|
+
type PosGetProductDetailPathParams = paths['/pos/catalog/products/{product_id}']['get']['parameters']['path'];
|
|
6757
|
+
type PosGetProductDetailHeaderParams = paths['/pos/catalog/products/{product_id}']['get']['parameters']['header'];
|
|
6719
6758
|
type PosListProductReviewsResponse = Readable<paths['/pos/catalog/products/{product_id}/reviews']['get']['responses'][200]['content']['application/json']>;
|
|
6720
6759
|
type PosListProductReviewsContent = PosListProductReviewsResponse['content'];
|
|
6721
6760
|
type PosListProductReviewsQuery = paths['/pos/catalog/products/{product_id}/reviews']['get']['parameters']['query'];
|
|
@@ -7695,16 +7734,12 @@ declare class PosClient extends PosAPIClient {
|
|
|
7695
7734
|
* Search products
|
|
7696
7735
|
* @param body - Search criteria and parameters
|
|
7697
7736
|
* @param headers - Optional header parameters
|
|
7698
|
-
* @returns Promise with search results
|
|
7737
|
+
* @returns Promise with search results including SKUs, facet distribution, facet stats, and pagination
|
|
7699
7738
|
* @example
|
|
7700
7739
|
* ```typescript
|
|
7740
|
+
* // Basic search
|
|
7701
7741
|
* const { data, error } = await pos.searchProducts({
|
|
7702
7742
|
* query: "smartphone",
|
|
7703
|
-
* filters: {
|
|
7704
|
-
* category: ["electronics", "mobile"],
|
|
7705
|
-
* price_range: { min: 100, max: 1000 },
|
|
7706
|
-
* brand: ["Apple", "Samsung"] // facet names depend on product configuration
|
|
7707
|
-
* },
|
|
7708
7743
|
* page: 1,
|
|
7709
7744
|
* limit: 20
|
|
7710
7745
|
* });
|
|
@@ -7714,17 +7749,52 @@ declare class PosClient extends PosAPIClient {
|
|
|
7714
7749
|
* } else {
|
|
7715
7750
|
* console.log("Search results:", data.skus?.length || 0, "products found");
|
|
7716
7751
|
* console.log("Facet distribution:", data.facet_distribution);
|
|
7717
|
-
* console.log("
|
|
7752
|
+
* console.log("Facet stats:", data.facet_stats);
|
|
7753
|
+
* console.log("Pagination:", data.pagination);
|
|
7754
|
+
*
|
|
7718
7755
|
* data.skus?.forEach(sku => {
|
|
7719
|
-
* console.log(`Found: ${sku.
|
|
7756
|
+
* console.log(`Found: ${sku.product_name} - ${sku.pricing?.selling_price}`);
|
|
7720
7757
|
* });
|
|
7721
7758
|
* }
|
|
7722
7759
|
*
|
|
7760
|
+
* // With filter (string expression — Meilisearch syntax)
|
|
7761
|
+
* const { data: filtered, error: filteredError } = await pos.searchProducts({
|
|
7762
|
+
* query: "laptop",
|
|
7763
|
+
* filter: "pricing.selling_price 500 TO 2000 AND product_type = physical",
|
|
7764
|
+
* sort: ["pricing.selling_price:asc"],
|
|
7765
|
+
* facets: ["product_type", "categories.name", "tags"],
|
|
7766
|
+
* page: 1,
|
|
7767
|
+
* limit: 10
|
|
7768
|
+
* });
|
|
7769
|
+
*
|
|
7770
|
+
* // With filter (array of conditions — combined with AND)
|
|
7771
|
+
* const { data: arrayFiltered, error: arrayError } = await pos.searchProducts({
|
|
7772
|
+
* query: "shoes",
|
|
7773
|
+
* filter: ["product_type = physical", "rating >= 4", "stock_available > 0"],
|
|
7774
|
+
* sort: ["rating:desc"],
|
|
7775
|
+
* facets: ["*"],
|
|
7776
|
+
* page: 1,
|
|
7777
|
+
* limit: 25
|
|
7778
|
+
* });
|
|
7779
|
+
*
|
|
7780
|
+
* // With filter (nested arrays — inner arrays use OR, outer uses AND)
|
|
7781
|
+
* const { data: nestedFiltered, error: nestedError } = await pos.searchProducts({
|
|
7782
|
+
* query: "headphones",
|
|
7783
|
+
* filter: [
|
|
7784
|
+
* "pricing.selling_price 50 TO 300",
|
|
7785
|
+
* ["product_type = physical", "product_type = bundle"]
|
|
7786
|
+
* ],
|
|
7787
|
+
* page: 1,
|
|
7788
|
+
* limit: 25
|
|
7789
|
+
* });
|
|
7790
|
+
*
|
|
7723
7791
|
* // Override customer group ID for this specific request
|
|
7724
7792
|
* const { data: overrideData, error: overrideError } = await pos.searchProducts(
|
|
7725
7793
|
* {
|
|
7726
7794
|
* query: "laptop",
|
|
7727
|
-
*
|
|
7795
|
+
* filter: "categories.name = computers",
|
|
7796
|
+
* page: 1,
|
|
7797
|
+
* limit: 20
|
|
7728
7798
|
* },
|
|
7729
7799
|
* {
|
|
7730
7800
|
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|
|
@@ -7823,32 +7893,33 @@ declare class PosClient extends PosAPIClient {
|
|
|
7823
7893
|
listUpsellProducts(query: PosListUpsellProductsQuery, headers?: PosListUpsellProductsHeaderParams): Promise<ApiResult<PosListUpsellProductsContent>>;
|
|
7824
7894
|
/**
|
|
7825
7895
|
* Get product details
|
|
7826
|
-
* @param pathParams -
|
|
7896
|
+
* @param pathParams - The path parameters. Accepts product ID or product slug.
|
|
7827
7897
|
* @param headers - Optional header parameters
|
|
7828
7898
|
* @returns Promise with product details
|
|
7829
7899
|
* @example
|
|
7830
7900
|
* ```typescript
|
|
7831
7901
|
* // Get product by ID
|
|
7832
7902
|
* const { data, error } = await pos.getProductDetail(
|
|
7833
|
-
* {
|
|
7903
|
+
* { product_id: "prod_123" }
|
|
7834
7904
|
* );
|
|
7835
7905
|
*
|
|
7836
7906
|
* if (error) {
|
|
7837
7907
|
* console.error("Failed to get product details:", error.message);
|
|
7838
7908
|
* } else {
|
|
7839
7909
|
* console.log("Product:", data.product.name);
|
|
7840
|
-
* console.log("Price:", data.product.
|
|
7841
|
-
* console.log("Description:", data.product.
|
|
7910
|
+
* console.log("Price:", data.product.pricing?.selling_price);
|
|
7911
|
+
* console.log("Description:", data.product.short_description);
|
|
7842
7912
|
* }
|
|
7843
7913
|
*
|
|
7844
|
-
* // Get product by slug
|
|
7914
|
+
* // Get product by slug (also accepted in place of product_id)
|
|
7845
7915
|
* const { data: slugData, error: slugError } = await pos.getProductDetail({
|
|
7846
|
-
*
|
|
7916
|
+
* product_id: "detox-candy"
|
|
7847
7917
|
* });
|
|
7848
7918
|
*
|
|
7849
7919
|
* // Override customer group ID for this specific request
|
|
7850
7920
|
* const { data: overrideData, error: overrideError } = await pos.getProductDetail(
|
|
7851
|
-
* {
|
|
7921
|
+
* { product_id: "detox-candy" },
|
|
7922
|
+
* undefined,
|
|
7852
7923
|
* {
|
|
7853
7924
|
* "x-customer-group-id": "premium_customers" // Override default SDK config
|
|
7854
7925
|
* }
|
|
@@ -7890,11 +7961,12 @@ declare class PosClient extends PosAPIClient {
|
|
|
7890
7961
|
listProductReviews(pathParams: PosListProductReviewsPathParams, query?: PosListProductReviewsQuery): Promise<ApiResult<PosListProductReviewsContent>>;
|
|
7891
7962
|
/**
|
|
7892
7963
|
* List product variants
|
|
7893
|
-
* @param pathParams -
|
|
7964
|
+
* @param pathParams - The path parameters. Accepts product ID or product slug.
|
|
7894
7965
|
* @param headers - Optional header parameters
|
|
7895
7966
|
* @returns Promise with product variants
|
|
7896
7967
|
* @example
|
|
7897
7968
|
* ```typescript
|
|
7969
|
+
* // By product ID
|
|
7898
7970
|
* const { data, error } = await pos.listProductVariants(
|
|
7899
7971
|
* { product_id: "prod_123" }
|
|
7900
7972
|
* );
|
|
@@ -7904,13 +7976,19 @@ declare class PosClient extends PosAPIClient {
|
|
|
7904
7976
|
* } else {
|
|
7905
7977
|
* console.log("Variants found:", data.variants?.length || 0);
|
|
7906
7978
|
* data.variants?.forEach(variant => {
|
|
7907
|
-
* console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.
|
|
7979
|
+
* console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.pricing?.selling_price}`);
|
|
7908
7980
|
* });
|
|
7909
7981
|
* }
|
|
7910
7982
|
*
|
|
7983
|
+
* // By product slug (also accepted in place of product_id)
|
|
7984
|
+
* const { data: slugData, error: slugError } = await pos.listProductVariants(
|
|
7985
|
+
* { product_id: "detox-candy" }
|
|
7986
|
+
* );
|
|
7987
|
+
*
|
|
7911
7988
|
* // Override customer group ID for this specific request
|
|
7912
7989
|
* const { data: overrideData, error: overrideError } = await pos.listProductVariants(
|
|
7913
7990
|
* { product_id: "prod_123" },
|
|
7991
|
+
* undefined,
|
|
7914
7992
|
* {
|
|
7915
7993
|
* "x-customer-group-id": "wholesale_customers" // Override default SDK config
|
|
7916
7994
|
* }
|
|
@@ -7920,11 +7998,12 @@ declare class PosClient extends PosAPIClient {
|
|
|
7920
7998
|
listProductVariants(pathParams: PosListProductVariantsPathParams, query?: PosListProductVariantsQuery, headers?: PosListProductVariantsHeaderParams): Promise<ApiResult<PosListProductVariantsContent>>;
|
|
7921
7999
|
/**
|
|
7922
8000
|
* Get variant details
|
|
7923
|
-
* @param pathParams -
|
|
8001
|
+
* @param pathParams - The path parameters. Accepts product ID or slug for product_id, and variant ID or slug for variant_id.
|
|
7924
8002
|
* @param headers - Optional header parameters
|
|
7925
8003
|
* @returns Promise with variant details
|
|
7926
8004
|
* @example
|
|
7927
8005
|
* ```typescript
|
|
8006
|
+
* // By product ID and variant ID
|
|
7928
8007
|
* const { data, error } = await pos.getVariantDetail(
|
|
7929
8008
|
* {
|
|
7930
8009
|
* product_id: "prod_123",
|
|
@@ -7937,16 +8016,25 @@ declare class PosClient extends PosAPIClient {
|
|
|
7937
8016
|
* } else {
|
|
7938
8017
|
* console.log("Variant:", data.variant.name);
|
|
7939
8018
|
* console.log("SKU:", data.variant.sku);
|
|
7940
|
-
* console.log("Price:", data.variant.
|
|
7941
|
-
* console.log("Stock:", data.variant.
|
|
8019
|
+
* console.log("Price:", data.variant.pricing?.selling_price);
|
|
8020
|
+
* console.log("Stock available:", data.variant.stock_available);
|
|
7942
8021
|
* }
|
|
7943
8022
|
*
|
|
8023
|
+
* // By product slug and variant slug (also accepted in place of IDs)
|
|
8024
|
+
* const { data: slugData, error: slugError } = await pos.getVariantDetail(
|
|
8025
|
+
* {
|
|
8026
|
+
* product_id: "detox-candy",
|
|
8027
|
+
* variant_id: "detox-candy-100g"
|
|
8028
|
+
* }
|
|
8029
|
+
* );
|
|
8030
|
+
*
|
|
7944
8031
|
* // Override customer group ID for this specific request
|
|
7945
8032
|
* const { data: overrideData, error: overrideError } = await pos.getVariantDetail(
|
|
7946
8033
|
* {
|
|
7947
8034
|
* product_id: "prod_123",
|
|
7948
8035
|
* variant_id: "var_456"
|
|
7949
8036
|
* },
|
|
8037
|
+
* undefined,
|
|
7950
8038
|
* {
|
|
7951
8039
|
* "x-customer-group-id": "wholesale_customers" // Override default SDK config
|
|
7952
8040
|
* }
|
package/dist/index.mjs
CHANGED
|
@@ -2001,16 +2001,12 @@ var PosClient = class extends PosAPIClient {
|
|
|
2001
2001
|
* Search products
|
|
2002
2002
|
* @param body - Search criteria and parameters
|
|
2003
2003
|
* @param headers - Optional header parameters
|
|
2004
|
-
* @returns Promise with search results
|
|
2004
|
+
* @returns Promise with search results including SKUs, facet distribution, facet stats, and pagination
|
|
2005
2005
|
* @example
|
|
2006
2006
|
* ```typescript
|
|
2007
|
+
* // Basic search
|
|
2007
2008
|
* const { data, error } = await pos.searchProducts({
|
|
2008
2009
|
* query: "smartphone",
|
|
2009
|
-
* filters: {
|
|
2010
|
-
* category: ["electronics", "mobile"],
|
|
2011
|
-
* price_range: { min: 100, max: 1000 },
|
|
2012
|
-
* brand: ["Apple", "Samsung"] // facet names depend on product configuration
|
|
2013
|
-
* },
|
|
2014
2010
|
* page: 1,
|
|
2015
2011
|
* limit: 20
|
|
2016
2012
|
* });
|
|
@@ -2020,17 +2016,52 @@ var PosClient = class extends PosAPIClient {
|
|
|
2020
2016
|
* } else {
|
|
2021
2017
|
* console.log("Search results:", data.skus?.length || 0, "products found");
|
|
2022
2018
|
* console.log("Facet distribution:", data.facet_distribution);
|
|
2023
|
-
* console.log("
|
|
2019
|
+
* console.log("Facet stats:", data.facet_stats);
|
|
2020
|
+
* console.log("Pagination:", data.pagination);
|
|
2021
|
+
*
|
|
2024
2022
|
* data.skus?.forEach(sku => {
|
|
2025
|
-
* console.log(`Found: ${sku.
|
|
2023
|
+
* console.log(`Found: ${sku.product_name} - ${sku.pricing?.selling_price}`);
|
|
2026
2024
|
* });
|
|
2027
2025
|
* }
|
|
2028
2026
|
*
|
|
2027
|
+
* // With filter (string expression — Meilisearch syntax)
|
|
2028
|
+
* const { data: filtered, error: filteredError } = await pos.searchProducts({
|
|
2029
|
+
* query: "laptop",
|
|
2030
|
+
* filter: "pricing.selling_price 500 TO 2000 AND product_type = physical",
|
|
2031
|
+
* sort: ["pricing.selling_price:asc"],
|
|
2032
|
+
* facets: ["product_type", "categories.name", "tags"],
|
|
2033
|
+
* page: 1,
|
|
2034
|
+
* limit: 10
|
|
2035
|
+
* });
|
|
2036
|
+
*
|
|
2037
|
+
* // With filter (array of conditions — combined with AND)
|
|
2038
|
+
* const { data: arrayFiltered, error: arrayError } = await pos.searchProducts({
|
|
2039
|
+
* query: "shoes",
|
|
2040
|
+
* filter: ["product_type = physical", "rating >= 4", "stock_available > 0"],
|
|
2041
|
+
* sort: ["rating:desc"],
|
|
2042
|
+
* facets: ["*"],
|
|
2043
|
+
* page: 1,
|
|
2044
|
+
* limit: 25
|
|
2045
|
+
* });
|
|
2046
|
+
*
|
|
2047
|
+
* // With filter (nested arrays — inner arrays use OR, outer uses AND)
|
|
2048
|
+
* const { data: nestedFiltered, error: nestedError } = await pos.searchProducts({
|
|
2049
|
+
* query: "headphones",
|
|
2050
|
+
* filter: [
|
|
2051
|
+
* "pricing.selling_price 50 TO 300",
|
|
2052
|
+
* ["product_type = physical", "product_type = bundle"]
|
|
2053
|
+
* ],
|
|
2054
|
+
* page: 1,
|
|
2055
|
+
* limit: 25
|
|
2056
|
+
* });
|
|
2057
|
+
*
|
|
2029
2058
|
* // Override customer group ID for this specific request
|
|
2030
2059
|
* const { data: overrideData, error: overrideError } = await pos.searchProducts(
|
|
2031
2060
|
* {
|
|
2032
2061
|
* query: "laptop",
|
|
2033
|
-
*
|
|
2062
|
+
* filter: "categories.name = computers",
|
|
2063
|
+
* page: 1,
|
|
2064
|
+
* limit: 20
|
|
2034
2065
|
* },
|
|
2035
2066
|
* {
|
|
2036
2067
|
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|
|
@@ -2147,32 +2178,33 @@ var PosClient = class extends PosAPIClient {
|
|
|
2147
2178
|
}
|
|
2148
2179
|
/**
|
|
2149
2180
|
* Get product details
|
|
2150
|
-
* @param pathParams -
|
|
2181
|
+
* @param pathParams - The path parameters. Accepts product ID or product slug.
|
|
2151
2182
|
* @param headers - Optional header parameters
|
|
2152
2183
|
* @returns Promise with product details
|
|
2153
2184
|
* @example
|
|
2154
2185
|
* ```typescript
|
|
2155
2186
|
* // Get product by ID
|
|
2156
2187
|
* const { data, error } = await pos.getProductDetail(
|
|
2157
|
-
* {
|
|
2188
|
+
* { product_id: "prod_123" }
|
|
2158
2189
|
* );
|
|
2159
2190
|
*
|
|
2160
2191
|
* if (error) {
|
|
2161
2192
|
* console.error("Failed to get product details:", error.message);
|
|
2162
2193
|
* } else {
|
|
2163
2194
|
* console.log("Product:", data.product.name);
|
|
2164
|
-
* console.log("Price:", data.product.
|
|
2165
|
-
* console.log("Description:", data.product.
|
|
2195
|
+
* console.log("Price:", data.product.pricing?.selling_price);
|
|
2196
|
+
* console.log("Description:", data.product.short_description);
|
|
2166
2197
|
* }
|
|
2167
2198
|
*
|
|
2168
|
-
* // Get product by slug
|
|
2199
|
+
* // Get product by slug (also accepted in place of product_id)
|
|
2169
2200
|
* const { data: slugData, error: slugError } = await pos.getProductDetail({
|
|
2170
|
-
*
|
|
2201
|
+
* product_id: "detox-candy"
|
|
2171
2202
|
* });
|
|
2172
2203
|
*
|
|
2173
2204
|
* // Override customer group ID for this specific request
|
|
2174
2205
|
* const { data: overrideData, error: overrideError } = await pos.getProductDetail(
|
|
2175
|
-
* {
|
|
2206
|
+
* { product_id: "detox-candy" },
|
|
2207
|
+
* undefined,
|
|
2176
2208
|
* {
|
|
2177
2209
|
* "x-customer-group-id": "premium_customers" // Override default SDK config
|
|
2178
2210
|
* }
|
|
@@ -2181,7 +2213,7 @@ var PosClient = class extends PosAPIClient {
|
|
|
2181
2213
|
*/
|
|
2182
2214
|
async getProductDetail(pathParams, query, headers) {
|
|
2183
2215
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
2184
|
-
return this.executeRequest(() => this.client.GET("/pos/catalog/products/{
|
|
2216
|
+
return this.executeRequest(() => this.client.GET("/pos/catalog/products/{product_id}", { params: {
|
|
2185
2217
|
path: pathParams,
|
|
2186
2218
|
query,
|
|
2187
2219
|
header: mergedHeaders
|
|
@@ -2226,11 +2258,12 @@ var PosClient = class extends PosAPIClient {
|
|
|
2226
2258
|
}
|
|
2227
2259
|
/**
|
|
2228
2260
|
* List product variants
|
|
2229
|
-
* @param pathParams -
|
|
2261
|
+
* @param pathParams - The path parameters. Accepts product ID or product slug.
|
|
2230
2262
|
* @param headers - Optional header parameters
|
|
2231
2263
|
* @returns Promise with product variants
|
|
2232
2264
|
* @example
|
|
2233
2265
|
* ```typescript
|
|
2266
|
+
* // By product ID
|
|
2234
2267
|
* const { data, error } = await pos.listProductVariants(
|
|
2235
2268
|
* { product_id: "prod_123" }
|
|
2236
2269
|
* );
|
|
@@ -2240,13 +2273,19 @@ var PosClient = class extends PosAPIClient {
|
|
|
2240
2273
|
* } else {
|
|
2241
2274
|
* console.log("Variants found:", data.variants?.length || 0);
|
|
2242
2275
|
* data.variants?.forEach(variant => {
|
|
2243
|
-
* console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.
|
|
2276
|
+
* console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.pricing?.selling_price}`);
|
|
2244
2277
|
* });
|
|
2245
2278
|
* }
|
|
2246
2279
|
*
|
|
2280
|
+
* // By product slug (also accepted in place of product_id)
|
|
2281
|
+
* const { data: slugData, error: slugError } = await pos.listProductVariants(
|
|
2282
|
+
* { product_id: "detox-candy" }
|
|
2283
|
+
* );
|
|
2284
|
+
*
|
|
2247
2285
|
* // Override customer group ID for this specific request
|
|
2248
2286
|
* const { data: overrideData, error: overrideError } = await pos.listProductVariants(
|
|
2249
2287
|
* { product_id: "prod_123" },
|
|
2288
|
+
* undefined,
|
|
2250
2289
|
* {
|
|
2251
2290
|
* "x-customer-group-id": "wholesale_customers" // Override default SDK config
|
|
2252
2291
|
* }
|
|
@@ -2263,11 +2302,12 @@ var PosClient = class extends PosAPIClient {
|
|
|
2263
2302
|
}
|
|
2264
2303
|
/**
|
|
2265
2304
|
* Get variant details
|
|
2266
|
-
* @param pathParams -
|
|
2305
|
+
* @param pathParams - The path parameters. Accepts product ID or slug for product_id, and variant ID or slug for variant_id.
|
|
2267
2306
|
* @param headers - Optional header parameters
|
|
2268
2307
|
* @returns Promise with variant details
|
|
2269
2308
|
* @example
|
|
2270
2309
|
* ```typescript
|
|
2310
|
+
* // By product ID and variant ID
|
|
2271
2311
|
* const { data, error } = await pos.getVariantDetail(
|
|
2272
2312
|
* {
|
|
2273
2313
|
* product_id: "prod_123",
|
|
@@ -2280,16 +2320,25 @@ var PosClient = class extends PosAPIClient {
|
|
|
2280
2320
|
* } else {
|
|
2281
2321
|
* console.log("Variant:", data.variant.name);
|
|
2282
2322
|
* console.log("SKU:", data.variant.sku);
|
|
2283
|
-
* console.log("Price:", data.variant.
|
|
2284
|
-
* console.log("Stock:", data.variant.
|
|
2323
|
+
* console.log("Price:", data.variant.pricing?.selling_price);
|
|
2324
|
+
* console.log("Stock available:", data.variant.stock_available);
|
|
2285
2325
|
* }
|
|
2286
2326
|
*
|
|
2327
|
+
* // By product slug and variant slug (also accepted in place of IDs)
|
|
2328
|
+
* const { data: slugData, error: slugError } = await pos.getVariantDetail(
|
|
2329
|
+
* {
|
|
2330
|
+
* product_id: "detox-candy",
|
|
2331
|
+
* variant_id: "detox-candy-100g"
|
|
2332
|
+
* }
|
|
2333
|
+
* );
|
|
2334
|
+
*
|
|
2287
2335
|
* // Override customer group ID for this specific request
|
|
2288
2336
|
* const { data: overrideData, error: overrideError } = await pos.getVariantDetail(
|
|
2289
2337
|
* {
|
|
2290
2338
|
* product_id: "prod_123",
|
|
2291
2339
|
* variant_id: "var_456"
|
|
2292
2340
|
* },
|
|
2341
|
+
* undefined,
|
|
2293
2342
|
* {
|
|
2294
2343
|
* "x-customer-group-id": "wholesale_customers" // Override default SDK config
|
|
2295
2344
|
* }
|