@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/client/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { h as WooCommerceConfig, g as WooCommerceClient } from '../types-
|
|
2
|
-
export { C as CartAPI, b as CartHeadersAdapter, c as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, d as ProductsAPI } from '../types-
|
|
1
|
+
import { h as WooCommerceConfig, g as WooCommerceClient } from '../types-DuA0wOpm.mjs';
|
|
2
|
+
export { C as CartAPI, b as CartHeadersAdapter, c as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, d as ProductsAPI } from '../types-DuA0wOpm.mjs';
|
|
3
3
|
import 'axios';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '
|
|
5
|
+
import '@atomic-solutions/schemas/woocommerce/store-api';
|
|
6
6
|
|
|
7
7
|
declare const createClient: (config: WooCommerceConfig) => WooCommerceClient;
|
|
8
8
|
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { h as WooCommerceConfig, g as WooCommerceClient } from '../types-
|
|
2
|
-
export { C as CartAPI, b as CartHeadersAdapter, c as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, d as ProductsAPI } from '../types-
|
|
1
|
+
import { h as WooCommerceConfig, g as WooCommerceClient } from '../types-DuA0wOpm.js';
|
|
2
|
+
export { C as CartAPI, b as CartHeadersAdapter, c as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, d as ProductsAPI } from '../types-DuA0wOpm.js';
|
|
3
3
|
import 'axios';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '
|
|
5
|
+
import '@atomic-solutions/schemas/woocommerce/store-api';
|
|
6
6
|
|
|
7
7
|
declare const createClient: (config: WooCommerceConfig) => WooCommerceClient;
|
|
8
8
|
|
package/dist/client/index.js
CHANGED
|
@@ -449,9 +449,9 @@ var setupRequestInterceptor = (axiosInstance, config, client) => {
|
|
|
449
449
|
axiosInstance.interceptors.request.use(
|
|
450
450
|
async (requestConfig) => {
|
|
451
451
|
const url = requestConfig.url;
|
|
452
|
-
if (
|
|
452
|
+
if (config.jwtToken) {
|
|
453
453
|
const token = await config.jwtToken.get();
|
|
454
|
-
if (token) {
|
|
454
|
+
if (token && (requiresAuth(url) || requiresCartAuth(url))) {
|
|
455
455
|
requestConfig.headers.Authorization = `Bearer ${token}`;
|
|
456
456
|
if (config.debug) {
|
|
457
457
|
debug("Injected JWT token for", url);
|
|
@@ -460,10 +460,11 @@ var setupRequestInterceptor = (axiosInstance, config, client) => {
|
|
|
460
460
|
}
|
|
461
461
|
if (requiresCartAuth(url)) {
|
|
462
462
|
const headers = await config.cartHeaders.get();
|
|
463
|
+
const isAuthenticated = !!await config.jwtToken?.get();
|
|
463
464
|
if (headers.nonce) {
|
|
464
465
|
requestConfig.headers.Nonce = headers.nonce;
|
|
465
466
|
}
|
|
466
|
-
if (headers.cartToken) {
|
|
467
|
+
if (headers.cartToken && !isAuthenticated) {
|
|
467
468
|
requestConfig.headers["Cart-Token"] = headers.cartToken;
|
|
468
469
|
}
|
|
469
470
|
requestConfig.headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
|
|
@@ -699,6 +700,28 @@ var moneySchema = zod.z.object({
|
|
|
699
700
|
/** Currency symbol suffix (empty if symbol is prefix) */
|
|
700
701
|
currency_suffix: zod.z.string()
|
|
701
702
|
});
|
|
703
|
+
zod.z.object({
|
|
704
|
+
/** Current page number */
|
|
705
|
+
page: zod.z.number().int().positive().optional(),
|
|
706
|
+
/** Items per page */
|
|
707
|
+
per_page: zod.z.number().int().positive().max(100).optional(),
|
|
708
|
+
/** Offset for pagination */
|
|
709
|
+
offset: zod.z.number().int().nonnegative().optional(),
|
|
710
|
+
/** Sort order */
|
|
711
|
+
order: zod.z.enum(["asc", "desc"]).optional(),
|
|
712
|
+
/** Field to sort by */
|
|
713
|
+
orderby: zod.z.string().optional()
|
|
714
|
+
});
|
|
715
|
+
zod.z.object({
|
|
716
|
+
/** Total number of items */
|
|
717
|
+
total: zod.z.number(),
|
|
718
|
+
/** Total number of pages */
|
|
719
|
+
totalPages: zod.z.number(),
|
|
720
|
+
/** Current page */
|
|
721
|
+
currentPage: zod.z.number(),
|
|
722
|
+
/** Items per page */
|
|
723
|
+
perPage: zod.z.number()
|
|
724
|
+
});
|
|
702
725
|
var productImageSchema = zod.z.object({
|
|
703
726
|
/** Alternative text for the image */
|
|
704
727
|
alt: zod.z.string(),
|
|
@@ -755,8 +778,6 @@ var pricesSchema = zod.z.object({
|
|
|
755
778
|
sale_price: zod.z.string()
|
|
756
779
|
}).optional()
|
|
757
780
|
}).merge(moneySchema);
|
|
758
|
-
|
|
759
|
-
// src/schemas/store-api/cart-item.schema.ts
|
|
760
781
|
var itemTotalsSchema = zod.z.object({
|
|
761
782
|
/** Subtotal before taxes */
|
|
762
783
|
line_subtotal: zod.z.string(),
|
|
@@ -933,8 +954,6 @@ var shippingPackageSchema = zod.z.object({
|
|
|
933
954
|
/** Available shipping rates for this package */
|
|
934
955
|
shipping_rates: zod.z.array(shippingRateSchema)
|
|
935
956
|
});
|
|
936
|
-
|
|
937
|
-
// src/schemas/store-api/cart.ts
|
|
938
957
|
var cartSchema = zod.z.object({
|
|
939
958
|
items: zod.z.array(cartItemSchema),
|
|
940
959
|
items_count: zod.z.number(),
|
|
@@ -1154,8 +1173,6 @@ var orderTotalsSchema = zod.z.object({
|
|
|
1154
1173
|
/** Currency suffix (e.g., 'USD') */
|
|
1155
1174
|
currency_suffix: zod.z.string()
|
|
1156
1175
|
});
|
|
1157
|
-
|
|
1158
|
-
// src/schemas/store-api/order.schema.ts
|
|
1159
1176
|
var orderStatusEnum = zod.z.enum([
|
|
1160
1177
|
"pending",
|
|
1161
1178
|
// Order received, awaiting payment
|
|
@@ -1202,6 +1219,21 @@ var storeApiOrderSchema = zod.z.object({
|
|
|
1202
1219
|
/** Payment method title (optional - returned from checkout) */
|
|
1203
1220
|
payment_method_title: zod.z.string().optional()
|
|
1204
1221
|
});
|
|
1222
|
+
zod.z.object({
|
|
1223
|
+
id: zod.z.number(),
|
|
1224
|
+
status: zod.z.string(),
|
|
1225
|
+
order_key: zod.z.string(),
|
|
1226
|
+
number: zod.z.string(),
|
|
1227
|
+
currency: zod.z.string(),
|
|
1228
|
+
total: zod.z.string(),
|
|
1229
|
+
date_created: zod.z.string(),
|
|
1230
|
+
customer_note: zod.z.string(),
|
|
1231
|
+
billing: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
1232
|
+
shipping: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
1233
|
+
payment_method: zod.z.string(),
|
|
1234
|
+
payment_method_title: zod.z.string(),
|
|
1235
|
+
line_items: zod.z.array(zod.z.unknown())
|
|
1236
|
+
});
|
|
1205
1237
|
var checkoutSchema = zod.z.object({
|
|
1206
1238
|
order_id: zod.z.number(),
|
|
1207
1239
|
status: zod.z.string(),
|
|
@@ -1285,8 +1317,103 @@ var productCategorySchema = zod.z.object({
|
|
|
1285
1317
|
/** Number of products in this category */
|
|
1286
1318
|
count: zod.z.number()
|
|
1287
1319
|
});
|
|
1288
|
-
|
|
1289
|
-
//
|
|
1320
|
+
zod.z.object({
|
|
1321
|
+
// Pagination
|
|
1322
|
+
/** Current page number */
|
|
1323
|
+
page: zod.z.number(),
|
|
1324
|
+
/** Number of products per page (1-100) */
|
|
1325
|
+
per_page: zod.z.number().min(1).max(100).default(10),
|
|
1326
|
+
// Ordering
|
|
1327
|
+
/** Field to order results by */
|
|
1328
|
+
orderby: zod.z.enum([
|
|
1329
|
+
"date",
|
|
1330
|
+
"id",
|
|
1331
|
+
"include",
|
|
1332
|
+
"title",
|
|
1333
|
+
"slug",
|
|
1334
|
+
"price",
|
|
1335
|
+
"popularity",
|
|
1336
|
+
"rating",
|
|
1337
|
+
"menu_order",
|
|
1338
|
+
"date_modified"
|
|
1339
|
+
]).optional(),
|
|
1340
|
+
/** Sort order (ascending or descending) */
|
|
1341
|
+
order: zod.z.enum(["asc", "desc"]).optional(),
|
|
1342
|
+
// Filtering
|
|
1343
|
+
/** Search query string */
|
|
1344
|
+
search: zod.z.string().optional(),
|
|
1345
|
+
/** Exact slug match */
|
|
1346
|
+
slug: zod.z.string().optional(),
|
|
1347
|
+
// Date filtering
|
|
1348
|
+
/** Filter products published after this date */
|
|
1349
|
+
after: zod.z.string().datetime().optional(),
|
|
1350
|
+
/** Filter products published before this date */
|
|
1351
|
+
before: zod.z.string().datetime().optional(),
|
|
1352
|
+
/** Filter products modified after this date */
|
|
1353
|
+
modified_after: zod.z.string().datetime().optional(),
|
|
1354
|
+
/** Filter products modified before this date */
|
|
1355
|
+
modified_before: zod.z.string().datetime().optional(),
|
|
1356
|
+
// ID filtering
|
|
1357
|
+
/** Include specific product IDs */
|
|
1358
|
+
include: zod.z.array(zod.z.number()).optional(),
|
|
1359
|
+
/** Exclude specific product IDs */
|
|
1360
|
+
exclude: zod.z.array(zod.z.number()).optional(),
|
|
1361
|
+
// Parent/Child
|
|
1362
|
+
/** Filter by parent product IDs */
|
|
1363
|
+
parent: zod.z.array(zod.z.number()).optional(),
|
|
1364
|
+
/** Exclude products with these parent IDs */
|
|
1365
|
+
parent_exclude: zod.z.array(zod.z.number()).optional(),
|
|
1366
|
+
// Type & Status
|
|
1367
|
+
/** Filter by product type */
|
|
1368
|
+
type: zod.z.enum(["simple", "grouped", "external", "variable", "variation"]).optional(),
|
|
1369
|
+
/** Filter by product status */
|
|
1370
|
+
status: zod.z.enum(["any", "draft", "pending", "private", "publish"]).optional(),
|
|
1371
|
+
// Featured
|
|
1372
|
+
/** Filter featured products */
|
|
1373
|
+
featured: zod.z.boolean().optional(),
|
|
1374
|
+
// Visibility
|
|
1375
|
+
/** Filter by catalog visibility */
|
|
1376
|
+
catalog_visibility: zod.z.enum(["any", "visible", "catalog", "search", "hidden"]).optional(),
|
|
1377
|
+
// Stock
|
|
1378
|
+
/** Filter by stock status */
|
|
1379
|
+
stock_status: zod.z.array(zod.z.enum(["instock", "outofstock", "onbackorder"])).optional(),
|
|
1380
|
+
// Category & Tag filtering
|
|
1381
|
+
/** Filter by category slug or ID */
|
|
1382
|
+
category: zod.z.string().optional(),
|
|
1383
|
+
/** Category filter operator */
|
|
1384
|
+
category_operator: zod.z.enum(["in", "not_in", "and"]).optional(),
|
|
1385
|
+
/** Filter by tag slug or ID */
|
|
1386
|
+
tag: zod.z.string().optional(),
|
|
1387
|
+
/** Tag filter operator */
|
|
1388
|
+
tag_operator: zod.z.enum(["in", "not_in", "and"]).optional(),
|
|
1389
|
+
// Attribute filtering
|
|
1390
|
+
/** Filter by product attributes */
|
|
1391
|
+
attributes: zod.z.array(
|
|
1392
|
+
zod.z.object({
|
|
1393
|
+
/** Attribute name */
|
|
1394
|
+
attribute: zod.z.string(),
|
|
1395
|
+
/** Filter by attribute term IDs */
|
|
1396
|
+
term_id: zod.z.array(zod.z.number()).optional(),
|
|
1397
|
+
/** Filter by attribute term slugs */
|
|
1398
|
+
slug: zod.z.array(zod.z.string()).optional(),
|
|
1399
|
+
/** Attribute filter operator */
|
|
1400
|
+
operator: zod.z.enum(["in", "not_in", "and"]).optional()
|
|
1401
|
+
})
|
|
1402
|
+
).optional(),
|
|
1403
|
+
/** Relationship between attribute filters */
|
|
1404
|
+
attribute_relation: zod.z.enum(["in", "and"]).optional(),
|
|
1405
|
+
// Price filtering
|
|
1406
|
+
/** Minimum price filter */
|
|
1407
|
+
min_price: zod.z.string().optional(),
|
|
1408
|
+
/** Maximum price filter */
|
|
1409
|
+
max_price: zod.z.string().optional(),
|
|
1410
|
+
// Sale status
|
|
1411
|
+
/** Filter products on sale */
|
|
1412
|
+
on_sale: zod.z.boolean().optional(),
|
|
1413
|
+
// Rating filter
|
|
1414
|
+
/** Filter by product rating (1-5 stars) */
|
|
1415
|
+
rating: zod.z.array(zod.z.number().min(1).max(5)).optional()
|
|
1416
|
+
});
|
|
1290
1417
|
var productSchema = zod.z.object({
|
|
1291
1418
|
id: zod.z.number(),
|
|
1292
1419
|
name: zod.z.string(),
|
|
@@ -1317,6 +1444,23 @@ var productSchema = zod.z.object({
|
|
|
1317
1444
|
review_count: zod.z.number(),
|
|
1318
1445
|
extensions: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
1319
1446
|
});
|
|
1447
|
+
var paymentDataItemSchema = zod.z.object({
|
|
1448
|
+
/** Key identifier for the payment data field */
|
|
1449
|
+
key: zod.z.string(),
|
|
1450
|
+
/** Value can be string or boolean depending on the field */
|
|
1451
|
+
value: zod.z.union([zod.z.string(), zod.z.boolean()])
|
|
1452
|
+
});
|
|
1453
|
+
zod.z.object({
|
|
1454
|
+
/** Payment method ID (e.g., "cod", "stripe", "bacs") */
|
|
1455
|
+
payment_method: zod.z.string().min(1, "Payment method is required"),
|
|
1456
|
+
/**
|
|
1457
|
+
* Optional payment gateway-specific data
|
|
1458
|
+
*
|
|
1459
|
+
* Array of key-value pairs that will be passed to the payment gateway
|
|
1460
|
+
* Example: [{ key: "stripe_token", value: "tok_xyz" }]
|
|
1461
|
+
*/
|
|
1462
|
+
payment_data: zod.z.array(paymentDataItemSchema).optional()
|
|
1463
|
+
});
|
|
1320
1464
|
|
|
1321
1465
|
// src/api/cart.ts
|
|
1322
1466
|
var createCartAPI = (client, endpoints, options) => ({
|