@atomic-solutions/woocommerce-api-client 0.1.0 → 0.1.2
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 +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +155 -11
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +155 -11
- package/dist/client/index.mjs.map +1 -1
- package/dist/http/index.d.mts +3 -3
- package/dist/http/index.d.ts +3 -3
- package/dist/http/index.js +4 -3
- package/dist/http/index.js.map +1 -1
- package/dist/http/index.mjs +4 -3
- package/dist/http/index.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +42 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -28
- package/dist/index.mjs.map +1 -1
- package/dist/{types-qKWtrw7A.d.ts → types-DuA0wOpm.d.mts} +1 -1
- package/dist/{types-B-zy1xrP.d.mts → types-DuA0wOpm.d.ts} +1 -1
- package/dist/utils/index.d.mts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/package.json +4 -19
- package/dist/pagination.schema-CdjWGZJr.d.mts +0 -190
- package/dist/pagination.schema-CdjWGZJr.d.ts +0 -190
- package/dist/products-Cxl54crz.d.mts +0 -3412
- package/dist/products-Cxl54crz.d.ts +0 -3412
- package/dist/schemas/admin-api/index.d.mts +0 -5340
- package/dist/schemas/admin-api/index.d.ts +0 -5340
- package/dist/schemas/admin-api/index.js +0 -584
- package/dist/schemas/admin-api/index.js.map +0 -1
- package/dist/schemas/admin-api/index.mjs +0 -545
- package/dist/schemas/admin-api/index.mjs.map +0 -1
- package/dist/schemas/index.d.mts +0 -4
- package/dist/schemas/index.d.ts +0 -4
- package/dist/schemas/index.js +0 -887
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/index.mjs +0 -844
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/schemas/store-api/index.d.mts +0 -1076
- package/dist/schemas/store-api/index.d.ts +0 -1076
- package/dist/schemas/store-api/index.js +0 -887
- package/dist/schemas/store-api/index.js.map +0 -1
- package/dist/schemas/store-api/index.mjs +0 -844
- package/dist/schemas/store-api/index.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -443,9 +443,9 @@ var setupRequestInterceptor = (axiosInstance, config, client) => {
|
|
|
443
443
|
axiosInstance.interceptors.request.use(
|
|
444
444
|
async (requestConfig) => {
|
|
445
445
|
const url = requestConfig.url;
|
|
446
|
-
if (
|
|
446
|
+
if (config.jwtToken) {
|
|
447
447
|
const token = await config.jwtToken.get();
|
|
448
|
-
if (token) {
|
|
448
|
+
if (token && (requiresAuth(url) || requiresCartAuth(url))) {
|
|
449
449
|
requestConfig.headers.Authorization = `Bearer ${token}`;
|
|
450
450
|
if (config.debug) {
|
|
451
451
|
debug("Injected JWT token for", url);
|
|
@@ -454,10 +454,11 @@ var setupRequestInterceptor = (axiosInstance, config, client) => {
|
|
|
454
454
|
}
|
|
455
455
|
if (requiresCartAuth(url)) {
|
|
456
456
|
const headers = await config.cartHeaders.get();
|
|
457
|
+
const isAuthenticated = !!await config.jwtToken?.get();
|
|
457
458
|
if (headers.nonce) {
|
|
458
459
|
requestConfig.headers.Nonce = headers.nonce;
|
|
459
460
|
}
|
|
460
|
-
if (headers.cartToken) {
|
|
461
|
+
if (headers.cartToken && !isAuthenticated) {
|
|
461
462
|
requestConfig.headers["Cart-Token"] = headers.cartToken;
|
|
462
463
|
}
|
|
463
464
|
requestConfig.headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
|
|
@@ -771,8 +772,6 @@ var pricesSchema = z.object({
|
|
|
771
772
|
sale_price: z.string()
|
|
772
773
|
}).optional()
|
|
773
774
|
}).merge(moneySchema);
|
|
774
|
-
|
|
775
|
-
// src/schemas/store-api/cart-item.schema.ts
|
|
776
775
|
var itemTotalsSchema = z.object({
|
|
777
776
|
/** Subtotal before taxes */
|
|
778
777
|
line_subtotal: z.string(),
|
|
@@ -949,8 +948,6 @@ var shippingPackageSchema = z.object({
|
|
|
949
948
|
/** Available shipping rates for this package */
|
|
950
949
|
shipping_rates: z.array(shippingRateSchema)
|
|
951
950
|
});
|
|
952
|
-
|
|
953
|
-
// src/schemas/store-api/cart.ts
|
|
954
951
|
var cartSchema = z.object({
|
|
955
952
|
items: z.array(cartItemSchema),
|
|
956
953
|
items_count: z.number(),
|
|
@@ -1170,8 +1167,6 @@ var orderTotalsSchema = z.object({
|
|
|
1170
1167
|
/** Currency suffix (e.g., 'USD') */
|
|
1171
1168
|
currency_suffix: z.string()
|
|
1172
1169
|
});
|
|
1173
|
-
|
|
1174
|
-
// src/schemas/store-api/order.schema.ts
|
|
1175
1170
|
var orderStatusEnum = z.enum([
|
|
1176
1171
|
"pending",
|
|
1177
1172
|
// Order received, awaiting payment
|
|
@@ -1218,6 +1213,21 @@ var storeApiOrderSchema = z.object({
|
|
|
1218
1213
|
/** Payment method title (optional - returned from checkout) */
|
|
1219
1214
|
payment_method_title: z.string().optional()
|
|
1220
1215
|
});
|
|
1216
|
+
z.object({
|
|
1217
|
+
id: z.number(),
|
|
1218
|
+
status: z.string(),
|
|
1219
|
+
order_key: z.string(),
|
|
1220
|
+
number: z.string(),
|
|
1221
|
+
currency: z.string(),
|
|
1222
|
+
total: z.string(),
|
|
1223
|
+
date_created: z.string(),
|
|
1224
|
+
customer_note: z.string(),
|
|
1225
|
+
billing: z.record(z.string(), z.unknown()),
|
|
1226
|
+
shipping: z.record(z.string(), z.unknown()),
|
|
1227
|
+
payment_method: z.string(),
|
|
1228
|
+
payment_method_title: z.string(),
|
|
1229
|
+
line_items: z.array(z.unknown())
|
|
1230
|
+
});
|
|
1221
1231
|
var checkoutSchema = z.object({
|
|
1222
1232
|
order_id: z.number(),
|
|
1223
1233
|
status: z.string(),
|
|
@@ -1398,8 +1408,6 @@ var storeProductsSearchParamsSchema = z.object({
|
|
|
1398
1408
|
/** Filter by product rating (1-5 stars) */
|
|
1399
1409
|
rating: z.array(z.number().min(1).max(5)).optional()
|
|
1400
1410
|
});
|
|
1401
|
-
|
|
1402
|
-
// src/schemas/store-api/products.ts
|
|
1403
1411
|
var productSchema = z.object({
|
|
1404
1412
|
id: z.number(),
|
|
1405
1413
|
name: z.string(),
|
|
@@ -1430,6 +1438,23 @@ var productSchema = z.object({
|
|
|
1430
1438
|
review_count: z.number(),
|
|
1431
1439
|
extensions: z.record(z.string(), z.unknown())
|
|
1432
1440
|
});
|
|
1441
|
+
var paymentDataItemSchema = z.object({
|
|
1442
|
+
/** Key identifier for the payment data field */
|
|
1443
|
+
key: z.string(),
|
|
1444
|
+
/** Value can be string or boolean depending on the field */
|
|
1445
|
+
value: z.union([z.string(), z.boolean()])
|
|
1446
|
+
});
|
|
1447
|
+
z.object({
|
|
1448
|
+
/** Payment method ID (e.g., "cod", "stripe", "bacs") */
|
|
1449
|
+
payment_method: z.string().min(1, "Payment method is required"),
|
|
1450
|
+
/**
|
|
1451
|
+
* Optional payment gateway-specific data
|
|
1452
|
+
*
|
|
1453
|
+
* Array of key-value pairs that will be passed to the payment gateway
|
|
1454
|
+
* Example: [{ key: "stripe_token", value: "tok_xyz" }]
|
|
1455
|
+
*/
|
|
1456
|
+
payment_data: z.array(paymentDataItemSchema).optional()
|
|
1457
|
+
});
|
|
1433
1458
|
|
|
1434
1459
|
// src/api/cart.ts
|
|
1435
1460
|
var createCartAPI = (client, endpoints, options) => ({
|
|
@@ -1568,8 +1593,6 @@ var createClient = (config) => {
|
|
|
1568
1593
|
setupErrorInterceptor(axiosInstance, fullConfig, client);
|
|
1569
1594
|
return client;
|
|
1570
1595
|
};
|
|
1571
|
-
|
|
1572
|
-
// src/schemas/admin-api/enums/enums-raw.ts
|
|
1573
1596
|
var ORDER_STATUS = [
|
|
1574
1597
|
"cancelled",
|
|
1575
1598
|
"completed",
|
|
@@ -1683,8 +1706,6 @@ var ENUM_RAW = {
|
|
|
1683
1706
|
ORDER_BY: COUPONS_ORDER_BY
|
|
1684
1707
|
}
|
|
1685
1708
|
};
|
|
1686
|
-
|
|
1687
|
-
// src/schemas/admin-api/enums/enums.ts
|
|
1688
1709
|
var APP_ENUMS = {
|
|
1689
1710
|
PRODUCT_TYPES: {
|
|
1690
1711
|
RAW: ENUM_RAW.PRODUCT.TYPES,
|
|
@@ -1790,8 +1811,6 @@ var wpLinksSchema = z.object({
|
|
|
1790
1811
|
})
|
|
1791
1812
|
).optional()
|
|
1792
1813
|
});
|
|
1793
|
-
|
|
1794
|
-
// src/schemas/admin-api/base/base-wc.schema.ts
|
|
1795
1814
|
var wcSortingSchema = z.object({
|
|
1796
1815
|
order: getAppEnumZod("COMMON_SORT_ORDER").default("desc"),
|
|
1797
1816
|
orderby: z.string().optional()
|
|
@@ -1843,8 +1862,6 @@ var wcErrorResponseSchema = z.object({
|
|
|
1843
1862
|
status: z.number()
|
|
1844
1863
|
}).optional()
|
|
1845
1864
|
}).passthrough();
|
|
1846
|
-
|
|
1847
|
-
// src/schemas/admin-api/coupons/coupon-filter.schema.ts
|
|
1848
1865
|
var couponFilterSchema = wcBaseParamsSchema.extend({
|
|
1849
1866
|
orderby: getAppEnumZod("COUPONS_ORDER_BY").default("date"),
|
|
1850
1867
|
code: z.string().optional()
|
|
@@ -1935,7 +1952,7 @@ var orderLineItemSchema = z.object({
|
|
|
1935
1952
|
sku: z.string(),
|
|
1936
1953
|
price: z.number()
|
|
1937
1954
|
});
|
|
1938
|
-
var
|
|
1955
|
+
var orderSchema2 = wcBaseResponseSchema.extend({
|
|
1939
1956
|
id: z.number(),
|
|
1940
1957
|
parent_id: z.number(),
|
|
1941
1958
|
status: getAppEnumZod("ORDER_STATUS"),
|
|
@@ -1967,7 +1984,7 @@ var orderSchema = wcBaseResponseSchema.extend({
|
|
|
1967
1984
|
var paymentMethodFilterSchema = wcBaseParamsSchema.extend({
|
|
1968
1985
|
enabled: z.boolean().optional()
|
|
1969
1986
|
});
|
|
1970
|
-
var
|
|
1987
|
+
var paymentMethodSchema2 = wcBaseResponseSchema.extend({
|
|
1971
1988
|
id: getAppEnumZod("PAYMENT_METHODS"),
|
|
1972
1989
|
title: z.string(),
|
|
1973
1990
|
description: z.string(),
|
|
@@ -2030,8 +2047,6 @@ var productSchema2 = wcBaseResponseSchema.extend({
|
|
|
2030
2047
|
on_sale: z.boolean(),
|
|
2031
2048
|
manufacturer: z.string().optional()
|
|
2032
2049
|
});
|
|
2033
|
-
|
|
2034
|
-
// src/schemas/admin-api/products/category.schema.ts
|
|
2035
2050
|
var productCategorySchema2 = wcBaseResponseSchema.extend({
|
|
2036
2051
|
id: z.number(),
|
|
2037
2052
|
name: z.string(),
|
|
@@ -2065,8 +2080,6 @@ var createCategorySchema = productCategorySchema2.omit({
|
|
|
2065
2080
|
}).extend({
|
|
2066
2081
|
name: z.string().min(1, "Name is required")
|
|
2067
2082
|
});
|
|
2068
|
-
|
|
2069
|
-
// src/schemas/admin-api/index.ts
|
|
2070
2083
|
var schemas = {
|
|
2071
2084
|
resources: {
|
|
2072
2085
|
product: {
|
|
@@ -2079,7 +2092,7 @@ var schemas = {
|
|
|
2079
2092
|
},
|
|
2080
2093
|
order: {
|
|
2081
2094
|
filter: orderFilterSchema,
|
|
2082
|
-
entity:
|
|
2095
|
+
entity: orderSchema2,
|
|
2083
2096
|
lineItem: orderLineItemSchema
|
|
2084
2097
|
},
|
|
2085
2098
|
customer: {
|
|
@@ -2095,11 +2108,11 @@ var schemas = {
|
|
|
2095
2108
|
},
|
|
2096
2109
|
paymentMethod: {
|
|
2097
2110
|
filter: paymentMethodFilterSchema,
|
|
2098
|
-
entity:
|
|
2111
|
+
entity: paymentMethodSchema2
|
|
2099
2112
|
}
|
|
2100
2113
|
}
|
|
2101
2114
|
};
|
|
2102
2115
|
|
|
2103
|
-
export { WooCommerceApiError, WooCommerceDataValidationError, addToCartInputSchema, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema,
|
|
2116
|
+
export { WooCommerceApiError, WooCommerceDataValidationError, addToCartInputSchema, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema2 as adminOrderSchema, productCategorySchema2 as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema2 as adminProductSchema, billingAddressSchemaMandatory as billingAddressSchema, cartItemImageSchema, cartSchema, checkoutInputSchema, checkoutSchema, couponInputSchema, createCategorySchema, createClient, createCouponSchema, createCustomerSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, paginationMetaSchema, paginationParamsSchema, paymentMethodFilterSchema, paymentMethodSchema2 as paymentMethodSchema, productCategorySchema, productImageSchema, productSchema, removeCartItemInputSchema, schemas, storeProductsSearchParamsSchema as searchParamsSchema, selectShippingRateInputSchema, storeApiOrderSchema, updateCartItemInputSchema, updateCustomerInputSchema, updateCustomerSchema, wcErrorResponseSchema };
|
|
2104
2117
|
//# sourceMappingURL=index.mjs.map
|
|
2105
2118
|
//# sourceMappingURL=index.mjs.map
|