@atomic-solutions/woocommerce-api-client 0.1.0 → 0.1.1

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 +19 -709
  4. package/dist/client/index.js.map +1 -1
  5. package/dist/client/index.mjs +5 -695
  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 +148 -1370
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +8 -1346
  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
package/dist/index.mjs CHANGED
@@ -1,5 +1,8 @@
1
1
  import axios, { isAxiosError } from 'axios';
2
+ import { productCategorySchema, productSchema, cartSchema, checkoutSchema, storeApiOrderSchema } from '@atomic-solutions/schemas/woocommerce/store-api';
3
+ export { addToCartInputSchema, addressSchema, billingAddressSchemaMandatory as billingAddressSchema, cartItemImageSchema, cartSchema, checkoutInputSchema, checkoutSchema, couponInputSchema, paginationMetaSchema, paginationParamsSchema, productCategorySchema, productImageSchema, productSchema, removeCartItemInputSchema, searchParamsSchema, selectShippingRateInputSchema, storeApiOrderSchema, updateCartItemInputSchema, updateCustomerInputSchema } from '@atomic-solutions/schemas/woocommerce/store-api';
2
4
  import { z } from 'zod';
5
+ export { categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema as adminProductSchema, createCategorySchema, createCouponSchema, createCustomerSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, paymentMethodFilterSchema, paymentMethodSchema, schemas, updateCustomerSchema, wcErrorResponseSchema } from '@atomic-solutions/schemas/woocommerce/admin-api';
3
6
 
4
7
  // src/client/createClient.ts
5
8
 
@@ -443,9 +446,9 @@ var setupRequestInterceptor = (axiosInstance, config, client) => {
443
446
  axiosInstance.interceptors.request.use(
444
447
  async (requestConfig) => {
445
448
  const url = requestConfig.url;
446
- if (requiresAuth(url) && config.jwtToken) {
449
+ if (config.jwtToken) {
447
450
  const token = await config.jwtToken.get();
448
- if (token) {
451
+ if (token && (requiresAuth(url) || requiresCartAuth(url))) {
449
452
  requestConfig.headers.Authorization = `Bearer ${token}`;
450
453
  if (config.debug) {
451
454
  debug("Injected JWT token for", url);
@@ -454,10 +457,11 @@ var setupRequestInterceptor = (axiosInstance, config, client) => {
454
457
  }
455
458
  if (requiresCartAuth(url)) {
456
459
  const headers = await config.cartHeaders.get();
460
+ const isAuthenticated = !!await config.jwtToken?.get();
457
461
  if (headers.nonce) {
458
462
  requestConfig.headers.Nonce = headers.nonce;
459
463
  }
460
- if (headers.cartToken) {
464
+ if (headers.cartToken && !isAuthenticated) {
461
465
  requestConfig.headers["Cart-Token"] = headers.cartToken;
462
466
  }
463
467
  requestConfig.headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
@@ -625,813 +629,6 @@ var setupErrorInterceptor = (axiosInstance, config, client) => {
625
629
  }
626
630
  );
627
631
  };
628
- var addressSchema = z.object({
629
- /** First name */
630
- first_name: z.string().min(1, "First name is required"),
631
- /** Last name */
632
- last_name: z.string().min(1, "Last name is required"),
633
- /** Company name (optional) */
634
- company: z.string(),
635
- /** Address line 1 */
636
- address_1: z.string().min(1, "Address is required"),
637
- /** Address line 2 (optional) */
638
- address_2: z.string(),
639
- /** City */
640
- city: z.string().min(1, "City is required"),
641
- /** State/Province/Region */
642
- state: z.string(),
643
- /** Postal code */
644
- postcode: z.string().min(1, "Postal code is required"),
645
- /** Country code (ISO 3166-1 alpha-2) */
646
- country: z.string(),
647
- /** Phone number */
648
- phone: z.string().min(1, "Phone number is required")
649
- });
650
- var addressSchemaNonMandatory = z.object({
651
- /** First name */
652
- first_name: z.string(),
653
- /** Last name */
654
- last_name: z.string(),
655
- /** Company name (optional) */
656
- company: z.string(),
657
- /** Address line 1 */
658
- address_1: z.string(),
659
- /** Address line 2 (optional) */
660
- address_2: z.string(),
661
- /** City */
662
- city: z.string(),
663
- /** State/Province/Region */
664
- state: z.string(),
665
- /** Postal code */
666
- postcode: z.string(),
667
- /** Country code (ISO 3166-1 alpha-2) */
668
- country: z.string(),
669
- /** Phone number */
670
- phone: z.string()
671
- });
672
- var billingAddressSchemaMandatory = addressSchema.extend({
673
- /** Email address (required for billing) */
674
- email: z.string().email("Valid email is required")
675
- });
676
- var billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({
677
- /** Email address (can be null for guest carts) */
678
- email: z.string().nullable()
679
- });
680
- var moneySchema = z.object({
681
- /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
682
- currency_code: z.string(),
683
- /** Currency symbol (e.g., '$', '€', 'KM') */
684
- currency_symbol: z.string(),
685
- /** Number of decimal places (e.g., 2 for dollars/euros) */
686
- currency_minor_unit: z.number(),
687
- /** Decimal separator character (e.g., '.', ',') */
688
- currency_decimal_separator: z.string(),
689
- /** Thousands separator character (e.g., ',', '.') */
690
- currency_thousand_separator: z.string(),
691
- /** Currency symbol prefix (empty if symbol is suffix) */
692
- currency_prefix: z.string(),
693
- /** Currency symbol suffix (empty if symbol is prefix) */
694
- currency_suffix: z.string()
695
- });
696
- var paginationParamsSchema = z.object({
697
- /** Current page number */
698
- page: z.number().int().positive().optional(),
699
- /** Items per page */
700
- per_page: z.number().int().positive().max(100).optional(),
701
- /** Offset for pagination */
702
- offset: z.number().int().nonnegative().optional(),
703
- /** Sort order */
704
- order: z.enum(["asc", "desc"]).optional(),
705
- /** Field to sort by */
706
- orderby: z.string().optional()
707
- });
708
- var paginationMetaSchema = z.object({
709
- /** Total number of items */
710
- total: z.number(),
711
- /** Total number of pages */
712
- totalPages: z.number(),
713
- /** Current page */
714
- currentPage: z.number(),
715
- /** Items per page */
716
- perPage: z.number()
717
- });
718
- var productImageSchema = z.object({
719
- /** Alternative text for the image */
720
- alt: z.string(),
721
- /** Image unique identifier */
722
- id: z.number(),
723
- /** Image filename */
724
- name: z.string(),
725
- /** Available image sizes in JSON format */
726
- sizes: z.string(),
727
- /** Full-size image URL */
728
- src: z.string().url(),
729
- /** Srcset attribute for responsive images */
730
- srcset: z.string(),
731
- /** Thumbnail image URL */
732
- thumbnail: z.string().url()
733
- });
734
- var cartItemImageSchema = z.object({
735
- /** Image ID */
736
- id: z.number(),
737
- /** Full image URL */
738
- src: z.string(),
739
- /** Thumbnail URL */
740
- thumbnail: z.string(),
741
- /** Responsive image srcset */
742
- srcset: z.string(),
743
- /** Responsive image sizes */
744
- sizes: z.string(),
745
- /** Image name */
746
- name: z.string(),
747
- /** Image alt text */
748
- alt: z.string()
749
- });
750
- var pricesSchema = z.object({
751
- /** Current active price (sale price if on sale, otherwise regular) */
752
- price: z.string(),
753
- /** Regular price (before any discounts) */
754
- regular_price: z.string(),
755
- /** Sale price (empty string if not on sale) */
756
- sale_price: z.string(),
757
- /** Price range for variable products (null for simple products) */
758
- price_range: z.object({
759
- min_amount: z.string(),
760
- max_amount: z.string()
761
- }).nullable(),
762
- /** Raw price data without formatting */
763
- raw_prices: z.object({
764
- /** Decimal precision */
765
- precision: z.number(),
766
- /** Raw price value */
767
- price: z.string(),
768
- /** Raw regular price value */
769
- regular_price: z.string(),
770
- /** Raw sale price value */
771
- sale_price: z.string()
772
- }).optional()
773
- }).merge(moneySchema);
774
-
775
- // src/schemas/store-api/cart-item.schema.ts
776
- var itemTotalsSchema = z.object({
777
- /** Subtotal before taxes */
778
- line_subtotal: z.string(),
779
- /** Tax amount on subtotal */
780
- line_subtotal_tax: z.string(),
781
- /** Total after discounts, before taxes */
782
- line_total: z.string(),
783
- /** Tax amount on total */
784
- line_total_tax: z.string()
785
- }).merge(moneySchema);
786
- var cartItemSchema = z.object({
787
- /** Unique cart item key (use this for update/remove operations) */
788
- key: z.string(),
789
- /** Product ID */
790
- id: z.number(),
791
- /** Quantity of this item in cart */
792
- quantity: z.number(),
793
- /** Quantity limits for this product */
794
- quantity_limits: z.object({
795
- /** Minimum quantity allowed */
796
- minimum: z.number(),
797
- /** Maximum quantity allowed */
798
- maximum: z.number(),
799
- /** Quantity must be multiple of this value */
800
- multiple_of: z.number(),
801
- /** Whether quantity can be changed */
802
- editable: z.boolean()
803
- }),
804
- /** Product name */
805
- name: z.string(),
806
- /** Short product description */
807
- short_description: z.string(),
808
- /** Full product description */
809
- description: z.string(),
810
- /** Product SKU */
811
- sku: z.string(),
812
- /** Remaining stock count if low (null if not low or unlimited) */
813
- low_stock_remaining: z.number().nullable(),
814
- /** Whether backorders are allowed */
815
- backorders_allowed: z.boolean(),
816
- /** Whether to show backorder badge */
817
- show_backorder_badge: z.boolean(),
818
- /** Whether product can only be purchased individually */
819
- sold_individually: z.boolean(),
820
- /** Product permalink URL */
821
- permalink: z.string(),
822
- /** Product images */
823
- images: z.array(cartItemImageSchema),
824
- /** Variation attributes (for variable products) */
825
- variation: z.array(
826
- z.object({
827
- /** Attribute name (e.g., 'Color', 'Size') */
828
- attribute: z.string(),
829
- /** Selected value (e.g., 'Red', 'Large') */
830
- value: z.string()
831
- })
832
- ),
833
- /** Additional item data/metadata */
834
- item_data: z.array(
835
- z.object({
836
- key: z.string(),
837
- value: z.string()
838
- })
839
- ),
840
- /** Product pricing information */
841
- prices: pricesSchema,
842
- /** Line item totals */
843
- totals: itemTotalsSchema,
844
- /** Catalog visibility setting */
845
- catalog_visibility: z.string(),
846
- /** Product type */
847
- type: z.enum(["simple", "variable", "grouped", "external"]),
848
- /** Extension data from plugins */
849
- extensions: z.record(z.string(), z.unknown())
850
- });
851
- var cartTotalsSchema = z.object({
852
- /** Total of all cart items (before discounts and taxes) */
853
- total_items: z.string(),
854
- /** Tax on cart items */
855
- total_items_tax: z.string(),
856
- /** Total fees */
857
- total_fees: z.string(),
858
- /** Tax on fees */
859
- total_fees_tax: z.string(),
860
- /** Total discount amount from coupons */
861
- total_discount: z.string(),
862
- /** Tax on discounts */
863
- total_discount_tax: z.string(),
864
- /** Shipping cost (null if not calculated yet) */
865
- total_shipping: z.string().nullable(),
866
- /** Shipping tax (null if not calculated yet) */
867
- total_shipping_tax: z.string().nullable(),
868
- /** Final total price (includes all taxes and fees) */
869
- total_price: z.string(),
870
- /** Total tax amount */
871
- total_tax: z.string(),
872
- /** Tax breakdown by rate */
873
- tax_lines: z.array(
874
- z.object({
875
- /** Tax rate name */
876
- name: z.string(),
877
- /** Tax amount */
878
- price: z.string(),
879
- /** Tax rate percentage */
880
- rate: z.string()
881
- })
882
- )
883
- }).merge(moneySchema);
884
- var cartCouponSchema = z.object({
885
- /** Coupon code */
886
- code: z.string(),
887
- /** Discount totals for this coupon */
888
- totals: z.object({
889
- /** Total discount amount (before tax) */
890
- total_discount: z.string(),
891
- /** Tax amount on discount */
892
- total_discount_tax: z.string()
893
- }).merge(moneySchema)
894
- });
895
- var shippingRateSchema = z.object({
896
- /** Unique rate identifier (format: instance_id:method_id) */
897
- rate_id: z.string(),
898
- /** Shipping method name */
899
- name: z.string(),
900
- /** Shipping method description */
901
- description: z.string(),
902
- /** Estimated delivery time */
903
- delivery_time: z.string(),
904
- /** Shipping cost */
905
- price: z.string(),
906
- /** Shipping instance ID */
907
- instance_id: z.number(),
908
- /** Shipping method ID */
909
- method_id: z.string(),
910
- /** Additional metadata for this shipping method */
911
- meta_data: z.array(
912
- z.object({
913
- key: z.string(),
914
- value: z.string()
915
- })
916
- ),
917
- /** Whether this rate is currently selected */
918
- selected: z.boolean(),
919
- /** Currency code for the price */
920
- currency_code: z.string(),
921
- /** Currency symbol for the price */
922
- currency_symbol: z.string()
923
- });
924
- var shippingPackageSchema = z.object({
925
- /** Package identifier (0-indexed) */
926
- package_id: z.number(),
927
- /** Package name/label */
928
- name: z.string(),
929
- /** Shipping destination address */
930
- destination: z.object({
931
- address_1: z.string(),
932
- address_2: z.string().optional(),
933
- city: z.string(),
934
- state: z.string(),
935
- postcode: z.string(),
936
- country: z.string()
937
- }),
938
- /** Items included in this package */
939
- items: z.array(
940
- z.object({
941
- /** Cart item key */
942
- key: z.string(),
943
- /** Product name */
944
- name: z.string(),
945
- /** Quantity in package */
946
- quantity: z.number()
947
- })
948
- ),
949
- /** Available shipping rates for this package */
950
- shipping_rates: z.array(shippingRateSchema)
951
- });
952
-
953
- // src/schemas/store-api/cart.ts
954
- var cartSchema = z.object({
955
- items: z.array(cartItemSchema),
956
- items_count: z.number(),
957
- items_weight: z.number(),
958
- needs_payment: z.boolean(),
959
- needs_shipping: z.boolean(),
960
- payment_methods: z.array(z.enum(["cod", "monri"])),
961
- payment_requirements: z.array(z.string()),
962
- has_calculated_shipping: z.boolean(),
963
- shipping_address: addressSchemaNonMandatory,
964
- billing_address: billingAddressSchemaNonMandatory,
965
- shipping_rates: z.array(shippingPackageSchema),
966
- coupons: z.array(cartCouponSchema),
967
- totals: cartTotalsSchema,
968
- errors: z.array(
969
- z.object({
970
- code: z.string(),
971
- message: z.string()
972
- })
973
- ),
974
- extensions: z.record(z.string(), z.unknown()).optional(),
975
- cross_sells: z.array(z.unknown()),
976
- fees: z.array(z.unknown())
977
- });
978
- var addToCartInputSchema = z.object({
979
- id: z.number(),
980
- quantity: z.number().int().positive(),
981
- variation: z.array(
982
- z.object({
983
- attribute: z.string(),
984
- value: z.string()
985
- })
986
- ).optional()
987
- });
988
- var updateCartItemInputSchema = z.object({
989
- key: z.string(),
990
- quantity: z.number().int().positive()
991
- });
992
- var removeCartItemInputSchema = z.object({
993
- key: z.string()
994
- });
995
- var couponInputSchema = z.object({
996
- code: z.string().min(1)
997
- });
998
- var updateCustomerInputSchema = z.object({
999
- billing_address: billingAddressSchemaMandatory.partial(),
1000
- shipping_address: addressSchema.partial()
1001
- }).partial();
1002
- var selectShippingRateInputSchema = z.object({
1003
- package_id: z.union([z.number(), z.string()]).default(0),
1004
- rate_id: z.string()
1005
- });
1006
- var orderItemImageSchema = z.object({
1007
- /** Image ID */
1008
- id: z.number(),
1009
- /** Full image URL */
1010
- src: z.string().url(),
1011
- /** Thumbnail URL */
1012
- thumbnail: z.string().url(),
1013
- /** Responsive image srcset */
1014
- srcset: z.string(),
1015
- /** Responsive image sizes attribute */
1016
- sizes: z.string(),
1017
- /** Image name */
1018
- name: z.string(),
1019
- /** Image alt text */
1020
- alt: z.string()
1021
- });
1022
- var orderItemPricesSchema = z.object({
1023
- /** Formatted price (current price) */
1024
- price: z.string(),
1025
- /** Formatted regular price */
1026
- regular_price: z.string(),
1027
- /** Formatted sale price */
1028
- sale_price: z.string(),
1029
- /** Price range (null for simple products) */
1030
- price_range: z.null(),
1031
- /** Currency code (e.g., 'USD', 'EUR') */
1032
- currency_code: z.string(),
1033
- /** Currency symbol (e.g., '$', '€') */
1034
- currency_symbol: z.string(),
1035
- /** Number of decimal places for currency */
1036
- currency_minor_unit: z.number(),
1037
- /** Decimal separator (e.g., '.', ',') */
1038
- currency_decimal_separator: z.string(),
1039
- /** Thousand separator (e.g., ',', '.') */
1040
- currency_thousand_separator: z.string(),
1041
- /** Currency prefix (e.g., '$') */
1042
- currency_prefix: z.string(),
1043
- /** Currency suffix (e.g., 'USD') */
1044
- currency_suffix: z.string(),
1045
- /** Raw price values for calculations */
1046
- raw_prices: z.object({
1047
- /** Precision for price calculations */
1048
- precision: z.number(),
1049
- /** Raw price (in minor units) */
1050
- price: z.string(),
1051
- /** Raw regular price (in minor units) */
1052
- regular_price: z.string(),
1053
- /** Raw sale price (in minor units) */
1054
- sale_price: z.string()
1055
- })
1056
- });
1057
- var orderItemTotalsSchema = z.object({
1058
- /** Line subtotal (before discounts) */
1059
- line_subtotal: z.string(),
1060
- /** Line subtotal tax */
1061
- line_subtotal_tax: z.string(),
1062
- /** Line total (after discounts) */
1063
- line_total: z.string(),
1064
- /** Line total tax */
1065
- line_total_tax: z.string(),
1066
- /** Currency code */
1067
- currency_code: z.string(),
1068
- /** Currency symbol */
1069
- currency_symbol: z.string(),
1070
- /** Currency minor unit */
1071
- currency_minor_unit: z.number(),
1072
- /** Decimal separator */
1073
- currency_decimal_separator: z.string(),
1074
- /** Thousand separator */
1075
- currency_thousand_separator: z.string(),
1076
- /** Currency prefix */
1077
- currency_prefix: z.string(),
1078
- /** Currency suffix */
1079
- currency_suffix: z.string()
1080
- });
1081
- var quantityLimitsSchema = z.object({
1082
- /** Minimum quantity allowed */
1083
- minimum: z.number(),
1084
- /** Maximum quantity allowed */
1085
- maximum: z.number(),
1086
- /** Quantity must be multiple of this value */
1087
- multiple_of: z.number(),
1088
- /** Whether quantity is editable */
1089
- editable: z.boolean()
1090
- });
1091
- var orderItemSchema = z.object({
1092
- /** Unique cart/order item key */
1093
- key: z.string(),
1094
- /** Product ID */
1095
- id: z.number(),
1096
- /** Quantity ordered */
1097
- quantity: z.number(),
1098
- /** Quantity limits for this product */
1099
- quantity_limits: quantityLimitsSchema,
1100
- /** Product name */
1101
- name: z.string(),
1102
- /** Short description */
1103
- short_description: z.string(),
1104
- /** Full description */
1105
- description: z.string(),
1106
- /** Product SKU */
1107
- sku: z.string(),
1108
- /** Low stock warning (null if not low) */
1109
- low_stock_remaining: z.null(),
1110
- /** Whether backorders are allowed */
1111
- backorders_allowed: z.boolean(),
1112
- /** Whether to show backorder badge */
1113
- show_backorder_badge: z.boolean(),
1114
- /** Whether product can only be purchased individually */
1115
- sold_individually: z.boolean(),
1116
- /** Product permalink URL */
1117
- permalink: z.string().url(),
1118
- /** Product images */
1119
- images: z.array(orderItemImageSchema),
1120
- /** Variation attributes (empty for simple products) */
1121
- variation: z.array(z.unknown()),
1122
- /** Custom item data/metadata */
1123
- item_data: z.array(z.unknown()),
1124
- /** Price information */
1125
- prices: orderItemPricesSchema,
1126
- /** Totals for this line item */
1127
- totals: orderItemTotalsSchema,
1128
- /** Catalog visibility setting */
1129
- catalog_visibility: z.string()
1130
- });
1131
- var orderTotalsSchema = z.object({
1132
- /** Subtotal (before discounts and fees) */
1133
- subtotal: z.string(),
1134
- /** Total discount amount */
1135
- total_discount: z.string(),
1136
- /** Total shipping cost */
1137
- total_shipping: z.string(),
1138
- /** Total fees */
1139
- total_fees: z.string(),
1140
- /** Total tax */
1141
- total_tax: z.string(),
1142
- /** Total refund amount */
1143
- total_refund: z.string(),
1144
- /** Final total price */
1145
- total_price: z.string(),
1146
- /** Total items cost (subtotal after item-level discounts) */
1147
- total_items: z.string(),
1148
- /** Tax on items */
1149
- total_items_tax: z.string(),
1150
- /** Tax on fees */
1151
- total_fees_tax: z.string(),
1152
- /** Tax on discounts */
1153
- total_discount_tax: z.string(),
1154
- /** Tax on shipping */
1155
- total_shipping_tax: z.string(),
1156
- /** Tax line items breakdown */
1157
- tax_lines: z.array(z.unknown()),
1158
- /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
1159
- currency_code: z.string(),
1160
- /** Currency symbol (e.g., '$', '€', 'KM') */
1161
- currency_symbol: z.string(),
1162
- /** Number of decimal places for currency */
1163
- currency_minor_unit: z.number(),
1164
- /** Decimal separator (e.g., '.', ',') */
1165
- currency_decimal_separator: z.string(),
1166
- /** Thousand separator (e.g., ',', '.') */
1167
- currency_thousand_separator: z.string(),
1168
- /** Currency prefix (e.g., '$') */
1169
- currency_prefix: z.string(),
1170
- /** Currency suffix (e.g., 'USD') */
1171
- currency_suffix: z.string()
1172
- });
1173
-
1174
- // src/schemas/store-api/order.schema.ts
1175
- var orderStatusEnum = z.enum([
1176
- "pending",
1177
- // Order received, awaiting payment
1178
- "processing",
1179
- // Payment received, order is being processed
1180
- "on-hold",
1181
- // Order on hold, awaiting confirmation
1182
- "completed",
1183
- // Order fulfilled and complete
1184
- "cancelled",
1185
- // Order cancelled by customer or admin
1186
- "refunded",
1187
- // Order refunded
1188
- "failed"
1189
- // Payment failed or order declined
1190
- ]);
1191
- var storeApiOrderSchema = z.object({
1192
- /** Order ID */
1193
- id: z.number(),
1194
- /** Order status */
1195
- status: orderStatusEnum,
1196
- /** Order line items (products purchased) */
1197
- items: z.array(orderItemSchema),
1198
- /** Applied coupons */
1199
- coupons: z.array(z.unknown()),
1200
- /** Order fees */
1201
- fees: z.array(z.unknown()),
1202
- /** Order totals breakdown */
1203
- totals: orderTotalsSchema,
1204
- /** Shipping address */
1205
- shipping_address: addressSchema,
1206
- /** Billing address (includes email) */
1207
- billing_address: billingAddressSchemaMandatory,
1208
- /** Whether order still needs payment */
1209
- needs_payment: z.boolean(),
1210
- /** Whether order needs shipping */
1211
- needs_shipping: z.boolean(),
1212
- /** Payment method requirements */
1213
- payment_requirements: z.array(z.string()),
1214
- /** Order errors (if any) */
1215
- errors: z.array(z.unknown()),
1216
- /** Payment method (optional - returned from checkout) */
1217
- payment_method: z.string().optional(),
1218
- /** Payment method title (optional - returned from checkout) */
1219
- payment_method_title: z.string().optional()
1220
- });
1221
- var checkoutSchema = z.object({
1222
- order_id: z.number(),
1223
- status: z.string(),
1224
- order_key: z.string(),
1225
- customer_note: z.string(),
1226
- customer_id: z.number(),
1227
- billing_address: billingAddressSchemaNonMandatory,
1228
- shipping_address: addressSchemaNonMandatory,
1229
- payment_method: z.string(),
1230
- payment_result: z.object({
1231
- payment_status: z.string(),
1232
- payment_details: z.array(z.unknown()),
1233
- redirect_url: z.string()
1234
- })
1235
- });
1236
- var checkoutInputSchema = z.object({
1237
- payment_method: z.string(),
1238
- payment_data: z.array(
1239
- z.object({
1240
- key: z.string(),
1241
- value: z.union([z.string(), z.boolean()])
1242
- })
1243
- ).optional(),
1244
- billing_address: billingAddressSchemaMandatory.optional(),
1245
- shipping_address: addressSchema.optional(),
1246
- customer_note: z.string().optional(),
1247
- create_account: z.boolean().optional(),
1248
- extensions: z.record(z.string(), z.unknown()).optional()
1249
- });
1250
- var addToCartSchema = z.object({
1251
- /** Description for add to cart action */
1252
- description: z.string(),
1253
- /** Maximum quantity that can be added */
1254
- maximum: z.number(),
1255
- /** Minimum quantity that can be added */
1256
- minimum: z.number(),
1257
- /** Quantity must be a multiple of this number */
1258
- multiple_of: z.number(),
1259
- /** Text for add to cart button */
1260
- text: z.string(),
1261
- /** URL for add to cart action */
1262
- url: z.string()
1263
- });
1264
- var embeddedCategorySchema = z.object({
1265
- /** Category unique identifier */
1266
- id: z.number(),
1267
- /** Category display name */
1268
- name: z.string(),
1269
- /** URL-friendly category identifier */
1270
- slug: z.string(),
1271
- /** Link to category page */
1272
- link: z.string(),
1273
- /** Parent category ID (0 for root categories) - optional in embedded */
1274
- parent: z.number().optional(),
1275
- /** Category description - optional in embedded */
1276
- description: z.string().optional(),
1277
- /** Display type - optional in embedded */
1278
- display: z.string().optional(),
1279
- /** Category image - optional in embedded */
1280
- image: productImageSchema.nullable().optional(),
1281
- /** Menu order for sorting - optional in embedded */
1282
- menu_order: z.number().optional(),
1283
- /** Number of products in this category - optional in embedded */
1284
- count: z.number().optional()
1285
- });
1286
- var productCategorySchema = z.object({
1287
- /** Category unique identifier */
1288
- id: z.number(),
1289
- /** Category display name */
1290
- name: z.string(),
1291
- /** URL-friendly category identifier */
1292
- slug: z.string(),
1293
- /** Parent category ID (0 for root categories) */
1294
- parent: z.number(),
1295
- /** Category description */
1296
- description: z.string(),
1297
- /** Category image */
1298
- image: productImageSchema.nullable(),
1299
- /** Menu order for sorting */
1300
- menu_order: z.number().optional(),
1301
- /** Number of products in this category */
1302
- count: z.number()
1303
- });
1304
- var storeProductsSearchParamsSchema = z.object({
1305
- // Pagination
1306
- /** Current page number */
1307
- page: z.number(),
1308
- /** Number of products per page (1-100) */
1309
- per_page: z.number().min(1).max(100).default(10),
1310
- // Ordering
1311
- /** Field to order results by */
1312
- orderby: z.enum([
1313
- "date",
1314
- "id",
1315
- "include",
1316
- "title",
1317
- "slug",
1318
- "price",
1319
- "popularity",
1320
- "rating",
1321
- "menu_order",
1322
- "date_modified"
1323
- ]).optional(),
1324
- /** Sort order (ascending or descending) */
1325
- order: z.enum(["asc", "desc"]).optional(),
1326
- // Filtering
1327
- /** Search query string */
1328
- search: z.string().optional(),
1329
- /** Exact slug match */
1330
- slug: z.string().optional(),
1331
- // Date filtering
1332
- /** Filter products published after this date */
1333
- after: z.string().datetime().optional(),
1334
- /** Filter products published before this date */
1335
- before: z.string().datetime().optional(),
1336
- /** Filter products modified after this date */
1337
- modified_after: z.string().datetime().optional(),
1338
- /** Filter products modified before this date */
1339
- modified_before: z.string().datetime().optional(),
1340
- // ID filtering
1341
- /** Include specific product IDs */
1342
- include: z.array(z.number()).optional(),
1343
- /** Exclude specific product IDs */
1344
- exclude: z.array(z.number()).optional(),
1345
- // Parent/Child
1346
- /** Filter by parent product IDs */
1347
- parent: z.array(z.number()).optional(),
1348
- /** Exclude products with these parent IDs */
1349
- parent_exclude: z.array(z.number()).optional(),
1350
- // Type & Status
1351
- /** Filter by product type */
1352
- type: z.enum(["simple", "grouped", "external", "variable", "variation"]).optional(),
1353
- /** Filter by product status */
1354
- status: z.enum(["any", "draft", "pending", "private", "publish"]).optional(),
1355
- // Featured
1356
- /** Filter featured products */
1357
- featured: z.boolean().optional(),
1358
- // Visibility
1359
- /** Filter by catalog visibility */
1360
- catalog_visibility: z.enum(["any", "visible", "catalog", "search", "hidden"]).optional(),
1361
- // Stock
1362
- /** Filter by stock status */
1363
- stock_status: z.array(z.enum(["instock", "outofstock", "onbackorder"])).optional(),
1364
- // Category & Tag filtering
1365
- /** Filter by category slug or ID */
1366
- category: z.string().optional(),
1367
- /** Category filter operator */
1368
- category_operator: z.enum(["in", "not_in", "and"]).optional(),
1369
- /** Filter by tag slug or ID */
1370
- tag: z.string().optional(),
1371
- /** Tag filter operator */
1372
- tag_operator: z.enum(["in", "not_in", "and"]).optional(),
1373
- // Attribute filtering
1374
- /** Filter by product attributes */
1375
- attributes: z.array(
1376
- z.object({
1377
- /** Attribute name */
1378
- attribute: z.string(),
1379
- /** Filter by attribute term IDs */
1380
- term_id: z.array(z.number()).optional(),
1381
- /** Filter by attribute term slugs */
1382
- slug: z.array(z.string()).optional(),
1383
- /** Attribute filter operator */
1384
- operator: z.enum(["in", "not_in", "and"]).optional()
1385
- })
1386
- ).optional(),
1387
- /** Relationship between attribute filters */
1388
- attribute_relation: z.enum(["in", "and"]).optional(),
1389
- // Price filtering
1390
- /** Minimum price filter */
1391
- min_price: z.string().optional(),
1392
- /** Maximum price filter */
1393
- max_price: z.string().optional(),
1394
- // Sale status
1395
- /** Filter products on sale */
1396
- on_sale: z.boolean().optional(),
1397
- // Rating filter
1398
- /** Filter by product rating (1-5 stars) */
1399
- rating: z.array(z.number().min(1).max(5)).optional()
1400
- });
1401
-
1402
- // src/schemas/store-api/products.ts
1403
- var productSchema = z.object({
1404
- id: z.number(),
1405
- name: z.string(),
1406
- slug: z.string(),
1407
- type: z.string(),
1408
- variation: z.string(),
1409
- permalink: z.string().url(),
1410
- sku: z.string(),
1411
- short_description: z.string(),
1412
- description: z.string(),
1413
- is_purchasable: z.boolean(),
1414
- is_in_stock: z.boolean(),
1415
- is_on_backorder: z.boolean(),
1416
- low_stock_remaining: z.number().nullable(),
1417
- sold_individually: z.boolean(),
1418
- add_to_cart: addToCartSchema,
1419
- has_options: z.boolean(),
1420
- on_sale: z.boolean(),
1421
- parent: z.number(),
1422
- attributes: z.array(z.unknown()),
1423
- categories: z.array(embeddedCategorySchema),
1424
- tags: z.array(z.unknown()),
1425
- images: z.array(productImageSchema),
1426
- variations: z.array(z.unknown()),
1427
- price_html: z.string(),
1428
- prices: pricesSchema,
1429
- average_rating: z.string(),
1430
- review_count: z.number(),
1431
- extensions: z.record(z.string(), z.unknown())
1432
- });
1433
-
1434
- // src/api/cart.ts
1435
632
  var createCartAPI = (client, endpoints, options) => ({
1436
633
  get: async () => {
1437
634
  const response = await client.get(endpoints.cart);
@@ -1466,8 +663,6 @@ var createCartAPI = (client, endpoints, options) => ({
1466
663
  return handleApiResponse(response, cartSchema, options);
1467
664
  }
1468
665
  });
1469
-
1470
- // src/api/checkout.ts
1471
666
  var createCheckoutAPI = (client, endpoints, options) => ({
1472
667
  get: async () => {
1473
668
  const response = await client.get(endpoints.checkout);
@@ -1478,8 +673,6 @@ var createCheckoutAPI = (client, endpoints, options) => ({
1478
673
  return handleApiResponse(response, checkoutSchema, options);
1479
674
  }
1480
675
  });
1481
-
1482
- // src/api/orders.ts
1483
676
  var createOrdersAPI = (client, endpoints, options) => ({
1484
677
  /**
1485
678
  * Get a single order by ID
@@ -1569,537 +762,6 @@ var createClient = (config) => {
1569
762
  return client;
1570
763
  };
1571
764
 
1572
- // src/schemas/admin-api/enums/enums-raw.ts
1573
- var ORDER_STATUS = [
1574
- "cancelled",
1575
- "completed",
1576
- "pending",
1577
- "processing",
1578
- "on-hold",
1579
- "auto-draft",
1580
- "trash",
1581
- "refunded",
1582
- "failed",
1583
- "checkout-draft"
1584
- ];
1585
- var PAYMENT_METHODS = ["cod", "monri", "pikpay", "bacs", "cheque"];
1586
- var PRODUCT_TYPES = ["simple", "grouped", "external", "variable"];
1587
- var PRODUCT_STATUS = [
1588
- "any",
1589
- "future",
1590
- "trash",
1591
- "draft",
1592
- "pending",
1593
- "private",
1594
- "publish"
1595
- ];
1596
- var STOCK_STATUS = ["instock", "outofstock", "onbackorder"];
1597
- var USER_ROLES = [
1598
- "all",
1599
- "administrator",
1600
- "editor",
1601
- "author",
1602
- "contributor",
1603
- "subscriber",
1604
- "customer",
1605
- "shop_manager",
1606
- "dc_pending_vendor",
1607
- "dc_rejected_vendor",
1608
- "dc_vendor",
1609
- "translator"
1610
- ];
1611
- var REVIEW_STATUS = ["all", "hold", "approved", "spam", "trash"];
1612
- var SORT_ORDER = ["asc", "desc"];
1613
- var COUPONS_ORDER_BY = ["date", "id", "include", "title", "slug", "modified"];
1614
- var PRODUCT_SORT_FIELDS = [
1615
- "date",
1616
- "id",
1617
- "include",
1618
- "title",
1619
- "slug",
1620
- "modified",
1621
- "popularity",
1622
- "rating",
1623
- "menu_order",
1624
- "price"
1625
- ];
1626
- var CATEGORY_SORT_FIELDS = [
1627
- "id",
1628
- "include",
1629
- "name",
1630
- "slug",
1631
- "term_group",
1632
- "description",
1633
- "count"
1634
- ];
1635
- var ORDER_SORT_FIELDS = ["date", "id", "include", "title", "slug", "modified"];
1636
- var ERROR_CODES = ["registration-error-email-exists", "rest_no_route"];
1637
- var CATALOG_VISIBILITY = ["visible", "catalog", "search", "hidden"];
1638
- var CUSTOMER_ROLE = [
1639
- "all",
1640
- "administrator",
1641
- "editor",
1642
- "author",
1643
- "contributor",
1644
- "subscriber",
1645
- "customer",
1646
- "shop_manager"
1647
- ];
1648
- var CUSTOMER_SORT_FIELDS = ["id", "include", "name", "registered_date"];
1649
- var PRODUCT_REVIEWS_SORT_FIELDS = ["date", "date_gmt", "id", "include", "product"];
1650
- var ENUM_RAW = {
1651
- ORDER: {
1652
- STATUS: ORDER_STATUS,
1653
- SORT_FIELDS: ORDER_SORT_FIELDS
1654
- },
1655
- PAYMENT: {
1656
- METHODS: PAYMENT_METHODS
1657
- },
1658
- PRODUCT: {
1659
- TYPES: PRODUCT_TYPES,
1660
- STATUS: PRODUCT_STATUS,
1661
- STOCK_STATUS,
1662
- CATALOG_VISIBILITY,
1663
- SORT_FIELDS: PRODUCT_SORT_FIELDS
1664
- },
1665
- USER: {
1666
- ROLES: USER_ROLES
1667
- },
1668
- REVIEW: {
1669
- STATUS: REVIEW_STATUS,
1670
- SORT_FIELDS: PRODUCT_REVIEWS_SORT_FIELDS
1671
- },
1672
- CATEGORY: {
1673
- SORT_FIELDS: CATEGORY_SORT_FIELDS
1674
- },
1675
- COMMON: {
1676
- SORT_ORDER,
1677
- ERROR_CODES},
1678
- CUSTOMER: {
1679
- ROLE: CUSTOMER_ROLE,
1680
- SORT_FIELDS: CUSTOMER_SORT_FIELDS
1681
- },
1682
- COUPONS: {
1683
- ORDER_BY: COUPONS_ORDER_BY
1684
- }
1685
- };
1686
-
1687
- // src/schemas/admin-api/enums/enums.ts
1688
- var APP_ENUMS = {
1689
- PRODUCT_TYPES: {
1690
- RAW: ENUM_RAW.PRODUCT.TYPES,
1691
- ZOD: z.enum(ENUM_RAW.PRODUCT.TYPES)
1692
- },
1693
- PRODUCT_STATUS: {
1694
- RAW: ENUM_RAW.PRODUCT.STATUS,
1695
- ZOD: z.enum(ENUM_RAW.PRODUCT.STATUS)
1696
- },
1697
- PRODUCT_STOCK_STATUS: {
1698
- RAW: ENUM_RAW.PRODUCT.STOCK_STATUS,
1699
- ZOD: z.enum(ENUM_RAW.PRODUCT.STOCK_STATUS)
1700
- },
1701
- PRODUCT_CATALOG_VISIBILITY: {
1702
- RAW: ENUM_RAW.PRODUCT.CATALOG_VISIBILITY,
1703
- ZOD: z.enum(ENUM_RAW.PRODUCT.CATALOG_VISIBILITY)
1704
- },
1705
- PRODUCT_SORT_FIELDS: {
1706
- RAW: ENUM_RAW.PRODUCT.SORT_FIELDS,
1707
- ZOD: z.enum(ENUM_RAW.PRODUCT.SORT_FIELDS)
1708
- },
1709
- ORDER_STATUS: {
1710
- RAW: ENUM_RAW.ORDER.STATUS,
1711
- ZOD: z.enum(ENUM_RAW.ORDER.STATUS)
1712
- },
1713
- ORDER_SORT_FIELDS: {
1714
- RAW: ENUM_RAW.ORDER.SORT_FIELDS,
1715
- ZOD: z.enum(ENUM_RAW.ORDER.SORT_FIELDS)
1716
- },
1717
- PAYMENT_METHODS: {
1718
- RAW: ENUM_RAW.PAYMENT.METHODS,
1719
- ZOD: z.enum(ENUM_RAW.PAYMENT.METHODS)
1720
- },
1721
- USER_ROLES: {
1722
- RAW: ENUM_RAW.USER.ROLES,
1723
- ZOD: z.enum(ENUM_RAW.USER.ROLES)
1724
- },
1725
- REVIEW_STATUS: {
1726
- RAW: ENUM_RAW.REVIEW.STATUS,
1727
- ZOD: z.enum(ENUM_RAW.REVIEW.STATUS)
1728
- },
1729
- CATEGORY_SORT_FIELDS: {
1730
- RAW: ENUM_RAW.CATEGORY.SORT_FIELDS,
1731
- ZOD: z.enum(ENUM_RAW.CATEGORY.SORT_FIELDS)
1732
- },
1733
- COMMON_SORT_ORDER: {
1734
- RAW: ENUM_RAW.COMMON.SORT_ORDER,
1735
- ZOD: z.enum(ENUM_RAW.COMMON.SORT_ORDER)
1736
- },
1737
- COMMON_ERROR_CODES: {
1738
- RAW: ENUM_RAW.COMMON.ERROR_CODES,
1739
- ZOD: z.enum(ENUM_RAW.COMMON.ERROR_CODES)
1740
- },
1741
- CUSTOMER_ROLE: {
1742
- RAW: ENUM_RAW.CUSTOMER.ROLE,
1743
- ZOD: z.enum(ENUM_RAW.CUSTOMER.ROLE)
1744
- },
1745
- CUSTOMER_SORT_FIELDS: {
1746
- RAW: ENUM_RAW.CUSTOMER.SORT_FIELDS,
1747
- ZOD: z.enum(ENUM_RAW.CUSTOMER.SORT_FIELDS)
1748
- },
1749
- REVIEW_SORT_FIELDS: {
1750
- RAW: ENUM_RAW.REVIEW.SORT_FIELDS,
1751
- ZOD: z.enum(ENUM_RAW.REVIEW.SORT_FIELDS)
1752
- },
1753
- COUPONS_ORDER_BY: {
1754
- RAW: ENUM_RAW.COUPONS.ORDER_BY,
1755
- ZOD: z.enum(ENUM_RAW.COUPONS.ORDER_BY)
1756
- }
1757
- };
1758
- var getAppEnumZod = (key) => APP_ENUMS[key].ZOD;
1759
- var getAppEnumRaw = (key) => APP_ENUMS[key].RAW;
1760
- var basePaginationSchema = z.object({
1761
- page: z.number().positive().default(1),
1762
- per_page: z.number().positive().max(100).default(10),
1763
- offset: z.number().nonnegative().optional()
1764
- });
1765
- var baseFilteringSchema = z.object({
1766
- search: z.string().optional(),
1767
- exclude: z.array(z.number()).default([]),
1768
- include: z.array(z.number()).default([])
1769
- });
1770
- z.object({
1771
- status: z.enum(["publish", "future", "draft", "pending", "private"]).optional()
1772
- });
1773
- z.object({
1774
- "x-wp-total": z.string().transform(Number),
1775
- "x-wp-totalpages": z.string().transform(Number)
1776
- });
1777
- z.object({
1778
- ...basePaginationSchema.shape,
1779
- ...baseFilteringSchema.shape,
1780
- context: z.enum(["view", "edit"]).default("view")
1781
- });
1782
- var wpLinksSchema = z.object({
1783
- self: z.array(z.object({ href: z.string() })),
1784
- collection: z.array(z.object({ href: z.string() })),
1785
- about: z.array(z.object({ href: z.string() })).optional(),
1786
- author: z.array(
1787
- z.object({
1788
- embeddable: z.boolean().optional(),
1789
- href: z.string()
1790
- })
1791
- ).optional()
1792
- });
1793
-
1794
- // src/schemas/admin-api/base/base-wc.schema.ts
1795
- var wcSortingSchema = z.object({
1796
- order: getAppEnumZod("COMMON_SORT_ORDER").default("desc"),
1797
- orderby: z.string().optional()
1798
- });
1799
- var wcDateFilterSchema = z.object({
1800
- after: z.string().datetime().optional(),
1801
- before: z.string().datetime().optional(),
1802
- modified_after: z.string().datetime().optional(),
1803
- modified_before: z.string().datetime().optional(),
1804
- dates_are_gmt: z.boolean().default(false)
1805
- });
1806
- var wcMetaDataSchema = z.object({
1807
- id: z.number(),
1808
- key: z.string(),
1809
- value: z.any()
1810
- });
1811
- var wcAddressSchema = z.object({
1812
- first_name: z.string().default(""),
1813
- last_name: z.string().default(""),
1814
- company: z.string().default(""),
1815
- address_1: z.string().default(""),
1816
- address_2: z.string().default(""),
1817
- city: z.string().default(""),
1818
- state: z.string().default(""),
1819
- postcode: z.string().default(""),
1820
- country: z.string().default("BA"),
1821
- phone: z.string().default(""),
1822
- email: z.string().email().optional()
1823
- });
1824
- var wcBaseParamsSchema = z.object({
1825
- ...basePaginationSchema.shape,
1826
- ...baseFilteringSchema.shape,
1827
- ...wcSortingSchema.shape
1828
- });
1829
- var wcBaseResponseSchema = z.object({
1830
- _links: wpLinksSchema,
1831
- meta_data: z.array(wcMetaDataSchema).optional()
1832
- });
1833
- z.object({
1834
- total: z.number(),
1835
- totalPages: z.number(),
1836
- currentPage: z.number(),
1837
- perPage: z.number()
1838
- });
1839
- var wcErrorResponseSchema = z.object({
1840
- code: getAppEnumZod("COMMON_ERROR_CODES"),
1841
- message: z.string(),
1842
- data: z.object({
1843
- status: z.number()
1844
- }).optional()
1845
- }).passthrough();
1846
-
1847
- // src/schemas/admin-api/coupons/coupon-filter.schema.ts
1848
- var couponFilterSchema = wcBaseParamsSchema.extend({
1849
- orderby: getAppEnumZod("COUPONS_ORDER_BY").default("date"),
1850
- code: z.string().optional()
1851
- });
1852
- var couponSchema = wcBaseResponseSchema.extend({
1853
- id: z.number(),
1854
- code: z.string(),
1855
- amount: z.string(),
1856
- status: z.string(),
1857
- discount_type: z.enum(["percent", "fixed_cart", "fixed_product"]),
1858
- description: z.string(),
1859
- date_expires: z.string().nullable(),
1860
- usage_count: z.number(),
1861
- individual_use: z.boolean(),
1862
- product_ids: z.array(z.number()),
1863
- excluded_product_ids: z.array(z.number()),
1864
- usage_limit: z.number().nullable(),
1865
- usage_limit_per_user: z.number().nullable(),
1866
- limit_usage_to_x_items: z.number().nullable(),
1867
- free_shipping: z.boolean(),
1868
- product_categories: z.array(z.number()),
1869
- excluded_product_categories: z.array(z.number()),
1870
- exclude_sale_items: z.boolean(),
1871
- minimum_amount: z.string(),
1872
- maximum_amount: z.string(),
1873
- email_restrictions: z.array(z.string())
1874
- });
1875
- var createCouponSchema = couponSchema.omit({
1876
- id: true,
1877
- usage_count: true
1878
- }).extend({
1879
- code: z.string().min(1, "Code is required"),
1880
- amount: z.string().min(1, "Amount is required")
1881
- });
1882
- var customerFilterSchema = wcBaseParamsSchema.extend({
1883
- orderby: getAppEnumZod("CUSTOMER_SORT_FIELDS").default("name"),
1884
- role: getAppEnumZod("CUSTOMER_ROLE").default("customer"),
1885
- email: z.string().email().optional()
1886
- });
1887
- var customerSchema = wcBaseResponseSchema.extend({
1888
- id: z.number(),
1889
- username: z.string(),
1890
- first_name: z.string(),
1891
- last_name: z.string(),
1892
- email: z.string().email(),
1893
- role: getAppEnumZod("CUSTOMER_ROLE"),
1894
- date_created: z.string(),
1895
- date_modified: z.string(),
1896
- is_paying_customer: z.boolean(),
1897
- avatar_url: z.string(),
1898
- billing: wcAddressSchema.extend({
1899
- email: z.string().email()
1900
- }),
1901
- shipping: wcAddressSchema
1902
- });
1903
- var createCustomerSchema = customerSchema.pick({
1904
- email: true,
1905
- first_name: true,
1906
- last_name: true,
1907
- shipping: true
1908
- }).extend({
1909
- loyalty_card_number: z.string().optional()
1910
- });
1911
- var updateCustomerSchema = createCustomerSchema.merge(
1912
- customerSchema.pick({
1913
- billing: true
1914
- })
1915
- ).partial();
1916
- var orderFilterSchema = wcBaseParamsSchema.extend({
1917
- orderby: getAppEnumZod("ORDER_SORT_FIELDS").default("date"),
1918
- status: z.array(getAppEnumZod("ORDER_STATUS")).optional(),
1919
- customer: z.number().optional(),
1920
- product: z.number().optional(),
1921
- dp: z.number().default(2).optional()
1922
- // decimal points
1923
- }).merge(wcDateFilterSchema);
1924
- var orderLineItemSchema = z.object({
1925
- id: z.number(),
1926
- name: z.string(),
1927
- product_id: z.number(),
1928
- variation_id: z.number(),
1929
- quantity: z.number(),
1930
- tax_class: z.string(),
1931
- subtotal: z.string(),
1932
- subtotal_tax: z.string(),
1933
- total: z.string(),
1934
- total_tax: z.string(),
1935
- sku: z.string(),
1936
- price: z.number()
1937
- });
1938
- var orderSchema = wcBaseResponseSchema.extend({
1939
- id: z.number(),
1940
- parent_id: z.number(),
1941
- status: getAppEnumZod("ORDER_STATUS"),
1942
- currency: z.string(),
1943
- version: z.string(),
1944
- prices_include_tax: z.boolean(),
1945
- date_created: z.string(),
1946
- date_modified: z.string(),
1947
- discount_total: z.string(),
1948
- shipping_total: z.string(),
1949
- cart_tax: z.string(),
1950
- total: z.string(),
1951
- customer_id: z.number(),
1952
- order_key: z.string(),
1953
- billing: wcAddressSchema.extend({
1954
- email: z.string().email()
1955
- }),
1956
- shipping: wcAddressSchema,
1957
- payment_method: getAppEnumZod("PAYMENT_METHODS"),
1958
- payment_method_title: z.string(),
1959
- line_items: z.array(orderLineItemSchema),
1960
- // specific fields
1961
- payment_url: z.string().optional(),
1962
- pikpay_transaction_id: z.string().optional(),
1963
- pikpay_status: z.string().optional(),
1964
- monri_transaction_id: z.string().optional(),
1965
- monri_status: z.string().optional()
1966
- });
1967
- var paymentMethodFilterSchema = wcBaseParamsSchema.extend({
1968
- enabled: z.boolean().optional()
1969
- });
1970
- var paymentMethodSchema = wcBaseResponseSchema.extend({
1971
- id: getAppEnumZod("PAYMENT_METHODS"),
1972
- title: z.string(),
1973
- description: z.string(),
1974
- enabled: z.boolean(),
1975
- method_title: z.string(),
1976
- method_description: z.string()
1977
- });
1978
- var categoryFilterSchema = wcBaseParamsSchema.extend({
1979
- orderby: getAppEnumZod("CATEGORY_SORT_FIELDS").default("name"),
1980
- hide_empty: z.boolean().default(false),
1981
- parent: z.number().optional(),
1982
- product: z.number().nullable().default(null),
1983
- slug: z.string().optional()
1984
- });
1985
- var productImageSchema2 = z.object({
1986
- id: z.number(),
1987
- date_created: z.string(),
1988
- date_modified: z.string(),
1989
- src: z.string(),
1990
- name: z.string(),
1991
- alt: z.string()
1992
- });
1993
- var productSchema2 = wcBaseResponseSchema.extend({
1994
- id: z.number(),
1995
- name: z.string(),
1996
- slug: z.string(),
1997
- date_created: z.string(),
1998
- date_modified: z.string(),
1999
- type: z.string(),
2000
- status: z.string(),
2001
- featured: z.boolean(),
2002
- catalog_visibility: z.string(),
2003
- description: z.string(),
2004
- short_description: z.string(),
2005
- sku: z.string(),
2006
- price: z.string(),
2007
- regular_price: z.string(),
2008
- sale_price: z.string(),
2009
- stock_status: getAppEnumZod("PRODUCT_STOCK_STATUS"),
2010
- stock_quantity: z.number().nullable(),
2011
- categories: z.array(
2012
- z.object({
2013
- id: z.number(),
2014
- name: z.string(),
2015
- slug: z.string()
2016
- })
2017
- ),
2018
- images: z.array(productImageSchema2),
2019
- attributes: z.array(
2020
- z.object({
2021
- id: z.number(),
2022
- name: z.string(),
2023
- position: z.number(),
2024
- visible: z.boolean(),
2025
- variation: z.boolean(),
2026
- options: z.array(z.string())
2027
- })
2028
- ),
2029
- meta_data: z.array(wcMetaDataSchema),
2030
- on_sale: z.boolean(),
2031
- manufacturer: z.string().optional()
2032
- });
2033
-
2034
- // src/schemas/admin-api/products/category.schema.ts
2035
- var productCategorySchema2 = wcBaseResponseSchema.extend({
2036
- id: z.number(),
2037
- name: z.string(),
2038
- slug: z.string(),
2039
- parent: z.number(),
2040
- description: z.string(),
2041
- display: z.string(),
2042
- image: productImageSchema2.nullable(),
2043
- menu_order: z.number(),
2044
- count: z.number()
2045
- });
2046
- var productFilterSchema = wcBaseParamsSchema.extend({
2047
- orderby: getAppEnumZod("PRODUCT_SORT_FIELDS").default("date"),
2048
- status: getAppEnumZod("PRODUCT_STATUS").default("any"),
2049
- type: getAppEnumZod("PRODUCT_TYPES").optional(),
2050
- sku: z.string().optional(),
2051
- featured: z.boolean().optional(),
2052
- category: z.string().optional(),
2053
- tag: z.string().optional(),
2054
- shipping_class: z.string().optional(),
2055
- attribute: z.string().optional(),
2056
- attribute_term: z.string().optional(),
2057
- stock_status: getAppEnumZod("PRODUCT_STOCK_STATUS").optional(),
2058
- on_sale: z.boolean().optional(),
2059
- min_price: z.string().optional(),
2060
- max_price: z.string().optional()
2061
- }).merge(wcDateFilterSchema);
2062
- var createCategorySchema = productCategorySchema2.omit({
2063
- id: true,
2064
- count: true
2065
- }).extend({
2066
- name: z.string().min(1, "Name is required")
2067
- });
2068
-
2069
- // src/schemas/admin-api/index.ts
2070
- var schemas = {
2071
- resources: {
2072
- product: {
2073
- filter: productFilterSchema,
2074
- entity: productSchema2,
2075
- category: {
2076
- filter: categoryFilterSchema,
2077
- entity: productCategorySchema2
2078
- }
2079
- },
2080
- order: {
2081
- filter: orderFilterSchema,
2082
- entity: orderSchema,
2083
- lineItem: orderLineItemSchema
2084
- },
2085
- customer: {
2086
- filter: customerFilterSchema,
2087
- entity: customerSchema,
2088
- create: createCustomerSchema,
2089
- update: updateCustomerSchema
2090
- },
2091
- coupon: {
2092
- filter: couponFilterSchema,
2093
- entity: couponSchema,
2094
- create: createCouponSchema
2095
- },
2096
- paymentMethod: {
2097
- filter: paymentMethodFilterSchema,
2098
- entity: paymentMethodSchema
2099
- }
2100
- }
2101
- };
2102
-
2103
- export { WooCommerceApiError, WooCommerceDataValidationError, addToCartInputSchema, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema 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, paymentMethodSchema, productCategorySchema, productImageSchema, productSchema, removeCartItemInputSchema, schemas, storeProductsSearchParamsSchema as searchParamsSchema, selectShippingRateInputSchema, storeApiOrderSchema, updateCartItemInputSchema, updateCustomerInputSchema, updateCustomerSchema, wcErrorResponseSchema };
765
+ export { WooCommerceApiError, WooCommerceDataValidationError, createClient };
2104
766
  //# sourceMappingURL=index.mjs.map
2105
767
  //# sourceMappingURL=index.mjs.map