@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.
Files changed (45) hide show
  1. package/dist/client/index.d.mts +3 -3
  2. package/dist/client/index.d.ts +3 -3
  3. package/dist/client/index.js +155 -11
  4. package/dist/client/index.js.map +1 -1
  5. package/dist/client/index.mjs +155 -11
  6. package/dist/client/index.mjs.map +1 -1
  7. package/dist/http/index.d.mts +3 -3
  8. package/dist/http/index.d.ts +3 -3
  9. package/dist/http/index.js +4 -3
  10. package/dist/http/index.js.map +1 -1
  11. package/dist/http/index.mjs +4 -3
  12. package/dist/http/index.mjs.map +1 -1
  13. package/dist/index.d.mts +5 -5
  14. package/dist/index.d.ts +5 -5
  15. package/dist/index.js +42 -29
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +41 -28
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/{types-qKWtrw7A.d.ts → types-DuA0wOpm.d.mts} +1 -1
  20. package/dist/{types-B-zy1xrP.d.mts → types-DuA0wOpm.d.ts} +1 -1
  21. package/dist/utils/index.d.mts +3 -3
  22. package/dist/utils/index.d.ts +3 -3
  23. package/package.json +4 -19
  24. package/dist/pagination.schema-CdjWGZJr.d.mts +0 -190
  25. package/dist/pagination.schema-CdjWGZJr.d.ts +0 -190
  26. package/dist/products-Cxl54crz.d.mts +0 -3412
  27. package/dist/products-Cxl54crz.d.ts +0 -3412
  28. package/dist/schemas/admin-api/index.d.mts +0 -5340
  29. package/dist/schemas/admin-api/index.d.ts +0 -5340
  30. package/dist/schemas/admin-api/index.js +0 -584
  31. package/dist/schemas/admin-api/index.js.map +0 -1
  32. package/dist/schemas/admin-api/index.mjs +0 -545
  33. package/dist/schemas/admin-api/index.mjs.map +0 -1
  34. package/dist/schemas/index.d.mts +0 -4
  35. package/dist/schemas/index.d.ts +0 -4
  36. package/dist/schemas/index.js +0 -887
  37. package/dist/schemas/index.js.map +0 -1
  38. package/dist/schemas/index.mjs +0 -844
  39. package/dist/schemas/index.mjs.map +0 -1
  40. package/dist/schemas/store-api/index.d.mts +0 -1076
  41. package/dist/schemas/store-api/index.d.ts +0 -1076
  42. package/dist/schemas/store-api/index.js +0 -887
  43. package/dist/schemas/store-api/index.js.map +0 -1
  44. package/dist/schemas/store-api/index.mjs +0 -844
  45. package/dist/schemas/store-api/index.mjs.map +0 -1
@@ -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 (requiresAuth(url) && config.jwtToken) {
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";
@@ -693,6 +694,28 @@ var moneySchema = z.object({
693
694
  /** Currency symbol suffix (empty if symbol is prefix) */
694
695
  currency_suffix: z.string()
695
696
  });
697
+ z.object({
698
+ /** Current page number */
699
+ page: z.number().int().positive().optional(),
700
+ /** Items per page */
701
+ per_page: z.number().int().positive().max(100).optional(),
702
+ /** Offset for pagination */
703
+ offset: z.number().int().nonnegative().optional(),
704
+ /** Sort order */
705
+ order: z.enum(["asc", "desc"]).optional(),
706
+ /** Field to sort by */
707
+ orderby: z.string().optional()
708
+ });
709
+ z.object({
710
+ /** Total number of items */
711
+ total: z.number(),
712
+ /** Total number of pages */
713
+ totalPages: z.number(),
714
+ /** Current page */
715
+ currentPage: z.number(),
716
+ /** Items per page */
717
+ perPage: z.number()
718
+ });
696
719
  var productImageSchema = z.object({
697
720
  /** Alternative text for the image */
698
721
  alt: z.string(),
@@ -749,8 +772,6 @@ var pricesSchema = z.object({
749
772
  sale_price: z.string()
750
773
  }).optional()
751
774
  }).merge(moneySchema);
752
-
753
- // src/schemas/store-api/cart-item.schema.ts
754
775
  var itemTotalsSchema = z.object({
755
776
  /** Subtotal before taxes */
756
777
  line_subtotal: z.string(),
@@ -927,8 +948,6 @@ var shippingPackageSchema = z.object({
927
948
  /** Available shipping rates for this package */
928
949
  shipping_rates: z.array(shippingRateSchema)
929
950
  });
930
-
931
- // src/schemas/store-api/cart.ts
932
951
  var cartSchema = z.object({
933
952
  items: z.array(cartItemSchema),
934
953
  items_count: z.number(),
@@ -1148,8 +1167,6 @@ var orderTotalsSchema = z.object({
1148
1167
  /** Currency suffix (e.g., 'USD') */
1149
1168
  currency_suffix: z.string()
1150
1169
  });
1151
-
1152
- // src/schemas/store-api/order.schema.ts
1153
1170
  var orderStatusEnum = z.enum([
1154
1171
  "pending",
1155
1172
  // Order received, awaiting payment
@@ -1196,6 +1213,21 @@ var storeApiOrderSchema = z.object({
1196
1213
  /** Payment method title (optional - returned from checkout) */
1197
1214
  payment_method_title: z.string().optional()
1198
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
+ });
1199
1231
  var checkoutSchema = z.object({
1200
1232
  order_id: z.number(),
1201
1233
  status: z.string(),
@@ -1279,8 +1311,103 @@ var productCategorySchema = z.object({
1279
1311
  /** Number of products in this category */
1280
1312
  count: z.number()
1281
1313
  });
1282
-
1283
- // src/schemas/store-api/products.ts
1314
+ z.object({
1315
+ // Pagination
1316
+ /** Current page number */
1317
+ page: z.number(),
1318
+ /** Number of products per page (1-100) */
1319
+ per_page: z.number().min(1).max(100).default(10),
1320
+ // Ordering
1321
+ /** Field to order results by */
1322
+ orderby: z.enum([
1323
+ "date",
1324
+ "id",
1325
+ "include",
1326
+ "title",
1327
+ "slug",
1328
+ "price",
1329
+ "popularity",
1330
+ "rating",
1331
+ "menu_order",
1332
+ "date_modified"
1333
+ ]).optional(),
1334
+ /** Sort order (ascending or descending) */
1335
+ order: z.enum(["asc", "desc"]).optional(),
1336
+ // Filtering
1337
+ /** Search query string */
1338
+ search: z.string().optional(),
1339
+ /** Exact slug match */
1340
+ slug: z.string().optional(),
1341
+ // Date filtering
1342
+ /** Filter products published after this date */
1343
+ after: z.string().datetime().optional(),
1344
+ /** Filter products published before this date */
1345
+ before: z.string().datetime().optional(),
1346
+ /** Filter products modified after this date */
1347
+ modified_after: z.string().datetime().optional(),
1348
+ /** Filter products modified before this date */
1349
+ modified_before: z.string().datetime().optional(),
1350
+ // ID filtering
1351
+ /** Include specific product IDs */
1352
+ include: z.array(z.number()).optional(),
1353
+ /** Exclude specific product IDs */
1354
+ exclude: z.array(z.number()).optional(),
1355
+ // Parent/Child
1356
+ /** Filter by parent product IDs */
1357
+ parent: z.array(z.number()).optional(),
1358
+ /** Exclude products with these parent IDs */
1359
+ parent_exclude: z.array(z.number()).optional(),
1360
+ // Type & Status
1361
+ /** Filter by product type */
1362
+ type: z.enum(["simple", "grouped", "external", "variable", "variation"]).optional(),
1363
+ /** Filter by product status */
1364
+ status: z.enum(["any", "draft", "pending", "private", "publish"]).optional(),
1365
+ // Featured
1366
+ /** Filter featured products */
1367
+ featured: z.boolean().optional(),
1368
+ // Visibility
1369
+ /** Filter by catalog visibility */
1370
+ catalog_visibility: z.enum(["any", "visible", "catalog", "search", "hidden"]).optional(),
1371
+ // Stock
1372
+ /** Filter by stock status */
1373
+ stock_status: z.array(z.enum(["instock", "outofstock", "onbackorder"])).optional(),
1374
+ // Category & Tag filtering
1375
+ /** Filter by category slug or ID */
1376
+ category: z.string().optional(),
1377
+ /** Category filter operator */
1378
+ category_operator: z.enum(["in", "not_in", "and"]).optional(),
1379
+ /** Filter by tag slug or ID */
1380
+ tag: z.string().optional(),
1381
+ /** Tag filter operator */
1382
+ tag_operator: z.enum(["in", "not_in", "and"]).optional(),
1383
+ // Attribute filtering
1384
+ /** Filter by product attributes */
1385
+ attributes: z.array(
1386
+ z.object({
1387
+ /** Attribute name */
1388
+ attribute: z.string(),
1389
+ /** Filter by attribute term IDs */
1390
+ term_id: z.array(z.number()).optional(),
1391
+ /** Filter by attribute term slugs */
1392
+ slug: z.array(z.string()).optional(),
1393
+ /** Attribute filter operator */
1394
+ operator: z.enum(["in", "not_in", "and"]).optional()
1395
+ })
1396
+ ).optional(),
1397
+ /** Relationship between attribute filters */
1398
+ attribute_relation: z.enum(["in", "and"]).optional(),
1399
+ // Price filtering
1400
+ /** Minimum price filter */
1401
+ min_price: z.string().optional(),
1402
+ /** Maximum price filter */
1403
+ max_price: z.string().optional(),
1404
+ // Sale status
1405
+ /** Filter products on sale */
1406
+ on_sale: z.boolean().optional(),
1407
+ // Rating filter
1408
+ /** Filter by product rating (1-5 stars) */
1409
+ rating: z.array(z.number().min(1).max(5)).optional()
1410
+ });
1284
1411
  var productSchema = z.object({
1285
1412
  id: z.number(),
1286
1413
  name: z.string(),
@@ -1311,6 +1438,23 @@ var productSchema = z.object({
1311
1438
  review_count: z.number(),
1312
1439
  extensions: z.record(z.string(), z.unknown())
1313
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
+ });
1314
1458
 
1315
1459
  // src/api/cart.ts
1316
1460
  var createCartAPI = (client, endpoints, options) => ({