@atomic-solutions/woocommerce-api-client 0.5.0 → 0.6.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.
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse, AxiosInstance, InternalAxiosRequestConfig } from 'axios';
2
+ import { BaseError } from '@atomic-solutions/errors';
2
3
  import { ZodError, ZodSchema, z } from 'zod';
3
4
 
4
5
  type WooCommerceApiErrorCode = 'cart_empty' | 'invalid_coupon' | 'missing_nonce' | 'invalid_nonce' | 'invalid_params' | 'product_not_found' | 'out_of_stock' | 'insufficient_stock' | 'invalid_payment_method' | 'checkout_error' | 'network_error' | 'unknown_error';
@@ -18,7 +19,7 @@ interface BaseReportableData {
18
19
  retryable?: boolean;
19
20
  }
20
21
  interface HttpErrorFields {
21
- statusCode: number;
22
+ statusCode?: number;
22
23
  url: string;
23
24
  method: string;
24
25
  requestBody?: unknown;
@@ -29,13 +30,6 @@ interface WooCommerceApiErrorOptions extends BaseErrorOptions, HttpErrorFields {
29
30
  originalCode: string;
30
31
  data?: Record<string, unknown>;
31
32
  }
32
- interface ApiReportableData extends BaseReportableData {
33
- statusCode: number;
34
- url: string;
35
- method: string;
36
- wooCode: WooCommerceApiErrorCode;
37
- originalCode: string;
38
- }
39
33
  interface WooCommerceDataValidationErrorOptions extends Omit<BaseErrorOptions, 'code' | 'retryable'> {
40
34
  url?: string;
41
35
  zodError?: ZodError;
@@ -46,24 +40,18 @@ interface ValidationReportableData extends BaseReportableData {
46
40
  url?: string;
47
41
  }
48
42
 
49
- declare class BaseError<TOptions extends BaseErrorOptions = BaseErrorOptions, TReportable extends BaseReportableData = BaseReportableData> extends Error {
50
- readonly options: TOptions;
51
- constructor(options: TOptions);
52
- getReportableData(): TReportable;
53
- toJSON(): Record<string, unknown>;
54
- }
55
-
56
- declare class WooCommerceApiError extends BaseError<WooCommerceApiErrorOptions, ApiReportableData> {
43
+ declare class WooCommerceApiError extends BaseError {
44
+ #private;
57
45
  constructor(options: WooCommerceApiErrorOptions);
46
+ get options(): WooCommerceApiErrorOptions;
58
47
  get wooCode(): WooCommerceApiErrorCode;
59
48
  get originalCode(): string;
60
- get statusCode(): number;
49
+ get statusCode(): number | undefined;
61
50
  get url(): string;
62
51
  get method(): string;
63
52
  get requestBody(): unknown | undefined;
64
53
  get responseBody(): unknown | undefined;
65
54
  get data(): Record<string, unknown> | undefined;
66
- getReportableData(): ApiReportableData;
67
55
  }
68
56
 
69
57
  type ValidationMode = 'strict' | 'warn';
@@ -2648,7 +2636,7 @@ declare const checkoutSchema: z.ZodObject<{
2648
2636
  phone: string;
2649
2637
  }>;
2650
2638
  payment_method: z.ZodString;
2651
- payment_result: z.ZodObject<{
2639
+ payment_result: z.ZodNullable<z.ZodObject<{
2652
2640
  payment_status: z.ZodString;
2653
2641
  payment_details: z.ZodArray<z.ZodUnknown, "many">;
2654
2642
  redirect_url: z.ZodString;
@@ -2660,7 +2648,7 @@ declare const checkoutSchema: z.ZodObject<{
2660
2648
  payment_status: string;
2661
2649
  payment_details: unknown[];
2662
2650
  redirect_url: string;
2663
- }>;
2651
+ }>>;
2664
2652
  }, "strip", z.ZodTypeAny, {
2665
2653
  status: string;
2666
2654
  shipping_address: {
@@ -2697,7 +2685,7 @@ declare const checkoutSchema: z.ZodObject<{
2697
2685
  payment_status: string;
2698
2686
  payment_details: unknown[];
2699
2687
  redirect_url: string;
2700
- };
2688
+ } | null;
2701
2689
  }, {
2702
2690
  status: string;
2703
2691
  shipping_address: {
@@ -2734,7 +2722,7 @@ declare const checkoutSchema: z.ZodObject<{
2734
2722
  payment_status: string;
2735
2723
  payment_details: unknown[];
2736
2724
  redirect_url: string;
2737
- };
2725
+ } | null;
2738
2726
  }>;
2739
2727
  declare const checkoutInputSchema: z.ZodObject<{
2740
2728
  payment_method: z.ZodString;
@@ -3488,6 +3476,24 @@ type ProductCategory = z.infer<typeof productCategorySchema>;
3488
3476
  type ProductImage = z.infer<typeof productImageSchema>;
3489
3477
  type ProductParams = z.infer<typeof storeProductsSearchParamsSchema>;
3490
3478
 
3479
+ declare const productTagSchema: z.ZodObject<{
3480
+ id: z.ZodNumber;
3481
+ name: z.ZodString;
3482
+ slug: z.ZodString;
3483
+ }, "strip", z.ZodTypeAny, {
3484
+ id: number;
3485
+ name: string;
3486
+ slug: string;
3487
+ }, {
3488
+ id: number;
3489
+ name: string;
3490
+ slug: string;
3491
+ }>;
3492
+ type ProductTag = z.infer<typeof productTagSchema>;
3493
+ type ProductTagsParams = {
3494
+ include?: number[];
3495
+ };
3496
+
3491
3497
  declare const orderAttributionSchema: z.ZodObject<{
3492
3498
  source_type: z.ZodString;
3493
3499
  utm_source: z.ZodString;
@@ -3542,6 +3548,7 @@ interface ProductsAPI {
3542
3548
  list: (params?: ProductParams) => Promise<PaginatedResponse<Product>>;
3543
3549
  get: (id: number) => Promise<Product>;
3544
3550
  categories: () => Promise<ProductCategory[]>;
3551
+ tags: (params?: ProductTagsParams) => Promise<ProductTag[]>;
3545
3552
  }
3546
3553
  interface AddItemsResult {
3547
3554
  cart: Cart;
@@ -3584,4 +3591,4 @@ interface WooCommerceClient {
3584
3591
  orders: OrdersAPI;
3585
3592
  }
3586
3593
 
3587
- export { checkoutSchema as $, type AddItemsInput as A, BaseError as B, type CartHeadersAdapter as C, type ProductImage as D, type ProductParams as E, type ProductsAPI as F, type GetOrderInput as G, type RemoveCartItemInput as H, type SelectShippingRateInput as I, type JwtTokenAdapter as J, type StoreApiOrder as K, type UpdateCustomerInput as L, WooCommerceApiError as M, type WooCommerceApiErrorOptions as N, type OrderStatus as O, type PaginatedResponse as P, addItemsInputSchema as Q, type ResponseOptions as R, type StoreApiVersion as S, addToCartInputSchema as T, type UpdateCartItemInput as U, type ValidationMode as V, type WooCommerceConfig as W, batchResponseSchema as X, cartItemImageSchema as Y, cartSchema as Z, checkoutInputSchema as _, type WooCommerceClient as a, couponInputSchema as a0, productCategorySchema as a1, productImageSchema as a2, productSchema as a3, removeCartItemInputSchema as a4, storeProductsSearchParamsSchema as a5, selectShippingRateInputSchema as a6, storeApiOrderSchema as a7, updateCartItemInputSchema as a8, updateCustomerInputSchema as a9, handleApiResponse as b, handlePaginatedApiResponse as c, type Pagination as d, calculatePagination as e, type WooCommerceApiErrorCode as f, type BaseErrorOptions as g, handleApiData as h, isZodError as i, type ValidationReportableData as j, type WooCommerceDataValidationErrorOptions as k, type AddItemsResult as l, type AddToCartInput as m, type BatchResponse as n, type Cart as o, type CartAPI as p, type CartItem as q, type CartItemImage as r, setupErrorInterceptor as s, type Checkout as t, type CheckoutAPI as u, type CheckoutInput as v, type CouponInput as w, type OrdersAPI as x, type Product as y, type ProductCategory as z };
3594
+ export { cartSchema as $, type AddItemsInput as A, type BaseErrorOptions as B, type CartHeadersAdapter as C, type ProductImage as D, type ProductParams as E, type ProductTag as F, type GetOrderInput as G, type ProductTagsParams as H, type ProductsAPI as I, type JwtTokenAdapter as J, type RemoveCartItemInput as K, type SelectShippingRateInput as L, type StoreApiOrder as M, type UpdateCustomerInput as N, type OrderStatus as O, type PaginatedResponse as P, WooCommerceApiError as Q, type ResponseOptions as R, type StoreApiVersion as S, type WooCommerceApiErrorOptions as T, type UpdateCartItemInput as U, type ValidationMode as V, type WooCommerceConfig as W, addItemsInputSchema as X, addToCartInputSchema as Y, batchResponseSchema as Z, cartItemImageSchema as _, type WooCommerceClient as a, checkoutInputSchema as a0, checkoutSchema as a1, couponInputSchema as a2, productCategorySchema as a3, productImageSchema as a4, productSchema as a5, removeCartItemInputSchema as a6, storeProductsSearchParamsSchema as a7, selectShippingRateInputSchema as a8, storeApiOrderSchema as a9, updateCartItemInputSchema as aa, updateCustomerInputSchema as ab, handleApiResponse as b, handlePaginatedApiResponse as c, type Pagination as d, calculatePagination as e, type WooCommerceApiErrorCode as f, type BaseReportableData as g, handleApiData as h, isZodError as i, type ValidationReportableData as j, type WooCommerceDataValidationErrorOptions as k, type AddItemsResult as l, type AddToCartInput as m, type BatchResponse as n, type Cart as o, type CartAPI as p, type CartItem as q, type CartItemImage as r, setupErrorInterceptor as s, type Checkout as t, type CheckoutAPI as u, type CheckoutInput as v, type CouponInput as w, type OrdersAPI as x, type Product as y, type ProductCategory as z };
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse, AxiosInstance, InternalAxiosRequestConfig } from 'axios';
2
+ import { BaseError } from '@atomic-solutions/errors';
2
3
  import { ZodError, ZodSchema, z } from 'zod';
3
4
 
4
5
  type WooCommerceApiErrorCode = 'cart_empty' | 'invalid_coupon' | 'missing_nonce' | 'invalid_nonce' | 'invalid_params' | 'product_not_found' | 'out_of_stock' | 'insufficient_stock' | 'invalid_payment_method' | 'checkout_error' | 'network_error' | 'unknown_error';
@@ -18,7 +19,7 @@ interface BaseReportableData {
18
19
  retryable?: boolean;
19
20
  }
20
21
  interface HttpErrorFields {
21
- statusCode: number;
22
+ statusCode?: number;
22
23
  url: string;
23
24
  method: string;
24
25
  requestBody?: unknown;
@@ -29,13 +30,6 @@ interface WooCommerceApiErrorOptions extends BaseErrorOptions, HttpErrorFields {
29
30
  originalCode: string;
30
31
  data?: Record<string, unknown>;
31
32
  }
32
- interface ApiReportableData extends BaseReportableData {
33
- statusCode: number;
34
- url: string;
35
- method: string;
36
- wooCode: WooCommerceApiErrorCode;
37
- originalCode: string;
38
- }
39
33
  interface WooCommerceDataValidationErrorOptions extends Omit<BaseErrorOptions, 'code' | 'retryable'> {
40
34
  url?: string;
41
35
  zodError?: ZodError;
@@ -46,24 +40,18 @@ interface ValidationReportableData extends BaseReportableData {
46
40
  url?: string;
47
41
  }
48
42
 
49
- declare class BaseError<TOptions extends BaseErrorOptions = BaseErrorOptions, TReportable extends BaseReportableData = BaseReportableData> extends Error {
50
- readonly options: TOptions;
51
- constructor(options: TOptions);
52
- getReportableData(): TReportable;
53
- toJSON(): Record<string, unknown>;
54
- }
55
-
56
- declare class WooCommerceApiError extends BaseError<WooCommerceApiErrorOptions, ApiReportableData> {
43
+ declare class WooCommerceApiError extends BaseError {
44
+ #private;
57
45
  constructor(options: WooCommerceApiErrorOptions);
46
+ get options(): WooCommerceApiErrorOptions;
58
47
  get wooCode(): WooCommerceApiErrorCode;
59
48
  get originalCode(): string;
60
- get statusCode(): number;
49
+ get statusCode(): number | undefined;
61
50
  get url(): string;
62
51
  get method(): string;
63
52
  get requestBody(): unknown | undefined;
64
53
  get responseBody(): unknown | undefined;
65
54
  get data(): Record<string, unknown> | undefined;
66
- getReportableData(): ApiReportableData;
67
55
  }
68
56
 
69
57
  type ValidationMode = 'strict' | 'warn';
@@ -2648,7 +2636,7 @@ declare const checkoutSchema: z.ZodObject<{
2648
2636
  phone: string;
2649
2637
  }>;
2650
2638
  payment_method: z.ZodString;
2651
- payment_result: z.ZodObject<{
2639
+ payment_result: z.ZodNullable<z.ZodObject<{
2652
2640
  payment_status: z.ZodString;
2653
2641
  payment_details: z.ZodArray<z.ZodUnknown, "many">;
2654
2642
  redirect_url: z.ZodString;
@@ -2660,7 +2648,7 @@ declare const checkoutSchema: z.ZodObject<{
2660
2648
  payment_status: string;
2661
2649
  payment_details: unknown[];
2662
2650
  redirect_url: string;
2663
- }>;
2651
+ }>>;
2664
2652
  }, "strip", z.ZodTypeAny, {
2665
2653
  status: string;
2666
2654
  shipping_address: {
@@ -2697,7 +2685,7 @@ declare const checkoutSchema: z.ZodObject<{
2697
2685
  payment_status: string;
2698
2686
  payment_details: unknown[];
2699
2687
  redirect_url: string;
2700
- };
2688
+ } | null;
2701
2689
  }, {
2702
2690
  status: string;
2703
2691
  shipping_address: {
@@ -2734,7 +2722,7 @@ declare const checkoutSchema: z.ZodObject<{
2734
2722
  payment_status: string;
2735
2723
  payment_details: unknown[];
2736
2724
  redirect_url: string;
2737
- };
2725
+ } | null;
2738
2726
  }>;
2739
2727
  declare const checkoutInputSchema: z.ZodObject<{
2740
2728
  payment_method: z.ZodString;
@@ -3488,6 +3476,24 @@ type ProductCategory = z.infer<typeof productCategorySchema>;
3488
3476
  type ProductImage = z.infer<typeof productImageSchema>;
3489
3477
  type ProductParams = z.infer<typeof storeProductsSearchParamsSchema>;
3490
3478
 
3479
+ declare const productTagSchema: z.ZodObject<{
3480
+ id: z.ZodNumber;
3481
+ name: z.ZodString;
3482
+ slug: z.ZodString;
3483
+ }, "strip", z.ZodTypeAny, {
3484
+ id: number;
3485
+ name: string;
3486
+ slug: string;
3487
+ }, {
3488
+ id: number;
3489
+ name: string;
3490
+ slug: string;
3491
+ }>;
3492
+ type ProductTag = z.infer<typeof productTagSchema>;
3493
+ type ProductTagsParams = {
3494
+ include?: number[];
3495
+ };
3496
+
3491
3497
  declare const orderAttributionSchema: z.ZodObject<{
3492
3498
  source_type: z.ZodString;
3493
3499
  utm_source: z.ZodString;
@@ -3542,6 +3548,7 @@ interface ProductsAPI {
3542
3548
  list: (params?: ProductParams) => Promise<PaginatedResponse<Product>>;
3543
3549
  get: (id: number) => Promise<Product>;
3544
3550
  categories: () => Promise<ProductCategory[]>;
3551
+ tags: (params?: ProductTagsParams) => Promise<ProductTag[]>;
3545
3552
  }
3546
3553
  interface AddItemsResult {
3547
3554
  cart: Cart;
@@ -3584,4 +3591,4 @@ interface WooCommerceClient {
3584
3591
  orders: OrdersAPI;
3585
3592
  }
3586
3593
 
3587
- export { checkoutSchema as $, type AddItemsInput as A, BaseError as B, type CartHeadersAdapter as C, type ProductImage as D, type ProductParams as E, type ProductsAPI as F, type GetOrderInput as G, type RemoveCartItemInput as H, type SelectShippingRateInput as I, type JwtTokenAdapter as J, type StoreApiOrder as K, type UpdateCustomerInput as L, WooCommerceApiError as M, type WooCommerceApiErrorOptions as N, type OrderStatus as O, type PaginatedResponse as P, addItemsInputSchema as Q, type ResponseOptions as R, type StoreApiVersion as S, addToCartInputSchema as T, type UpdateCartItemInput as U, type ValidationMode as V, type WooCommerceConfig as W, batchResponseSchema as X, cartItemImageSchema as Y, cartSchema as Z, checkoutInputSchema as _, type WooCommerceClient as a, couponInputSchema as a0, productCategorySchema as a1, productImageSchema as a2, productSchema as a3, removeCartItemInputSchema as a4, storeProductsSearchParamsSchema as a5, selectShippingRateInputSchema as a6, storeApiOrderSchema as a7, updateCartItemInputSchema as a8, updateCustomerInputSchema as a9, handleApiResponse as b, handlePaginatedApiResponse as c, type Pagination as d, calculatePagination as e, type WooCommerceApiErrorCode as f, type BaseErrorOptions as g, handleApiData as h, isZodError as i, type ValidationReportableData as j, type WooCommerceDataValidationErrorOptions as k, type AddItemsResult as l, type AddToCartInput as m, type BatchResponse as n, type Cart as o, type CartAPI as p, type CartItem as q, type CartItemImage as r, setupErrorInterceptor as s, type Checkout as t, type CheckoutAPI as u, type CheckoutInput as v, type CouponInput as w, type OrdersAPI as x, type Product as y, type ProductCategory as z };
3594
+ export { cartSchema as $, type AddItemsInput as A, type BaseErrorOptions as B, type CartHeadersAdapter as C, type ProductImage as D, type ProductParams as E, type ProductTag as F, type GetOrderInput as G, type ProductTagsParams as H, type ProductsAPI as I, type JwtTokenAdapter as J, type RemoveCartItemInput as K, type SelectShippingRateInput as L, type StoreApiOrder as M, type UpdateCustomerInput as N, type OrderStatus as O, type PaginatedResponse as P, WooCommerceApiError as Q, type ResponseOptions as R, type StoreApiVersion as S, type WooCommerceApiErrorOptions as T, type UpdateCartItemInput as U, type ValidationMode as V, type WooCommerceConfig as W, addItemsInputSchema as X, addToCartInputSchema as Y, batchResponseSchema as Z, cartItemImageSchema as _, type WooCommerceClient as a, checkoutInputSchema as a0, checkoutSchema as a1, couponInputSchema as a2, productCategorySchema as a3, productImageSchema as a4, productSchema as a5, removeCartItemInputSchema as a6, storeProductsSearchParamsSchema as a7, selectShippingRateInputSchema as a8, storeApiOrderSchema as a9, updateCartItemInputSchema as aa, updateCustomerInputSchema as ab, handleApiResponse as b, handlePaginatedApiResponse as c, type Pagination as d, calculatePagination as e, type WooCommerceApiErrorCode as f, type BaseReportableData as g, handleApiData as h, isZodError as i, type ValidationReportableData as j, type WooCommerceDataValidationErrorOptions as k, type AddItemsResult as l, type AddToCartInput as m, type BatchResponse as n, type Cart as o, type CartAPI as p, type CartItem as q, type CartItemImage as r, setupErrorInterceptor as s, type Checkout as t, type CheckoutAPI as u, type CheckoutInput as v, type CouponInput as w, type OrdersAPI as x, type Product as y, type ProductCategory as z };
@@ -1,6 +1,7 @@
1
- import { C as CartHeadersAdapter } from '../types-aYzN4O5x.mjs';
2
- export { P as PaginatedResponse, d as Pagination, R as ResponseOptions, V as ValidationMode, e as calculatePagination, b as handleApiResponse, c as handlePaginatedApiResponse, i as isZodError } from '../types-aYzN4O5x.mjs';
1
+ import { C as CartHeadersAdapter } from '../types-Cbf1-EhK.mjs';
2
+ export { P as PaginatedResponse, d as Pagination, R as ResponseOptions, V as ValidationMode, e as calculatePagination, b as handleApiResponse, c as handlePaginatedApiResponse, i as isZodError } from '../types-Cbf1-EhK.mjs';
3
3
  import { AxiosResponse, AxiosInstance } from 'axios';
4
+ import '@atomic-solutions/errors';
4
5
  import 'zod';
5
6
 
6
7
  interface PaginationMeta {
@@ -1,6 +1,7 @@
1
- import { C as CartHeadersAdapter } from '../types-aYzN4O5x.js';
2
- export { P as PaginatedResponse, d as Pagination, R as ResponseOptions, V as ValidationMode, e as calculatePagination, b as handleApiResponse, c as handlePaginatedApiResponse, i as isZodError } from '../types-aYzN4O5x.js';
1
+ import { C as CartHeadersAdapter } from '../types-Cbf1-EhK.js';
2
+ export { P as PaginatedResponse, d as Pagination, R as ResponseOptions, V as ValidationMode, e as calculatePagination, b as handleApiResponse, c as handlePaginatedApiResponse, i as isZodError } from '../types-Cbf1-EhK.js';
3
3
  import { AxiosResponse, AxiosInstance } from 'axios';
4
+ import '@atomic-solutions/errors';
4
5
  import 'zod';
5
6
 
6
7
  interface PaginationMeta {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomic-solutions/woocommerce-api-client",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Type-safe WooCommerce API client (framework-agnostic)",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",
@@ -64,10 +64,12 @@
64
64
  "access": "public"
65
65
  },
66
66
  "peerDependencies": {
67
+ "@atomic-solutions/errors": ">=1.5.1",
67
68
  "axios": ">=1.18.0",
68
69
  "zod": ">=3.0.0"
69
70
  },
70
71
  "devDependencies": {
72
+ "@atomic-solutions/errors": "^1.5.1",
71
73
  "@eslint/compat": "^1.3.2",
72
74
  "@eslint/eslintrc": "^3.3.1",
73
75
  "@eslint/js": "^9.35.0",