@szymonpiatek/nextwordpress 0.0.6 → 0.0.8
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/hooks/index.cjs +170 -30
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +170 -30
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +934 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +577 -3
- package/dist/index.d.ts +577 -3
- package/dist/index.js +929 -32
- package/dist/index.js.map +1 -1
- package/dist/{types-soq-mA1E.d.cts → types-Dxb6tuW_.d.cts} +54 -4
- package/dist/{types-soq-mA1E.d.ts → types-Dxb6tuW_.d.ts} +54 -4
- package/package.json +15 -5
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
declare const ErrorCode: {
|
|
2
|
+
readonly WP_REQUEST_FAILED: "WP_REQUEST_FAILED";
|
|
3
|
+
readonly WP_NOT_FOUND: "WP_NOT_FOUND";
|
|
4
|
+
readonly WP_UNAUTHORIZED: "WP_UNAUTHORIZED";
|
|
5
|
+
readonly WP_FORBIDDEN: "WP_FORBIDDEN";
|
|
6
|
+
readonly GQL_REQUEST_FAILED: "GQL_REQUEST_FAILED";
|
|
7
|
+
readonly GQL_NO_DATA: "GQL_NO_DATA";
|
|
8
|
+
readonly GQL_ERRORS_IN_RESPONSE: "GQL_ERRORS_IN_RESPONSE";
|
|
9
|
+
readonly WOO_REQUEST_FAILED: "WOO_REQUEST_FAILED";
|
|
10
|
+
readonly WOO_NOT_FOUND: "WOO_NOT_FOUND";
|
|
11
|
+
readonly WOO_UNAUTHORIZED: "WOO_UNAUTHORIZED";
|
|
12
|
+
readonly WOO_FORBIDDEN: "WOO_FORBIDDEN";
|
|
13
|
+
readonly WOO_COUPON_NOT_FOUND: "WOO_COUPON_NOT_FOUND";
|
|
14
|
+
readonly WOO_PRODUCT_NOT_FOUND: "WOO_PRODUCT_NOT_FOUND";
|
|
15
|
+
readonly WOO_ORDER_NOT_FOUND: "WOO_ORDER_NOT_FOUND";
|
|
16
|
+
readonly WOO_CUSTOMER_NOT_FOUND: "WOO_CUSTOMER_NOT_FOUND";
|
|
17
|
+
readonly WOO_CATEGORY_NOT_FOUND: "WOO_CATEGORY_NOT_FOUND";
|
|
18
|
+
readonly WOO_TAG_NOT_FOUND: "WOO_TAG_NOT_FOUND";
|
|
19
|
+
readonly WOO_REVIEW_NOT_FOUND: "WOO_REVIEW_NOT_FOUND";
|
|
20
|
+
readonly WOO_WEBHOOK_NOT_FOUND: "WOO_WEBHOOK_NOT_FOUND";
|
|
21
|
+
readonly WOO_SHIPPING_ZONE_NOT_FOUND: "WOO_SHIPPING_ZONE_NOT_FOUND";
|
|
22
|
+
readonly AUTH_JWT_FAILED: "AUTH_JWT_FAILED";
|
|
23
|
+
readonly AUTH_CREDENTIALS_INVALID: "AUTH_CREDENTIALS_INVALID";
|
|
24
|
+
readonly AUTH_TOKEN_INVALID: "AUTH_TOKEN_INVALID";
|
|
25
|
+
};
|
|
26
|
+
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
27
|
+
declare const defaultMessages: Record<ErrorCode, string>;
|
|
28
|
+
declare const defaultMessagesPl: Record<ErrorCode, string>;
|
|
29
|
+
declare function resolveMessage(code: ErrorCode, overrides?: Partial<Record<ErrorCode, string>>): string;
|
|
30
|
+
|
|
1
31
|
interface NextWordpressConfig {
|
|
2
32
|
/** Used in server components / SSR (e.g., internal Docker hostname). */
|
|
3
33
|
serverURL: string;
|
|
@@ -5,6 +35,8 @@ interface NextWordpressConfig {
|
|
|
5
35
|
clientURL: string;
|
|
6
36
|
/** Cache TTL in seconds for Next.js ISR revalidation (default: 300). */
|
|
7
37
|
cacheTTL?: number;
|
|
38
|
+
/** Override default error messages by error code. */
|
|
39
|
+
errorMessages?: Partial<Record<ErrorCode, string>>;
|
|
8
40
|
}
|
|
9
41
|
interface WPEntity {
|
|
10
42
|
id: number;
|
|
@@ -47,8 +79,9 @@ interface JwtAuthResponse {
|
|
|
47
79
|
user_display_name: string;
|
|
48
80
|
}
|
|
49
81
|
declare class AuthenticationError extends Error {
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
readonly code: ErrorCode;
|
|
83
|
+
readonly status: number;
|
|
84
|
+
constructor(code: ErrorCode, status: number, message: string, detail?: string);
|
|
52
85
|
}
|
|
53
86
|
|
|
54
87
|
interface MediaSize {
|
|
@@ -219,12 +252,21 @@ interface WordPressResponse<T> {
|
|
|
219
252
|
data: T;
|
|
220
253
|
headers: WordPressPaginationHeaders;
|
|
221
254
|
}
|
|
255
|
+
declare class WordPressAPIError extends Error {
|
|
256
|
+
readonly code: ErrorCode;
|
|
257
|
+
readonly status: number;
|
|
258
|
+
readonly endpoint: string;
|
|
259
|
+
constructor(code: ErrorCode, status: number, endpoint: string, message: string, detail?: string);
|
|
260
|
+
}
|
|
222
261
|
|
|
223
262
|
interface WooCommerceConfig {
|
|
224
263
|
serverURL: string;
|
|
264
|
+
clientURL?: string;
|
|
225
265
|
consumerKey: string;
|
|
226
266
|
consumerSecret: string;
|
|
227
267
|
cacheTTL?: number;
|
|
268
|
+
/** Override default error messages by error code. */
|
|
269
|
+
errorMessages?: Partial<Record<ErrorCode, string>>;
|
|
228
270
|
}
|
|
229
271
|
interface WooCommercePaginationHeaders {
|
|
230
272
|
total: number;
|
|
@@ -234,6 +276,13 @@ interface WooCommerceResponse<T> {
|
|
|
234
276
|
data: T;
|
|
235
277
|
headers: WooCommercePaginationHeaders;
|
|
236
278
|
}
|
|
279
|
+
declare class WooCommerceError extends Error {
|
|
280
|
+
readonly code: ErrorCode;
|
|
281
|
+
readonly status: number;
|
|
282
|
+
readonly endpoint: string;
|
|
283
|
+
readonly upstreamCode?: string | undefined;
|
|
284
|
+
constructor(code: ErrorCode, status: number, endpoint: string, message: string, upstreamCode?: string | undefined, detail?: string);
|
|
285
|
+
}
|
|
237
286
|
|
|
238
287
|
interface WCImage {
|
|
239
288
|
id: number;
|
|
@@ -540,10 +589,11 @@ interface GQLError {
|
|
|
540
589
|
path?: string[];
|
|
541
590
|
}
|
|
542
591
|
declare class WPGraphQLError extends Error {
|
|
592
|
+
readonly code: ErrorCode;
|
|
543
593
|
readonly status: number;
|
|
544
594
|
readonly endpoint: string;
|
|
545
595
|
readonly gqlErrors?: GQLError[] | undefined;
|
|
546
|
-
constructor(
|
|
596
|
+
constructor(code: ErrorCode, status: number, endpoint: string, message: string, gqlErrors?: GQLError[] | undefined);
|
|
547
597
|
}
|
|
548
598
|
|
|
549
599
|
interface GQLPostFilter {
|
|
@@ -600,4 +650,4 @@ interface GQLPost {
|
|
|
600
650
|
};
|
|
601
651
|
}
|
|
602
652
|
|
|
603
|
-
export { type Author as A, type BlockType as B, type
|
|
653
|
+
export { type Author as A, type BlockType as B, type WCOrderLineItem as C, type WCProductAttribute as D, type EditorBlock as E, type FeaturedMedia as F, type GQLPost as G, type WCProductDefaultAttribute as H, type WCShippingLine as I, type JwtAuthCredentials as J, WPGraphQLError as K, WooCommerceError as L, type MediaDetails as M, type NextWordpressConfig as N, type WooCommercePaginationHeaders as O, type Post as P, WordPressAPIError as Q, type RenderedTitle as R, type SearchResult as S, type Taxonomy as T, type UpdateCustomerInput as U, defaultMessages as V, type WordPressResponse as W, defaultMessagesPl as X, resolveMessage as Y, type WooCommerceConfig as a, type WCProduct as b, type WCProductFilterParams as c, type WooCommerceResponse as d, type WCCreateOrderInput as e, type WCOrder as f, type WCCustomer as g, type WPGraphQLConfig as h, type GQLPostFilter as i, type GQLConnection as j, type JwtAuthResponse as k, type WPEntity as l, type RenderedContent as m, type WCImage as n, type WCProductVariation as o, type WCAddress as p, AuthenticationError as q, type EmbeddedAuthor as r, type EmbeddedTerm as s, ErrorCode as t, type GQLError as u, type GQLPageInfo as v, type MediaSize as w, type PostEmbedded as x, type TemplatePart as y, type WCDimensions as z };
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
declare const ErrorCode: {
|
|
2
|
+
readonly WP_REQUEST_FAILED: "WP_REQUEST_FAILED";
|
|
3
|
+
readonly WP_NOT_FOUND: "WP_NOT_FOUND";
|
|
4
|
+
readonly WP_UNAUTHORIZED: "WP_UNAUTHORIZED";
|
|
5
|
+
readonly WP_FORBIDDEN: "WP_FORBIDDEN";
|
|
6
|
+
readonly GQL_REQUEST_FAILED: "GQL_REQUEST_FAILED";
|
|
7
|
+
readonly GQL_NO_DATA: "GQL_NO_DATA";
|
|
8
|
+
readonly GQL_ERRORS_IN_RESPONSE: "GQL_ERRORS_IN_RESPONSE";
|
|
9
|
+
readonly WOO_REQUEST_FAILED: "WOO_REQUEST_FAILED";
|
|
10
|
+
readonly WOO_NOT_FOUND: "WOO_NOT_FOUND";
|
|
11
|
+
readonly WOO_UNAUTHORIZED: "WOO_UNAUTHORIZED";
|
|
12
|
+
readonly WOO_FORBIDDEN: "WOO_FORBIDDEN";
|
|
13
|
+
readonly WOO_COUPON_NOT_FOUND: "WOO_COUPON_NOT_FOUND";
|
|
14
|
+
readonly WOO_PRODUCT_NOT_FOUND: "WOO_PRODUCT_NOT_FOUND";
|
|
15
|
+
readonly WOO_ORDER_NOT_FOUND: "WOO_ORDER_NOT_FOUND";
|
|
16
|
+
readonly WOO_CUSTOMER_NOT_FOUND: "WOO_CUSTOMER_NOT_FOUND";
|
|
17
|
+
readonly WOO_CATEGORY_NOT_FOUND: "WOO_CATEGORY_NOT_FOUND";
|
|
18
|
+
readonly WOO_TAG_NOT_FOUND: "WOO_TAG_NOT_FOUND";
|
|
19
|
+
readonly WOO_REVIEW_NOT_FOUND: "WOO_REVIEW_NOT_FOUND";
|
|
20
|
+
readonly WOO_WEBHOOK_NOT_FOUND: "WOO_WEBHOOK_NOT_FOUND";
|
|
21
|
+
readonly WOO_SHIPPING_ZONE_NOT_FOUND: "WOO_SHIPPING_ZONE_NOT_FOUND";
|
|
22
|
+
readonly AUTH_JWT_FAILED: "AUTH_JWT_FAILED";
|
|
23
|
+
readonly AUTH_CREDENTIALS_INVALID: "AUTH_CREDENTIALS_INVALID";
|
|
24
|
+
readonly AUTH_TOKEN_INVALID: "AUTH_TOKEN_INVALID";
|
|
25
|
+
};
|
|
26
|
+
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
27
|
+
declare const defaultMessages: Record<ErrorCode, string>;
|
|
28
|
+
declare const defaultMessagesPl: Record<ErrorCode, string>;
|
|
29
|
+
declare function resolveMessage(code: ErrorCode, overrides?: Partial<Record<ErrorCode, string>>): string;
|
|
30
|
+
|
|
1
31
|
interface NextWordpressConfig {
|
|
2
32
|
/** Used in server components / SSR (e.g., internal Docker hostname). */
|
|
3
33
|
serverURL: string;
|
|
@@ -5,6 +35,8 @@ interface NextWordpressConfig {
|
|
|
5
35
|
clientURL: string;
|
|
6
36
|
/** Cache TTL in seconds for Next.js ISR revalidation (default: 300). */
|
|
7
37
|
cacheTTL?: number;
|
|
38
|
+
/** Override default error messages by error code. */
|
|
39
|
+
errorMessages?: Partial<Record<ErrorCode, string>>;
|
|
8
40
|
}
|
|
9
41
|
interface WPEntity {
|
|
10
42
|
id: number;
|
|
@@ -47,8 +79,9 @@ interface JwtAuthResponse {
|
|
|
47
79
|
user_display_name: string;
|
|
48
80
|
}
|
|
49
81
|
declare class AuthenticationError extends Error {
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
readonly code: ErrorCode;
|
|
83
|
+
readonly status: number;
|
|
84
|
+
constructor(code: ErrorCode, status: number, message: string, detail?: string);
|
|
52
85
|
}
|
|
53
86
|
|
|
54
87
|
interface MediaSize {
|
|
@@ -219,12 +252,21 @@ interface WordPressResponse<T> {
|
|
|
219
252
|
data: T;
|
|
220
253
|
headers: WordPressPaginationHeaders;
|
|
221
254
|
}
|
|
255
|
+
declare class WordPressAPIError extends Error {
|
|
256
|
+
readonly code: ErrorCode;
|
|
257
|
+
readonly status: number;
|
|
258
|
+
readonly endpoint: string;
|
|
259
|
+
constructor(code: ErrorCode, status: number, endpoint: string, message: string, detail?: string);
|
|
260
|
+
}
|
|
222
261
|
|
|
223
262
|
interface WooCommerceConfig {
|
|
224
263
|
serverURL: string;
|
|
264
|
+
clientURL?: string;
|
|
225
265
|
consumerKey: string;
|
|
226
266
|
consumerSecret: string;
|
|
227
267
|
cacheTTL?: number;
|
|
268
|
+
/** Override default error messages by error code. */
|
|
269
|
+
errorMessages?: Partial<Record<ErrorCode, string>>;
|
|
228
270
|
}
|
|
229
271
|
interface WooCommercePaginationHeaders {
|
|
230
272
|
total: number;
|
|
@@ -234,6 +276,13 @@ interface WooCommerceResponse<T> {
|
|
|
234
276
|
data: T;
|
|
235
277
|
headers: WooCommercePaginationHeaders;
|
|
236
278
|
}
|
|
279
|
+
declare class WooCommerceError extends Error {
|
|
280
|
+
readonly code: ErrorCode;
|
|
281
|
+
readonly status: number;
|
|
282
|
+
readonly endpoint: string;
|
|
283
|
+
readonly upstreamCode?: string | undefined;
|
|
284
|
+
constructor(code: ErrorCode, status: number, endpoint: string, message: string, upstreamCode?: string | undefined, detail?: string);
|
|
285
|
+
}
|
|
237
286
|
|
|
238
287
|
interface WCImage {
|
|
239
288
|
id: number;
|
|
@@ -540,10 +589,11 @@ interface GQLError {
|
|
|
540
589
|
path?: string[];
|
|
541
590
|
}
|
|
542
591
|
declare class WPGraphQLError extends Error {
|
|
592
|
+
readonly code: ErrorCode;
|
|
543
593
|
readonly status: number;
|
|
544
594
|
readonly endpoint: string;
|
|
545
595
|
readonly gqlErrors?: GQLError[] | undefined;
|
|
546
|
-
constructor(
|
|
596
|
+
constructor(code: ErrorCode, status: number, endpoint: string, message: string, gqlErrors?: GQLError[] | undefined);
|
|
547
597
|
}
|
|
548
598
|
|
|
549
599
|
interface GQLPostFilter {
|
|
@@ -600,4 +650,4 @@ interface GQLPost {
|
|
|
600
650
|
};
|
|
601
651
|
}
|
|
602
652
|
|
|
603
|
-
export { type Author as A, type BlockType as B, type
|
|
653
|
+
export { type Author as A, type BlockType as B, type WCOrderLineItem as C, type WCProductAttribute as D, type EditorBlock as E, type FeaturedMedia as F, type GQLPost as G, type WCProductDefaultAttribute as H, type WCShippingLine as I, type JwtAuthCredentials as J, WPGraphQLError as K, WooCommerceError as L, type MediaDetails as M, type NextWordpressConfig as N, type WooCommercePaginationHeaders as O, type Post as P, WordPressAPIError as Q, type RenderedTitle as R, type SearchResult as S, type Taxonomy as T, type UpdateCustomerInput as U, defaultMessages as V, type WordPressResponse as W, defaultMessagesPl as X, resolveMessage as Y, type WooCommerceConfig as a, type WCProduct as b, type WCProductFilterParams as c, type WooCommerceResponse as d, type WCCreateOrderInput as e, type WCOrder as f, type WCCustomer as g, type WPGraphQLConfig as h, type GQLPostFilter as i, type GQLConnection as j, type JwtAuthResponse as k, type WPEntity as l, type RenderedContent as m, type WCImage as n, type WCProductVariation as o, type WCAddress as p, AuthenticationError as q, type EmbeddedAuthor as r, type EmbeddedTerm as s, ErrorCode as t, type GQLError as u, type GQLPageInfo as v, type MediaSize as w, type PostEmbedded as x, type TemplatePart as y, type WCDimensions as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@szymonpiatek/nextwordpress",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Szymon Piątek - Next.js WordPress client (types, queries, fetcher)",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -42,15 +42,22 @@
|
|
|
42
42
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
43
43
|
"format": "prettier --write \"src/**/*.{ts,md,json}\"",
|
|
44
44
|
"typecheck": "tsc --noEmit",
|
|
45
|
-
"prepublishOnly": "npm run lint && npm run test && npm run clean && npm run build"
|
|
45
|
+
"prepublishOnly": "npm run lint && npm run test && npm run clean && npm run build",
|
|
46
|
+
"docs:dev": "typedoc && vitepress dev ../docs",
|
|
47
|
+
"docs:build": "typedoc && vitepress build ../docs",
|
|
48
|
+
"docs:preview": "vitepress preview ../docs"
|
|
46
49
|
},
|
|
47
50
|
"peerDependencies": {
|
|
48
51
|
"react": ">=18.0.0",
|
|
49
52
|
"swr": ">=2.0.0"
|
|
50
53
|
},
|
|
51
54
|
"peerDependenciesMeta": {
|
|
52
|
-
"react": {
|
|
53
|
-
|
|
55
|
+
"react": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"swr": {
|
|
59
|
+
"optional": true
|
|
60
|
+
}
|
|
54
61
|
},
|
|
55
62
|
"dependencies": {
|
|
56
63
|
"zod": "^3.23.8"
|
|
@@ -72,8 +79,11 @@
|
|
|
72
79
|
"swr": "^2.4.1",
|
|
73
80
|
"ts-jest": "^29.2.5",
|
|
74
81
|
"tsup": "^8.3.5",
|
|
82
|
+
"typedoc": "^0.28.19",
|
|
83
|
+
"typedoc-plugin-markdown": "^4.12.0",
|
|
75
84
|
"typescript": "^5.6.3",
|
|
76
|
-
"typescript-eslint": "^8.15.0"
|
|
85
|
+
"typescript-eslint": "^8.15.0",
|
|
86
|
+
"vitepress": "^1.6.4"
|
|
77
87
|
},
|
|
78
88
|
"repository": {
|
|
79
89
|
"type": "git",
|