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

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