@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.
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +32 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +32 -1
- package/dist/client/index.mjs.map +1 -1
- package/dist/http/index.d.mts +2 -2
- package/dist/http/index.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -2
- package/dist/index.mjs.map +1 -1
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +32 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs +32 -1
- package/dist/testing/index.mjs.map +1 -1
- package/dist/{types-9I6oS_83.d.mts → types-Tf-Yd0qB.d.mts} +36 -5
- package/dist/{types-9I6oS_83.d.ts → types-Tf-Yd0qB.d.ts} +36 -5
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/http/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-
|
|
2
|
-
export { P as PaginatedResponse, R as ResponseOptions, V as ValidationMode, h as handleApiData, b as handleApiResponse, c as handlePaginatedApiResponse, i as isZodError, s as setupErrorInterceptor } from '../types-
|
|
1
|
+
import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-Tf-Yd0qB.mjs';
|
|
2
|
+
export { P as PaginatedResponse, R as ResponseOptions, V as ValidationMode, h as handleApiData, b as handleApiResponse, c as handlePaginatedApiResponse, i as isZodError, s as setupErrorInterceptor } from '../types-Tf-Yd0qB.mjs';
|
|
3
3
|
import { AxiosInstance } from 'axios';
|
|
4
4
|
import '@atomic-solutions/errors';
|
|
5
5
|
import 'zod';
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-
|
|
2
|
-
export { P as PaginatedResponse, R as ResponseOptions, V as ValidationMode, h as handleApiData, b as handleApiResponse, c as handlePaginatedApiResponse, i as isZodError, s as setupErrorInterceptor } from '../types-
|
|
1
|
+
import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-Tf-Yd0qB.js';
|
|
2
|
+
export { P as PaginatedResponse, R as ResponseOptions, V as ValidationMode, h as handleApiData, b as handleApiResponse, c as handlePaginatedApiResponse, i as isZodError, s as setupErrorInterceptor } from '../types-Tf-Yd0qB.js';
|
|
3
3
|
import { AxiosInstance } from 'axios';
|
|
4
4
|
import '@atomic-solutions/errors';
|
|
5
5
|
import 'zod';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createClient } from './client/index.mjs';
|
|
2
|
-
import { f as WooCommerceApiErrorCode, B as BaseErrorOptions, g as BaseReportableData, j as ValidationReportableData, k as WooCommerceDataValidationErrorOptions } from './types-
|
|
3
|
-
export { A as AddItemsInput, l as AddItemsResult, m as AddToCartInput, n as BatchResponse, o as Cart, p as CartAPI, C as CartHeadersAdapter,
|
|
2
|
+
import { f as WooCommerceApiErrorCode, B as BaseErrorOptions, g as BaseReportableData, j as ValidationReportableData, k as WooCommerceDataValidationErrorOptions } from './types-Tf-Yd0qB.mjs';
|
|
3
|
+
export { A as AddItemsInput, l as AddItemsResult, m as AddToCartInput, n as BatchResponse, o as Cart, p as CartAPI, q as CartExtensionsInput, C as CartHeadersAdapter, r as CartItem, t as CartItemImage, u as Checkout, v as CheckoutAPI, w as CheckoutInput, x as CouponInput, G as GetOrderInput, J as JwtTokenAdapter, O as OrderStatus, y as OrdersAPI, P as PaginatedResponse, z as Product, D as ProductCategory, E as ProductImage, F as ProductParams, H as ProductTag, I as ProductTagsParams, K as ProductsAPI, L as RemoveCartItemInput, M as SelectShippingRateInput, N as StoreApiOrder, U as UpdateCartItemInput, Q as UpdateCustomerInput, T as WooCommerceApiError, X as WooCommerceApiErrorOptions, a as WooCommerceClient, W as WooCommerceConfig, Y as addItemsInputSchema, Z as addToCartInputSchema, _ as batchResponseSchema, $ as cartExtensionsInputSchema, a0 as cartItemImageSchema, a1 as cartSchema, a2 as checkoutInputSchema, a3 as checkoutSchema, a4 as couponInputSchema, a5 as productCategorySchema, a6 as productImageSchema, a7 as productSchema, a8 as removeCartItemInputSchema, a9 as searchParamsSchema, aa as selectShippingRateInputSchema, ab as storeApiOrderSchema, ac as updateCartItemInputSchema, ad as updateCustomerInputSchema } from './types-Tf-Yd0qB.mjs';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { ZodError, z } from 'zod';
|
|
6
6
|
import 'axios';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createClient } from './client/index.js';
|
|
2
|
-
import { f as WooCommerceApiErrorCode, B as BaseErrorOptions, g as BaseReportableData, j as ValidationReportableData, k as WooCommerceDataValidationErrorOptions } from './types-
|
|
3
|
-
export { A as AddItemsInput, l as AddItemsResult, m as AddToCartInput, n as BatchResponse, o as Cart, p as CartAPI, C as CartHeadersAdapter,
|
|
2
|
+
import { f as WooCommerceApiErrorCode, B as BaseErrorOptions, g as BaseReportableData, j as ValidationReportableData, k as WooCommerceDataValidationErrorOptions } from './types-Tf-Yd0qB.js';
|
|
3
|
+
export { A as AddItemsInput, l as AddItemsResult, m as AddToCartInput, n as BatchResponse, o as Cart, p as CartAPI, q as CartExtensionsInput, C as CartHeadersAdapter, r as CartItem, t as CartItemImage, u as Checkout, v as CheckoutAPI, w as CheckoutInput, x as CouponInput, G as GetOrderInput, J as JwtTokenAdapter, O as OrderStatus, y as OrdersAPI, P as PaginatedResponse, z as Product, D as ProductCategory, E as ProductImage, F as ProductParams, H as ProductTag, I as ProductTagsParams, K as ProductsAPI, L as RemoveCartItemInput, M as SelectShippingRateInput, N as StoreApiOrder, U as UpdateCartItemInput, Q as UpdateCustomerInput, T as WooCommerceApiError, X as WooCommerceApiErrorOptions, a as WooCommerceClient, W as WooCommerceConfig, Y as addItemsInputSchema, Z as addToCartInputSchema, _ as batchResponseSchema, $ as cartExtensionsInputSchema, a0 as cartItemImageSchema, a1 as cartSchema, a2 as checkoutInputSchema, a3 as checkoutSchema, a4 as couponInputSchema, a5 as productCategorySchema, a6 as productImageSchema, a7 as productSchema, a8 as removeCartItemInputSchema, a9 as searchParamsSchema, aa as selectShippingRateInputSchema, ab as storeApiOrderSchema, ac as updateCartItemInputSchema, ad as updateCustomerInputSchema } from './types-Tf-Yd0qB.js';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { ZodError, z } from 'zod';
|
|
6
6
|
import 'axios';
|
package/dist/index.js
CHANGED
|
@@ -1086,6 +1086,10 @@ var removeCartItemInputSchema = zod.z.object({
|
|
|
1086
1086
|
var couponInputSchema = zod.z.object({
|
|
1087
1087
|
code: zod.z.string().min(1)
|
|
1088
1088
|
});
|
|
1089
|
+
var cartExtensionsInputSchema = zod.z.object({
|
|
1090
|
+
namespace: zod.z.string().min(1),
|
|
1091
|
+
data: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
1092
|
+
});
|
|
1089
1093
|
var updateCustomerInputSchema = zod.z.object({
|
|
1090
1094
|
billing_address: billingAddressSchemaMandatory.partial(),
|
|
1091
1095
|
shipping_address: addressSchema.partial()
|
|
@@ -1318,11 +1322,13 @@ var checkoutSchema = zod.z.object({
|
|
|
1318
1322
|
billing_address: billingAddressSchemaNonMandatory,
|
|
1319
1323
|
shipping_address: addressSchemaNonMandatory,
|
|
1320
1324
|
payment_method: zod.z.string(),
|
|
1325
|
+
// Null until an order is placed.
|
|
1326
|
+
// GET /checkout returns null here, so the schema must accept it.
|
|
1321
1327
|
payment_result: zod.z.object({
|
|
1322
1328
|
payment_status: zod.z.string(),
|
|
1323
1329
|
payment_details: zod.z.array(zod.z.unknown()),
|
|
1324
1330
|
redirect_url: zod.z.string()
|
|
1325
|
-
})
|
|
1331
|
+
}).nullable()
|
|
1326
1332
|
});
|
|
1327
1333
|
var checkoutInputSchema = zod.z.object({
|
|
1328
1334
|
payment_method: zod.z.string(),
|
|
@@ -1525,6 +1531,14 @@ var productSchema = zod.z.object({
|
|
|
1525
1531
|
review_count: zod.z.number(),
|
|
1526
1532
|
extensions: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
1527
1533
|
});
|
|
1534
|
+
var productTagSchema = zod.z.object({
|
|
1535
|
+
/** Tag unique identifier */
|
|
1536
|
+
id: zod.z.number(),
|
|
1537
|
+
/** Tag display name, e.g. "Vichy decembar 2025" */
|
|
1538
|
+
name: zod.z.string(),
|
|
1539
|
+
/** URL-friendly tag identifier */
|
|
1540
|
+
slug: zod.z.string()
|
|
1541
|
+
});
|
|
1528
1542
|
zod.z.object({
|
|
1529
1543
|
/** Attribution source type (e.g., 'mobile_app', 'organic', 'referral') */
|
|
1530
1544
|
source_type: zod.z.string(),
|
|
@@ -1616,6 +1630,11 @@ var createCartAPI = (client, endpoints, options) => ({
|
|
|
1616
1630
|
const response = await client.post(endpoints.removeCoupon, input);
|
|
1617
1631
|
return handleApiResponse(response, cartSchema, options);
|
|
1618
1632
|
},
|
|
1633
|
+
// Same request headers (Nonce / Cart-Token / Bearer) as every cart POST.
|
|
1634
|
+
updateExtensions: async (input) => {
|
|
1635
|
+
const response = await client.post(endpoints.updateExtensions, input);
|
|
1636
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1637
|
+
},
|
|
1619
1638
|
updateCustomer: async (input) => {
|
|
1620
1639
|
const response = await client.post(endpoints.updateCustomer, input);
|
|
1621
1640
|
return handleApiResponse(response, cartSchema, options);
|
|
@@ -1670,6 +1689,14 @@ var createProductsAPI = (client, endpoints, options) => ({
|
|
|
1670
1689
|
categories: async () => {
|
|
1671
1690
|
const response = await client.get(endpoints.categories);
|
|
1672
1691
|
return handleApiResponse(response, zod.z.array(productCategorySchema), options);
|
|
1692
|
+
},
|
|
1693
|
+
// Tags, e.g. GET /products/tags?include=996,683.
|
|
1694
|
+
// The Store API wants include as a comma list, so join the ids.
|
|
1695
|
+
tags: async (params) => {
|
|
1696
|
+
const response = await client.get(endpoints.tags, {
|
|
1697
|
+
params: { include: params?.include?.join(",") }
|
|
1698
|
+
});
|
|
1699
|
+
return handleApiResponse(response, zod.z.array(productTagSchema), options);
|
|
1673
1700
|
}
|
|
1674
1701
|
});
|
|
1675
1702
|
|
|
@@ -1680,6 +1707,8 @@ var createEndpoints = (version = "legacy") => {
|
|
|
1680
1707
|
// Products
|
|
1681
1708
|
products: `${prefix}/products`,
|
|
1682
1709
|
categories: `${prefix}/products/categories`,
|
|
1710
|
+
// Product tags, e.g. to turn a tag id into its name
|
|
1711
|
+
tags: `${prefix}/products/tags`,
|
|
1683
1712
|
// Cart
|
|
1684
1713
|
cart: `${prefix}/cart`,
|
|
1685
1714
|
addItem: `${prefix}/cart/add-item`,
|
|
@@ -1687,6 +1716,8 @@ var createEndpoints = (version = "legacy") => {
|
|
|
1687
1716
|
removeItem: `${prefix}/cart/remove-item`,
|
|
1688
1717
|
applyCoupon: `${prefix}/cart/apply-coupon`,
|
|
1689
1718
|
removeCoupon: `${prefix}/cart/remove-coupon`,
|
|
1719
|
+
// Plugins change the cart through this one route (e.g. points discounts).
|
|
1720
|
+
updateExtensions: `${prefix}/cart/extensions`,
|
|
1690
1721
|
updateCustomer: `${prefix}/cart/update-customer`,
|
|
1691
1722
|
selectShippingRate: `${prefix}/cart/select-shipping-rate`,
|
|
1692
1723
|
// Batch
|
|
@@ -2292,6 +2323,7 @@ exports.adminProductFilterSchema = productFilterSchema;
|
|
|
2292
2323
|
exports.adminProductSchema = productSchema2;
|
|
2293
2324
|
exports.batchResponseSchema = batchResponseSchema;
|
|
2294
2325
|
exports.billingAddressSchema = billingAddressSchemaMandatory;
|
|
2326
|
+
exports.cartExtensionsInputSchema = cartExtensionsInputSchema;
|
|
2295
2327
|
exports.cartItemImageSchema = cartItemImageSchema;
|
|
2296
2328
|
exports.cartSchema = cartSchema;
|
|
2297
2329
|
exports.checkoutInputSchema = checkoutInputSchema;
|