kizlo 0.1.0
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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/adapters/auth.d.ts +18 -0
- package/dist/adapters/auth.js +15 -0
- package/dist/adapters/captcha.d.ts +28 -0
- package/dist/adapters/captcha.js +86 -0
- package/dist/adapters/geo.d.ts +18 -0
- package/dist/adapters/geo.js +18 -0
- package/dist/adapters/geo.vercel.d.ts +6 -0
- package/dist/adapters/geo.vercel.js +41 -0
- package/dist/adapters/logger.d.ts +31 -0
- package/dist/adapters/logger.js +30 -0
- package/dist/cli/banner.js +26 -0
- package/dist/cli/commands/generate.js +34 -0
- package/dist/cli/commands/init.js +313 -0
- package/dist/cli/commands/test.js +68 -0
- package/dist/cli/commands/watch.js +53 -0
- package/dist/cli/commands/wp.js +66 -0
- package/dist/cli/daemon/config.js +87 -0
- package/dist/cli/daemon/generate.js +40 -0
- package/dist/cli/daemon/lock.js +31 -0
- package/dist/cli/daemon/logger.js +8 -0
- package/dist/cli/daemon/watch.js +37 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +22 -0
- package/dist/cli/presets/base.js +23 -0
- package/dist/cli/presets/index.js +16 -0
- package/dist/cli/presets/nextjs.js +39 -0
- package/dist/cli/utils.js +182 -0
- package/dist/cli/wp/bootstrap.js +114 -0
- package/dist/cli/wp/compose/docker-compose.yml +73 -0
- package/dist/cli/wp/constants.js +52 -0
- package/dist/cli/wp/docker.d.ts +24 -0
- package/dist/cli/wp/docker.js +69 -0
- package/dist/cli/wp/setup.js +39 -0
- package/dist/cli/wp/types.d.ts +72 -0
- package/dist/cli/wp/types.js +8 -0
- package/dist/cli/wp/utils.d.ts +39 -0
- package/dist/cli/wp/utils.js +105 -0
- package/dist/client.d.ts +24 -0
- package/dist/client.js +55 -0
- package/dist/comment/errors.js +47 -0
- package/dist/comment/index.js +138 -0
- package/dist/comment/schema.js +72 -0
- package/dist/comment/utils.js +35 -0
- package/dist/config.d.ts +39 -0
- package/dist/config.js +7 -0
- package/dist/context.d.ts +73 -0
- package/dist/context.js +145 -0
- package/dist/cookie.d.ts +19 -0
- package/dist/cookie.js +25 -0
- package/dist/email/service.d.ts +11 -0
- package/dist/email/service.interface.d.ts +8 -0
- package/dist/email/service.js +20 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +31 -0
- package/dist/integrations/nextjs/kizlo.client.d.ts +10 -0
- package/dist/integrations/nextjs/kizlo.client.js +13 -0
- package/dist/integrations/nextjs/kizlo.server.d.ts +12 -0
- package/dist/integrations/nextjs/kizlo.server.js +13 -0
- package/dist/integrations/nextjs/utils.js +11 -0
- package/dist/kizlo.d.ts +73 -0
- package/dist/kizlo.js +144 -0
- package/dist/menu/errors.js +16 -0
- package/dist/menu/fixture.d.ts +8 -0
- package/dist/menu/fixture.js +62 -0
- package/dist/menu/index.js +70 -0
- package/dist/menu/schema.js +70 -0
- package/dist/menu/utils.js +57 -0
- package/dist/nextjs/server.d.ts +2 -0
- package/dist/nextjs/server.js +3 -0
- package/dist/nextjs.d.ts +2 -0
- package/dist/nextjs.js +3 -0
- package/dist/package.js +5 -0
- package/dist/post/error.js +30 -0
- package/dist/post/fixture.d.ts +8 -0
- package/dist/post/fixture.js +71 -0
- package/dist/post/index.js +123 -0
- package/dist/post/schema.js +120 -0
- package/dist/post/utils.js +42 -0
- package/dist/post-type/service.js +48 -0
- package/dist/router.d.ts +624 -0
- package/dist/router.js +15 -0
- package/dist/seo/index.js +54 -0
- package/dist/seo/schema.d.ts +196 -0
- package/dist/seo/schema.js +96 -0
- package/dist/seo/types.d.ts +80 -0
- package/dist/seo/utils.js +44 -0
- package/dist/service.d.ts +17 -0
- package/dist/service.js +17 -0
- package/dist/shared/constants.js +10 -0
- package/dist/shared/contract.d.ts +21 -0
- package/dist/shared/contract.js +43 -0
- package/dist/shared/crypto.d.ts +28 -0
- package/dist/shared/crypto.js +34 -0
- package/dist/shared/error.d.ts +128 -0
- package/dist/shared/error.js +147 -0
- package/dist/shared/extension.d.ts +25 -0
- package/dist/shared/extension.js +7 -0
- package/dist/shared/identifier.d.ts +11 -0
- package/dist/shared/identifier.js +26 -0
- package/dist/shared/middleware.d.ts +29 -0
- package/dist/shared/procedure.d.ts +114 -0
- package/dist/shared/procedure.js +114 -0
- package/dist/shared/result.d.ts +24 -0
- package/dist/shared/result.js +49 -0
- package/dist/shared/router.d.ts +7 -0
- package/dist/shared/router.js +26 -0
- package/dist/shared/schema.d.ts +55 -0
- package/dist/shared/schema.js +43 -0
- package/dist/shared/serialize.d.ts +12 -0
- package/dist/shared/serialize.js +51 -0
- package/dist/shared/types.d.ts +35 -0
- package/dist/shared/utils.js +17 -0
- package/dist/test/auth.d.ts +7 -0
- package/dist/test/auth.js +15 -0
- package/dist/test/captcha.d.ts +7 -0
- package/dist/test/captcha.js +8 -0
- package/dist/test/client.d.ts +11 -0
- package/dist/test/client.js +14 -0
- package/dist/test/fixtures.d.ts +14 -0
- package/dist/test/fixtures.js +13 -0
- package/dist/test/server.d.ts +10 -0
- package/dist/test/server.js +32 -0
- package/dist/test/users.d.ts +14 -0
- package/dist/test/users.js +17 -0
- package/dist/test.d.ts +12 -0
- package/dist/test.js +13 -0
- package/dist/webhook/index.d.ts +38 -0
- package/dist/webhook/index.js +44 -0
- package/dist/webhook/schema.d.ts +45 -0
- package/dist/webhook/schema.js +72 -0
- package/dist/webhook/utils.js +21 -0
- package/dist/wordpress/comment/service.d.ts +28 -0
- package/dist/wordpress/comment/service.js +55 -0
- package/dist/wordpress/comment/types.d.ts +206 -0
- package/dist/wordpress/constants.d.ts +14 -0
- package/dist/wordpress/constants.js +13 -0
- package/dist/wordpress/error.d.ts +9 -0
- package/dist/wordpress/error.js +12 -0
- package/dist/wordpress/index.d.ts +15 -0
- package/dist/wordpress/menu/items/service.d.ts +28 -0
- package/dist/wordpress/menu/items/service.js +55 -0
- package/dist/wordpress/menu/items/types.d.ts +214 -0
- package/dist/wordpress/menu/service.d.ts +30 -0
- package/dist/wordpress/menu/service.js +58 -0
- package/dist/wordpress/menu/types.d.ts +115 -0
- package/dist/wordpress/post/service.d.ts +28 -0
- package/dist/wordpress/post/service.js +55 -0
- package/dist/wordpress/post/types.d.ts +290 -0
- package/dist/wordpress/service.d.ts +77 -0
- package/dist/wordpress/service.js +180 -0
- package/dist/wordpress/types.d.ts +67 -0
- package/dist/wordpress/user/service.d.ts +28 -0
- package/dist/wordpress/user/service.js +55 -0
- package/dist/wordpress/user/types.d.ts +221 -0
- package/dist/wordpress/utils.d.ts +7 -0
- package/dist/wordpress/utils.js +9 -0
- package/package.json +109 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { WP_Context, WP_Link, WP_ListOrder } from "../../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/wordpress/menu/items/types.d.ts
|
|
4
|
+
/** The family of objects originally represented, such as 'post_type' or 'taxonomy'. */
|
|
5
|
+
type WP_MenuItemType = "taxonomy" | "post_type" | "post_type_archive" | "custom";
|
|
6
|
+
/** A named status for the object. Used in responses and as the input on create/update. */
|
|
7
|
+
type WP_MenuItemStatus = "publish" | "future" | "draft" | "pending" | "private" | "trash";
|
|
8
|
+
/** Status filter values accepted by `GET /wp/v2/menu-items`. Inherits the posts controller's filter enum, widening `WP_MenuItemStatus` with internal statuses and the `any` alias. */
|
|
9
|
+
type WP_MenuItemStatusFilter = WP_MenuItemStatus | "auto-draft" | "inherit" | "any";
|
|
10
|
+
/** The target attribute of the link element for this menu item. */
|
|
11
|
+
type WP_MenuItemTarget = "_blank" | "";
|
|
12
|
+
/** Sort collection by object attribute. */
|
|
13
|
+
type WP_MenuItemOrderBy = "author" | "date" | "id" | "include" | "modified" | "parent" | "relevance" | "slug" | "include_slugs" | "title" | "menu_order";
|
|
14
|
+
/** Limit result set based on relationship between multiple taxonomies. */
|
|
15
|
+
type WP_MenuItemTaxRelation = "AND" | "OR";
|
|
16
|
+
/** The title for the menu item. */
|
|
17
|
+
interface WP_MenuItemTitle {
|
|
18
|
+
/** HTML title for the object, transformed for display. */
|
|
19
|
+
rendered: string;
|
|
20
|
+
/** Title for the object, as it exists in the database. */
|
|
21
|
+
raw: string;
|
|
22
|
+
}
|
|
23
|
+
/** Title input for create/update — WP accepts a plain string or `{ raw }`. */
|
|
24
|
+
type WP_MenuItemTitleInput = string | {
|
|
25
|
+
raw: string;
|
|
26
|
+
};
|
|
27
|
+
/** Hypermedia links for the menu item resource. */
|
|
28
|
+
interface WP_MenuItemLinks {
|
|
29
|
+
self?: WP_Link[];
|
|
30
|
+
collection?: WP_Link[];
|
|
31
|
+
about?: WP_Link[];
|
|
32
|
+
"version-history"?: WP_Link[];
|
|
33
|
+
"predecessor-version"?: WP_Link[];
|
|
34
|
+
"wp:attachment"?: WP_Link[];
|
|
35
|
+
"wp:term"?: WP_Link[];
|
|
36
|
+
"wp:object"?: WP_Link[];
|
|
37
|
+
curies?: WP_Link[];
|
|
38
|
+
[rel: string]: WP_Link[] | undefined;
|
|
39
|
+
}
|
|
40
|
+
interface WP_MenuItem {
|
|
41
|
+
/** The title for the object. */
|
|
42
|
+
title: WP_MenuItemTitle;
|
|
43
|
+
/** Unique identifier for the object. */
|
|
44
|
+
id: number;
|
|
45
|
+
/** The singular label used to describe this type of menu item. */
|
|
46
|
+
type_label: string;
|
|
47
|
+
/** The family of objects originally represented, such as 'post_type' or 'taxonomy'. */
|
|
48
|
+
type: WP_MenuItemType;
|
|
49
|
+
/** A named status for the object. */
|
|
50
|
+
status: WP_MenuItemStatus;
|
|
51
|
+
/** The ID for the parent of the object. */
|
|
52
|
+
parent: number;
|
|
53
|
+
/** Text for the title attribute of the link element for this menu item. */
|
|
54
|
+
attr_title: string;
|
|
55
|
+
/** Class names for the link element of this menu item. */
|
|
56
|
+
classes: string[];
|
|
57
|
+
/** The description of this menu item. */
|
|
58
|
+
description: string;
|
|
59
|
+
/** The DB ID of the nav_menu_item that is this item's menu parent, if any, otherwise 0. */
|
|
60
|
+
menu_order: number;
|
|
61
|
+
/** The type of object originally represented, such as 'category', 'post', or 'attachment'. */
|
|
62
|
+
object: string;
|
|
63
|
+
/** The database ID of the original object this menu item represents, for example the ID for posts or the term_id for categories. */
|
|
64
|
+
object_id: number;
|
|
65
|
+
/** The target attribute of the link element for this menu item. */
|
|
66
|
+
target: WP_MenuItemTarget;
|
|
67
|
+
/** The URL to which this menu item points. */
|
|
68
|
+
url: string;
|
|
69
|
+
/** The XFN relationship expressed in the link of this menu item. */
|
|
70
|
+
xfn: string[];
|
|
71
|
+
/** Whether the menu item represents an object that no longer exists. */
|
|
72
|
+
invalid: boolean;
|
|
73
|
+
/** The terms assigned to the object in the nav_menu taxonomy. */
|
|
74
|
+
menus: number;
|
|
75
|
+
/** Meta fields. */
|
|
76
|
+
meta: Record<string, unknown>;
|
|
77
|
+
/** Hypermedia links. */
|
|
78
|
+
_links?: WP_MenuItemLinks;
|
|
79
|
+
}
|
|
80
|
+
interface WP_MenuItemListInput {
|
|
81
|
+
/** Scope under which the request is made; determines fields present in response. */
|
|
82
|
+
context?: WP_Context;
|
|
83
|
+
/** Current page of the collection. */
|
|
84
|
+
page?: number;
|
|
85
|
+
/** Maximum number of items to be returned in result set. */
|
|
86
|
+
per_page?: number;
|
|
87
|
+
/** Limit results to those matching a string. */
|
|
88
|
+
search?: string;
|
|
89
|
+
/** Limit response to posts published after a given ISO8601 compliant date. */
|
|
90
|
+
after?: string;
|
|
91
|
+
/** Limit response to posts modified after a given ISO8601 compliant date. */
|
|
92
|
+
modified_after?: string;
|
|
93
|
+
/** Limit response to posts published before a given ISO8601 compliant date. */
|
|
94
|
+
before?: string;
|
|
95
|
+
/** Limit response to posts modified before a given ISO8601 compliant date. */
|
|
96
|
+
modified_before?: string;
|
|
97
|
+
/** Ensure result set excludes specific IDs. */
|
|
98
|
+
exclude?: number | number[];
|
|
99
|
+
/** Limit result set to specific IDs. */
|
|
100
|
+
include?: number | number[];
|
|
101
|
+
/** Offset the result set by a specific number of items. */
|
|
102
|
+
offset?: number;
|
|
103
|
+
/** Order sort attribute ascending or descending. */
|
|
104
|
+
order?: WP_ListOrder;
|
|
105
|
+
/** Sort collection by object attribute. */
|
|
106
|
+
orderby?: WP_MenuItemOrderBy;
|
|
107
|
+
/** Array of column names to be searched. */
|
|
108
|
+
search_columns?: string[];
|
|
109
|
+
/** Limit result set to posts with one or more specific slugs. */
|
|
110
|
+
slug?: string | string[];
|
|
111
|
+
/** Limit result set to posts assigned one or more statuses. */
|
|
112
|
+
status?: WP_MenuItemStatusFilter | WP_MenuItemStatusFilter[];
|
|
113
|
+
/** Limit result set based on relationship between multiple taxonomies. */
|
|
114
|
+
tax_relation?: WP_MenuItemTaxRelation;
|
|
115
|
+
/** Limit result set to items with specific terms assigned in the menus taxonomy. */
|
|
116
|
+
menus?: number | number[];
|
|
117
|
+
/** Limit result set to items except those with specific terms assigned in the menus taxonomy. */
|
|
118
|
+
menus_exclude?: number | number[];
|
|
119
|
+
/** Limit result set to posts with a specific menu_order value. */
|
|
120
|
+
menu_order?: number;
|
|
121
|
+
}
|
|
122
|
+
type WP_MenuItemListErrorCode = "rest_no_search_term_defined" | "rest_orderby_include_missing_include" | "rest_post_invalid_page_number" | "rest_cannot_view" | "rest_forbidden_context";
|
|
123
|
+
interface WP_MenuItemCreateInput {
|
|
124
|
+
/** The title for the object. */
|
|
125
|
+
title?: WP_MenuItemTitleInput;
|
|
126
|
+
/** The family of objects originally represented, such as 'post_type' or 'taxonomy'. */
|
|
127
|
+
type?: WP_MenuItemType;
|
|
128
|
+
/** A named status for the object. */
|
|
129
|
+
status?: WP_MenuItemStatus;
|
|
130
|
+
/** The ID for the parent of the object. */
|
|
131
|
+
parent?: number;
|
|
132
|
+
/** Text for the title attribute of the link element for this menu item. */
|
|
133
|
+
attr_title?: string;
|
|
134
|
+
/** Class names for the link element of this menu item. */
|
|
135
|
+
classes?: string[];
|
|
136
|
+
/** The description of this menu item. */
|
|
137
|
+
description?: string;
|
|
138
|
+
/** The DB ID of the nav_menu_item that is this item's menu parent, if any, otherwise 0. */
|
|
139
|
+
menu_order?: number;
|
|
140
|
+
/** The type of object originally represented, such as 'category', 'post', or 'attachment'. */
|
|
141
|
+
object?: string;
|
|
142
|
+
/** The database ID of the original object this menu item represents, for example the ID for posts or the term_id for categories. */
|
|
143
|
+
object_id?: number;
|
|
144
|
+
/** The target attribute of the link element for this menu item. */
|
|
145
|
+
target?: WP_MenuItemTarget;
|
|
146
|
+
/** The URL to which this menu item points. */
|
|
147
|
+
url?: string;
|
|
148
|
+
/** The XFN relationship expressed in the link of this menu item. */
|
|
149
|
+
xfn?: string[];
|
|
150
|
+
/** The terms assigned to the object in the nav_menu taxonomy. */
|
|
151
|
+
menus?: number;
|
|
152
|
+
/** Meta fields. */
|
|
153
|
+
meta?: Record<string, unknown>;
|
|
154
|
+
}
|
|
155
|
+
type WP_MenuItemCreateErrorCode = "rest_invalid_author" | "rest_invalid_field" | "rest_post_exists" | "rest_post_invalid_id" | "rest_post_invalid_type" | "rest_term_invalid_id" | "rest_title_required" | "rest_url_required" | "rest_cannot_assign_sticky" | "rest_cannot_assign_term" | "rest_cannot_create" | "rest_cannot_edit_others" | "rest_cannot_publish" | "rest_forbidden_status" | "db_insert_error";
|
|
156
|
+
interface WP_MenuItemRetrieveInput {
|
|
157
|
+
/** Unique identifier for the post. */
|
|
158
|
+
id: number;
|
|
159
|
+
/** Scope under which the request is made; determines fields present in response. */
|
|
160
|
+
context?: WP_Context;
|
|
161
|
+
}
|
|
162
|
+
type WP_MenuItemRetrieveErrorCode = "rest_cannot_view" | "rest_forbidden_context" | "rest_post_incorrect_password" | "rest_post_invalid_id";
|
|
163
|
+
interface WP_MenuItemUpdateInput {
|
|
164
|
+
/** Unique identifier for the post. */
|
|
165
|
+
id: number;
|
|
166
|
+
/** The title for the object. */
|
|
167
|
+
title?: WP_MenuItemTitleInput;
|
|
168
|
+
/** The family of objects originally represented, such as 'post_type' or 'taxonomy'. */
|
|
169
|
+
type?: WP_MenuItemType;
|
|
170
|
+
/** A named status for the object. */
|
|
171
|
+
status?: WP_MenuItemStatus;
|
|
172
|
+
/** The ID for the parent of the object. */
|
|
173
|
+
parent?: number;
|
|
174
|
+
/** Text for the title attribute of the link element for this menu item. */
|
|
175
|
+
attr_title?: string;
|
|
176
|
+
/** Class names for the link element of this menu item. */
|
|
177
|
+
classes?: string[];
|
|
178
|
+
/** The description of this menu item. */
|
|
179
|
+
description?: string;
|
|
180
|
+
/** The DB ID of the nav_menu_item that is this item's menu parent, if any, otherwise 0. */
|
|
181
|
+
menu_order?: number;
|
|
182
|
+
/** The type of object originally represented, such as 'category', 'post', or 'attachment'. */
|
|
183
|
+
object?: string;
|
|
184
|
+
/** The database ID of the original object this menu item represents, for example the ID for posts or the term_id for categories. */
|
|
185
|
+
object_id?: number;
|
|
186
|
+
/** The target attribute of the link element for this menu item. */
|
|
187
|
+
target?: WP_MenuItemTarget;
|
|
188
|
+
/** The URL to which this menu item points. */
|
|
189
|
+
url?: string;
|
|
190
|
+
/** The XFN relationship expressed in the link of this menu item. */
|
|
191
|
+
xfn?: string[];
|
|
192
|
+
/** The terms assigned to the object in the nav_menu taxonomy. */
|
|
193
|
+
menus?: number;
|
|
194
|
+
/** Meta fields. */
|
|
195
|
+
meta?: Record<string, unknown>;
|
|
196
|
+
}
|
|
197
|
+
type WP_MenuItemUpdateErrorCode = "rest_invalid_author" | "rest_invalid_field" | "rest_post_invalid_id" | "rest_post_invalid_type" | "rest_term_invalid_id" | "rest_title_required" | "rest_url_required" | "rest_cannot_assign_sticky" | "rest_cannot_assign_term" | "rest_cannot_edit" | "rest_cannot_edit_others" | "rest_cannot_publish" | "rest_forbidden_status" | "db_update_error";
|
|
198
|
+
interface WP_MenuItemDeleteInput {
|
|
199
|
+
/** Unique identifier for the post. */
|
|
200
|
+
id: number;
|
|
201
|
+
/** Whether to bypass Trash and force deletion. */
|
|
202
|
+
force?: boolean;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Response from `DELETE /wp/v2/menu-items/<id>`.
|
|
206
|
+
* Menu items do not support trashing — `force=true` is required, so the response is always `{ deleted: true, previous: WP_MenuItem }`.
|
|
207
|
+
*/
|
|
208
|
+
type WP_MenuItemDeleteResponse = {
|
|
209
|
+
deleted: true;
|
|
210
|
+
previous: WP_MenuItem;
|
|
211
|
+
};
|
|
212
|
+
type WP_MenuItemDeleteErrorCode = "rest_cannot_delete" | "rest_user_cannot_delete_post" | "rest_post_invalid_id" | "rest_already_trashed" | "rest_trash_not_supported";
|
|
213
|
+
//#endregion
|
|
214
|
+
export { WP_MenuItem, WP_MenuItemCreateErrorCode, WP_MenuItemCreateInput, WP_MenuItemDeleteErrorCode, WP_MenuItemDeleteInput, WP_MenuItemDeleteResponse, WP_MenuItemLinks, WP_MenuItemListErrorCode, WP_MenuItemListInput, WP_MenuItemOrderBy, WP_MenuItemRetrieveErrorCode, WP_MenuItemRetrieveInput, WP_MenuItemStatus, WP_MenuItemStatusFilter, WP_MenuItemTarget, WP_MenuItemTaxRelation, WP_MenuItemTitle, WP_MenuItemTitleInput, WP_MenuItemType, WP_MenuItemUpdateErrorCode, WP_MenuItemUpdateInput };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WP_Error } from "../error.js";
|
|
2
|
+
import { WP_List, WP_Result } from "../types.js";
|
|
3
|
+
import { MenuItemService } from "./items/service.js";
|
|
4
|
+
import { WP_Menu, WP_MenuCreateErrorCode, WP_MenuCreateInput, WP_MenuDeleteErrorCode, WP_MenuDeleteInput, WP_MenuDeleteResponse, WP_MenuListErrorCode, WP_MenuListInput, WP_MenuRetrieveErrorCode, WP_MenuRetrieveInput, WP_MenuUpdateErrorCode, WP_MenuUpdateInput } from "./types.js";
|
|
5
|
+
import { WordPressService } from "../service.js";
|
|
6
|
+
import "../index.js";
|
|
7
|
+
|
|
8
|
+
//#region src/wordpress/menu/service.d.ts
|
|
9
|
+
declare class MenuService {
|
|
10
|
+
readonly items: MenuItemService;
|
|
11
|
+
private readonly wordpress;
|
|
12
|
+
constructor(wordpress: WordPressService);
|
|
13
|
+
list(input: WP_MenuListInput): Promise<{
|
|
14
|
+
data: null;
|
|
15
|
+
status: number;
|
|
16
|
+
headers: Headers;
|
|
17
|
+
error: WP_Error<WP_MenuListErrorCode>;
|
|
18
|
+
} | {
|
|
19
|
+
data: WP_List<WP_Menu>;
|
|
20
|
+
status: number;
|
|
21
|
+
headers: Headers;
|
|
22
|
+
error: null;
|
|
23
|
+
}>;
|
|
24
|
+
create(input: WP_MenuCreateInput): Promise<WP_Result<WP_Menu, WP_MenuCreateErrorCode>>;
|
|
25
|
+
get(input: WP_MenuRetrieveInput): Promise<WP_Result<WP_Menu, WP_MenuRetrieveErrorCode>>;
|
|
26
|
+
update(input: WP_MenuUpdateInput): Promise<WP_Result<WP_Menu, WP_MenuUpdateErrorCode>>;
|
|
27
|
+
delete(input: WP_MenuDeleteInput): Promise<WP_Result<WP_MenuDeleteResponse, WP_MenuDeleteErrorCode>>;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { MenuService };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { WP_CORE_BASE } from "../constants.js";
|
|
2
|
+
import { MenuItemService } from "./items/service.js";
|
|
3
|
+
|
|
4
|
+
//#region src/wordpress/menu/service.ts
|
|
5
|
+
var MenuService = class {
|
|
6
|
+
items;
|
|
7
|
+
wordpress;
|
|
8
|
+
constructor(wordpress) {
|
|
9
|
+
this.wordpress = wordpress;
|
|
10
|
+
this.items = new MenuItemService(wordpress);
|
|
11
|
+
}
|
|
12
|
+
async list(input) {
|
|
13
|
+
const { ...searchParams } = input;
|
|
14
|
+
const result = await this.wordpress.get("/menus", {
|
|
15
|
+
base: WP_CORE_BASE,
|
|
16
|
+
searchParams
|
|
17
|
+
});
|
|
18
|
+
if (result.error) return result;
|
|
19
|
+
return {
|
|
20
|
+
...result,
|
|
21
|
+
data: this.wordpress.resolveList({
|
|
22
|
+
data: result.data,
|
|
23
|
+
headers: result.headers,
|
|
24
|
+
searchParams
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async create(input) {
|
|
29
|
+
return this.wordpress.post("/menus", {
|
|
30
|
+
base: WP_CORE_BASE,
|
|
31
|
+
body: input
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async get(input) {
|
|
35
|
+
const { id,...searchParams } = input;
|
|
36
|
+
return this.wordpress.get(`/menus/${id}`, {
|
|
37
|
+
base: WP_CORE_BASE,
|
|
38
|
+
searchParams
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async update(input) {
|
|
42
|
+
const { id,...body } = input;
|
|
43
|
+
return this.wordpress.post(`/menus/${id}`, {
|
|
44
|
+
base: WP_CORE_BASE,
|
|
45
|
+
body
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async delete(input) {
|
|
49
|
+
const { id,...searchParams } = input;
|
|
50
|
+
return this.wordpress.delete(`/menus/${id}`, {
|
|
51
|
+
base: WP_CORE_BASE,
|
|
52
|
+
searchParams
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { MenuService };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { WP_Context, WP_Link, WP_ListOrder } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/wordpress/menu/types.d.ts
|
|
4
|
+
/** Sort collection by term attribute. */
|
|
5
|
+
type WP_MenuOrderBy = "id" | "include" | "name" | "slug" | "include_slugs" | "term_group" | "description" | "count";
|
|
6
|
+
/** Hypermedia links for the menu resource. */
|
|
7
|
+
interface WP_MenuLinks {
|
|
8
|
+
self?: WP_Link[];
|
|
9
|
+
collection?: WP_Link[];
|
|
10
|
+
about?: WP_Link[];
|
|
11
|
+
"wp:post_type"?: WP_Link[];
|
|
12
|
+
curies?: WP_Link[];
|
|
13
|
+
[rel: string]: WP_Link[] | undefined;
|
|
14
|
+
}
|
|
15
|
+
interface WP_Menu {
|
|
16
|
+
/** Unique identifier for the term. */
|
|
17
|
+
id: number;
|
|
18
|
+
/** HTML description of the term. */
|
|
19
|
+
description: string;
|
|
20
|
+
/** HTML title for the term. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** An alphanumeric identifier for the term unique to its type. */
|
|
23
|
+
slug: string;
|
|
24
|
+
/** Meta fields. */
|
|
25
|
+
meta: Record<string, unknown>;
|
|
26
|
+
/** The locations assigned to the menu. */
|
|
27
|
+
locations: string[];
|
|
28
|
+
/** Whether to automatically add top level pages to this menu. */
|
|
29
|
+
auto_add: boolean;
|
|
30
|
+
/** Hypermedia links. */
|
|
31
|
+
_links?: WP_MenuLinks;
|
|
32
|
+
}
|
|
33
|
+
interface WP_MenuListInput {
|
|
34
|
+
/** Scope under which the request is made; determines fields present in response. */
|
|
35
|
+
context?: WP_Context;
|
|
36
|
+
/** Current page of the collection. */
|
|
37
|
+
page?: number;
|
|
38
|
+
/** Maximum number of items to be returned in result set. */
|
|
39
|
+
per_page?: number;
|
|
40
|
+
/** Limit results to those matching a string. */
|
|
41
|
+
search?: string;
|
|
42
|
+
/** Ensure result set excludes specific IDs. */
|
|
43
|
+
exclude?: number | number[];
|
|
44
|
+
/** Limit result set to specific IDs. */
|
|
45
|
+
include?: number | number[];
|
|
46
|
+
/** Offset the result set by a specific number of items. */
|
|
47
|
+
offset?: number;
|
|
48
|
+
/** Order sort attribute ascending or descending. */
|
|
49
|
+
order?: WP_ListOrder;
|
|
50
|
+
/** Sort collection by term attribute. */
|
|
51
|
+
orderby?: WP_MenuOrderBy;
|
|
52
|
+
/** Whether to hide terms not assigned to any posts. */
|
|
53
|
+
hide_empty?: boolean;
|
|
54
|
+
/** Limit result set to terms assigned to a specific post. */
|
|
55
|
+
post?: number;
|
|
56
|
+
/** Limit result set to terms with one or more specific slugs. */
|
|
57
|
+
slug?: string | string[];
|
|
58
|
+
}
|
|
59
|
+
type WP_MenuListErrorCode = "rest_post_invalid_id" | "rest_cannot_view" | "rest_forbidden_context";
|
|
60
|
+
interface WP_MenuCreateInput {
|
|
61
|
+
/** HTML title for the term. */
|
|
62
|
+
name?: string;
|
|
63
|
+
/** HTML description of the term. */
|
|
64
|
+
description?: string;
|
|
65
|
+
/** An alphanumeric identifier for the term unique to its type. */
|
|
66
|
+
slug?: string;
|
|
67
|
+
/** Meta fields. */
|
|
68
|
+
meta?: Record<string, unknown>;
|
|
69
|
+
/** The locations assigned to the menu. */
|
|
70
|
+
locations?: string[];
|
|
71
|
+
/** Whether to automatically add top level pages to this menu. */
|
|
72
|
+
auto_add?: boolean;
|
|
73
|
+
}
|
|
74
|
+
type WP_MenuCreateErrorCode = "rest_invalid_menu_location" | "rest_taxonomy_not_hierarchical" | "rest_term_invalid" | "rest_cannot_create";
|
|
75
|
+
interface WP_MenuRetrieveInput {
|
|
76
|
+
/** Unique identifier for the term. */
|
|
77
|
+
id: number;
|
|
78
|
+
/** Scope under which the request is made; determines fields present in response. */
|
|
79
|
+
context?: WP_Context;
|
|
80
|
+
}
|
|
81
|
+
type WP_MenuRetrieveErrorCode = "rest_cannot_view" | "rest_forbidden_context" | "rest_term_invalid";
|
|
82
|
+
interface WP_MenuUpdateInput {
|
|
83
|
+
/** Unique identifier for the term. */
|
|
84
|
+
id: number;
|
|
85
|
+
/** HTML description of the term. */
|
|
86
|
+
description?: string;
|
|
87
|
+
/** HTML title for the term. */
|
|
88
|
+
name?: string;
|
|
89
|
+
/** An alphanumeric identifier for the term unique to its type. */
|
|
90
|
+
slug?: string;
|
|
91
|
+
/** Meta fields. */
|
|
92
|
+
meta?: Record<string, unknown>;
|
|
93
|
+
/** The locations assigned to the menu. */
|
|
94
|
+
locations?: string[];
|
|
95
|
+
/** Whether to automatically add top level pages to this menu. */
|
|
96
|
+
auto_add?: boolean;
|
|
97
|
+
}
|
|
98
|
+
type WP_MenuUpdateErrorCode = "rest_invalid_menu_location" | "rest_taxonomy_not_hierarchical" | "rest_term_invalid" | "rest_cannot_update";
|
|
99
|
+
interface WP_MenuDeleteInput {
|
|
100
|
+
/** Unique identifier for the term. */
|
|
101
|
+
id: number;
|
|
102
|
+
/** Required to be true, as terms do not support trashing. */
|
|
103
|
+
force?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Response from `DELETE /wp/v2/menus/<id>`.
|
|
107
|
+
* Menus do not support trashing — `force=true` is required, so the response is always `{ deleted: true, previous: WP_Menu }`.
|
|
108
|
+
*/
|
|
109
|
+
type WP_MenuDeleteResponse = {
|
|
110
|
+
deleted: true;
|
|
111
|
+
previous: WP_Menu;
|
|
112
|
+
};
|
|
113
|
+
type WP_MenuDeleteErrorCode = "rest_cannot_delete" | "rest_term_invalid" | "rest_trash_not_supported";
|
|
114
|
+
//#endregion
|
|
115
|
+
export { WP_Menu, WP_MenuCreateErrorCode, WP_MenuCreateInput, WP_MenuDeleteErrorCode, WP_MenuDeleteInput, WP_MenuDeleteResponse, WP_MenuLinks, WP_MenuListErrorCode, WP_MenuListInput, WP_MenuOrderBy, WP_MenuRetrieveErrorCode, WP_MenuRetrieveInput, WP_MenuUpdateErrorCode, WP_MenuUpdateInput };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WP_Error } from "../error.js";
|
|
2
|
+
import { WP_List, WP_Result } from "../types.js";
|
|
3
|
+
import { WP_Post, WP_PostCreateErrorCode, WP_PostCreateInput, WP_PostDeleteErrorCode, WP_PostDeleteInput, WP_PostDeleteResponse, WP_PostListErrorCode, WP_PostListInput, WP_PostRetrieveErrorCode, WP_PostRetrieveInput, WP_PostUpdateErrorCode, WP_PostUpdateInput } from "./types.js";
|
|
4
|
+
import { WordPressService } from "../service.js";
|
|
5
|
+
import "../index.js";
|
|
6
|
+
|
|
7
|
+
//#region src/wordpress/post/service.d.ts
|
|
8
|
+
declare class PostService {
|
|
9
|
+
private readonly wordpress;
|
|
10
|
+
constructor(wordpress: WordPressService);
|
|
11
|
+
list(input: WP_PostListInput): Promise<{
|
|
12
|
+
data: null;
|
|
13
|
+
status: number;
|
|
14
|
+
headers: Headers;
|
|
15
|
+
error: WP_Error<WP_PostListErrorCode>;
|
|
16
|
+
} | {
|
|
17
|
+
data: WP_List<WP_Post>;
|
|
18
|
+
status: number;
|
|
19
|
+
headers: Headers;
|
|
20
|
+
error: null;
|
|
21
|
+
}>;
|
|
22
|
+
create(input: WP_PostCreateInput): Promise<WP_Result<WP_Post, WP_PostCreateErrorCode>>;
|
|
23
|
+
get(input: WP_PostRetrieveInput): Promise<WP_Result<WP_Post, WP_PostRetrieveErrorCode>>;
|
|
24
|
+
update(input: WP_PostUpdateInput): Promise<WP_Result<WP_Post, WP_PostUpdateErrorCode>>;
|
|
25
|
+
delete(input: WP_PostDeleteInput): Promise<WP_Result<WP_PostDeleteResponse, WP_PostDeleteErrorCode>>;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { PostService };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { WP_CORE_BASE } from "../constants.js";
|
|
2
|
+
|
|
3
|
+
//#region src/wordpress/post/service.ts
|
|
4
|
+
var PostService = 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("/posts", {
|
|
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("/posts", {
|
|
27
|
+
base: WP_CORE_BASE,
|
|
28
|
+
body: input
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async get(input) {
|
|
32
|
+
const { id,...searchParams } = input;
|
|
33
|
+
return this.wordpress.get(`/posts/${id}`, {
|
|
34
|
+
base: WP_CORE_BASE,
|
|
35
|
+
searchParams
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async update(input) {
|
|
39
|
+
const { id,...body } = input;
|
|
40
|
+
return this.wordpress.post(`/posts/${id}`, {
|
|
41
|
+
base: WP_CORE_BASE,
|
|
42
|
+
body
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async delete(input) {
|
|
46
|
+
const { id,...searchParams } = input;
|
|
47
|
+
return this.wordpress.delete(`/posts/${id}`, {
|
|
48
|
+
base: WP_CORE_BASE,
|
|
49
|
+
searchParams
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { PostService };
|