katanakit-js 3.1.3 → 3.2.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.
@@ -0,0 +1,685 @@
1
+ import type { FetchResult, WordPressConfig, WpBatchOperation, WpBatchResult, WpCategory, WpCategoryCreate, WpCategoryUpdate, WpComment, WpCommentCreate, WpCommentUpdate, WpMedia, WpMediaMeta, WpMediaUpdate, WpPage, WpPageCreate, WpPageUpdate, WpPost, WpPostCreate, WpPostUpdate, WpQueryParams, WpTag, WpTagCreate, WpTagUpdate, WpUser, WpUserCreate, WpUserUpdate } from "../../types/index.js";
2
+ /**
3
+ * Registers the WordPress REST API configuration. Call this once before
4
+ * any other WordPress function.
5
+ *
6
+ * Supports multiple auth methods: Application Passwords (recommended for
7
+ * plugins), JWT tokens, Basic Auth, and nonce-based auth for themes.
8
+ *
9
+ * @param cfg - Site URL, authentication method, and optional API namespace.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { useInitWordPress } from "katanakit-js/adapters/wordpress";
14
+ *
15
+ * // With Application Passwords (recommended)
16
+ * useInitWordPress({
17
+ * baseUrl: "https://mysite.com",
18
+ * auth: { type: "application-passwords", username: "admin", password: "xxxx xxxx xxxx" },
19
+ * });
20
+ *
21
+ * // With JWT
22
+ * useInitWordPress({
23
+ * baseUrl: "https://mysite.com",
24
+ * auth: { type: "jwt", token: "eyJhbGci..." },
25
+ * });
26
+ * ```
27
+ */
28
+ export declare function useInitWordPress(cfg: WordPressConfig): void;
29
+ /**
30
+ * Retrieves a list of WordPress posts with optional filtering and pagination.
31
+ *
32
+ * Use to display blog listings, search posts, or filter by category/tag/status.
33
+ * Returns a single page of results (default 10 per page).
34
+ *
35
+ * @param options - Query params: `per_page`, `page`, `search`, `categories`,
36
+ * `tags`, `status`, `orderby`, `order`, `_embed`, etc.
37
+ * @returns Array of posts.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * // Get latest 5 published posts
42
+ * const result = await useWpGetPosts({ per_page: 5, status: "publish" });
43
+ *
44
+ * // Search posts by keyword
45
+ * const result = await useWpGetPosts({ search: "tutorial" });
46
+ *
47
+ * // Get posts from category 3, sorted by title
48
+ * const result = await useWpGetPosts({ categories: 3, orderby: "title", order: "asc" });
49
+ * ```
50
+ */
51
+ export declare function useWpGetPosts(options?: WpQueryParams): Promise<FetchResult<WpPost[]>>;
52
+ /**
53
+ * Retrieves a single WordPress post by ID.
54
+ *
55
+ * @param id - The post ID.
56
+ * @param options - Optional query params (e.g. _embed for featured media).
57
+ * @returns The post object.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const result = await useWpGetPost(42, { _embed: true });
62
+ * if (result.ok) console.log(result.data.title.rendered);
63
+ * ```
64
+ */
65
+ export declare function useWpGetPost(id: number, options?: WpQueryParams): Promise<FetchResult<WpPost>>;
66
+ /**
67
+ * Creates a new WordPress post.
68
+ *
69
+ * Use to publish blog entries, create drafts, or schedule future posts.
70
+ * The post will be assigned to the authenticated user by default.
71
+ *
72
+ * @param data - Post data: `title`, `content` (HTML), `status` (publish/draft/pending),
73
+ * `categories`, `tags`, `featured_media`, `excerpt`, `slug`, `date`, etc.
74
+ * @returns The created post.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * // Publish immediately
79
+ * const result = await useWpCreatePost({
80
+ * title: "My New Post",
81
+ * content: "<p>Hello World!</p>",
82
+ * status: "publish",
83
+ * categories: [1, 3],
84
+ * });
85
+ *
86
+ * // Create as draft
87
+ * await useWpCreatePost({ title: "Draft Post", content: "...", status: "draft" });
88
+ * ```
89
+ */
90
+ export declare function useWpCreatePost(data: WpPostCreate): Promise<FetchResult<WpPost>>;
91
+ /**
92
+ * Updates an existing WordPress post.
93
+ *
94
+ * @param id - The post ID to update.
95
+ * @param data - Fields to update.
96
+ * @returns The updated post.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * await useWpUpdatePost(42, { title: "Updated Title" });
101
+ * ```
102
+ */
103
+ export declare function useWpUpdatePost(id: number, data: WpPostUpdate): Promise<FetchResult<WpPost>>;
104
+ /**
105
+ * Deletes a WordPress post.
106
+ *
107
+ * @param id - The post ID to delete.
108
+ * @param force - If true, permanently deletes. If false, moves to trash.
109
+ * @returns The deleted post.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * await useWpDeletePost(42); // Move to trash
114
+ * await useWpDeletePost(42, true); // Permanently delete
115
+ * ```
116
+ */
117
+ export declare function useWpDeletePost(id: number, force?: boolean): Promise<FetchResult<WpPost>>;
118
+ /**
119
+ * Retrieves a list of WordPress pages.
120
+ *
121
+ * @param options - Query params for filtering, sorting, and pagination.
122
+ * @returns Array of pages.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const result = await useWpGetPages({ per_page: 20 });
127
+ * ```
128
+ */
129
+ export declare function useWpGetPages(options?: WpQueryParams): Promise<FetchResult<WpPage[]>>;
130
+ /**
131
+ * Retrieves a single WordPress page by ID.
132
+ *
133
+ * @param id - The page ID.
134
+ * @param options - Optional query params.
135
+ * @returns The page object.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const result = await useWpGetPage(10);
140
+ * if (result.ok) console.log(result.data.title.rendered);
141
+ * ```
142
+ */
143
+ export declare function useWpGetPage(id: number, options?: WpQueryParams): Promise<FetchResult<WpPage>>;
144
+ /**
145
+ * Creates a new WordPress page.
146
+ *
147
+ * @param data - Page data (title, content, parent, etc.).
148
+ * @returns The created page.
149
+ *
150
+ * @example
151
+ * ```ts
152
+ * await useWpCreatePage({
153
+ * title: "About Us",
154
+ * content: "<p>Welcome to our site!</p>",
155
+ * status: "publish",
156
+ * });
157
+ * ```
158
+ */
159
+ export declare function useWpCreatePage(data: WpPageCreate): Promise<FetchResult<WpPage>>;
160
+ /**
161
+ * Updates an existing WordPress page.
162
+ *
163
+ * @param id - The page ID to update.
164
+ * @param data - Fields to update.
165
+ * @returns The updated page.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * await useWpUpdatePage(10, { title: "Updated About" });
170
+ * ```
171
+ */
172
+ export declare function useWpUpdatePage(id: number, data: WpPageUpdate): Promise<FetchResult<WpPage>>;
173
+ /**
174
+ * Deletes a WordPress page.
175
+ *
176
+ * @param id - The page ID to delete.
177
+ * @param force - If true, permanently deletes. If false, moves to trash.
178
+ * @returns The deleted page.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * await useWpDeletePage(10); // Move to trash
183
+ * ```
184
+ */
185
+ export declare function useWpDeletePage(id: number, force?: boolean): Promise<FetchResult<WpPage>>;
186
+ /**
187
+ * Retrieves a list of WordPress media items.
188
+ *
189
+ * @param options - Query params for filtering and pagination.
190
+ * @returns Array of media items.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * const result = await useWpGetMedia({ per_page: 20 });
195
+ * ```
196
+ */
197
+ export declare function useWpGetMedia(options?: WpQueryParams): Promise<FetchResult<WpMedia[]>>;
198
+ /**
199
+ * Retrieves a single WordPress media item by ID.
200
+ *
201
+ * @param id - The media item ID.
202
+ * @returns The media object.
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * const result = await useWpGetMediaItem(42);
207
+ * if (result.ok) console.log(result.data.source_url);
208
+ * ```
209
+ */
210
+ export declare function useWpGetMediaItem(id: number): Promise<FetchResult<WpMedia>>;
211
+ /**
212
+ * Uploads a file to the WordPress media library.
213
+ *
214
+ * Use to upload images, documents, or any file type supported by WordPress.
215
+ * Returns the media item with its URL for use as featured media or in content.
216
+ *
217
+ * @param file - File (browser), Blob, or Buffer (Node.js) to upload.
218
+ * @param meta - Optional metadata: `title`, `alt_text`, `caption`, `description`,
219
+ * `post` (attach to existing post), `slug`.
220
+ * @returns The created media item with `source_url`.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * // From a file input (browser)
225
+ * const file = document.querySelector("input[type=file]").files[0];
226
+ * const result = await useWpUploadMedia(file, {
227
+ * title: "My Image",
228
+ * alt_text: "Description for accessibility",
229
+ * });
230
+ * if (result.ok) console.log(result.data.source_url); // URL to use in content
231
+ *
232
+ * // From a Buffer (Node.js)
233
+ * const buffer = fs.readFileSync("photo.jpg");
234
+ * await useWpUploadMedia(buffer, { title: "Photo" });
235
+ * ```
236
+ */
237
+ export declare function useWpUploadMedia(file: File | Blob | Buffer, meta?: WpMediaMeta): Promise<FetchResult<WpMedia>>;
238
+ /**
239
+ * Updates metadata of a WordPress media item.
240
+ *
241
+ * @param id - The media item ID.
242
+ * @param data - Fields to update.
243
+ * @returns The updated media item.
244
+ *
245
+ * @example
246
+ * ```ts
247
+ * await useWpUpdateMedia(42, { alt_text: "New alt text" });
248
+ * ```
249
+ */
250
+ export declare function useWpUpdateMedia(id: number, data: WpMediaUpdate): Promise<FetchResult<WpMedia>>;
251
+ /**
252
+ * Deletes a WordPress media item.
253
+ *
254
+ * @param id - The media item ID.
255
+ * @param force - If true, permanently deletes.
256
+ * @returns The deleted media item.
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * await useWpDeleteMedia(42, true);
261
+ * ```
262
+ */
263
+ export declare function useWpDeleteMedia(id: number, force?: boolean): Promise<FetchResult<WpMedia>>;
264
+ /**
265
+ * Retrieves a list of WordPress categories.
266
+ *
267
+ * @param options - Query params for filtering and pagination.
268
+ * @returns Array of categories.
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * const result = await useWpGetCategories({ per_page: 50 });
273
+ * if (result.ok) result.data.forEach(c => console.log(c.name));
274
+ * ```
275
+ */
276
+ export declare function useWpGetCategories(options?: WpQueryParams): Promise<FetchResult<WpCategory[]>>;
277
+ /**
278
+ * Retrieves a single WordPress category by ID.
279
+ *
280
+ * @param id - The category ID.
281
+ * @returns The category object.
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * const result = await useWpGetCategory(5);
286
+ * if (result.ok) console.log(result.data.name);
287
+ * ```
288
+ */
289
+ export declare function useWpGetCategory(id: number): Promise<FetchResult<WpCategory>>;
290
+ /**
291
+ * Creates a new WordPress category.
292
+ *
293
+ * @param data - Category data (name, slug, parent, etc.).
294
+ * @returns The created category.
295
+ *
296
+ * @example
297
+ * ```ts
298
+ * await useWpCreateCategory({ name: "Technology", slug: "tech" });
299
+ * ```
300
+ */
301
+ export declare function useWpCreateCategory(data: WpCategoryCreate): Promise<FetchResult<WpCategory>>;
302
+ /**
303
+ * Updates an existing WordPress category.
304
+ *
305
+ * @param id - The category ID to update.
306
+ * @param data - Fields to update.
307
+ * @returns The updated category.
308
+ *
309
+ * @example
310
+ * ```ts
311
+ * await useWpUpdateCategory(5, { name: "Tech News" });
312
+ * ```
313
+ */
314
+ export declare function useWpUpdateCategory(id: number, data: WpCategoryUpdate): Promise<FetchResult<WpCategory>>;
315
+ /**
316
+ * Deletes a WordPress category.
317
+ *
318
+ * @param id - The category ID to delete.
319
+ * @param force - If true, permanently deletes.
320
+ * @returns The deleted category.
321
+ *
322
+ * @example
323
+ * ```ts
324
+ * await useWpDeleteCategory(5);
325
+ * ```
326
+ */
327
+ export declare function useWpDeleteCategory(id: number, force?: boolean): Promise<FetchResult<WpCategory>>;
328
+ /**
329
+ * Retrieves a list of WordPress tags.
330
+ *
331
+ * @param options - Query params for filtering and pagination.
332
+ * @returns Array of tags.
333
+ *
334
+ * @example
335
+ * ```ts
336
+ * const result = await useWpGetTags({ search: "javascript" });
337
+ * ```
338
+ */
339
+ export declare function useWpGetTags(options?: WpQueryParams): Promise<FetchResult<WpTag[]>>;
340
+ /**
341
+ * Retrieves a single WordPress tag by ID.
342
+ *
343
+ * @param id - The tag ID.
344
+ * @returns The tag object.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * const result = await useWpGetTag(12);
349
+ * ```
350
+ */
351
+ export declare function useWpGetTag(id: number): Promise<FetchResult<WpTag>>;
352
+ /**
353
+ * Creates a new WordPress tag.
354
+ *
355
+ * @param data - Tag data (name, slug, etc.).
356
+ * @returns The created tag.
357
+ *
358
+ * @example
359
+ * ```ts
360
+ * await useWpCreateTag({ name: "TypeScript", slug: "typescript" });
361
+ * ```
362
+ */
363
+ export declare function useWpCreateTag(data: WpTagCreate): Promise<FetchResult<WpTag>>;
364
+ /**
365
+ * Updates an existing WordPress tag.
366
+ *
367
+ * @param id - The tag ID to update.
368
+ * @param data - Fields to update.
369
+ * @returns The updated tag.
370
+ *
371
+ * @example
372
+ * ```ts
373
+ * await useWpUpdateTag(12, { name: "TS" });
374
+ * ```
375
+ */
376
+ export declare function useWpUpdateTag(id: number, data: WpTagUpdate): Promise<FetchResult<WpTag>>;
377
+ /**
378
+ * Deletes a WordPress tag.
379
+ *
380
+ * @param id - The tag ID to delete.
381
+ * @param force - If true, permanently deletes.
382
+ * @returns The deleted tag.
383
+ *
384
+ * @example
385
+ * ```ts
386
+ * await useWpDeleteTag(12);
387
+ * ```
388
+ */
389
+ export declare function useWpDeleteTag(id: number, force?: boolean): Promise<FetchResult<WpTag>>;
390
+ /**
391
+ * Retrieves a list of WordPress comments.
392
+ *
393
+ * @param options - Query params for filtering and pagination.
394
+ * @returns Array of comments.
395
+ *
396
+ * @example
397
+ * ```ts
398
+ * // Get comments for a specific post
399
+ * const result = await useWpGetComments({ post: 42 });
400
+ * ```
401
+ */
402
+ export declare function useWpGetComments(options?: WpQueryParams): Promise<FetchResult<WpComment[]>>;
403
+ /**
404
+ * Retrieves a single WordPress comment by ID.
405
+ *
406
+ * @param id - The comment ID.
407
+ * @returns The comment object.
408
+ *
409
+ * @example
410
+ * ```ts
411
+ * const result = await useWpGetComment(7);
412
+ * ```
413
+ */
414
+ export declare function useWpGetComment(id: number): Promise<FetchResult<WpComment>>;
415
+ /**
416
+ * Creates a new WordPress comment.
417
+ *
418
+ * @param data - Comment data (post ID, content, author, etc.).
419
+ * @returns The created comment.
420
+ *
421
+ * @example
422
+ * ```ts
423
+ * await useWpCreateComment({
424
+ * post: 42,
425
+ * content: "Great article!",
426
+ * author_name: "John",
427
+ * author_email: "john@example.com",
428
+ * });
429
+ * ```
430
+ */
431
+ export declare function useWpCreateComment(data: WpCommentCreate): Promise<FetchResult<WpComment>>;
432
+ /**
433
+ * Updates an existing WordPress comment.
434
+ *
435
+ * @param id - The comment ID to update.
436
+ * @param data - Fields to update.
437
+ * @returns The updated comment.
438
+ *
439
+ * @example
440
+ * ```ts
441
+ * await useWpUpdateComment(7, { content: "Updated comment" });
442
+ * ```
443
+ */
444
+ export declare function useWpUpdateComment(id: number, data: WpCommentUpdate): Promise<FetchResult<WpComment>>;
445
+ /**
446
+ * Deletes a WordPress comment.
447
+ *
448
+ * @param id - The comment ID to delete.
449
+ * @param force - If true, permanently deletes.
450
+ * @returns The deleted comment.
451
+ *
452
+ * @example
453
+ * ```ts
454
+ * await useWpDeleteComment(7);
455
+ * ```
456
+ */
457
+ export declare function useWpDeleteComment(id: number, force?: boolean): Promise<FetchResult<WpComment>>;
458
+ /**
459
+ * Retrieves a list of WordPress users.
460
+ *
461
+ * @param options - Query params for filtering and pagination.
462
+ * @returns Array of users.
463
+ *
464
+ * @example
465
+ * ```ts
466
+ * const result = await useWpGetUsers({ roles: "editor" });
467
+ * ```
468
+ */
469
+ export declare function useWpGetUsers(options?: WpQueryParams): Promise<FetchResult<WpUser[]>>;
470
+ /**
471
+ * Retrieves a single WordPress user by ID.
472
+ *
473
+ * @param id - The user ID.
474
+ * @returns The user object.
475
+ *
476
+ * @example
477
+ * ```ts
478
+ * const result = await useWpGetUser(1);
479
+ * if (result.ok) console.log(result.data.name);
480
+ * ```
481
+ */
482
+ export declare function useWpGetUser(id: number): Promise<FetchResult<WpUser>>;
483
+ /**
484
+ * Retrieves the currently authenticated WordPress user.
485
+ *
486
+ * @returns The current user object.
487
+ *
488
+ * @example
489
+ * ```ts
490
+ * const result = await useWpGetCurrentUser();
491
+ * if (result.ok) console.log(result.data.email);
492
+ * ```
493
+ */
494
+ export declare function useWpGetCurrentUser(): Promise<FetchResult<WpUser>>;
495
+ /**
496
+ * Creates a new WordPress user.
497
+ *
498
+ * @param data - User data (username, email, password, etc.).
499
+ * @returns The created user.
500
+ *
501
+ * @example
502
+ * ```ts
503
+ * await useWpCreateUser({
504
+ * username: "johndoe",
505
+ * email: "john@example.com",
506
+ * password: "secure-password",
507
+ * roles: ["editor"],
508
+ * });
509
+ * ```
510
+ */
511
+ export declare function useWpCreateUser(data: WpUserCreate): Promise<FetchResult<WpUser>>;
512
+ /**
513
+ * Updates an existing WordPress user.
514
+ *
515
+ * @param id - The user ID to update.
516
+ * @param data - Fields to update.
517
+ * @returns The updated user.
518
+ *
519
+ * @example
520
+ * ```ts
521
+ * await useWpUpdateUser(2, { name: "John Smith" });
522
+ * ```
523
+ */
524
+ export declare function useWpUpdateUser(id: number, data: WpUserUpdate): Promise<FetchResult<WpUser>>;
525
+ /**
526
+ * Deletes a WordPress user.
527
+ *
528
+ * @param id - The user ID to delete.
529
+ * @param reassign - User ID to reassign content to (required for non-admin).
530
+ * @returns The deleted user.
531
+ *
532
+ * @example
533
+ * ```ts
534
+ * await useWpDeleteUser(2, 1); // Reassign content to user 1
535
+ * ```
536
+ */
537
+ export declare function useWpDeleteUser(id: number, reassign?: number): Promise<FetchResult<WpUser>>;
538
+ /**
539
+ * Retrieves a list of custom post type entries.
540
+ *
541
+ * @param postType - The custom post type slug (e.g. "product", "portfolio").
542
+ * @param options - Query params for filtering and pagination.
543
+ * @returns Array of custom post entries.
544
+ *
545
+ * @example
546
+ * ```ts
547
+ * const result = await useWpGetCustomPosts("product", { per_page: 10 });
548
+ * ```
549
+ */
550
+ export declare function useWpGetCustomPosts(postType: string, options?: WpQueryParams): Promise<FetchResult<unknown[]>>;
551
+ /**
552
+ * Retrieves a single custom post type entry by ID.
553
+ *
554
+ * @param postType - The custom post type slug.
555
+ * @param id - The entry ID.
556
+ * @param options - Optional query params.
557
+ * @returns The custom post entry.
558
+ *
559
+ * @example
560
+ * ```ts
561
+ * const result = await useWpGetCustomPost("product", 15);
562
+ * ```
563
+ */
564
+ export declare function useWpGetCustomPost(postType: string, id: number, options?: WpQueryParams): Promise<FetchResult<unknown>>;
565
+ /**
566
+ * Creates a new custom post type entry.
567
+ *
568
+ * @param postType - The custom post type slug.
569
+ * @param data - Entry data.
570
+ * @returns The created entry.
571
+ *
572
+ * @example
573
+ * ```ts
574
+ * await useWpCreateCustomPost("product", {
575
+ * title: "Widget",
576
+ * content: "<p>A great widget</p>",
577
+ * status: "publish",
578
+ * });
579
+ * ```
580
+ */
581
+ export declare function useWpCreateCustomPost(postType: string, data: Record<string, unknown>): Promise<FetchResult<unknown>>;
582
+ /**
583
+ * Updates a custom post type entry.
584
+ *
585
+ * @param postType - The custom post type slug.
586
+ * @param id - The entry ID.
587
+ * @param data - Fields to update.
588
+ * @returns The updated entry.
589
+ *
590
+ * @example
591
+ * ```ts
592
+ * await useWpUpdateCustomPost("product", 15, { title: "Updated Widget" });
593
+ * ```
594
+ */
595
+ export declare function useWpUpdateCustomPost(postType: string, id: number, data: Record<string, unknown>): Promise<FetchResult<unknown>>;
596
+ /**
597
+ * Deletes a custom post type entry.
598
+ *
599
+ * @param postType - The custom post type slug.
600
+ * @param id - The entry ID.
601
+ * @param force - If true, permanently deletes.
602
+ * @returns The deleted entry.
603
+ *
604
+ * @example
605
+ * ```ts
606
+ * await useWpDeleteCustomPost("product", 15, true);
607
+ * ```
608
+ */
609
+ export declare function useWpDeleteCustomPost(postType: string, id: number, force?: boolean): Promise<FetchResult<unknown>>;
610
+ /**
611
+ * Executes multiple WordPress REST API requests in a single batch.
612
+ *
613
+ * @param operations - Array of batch operations to execute.
614
+ * @returns Combined results from all operations.
615
+ *
616
+ * @example
617
+ * ```ts
618
+ * const result = await useWpBatch([
619
+ * { method: "GET", path: "/wp/v2/posts/1" },
620
+ * { method: "POST", path: "/wp/v2/posts", body: { title: "New Post" } },
621
+ * ]);
622
+ * if (result.ok) console.log(result.data.responses);
623
+ * ```
624
+ */
625
+ export declare function useWpBatch(operations: WpBatchOperation[]): Promise<FetchResult<WpBatchResult>>;
626
+ /**
627
+ * Fetches ALL posts matching the criteria, automatically handling pagination.
628
+ *
629
+ * Use when you need every post (e.g. for sitemap generation, RSS feeds,
630
+ * or data exports) without managing page numbers. Loops until all pages
631
+ * are fetched.
632
+ *
633
+ * @param options - Query params for filtering (`status`, `categories`, `tags`,
634
+ * `author`, `search`, `orderby`, `order`). Do NOT pass `page` or `per_page`.
635
+ * @returns All posts as a flat array.
636
+ *
637
+ * @example
638
+ * ```ts
639
+ * // Get ALL published posts
640
+ * const result = await useWpListAllPosts({ status: "publish" });
641
+ * if (result.ok) console.log(`Total: ${result.data.length}`);
642
+ *
643
+ * // Get ALL posts from category 5
644
+ * const cat5 = await useWpListAllPosts({ categories: 5 });
645
+ * ```
646
+ */
647
+ export declare function useWpListAllPosts(options?: WpQueryParams): Promise<FetchResult<WpPost[]>>;
648
+ /**
649
+ * Searches ALL posts by keyword, automatically handling pagination.
650
+ *
651
+ * Use to find posts by title or content when you need every match,
652
+ * not just the first page. Combines `search` param with auto-pagination.
653
+ *
654
+ * @param query - Search term (searches title and content).
655
+ * @param options - Additional filters (`status`, `categories`, etc.).
656
+ * @returns All posts matching the search.
657
+ *
658
+ * @example
659
+ * ```ts
660
+ * const result = await useWpSearchAllPosts("tutorial");
661
+ * if (result.ok) result.data.forEach(p => console.log(p.title.rendered));
662
+ * ```
663
+ */
664
+ export declare function useWpSearchAllPosts(query: string, options?: WpQueryParams): Promise<FetchResult<WpPost[]>>;
665
+ /**
666
+ * Finds a single post by its URL slug.
667
+ *
668
+ * Use for slug-based routing (e.g. `/blog/:slug` pages) where you need
669
+ * to fetch a post by its human-readable URL identifier. Returns `null`
670
+ * if no post matches the slug.
671
+ *
672
+ * @param slug - The post slug (e.g. "hello-world").
673
+ * @returns The post or `null` if not found.
674
+ *
675
+ * @example
676
+ * ```ts
677
+ * // In an Astro/[slug].astro or similar dynamic route
678
+ * const result = await useWpFindPostBySlug("hello-world");
679
+ * if (result.ok && result.data) {
680
+ * console.log(result.data.title.rendered);
681
+ * }
682
+ * ```
683
+ */
684
+ export declare function useWpFindPostBySlug(slug: string): Promise<FetchResult<WpPost | null>>;
685
+ //# sourceMappingURL=wordpress.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wordpress.service.d.ts","sourceRoot":"","sources":["../../../src/adapters/wordpress/wordpress.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,KAAK,EACL,WAAW,EACX,WAAW,EACX,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,MAAM,sBAAsB,CAAC;AAkO9B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAE3D;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAE3F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CACjC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAE9B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAKtF;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CACpC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,YAAY,GAChB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAK9B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC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