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