@szymonpiatek/nextwordpress 0.0.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/index.cjs +798 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +697 -0
- package/dist/index.d.ts +697 -0
- package/dist/index.js +788 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
interface NextWordpressConfig {
|
|
2
|
+
/** Used in server components / SSR (e.g., internal Docker hostname). */
|
|
3
|
+
serverURL: string;
|
|
4
|
+
/** Used in browser / client components (e.g., public domain). */
|
|
5
|
+
clientURL: string;
|
|
6
|
+
}
|
|
7
|
+
interface WordPressPaginationHeaders {
|
|
8
|
+
total: number;
|
|
9
|
+
totalPages: number;
|
|
10
|
+
}
|
|
11
|
+
interface WordPressResponse<T> {
|
|
12
|
+
data: T;
|
|
13
|
+
headers: WordPressPaginationHeaders;
|
|
14
|
+
}
|
|
15
|
+
declare class WordPressAPIError extends Error {
|
|
16
|
+
status: number;
|
|
17
|
+
endpoint: string;
|
|
18
|
+
constructor(message: string, status: number, endpoint: string);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare function resolveBaseUrl(config: NextWordpressConfig): string;
|
|
22
|
+
declare function buildUrl(config: NextWordpressConfig, path: string, query?: Record<string, unknown>): string;
|
|
23
|
+
|
|
24
|
+
declare function createFetcher(config: NextWordpressConfig): {
|
|
25
|
+
wpFetch: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
|
|
26
|
+
wpFetchGraceful: <T>(path: string, fallback: T, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
|
|
27
|
+
wpFetchPaginated: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WordPressResponse<T[]>>;
|
|
28
|
+
wpFetchPaginatedGraceful: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WordPressResponse<T[]>>;
|
|
29
|
+
wpMutate: <T>(path: string, body: unknown, method?: "POST" | "PUT" | "PATCH" | "DELETE") => Promise<T>;
|
|
30
|
+
};
|
|
31
|
+
type WordPressFetcher = ReturnType<typeof createFetcher>;
|
|
32
|
+
|
|
33
|
+
interface WPEntity {
|
|
34
|
+
id: number;
|
|
35
|
+
date: string;
|
|
36
|
+
date_gmt: string;
|
|
37
|
+
modified: string;
|
|
38
|
+
modified_gmt: string;
|
|
39
|
+
slug: string;
|
|
40
|
+
status: 'publish' | 'future' | 'draft' | 'pending' | 'private';
|
|
41
|
+
link: string;
|
|
42
|
+
guid: {
|
|
43
|
+
rendered: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
interface RenderedContent {
|
|
47
|
+
rendered: string;
|
|
48
|
+
protected: boolean;
|
|
49
|
+
}
|
|
50
|
+
interface RenderedTitle {
|
|
51
|
+
rendered: string;
|
|
52
|
+
}
|
|
53
|
+
interface Taxonomy {
|
|
54
|
+
id: number;
|
|
55
|
+
count: number;
|
|
56
|
+
description: string;
|
|
57
|
+
link: string;
|
|
58
|
+
name: string;
|
|
59
|
+
slug: string;
|
|
60
|
+
meta: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface MediaSize {
|
|
64
|
+
file: string;
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
mime_type: string;
|
|
68
|
+
source_url: string;
|
|
69
|
+
}
|
|
70
|
+
interface MediaDetails {
|
|
71
|
+
width: number;
|
|
72
|
+
height: number;
|
|
73
|
+
file: string;
|
|
74
|
+
sizes: Record<string, MediaSize>;
|
|
75
|
+
}
|
|
76
|
+
interface FeaturedMedia extends WPEntity {
|
|
77
|
+
title: RenderedTitle;
|
|
78
|
+
author: number;
|
|
79
|
+
caption: {
|
|
80
|
+
rendered: string;
|
|
81
|
+
};
|
|
82
|
+
alt_text: string;
|
|
83
|
+
media_type: string;
|
|
84
|
+
mime_type: string;
|
|
85
|
+
media_details: MediaDetails;
|
|
86
|
+
source_url: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface Author {
|
|
90
|
+
id: number;
|
|
91
|
+
name: string;
|
|
92
|
+
url: string;
|
|
93
|
+
description: string;
|
|
94
|
+
link: string;
|
|
95
|
+
slug: string;
|
|
96
|
+
avatar_urls: Record<string, string>;
|
|
97
|
+
meta: Record<string, unknown>;
|
|
98
|
+
}
|
|
99
|
+
interface EmbeddedAuthor {
|
|
100
|
+
id: number;
|
|
101
|
+
name: string;
|
|
102
|
+
slug: string;
|
|
103
|
+
avatar_urls: Record<string, string>;
|
|
104
|
+
}
|
|
105
|
+
interface EmbeddedTerm {
|
|
106
|
+
id: number;
|
|
107
|
+
name: string;
|
|
108
|
+
slug: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface BlockSupports {
|
|
112
|
+
align?: boolean | string[];
|
|
113
|
+
anchor?: boolean;
|
|
114
|
+
className?: boolean;
|
|
115
|
+
color?: {
|
|
116
|
+
background?: boolean;
|
|
117
|
+
gradients?: boolean;
|
|
118
|
+
text?: boolean;
|
|
119
|
+
};
|
|
120
|
+
spacing?: {
|
|
121
|
+
margin?: boolean;
|
|
122
|
+
padding?: boolean;
|
|
123
|
+
};
|
|
124
|
+
typography?: {
|
|
125
|
+
fontSize?: boolean;
|
|
126
|
+
lineHeight?: boolean;
|
|
127
|
+
};
|
|
128
|
+
[key: string]: unknown;
|
|
129
|
+
}
|
|
130
|
+
interface BlockStyle {
|
|
131
|
+
name: string;
|
|
132
|
+
label: string;
|
|
133
|
+
isDefault: boolean;
|
|
134
|
+
}
|
|
135
|
+
interface BlockType {
|
|
136
|
+
api_version: number;
|
|
137
|
+
title: string;
|
|
138
|
+
name: string;
|
|
139
|
+
description: string;
|
|
140
|
+
icon: string;
|
|
141
|
+
category: string;
|
|
142
|
+
keywords: string[];
|
|
143
|
+
parent: string[];
|
|
144
|
+
supports: BlockSupports;
|
|
145
|
+
styles: BlockStyle[];
|
|
146
|
+
textdomain: string;
|
|
147
|
+
example: Record<string, unknown>;
|
|
148
|
+
attributes: Record<string, unknown>;
|
|
149
|
+
provides_context: Record<string, string>;
|
|
150
|
+
uses_context: string[];
|
|
151
|
+
editor_script: string;
|
|
152
|
+
script: string;
|
|
153
|
+
editor_style: string;
|
|
154
|
+
style: string;
|
|
155
|
+
}
|
|
156
|
+
interface EditorBlock {
|
|
157
|
+
id: string;
|
|
158
|
+
name: string;
|
|
159
|
+
attributes: Record<string, unknown>;
|
|
160
|
+
innerBlocks: EditorBlock[];
|
|
161
|
+
innerHTML: string;
|
|
162
|
+
innerContent: (string | null)[];
|
|
163
|
+
}
|
|
164
|
+
interface TemplatePart {
|
|
165
|
+
id: string;
|
|
166
|
+
slug: string;
|
|
167
|
+
theme: string;
|
|
168
|
+
type: string;
|
|
169
|
+
source: string;
|
|
170
|
+
origin: string;
|
|
171
|
+
content: string | EditorBlock[];
|
|
172
|
+
title: {
|
|
173
|
+
raw: string;
|
|
174
|
+
rendered: string;
|
|
175
|
+
};
|
|
176
|
+
description: string;
|
|
177
|
+
status: 'publish' | 'future' | 'draft' | 'pending' | 'private';
|
|
178
|
+
wp_id: number;
|
|
179
|
+
has_theme_file: boolean;
|
|
180
|
+
author: number;
|
|
181
|
+
area: string;
|
|
182
|
+
}
|
|
183
|
+
interface SearchResult {
|
|
184
|
+
id: number;
|
|
185
|
+
title: string;
|
|
186
|
+
url: string;
|
|
187
|
+
type: string;
|
|
188
|
+
subtype: string;
|
|
189
|
+
_links: {
|
|
190
|
+
self: Array<{
|
|
191
|
+
embeddable: boolean;
|
|
192
|
+
href: string;
|
|
193
|
+
}>;
|
|
194
|
+
about: Array<{
|
|
195
|
+
href: string;
|
|
196
|
+
}>;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
interface PostEmbedded {
|
|
201
|
+
author?: EmbeddedAuthor[];
|
|
202
|
+
'wp:featuredmedia'?: FeaturedMedia[];
|
|
203
|
+
'wp:term'?: EmbeddedTerm[][];
|
|
204
|
+
}
|
|
205
|
+
interface Post extends WPEntity {
|
|
206
|
+
title: RenderedTitle;
|
|
207
|
+
content: RenderedContent;
|
|
208
|
+
excerpt: RenderedContent;
|
|
209
|
+
author: number;
|
|
210
|
+
featured_media: number;
|
|
211
|
+
comment_status: 'open' | 'closed';
|
|
212
|
+
ping_status: 'open' | 'closed';
|
|
213
|
+
sticky: boolean;
|
|
214
|
+
template: string;
|
|
215
|
+
format: 'standard' | 'aside' | 'chat' | 'gallery' | 'link' | 'image' | 'quote' | 'status' | 'video' | 'audio';
|
|
216
|
+
categories: number[];
|
|
217
|
+
tags: number[];
|
|
218
|
+
meta: Record<string, unknown>;
|
|
219
|
+
blocks?: EditorBlock[];
|
|
220
|
+
_embedded?: PostEmbedded;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface Category extends Taxonomy {
|
|
224
|
+
taxonomy: 'category';
|
|
225
|
+
parent: number;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
interface Tag extends Taxonomy {
|
|
229
|
+
taxonomy: 'post_tag';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface Page extends WPEntity {
|
|
233
|
+
title: RenderedTitle;
|
|
234
|
+
content: RenderedContent;
|
|
235
|
+
excerpt: RenderedContent;
|
|
236
|
+
author: number;
|
|
237
|
+
featured_media: number;
|
|
238
|
+
parent: number;
|
|
239
|
+
menu_order: number;
|
|
240
|
+
comment_status: 'open' | 'closed';
|
|
241
|
+
ping_status: 'open' | 'closed';
|
|
242
|
+
template: string;
|
|
243
|
+
meta: Record<string, unknown>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
declare function createWordPressClient(config: NextWordpressConfig): {
|
|
247
|
+
getAllPages: () => Promise<Page[]>;
|
|
248
|
+
getPageById: (id: number) => Promise<Page>;
|
|
249
|
+
getPageBySlug: (slug: string) => Promise<Page | undefined>;
|
|
250
|
+
getFeaturedMediaById: (id: number) => Promise<FeaturedMedia>;
|
|
251
|
+
getAllAuthors: () => Promise<Author[]>;
|
|
252
|
+
getAuthorById: (id: number) => Promise<Author>;
|
|
253
|
+
getAuthorBySlug: (slug: string) => Promise<Author>;
|
|
254
|
+
searchAuthors: (query: string) => Promise<Author[]>;
|
|
255
|
+
getAllTags: () => Promise<Tag[]>;
|
|
256
|
+
getTagById: (id: number) => Promise<Tag>;
|
|
257
|
+
getTagBySlug: (slug: string) => Promise<Tag>;
|
|
258
|
+
getTagsByPost: (postId: number) => Promise<Tag[]>;
|
|
259
|
+
searchTags: (query: string) => Promise<Tag[]>;
|
|
260
|
+
getAllCategories: () => Promise<Category[]>;
|
|
261
|
+
getCategoryById: (id: number) => Promise<Category>;
|
|
262
|
+
getCategoryBySlug: (slug: string) => Promise<Category>;
|
|
263
|
+
searchCategories: (query: string) => Promise<Category[]>;
|
|
264
|
+
getPostsPaginated: (page?: number, perPage?: number, filterParams?: {
|
|
265
|
+
author?: string;
|
|
266
|
+
tag?: string;
|
|
267
|
+
category?: string;
|
|
268
|
+
search?: string;
|
|
269
|
+
}) => Promise<WordPressResponse<Post[]>>;
|
|
270
|
+
getRecentPosts: (filterParams?: {
|
|
271
|
+
author?: string;
|
|
272
|
+
tag?: string;
|
|
273
|
+
category?: string;
|
|
274
|
+
search?: string;
|
|
275
|
+
}) => Promise<Post[]>;
|
|
276
|
+
getPostById: (id: number) => Promise<Post>;
|
|
277
|
+
getPostBySlug: (slug: string) => Promise<Post | undefined>;
|
|
278
|
+
getPostsByCategory: (categoryId: number) => Promise<Post[]>;
|
|
279
|
+
getPostsByTag: (tagId: number) => Promise<Post[]>;
|
|
280
|
+
getPostsByAuthor: (authorId: number) => Promise<Post[]>;
|
|
281
|
+
getPostsByCategoryPaginated: (categoryId: number, page?: number, perPage?: number) => Promise<WordPressResponse<Post[]>>;
|
|
282
|
+
getPostsByTagPaginated: (tagId: number, page?: number, perPage?: number) => Promise<WordPressResponse<Post[]>>;
|
|
283
|
+
getPostsByAuthorPaginated: (authorId: number, page?: number, perPage?: number) => Promise<WordPressResponse<Post[]>>;
|
|
284
|
+
getAllPostSlugs: () => Promise<{
|
|
285
|
+
slug: string;
|
|
286
|
+
}[]>;
|
|
287
|
+
getAllPostsForSitemap: () => Promise<{
|
|
288
|
+
slug: string;
|
|
289
|
+
modified: string;
|
|
290
|
+
}[]>;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
interface WooCommerceConfig {
|
|
294
|
+
serverURL: string;
|
|
295
|
+
consumerKey: string;
|
|
296
|
+
consumerSecret: string;
|
|
297
|
+
cacheTTL?: number;
|
|
298
|
+
}
|
|
299
|
+
interface WooCommercePaginationHeaders {
|
|
300
|
+
total: number;
|
|
301
|
+
totalPages: number;
|
|
302
|
+
}
|
|
303
|
+
interface WooCommerceResponse<T> {
|
|
304
|
+
data: T;
|
|
305
|
+
headers: WooCommercePaginationHeaders;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
declare function createWooCommerceFetcher(config: WooCommerceConfig): {
|
|
309
|
+
wcFetch: <T>(path: string, query?: Record<string, unknown>, tags?: string[], options?: RequestInit) => Promise<T>;
|
|
310
|
+
wcFetchGraceful: <T>(path: string, fallback: T, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
|
|
311
|
+
wcFetchPaginated: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
|
|
312
|
+
wcFetchPaginatedGraceful: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
|
|
313
|
+
wcMutate: <T>(path: string, body: unknown, method?: "POST" | "PUT" | "PATCH" | "DELETE") => Promise<T>;
|
|
314
|
+
};
|
|
315
|
+
type WooCommerceFetcher = ReturnType<typeof createWooCommerceFetcher>;
|
|
316
|
+
|
|
317
|
+
interface WCImage {
|
|
318
|
+
id: number;
|
|
319
|
+
src: string;
|
|
320
|
+
name: string;
|
|
321
|
+
alt: string;
|
|
322
|
+
}
|
|
323
|
+
interface WCDimensions {
|
|
324
|
+
length: string;
|
|
325
|
+
width: string;
|
|
326
|
+
height: string;
|
|
327
|
+
}
|
|
328
|
+
interface WCAddress {
|
|
329
|
+
first_name: string;
|
|
330
|
+
last_name: string;
|
|
331
|
+
company: string;
|
|
332
|
+
address_1: string;
|
|
333
|
+
address_2: string;
|
|
334
|
+
city: string;
|
|
335
|
+
state: string;
|
|
336
|
+
postcode: string;
|
|
337
|
+
country: string;
|
|
338
|
+
email?: string;
|
|
339
|
+
phone?: string;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
interface WCProductCategory {
|
|
343
|
+
id: number;
|
|
344
|
+
name: string;
|
|
345
|
+
slug: string;
|
|
346
|
+
parent: number;
|
|
347
|
+
description: string;
|
|
348
|
+
display: string;
|
|
349
|
+
image: WCImage | null;
|
|
350
|
+
menu_order: number;
|
|
351
|
+
count: number;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
interface WCProductAttribute {
|
|
355
|
+
id: number;
|
|
356
|
+
name: string;
|
|
357
|
+
position: number;
|
|
358
|
+
visible: boolean;
|
|
359
|
+
variation: boolean;
|
|
360
|
+
options: string[];
|
|
361
|
+
}
|
|
362
|
+
interface WCProductDefaultAttribute {
|
|
363
|
+
id: number;
|
|
364
|
+
name: string;
|
|
365
|
+
option: string;
|
|
366
|
+
}
|
|
367
|
+
interface WCProductVariation {
|
|
368
|
+
id: number;
|
|
369
|
+
date_created: string;
|
|
370
|
+
date_modified: string;
|
|
371
|
+
description: string;
|
|
372
|
+
permalink: string;
|
|
373
|
+
sku: string;
|
|
374
|
+
price: string;
|
|
375
|
+
regular_price: string;
|
|
376
|
+
sale_price: string;
|
|
377
|
+
on_sale: boolean;
|
|
378
|
+
purchasable: boolean;
|
|
379
|
+
stock_quantity: number | null;
|
|
380
|
+
stock_status: 'instock' | 'outofstock' | 'onbackorder';
|
|
381
|
+
manage_stock: boolean;
|
|
382
|
+
backorders: 'no' | 'notify' | 'yes';
|
|
383
|
+
backorders_allowed: boolean;
|
|
384
|
+
backordered: boolean;
|
|
385
|
+
weight: string;
|
|
386
|
+
dimensions: WCDimensions;
|
|
387
|
+
image: WCImage | null;
|
|
388
|
+
attributes: Array<{
|
|
389
|
+
id: number;
|
|
390
|
+
name: string;
|
|
391
|
+
option: string;
|
|
392
|
+
}>;
|
|
393
|
+
}
|
|
394
|
+
interface WCProduct {
|
|
395
|
+
id: number;
|
|
396
|
+
name: string;
|
|
397
|
+
slug: string;
|
|
398
|
+
permalink: string;
|
|
399
|
+
date_created: string;
|
|
400
|
+
date_modified: string;
|
|
401
|
+
type: 'simple' | 'grouped' | 'external' | 'variable';
|
|
402
|
+
status: 'draft' | 'pending' | 'private' | 'publish';
|
|
403
|
+
featured: boolean;
|
|
404
|
+
catalog_visibility: 'visible' | 'catalog' | 'search' | 'hidden';
|
|
405
|
+
description: string;
|
|
406
|
+
short_description: string;
|
|
407
|
+
sku: string;
|
|
408
|
+
price: string;
|
|
409
|
+
regular_price: string;
|
|
410
|
+
sale_price: string;
|
|
411
|
+
on_sale: boolean;
|
|
412
|
+
purchasable: boolean;
|
|
413
|
+
total_sales: number;
|
|
414
|
+
virtual: boolean;
|
|
415
|
+
downloadable: boolean;
|
|
416
|
+
tax_status: 'taxable' | 'shipping' | 'none';
|
|
417
|
+
tax_class: string;
|
|
418
|
+
manage_stock: boolean;
|
|
419
|
+
stock_quantity: number | null;
|
|
420
|
+
stock_status: 'instock' | 'outofstock' | 'onbackorder';
|
|
421
|
+
backorders: 'no' | 'notify' | 'yes';
|
|
422
|
+
backorders_allowed: boolean;
|
|
423
|
+
backordered: boolean;
|
|
424
|
+
sold_individually: boolean;
|
|
425
|
+
weight: string;
|
|
426
|
+
dimensions: WCDimensions;
|
|
427
|
+
shipping_required: boolean;
|
|
428
|
+
shipping_taxable: boolean;
|
|
429
|
+
shipping_class: string;
|
|
430
|
+
shipping_class_id: number;
|
|
431
|
+
reviews_allowed: boolean;
|
|
432
|
+
average_rating: string;
|
|
433
|
+
rating_count: number;
|
|
434
|
+
related_ids: number[];
|
|
435
|
+
upsell_ids: number[];
|
|
436
|
+
cross_sell_ids: number[];
|
|
437
|
+
parent_id: number;
|
|
438
|
+
categories: Array<{
|
|
439
|
+
id: number;
|
|
440
|
+
name: string;
|
|
441
|
+
slug: string;
|
|
442
|
+
}>;
|
|
443
|
+
tags: Array<{
|
|
444
|
+
id: number;
|
|
445
|
+
name: string;
|
|
446
|
+
slug: string;
|
|
447
|
+
}>;
|
|
448
|
+
images: WCImage[];
|
|
449
|
+
attributes: WCProductAttribute[];
|
|
450
|
+
default_attributes: WCProductDefaultAttribute[];
|
|
451
|
+
variations: number[];
|
|
452
|
+
grouped_products: number[];
|
|
453
|
+
menu_order: number;
|
|
454
|
+
meta_data: Array<{
|
|
455
|
+
id: number;
|
|
456
|
+
key: string;
|
|
457
|
+
value: unknown;
|
|
458
|
+
}>;
|
|
459
|
+
}
|
|
460
|
+
interface WCProductFilterParams {
|
|
461
|
+
category?: string;
|
|
462
|
+
tag?: string;
|
|
463
|
+
featured?: boolean;
|
|
464
|
+
on_sale?: boolean;
|
|
465
|
+
min_price?: string;
|
|
466
|
+
max_price?: string;
|
|
467
|
+
search?: string;
|
|
468
|
+
orderby?: 'date' | 'id' | 'include' | 'title' | 'slug' | 'price' | 'popularity' | 'rating';
|
|
469
|
+
order?: 'asc' | 'desc';
|
|
470
|
+
stock_status?: 'instock' | 'outofstock' | 'onbackorder';
|
|
471
|
+
type?: WCProduct['type'];
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
interface WCProductTag {
|
|
475
|
+
id: number;
|
|
476
|
+
name: string;
|
|
477
|
+
slug: string;
|
|
478
|
+
description: string;
|
|
479
|
+
count: number;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
interface WCOrderLineItem {
|
|
483
|
+
id: number;
|
|
484
|
+
name: string;
|
|
485
|
+
product_id: number;
|
|
486
|
+
variation_id: number;
|
|
487
|
+
quantity: number;
|
|
488
|
+
sku: string;
|
|
489
|
+
price: number;
|
|
490
|
+
subtotal: string;
|
|
491
|
+
subtotal_tax: string;
|
|
492
|
+
total: string;
|
|
493
|
+
total_tax: string;
|
|
494
|
+
taxes: Array<{
|
|
495
|
+
id: number;
|
|
496
|
+
total: string;
|
|
497
|
+
subtotal: string;
|
|
498
|
+
}>;
|
|
499
|
+
meta_data: Array<{
|
|
500
|
+
id: number;
|
|
501
|
+
key: string;
|
|
502
|
+
value: unknown;
|
|
503
|
+
display_key: string;
|
|
504
|
+
display_value: string;
|
|
505
|
+
}>;
|
|
506
|
+
image: {
|
|
507
|
+
id: string;
|
|
508
|
+
src: string;
|
|
509
|
+
} | null;
|
|
510
|
+
}
|
|
511
|
+
interface WCShippingLine {
|
|
512
|
+
id: number;
|
|
513
|
+
method_title: string;
|
|
514
|
+
method_id: string;
|
|
515
|
+
instance_id: string;
|
|
516
|
+
total: string;
|
|
517
|
+
total_tax: string;
|
|
518
|
+
taxes: Array<{
|
|
519
|
+
id: number;
|
|
520
|
+
total: string;
|
|
521
|
+
}>;
|
|
522
|
+
meta_data: Array<{
|
|
523
|
+
id: number;
|
|
524
|
+
key: string;
|
|
525
|
+
value: unknown;
|
|
526
|
+
}>;
|
|
527
|
+
}
|
|
528
|
+
interface WCOrder {
|
|
529
|
+
id: number;
|
|
530
|
+
parent_id: number;
|
|
531
|
+
status: 'pending' | 'processing' | 'on-hold' | 'completed' | 'cancelled' | 'refunded' | 'failed' | 'trash';
|
|
532
|
+
currency: string;
|
|
533
|
+
date_created: string;
|
|
534
|
+
date_modified: string;
|
|
535
|
+
discount_total: string;
|
|
536
|
+
discount_tax: string;
|
|
537
|
+
shipping_total: string;
|
|
538
|
+
shipping_tax: string;
|
|
539
|
+
cart_tax: string;
|
|
540
|
+
total: string;
|
|
541
|
+
total_tax: string;
|
|
542
|
+
customer_id: number;
|
|
543
|
+
order_key: string;
|
|
544
|
+
billing: WCAddress;
|
|
545
|
+
shipping: WCAddress;
|
|
546
|
+
payment_method: string;
|
|
547
|
+
payment_method_title: string;
|
|
548
|
+
transaction_id: string;
|
|
549
|
+
customer_note: string;
|
|
550
|
+
line_items: WCOrderLineItem[];
|
|
551
|
+
shipping_lines: WCShippingLine[];
|
|
552
|
+
meta_data: Array<{
|
|
553
|
+
id: number;
|
|
554
|
+
key: string;
|
|
555
|
+
value: unknown;
|
|
556
|
+
}>;
|
|
557
|
+
}
|
|
558
|
+
interface WCCreateOrderInput {
|
|
559
|
+
status?: WCOrder['status'];
|
|
560
|
+
payment_method?: string;
|
|
561
|
+
payment_method_title?: string;
|
|
562
|
+
customer_id?: number;
|
|
563
|
+
customer_note?: string;
|
|
564
|
+
billing?: Partial<WCAddress>;
|
|
565
|
+
shipping?: Partial<WCAddress>;
|
|
566
|
+
line_items: Array<{
|
|
567
|
+
product_id: number;
|
|
568
|
+
variation_id?: number;
|
|
569
|
+
quantity: number;
|
|
570
|
+
}>;
|
|
571
|
+
coupon_lines?: Array<{
|
|
572
|
+
code: string;
|
|
573
|
+
}>;
|
|
574
|
+
shipping_lines?: Array<{
|
|
575
|
+
method_id: string;
|
|
576
|
+
method_title: string;
|
|
577
|
+
total: string;
|
|
578
|
+
}>;
|
|
579
|
+
meta_data?: Array<{
|
|
580
|
+
key: string;
|
|
581
|
+
value: unknown;
|
|
582
|
+
}>;
|
|
583
|
+
set_paid?: boolean;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
interface WCCoupon {
|
|
587
|
+
id: number;
|
|
588
|
+
code: string;
|
|
589
|
+
discount_type: 'percent' | 'fixed_cart' | 'fixed_product';
|
|
590
|
+
amount: string;
|
|
591
|
+
date_expires: string | null;
|
|
592
|
+
usage_count: number;
|
|
593
|
+
individual_use: boolean;
|
|
594
|
+
product_ids: number[];
|
|
595
|
+
excluded_product_ids: number[];
|
|
596
|
+
usage_limit: number | null;
|
|
597
|
+
usage_limit_per_user: number | null;
|
|
598
|
+
free_shipping: boolean;
|
|
599
|
+
minimum_amount: string;
|
|
600
|
+
maximum_amount: string;
|
|
601
|
+
description: string;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
interface WCCustomer {
|
|
605
|
+
id: number;
|
|
606
|
+
date_created: string;
|
|
607
|
+
date_modified: string;
|
|
608
|
+
email: string;
|
|
609
|
+
first_name: string;
|
|
610
|
+
last_name: string;
|
|
611
|
+
role: string;
|
|
612
|
+
username: string;
|
|
613
|
+
billing: WCAddress;
|
|
614
|
+
shipping: Omit<WCAddress, 'email' | 'phone'>;
|
|
615
|
+
is_paying_customer: boolean;
|
|
616
|
+
avatar_url: string;
|
|
617
|
+
orders_count: number;
|
|
618
|
+
total_spent: string;
|
|
619
|
+
meta_data: Array<{
|
|
620
|
+
id: number;
|
|
621
|
+
key: string;
|
|
622
|
+
value: unknown;
|
|
623
|
+
}>;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
interface OmnibusPriceEntry {
|
|
627
|
+
price: string;
|
|
628
|
+
date: string;
|
|
629
|
+
}
|
|
630
|
+
interface OmnibusProductData {
|
|
631
|
+
lowestPrice: string | null;
|
|
632
|
+
priceHistory: OmnibusPriceEntry[];
|
|
633
|
+
}
|
|
634
|
+
type WCProductWithOmnibus = WCProduct & {
|
|
635
|
+
omnibus: OmnibusProductData;
|
|
636
|
+
};
|
|
637
|
+
type WCProductVariationWithOmnibus = WCProductVariation & {
|
|
638
|
+
omnibus: OmnibusProductData;
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
declare function extractOmnibusData(meta_data: Array<{
|
|
642
|
+
id: number;
|
|
643
|
+
key: string;
|
|
644
|
+
value: unknown;
|
|
645
|
+
}>): OmnibusProductData;
|
|
646
|
+
declare function withOmnibus(product: WCProduct): WCProductWithOmnibus;
|
|
647
|
+
declare function withOmnibusVariation(variation: WCProductVariation & {
|
|
648
|
+
meta_data?: Array<{
|
|
649
|
+
id: number;
|
|
650
|
+
key: string;
|
|
651
|
+
value: unknown;
|
|
652
|
+
}>;
|
|
653
|
+
}): WCProductVariationWithOmnibus;
|
|
654
|
+
|
|
655
|
+
declare function createWooCommerceClient(config: WooCommerceConfig): {
|
|
656
|
+
getCustomerById: (id: number) => Promise<WCCustomer>;
|
|
657
|
+
getCustomerByEmail: (email: string) => Promise<WCCustomer | undefined>;
|
|
658
|
+
getCustomerByEmailNoCache: (email: string) => Promise<WCCustomer | undefined>;
|
|
659
|
+
createCustomer: (data: Pick<WCCustomer, "email" | "first_name" | "last_name"> & {
|
|
660
|
+
username?: string;
|
|
661
|
+
password?: string;
|
|
662
|
+
billing?: Partial<WCAddress>;
|
|
663
|
+
shipping?: Partial<Omit<WCAddress, "email" | "phone">>;
|
|
664
|
+
}) => Promise<WCCustomer>;
|
|
665
|
+
getCouponByCode: (code: string) => Promise<WCCoupon | undefined>;
|
|
666
|
+
validateCoupon: (code: string) => Promise<{
|
|
667
|
+
valid: boolean;
|
|
668
|
+
coupon?: WCCoupon;
|
|
669
|
+
reason?: string;
|
|
670
|
+
}>;
|
|
671
|
+
createOrder: (input: WCCreateOrderInput) => Promise<WCOrder>;
|
|
672
|
+
getOrderById: (id: number) => Promise<WCOrder>;
|
|
673
|
+
updateOrder: (id: number, data: Partial<WCCreateOrderInput>) => Promise<WCOrder>;
|
|
674
|
+
getOrdersByCustomer: (customerId: number) => Promise<WCOrder[]>;
|
|
675
|
+
getAllProductTags: () => Promise<WCProductTag[]>;
|
|
676
|
+
getProductTagById: (id: number) => Promise<WCProductTag>;
|
|
677
|
+
getProductsByTag: (tagId: number, limit?: number) => Promise<WCProduct[]>;
|
|
678
|
+
getAllProductCategories: () => Promise<WCProductCategory[]>;
|
|
679
|
+
getProductCategoryById: (id: number) => Promise<WCProductCategory>;
|
|
680
|
+
getProductCategoryBySlug: (slug: string) => Promise<WCProductCategory | undefined>;
|
|
681
|
+
getProductsByCategory: (categoryId: number, limit?: number) => Promise<WCProduct[]>;
|
|
682
|
+
getProductsByCategorySlug: (categorySlug: string) => Promise<WCProduct[]>;
|
|
683
|
+
getProducts: (filterParams?: WCProductFilterParams) => Promise<WCProduct[]>;
|
|
684
|
+
getProductsPaginated: (page?: number, perPage?: number, filterParams?: WCProductFilterParams) => Promise<WooCommerceResponse<WCProduct[]>>;
|
|
685
|
+
getProductById: (id: number) => Promise<WCProduct>;
|
|
686
|
+
getProductBySlug: (slug: string) => Promise<WCProduct | undefined>;
|
|
687
|
+
getFeaturedProducts: (limit?: number) => Promise<WCProduct[]>;
|
|
688
|
+
getOnSaleProducts: (limit?: number) => Promise<WCProduct[]>;
|
|
689
|
+
getRelatedProducts: (productId: number) => Promise<WCProduct[]>;
|
|
690
|
+
getAllProductSlugs: () => Promise<{
|
|
691
|
+
slug: string;
|
|
692
|
+
}[]>;
|
|
693
|
+
getProductVariations: (productId: number) => Promise<WCProductVariation[]>;
|
|
694
|
+
getProductVariationById: (productId: number, variationId: number) => Promise<WCProductVariation>;
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
export { type Author, type BlockType, type Category, type EditorBlock, type EmbeddedAuthor, type EmbeddedTerm, type FeaturedMedia, type MediaDetails, type MediaSize, type NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, type Post, type PostEmbedded, type RenderedContent, type RenderedTitle, type SearchResult, type Tag, type Taxonomy, type TemplatePart, type WCAddress, type WCCoupon, type WCCreateOrderInput, type WCCustomer, type WCDimensions, type WCImage, type WCOrder, type WCOrderLineItem, type WCProduct, type WCProductAttribute, type WCProductCategory, type WCProductDefaultAttribute, type WCProductFilterParams, type WCProductTag, type WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCShippingLine, type WPEntity, type WooCommerceConfig, type WooCommerceFetcher, type WooCommercePaginationHeaders, type WooCommerceResponse, WordPressAPIError, type WordPressFetcher, type WordPressPaginationHeaders, type WordPressResponse, buildUrl, createFetcher, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, extractOmnibusData, resolveBaseUrl, withOmnibus, withOmnibusVariation };
|