@atomic-solutions/woocommerce-api-client 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -685,6 +685,33 @@ var billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({
685
685
  /** Email address (can be null for guest carts) */
686
686
  email: z.string().nullable()
687
687
  });
688
+ var phoneFormatRegex = /^[+\d][\d\s\-/()]{5,}$/;
689
+ var defaultAddressFormMessages = {
690
+ required: "This field is required",
691
+ email: "Valid email is required",
692
+ postcode: "Postal code is not valid",
693
+ phone: "Invalid phone number"
694
+ };
695
+ var defaultPostcodePattern = /^\d+$/;
696
+ var resolveAddressFormMessages = (messages) => ({ ...defaultAddressFormMessages, ...messages });
697
+ var buildAddressFormShape = (m, postcodePattern) => ({
698
+ first_name: z.string().trim().min(1, m.required),
699
+ last_name: z.string().trim().min(1, m.required),
700
+ company: z.string().trim(),
701
+ address_1: z.string().trim().min(1, m.required),
702
+ address_2: z.string().trim(),
703
+ city: z.string().trim().min(1, m.required),
704
+ postcode: z.string().trim().min(1, m.required).regex(postcodePattern, m.postcode),
705
+ phone: z.string().trim().min(1, m.required).regex(phoneFormatRegex, m.phone)
706
+ });
707
+ var makeAddressFormSchema = (messages = {}, postcodePattern = defaultPostcodePattern) => z.object(buildAddressFormShape(resolveAddressFormMessages(messages), postcodePattern));
708
+ var makeBillingAddressFormSchema = (messages = {}, postcodePattern = defaultPostcodePattern) => {
709
+ const m = resolveAddressFormMessages(messages);
710
+ return z.object({
711
+ ...buildAddressFormShape(m, postcodePattern),
712
+ email: z.string().trim().min(1, m.required).email(m.email)
713
+ });
714
+ };
688
715
  var moneySchema = z.object({
689
716
  /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
690
717
  currency_code: z.string(),
@@ -1939,8 +1966,7 @@ var createCustomerSchema = customerSchema.pick({
1939
1966
  last_name: true,
1940
1967
  shipping: true
1941
1968
  }).extend({
1942
- loyalty_card_number: z.string().optional(),
1943
- billing: customerSchema.shape.billing.optional()
1969
+ loyalty_card_number: z.string().optional()
1944
1970
  });
1945
1971
  var updateCustomerSchema = createCustomerSchema.merge(
1946
1972
  customerSchema.pick({
@@ -2134,6 +2160,6 @@ var schemas = {
2134
2160
  }
2135
2161
  };
2136
2162
 
2137
- export { WooCommerceApiError, WooCommerceDataValidationError, addToCartInputSchema, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema2 as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema2 as adminProductSchema, billingAddressSchemaMandatory as billingAddressSchema, cartItemImageSchema, cartSchema, checkoutInputSchema, checkoutSchema, couponInputSchema, createCategorySchema, createClient, createCouponSchema, createCustomerSchema, createPaginatedSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, paginationMetaSchema, paginationParamsSchema, paymentMethodFilterSchema, paymentMethodSchema, productCategorySchema, productImageSchema, productSchema, removeCartItemInputSchema, schemas, storeProductsSearchParamsSchema as searchParamsSchema, selectShippingRateInputSchema, storeApiOrderSchema, updateCartItemInputSchema, updateCustomerInputSchema, updateCustomerSchema, wcBaseParamsSchema, wcErrorResponseSchema, wcPaginationMetaSchema };
2163
+ export { WooCommerceApiError, WooCommerceDataValidationError, addToCartInputSchema, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema2 as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema2 as adminProductSchema, billingAddressSchemaMandatory as billingAddressSchema, cartItemImageSchema, cartSchema, checkoutInputSchema, checkoutSchema, couponInputSchema, createCategorySchema, createClient, createCouponSchema, createCustomerSchema, createPaginatedSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, makeAddressFormSchema, makeBillingAddressFormSchema, paginationMetaSchema, paginationParamsSchema, paymentMethodFilterSchema, paymentMethodSchema, productCategorySchema, productImageSchema, productSchema, removeCartItemInputSchema, schemas, storeProductsSearchParamsSchema as searchParamsSchema, selectShippingRateInputSchema, storeApiOrderSchema, updateCartItemInputSchema, updateCustomerInputSchema, updateCustomerSchema, wcBaseParamsSchema, wcErrorResponseSchema, wcPaginationMetaSchema };
2138
2164
  //# sourceMappingURL=index.mjs.map
2139
2165
  //# sourceMappingURL=index.mjs.map