@commercengine/pos 0.4.1 → 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.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("Price range:", data.facet_stats.price_range);
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.name} - ${sku.price}`);
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
- * filters: { category: ["computers"] }
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 - Product ID or slug
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
- * { product_id_or_slug: "prod_123" }
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.price);
2165
- * console.log("Description:", data.product.description);
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
- * product_id_or_slug: "detox-candy"
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
- * { product_id_or_slug: "detox-candy" },
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/{product_id_or_slug}", { params: {
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 - Product ID
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.price}`);
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 - Product ID and variant ID
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.price);
2284
- * console.log("Stock:", data.variant.stock);
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
  * }