kizlo 0.7.0 → 0.8.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/category/error.js +14 -0
- package/dist/category/index.js +77 -0
- package/dist/category/schema.js +40 -0
- package/dist/category/utils.js +20 -0
- package/dist/cli/banner.js +1 -1
- package/dist/cli/commands/_setup.js +342 -0
- package/dist/cli/commands/create.js +152 -0
- package/dist/cli/commands/dev.js +1 -1
- package/dist/cli/commands/init.js +53 -300
- package/dist/cli/index.js +2 -1
- package/dist/cli/presets/generated/templates.js +59 -0
- package/dist/cli/presets/nextjs.js +3 -95
- package/dist/cli/presets/patch.js +133 -0
- package/dist/cli/presets/template.js +36 -0
- package/dist/comment/index.js +4 -4
- package/dist/context.d.ts +25 -8
- package/dist/context.js +15 -5
- package/dist/email/service.d.ts +4 -3
- package/dist/email/service.js +4 -4
- package/dist/index.d.ts +15 -11
- package/dist/index.js +10 -4
- package/dist/integrations/nextjs/metadata.js +6 -3
- package/dist/integrations/nextjs/sitemap.d.ts +8 -7
- package/dist/integrations/nextjs/sitemap.js +3 -3
- package/dist/menu/index.js +19 -14
- package/dist/menu/schema.d.ts +14 -0
- package/dist/menu/schema.js +35 -40
- package/dist/menu/utils.js +23 -14
- package/dist/nextjs/server.d.ts +2 -1
- package/dist/nextjs/server.js +2 -1
- package/dist/package.js +1 -1
- package/dist/page/error.js +20 -0
- package/dist/page/index.js +128 -0
- package/dist/page/schema.js +75 -0
- package/dist/page/utils.js +43 -0
- package/dist/post/error.js +4 -14
- package/dist/post/index.js +17 -9
- package/dist/post/schema.js +37 -66
- package/dist/post/utils.js +27 -24
- package/dist/router.d.ts +1006 -185
- package/dist/router.js +6 -0
- package/dist/seo/index.js +7 -44
- package/dist/seo/schema.d.ts +10 -6
- package/dist/seo/schema.js +7 -5
- package/dist/seo/sitemap.d.ts +9 -1
- package/dist/seo/sitemap.js +17 -1
- package/dist/seo/types.d.ts +17 -20
- package/dist/seo/utils.js +9 -7
- package/dist/settings/index.js +27 -24
- package/dist/settings/service.d.ts +14 -13
- package/dist/settings/service.interface.d.ts +2 -2
- package/dist/settings/service.js +9 -9
- package/dist/shared/middleware.d.ts +4 -4
- package/dist/shared/procedure.d.ts +6 -7
- package/dist/tag/error.js +14 -0
- package/dist/tag/index.js +76 -0
- package/dist/tag/schema.js +38 -0
- package/dist/tag/utils.js +19 -0
- package/dist/taxonomy/service.js +48 -0
- package/dist/test/fixtures.d.ts +1 -1
- package/dist/test/fixtures.js +1 -1
- package/dist/webhook/index.d.ts +2 -2
- package/dist/wordpress/category/service.d.ts +28 -0
- package/dist/wordpress/category/service.js +55 -0
- package/dist/wordpress/category/types.d.ts +120 -0
- package/dist/wordpress/category/types.js +15 -0
- package/dist/wordpress/comment/service.d.ts +1 -1
- package/dist/wordpress/index.d.ts +9 -4
- package/dist/wordpress/menu/items/types.d.ts +7 -4
- package/dist/wordpress/menu/items/types.js +22 -0
- package/dist/wordpress/page/service.d.ts +28 -0
- package/dist/wordpress/page/service.js +55 -0
- package/dist/wordpress/page/types.d.ts +270 -0
- package/dist/wordpress/page/types.js +27 -0
- package/dist/wordpress/post/types.d.ts +9 -5
- package/dist/wordpress/post/types.js +41 -0
- package/dist/wordpress/service.d.ts +7 -1
- package/dist/wordpress/service.js +6 -0
- package/dist/wordpress/tag/service.d.ts +28 -0
- package/dist/wordpress/tag/service.js +55 -0
- package/dist/wordpress/tag/types.d.ts +113 -0
- package/dist/wordpress/tag/types.js +15 -0
- package/package.json +5 -3
- package/dist/service.d.ts +0 -19
- package/dist/service.js +0 -20
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { WP_Context, WP_Link, WP_ListOrder } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/wordpress/page/types.d.ts
|
|
4
|
+
/** A named status for the page. Used in responses and as the input on create/update. */
|
|
5
|
+
declare const WP_PAGE_STATUSES: readonly ["publish", "future", "draft", "pending", "private", "trash"];
|
|
6
|
+
type WP_PageStatus = (typeof WP_PAGE_STATUSES)[number];
|
|
7
|
+
/** Status filter values accepted by `GET /wp/v2/pages`. Widens `WP_PageStatus` with WP-internal statuses and the `any` alias. */
|
|
8
|
+
type WP_PageStatusFilter = WP_PageStatus | "auto-draft" | "inherit" | "any";
|
|
9
|
+
/** Whether or not comments / pings are open on the page. */
|
|
10
|
+
type WP_PageCommentStatus = "open" | "closed";
|
|
11
|
+
/** Sort collection by page attribute. */
|
|
12
|
+
declare const WP_PAGE_ORDER_BYES: readonly ["author", "date", "id", "include", "modified", "parent", "relevance", "slug", "include_slugs", "title", "menu_order"];
|
|
13
|
+
type WP_PageOrderBy = (typeof WP_PAGE_ORDER_BYES)[number];
|
|
14
|
+
/** The globally unique identifier for the page. */
|
|
15
|
+
interface WP_PageGuid {
|
|
16
|
+
/** GUID for the page, transformed for display. */
|
|
17
|
+
rendered: string;
|
|
18
|
+
/** GUID for the page, as it exists in the database. */
|
|
19
|
+
raw: string;
|
|
20
|
+
}
|
|
21
|
+
/** The title for the page. */
|
|
22
|
+
interface WP_PageTitle {
|
|
23
|
+
/** HTML title for the page, transformed for display. */
|
|
24
|
+
rendered: string;
|
|
25
|
+
/** Title for the page, as it exists in the database. */
|
|
26
|
+
raw: string;
|
|
27
|
+
}
|
|
28
|
+
/** The content for the page. */
|
|
29
|
+
interface WP_PageContent {
|
|
30
|
+
/** HTML content for the page, transformed for display. */
|
|
31
|
+
rendered: string;
|
|
32
|
+
/** Content for the page, as it exists in the database. */
|
|
33
|
+
raw: string;
|
|
34
|
+
/** Version of the block format used in the page. */
|
|
35
|
+
block_version: number;
|
|
36
|
+
/** Whether the content is protected with a password. */
|
|
37
|
+
protected: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** The excerpt for the page. */
|
|
40
|
+
interface WP_PageExcerpt {
|
|
41
|
+
/** HTML excerpt for the page, transformed for display. */
|
|
42
|
+
rendered: string;
|
|
43
|
+
/** Excerpt for the page, as it exists in the database. */
|
|
44
|
+
raw: string;
|
|
45
|
+
/** Whether the excerpt is protected with a password. */
|
|
46
|
+
protected: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Hypermedia links for the page resource. */
|
|
49
|
+
interface WP_PageLinks {
|
|
50
|
+
self?: WP_Link[];
|
|
51
|
+
collection?: WP_Link[];
|
|
52
|
+
about?: WP_Link[];
|
|
53
|
+
author?: WP_Link[];
|
|
54
|
+
replies?: WP_Link[];
|
|
55
|
+
"version-history"?: WP_Link[];
|
|
56
|
+
"predecessor-version"?: WP_Link[];
|
|
57
|
+
up?: WP_Link[];
|
|
58
|
+
"wp:featuredmedia"?: WP_Link[];
|
|
59
|
+
"wp:attachment"?: WP_Link[];
|
|
60
|
+
curies?: WP_Link[];
|
|
61
|
+
[rel: string]: WP_Link[] | undefined;
|
|
62
|
+
}
|
|
63
|
+
interface WP_Page {
|
|
64
|
+
/** Unique identifier for the page. */
|
|
65
|
+
id: number;
|
|
66
|
+
/** The date the page was published, in the site's timezone. */
|
|
67
|
+
date: string | null;
|
|
68
|
+
/** The date the page was published, as GMT. */
|
|
69
|
+
date_gmt: string | null;
|
|
70
|
+
/** The globally unique identifier for the page. */
|
|
71
|
+
guid: WP_PageGuid;
|
|
72
|
+
/** The date the page was last modified, in the site's timezone. */
|
|
73
|
+
modified: string;
|
|
74
|
+
/** The date the page was last modified, as GMT. */
|
|
75
|
+
modified_gmt: string;
|
|
76
|
+
/** An alphanumeric identifier for the page unique to its type. */
|
|
77
|
+
slug: string;
|
|
78
|
+
/** A named status for the page. */
|
|
79
|
+
status: WP_PageStatus;
|
|
80
|
+
/** Type of post. */
|
|
81
|
+
type: string;
|
|
82
|
+
/** A password to protect access to the content and excerpt. */
|
|
83
|
+
password: string;
|
|
84
|
+
/** Permalink template for the page. */
|
|
85
|
+
permalink_template: string;
|
|
86
|
+
/** Slug automatically generated from the page title. */
|
|
87
|
+
generated_slug: string;
|
|
88
|
+
/** The ID for the parent of the page. */
|
|
89
|
+
parent: number;
|
|
90
|
+
/** URL to the page. */
|
|
91
|
+
link: string;
|
|
92
|
+
/** The title for the page. */
|
|
93
|
+
title: WP_PageTitle;
|
|
94
|
+
/** The content for the page. */
|
|
95
|
+
content: WP_PageContent;
|
|
96
|
+
/** The ID for the author of the page. */
|
|
97
|
+
author: number;
|
|
98
|
+
/** The excerpt for the page. */
|
|
99
|
+
excerpt: WP_PageExcerpt;
|
|
100
|
+
/** The ID of the featured media for the page. */
|
|
101
|
+
featured_media: number;
|
|
102
|
+
/** Whether or not comments are open on the page. */
|
|
103
|
+
comment_status: WP_PageCommentStatus;
|
|
104
|
+
/** Whether or not the page can be pinged. */
|
|
105
|
+
ping_status: WP_PageCommentStatus;
|
|
106
|
+
/** The order of the page in relation to other pages. */
|
|
107
|
+
menu_order: number;
|
|
108
|
+
/** Meta fields. */
|
|
109
|
+
meta: Record<string, unknown>;
|
|
110
|
+
/** The theme file to use to display the page. */
|
|
111
|
+
template: string;
|
|
112
|
+
/** Hypermedia links. */
|
|
113
|
+
_links?: WP_PageLinks;
|
|
114
|
+
}
|
|
115
|
+
interface WP_PageListInput {
|
|
116
|
+
/** Scope under which the request is made; determines fields present in response. */
|
|
117
|
+
context?: WP_Context;
|
|
118
|
+
/** Current page of the collection. */
|
|
119
|
+
page?: number;
|
|
120
|
+
/** Maximum number of items to be returned in result set. */
|
|
121
|
+
per_page?: number;
|
|
122
|
+
/** Limit results to those matching a string. */
|
|
123
|
+
search?: string;
|
|
124
|
+
/** Limit response to posts published after a given ISO8601 compliant date. */
|
|
125
|
+
after?: string;
|
|
126
|
+
/** Limit response to posts modified after a given ISO8601 compliant date. */
|
|
127
|
+
modified_after?: string;
|
|
128
|
+
/** Limit result set to posts assigned to specific authors. */
|
|
129
|
+
author?: number | number[];
|
|
130
|
+
/** Ensure result set excludes posts assigned to specific authors. */
|
|
131
|
+
author_exclude?: number | number[];
|
|
132
|
+
/** Limit response to posts published before a given ISO8601 compliant date. */
|
|
133
|
+
before?: string;
|
|
134
|
+
/** Limit response to posts modified before a given ISO8601 compliant date. */
|
|
135
|
+
modified_before?: string;
|
|
136
|
+
/** Ensure result set excludes specific IDs. */
|
|
137
|
+
exclude?: number | number[];
|
|
138
|
+
/** Limit result set to specific IDs. */
|
|
139
|
+
include?: number | number[];
|
|
140
|
+
/** Limit result set to posts with a specific menu_order value. */
|
|
141
|
+
menu_order?: number;
|
|
142
|
+
/** Offset the result set by a specific number of items. */
|
|
143
|
+
offset?: number;
|
|
144
|
+
/** Order sort attribute ascending or descending. */
|
|
145
|
+
order?: WP_ListOrder;
|
|
146
|
+
/** Sort collection by post attribute. */
|
|
147
|
+
orderby?: WP_PageOrderBy;
|
|
148
|
+
/** Limit result set to items with particular parent IDs. */
|
|
149
|
+
parent?: number | number[];
|
|
150
|
+
/** Limit result set to all items except those of a particular parent ID. */
|
|
151
|
+
parent_exclude?: number | number[];
|
|
152
|
+
/** Array of column names to be searched. */
|
|
153
|
+
search_columns?: string[];
|
|
154
|
+
/** Limit result set to posts with one or more specific slugs. */
|
|
155
|
+
slug?: string | string[];
|
|
156
|
+
/** Limit result set to posts assigned one or more statuses. */
|
|
157
|
+
status?: WP_PageStatusFilter | WP_PageStatusFilter[];
|
|
158
|
+
}
|
|
159
|
+
type WP_PageListErrorCode = "rest_no_search_term_defined" | "rest_orderby_include_missing_include" | "rest_post_invalid_page_number" | "rest_forbidden_context" | "rest_forbidden_status";
|
|
160
|
+
/** Title payload accepted when creating or updating a page. */
|
|
161
|
+
type WP_PageTitleInput = string | {
|
|
162
|
+
raw: string;
|
|
163
|
+
};
|
|
164
|
+
/** Content payload accepted when creating or updating a page. */
|
|
165
|
+
type WP_PageContentInput = string | {
|
|
166
|
+
raw: string;
|
|
167
|
+
};
|
|
168
|
+
/** Excerpt payload accepted when creating or updating a page. */
|
|
169
|
+
type WP_PageExcerptInput = string | {
|
|
170
|
+
raw: string;
|
|
171
|
+
};
|
|
172
|
+
interface WP_PageCreateInput {
|
|
173
|
+
/** The date the page was published, in the site's timezone. */
|
|
174
|
+
date?: string | null;
|
|
175
|
+
/** The date the page was published, as GMT. */
|
|
176
|
+
date_gmt?: string | null;
|
|
177
|
+
/** An alphanumeric identifier for the page unique to its type. */
|
|
178
|
+
slug?: string;
|
|
179
|
+
/** A named status for the page. */
|
|
180
|
+
status?: WP_PageStatus;
|
|
181
|
+
/** A password to protect access to the content and excerpt. */
|
|
182
|
+
password?: string;
|
|
183
|
+
/** The ID for the parent of the page. */
|
|
184
|
+
parent?: number;
|
|
185
|
+
/** The title for the page. */
|
|
186
|
+
title?: WP_PageTitleInput;
|
|
187
|
+
/** The content for the page. */
|
|
188
|
+
content?: WP_PageContentInput;
|
|
189
|
+
/** The ID for the author of the page. */
|
|
190
|
+
author?: number;
|
|
191
|
+
/** The excerpt for the page. */
|
|
192
|
+
excerpt?: WP_PageExcerptInput;
|
|
193
|
+
/** The ID of the featured media for the page. */
|
|
194
|
+
featured_media?: number;
|
|
195
|
+
/** Whether or not comments are open on the page. */
|
|
196
|
+
comment_status?: WP_PageCommentStatus;
|
|
197
|
+
/** Whether or not the page can be pinged. */
|
|
198
|
+
ping_status?: WP_PageCommentStatus;
|
|
199
|
+
/** The order of the page in relation to other pages. */
|
|
200
|
+
menu_order?: number;
|
|
201
|
+
/** Meta fields. */
|
|
202
|
+
meta?: Record<string, unknown>;
|
|
203
|
+
/** The theme file to use to display the page. */
|
|
204
|
+
template?: string;
|
|
205
|
+
}
|
|
206
|
+
type WP_PageCreateErrorCode = "rest_invalid_author" | "rest_invalid_featured_media" | "rest_post_exists" | "rest_post_invalid_id" | "rest_cannot_create" | "rest_cannot_edit_others" | "rest_cannot_publish";
|
|
207
|
+
interface WP_PageRetrieveInput {
|
|
208
|
+
/** Unique identifier for the page. */
|
|
209
|
+
id: number;
|
|
210
|
+
/** Scope under which the request is made; determines fields present in response. */
|
|
211
|
+
context?: WP_Context;
|
|
212
|
+
/** The password for the page if it is password protected. */
|
|
213
|
+
password?: string;
|
|
214
|
+
}
|
|
215
|
+
type WP_PageRetrieveErrorCode = "rest_forbidden_context" | "rest_post_incorrect_password" | "rest_post_invalid_id";
|
|
216
|
+
interface WP_PageUpdateInput {
|
|
217
|
+
/** Unique identifier for the page. */
|
|
218
|
+
id: number;
|
|
219
|
+
/** The date the page was published, in the site's timezone. */
|
|
220
|
+
date?: string | null;
|
|
221
|
+
/** The date the page was published, as GMT. */
|
|
222
|
+
date_gmt?: string | null;
|
|
223
|
+
/** An alphanumeric identifier for the page unique to its type. */
|
|
224
|
+
slug?: string;
|
|
225
|
+
/** A named status for the page. */
|
|
226
|
+
status?: WP_PageStatus;
|
|
227
|
+
/** A password to protect access to the content and excerpt. */
|
|
228
|
+
password?: string;
|
|
229
|
+
/** The ID for the parent of the page. */
|
|
230
|
+
parent?: number;
|
|
231
|
+
/** The title for the page. */
|
|
232
|
+
title?: WP_PageTitleInput;
|
|
233
|
+
/** The content for the page. */
|
|
234
|
+
content?: WP_PageContentInput;
|
|
235
|
+
/** The ID for the author of the page. */
|
|
236
|
+
author?: number;
|
|
237
|
+
/** The excerpt for the page. */
|
|
238
|
+
excerpt?: WP_PageExcerptInput;
|
|
239
|
+
/** The ID of the featured media for the page. */
|
|
240
|
+
featured_media?: number;
|
|
241
|
+
/** Whether or not comments are open on the page. */
|
|
242
|
+
comment_status?: WP_PageCommentStatus;
|
|
243
|
+
/** Whether or not the page can be pinged. */
|
|
244
|
+
ping_status?: WP_PageCommentStatus;
|
|
245
|
+
/** The order of the page in relation to other pages. */
|
|
246
|
+
menu_order?: number;
|
|
247
|
+
/** Meta fields. */
|
|
248
|
+
meta?: Record<string, unknown>;
|
|
249
|
+
/** The theme file to use to display the page. */
|
|
250
|
+
template?: string;
|
|
251
|
+
}
|
|
252
|
+
type WP_PageUpdateErrorCode = "rest_invalid_author" | "rest_invalid_featured_media" | "rest_post_invalid_id" | "rest_cannot_edit" | "rest_cannot_edit_others" | "rest_cannot_publish";
|
|
253
|
+
interface WP_PageDeleteInput {
|
|
254
|
+
/** Unique identifier for the page. */
|
|
255
|
+
id: number;
|
|
256
|
+
/** Whether to bypass Trash and force deletion. */
|
|
257
|
+
force?: boolean;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Response from `DELETE /wp/v2/pages/<id>`.
|
|
261
|
+
* - When `force=true`: returns `{ deleted: true, previous: WP_Page }`.
|
|
262
|
+
* - When `force=false` (trashed): returns the updated `WP_Page` with `status: "trash"`.
|
|
263
|
+
*/
|
|
264
|
+
type WP_PageDeleteResponse = WP_Page | {
|
|
265
|
+
deleted: true;
|
|
266
|
+
previous: WP_Page;
|
|
267
|
+
};
|
|
268
|
+
type WP_PageDeleteErrorCode = "rest_cannot_delete" | "rest_user_cannot_delete_post" | "rest_post_invalid_id" | "rest_already_trashed" | "rest_trash_not_supported";
|
|
269
|
+
//#endregion
|
|
270
|
+
export { WP_PAGE_ORDER_BYES, WP_PAGE_STATUSES, WP_Page, WP_PageCommentStatus, WP_PageContent, WP_PageContentInput, WP_PageCreateErrorCode, WP_PageCreateInput, WP_PageDeleteErrorCode, WP_PageDeleteInput, WP_PageDeleteResponse, WP_PageExcerpt, WP_PageExcerptInput, WP_PageGuid, WP_PageLinks, WP_PageListErrorCode, WP_PageListInput, WP_PageOrderBy, WP_PageRetrieveErrorCode, WP_PageRetrieveInput, WP_PageStatus, WP_PageStatusFilter, WP_PageTitle, WP_PageTitleInput, WP_PageUpdateErrorCode, WP_PageUpdateInput };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/wordpress/page/types.ts
|
|
2
|
+
/** A named status for the page. Used in responses and as the input on create/update. */
|
|
3
|
+
const WP_PAGE_STATUSES = [
|
|
4
|
+
"publish",
|
|
5
|
+
"future",
|
|
6
|
+
"draft",
|
|
7
|
+
"pending",
|
|
8
|
+
"private",
|
|
9
|
+
"trash"
|
|
10
|
+
];
|
|
11
|
+
/** Sort collection by page attribute. */
|
|
12
|
+
const WP_PAGE_ORDER_BYES = [
|
|
13
|
+
"author",
|
|
14
|
+
"date",
|
|
15
|
+
"id",
|
|
16
|
+
"include",
|
|
17
|
+
"modified",
|
|
18
|
+
"parent",
|
|
19
|
+
"relevance",
|
|
20
|
+
"slug",
|
|
21
|
+
"include_slugs",
|
|
22
|
+
"title",
|
|
23
|
+
"menu_order"
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { WP_PAGE_ORDER_BYES, WP_PAGE_STATUSES };
|
|
@@ -2,17 +2,21 @@ import { WP_Context, WP_Link, WP_ListOrder } from "../types.js";
|
|
|
2
2
|
|
|
3
3
|
//#region src/wordpress/post/types.d.ts
|
|
4
4
|
/** A named status for the post. Used in responses and as the input on create/update. */
|
|
5
|
-
|
|
5
|
+
declare const WP_POST_STATUSES: readonly ["publish", "future", "draft", "pending", "private", "trash"];
|
|
6
|
+
type WP_PostStatus = (typeof WP_POST_STATUSES)[number];
|
|
6
7
|
/** Status filter values accepted by `GET /wp/v2/posts`. Widens `WP_PostStatus` with WP-internal statuses and the `any` alias. */
|
|
7
8
|
type WP_PostStatusFilter = WP_PostStatus | "auto-draft" | "inherit" | "any";
|
|
8
9
|
/** Whether or not comments / pings are open on the post. */
|
|
9
10
|
type WP_PostCommentStatus = "open" | "closed";
|
|
10
11
|
/** The format for the post. */
|
|
11
|
-
|
|
12
|
+
declare const WP_POST_FORMATS: readonly ["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio"];
|
|
13
|
+
type WP_PostFormat = (typeof WP_POST_FORMATS)[number];
|
|
12
14
|
/** Sort collection by post attribute. */
|
|
13
|
-
|
|
15
|
+
declare const WP_POST_ORDER_BYES: readonly ["author", "date", "id", "include", "modified", "parent", "relevance", "slug", "include_slugs", "title"];
|
|
16
|
+
type WP_PostOrderBy = (typeof WP_POST_ORDER_BYES)[number];
|
|
14
17
|
/** Limit result set based on relationship between multiple taxonomies. */
|
|
15
|
-
|
|
18
|
+
declare const WP_POST_TAX_RELATIONS: readonly ["AND", "OR"];
|
|
19
|
+
type WP_PostTaxRelation = (typeof WP_POST_TAX_RELATIONS)[number];
|
|
16
20
|
/** The globally unique identifier for the post. */
|
|
17
21
|
interface WP_PostGuid {
|
|
18
22
|
/** GUID for the post, transformed for display. */
|
|
@@ -287,4 +291,4 @@ type WP_PostDeleteResponse = WP_Post | {
|
|
|
287
291
|
};
|
|
288
292
|
type WP_PostDeleteErrorCode = "rest_cannot_delete" | "rest_user_cannot_delete_post" | "rest_post_invalid_id" | "rest_already_trashed" | "rest_trash_not_supported";
|
|
289
293
|
//#endregion
|
|
290
|
-
export { WP_Post, WP_PostCommentStatus, WP_PostContent, WP_PostContentInput, WP_PostCreateErrorCode, WP_PostCreateInput, WP_PostDeleteErrorCode, WP_PostDeleteInput, WP_PostDeleteResponse, WP_PostExcerpt, WP_PostExcerptInput, WP_PostFormat, WP_PostGuid, WP_PostLinks, WP_PostListErrorCode, WP_PostListInput, WP_PostOrderBy, WP_PostRetrieveErrorCode, WP_PostRetrieveInput, WP_PostStatus, WP_PostStatusFilter, WP_PostTaxRelation, WP_PostTitle, WP_PostTitleInput, WP_PostUpdateErrorCode, WP_PostUpdateInput };
|
|
294
|
+
export { WP_POST_FORMATS, WP_POST_ORDER_BYES, WP_POST_STATUSES, WP_POST_TAX_RELATIONS, WP_Post, WP_PostCommentStatus, WP_PostContent, WP_PostContentInput, WP_PostCreateErrorCode, WP_PostCreateInput, WP_PostDeleteErrorCode, WP_PostDeleteInput, WP_PostDeleteResponse, WP_PostExcerpt, WP_PostExcerptInput, WP_PostFormat, WP_PostGuid, WP_PostLinks, WP_PostListErrorCode, WP_PostListInput, WP_PostOrderBy, WP_PostRetrieveErrorCode, WP_PostRetrieveInput, WP_PostStatus, WP_PostStatusFilter, WP_PostTaxRelation, WP_PostTitle, WP_PostTitleInput, WP_PostUpdateErrorCode, WP_PostUpdateInput };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/wordpress/post/types.ts
|
|
2
|
+
/** A named status for the post. Used in responses and as the input on create/update. */
|
|
3
|
+
const WP_POST_STATUSES = [
|
|
4
|
+
"publish",
|
|
5
|
+
"future",
|
|
6
|
+
"draft",
|
|
7
|
+
"pending",
|
|
8
|
+
"private",
|
|
9
|
+
"trash"
|
|
10
|
+
];
|
|
11
|
+
/** The format for the post. */
|
|
12
|
+
const WP_POST_FORMATS = [
|
|
13
|
+
"standard",
|
|
14
|
+
"aside",
|
|
15
|
+
"chat",
|
|
16
|
+
"gallery",
|
|
17
|
+
"link",
|
|
18
|
+
"image",
|
|
19
|
+
"quote",
|
|
20
|
+
"status",
|
|
21
|
+
"video",
|
|
22
|
+
"audio"
|
|
23
|
+
];
|
|
24
|
+
/** Sort collection by post attribute. */
|
|
25
|
+
const WP_POST_ORDER_BYES = [
|
|
26
|
+
"author",
|
|
27
|
+
"date",
|
|
28
|
+
"id",
|
|
29
|
+
"include",
|
|
30
|
+
"modified",
|
|
31
|
+
"parent",
|
|
32
|
+
"relevance",
|
|
33
|
+
"slug",
|
|
34
|
+
"include_slugs",
|
|
35
|
+
"title"
|
|
36
|
+
];
|
|
37
|
+
/** Limit result set based on relationship between multiple taxonomies. */
|
|
38
|
+
const WP_POST_TAX_RELATIONS = ["AND", "OR"];
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { WP_POST_FORMATS, WP_POST_ORDER_BYES, WP_POST_STATUSES, WP_POST_TAX_RELATIONS };
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { WP_List, WP_ListMetadata, WP_RequestInput, WP_Result, WordPressCredentials } from "./types.js";
|
|
2
|
+
import { CommentService } from "./comment/service.js";
|
|
2
3
|
import { MenuService } from "./menu/service.js";
|
|
4
|
+
import { PageService } from "./page/service.js";
|
|
3
5
|
import { PostService } from "./post/service.js";
|
|
6
|
+
import { TagService } from "./tag/service.js";
|
|
4
7
|
import { UserService } from "./user/service.js";
|
|
5
|
-
import {
|
|
8
|
+
import { CategoryService } from "./category/service.js";
|
|
6
9
|
import { Duration, SearchParamsLike } from "@kizlo/shared";
|
|
7
10
|
|
|
8
11
|
//#region src/wordpress/service.d.ts
|
|
9
12
|
declare class WordPressService {
|
|
10
13
|
readonly users: UserService;
|
|
11
14
|
readonly comments: CommentService;
|
|
15
|
+
readonly categories: CategoryService;
|
|
12
16
|
readonly posts: PostService;
|
|
17
|
+
readonly pages: PageService;
|
|
18
|
+
readonly tags: TagService;
|
|
13
19
|
readonly menus: MenuService;
|
|
14
20
|
private readonly siteBase;
|
|
15
21
|
private readonly authHeader;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { SAFE_REQUEST_TIMEOUT, UNEXPECTED_BODY_SNIPPET_LENGTH, WP_AUTH_HEADER_KEY, WP_AUTH_TYPE } from "./constants.js";
|
|
2
|
+
import { CategoryService } from "./category/service.js";
|
|
2
3
|
import { CommentService } from "./comment/service.js";
|
|
3
4
|
import { WP_Error } from "./error.js";
|
|
4
5
|
import { MenuService } from "./menu/service.js";
|
|
6
|
+
import { PageService } from "./page/service.js";
|
|
5
7
|
import { PostService } from "./post/service.js";
|
|
8
|
+
import { TagService } from "./tag/service.js";
|
|
6
9
|
import { UserService } from "./user/service.js";
|
|
7
10
|
import { isWordPressResourceError } from "./utils.js";
|
|
8
11
|
import { milliseconds, stringifyQueryString, trimLeadingTrailingSlashes, tryCatch, tryCatchSync } from "@kizlo/shared";
|
|
@@ -11,7 +14,10 @@ import { milliseconds, stringifyQueryString, trimLeadingTrailingSlashes, tryCatc
|
|
|
11
14
|
var WordPressService = class {
|
|
12
15
|
users = new UserService(this);
|
|
13
16
|
comments = new CommentService(this);
|
|
17
|
+
categories = new CategoryService(this);
|
|
14
18
|
posts = new PostService(this);
|
|
19
|
+
pages = new PageService(this);
|
|
20
|
+
tags = new TagService(this);
|
|
15
21
|
menus = new MenuService(this);
|
|
16
22
|
siteBase;
|
|
17
23
|
authHeader;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WP_Error } from "../error.js";
|
|
2
|
+
import { WP_List, WP_Result } from "../types.js";
|
|
3
|
+
import { WP_Tag, WP_TagCreateErrorCode, WP_TagCreateInput, WP_TagDeleteErrorCode, WP_TagDeleteInput, WP_TagDeleteResponse, WP_TagListErrorCode, WP_TagListInput, WP_TagRetrieveErrorCode, WP_TagRetrieveInput, WP_TagUpdateErrorCode, WP_TagUpdateInput } from "./types.js";
|
|
4
|
+
import { WordPressService } from "../service.js";
|
|
5
|
+
import "../index.js";
|
|
6
|
+
|
|
7
|
+
//#region src/wordpress/tag/service.d.ts
|
|
8
|
+
declare class TagService {
|
|
9
|
+
private readonly wordpress;
|
|
10
|
+
constructor(wordpress: WordPressService);
|
|
11
|
+
list(input: WP_TagListInput): Promise<{
|
|
12
|
+
data: null;
|
|
13
|
+
status: number;
|
|
14
|
+
headers: Headers;
|
|
15
|
+
error: WP_Error<WP_TagListErrorCode>;
|
|
16
|
+
} | {
|
|
17
|
+
data: WP_List<WP_Tag>;
|
|
18
|
+
status: number;
|
|
19
|
+
headers: Headers;
|
|
20
|
+
error: null;
|
|
21
|
+
}>;
|
|
22
|
+
create(input: WP_TagCreateInput): Promise<WP_Result<WP_Tag, WP_TagCreateErrorCode>>;
|
|
23
|
+
get(input: WP_TagRetrieveInput): Promise<WP_Result<WP_Tag, WP_TagRetrieveErrorCode>>;
|
|
24
|
+
update(input: WP_TagUpdateInput): Promise<WP_Result<WP_Tag, WP_TagUpdateErrorCode>>;
|
|
25
|
+
delete(input: WP_TagDeleteInput): Promise<WP_Result<WP_TagDeleteResponse, WP_TagDeleteErrorCode>>;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { TagService };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { WP_CORE_BASE } from "../constants.js";
|
|
2
|
+
|
|
3
|
+
//#region src/wordpress/tag/service.ts
|
|
4
|
+
var TagService = class {
|
|
5
|
+
wordpress;
|
|
6
|
+
constructor(wordpress) {
|
|
7
|
+
this.wordpress = wordpress;
|
|
8
|
+
}
|
|
9
|
+
async list(input) {
|
|
10
|
+
const { ...searchParams } = input;
|
|
11
|
+
const result = await this.wordpress.get("/tags", {
|
|
12
|
+
base: WP_CORE_BASE,
|
|
13
|
+
searchParams
|
|
14
|
+
});
|
|
15
|
+
if (result.error) return result;
|
|
16
|
+
return {
|
|
17
|
+
...result,
|
|
18
|
+
data: this.wordpress.resolveList({
|
|
19
|
+
data: result.data,
|
|
20
|
+
headers: result.headers,
|
|
21
|
+
searchParams
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async create(input) {
|
|
26
|
+
return this.wordpress.post("/tags", {
|
|
27
|
+
base: WP_CORE_BASE,
|
|
28
|
+
body: input
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async get(input) {
|
|
32
|
+
const { id,...searchParams } = input;
|
|
33
|
+
return this.wordpress.get(`/tags/${id}`, {
|
|
34
|
+
base: WP_CORE_BASE,
|
|
35
|
+
searchParams
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async update(input) {
|
|
39
|
+
const { id,...body } = input;
|
|
40
|
+
return this.wordpress.post(`/tags/${id}`, {
|
|
41
|
+
base: WP_CORE_BASE,
|
|
42
|
+
body
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async delete(input) {
|
|
46
|
+
const { id,...searchParams } = input;
|
|
47
|
+
return this.wordpress.delete(`/tags/${id}`, {
|
|
48
|
+
base: WP_CORE_BASE,
|
|
49
|
+
searchParams
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { TagService };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { WP_Context, WP_Link, WP_ListOrder } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/wordpress/tag/types.d.ts
|
|
4
|
+
/** Type attribution for the term. */
|
|
5
|
+
type WP_TagTaxonomy = "post_tag";
|
|
6
|
+
/** Sort collection by term attribute. */
|
|
7
|
+
declare const WP_TAG_ORDER_BYS: readonly ["id", "include", "name", "slug", "include_slugs", "term_group", "description", "count"];
|
|
8
|
+
type WP_TagOrderBy = (typeof WP_TAG_ORDER_BYS)[number];
|
|
9
|
+
/** Hypermedia links for the tag resource. */
|
|
10
|
+
interface WP_TagLinks {
|
|
11
|
+
self?: WP_Link[];
|
|
12
|
+
collection?: WP_Link[];
|
|
13
|
+
about?: WP_Link[];
|
|
14
|
+
"wp:post_type"?: WP_Link[];
|
|
15
|
+
curies?: WP_Link[];
|
|
16
|
+
[rel: string]: WP_Link[] | undefined;
|
|
17
|
+
}
|
|
18
|
+
interface WP_Tag {
|
|
19
|
+
/** Unique identifier for the term. */
|
|
20
|
+
id: number;
|
|
21
|
+
/** Number of published posts for the term. */
|
|
22
|
+
count: number;
|
|
23
|
+
/** HTML description of the term. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** URL of the term. */
|
|
26
|
+
link: string;
|
|
27
|
+
/** HTML title for the term. */
|
|
28
|
+
name: string;
|
|
29
|
+
/** An alphanumeric identifier for the term unique to its type. */
|
|
30
|
+
slug: string;
|
|
31
|
+
/** Type attribution for the term. */
|
|
32
|
+
taxonomy: WP_TagTaxonomy;
|
|
33
|
+
/** Meta fields. */
|
|
34
|
+
meta: Record<string, unknown>;
|
|
35
|
+
/** Hypermedia links. */
|
|
36
|
+
_links?: WP_TagLinks;
|
|
37
|
+
}
|
|
38
|
+
interface WP_TagListInput {
|
|
39
|
+
/** Scope under which the request is made; determines fields present in response. */
|
|
40
|
+
context?: WP_Context;
|
|
41
|
+
/** Current page of the collection. */
|
|
42
|
+
page?: number;
|
|
43
|
+
/** Maximum number of items to be returned in result set. */
|
|
44
|
+
per_page?: number;
|
|
45
|
+
/** Limit results to those matching a string. */
|
|
46
|
+
search?: string;
|
|
47
|
+
/** Ensure result set excludes specific IDs. */
|
|
48
|
+
exclude?: number | number[];
|
|
49
|
+
/** Limit result set to specific IDs. */
|
|
50
|
+
include?: number | number[];
|
|
51
|
+
/** Offset the result set by a specific number of items. */
|
|
52
|
+
offset?: number;
|
|
53
|
+
/** Order sort attribute ascending or descending. */
|
|
54
|
+
order?: WP_ListOrder;
|
|
55
|
+
/** Sort collection by term attribute. */
|
|
56
|
+
orderby?: WP_TagOrderBy;
|
|
57
|
+
/** Whether to hide terms not assigned to any posts. */
|
|
58
|
+
hide_empty?: boolean;
|
|
59
|
+
/** Limit result set to terms assigned to a specific post. */
|
|
60
|
+
post?: number;
|
|
61
|
+
/** Limit result set to terms with one or more specific slugs. */
|
|
62
|
+
slug?: string | string[];
|
|
63
|
+
}
|
|
64
|
+
type WP_TagListErrorCode = "rest_post_invalid_id" | "rest_forbidden_context";
|
|
65
|
+
interface WP_TagCreateInput {
|
|
66
|
+
/** HTML description of the term. */
|
|
67
|
+
description?: string;
|
|
68
|
+
/** HTML title for the term. */
|
|
69
|
+
name?: string;
|
|
70
|
+
/** An alphanumeric identifier for the term unique to its type. */
|
|
71
|
+
slug?: string;
|
|
72
|
+
/** Meta fields. */
|
|
73
|
+
meta?: Record<string, unknown>;
|
|
74
|
+
}
|
|
75
|
+
type WP_TagCreateErrorCode = "rest_taxonomy_not_hierarchical" | "rest_term_invalid" | "rest_cannot_create";
|
|
76
|
+
interface WP_TagRetrieveInput {
|
|
77
|
+
/** Unique identifier for the term. */
|
|
78
|
+
id: number;
|
|
79
|
+
/** Scope under which the request is made; determines fields present in response. */
|
|
80
|
+
context?: WP_Context;
|
|
81
|
+
}
|
|
82
|
+
type WP_TagRetrieveErrorCode = "rest_forbidden_context" | "rest_term_invalid";
|
|
83
|
+
interface WP_TagUpdateInput {
|
|
84
|
+
/** Unique identifier for the term. */
|
|
85
|
+
id: number;
|
|
86
|
+
/** HTML description of the term. */
|
|
87
|
+
description?: string;
|
|
88
|
+
/** HTML title for the term. */
|
|
89
|
+
name?: string;
|
|
90
|
+
/** An alphanumeric identifier for the term unique to its type. */
|
|
91
|
+
slug?: string;
|
|
92
|
+
/** Meta fields. */
|
|
93
|
+
meta?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
type WP_TagUpdateErrorCode = "rest_taxonomy_not_hierarchical" | "rest_term_invalid" | "rest_cannot_update";
|
|
96
|
+
interface WP_TagDeleteInput {
|
|
97
|
+
/** Unique identifier for the term. */
|
|
98
|
+
id: number;
|
|
99
|
+
/** Required to be true, as terms do not support trashing. */
|
|
100
|
+
force?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Response from `DELETE /wp/v2/tags/<id>`.
|
|
104
|
+
* Terms do not support trashing, so `force=true` is required and the response
|
|
105
|
+
* is always `{ deleted: true, previous: WP_Tag }`.
|
|
106
|
+
*/
|
|
107
|
+
type WP_TagDeleteResponse = {
|
|
108
|
+
deleted: true;
|
|
109
|
+
previous: WP_Tag;
|
|
110
|
+
};
|
|
111
|
+
type WP_TagDeleteErrorCode = "rest_cannot_delete" | "rest_term_invalid" | "rest_trash_not_supported";
|
|
112
|
+
//#endregion
|
|
113
|
+
export { WP_TAG_ORDER_BYS, WP_Tag, WP_TagCreateErrorCode, WP_TagCreateInput, WP_TagDeleteErrorCode, WP_TagDeleteInput, WP_TagDeleteResponse, WP_TagLinks, WP_TagListErrorCode, WP_TagListInput, WP_TagOrderBy, WP_TagRetrieveErrorCode, WP_TagRetrieveInput, WP_TagTaxonomy, WP_TagUpdateErrorCode, WP_TagUpdateInput };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/wordpress/tag/types.ts
|
|
2
|
+
/** Sort collection by term attribute. */
|
|
3
|
+
const WP_TAG_ORDER_BYS = [
|
|
4
|
+
"id",
|
|
5
|
+
"include",
|
|
6
|
+
"name",
|
|
7
|
+
"slug",
|
|
8
|
+
"include_slugs",
|
|
9
|
+
"term_group",
|
|
10
|
+
"description",
|
|
11
|
+
"count"
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { WP_TAG_ORDER_BYS };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kizlo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "A headless WordPress
|
|
5
|
+
"description": "A headless WordPress framework for TypeScript.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"wordpress",
|
|
8
8
|
"headless",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@clack/prompts": "^1.5.1",
|
|
79
|
-
"@kizlo/shared": "0.
|
|
79
|
+
"@kizlo/shared": "0.5.0",
|
|
80
80
|
"@orpc/client": "^1.14.3",
|
|
81
81
|
"@orpc/contract": "^1.14.3",
|
|
82
82
|
"@orpc/openapi": "^1.14.3",
|
|
@@ -86,7 +86,9 @@
|
|
|
86
86
|
"citty": "^0.1.6",
|
|
87
87
|
"consola": "^3.2.3",
|
|
88
88
|
"cookie": "^1.0.2",
|
|
89
|
+
"giget": "^3.0.0",
|
|
89
90
|
"jiti": "^2.7.0",
|
|
91
|
+
"magicast": "^0.5.3",
|
|
90
92
|
"zod": "^4.3.6"
|
|
91
93
|
},
|
|
92
94
|
"peerDependencies": {
|