@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
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var axios = require('axios');
4
+ var storeApi = require('@atomic-solutions/schemas/woocommerce/store-api');
4
5
  var zod = require('zod');
5
6
 
6
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -449,9 +450,9 @@ var setupRequestInterceptor = (axiosInstance, config, client) => {
449
450
  axiosInstance.interceptors.request.use(
450
451
  async (requestConfig) => {
451
452
  const url = requestConfig.url;
452
- if (requiresAuth(url) && config.jwtToken) {
453
+ if (config.jwtToken) {
453
454
  const token = await config.jwtToken.get();
454
- if (token) {
455
+ if (token && (requiresAuth(url) || requiresCartAuth(url))) {
455
456
  requestConfig.headers.Authorization = `Bearer ${token}`;
456
457
  if (config.debug) {
457
458
  debug("Injected JWT token for", url);
@@ -460,10 +461,11 @@ var setupRequestInterceptor = (axiosInstance, config, client) => {
460
461
  }
461
462
  if (requiresCartAuth(url)) {
462
463
  const headers = await config.cartHeaders.get();
464
+ const isAuthenticated = !!await config.jwtToken?.get();
463
465
  if (headers.nonce) {
464
466
  requestConfig.headers.Nonce = headers.nonce;
465
467
  }
466
- if (headers.cartToken) {
468
+ if (headers.cartToken && !isAuthenticated) {
467
469
  requestConfig.headers["Cart-Token"] = headers.cartToken;
468
470
  }
469
471
  requestConfig.headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
@@ -631,742 +633,50 @@ var setupErrorInterceptor = (axiosInstance, config, client) => {
631
633
  }
632
634
  );
633
635
  };
634
- var addressSchema = zod.z.object({
635
- /** First name */
636
- first_name: zod.z.string().min(1, "First name is required"),
637
- /** Last name */
638
- last_name: zod.z.string().min(1, "Last name is required"),
639
- /** Company name (optional) */
640
- company: zod.z.string(),
641
- /** Address line 1 */
642
- address_1: zod.z.string().min(1, "Address is required"),
643
- /** Address line 2 (optional) */
644
- address_2: zod.z.string(),
645
- /** City */
646
- city: zod.z.string().min(1, "City is required"),
647
- /** State/Province/Region */
648
- state: zod.z.string(),
649
- /** Postal code */
650
- postcode: zod.z.string().min(1, "Postal code is required"),
651
- /** Country code (ISO 3166-1 alpha-2) */
652
- country: zod.z.string(),
653
- /** Phone number */
654
- phone: zod.z.string().min(1, "Phone number is required")
655
- });
656
- var addressSchemaNonMandatory = zod.z.object({
657
- /** First name */
658
- first_name: zod.z.string(),
659
- /** Last name */
660
- last_name: zod.z.string(),
661
- /** Company name (optional) */
662
- company: zod.z.string(),
663
- /** Address line 1 */
664
- address_1: zod.z.string(),
665
- /** Address line 2 (optional) */
666
- address_2: zod.z.string(),
667
- /** City */
668
- city: zod.z.string(),
669
- /** State/Province/Region */
670
- state: zod.z.string(),
671
- /** Postal code */
672
- postcode: zod.z.string(),
673
- /** Country code (ISO 3166-1 alpha-2) */
674
- country: zod.z.string(),
675
- /** Phone number */
676
- phone: zod.z.string()
677
- });
678
- var billingAddressSchemaMandatory = addressSchema.extend({
679
- /** Email address (required for billing) */
680
- email: zod.z.string().email("Valid email is required")
681
- });
682
- var billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({
683
- /** Email address (can be null for guest carts) */
684
- email: zod.z.string().nullable()
685
- });
686
- var moneySchema = zod.z.object({
687
- /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
688
- currency_code: zod.z.string(),
689
- /** Currency symbol (e.g., '$', '€', 'KM') */
690
- currency_symbol: zod.z.string(),
691
- /** Number of decimal places (e.g., 2 for dollars/euros) */
692
- currency_minor_unit: zod.z.number(),
693
- /** Decimal separator character (e.g., '.', ',') */
694
- currency_decimal_separator: zod.z.string(),
695
- /** Thousands separator character (e.g., ',', '.') */
696
- currency_thousand_separator: zod.z.string(),
697
- /** Currency symbol prefix (empty if symbol is suffix) */
698
- currency_prefix: zod.z.string(),
699
- /** Currency symbol suffix (empty if symbol is prefix) */
700
- currency_suffix: zod.z.string()
701
- });
702
- var productImageSchema = zod.z.object({
703
- /** Alternative text for the image */
704
- alt: zod.z.string(),
705
- /** Image unique identifier */
706
- id: zod.z.number(),
707
- /** Image filename */
708
- name: zod.z.string(),
709
- /** Available image sizes in JSON format */
710
- sizes: zod.z.string(),
711
- /** Full-size image URL */
712
- src: zod.z.string().url(),
713
- /** Srcset attribute for responsive images */
714
- srcset: zod.z.string(),
715
- /** Thumbnail image URL */
716
- thumbnail: zod.z.string().url()
717
- });
718
- var cartItemImageSchema = zod.z.object({
719
- /** Image ID */
720
- id: zod.z.number(),
721
- /** Full image URL */
722
- src: zod.z.string(),
723
- /** Thumbnail URL */
724
- thumbnail: zod.z.string(),
725
- /** Responsive image srcset */
726
- srcset: zod.z.string(),
727
- /** Responsive image sizes */
728
- sizes: zod.z.string(),
729
- /** Image name */
730
- name: zod.z.string(),
731
- /** Image alt text */
732
- alt: zod.z.string()
733
- });
734
- var pricesSchema = zod.z.object({
735
- /** Current active price (sale price if on sale, otherwise regular) */
736
- price: zod.z.string(),
737
- /** Regular price (before any discounts) */
738
- regular_price: zod.z.string(),
739
- /** Sale price (empty string if not on sale) */
740
- sale_price: zod.z.string(),
741
- /** Price range for variable products (null for simple products) */
742
- price_range: zod.z.object({
743
- min_amount: zod.z.string(),
744
- max_amount: zod.z.string()
745
- }).nullable(),
746
- /** Raw price data without formatting */
747
- raw_prices: zod.z.object({
748
- /** Decimal precision */
749
- precision: zod.z.number(),
750
- /** Raw price value */
751
- price: zod.z.string(),
752
- /** Raw regular price value */
753
- regular_price: zod.z.string(),
754
- /** Raw sale price value */
755
- sale_price: zod.z.string()
756
- }).optional()
757
- }).merge(moneySchema);
758
-
759
- // src/schemas/store-api/cart-item.schema.ts
760
- var itemTotalsSchema = zod.z.object({
761
- /** Subtotal before taxes */
762
- line_subtotal: zod.z.string(),
763
- /** Tax amount on subtotal */
764
- line_subtotal_tax: zod.z.string(),
765
- /** Total after discounts, before taxes */
766
- line_total: zod.z.string(),
767
- /** Tax amount on total */
768
- line_total_tax: zod.z.string()
769
- }).merge(moneySchema);
770
- var cartItemSchema = zod.z.object({
771
- /** Unique cart item key (use this for update/remove operations) */
772
- key: zod.z.string(),
773
- /** Product ID */
774
- id: zod.z.number(),
775
- /** Quantity of this item in cart */
776
- quantity: zod.z.number(),
777
- /** Quantity limits for this product */
778
- quantity_limits: zod.z.object({
779
- /** Minimum quantity allowed */
780
- minimum: zod.z.number(),
781
- /** Maximum quantity allowed */
782
- maximum: zod.z.number(),
783
- /** Quantity must be multiple of this value */
784
- multiple_of: zod.z.number(),
785
- /** Whether quantity can be changed */
786
- editable: zod.z.boolean()
787
- }),
788
- /** Product name */
789
- name: zod.z.string(),
790
- /** Short product description */
791
- short_description: zod.z.string(),
792
- /** Full product description */
793
- description: zod.z.string(),
794
- /** Product SKU */
795
- sku: zod.z.string(),
796
- /** Remaining stock count if low (null if not low or unlimited) */
797
- low_stock_remaining: zod.z.number().nullable(),
798
- /** Whether backorders are allowed */
799
- backorders_allowed: zod.z.boolean(),
800
- /** Whether to show backorder badge */
801
- show_backorder_badge: zod.z.boolean(),
802
- /** Whether product can only be purchased individually */
803
- sold_individually: zod.z.boolean(),
804
- /** Product permalink URL */
805
- permalink: zod.z.string(),
806
- /** Product images */
807
- images: zod.z.array(cartItemImageSchema),
808
- /** Variation attributes (for variable products) */
809
- variation: zod.z.array(
810
- zod.z.object({
811
- /** Attribute name (e.g., 'Color', 'Size') */
812
- attribute: zod.z.string(),
813
- /** Selected value (e.g., 'Red', 'Large') */
814
- value: zod.z.string()
815
- })
816
- ),
817
- /** Additional item data/metadata */
818
- item_data: zod.z.array(
819
- zod.z.object({
820
- key: zod.z.string(),
821
- value: zod.z.string()
822
- })
823
- ),
824
- /** Product pricing information */
825
- prices: pricesSchema,
826
- /** Line item totals */
827
- totals: itemTotalsSchema,
828
- /** Catalog visibility setting */
829
- catalog_visibility: zod.z.string(),
830
- /** Product type */
831
- type: zod.z.enum(["simple", "variable", "grouped", "external"]),
832
- /** Extension data from plugins */
833
- extensions: zod.z.record(zod.z.string(), zod.z.unknown())
834
- });
835
- var cartTotalsSchema = zod.z.object({
836
- /** Total of all cart items (before discounts and taxes) */
837
- total_items: zod.z.string(),
838
- /** Tax on cart items */
839
- total_items_tax: zod.z.string(),
840
- /** Total fees */
841
- total_fees: zod.z.string(),
842
- /** Tax on fees */
843
- total_fees_tax: zod.z.string(),
844
- /** Total discount amount from coupons */
845
- total_discount: zod.z.string(),
846
- /** Tax on discounts */
847
- total_discount_tax: zod.z.string(),
848
- /** Shipping cost (null if not calculated yet) */
849
- total_shipping: zod.z.string().nullable(),
850
- /** Shipping tax (null if not calculated yet) */
851
- total_shipping_tax: zod.z.string().nullable(),
852
- /** Final total price (includes all taxes and fees) */
853
- total_price: zod.z.string(),
854
- /** Total tax amount */
855
- total_tax: zod.z.string(),
856
- /** Tax breakdown by rate */
857
- tax_lines: zod.z.array(
858
- zod.z.object({
859
- /** Tax rate name */
860
- name: zod.z.string(),
861
- /** Tax amount */
862
- price: zod.z.string(),
863
- /** Tax rate percentage */
864
- rate: zod.z.string()
865
- })
866
- )
867
- }).merge(moneySchema);
868
- var cartCouponSchema = zod.z.object({
869
- /** Coupon code */
870
- code: zod.z.string(),
871
- /** Discount totals for this coupon */
872
- totals: zod.z.object({
873
- /** Total discount amount (before tax) */
874
- total_discount: zod.z.string(),
875
- /** Tax amount on discount */
876
- total_discount_tax: zod.z.string()
877
- }).merge(moneySchema)
878
- });
879
- var shippingRateSchema = zod.z.object({
880
- /** Unique rate identifier (format: instance_id:method_id) */
881
- rate_id: zod.z.string(),
882
- /** Shipping method name */
883
- name: zod.z.string(),
884
- /** Shipping method description */
885
- description: zod.z.string(),
886
- /** Estimated delivery time */
887
- delivery_time: zod.z.string(),
888
- /** Shipping cost */
889
- price: zod.z.string(),
890
- /** Shipping instance ID */
891
- instance_id: zod.z.number(),
892
- /** Shipping method ID */
893
- method_id: zod.z.string(),
894
- /** Additional metadata for this shipping method */
895
- meta_data: zod.z.array(
896
- zod.z.object({
897
- key: zod.z.string(),
898
- value: zod.z.string()
899
- })
900
- ),
901
- /** Whether this rate is currently selected */
902
- selected: zod.z.boolean(),
903
- /** Currency code for the price */
904
- currency_code: zod.z.string(),
905
- /** Currency symbol for the price */
906
- currency_symbol: zod.z.string()
907
- });
908
- var shippingPackageSchema = zod.z.object({
909
- /** Package identifier (0-indexed) */
910
- package_id: zod.z.number(),
911
- /** Package name/label */
912
- name: zod.z.string(),
913
- /** Shipping destination address */
914
- destination: zod.z.object({
915
- address_1: zod.z.string(),
916
- address_2: zod.z.string().optional(),
917
- city: zod.z.string(),
918
- state: zod.z.string(),
919
- postcode: zod.z.string(),
920
- country: zod.z.string()
921
- }),
922
- /** Items included in this package */
923
- items: zod.z.array(
924
- zod.z.object({
925
- /** Cart item key */
926
- key: zod.z.string(),
927
- /** Product name */
928
- name: zod.z.string(),
929
- /** Quantity in package */
930
- quantity: zod.z.number()
931
- })
932
- ),
933
- /** Available shipping rates for this package */
934
- shipping_rates: zod.z.array(shippingRateSchema)
935
- });
936
-
937
- // src/schemas/store-api/cart.ts
938
- var cartSchema = zod.z.object({
939
- items: zod.z.array(cartItemSchema),
940
- items_count: zod.z.number(),
941
- items_weight: zod.z.number(),
942
- needs_payment: zod.z.boolean(),
943
- needs_shipping: zod.z.boolean(),
944
- payment_methods: zod.z.array(zod.z.enum(["cod", "monri"])),
945
- payment_requirements: zod.z.array(zod.z.string()),
946
- has_calculated_shipping: zod.z.boolean(),
947
- shipping_address: addressSchemaNonMandatory,
948
- billing_address: billingAddressSchemaNonMandatory,
949
- shipping_rates: zod.z.array(shippingPackageSchema),
950
- coupons: zod.z.array(cartCouponSchema),
951
- totals: cartTotalsSchema,
952
- errors: zod.z.array(
953
- zod.z.object({
954
- code: zod.z.string(),
955
- message: zod.z.string()
956
- })
957
- ),
958
- extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
959
- cross_sells: zod.z.array(zod.z.unknown()),
960
- fees: zod.z.array(zod.z.unknown())
961
- });
962
- zod.z.object({
963
- id: zod.z.number(),
964
- quantity: zod.z.number().int().positive(),
965
- variation: zod.z.array(
966
- zod.z.object({
967
- attribute: zod.z.string(),
968
- value: zod.z.string()
969
- })
970
- ).optional()
971
- });
972
- zod.z.object({
973
- key: zod.z.string(),
974
- quantity: zod.z.number().int().positive()
975
- });
976
- zod.z.object({
977
- key: zod.z.string()
978
- });
979
- zod.z.object({
980
- code: zod.z.string().min(1)
981
- });
982
- zod.z.object({
983
- billing_address: billingAddressSchemaMandatory.partial(),
984
- shipping_address: addressSchema.partial()
985
- }).partial();
986
- zod.z.object({
987
- package_id: zod.z.union([zod.z.number(), zod.z.string()]).default(0),
988
- rate_id: zod.z.string()
989
- });
990
- var orderItemImageSchema = zod.z.object({
991
- /** Image ID */
992
- id: zod.z.number(),
993
- /** Full image URL */
994
- src: zod.z.string().url(),
995
- /** Thumbnail URL */
996
- thumbnail: zod.z.string().url(),
997
- /** Responsive image srcset */
998
- srcset: zod.z.string(),
999
- /** Responsive image sizes attribute */
1000
- sizes: zod.z.string(),
1001
- /** Image name */
1002
- name: zod.z.string(),
1003
- /** Image alt text */
1004
- alt: zod.z.string()
1005
- });
1006
- var orderItemPricesSchema = zod.z.object({
1007
- /** Formatted price (current price) */
1008
- price: zod.z.string(),
1009
- /** Formatted regular price */
1010
- regular_price: zod.z.string(),
1011
- /** Formatted sale price */
1012
- sale_price: zod.z.string(),
1013
- /** Price range (null for simple products) */
1014
- price_range: zod.z.null(),
1015
- /** Currency code (e.g., 'USD', 'EUR') */
1016
- currency_code: zod.z.string(),
1017
- /** Currency symbol (e.g., '$', '€') */
1018
- currency_symbol: zod.z.string(),
1019
- /** Number of decimal places for currency */
1020
- currency_minor_unit: zod.z.number(),
1021
- /** Decimal separator (e.g., '.', ',') */
1022
- currency_decimal_separator: zod.z.string(),
1023
- /** Thousand separator (e.g., ',', '.') */
1024
- currency_thousand_separator: zod.z.string(),
1025
- /** Currency prefix (e.g., '$') */
1026
- currency_prefix: zod.z.string(),
1027
- /** Currency suffix (e.g., 'USD') */
1028
- currency_suffix: zod.z.string(),
1029
- /** Raw price values for calculations */
1030
- raw_prices: zod.z.object({
1031
- /** Precision for price calculations */
1032
- precision: zod.z.number(),
1033
- /** Raw price (in minor units) */
1034
- price: zod.z.string(),
1035
- /** Raw regular price (in minor units) */
1036
- regular_price: zod.z.string(),
1037
- /** Raw sale price (in minor units) */
1038
- sale_price: zod.z.string()
1039
- })
1040
- });
1041
- var orderItemTotalsSchema = zod.z.object({
1042
- /** Line subtotal (before discounts) */
1043
- line_subtotal: zod.z.string(),
1044
- /** Line subtotal tax */
1045
- line_subtotal_tax: zod.z.string(),
1046
- /** Line total (after discounts) */
1047
- line_total: zod.z.string(),
1048
- /** Line total tax */
1049
- line_total_tax: zod.z.string(),
1050
- /** Currency code */
1051
- currency_code: zod.z.string(),
1052
- /** Currency symbol */
1053
- currency_symbol: zod.z.string(),
1054
- /** Currency minor unit */
1055
- currency_minor_unit: zod.z.number(),
1056
- /** Decimal separator */
1057
- currency_decimal_separator: zod.z.string(),
1058
- /** Thousand separator */
1059
- currency_thousand_separator: zod.z.string(),
1060
- /** Currency prefix */
1061
- currency_prefix: zod.z.string(),
1062
- /** Currency suffix */
1063
- currency_suffix: zod.z.string()
1064
- });
1065
- var quantityLimitsSchema = zod.z.object({
1066
- /** Minimum quantity allowed */
1067
- minimum: zod.z.number(),
1068
- /** Maximum quantity allowed */
1069
- maximum: zod.z.number(),
1070
- /** Quantity must be multiple of this value */
1071
- multiple_of: zod.z.number(),
1072
- /** Whether quantity is editable */
1073
- editable: zod.z.boolean()
1074
- });
1075
- var orderItemSchema = zod.z.object({
1076
- /** Unique cart/order item key */
1077
- key: zod.z.string(),
1078
- /** Product ID */
1079
- id: zod.z.number(),
1080
- /** Quantity ordered */
1081
- quantity: zod.z.number(),
1082
- /** Quantity limits for this product */
1083
- quantity_limits: quantityLimitsSchema,
1084
- /** Product name */
1085
- name: zod.z.string(),
1086
- /** Short description */
1087
- short_description: zod.z.string(),
1088
- /** Full description */
1089
- description: zod.z.string(),
1090
- /** Product SKU */
1091
- sku: zod.z.string(),
1092
- /** Low stock warning (null if not low) */
1093
- low_stock_remaining: zod.z.null(),
1094
- /** Whether backorders are allowed */
1095
- backorders_allowed: zod.z.boolean(),
1096
- /** Whether to show backorder badge */
1097
- show_backorder_badge: zod.z.boolean(),
1098
- /** Whether product can only be purchased individually */
1099
- sold_individually: zod.z.boolean(),
1100
- /** Product permalink URL */
1101
- permalink: zod.z.string().url(),
1102
- /** Product images */
1103
- images: zod.z.array(orderItemImageSchema),
1104
- /** Variation attributes (empty for simple products) */
1105
- variation: zod.z.array(zod.z.unknown()),
1106
- /** Custom item data/metadata */
1107
- item_data: zod.z.array(zod.z.unknown()),
1108
- /** Price information */
1109
- prices: orderItemPricesSchema,
1110
- /** Totals for this line item */
1111
- totals: orderItemTotalsSchema,
1112
- /** Catalog visibility setting */
1113
- catalog_visibility: zod.z.string()
1114
- });
1115
- var orderTotalsSchema = zod.z.object({
1116
- /** Subtotal (before discounts and fees) */
1117
- subtotal: zod.z.string(),
1118
- /** Total discount amount */
1119
- total_discount: zod.z.string(),
1120
- /** Total shipping cost */
1121
- total_shipping: zod.z.string(),
1122
- /** Total fees */
1123
- total_fees: zod.z.string(),
1124
- /** Total tax */
1125
- total_tax: zod.z.string(),
1126
- /** Total refund amount */
1127
- total_refund: zod.z.string(),
1128
- /** Final total price */
1129
- total_price: zod.z.string(),
1130
- /** Total items cost (subtotal after item-level discounts) */
1131
- total_items: zod.z.string(),
1132
- /** Tax on items */
1133
- total_items_tax: zod.z.string(),
1134
- /** Tax on fees */
1135
- total_fees_tax: zod.z.string(),
1136
- /** Tax on discounts */
1137
- total_discount_tax: zod.z.string(),
1138
- /** Tax on shipping */
1139
- total_shipping_tax: zod.z.string(),
1140
- /** Tax line items breakdown */
1141
- tax_lines: zod.z.array(zod.z.unknown()),
1142
- /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
1143
- currency_code: zod.z.string(),
1144
- /** Currency symbol (e.g., '$', '€', 'KM') */
1145
- currency_symbol: zod.z.string(),
1146
- /** Number of decimal places for currency */
1147
- currency_minor_unit: zod.z.number(),
1148
- /** Decimal separator (e.g., '.', ',') */
1149
- currency_decimal_separator: zod.z.string(),
1150
- /** Thousand separator (e.g., ',', '.') */
1151
- currency_thousand_separator: zod.z.string(),
1152
- /** Currency prefix (e.g., '$') */
1153
- currency_prefix: zod.z.string(),
1154
- /** Currency suffix (e.g., 'USD') */
1155
- currency_suffix: zod.z.string()
1156
- });
1157
-
1158
- // src/schemas/store-api/order.schema.ts
1159
- var orderStatusEnum = zod.z.enum([
1160
- "pending",
1161
- // Order received, awaiting payment
1162
- "processing",
1163
- // Payment received, order is being processed
1164
- "on-hold",
1165
- // Order on hold, awaiting confirmation
1166
- "completed",
1167
- // Order fulfilled and complete
1168
- "cancelled",
1169
- // Order cancelled by customer or admin
1170
- "refunded",
1171
- // Order refunded
1172
- "failed"
1173
- // Payment failed or order declined
1174
- ]);
1175
- var storeApiOrderSchema = zod.z.object({
1176
- /** Order ID */
1177
- id: zod.z.number(),
1178
- /** Order status */
1179
- status: orderStatusEnum,
1180
- /** Order line items (products purchased) */
1181
- items: zod.z.array(orderItemSchema),
1182
- /** Applied coupons */
1183
- coupons: zod.z.array(zod.z.unknown()),
1184
- /** Order fees */
1185
- fees: zod.z.array(zod.z.unknown()),
1186
- /** Order totals breakdown */
1187
- totals: orderTotalsSchema,
1188
- /** Shipping address */
1189
- shipping_address: addressSchema,
1190
- /** Billing address (includes email) */
1191
- billing_address: billingAddressSchemaMandatory,
1192
- /** Whether order still needs payment */
1193
- needs_payment: zod.z.boolean(),
1194
- /** Whether order needs shipping */
1195
- needs_shipping: zod.z.boolean(),
1196
- /** Payment method requirements */
1197
- payment_requirements: zod.z.array(zod.z.string()),
1198
- /** Order errors (if any) */
1199
- errors: zod.z.array(zod.z.unknown()),
1200
- /** Payment method (optional - returned from checkout) */
1201
- payment_method: zod.z.string().optional(),
1202
- /** Payment method title (optional - returned from checkout) */
1203
- payment_method_title: zod.z.string().optional()
1204
- });
1205
- var checkoutSchema = zod.z.object({
1206
- order_id: zod.z.number(),
1207
- status: zod.z.string(),
1208
- order_key: zod.z.string(),
1209
- customer_note: zod.z.string(),
1210
- customer_id: zod.z.number(),
1211
- billing_address: billingAddressSchemaNonMandatory,
1212
- shipping_address: addressSchemaNonMandatory,
1213
- payment_method: zod.z.string(),
1214
- payment_result: zod.z.object({
1215
- payment_status: zod.z.string(),
1216
- payment_details: zod.z.array(zod.z.unknown()),
1217
- redirect_url: zod.z.string()
1218
- })
1219
- });
1220
- zod.z.object({
1221
- payment_method: zod.z.string(),
1222
- payment_data: zod.z.array(
1223
- zod.z.object({
1224
- key: zod.z.string(),
1225
- value: zod.z.union([zod.z.string(), zod.z.boolean()])
1226
- })
1227
- ).optional(),
1228
- billing_address: billingAddressSchemaMandatory.optional(),
1229
- shipping_address: addressSchema.optional(),
1230
- customer_note: zod.z.string().optional(),
1231
- create_account: zod.z.boolean().optional(),
1232
- extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
1233
- });
1234
- var addToCartSchema = zod.z.object({
1235
- /** Description for add to cart action */
1236
- description: zod.z.string(),
1237
- /** Maximum quantity that can be added */
1238
- maximum: zod.z.number(),
1239
- /** Minimum quantity that can be added */
1240
- minimum: zod.z.number(),
1241
- /** Quantity must be a multiple of this number */
1242
- multiple_of: zod.z.number(),
1243
- /** Text for add to cart button */
1244
- text: zod.z.string(),
1245
- /** URL for add to cart action */
1246
- url: zod.z.string()
1247
- });
1248
- var embeddedCategorySchema = zod.z.object({
1249
- /** Category unique identifier */
1250
- id: zod.z.number(),
1251
- /** Category display name */
1252
- name: zod.z.string(),
1253
- /** URL-friendly category identifier */
1254
- slug: zod.z.string(),
1255
- /** Link to category page */
1256
- link: zod.z.string(),
1257
- /** Parent category ID (0 for root categories) - optional in embedded */
1258
- parent: zod.z.number().optional(),
1259
- /** Category description - optional in embedded */
1260
- description: zod.z.string().optional(),
1261
- /** Display type - optional in embedded */
1262
- display: zod.z.string().optional(),
1263
- /** Category image - optional in embedded */
1264
- image: productImageSchema.nullable().optional(),
1265
- /** Menu order for sorting - optional in embedded */
1266
- menu_order: zod.z.number().optional(),
1267
- /** Number of products in this category - optional in embedded */
1268
- count: zod.z.number().optional()
1269
- });
1270
- var productCategorySchema = zod.z.object({
1271
- /** Category unique identifier */
1272
- id: zod.z.number(),
1273
- /** Category display name */
1274
- name: zod.z.string(),
1275
- /** URL-friendly category identifier */
1276
- slug: zod.z.string(),
1277
- /** Parent category ID (0 for root categories) */
1278
- parent: zod.z.number(),
1279
- /** Category description */
1280
- description: zod.z.string(),
1281
- /** Category image */
1282
- image: productImageSchema.nullable(),
1283
- /** Menu order for sorting */
1284
- menu_order: zod.z.number().optional(),
1285
- /** Number of products in this category */
1286
- count: zod.z.number()
1287
- });
1288
-
1289
- // src/schemas/store-api/products.ts
1290
- var productSchema = zod.z.object({
1291
- id: zod.z.number(),
1292
- name: zod.z.string(),
1293
- slug: zod.z.string(),
1294
- type: zod.z.string(),
1295
- variation: zod.z.string(),
1296
- permalink: zod.z.string().url(),
1297
- sku: zod.z.string(),
1298
- short_description: zod.z.string(),
1299
- description: zod.z.string(),
1300
- is_purchasable: zod.z.boolean(),
1301
- is_in_stock: zod.z.boolean(),
1302
- is_on_backorder: zod.z.boolean(),
1303
- low_stock_remaining: zod.z.number().nullable(),
1304
- sold_individually: zod.z.boolean(),
1305
- add_to_cart: addToCartSchema,
1306
- has_options: zod.z.boolean(),
1307
- on_sale: zod.z.boolean(),
1308
- parent: zod.z.number(),
1309
- attributes: zod.z.array(zod.z.unknown()),
1310
- categories: zod.z.array(embeddedCategorySchema),
1311
- tags: zod.z.array(zod.z.unknown()),
1312
- images: zod.z.array(productImageSchema),
1313
- variations: zod.z.array(zod.z.unknown()),
1314
- price_html: zod.z.string(),
1315
- prices: pricesSchema,
1316
- average_rating: zod.z.string(),
1317
- review_count: zod.z.number(),
1318
- extensions: zod.z.record(zod.z.string(), zod.z.unknown())
1319
- });
1320
-
1321
- // src/api/cart.ts
1322
636
  var createCartAPI = (client, endpoints, options) => ({
1323
637
  get: async () => {
1324
638
  const response = await client.get(endpoints.cart);
1325
- return handleApiResponse(response, cartSchema, options);
639
+ return handleApiResponse(response, storeApi.cartSchema, options);
1326
640
  },
1327
641
  addItem: async (input) => {
1328
642
  const response = await client.post(endpoints.addItem, input);
1329
- return handleApiResponse(response, cartSchema, options);
643
+ return handleApiResponse(response, storeApi.cartSchema, options);
1330
644
  },
1331
645
  updateItem: async (input) => {
1332
646
  const response = await client.post(endpoints.updateItem, input);
1333
- return handleApiResponse(response, cartSchema, options);
647
+ return handleApiResponse(response, storeApi.cartSchema, options);
1334
648
  },
1335
649
  removeItem: async (input) => {
1336
650
  const response = await client.post(endpoints.removeItem, input);
1337
- return handleApiResponse(response, cartSchema, options);
651
+ return handleApiResponse(response, storeApi.cartSchema, options);
1338
652
  },
1339
653
  applyCoupon: async (input) => {
1340
654
  const response = await client.post(endpoints.applyCoupon, input);
1341
- return handleApiResponse(response, cartSchema, options);
655
+ return handleApiResponse(response, storeApi.cartSchema, options);
1342
656
  },
1343
657
  removeCoupon: async (input) => {
1344
658
  const response = await client.post(endpoints.removeCoupon, input);
1345
- return handleApiResponse(response, cartSchema, options);
659
+ return handleApiResponse(response, storeApi.cartSchema, options);
1346
660
  },
1347
661
  updateCustomer: async (input) => {
1348
662
  const response = await client.post(endpoints.updateCustomer, input);
1349
- return handleApiResponse(response, cartSchema, options);
663
+ return handleApiResponse(response, storeApi.cartSchema, options);
1350
664
  },
1351
665
  selectShippingRate: async (input) => {
1352
666
  const response = await client.post(endpoints.selectShippingRate, input);
1353
- return handleApiResponse(response, cartSchema, options);
667
+ return handleApiResponse(response, storeApi.cartSchema, options);
1354
668
  }
1355
669
  });
1356
-
1357
- // src/api/checkout.ts
1358
670
  var createCheckoutAPI = (client, endpoints, options) => ({
1359
671
  get: async () => {
1360
672
  const response = await client.get(endpoints.checkout);
1361
- return handleApiResponse(response, checkoutSchema, options);
673
+ return handleApiResponse(response, storeApi.checkoutSchema, options);
1362
674
  },
1363
675
  process: async (input) => {
1364
676
  const response = await client.post(endpoints.checkout, input);
1365
- return handleApiResponse(response, checkoutSchema, options);
677
+ return handleApiResponse(response, storeApi.checkoutSchema, options);
1366
678
  }
1367
679
  });
1368
-
1369
- // src/api/orders.ts
1370
680
  var createOrdersAPI = (client, endpoints, options) => ({
1371
681
  /**
1372
682
  * Get a single order by ID
@@ -1376,21 +686,21 @@ var createOrdersAPI = (client, endpoints, options) => ({
1376
686
  const { id, billing_email, key } = input;
1377
687
  const params = billing_email && key ? { billing_email, key } : void 0;
1378
688
  const response = await client.get(`${endpoints.order}/${id}`, { params });
1379
- return handleApiResponse(response, storeApiOrderSchema, options);
689
+ return handleApiResponse(response, storeApi.storeApiOrderSchema, options);
1380
690
  }
1381
691
  });
1382
692
  var createProductsAPI = (client, endpoints, options) => ({
1383
693
  list: async (params) => {
1384
694
  const response = await client.get(endpoints.products, { params });
1385
- return handlePaginatedApiResponse(response, zod.z.array(productSchema), params, options);
695
+ return handlePaginatedApiResponse(response, zod.z.array(storeApi.productSchema), params, options);
1386
696
  },
1387
697
  get: async (id) => {
1388
698
  const response = await client.get(`${endpoints.products}/${id}`);
1389
- return handleApiResponse(response, productSchema, options);
699
+ return handleApiResponse(response, storeApi.productSchema, options);
1390
700
  },
1391
701
  categories: async () => {
1392
702
  const response = await client.get(endpoints.categories);
1393
- return handleApiResponse(response, zod.z.array(productCategorySchema), options);
703
+ return handleApiResponse(response, zod.z.array(storeApi.productCategorySchema), options);
1394
704
  }
1395
705
  });
1396
706