@atomic-solutions/woocommerce-api-client 0.5.0 → 0.5.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.
- package/dist/client/index.d.mts +3 -2
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.js +48 -26
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +49 -27
- package/dist/client/index.mjs.map +1 -1
- package/dist/http/index.d.mts +3 -2
- package/dist/http/index.d.ts +3 -2
- package/dist/http/index.js +49 -25
- package/dist/http/index.js.map +1 -1
- package/dist/http/index.mjs +50 -26
- package/dist/http/index.mjs.map +1 -1
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +48 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -27
- package/dist/index.mjs.map +1 -1
- package/dist/testing/index.d.mts +2 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +48 -26
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs +49 -27
- package/dist/testing/index.mjs.map +1 -1
- package/dist/{types-aYzN4O5x.d.mts → types-9I6oS_83.d.mts} +7 -19
- package/dist/{types-aYzN4O5x.d.ts → types-9I6oS_83.d.ts} +7 -19
- package/dist/utils/index.d.mts +3 -2
- package/dist/utils/index.d.ts +3 -2
- package/package.json +3 -1
|
@@ -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
|
|
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
|
|
50
|
-
|
|
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';
|
|
@@ -3584,4 +3572,4 @@ interface WooCommerceClient {
|
|
|
3584
3572
|
orders: OrdersAPI;
|
|
3585
3573
|
}
|
|
3586
3574
|
|
|
3587
|
-
export { checkoutSchema as $, type AddItemsInput as A,
|
|
3575
|
+
export { checkoutSchema as $, type AddItemsInput as A, type BaseErrorOptions 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 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
|
|
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
|
|
50
|
-
|
|
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';
|
|
@@ -3584,4 +3572,4 @@ interface WooCommerceClient {
|
|
|
3584
3572
|
orders: OrdersAPI;
|
|
3585
3573
|
}
|
|
3586
3574
|
|
|
3587
|
-
export { checkoutSchema as $, type AddItemsInput as A,
|
|
3575
|
+
export { checkoutSchema as $, type AddItemsInput as A, type BaseErrorOptions 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 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 };
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { C as CartHeadersAdapter } from '../types-
|
|
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-
|
|
1
|
+
import { C as CartHeadersAdapter } from '../types-9I6oS_83.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-9I6oS_83.mjs';
|
|
3
3
|
import { AxiosResponse, AxiosInstance } from 'axios';
|
|
4
|
+
import '@atomic-solutions/errors';
|
|
4
5
|
import 'zod';
|
|
5
6
|
|
|
6
7
|
interface PaginationMeta {
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { C as CartHeadersAdapter } from '../types-
|
|
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-
|
|
1
|
+
import { C as CartHeadersAdapter } from '../types-9I6oS_83.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-9I6oS_83.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.
|
|
3
|
+
"version": "0.5.1",
|
|
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",
|