@atomic-solutions/woocommerce-api-client 0.1.3 → 0.1.5
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 -3
- package/dist/client/index.d.ts +2 -3
- package/dist/client/index.js +30 -152
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +30 -152
- package/dist/client/index.mjs.map +1 -1
- package/dist/http/index.d.mts +2 -3
- package/dist/http/index.d.ts +2 -3
- package/dist/index.d.mts +5021 -7
- package/dist/index.d.ts +5021 -7
- package/dist/index.js +57 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -40
- package/dist/index.mjs.map +1 -1
- package/dist/types-B7CKE1bj.d.mts +3491 -0
- package/dist/types-B7CKE1bj.d.ts +3491 -0
- package/dist/utils/index.d.mts +2 -3
- package/dist/utils/index.d.ts +2 -3
- package/package.json +2 -2
- package/dist/types-DuA0wOpm.d.mts +0 -183
- package/dist/types-DuA0wOpm.d.ts +0 -183
package/dist/client/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-B7CKE1bj.mjs';
|
|
2
|
+
export { k as CartAPI, C as CartHeadersAdapter, o as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, w as ProductsAPI } from '../types-B7CKE1bj.mjs';
|
|
3
3
|
import 'axios';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '@atomic-solutions/schemas/woocommerce/store-api';
|
|
6
5
|
|
|
7
6
|
declare const createClient: (config: WooCommerceConfig) => WooCommerceClient;
|
|
8
7
|
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-B7CKE1bj.js';
|
|
2
|
+
export { k as CartAPI, C as CartHeadersAdapter, o as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, w as ProductsAPI } from '../types-B7CKE1bj.js';
|
|
3
3
|
import 'axios';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '@atomic-solutions/schemas/woocommerce/store-api';
|
|
6
5
|
|
|
7
6
|
declare const createClient: (config: WooCommerceConfig) => WooCommerceClient;
|
|
8
7
|
|
package/dist/client/index.js
CHANGED
|
@@ -700,28 +700,6 @@ var moneySchema = zod.z.object({
|
|
|
700
700
|
/** Currency symbol suffix (empty if symbol is prefix) */
|
|
701
701
|
currency_suffix: zod.z.string()
|
|
702
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
|
-
});
|
|
725
703
|
var productImageSchema = zod.z.object({
|
|
726
704
|
/** Alternative text for the image */
|
|
727
705
|
alt: zod.z.string(),
|
|
@@ -778,6 +756,8 @@ var pricesSchema = zod.z.object({
|
|
|
778
756
|
sale_price: zod.z.string()
|
|
779
757
|
}).optional()
|
|
780
758
|
}).merge(moneySchema);
|
|
759
|
+
|
|
760
|
+
// ../schemas/src/woocommerce/store-api/cart-item.schema.ts
|
|
781
761
|
var itemTotalsSchema = zod.z.object({
|
|
782
762
|
/** Subtotal before taxes */
|
|
783
763
|
line_subtotal: zod.z.string(),
|
|
@@ -954,6 +934,8 @@ var shippingPackageSchema = zod.z.object({
|
|
|
954
934
|
/** Available shipping rates for this package */
|
|
955
935
|
shipping_rates: zod.z.array(shippingRateSchema)
|
|
956
936
|
});
|
|
937
|
+
|
|
938
|
+
// ../schemas/src/woocommerce/store-api/cart.ts
|
|
957
939
|
var cartSchema = zod.z.object({
|
|
958
940
|
items: zod.z.array(cartItemSchema),
|
|
959
941
|
items_count: zod.z.number(),
|
|
@@ -1173,6 +1155,8 @@ var orderTotalsSchema = zod.z.object({
|
|
|
1173
1155
|
/** Currency suffix (e.g., 'USD') */
|
|
1174
1156
|
currency_suffix: zod.z.string()
|
|
1175
1157
|
});
|
|
1158
|
+
|
|
1159
|
+
// ../schemas/src/woocommerce/store-api/order.schema.ts
|
|
1176
1160
|
var orderStatusEnum = zod.z.enum([
|
|
1177
1161
|
"pending",
|
|
1178
1162
|
// Order received, awaiting payment
|
|
@@ -1219,21 +1203,6 @@ var storeApiOrderSchema = zod.z.object({
|
|
|
1219
1203
|
/** Payment method title (optional - returned from checkout) */
|
|
1220
1204
|
payment_method_title: zod.z.string().optional()
|
|
1221
1205
|
});
|
|
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
|
-
});
|
|
1237
1206
|
var checkoutSchema = zod.z.object({
|
|
1238
1207
|
order_id: zod.z.number(),
|
|
1239
1208
|
status: zod.z.string(),
|
|
@@ -1317,103 +1286,8 @@ var productCategorySchema = zod.z.object({
|
|
|
1317
1286
|
/** Number of products in this category */
|
|
1318
1287
|
count: zod.z.number()
|
|
1319
1288
|
});
|
|
1320
|
-
|
|
1321
|
-
|
|
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
|
-
});
|
|
1289
|
+
|
|
1290
|
+
// ../schemas/src/woocommerce/store-api/products.ts
|
|
1417
1291
|
var productSchema = zod.z.object({
|
|
1418
1292
|
id: zod.z.number(),
|
|
1419
1293
|
name: zod.z.string(),
|
|
@@ -1444,23 +1318,15 @@ var productSchema = zod.z.object({
|
|
|
1444
1318
|
review_count: zod.z.number(),
|
|
1445
1319
|
extensions: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
1446
1320
|
});
|
|
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
1321
|
zod.z.object({
|
|
1454
|
-
/**
|
|
1455
|
-
|
|
1456
|
-
/**
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
* Example: [{ key: "stripe_token", value: "tok_xyz" }]
|
|
1461
|
-
*/
|
|
1462
|
-
payment_data: zod.z.array(paymentDataItemSchema).optional()
|
|
1322
|
+
/** Attribution source type (e.g., 'mobile_app', 'organic', 'referral') */
|
|
1323
|
+
source_type: zod.z.string(),
|
|
1324
|
+
/** UTM source identifier (e.g., 'moja-apoteka-app', 'google') */
|
|
1325
|
+
utm_source: zod.z.string(),
|
|
1326
|
+
/** Device type (e.g., 'mobile', 'desktop', 'tablet') */
|
|
1327
|
+
device_type: zod.z.string()
|
|
1463
1328
|
});
|
|
1329
|
+
var ORDER_ATTRIBUTION_NAMESPACE = "woocommerce/order-attribution";
|
|
1464
1330
|
|
|
1465
1331
|
// src/api/cart.ts
|
|
1466
1332
|
var createCartAPI = (client, endpoints, options) => ({
|
|
@@ -1499,13 +1365,20 @@ var createCartAPI = (client, endpoints, options) => ({
|
|
|
1499
1365
|
});
|
|
1500
1366
|
|
|
1501
1367
|
// src/api/checkout.ts
|
|
1502
|
-
var createCheckoutAPI = (client, endpoints, options) => ({
|
|
1368
|
+
var createCheckoutAPI = (client, endpoints, options, orderAttribution) => ({
|
|
1503
1369
|
get: async () => {
|
|
1504
1370
|
const response = await client.get(endpoints.checkout);
|
|
1505
1371
|
return handleApiResponse(response, checkoutSchema, options);
|
|
1506
1372
|
},
|
|
1507
1373
|
process: async (input) => {
|
|
1508
|
-
const
|
|
1374
|
+
const body = orderAttribution ? {
|
|
1375
|
+
...input,
|
|
1376
|
+
extensions: {
|
|
1377
|
+
[ORDER_ATTRIBUTION_NAMESPACE]: orderAttribution,
|
|
1378
|
+
...input.extensions
|
|
1379
|
+
}
|
|
1380
|
+
} : input;
|
|
1381
|
+
const response = await client.post(endpoints.checkout, body);
|
|
1509
1382
|
return handleApiResponse(response, checkoutSchema, options);
|
|
1510
1383
|
}
|
|
1511
1384
|
});
|
|
@@ -1591,7 +1464,12 @@ var createClient = (config) => {
|
|
|
1591
1464
|
axios: axiosInstance,
|
|
1592
1465
|
products: createProductsAPI(axiosInstance, endpoints, responseOptions),
|
|
1593
1466
|
cart: createCartAPI(axiosInstance, endpoints, responseOptions),
|
|
1594
|
-
checkout: createCheckoutAPI(
|
|
1467
|
+
checkout: createCheckoutAPI(
|
|
1468
|
+
axiosInstance,
|
|
1469
|
+
endpoints,
|
|
1470
|
+
responseOptions,
|
|
1471
|
+
fullConfig.orderAttribution
|
|
1472
|
+
),
|
|
1595
1473
|
orders: createOrdersAPI(axiosInstance, endpoints, responseOptions)
|
|
1596
1474
|
};
|
|
1597
1475
|
setupRequestInterceptor(axiosInstance, fullConfig, client);
|