@atomic-solutions/woocommerce-api-client 0.2.0 → 0.3.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.
@@ -1,5 +1,5 @@
1
- import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-CgTmmyIP.mjs';
2
- export { P as PaginatedResponse, R as ResponseOptions, V as ValidationMode, h as handleApiResponse, b as handlePaginatedApiResponse, i as isZodError, s as setupErrorInterceptor } from '../types-CgTmmyIP.mjs';
1
+ import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-BF4_UUqp.mjs';
2
+ export { P as PaginatedResponse, R as ResponseOptions, V as ValidationMode, h as handleApiResponse, b as handlePaginatedApiResponse, i as isZodError, s as setupErrorInterceptor } from '../types-BF4_UUqp.mjs';
3
3
  import { AxiosInstance } from 'axios';
4
4
  import 'zod';
5
5
 
@@ -1,5 +1,5 @@
1
- import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-CgTmmyIP.js';
2
- export { P as PaginatedResponse, R as ResponseOptions, V as ValidationMode, h as handleApiResponse, b as handlePaginatedApiResponse, i as isZodError, s as setupErrorInterceptor } from '../types-CgTmmyIP.js';
1
+ import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-BF4_UUqp.js';
2
+ export { P as PaginatedResponse, R as ResponseOptions, V as ValidationMode, h as handleApiResponse, b as handlePaginatedApiResponse, i as isZodError, s as setupErrorInterceptor } from '../types-BF4_UUqp.js';
3
3
  import { AxiosInstance } from 'axios';
4
4
  import 'zod';
5
5
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createClient } from './client/index.mjs';
2
- import { B as BaseError, e as BaseErrorOptions, f as ValidationReportableData, g as WooCommerceDataValidationErrorOptions } from './types-CgTmmyIP.mjs';
3
- export { A as AddToCartInput, j as Cart, k as CartAPI, C as CartHeadersAdapter, l as CartItem, m as CartItemImage, n as Checkout, o as CheckoutAPI, p as CheckoutInput, q as CouponInput, G as GetOrderInput, J as JwtTokenAdapter, O as OrderStatus, r as OrdersAPI, P as PaginatedResponse, t as Product, u as ProductCategory, v as ProductImage, w as ProductParams, x as ProductsAPI, y as RemoveCartItemInput, S as SelectShippingRateInput, z as StoreApiOrder, U as UpdateCartItemInput, D as UpdateCustomerInput, E as WooCommerceApiError, F as WooCommerceApiErrorOptions, a as WooCommerceClient, W as WooCommerceConfig, H as addToCartInputSchema, I as cartItemImageSchema, K as cartSchema, L as checkoutInputSchema, M as checkoutSchema, N as couponInputSchema, Q as productCategorySchema, T as productImageSchema, X as productSchema, Y as removeCartItemInputSchema, Z as searchParamsSchema, _ as selectShippingRateInputSchema, $ as storeApiOrderSchema, a0 as updateCartItemInputSchema, a1 as updateCustomerInputSchema } from './types-CgTmmyIP.mjs';
2
+ import { B as BaseError, e as BaseErrorOptions, f as ValidationReportableData, g as WooCommerceDataValidationErrorOptions } from './types-BF4_UUqp.mjs';
3
+ export { A as AddToCartInput, j as Cart, k as CartAPI, C as CartHeadersAdapter, l as CartItem, m as CartItemImage, n as Checkout, o as CheckoutAPI, p as CheckoutInput, q as CouponInput, G as GetOrderInput, J as JwtTokenAdapter, O as OrderStatus, r as OrdersAPI, P as PaginatedResponse, t as Product, u as ProductCategory, v as ProductImage, w as ProductParams, x as ProductsAPI, y as RemoveCartItemInput, z as SelectShippingRateInput, D as StoreApiOrder, U as UpdateCartItemInput, E as UpdateCustomerInput, F as WooCommerceApiError, H as WooCommerceApiErrorOptions, a as WooCommerceClient, W as WooCommerceConfig, I as addToCartInputSchema, K as cartItemImageSchema, L as cartSchema, M as checkoutInputSchema, N as checkoutSchema, Q as couponInputSchema, T as productCategorySchema, X as productImageSchema, Y as productSchema, Z as removeCartItemInputSchema, _ as searchParamsSchema, $ as selectShippingRateInputSchema, a0 as storeApiOrderSchema, a1 as updateCartItemInputSchema, a2 as updateCustomerInputSchema } from './types-BF4_UUqp.mjs';
4
4
  import * as zod from 'zod';
5
5
  import { ZodError, z } from 'zod';
6
6
  import 'axios';
@@ -96,8 +96,75 @@ declare const billingAddressSchemaMandatory: z.ZodObject<{
96
96
  phone: string;
97
97
  email: string;
98
98
  }>;
99
+ interface AddressFormMessages {
100
+ required?: string;
101
+ email?: string;
102
+ postcode?: string;
103
+ phone?: string;
104
+ }
105
+ declare const makeAddressFormSchema: (messages?: AddressFormMessages, postcodePattern?: RegExp) => z.ZodObject<{
106
+ first_name: z.ZodString;
107
+ last_name: z.ZodString;
108
+ company: z.ZodString;
109
+ address_1: z.ZodString;
110
+ address_2: z.ZodString;
111
+ city: z.ZodString;
112
+ postcode: z.ZodString;
113
+ phone: z.ZodString;
114
+ }, "strip", z.ZodTypeAny, {
115
+ first_name: string;
116
+ last_name: string;
117
+ company: string;
118
+ address_1: string;
119
+ address_2: string;
120
+ city: string;
121
+ postcode: string;
122
+ phone: string;
123
+ }, {
124
+ first_name: string;
125
+ last_name: string;
126
+ company: string;
127
+ address_1: string;
128
+ address_2: string;
129
+ city: string;
130
+ postcode: string;
131
+ phone: string;
132
+ }>;
133
+ declare const makeBillingAddressFormSchema: (messages?: AddressFormMessages, postcodePattern?: RegExp) => z.ZodObject<{
134
+ email: z.ZodString;
135
+ first_name: z.ZodString;
136
+ last_name: z.ZodString;
137
+ company: z.ZodString;
138
+ address_1: z.ZodString;
139
+ address_2: z.ZodString;
140
+ city: z.ZodString;
141
+ postcode: z.ZodString;
142
+ phone: z.ZodString;
143
+ }, "strip", z.ZodTypeAny, {
144
+ first_name: string;
145
+ last_name: string;
146
+ company: string;
147
+ address_1: string;
148
+ address_2: string;
149
+ city: string;
150
+ postcode: string;
151
+ phone: string;
152
+ email: string;
153
+ }, {
154
+ first_name: string;
155
+ last_name: string;
156
+ company: string;
157
+ address_1: string;
158
+ address_2: string;
159
+ city: string;
160
+ postcode: string;
161
+ phone: string;
162
+ email: string;
163
+ }>;
99
164
  type Address = z.infer<typeof addressSchema>;
100
165
  type BillingAddress = z.infer<typeof billingAddressSchemaMandatory>;
166
+ type AddressFormValues = z.infer<ReturnType<typeof makeAddressFormSchema>>;
167
+ type BillingAddressFormValues = z.infer<ReturnType<typeof makeBillingAddressFormSchema>>;
101
168
 
102
169
  declare const paginationParamsSchema: z.ZodObject<{
103
170
  page: z.ZodOptional<z.ZodNumber>;
@@ -5040,4 +5107,4 @@ declare const schemas: {
5040
5107
  };
5041
5108
  };
5042
5109
 
5043
- export { type Address, type CategoryFilterParams as AdminCategoryFilterParams, type Product as AdminProduct, type ProductCategory as AdminProductCategory, type ProductFilterParams as AdminProductFilterParams, type BillingAddress, type Coupon, type CouponFilterParams, type Customer, type CustomerFilterParams, type Order, type OrderFilterParams, type PaginationMeta, type PaginationParams, type PaymentMethod, type PaymentMethodFilterParams, type TAppEnumsKeys, type WCBaseParams, type WCErrorResponse, type WCPaginationMeta, WooCommerceDataValidationError, WooCommerceDataValidationErrorOptions, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema as adminProductSchema, billingAddressSchemaMandatory as billingAddressSchema, createCategorySchema, createCouponSchema, createCustomerSchema, createPaginatedSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, paginationMetaSchema, paginationParamsSchema, paymentMethodFilterSchema, paymentMethodSchema, schemas, updateCustomerSchema, wcBaseParamsSchema, wcErrorResponseSchema, wcPaginationMetaSchema };
5110
+ export { type Address, type AddressFormMessages, type AddressFormValues, type CategoryFilterParams as AdminCategoryFilterParams, type Product as AdminProduct, type ProductCategory as AdminProductCategory, type ProductFilterParams as AdminProductFilterParams, type BillingAddress, type BillingAddressFormValues, type Coupon, type CouponFilterParams, type Customer, type CustomerFilterParams, type Order, type OrderFilterParams, type PaginationMeta, type PaginationParams, type PaymentMethod, type PaymentMethodFilterParams, type TAppEnumsKeys, type WCBaseParams, type WCErrorResponse, type WCPaginationMeta, WooCommerceDataValidationError, WooCommerceDataValidationErrorOptions, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema as adminProductSchema, billingAddressSchemaMandatory as billingAddressSchema, createCategorySchema, createCouponSchema, createCustomerSchema, createPaginatedSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, makeAddressFormSchema, makeBillingAddressFormSchema, paginationMetaSchema, paginationParamsSchema, paymentMethodFilterSchema, paymentMethodSchema, schemas, updateCustomerSchema, wcBaseParamsSchema, wcErrorResponseSchema, wcPaginationMetaSchema };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createClient } from './client/index.js';
2
- import { B as BaseError, e as BaseErrorOptions, f as ValidationReportableData, g as WooCommerceDataValidationErrorOptions } from './types-CgTmmyIP.js';
3
- export { A as AddToCartInput, j as Cart, k as CartAPI, C as CartHeadersAdapter, l as CartItem, m as CartItemImage, n as Checkout, o as CheckoutAPI, p as CheckoutInput, q as CouponInput, G as GetOrderInput, J as JwtTokenAdapter, O as OrderStatus, r as OrdersAPI, P as PaginatedResponse, t as Product, u as ProductCategory, v as ProductImage, w as ProductParams, x as ProductsAPI, y as RemoveCartItemInput, S as SelectShippingRateInput, z as StoreApiOrder, U as UpdateCartItemInput, D as UpdateCustomerInput, E as WooCommerceApiError, F as WooCommerceApiErrorOptions, a as WooCommerceClient, W as WooCommerceConfig, H as addToCartInputSchema, I as cartItemImageSchema, K as cartSchema, L as checkoutInputSchema, M as checkoutSchema, N as couponInputSchema, Q as productCategorySchema, T as productImageSchema, X as productSchema, Y as removeCartItemInputSchema, Z as searchParamsSchema, _ as selectShippingRateInputSchema, $ as storeApiOrderSchema, a0 as updateCartItemInputSchema, a1 as updateCustomerInputSchema } from './types-CgTmmyIP.js';
2
+ import { B as BaseError, e as BaseErrorOptions, f as ValidationReportableData, g as WooCommerceDataValidationErrorOptions } from './types-BF4_UUqp.js';
3
+ export { A as AddToCartInput, j as Cart, k as CartAPI, C as CartHeadersAdapter, l as CartItem, m as CartItemImage, n as Checkout, o as CheckoutAPI, p as CheckoutInput, q as CouponInput, G as GetOrderInput, J as JwtTokenAdapter, O as OrderStatus, r as OrdersAPI, P as PaginatedResponse, t as Product, u as ProductCategory, v as ProductImage, w as ProductParams, x as ProductsAPI, y as RemoveCartItemInput, z as SelectShippingRateInput, D as StoreApiOrder, U as UpdateCartItemInput, E as UpdateCustomerInput, F as WooCommerceApiError, H as WooCommerceApiErrorOptions, a as WooCommerceClient, W as WooCommerceConfig, I as addToCartInputSchema, K as cartItemImageSchema, L as cartSchema, M as checkoutInputSchema, N as checkoutSchema, Q as couponInputSchema, T as productCategorySchema, X as productImageSchema, Y as productSchema, Z as removeCartItemInputSchema, _ as searchParamsSchema, $ as selectShippingRateInputSchema, a0 as storeApiOrderSchema, a1 as updateCartItemInputSchema, a2 as updateCustomerInputSchema } from './types-BF4_UUqp.js';
4
4
  import * as zod from 'zod';
5
5
  import { ZodError, z } from 'zod';
6
6
  import 'axios';
@@ -96,8 +96,75 @@ declare const billingAddressSchemaMandatory: z.ZodObject<{
96
96
  phone: string;
97
97
  email: string;
98
98
  }>;
99
+ interface AddressFormMessages {
100
+ required?: string;
101
+ email?: string;
102
+ postcode?: string;
103
+ phone?: string;
104
+ }
105
+ declare const makeAddressFormSchema: (messages?: AddressFormMessages, postcodePattern?: RegExp) => z.ZodObject<{
106
+ first_name: z.ZodString;
107
+ last_name: z.ZodString;
108
+ company: z.ZodString;
109
+ address_1: z.ZodString;
110
+ address_2: z.ZodString;
111
+ city: z.ZodString;
112
+ postcode: z.ZodString;
113
+ phone: z.ZodString;
114
+ }, "strip", z.ZodTypeAny, {
115
+ first_name: string;
116
+ last_name: string;
117
+ company: string;
118
+ address_1: string;
119
+ address_2: string;
120
+ city: string;
121
+ postcode: string;
122
+ phone: string;
123
+ }, {
124
+ first_name: string;
125
+ last_name: string;
126
+ company: string;
127
+ address_1: string;
128
+ address_2: string;
129
+ city: string;
130
+ postcode: string;
131
+ phone: string;
132
+ }>;
133
+ declare const makeBillingAddressFormSchema: (messages?: AddressFormMessages, postcodePattern?: RegExp) => z.ZodObject<{
134
+ email: z.ZodString;
135
+ first_name: z.ZodString;
136
+ last_name: z.ZodString;
137
+ company: z.ZodString;
138
+ address_1: z.ZodString;
139
+ address_2: z.ZodString;
140
+ city: z.ZodString;
141
+ postcode: z.ZodString;
142
+ phone: z.ZodString;
143
+ }, "strip", z.ZodTypeAny, {
144
+ first_name: string;
145
+ last_name: string;
146
+ company: string;
147
+ address_1: string;
148
+ address_2: string;
149
+ city: string;
150
+ postcode: string;
151
+ phone: string;
152
+ email: string;
153
+ }, {
154
+ first_name: string;
155
+ last_name: string;
156
+ company: string;
157
+ address_1: string;
158
+ address_2: string;
159
+ city: string;
160
+ postcode: string;
161
+ phone: string;
162
+ email: string;
163
+ }>;
99
164
  type Address = z.infer<typeof addressSchema>;
100
165
  type BillingAddress = z.infer<typeof billingAddressSchemaMandatory>;
166
+ type AddressFormValues = z.infer<ReturnType<typeof makeAddressFormSchema>>;
167
+ type BillingAddressFormValues = z.infer<ReturnType<typeof makeBillingAddressFormSchema>>;
101
168
 
102
169
  declare const paginationParamsSchema: z.ZodObject<{
103
170
  page: z.ZodOptional<z.ZodNumber>;
@@ -5040,4 +5107,4 @@ declare const schemas: {
5040
5107
  };
5041
5108
  };
5042
5109
 
5043
- export { type Address, type CategoryFilterParams as AdminCategoryFilterParams, type Product as AdminProduct, type ProductCategory as AdminProductCategory, type ProductFilterParams as AdminProductFilterParams, type BillingAddress, type Coupon, type CouponFilterParams, type Customer, type CustomerFilterParams, type Order, type OrderFilterParams, type PaginationMeta, type PaginationParams, type PaymentMethod, type PaymentMethodFilterParams, type TAppEnumsKeys, type WCBaseParams, type WCErrorResponse, type WCPaginationMeta, WooCommerceDataValidationError, WooCommerceDataValidationErrorOptions, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema as adminProductSchema, billingAddressSchemaMandatory as billingAddressSchema, createCategorySchema, createCouponSchema, createCustomerSchema, createPaginatedSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, paginationMetaSchema, paginationParamsSchema, paymentMethodFilterSchema, paymentMethodSchema, schemas, updateCustomerSchema, wcBaseParamsSchema, wcErrorResponseSchema, wcPaginationMetaSchema };
5110
+ export { type Address, type AddressFormMessages, type AddressFormValues, type CategoryFilterParams as AdminCategoryFilterParams, type Product as AdminProduct, type ProductCategory as AdminProductCategory, type ProductFilterParams as AdminProductFilterParams, type BillingAddress, type BillingAddressFormValues, type Coupon, type CouponFilterParams, type Customer, type CustomerFilterParams, type Order, type OrderFilterParams, type PaginationMeta, type PaginationParams, type PaymentMethod, type PaymentMethodFilterParams, type TAppEnumsKeys, type WCBaseParams, type WCErrorResponse, type WCPaginationMeta, WooCommerceDataValidationError, WooCommerceDataValidationErrorOptions, addressSchema, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema as adminProductSchema, billingAddressSchemaMandatory as billingAddressSchema, createCategorySchema, createCouponSchema, createCustomerSchema, createPaginatedSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, makeAddressFormSchema, makeBillingAddressFormSchema, paginationMetaSchema, paginationParamsSchema, paymentMethodFilterSchema, paymentMethodSchema, schemas, updateCustomerSchema, wcBaseParamsSchema, wcErrorResponseSchema, wcPaginationMetaSchema };
package/dist/index.js CHANGED
@@ -691,6 +691,33 @@ var billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({
691
691
  /** Email address (can be null for guest carts) */
692
692
  email: zod.z.string().nullable()
693
693
  });
694
+ var phoneFormatRegex = /^[+\d][\d\s\-/()]{5,}$/;
695
+ var defaultAddressFormMessages = {
696
+ required: "This field is required",
697
+ email: "Valid email is required",
698
+ postcode: "Postal code is not valid",
699
+ phone: "Invalid phone number"
700
+ };
701
+ var defaultPostcodePattern = /^\d+$/;
702
+ var resolveAddressFormMessages = (messages) => ({ ...defaultAddressFormMessages, ...messages });
703
+ var buildAddressFormShape = (m, postcodePattern) => ({
704
+ first_name: zod.z.string().trim().min(1, m.required),
705
+ last_name: zod.z.string().trim().min(1, m.required),
706
+ company: zod.z.string().trim(),
707
+ address_1: zod.z.string().trim().min(1, m.required),
708
+ address_2: zod.z.string().trim(),
709
+ city: zod.z.string().trim().min(1, m.required),
710
+ postcode: zod.z.string().trim().min(1, m.required).regex(postcodePattern, m.postcode),
711
+ phone: zod.z.string().trim().min(1, m.required).regex(phoneFormatRegex, m.phone)
712
+ });
713
+ var makeAddressFormSchema = (messages = {}, postcodePattern = defaultPostcodePattern) => zod.z.object(buildAddressFormShape(resolveAddressFormMessages(messages), postcodePattern));
714
+ var makeBillingAddressFormSchema = (messages = {}, postcodePattern = defaultPostcodePattern) => {
715
+ const m = resolveAddressFormMessages(messages);
716
+ return zod.z.object({
717
+ ...buildAddressFormShape(m, postcodePattern),
718
+ email: zod.z.string().trim().min(1, m.required).email(m.email)
719
+ });
720
+ };
694
721
  var moneySchema = zod.z.object({
695
722
  /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
696
723
  currency_code: zod.z.string(),
@@ -2166,6 +2193,8 @@ exports.customerFilterSchema = customerFilterSchema;
2166
2193
  exports.customerSchema = customerSchema;
2167
2194
  exports.getAppEnumRaw = getAppEnumRaw;
2168
2195
  exports.getAppEnumZod = getAppEnumZod;
2196
+ exports.makeAddressFormSchema = makeAddressFormSchema;
2197
+ exports.makeBillingAddressFormSchema = makeBillingAddressFormSchema;
2169
2198
  exports.paginationMetaSchema = paginationMetaSchema;
2170
2199
  exports.paginationParamsSchema = paginationParamsSchema;
2171
2200
  exports.paymentMethodFilterSchema = paymentMethodFilterSchema;