@atomic-solutions/woocommerce-api-client 0.5.1 → 0.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.
@@ -1,4 +1,4 @@
1
- import { S as StoreApiVersion, C as CartHeadersAdapter, J as JwtTokenAdapter } from '../types-9I6oS_83.mjs';
1
+ import { S as StoreApiVersion, C as CartHeadersAdapter, J as JwtTokenAdapter } from '../types-Tf-Yd0qB.mjs';
2
2
  import 'axios';
3
3
  import '@atomic-solutions/errors';
4
4
  import 'zod';
@@ -1,4 +1,4 @@
1
- import { S as StoreApiVersion, C as CartHeadersAdapter, J as JwtTokenAdapter } from '../types-9I6oS_83.js';
1
+ import { S as StoreApiVersion, C as CartHeadersAdapter, J as JwtTokenAdapter } from '../types-Tf-Yd0qB.js';
2
2
  import 'axios';
3
3
  import '@atomic-solutions/errors';
4
4
  import 'zod';
@@ -1036,6 +1036,10 @@ zod.z.object({
1036
1036
  zod.z.object({
1037
1037
  code: zod.z.string().min(1)
1038
1038
  });
1039
+ zod.z.object({
1040
+ namespace: zod.z.string().min(1),
1041
+ data: zod.z.record(zod.z.string(), zod.z.unknown())
1042
+ });
1039
1043
  zod.z.object({
1040
1044
  billing_address: billingAddressSchemaMandatory.partial(),
1041
1045
  shipping_address: addressSchema.partial()
@@ -1268,11 +1272,13 @@ var checkoutSchema = zod.z.object({
1268
1272
  billing_address: billingAddressSchemaNonMandatory,
1269
1273
  shipping_address: addressSchemaNonMandatory,
1270
1274
  payment_method: zod.z.string(),
1275
+ // Null until an order is placed.
1276
+ // GET /checkout returns null here, so the schema must accept it.
1271
1277
  payment_result: zod.z.object({
1272
1278
  payment_status: zod.z.string(),
1273
1279
  payment_details: zod.z.array(zod.z.unknown()),
1274
1280
  redirect_url: zod.z.string()
1275
- })
1281
+ }).nullable()
1276
1282
  });
1277
1283
  zod.z.object({
1278
1284
  payment_method: zod.z.string(),
@@ -1374,6 +1380,14 @@ var productSchema = zod.z.object({
1374
1380
  review_count: zod.z.number(),
1375
1381
  extensions: zod.z.record(zod.z.string(), zod.z.unknown())
1376
1382
  });
1383
+ var productTagSchema = zod.z.object({
1384
+ /** Tag unique identifier */
1385
+ id: zod.z.number(),
1386
+ /** Tag display name, e.g. "Vichy decembar 2025" */
1387
+ name: zod.z.string(),
1388
+ /** URL-friendly tag identifier */
1389
+ slug: zod.z.string()
1390
+ });
1377
1391
  zod.z.object({
1378
1392
  /** Attribution source type (e.g., 'mobile_app', 'organic', 'referral') */
1379
1393
  source_type: zod.z.string(),
@@ -1465,6 +1479,11 @@ var createCartAPI = (client, endpoints, options) => ({
1465
1479
  const response = await client.post(endpoints.removeCoupon, input);
1466
1480
  return handleApiResponse(response, cartSchema, options);
1467
1481
  },
1482
+ // Same request headers (Nonce / Cart-Token / Bearer) as every cart POST.
1483
+ updateExtensions: async (input) => {
1484
+ const response = await client.post(endpoints.updateExtensions, input);
1485
+ return handleApiResponse(response, cartSchema, options);
1486
+ },
1468
1487
  updateCustomer: async (input) => {
1469
1488
  const response = await client.post(endpoints.updateCustomer, input);
1470
1489
  return handleApiResponse(response, cartSchema, options);
@@ -1519,6 +1538,14 @@ var createProductsAPI = (client, endpoints, options) => ({
1519
1538
  categories: async () => {
1520
1539
  const response = await client.get(endpoints.categories);
1521
1540
  return handleApiResponse(response, zod.z.array(productCategorySchema), options);
1541
+ },
1542
+ // Tags, e.g. GET /products/tags?include=996,683.
1543
+ // The Store API wants include as a comma list, so join the ids.
1544
+ tags: async (params) => {
1545
+ const response = await client.get(endpoints.tags, {
1546
+ params: { include: params?.include?.join(",") }
1547
+ });
1548
+ return handleApiResponse(response, zod.z.array(productTagSchema), options);
1522
1549
  }
1523
1550
  });
1524
1551
 
@@ -1529,6 +1556,8 @@ var createEndpoints = (version = "legacy") => {
1529
1556
  // Products
1530
1557
  products: `${prefix}/products`,
1531
1558
  categories: `${prefix}/products/categories`,
1559
+ // Product tags, e.g. to turn a tag id into its name
1560
+ tags: `${prefix}/products/tags`,
1532
1561
  // Cart
1533
1562
  cart: `${prefix}/cart`,
1534
1563
  addItem: `${prefix}/cart/add-item`,
@@ -1536,6 +1565,8 @@ var createEndpoints = (version = "legacy") => {
1536
1565
  removeItem: `${prefix}/cart/remove-item`,
1537
1566
  applyCoupon: `${prefix}/cart/apply-coupon`,
1538
1567
  removeCoupon: `${prefix}/cart/remove-coupon`,
1568
+ // Plugins change the cart through this one route (e.g. points discounts).
1569
+ updateExtensions: `${prefix}/cart/extensions`,
1539
1570
  updateCustomer: `${prefix}/cart/update-customer`,
1540
1571
  selectShippingRate: `${prefix}/cart/select-shipping-rate`,
1541
1572
  // Batch