@studiocms/devapps 0.1.0-beta.8 → 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 +1 -1
- package/README.md +3 -23
- package/dist/effects/WordPressAPI/configs.d.ts +87 -0
- package/dist/effects/WordPressAPI/configs.js +88 -0
- package/dist/effects/WordPressAPI/converters.d.ts +57 -0
- package/dist/effects/WordPressAPI/converters.js +331 -0
- package/dist/effects/WordPressAPI/errors.d.ts +12 -0
- package/dist/effects/WordPressAPI/errors.js +6 -0
- package/dist/effects/WordPressAPI/importers.d.ts +19 -0
- package/dist/effects/WordPressAPI/importers.js +122 -0
- package/dist/effects/WordPressAPI/schema.d.ts +478 -0
- package/dist/effects/WordPressAPI/schema.js +127 -0
- package/dist/effects/WordPressAPI/utils.d.ts +17 -0
- package/dist/effects/WordPressAPI/utils.js +239 -0
- package/dist/effects/wpImporter.d.ts +14 -0
- package/dist/effects/wpImporter.js +88 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -16
- package/dist/routes/wp-importer.d.ts +0 -25
- package/dist/routes/wp-importer.js +9 -54
- package/dist/schema/index.d.ts +0 -24
- package/dist/schema/index.js +1 -13
- package/dist/utils/pathGenerator.js +3 -1
- package/dist/virt.d.ts +1 -5
- package/package.json +25 -31
- package/dist/apps/libsql-viewer.d.ts +0 -46
- package/dist/apps/libsql-viewer.js +0 -95
- package/dist/schema/wp-api.d.ts +0 -439
- package/dist/schema/wp-api.js +0 -72
- package/dist/utils/wp-api/converters.d.ts +0 -74
- package/dist/utils/wp-api/converters.js +0 -181
- package/dist/utils/wp-api/index.d.ts +0 -6
- package/dist/utils/wp-api/index.js +0 -3
- package/dist/utils/wp-api/pages.d.ts +0 -13
- package/dist/utils/wp-api/pages.js +0 -38
- package/dist/utils/wp-api/posts.d.ts +0 -10
- package/dist/utils/wp-api/posts.js +0 -38
- package/dist/utils/wp-api/settings.d.ts +0 -18
- package/dist/utils/wp-api/settings.js +0 -45
- package/dist/utils/wp-api/utils.d.ts +0 -66
- package/dist/utils/wp-api/utils.js +0 -138
- package/dist/virt.d.js +0 -0
package/dist/schema/wp-api.d.ts
DELETED
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
import { z } from 'astro/zod';
|
|
2
|
-
/**
|
|
3
|
-
* Schema definition for a WordPress Page object.
|
|
4
|
-
*
|
|
5
|
-
* This schema validates the structure of a WordPress Page object, ensuring that
|
|
6
|
-
* all required fields are present and have the correct types.
|
|
7
|
-
*
|
|
8
|
-
* Properties:
|
|
9
|
-
* - `id`: The unique identifier for the page (number).
|
|
10
|
-
* - `date`: The date the page was created (Date).
|
|
11
|
-
* - `date_gmt`: The date the page was created in GMT (Date).
|
|
12
|
-
* - `guid`: The globally unique identifier for the page, containing a rendered string.
|
|
13
|
-
* - `modified`: The date the page was last modified (Date).
|
|
14
|
-
* - `modified_gmt`: The date the page was last modified in GMT (Date).
|
|
15
|
-
* - `slug`: The URL-friendly slug for the page (string).
|
|
16
|
-
* - `status`: The status of the page, which can be 'publish', 'future', 'draft', 'pending', or 'private'.
|
|
17
|
-
* - `type`: The type of the page (string).
|
|
18
|
-
* - `title`: The title of the page, containing a rendered string.
|
|
19
|
-
* - `content`: The content of the page, containing a rendered string and a boolean indicating if it is protected.
|
|
20
|
-
* - `excerpt`: The excerpt of the page, containing a rendered string and a boolean indicating if it is protected.
|
|
21
|
-
* - `author`: The ID of the author of the page (number).
|
|
22
|
-
* - `featured_media`: The ID of the featured media for the page (number).
|
|
23
|
-
* - `parent`: The ID of the parent page (number).
|
|
24
|
-
* - `menu_order`: The order of the page in the menu (number).
|
|
25
|
-
* - `comment_status`: The comment status of the page, which can be 'open' or 'closed'.
|
|
26
|
-
* - `ping_status`: The ping status of the page, which can be 'open' or 'closed'.
|
|
27
|
-
* - `template`: The template used for the page (string).
|
|
28
|
-
* - `meta`: An array of metadata associated with the page, which can be any type or a record of any type.
|
|
29
|
-
*/
|
|
30
|
-
export declare const PageSchema: z.ZodObject<{
|
|
31
|
-
id: z.ZodNumber;
|
|
32
|
-
date: z.ZodDate;
|
|
33
|
-
date_gmt: z.ZodDate;
|
|
34
|
-
guid: z.ZodObject<{
|
|
35
|
-
rendered: z.ZodString;
|
|
36
|
-
}, "strip", z.ZodTypeAny, {
|
|
37
|
-
rendered: string;
|
|
38
|
-
}, {
|
|
39
|
-
rendered: string;
|
|
40
|
-
}>;
|
|
41
|
-
modified: z.ZodDate;
|
|
42
|
-
modified_gmt: z.ZodDate;
|
|
43
|
-
slug: z.ZodString;
|
|
44
|
-
status: z.ZodEnum<["publish", "future", "draft", "pending", "private"]>;
|
|
45
|
-
type: z.ZodString;
|
|
46
|
-
title: z.ZodObject<{
|
|
47
|
-
rendered: z.ZodString;
|
|
48
|
-
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
rendered: string;
|
|
50
|
-
}, {
|
|
51
|
-
rendered: string;
|
|
52
|
-
}>;
|
|
53
|
-
content: z.ZodObject<{
|
|
54
|
-
rendered: z.ZodString;
|
|
55
|
-
protected: z.ZodBoolean;
|
|
56
|
-
}, "strip", z.ZodTypeAny, {
|
|
57
|
-
rendered: string;
|
|
58
|
-
protected: boolean;
|
|
59
|
-
}, {
|
|
60
|
-
rendered: string;
|
|
61
|
-
protected: boolean;
|
|
62
|
-
}>;
|
|
63
|
-
excerpt: z.ZodObject<{
|
|
64
|
-
rendered: z.ZodString;
|
|
65
|
-
protected: z.ZodBoolean;
|
|
66
|
-
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
rendered: string;
|
|
68
|
-
protected: boolean;
|
|
69
|
-
}, {
|
|
70
|
-
rendered: string;
|
|
71
|
-
protected: boolean;
|
|
72
|
-
}>;
|
|
73
|
-
author: z.ZodNumber;
|
|
74
|
-
featured_media: z.ZodNumber;
|
|
75
|
-
parent: z.ZodNumber;
|
|
76
|
-
menu_order: z.ZodNumber;
|
|
77
|
-
comment_status: z.ZodEnum<["open", "closed", ""]>;
|
|
78
|
-
ping_status: z.ZodEnum<["open", "closed", ""]>;
|
|
79
|
-
template: z.ZodString;
|
|
80
|
-
meta: z.ZodArray<z.ZodUnion<[z.ZodAny, z.ZodRecord<z.ZodString, z.ZodAny>]>, "many">;
|
|
81
|
-
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
status: "publish" | "future" | "draft" | "pending" | "private";
|
|
83
|
-
type: string;
|
|
84
|
-
date: Date;
|
|
85
|
-
meta: any[];
|
|
86
|
-
template: string;
|
|
87
|
-
title: {
|
|
88
|
-
rendered: string;
|
|
89
|
-
};
|
|
90
|
-
content: {
|
|
91
|
-
rendered: string;
|
|
92
|
-
protected: boolean;
|
|
93
|
-
};
|
|
94
|
-
id: number;
|
|
95
|
-
date_gmt: Date;
|
|
96
|
-
guid: {
|
|
97
|
-
rendered: string;
|
|
98
|
-
};
|
|
99
|
-
modified: Date;
|
|
100
|
-
modified_gmt: Date;
|
|
101
|
-
slug: string;
|
|
102
|
-
excerpt: {
|
|
103
|
-
rendered: string;
|
|
104
|
-
protected: boolean;
|
|
105
|
-
};
|
|
106
|
-
author: number;
|
|
107
|
-
featured_media: number;
|
|
108
|
-
parent: number;
|
|
109
|
-
menu_order: number;
|
|
110
|
-
comment_status: "" | "open" | "closed";
|
|
111
|
-
ping_status: "" | "open" | "closed";
|
|
112
|
-
}, {
|
|
113
|
-
status: "publish" | "future" | "draft" | "pending" | "private";
|
|
114
|
-
type: string;
|
|
115
|
-
date: Date;
|
|
116
|
-
meta: any[];
|
|
117
|
-
template: string;
|
|
118
|
-
title: {
|
|
119
|
-
rendered: string;
|
|
120
|
-
};
|
|
121
|
-
content: {
|
|
122
|
-
rendered: string;
|
|
123
|
-
protected: boolean;
|
|
124
|
-
};
|
|
125
|
-
id: number;
|
|
126
|
-
date_gmt: Date;
|
|
127
|
-
guid: {
|
|
128
|
-
rendered: string;
|
|
129
|
-
};
|
|
130
|
-
modified: Date;
|
|
131
|
-
modified_gmt: Date;
|
|
132
|
-
slug: string;
|
|
133
|
-
excerpt: {
|
|
134
|
-
rendered: string;
|
|
135
|
-
protected: boolean;
|
|
136
|
-
};
|
|
137
|
-
author: number;
|
|
138
|
-
featured_media: number;
|
|
139
|
-
parent: number;
|
|
140
|
-
menu_order: number;
|
|
141
|
-
comment_status: "" | "open" | "closed";
|
|
142
|
-
ping_status: "" | "open" | "closed";
|
|
143
|
-
}>;
|
|
144
|
-
/**
|
|
145
|
-
* Extends the PageSchema to define the schema for a WordPress Post.
|
|
146
|
-
*
|
|
147
|
-
* Properties:
|
|
148
|
-
* - `format`: Enum representing the format of the post. Possible values are:
|
|
149
|
-
* - 'standard'
|
|
150
|
-
* - 'aside'
|
|
151
|
-
* - 'chat'
|
|
152
|
-
* - 'gallery'
|
|
153
|
-
* - 'link'
|
|
154
|
-
* - 'image'
|
|
155
|
-
* - 'quote'
|
|
156
|
-
* - 'status'
|
|
157
|
-
* - 'video'
|
|
158
|
-
* - 'audio'
|
|
159
|
-
* - ''
|
|
160
|
-
* - `categories`: Array of numbers representing the categories assigned to the post.
|
|
161
|
-
* - `tags`: Array of numbers representing the tags assigned to the post.
|
|
162
|
-
*/
|
|
163
|
-
export declare const PostSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
164
|
-
id: z.ZodNumber;
|
|
165
|
-
date: z.ZodDate;
|
|
166
|
-
date_gmt: z.ZodDate;
|
|
167
|
-
guid: z.ZodObject<{
|
|
168
|
-
rendered: z.ZodString;
|
|
169
|
-
}, "strip", z.ZodTypeAny, {
|
|
170
|
-
rendered: string;
|
|
171
|
-
}, {
|
|
172
|
-
rendered: string;
|
|
173
|
-
}>;
|
|
174
|
-
modified: z.ZodDate;
|
|
175
|
-
modified_gmt: z.ZodDate;
|
|
176
|
-
slug: z.ZodString;
|
|
177
|
-
status: z.ZodEnum<["publish", "future", "draft", "pending", "private"]>;
|
|
178
|
-
type: z.ZodString;
|
|
179
|
-
title: z.ZodObject<{
|
|
180
|
-
rendered: z.ZodString;
|
|
181
|
-
}, "strip", z.ZodTypeAny, {
|
|
182
|
-
rendered: string;
|
|
183
|
-
}, {
|
|
184
|
-
rendered: string;
|
|
185
|
-
}>;
|
|
186
|
-
content: z.ZodObject<{
|
|
187
|
-
rendered: z.ZodString;
|
|
188
|
-
protected: z.ZodBoolean;
|
|
189
|
-
}, "strip", z.ZodTypeAny, {
|
|
190
|
-
rendered: string;
|
|
191
|
-
protected: boolean;
|
|
192
|
-
}, {
|
|
193
|
-
rendered: string;
|
|
194
|
-
protected: boolean;
|
|
195
|
-
}>;
|
|
196
|
-
excerpt: z.ZodObject<{
|
|
197
|
-
rendered: z.ZodString;
|
|
198
|
-
protected: z.ZodBoolean;
|
|
199
|
-
}, "strip", z.ZodTypeAny, {
|
|
200
|
-
rendered: string;
|
|
201
|
-
protected: boolean;
|
|
202
|
-
}, {
|
|
203
|
-
rendered: string;
|
|
204
|
-
protected: boolean;
|
|
205
|
-
}>;
|
|
206
|
-
author: z.ZodNumber;
|
|
207
|
-
featured_media: z.ZodNumber;
|
|
208
|
-
parent: z.ZodNumber;
|
|
209
|
-
menu_order: z.ZodNumber;
|
|
210
|
-
comment_status: z.ZodEnum<["open", "closed", ""]>;
|
|
211
|
-
ping_status: z.ZodEnum<["open", "closed", ""]>;
|
|
212
|
-
template: z.ZodString;
|
|
213
|
-
meta: z.ZodArray<z.ZodUnion<[z.ZodAny, z.ZodRecord<z.ZodString, z.ZodAny>]>, "many">;
|
|
214
|
-
}, {
|
|
215
|
-
format: z.ZodEnum<["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio", ""]>;
|
|
216
|
-
categories: z.ZodArray<z.ZodNumber, "many">;
|
|
217
|
-
tags: z.ZodArray<z.ZodNumber, "many">;
|
|
218
|
-
}>, "strip", z.ZodTypeAny, {
|
|
219
|
-
status: "publish" | "future" | "draft" | "pending" | "private";
|
|
220
|
-
type: string;
|
|
221
|
-
date: Date;
|
|
222
|
-
meta: any[];
|
|
223
|
-
template: string;
|
|
224
|
-
title: {
|
|
225
|
-
rendered: string;
|
|
226
|
-
};
|
|
227
|
-
content: {
|
|
228
|
-
rendered: string;
|
|
229
|
-
protected: boolean;
|
|
230
|
-
};
|
|
231
|
-
id: number;
|
|
232
|
-
date_gmt: Date;
|
|
233
|
-
guid: {
|
|
234
|
-
rendered: string;
|
|
235
|
-
};
|
|
236
|
-
modified: Date;
|
|
237
|
-
modified_gmt: Date;
|
|
238
|
-
slug: string;
|
|
239
|
-
excerpt: {
|
|
240
|
-
rendered: string;
|
|
241
|
-
protected: boolean;
|
|
242
|
-
};
|
|
243
|
-
author: number;
|
|
244
|
-
featured_media: number;
|
|
245
|
-
parent: number;
|
|
246
|
-
menu_order: number;
|
|
247
|
-
comment_status: "" | "open" | "closed";
|
|
248
|
-
ping_status: "" | "open" | "closed";
|
|
249
|
-
format: "" | "status" | "image" | "aside" | "audio" | "link" | "video" | "standard" | "chat" | "gallery" | "quote";
|
|
250
|
-
categories: number[];
|
|
251
|
-
tags: number[];
|
|
252
|
-
}, {
|
|
253
|
-
status: "publish" | "future" | "draft" | "pending" | "private";
|
|
254
|
-
type: string;
|
|
255
|
-
date: Date;
|
|
256
|
-
meta: any[];
|
|
257
|
-
template: string;
|
|
258
|
-
title: {
|
|
259
|
-
rendered: string;
|
|
260
|
-
};
|
|
261
|
-
content: {
|
|
262
|
-
rendered: string;
|
|
263
|
-
protected: boolean;
|
|
264
|
-
};
|
|
265
|
-
id: number;
|
|
266
|
-
date_gmt: Date;
|
|
267
|
-
guid: {
|
|
268
|
-
rendered: string;
|
|
269
|
-
};
|
|
270
|
-
modified: Date;
|
|
271
|
-
modified_gmt: Date;
|
|
272
|
-
slug: string;
|
|
273
|
-
excerpt: {
|
|
274
|
-
rendered: string;
|
|
275
|
-
protected: boolean;
|
|
276
|
-
};
|
|
277
|
-
author: number;
|
|
278
|
-
featured_media: number;
|
|
279
|
-
parent: number;
|
|
280
|
-
menu_order: number;
|
|
281
|
-
comment_status: "" | "open" | "closed";
|
|
282
|
-
ping_status: "" | "open" | "closed";
|
|
283
|
-
format: "" | "status" | "image" | "aside" | "audio" | "link" | "video" | "standard" | "chat" | "gallery" | "quote";
|
|
284
|
-
categories: number[];
|
|
285
|
-
tags: number[];
|
|
286
|
-
}>;
|
|
287
|
-
/**
|
|
288
|
-
* Schema for a WordPress Tag object.
|
|
289
|
-
*
|
|
290
|
-
* This schema validates the structure of a WordPress Tag object, ensuring that
|
|
291
|
-
* it contains the following properties:
|
|
292
|
-
*
|
|
293
|
-
* - `id`: A numeric identifier for the tag.
|
|
294
|
-
* - `count`: A numeric count of the number of posts associated with the tag.
|
|
295
|
-
* - `description`: A string description of the tag.
|
|
296
|
-
* - `link`: A URL string linking to the tag.
|
|
297
|
-
* - `name`: A string name of the tag.
|
|
298
|
-
* - `slug`: A string slug for the tag.
|
|
299
|
-
* - `taxonomy`: A string representing the taxonomy type.
|
|
300
|
-
* - `meta`: An array or record of any additional metadata associated with the tag.
|
|
301
|
-
*/
|
|
302
|
-
export declare const TagSchema: z.ZodObject<{
|
|
303
|
-
id: z.ZodNumber;
|
|
304
|
-
count: z.ZodNumber;
|
|
305
|
-
description: z.ZodString;
|
|
306
|
-
link: z.ZodString;
|
|
307
|
-
name: z.ZodString;
|
|
308
|
-
slug: z.ZodString;
|
|
309
|
-
taxonomy: z.ZodString;
|
|
310
|
-
meta: z.ZodUnion<[z.ZodArray<z.ZodAny, "many">, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
311
|
-
}, "strip", z.ZodTypeAny, {
|
|
312
|
-
link: string;
|
|
313
|
-
meta: any[] | Record<string, any>;
|
|
314
|
-
id: number;
|
|
315
|
-
slug: string;
|
|
316
|
-
count: number;
|
|
317
|
-
description: string;
|
|
318
|
-
name: string;
|
|
319
|
-
taxonomy: string;
|
|
320
|
-
}, {
|
|
321
|
-
link: string;
|
|
322
|
-
meta: any[] | Record<string, any>;
|
|
323
|
-
id: number;
|
|
324
|
-
slug: string;
|
|
325
|
-
count: number;
|
|
326
|
-
description: string;
|
|
327
|
-
name: string;
|
|
328
|
-
taxonomy: string;
|
|
329
|
-
}>;
|
|
330
|
-
/**
|
|
331
|
-
* Extends the TagSchema to create a CategorySchema.
|
|
332
|
-
*
|
|
333
|
-
* @property {number} parent - The ID of the parent category.
|
|
334
|
-
*/
|
|
335
|
-
export declare const CategorySchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
336
|
-
id: z.ZodNumber;
|
|
337
|
-
count: z.ZodNumber;
|
|
338
|
-
description: z.ZodString;
|
|
339
|
-
link: z.ZodString;
|
|
340
|
-
name: z.ZodString;
|
|
341
|
-
slug: z.ZodString;
|
|
342
|
-
taxonomy: z.ZodString;
|
|
343
|
-
meta: z.ZodUnion<[z.ZodArray<z.ZodAny, "many">, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
344
|
-
}, {
|
|
345
|
-
parent: z.ZodNumber;
|
|
346
|
-
}>, "strip", z.ZodTypeAny, {
|
|
347
|
-
link: string;
|
|
348
|
-
meta: any[] | Record<string, any>;
|
|
349
|
-
id: number;
|
|
350
|
-
slug: string;
|
|
351
|
-
parent: number;
|
|
352
|
-
count: number;
|
|
353
|
-
description: string;
|
|
354
|
-
name: string;
|
|
355
|
-
taxonomy: string;
|
|
356
|
-
}, {
|
|
357
|
-
link: string;
|
|
358
|
-
meta: any[] | Record<string, any>;
|
|
359
|
-
id: number;
|
|
360
|
-
slug: string;
|
|
361
|
-
parent: number;
|
|
362
|
-
count: number;
|
|
363
|
-
description: string;
|
|
364
|
-
name: string;
|
|
365
|
-
taxonomy: string;
|
|
366
|
-
}>;
|
|
367
|
-
/**
|
|
368
|
-
* Schema for site settings in the WordPress API.
|
|
369
|
-
*
|
|
370
|
-
* This schema defines the structure of the site settings object, which includes
|
|
371
|
-
* various properties related to the site's configuration.
|
|
372
|
-
*
|
|
373
|
-
* Properties:
|
|
374
|
-
* - `name`: The name of the site (string).
|
|
375
|
-
* - `description`: A brief description of the site (string).
|
|
376
|
-
* - `url`: The URL of the site (string).
|
|
377
|
-
* - `home`: The home URL of the site (string).
|
|
378
|
-
* - `gmt_offset`: The GMT offset for the site's timezone (number).
|
|
379
|
-
* - `timezone_string`: The timezone string for the site (string).
|
|
380
|
-
* - `site_logo`: The ID of the site's logo (optional number).
|
|
381
|
-
* - `site_icon`: The ID of the site's icon (optional number).
|
|
382
|
-
* - `site_icon_url`: The URL of the site's icon (optional string).
|
|
383
|
-
*/
|
|
384
|
-
export declare const SiteSettingsSchema: z.ZodObject<{
|
|
385
|
-
name: z.ZodString;
|
|
386
|
-
description: z.ZodString;
|
|
387
|
-
url: z.ZodString;
|
|
388
|
-
home: z.ZodString;
|
|
389
|
-
gmt_offset: z.ZodNumber;
|
|
390
|
-
timezone_string: z.ZodString;
|
|
391
|
-
site_logo: z.ZodOptional<z.ZodNumber>;
|
|
392
|
-
site_icon: z.ZodOptional<z.ZodNumber>;
|
|
393
|
-
site_icon_url: z.ZodOptional<z.ZodString>;
|
|
394
|
-
}, "strip", z.ZodTypeAny, {
|
|
395
|
-
url: string;
|
|
396
|
-
description: string;
|
|
397
|
-
name: string;
|
|
398
|
-
home: string;
|
|
399
|
-
gmt_offset: number;
|
|
400
|
-
timezone_string: string;
|
|
401
|
-
site_logo?: number | undefined;
|
|
402
|
-
site_icon?: number | undefined;
|
|
403
|
-
site_icon_url?: string | undefined;
|
|
404
|
-
}, {
|
|
405
|
-
url: string;
|
|
406
|
-
description: string;
|
|
407
|
-
name: string;
|
|
408
|
-
home: string;
|
|
409
|
-
gmt_offset: number;
|
|
410
|
-
timezone_string: string;
|
|
411
|
-
site_logo?: number | undefined;
|
|
412
|
-
site_icon?: number | undefined;
|
|
413
|
-
site_icon_url?: string | undefined;
|
|
414
|
-
}>;
|
|
415
|
-
/**
|
|
416
|
-
* Represents the type of a Page object as defined by the PageSchema.
|
|
417
|
-
* This type is derived from the output type of the PageSchema.
|
|
418
|
-
*/
|
|
419
|
-
export type Page = z.infer<typeof PageSchema>;
|
|
420
|
-
/**
|
|
421
|
-
* Represents a WordPress post based on the PostSchema.
|
|
422
|
-
*
|
|
423
|
-
* This type is derived from the output type of the PostSchema.
|
|
424
|
-
*/
|
|
425
|
-
export type Post = z.infer<typeof PostSchema>;
|
|
426
|
-
/**
|
|
427
|
-
* Represents a Tag type derived from the TagSchema's output type.
|
|
428
|
-
*/
|
|
429
|
-
export type Tag = z.infer<typeof TagSchema>;
|
|
430
|
-
/**
|
|
431
|
-
* Represents a Category type derived from the output of the CategorySchema.
|
|
432
|
-
*/
|
|
433
|
-
export type Category = z.infer<typeof CategorySchema>;
|
|
434
|
-
/**
|
|
435
|
-
* Represents the settings for a site.
|
|
436
|
-
*
|
|
437
|
-
* This type is derived from the output of the `SiteSettingsSchema`.
|
|
438
|
-
*/
|
|
439
|
-
export type SiteSettings = z.infer<typeof SiteSettingsSchema>;
|
package/dist/schema/wp-api.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { z } from "astro/zod";
|
|
2
|
-
const OpenClosedSchema = z.enum(["open", "closed", ""]);
|
|
3
|
-
const PageSchema = z.object({
|
|
4
|
-
id: z.number(),
|
|
5
|
-
date: z.coerce.date(),
|
|
6
|
-
date_gmt: z.coerce.date(),
|
|
7
|
-
guid: z.object({ rendered: z.string() }),
|
|
8
|
-
modified: z.coerce.date(),
|
|
9
|
-
modified_gmt: z.coerce.date(),
|
|
10
|
-
slug: z.string(),
|
|
11
|
-
status: z.enum(["publish", "future", "draft", "pending", "private"]),
|
|
12
|
-
type: z.string(),
|
|
13
|
-
title: z.object({ rendered: z.string() }),
|
|
14
|
-
content: z.object({ rendered: z.string(), protected: z.boolean() }),
|
|
15
|
-
excerpt: z.object({ rendered: z.string(), protected: z.boolean() }),
|
|
16
|
-
author: z.number(),
|
|
17
|
-
featured_media: z.number(),
|
|
18
|
-
parent: z.number(),
|
|
19
|
-
menu_order: z.number(),
|
|
20
|
-
comment_status: OpenClosedSchema,
|
|
21
|
-
ping_status: OpenClosedSchema,
|
|
22
|
-
template: z.string(),
|
|
23
|
-
meta: z.array(z.any().or(z.record(z.any())))
|
|
24
|
-
});
|
|
25
|
-
const PostSchema = PageSchema.extend({
|
|
26
|
-
format: z.enum([
|
|
27
|
-
"standard",
|
|
28
|
-
"aside",
|
|
29
|
-
"chat",
|
|
30
|
-
"gallery",
|
|
31
|
-
"link",
|
|
32
|
-
"image",
|
|
33
|
-
"quote",
|
|
34
|
-
"status",
|
|
35
|
-
"video",
|
|
36
|
-
"audio",
|
|
37
|
-
""
|
|
38
|
-
]),
|
|
39
|
-
categories: z.array(z.number()),
|
|
40
|
-
tags: z.array(z.number())
|
|
41
|
-
});
|
|
42
|
-
const TagSchema = z.object({
|
|
43
|
-
id: z.number(),
|
|
44
|
-
count: z.number(),
|
|
45
|
-
description: z.string(),
|
|
46
|
-
link: z.string().url(),
|
|
47
|
-
name: z.string(),
|
|
48
|
-
slug: z.string(),
|
|
49
|
-
taxonomy: z.string(),
|
|
50
|
-
meta: z.array(z.any()).or(z.record(z.any()))
|
|
51
|
-
});
|
|
52
|
-
const CategorySchema = TagSchema.extend({
|
|
53
|
-
parent: z.number()
|
|
54
|
-
});
|
|
55
|
-
const SiteSettingsSchema = z.object({
|
|
56
|
-
name: z.string(),
|
|
57
|
-
description: z.string(),
|
|
58
|
-
url: z.string(),
|
|
59
|
-
home: z.string(),
|
|
60
|
-
gmt_offset: z.coerce.number(),
|
|
61
|
-
timezone_string: z.string(),
|
|
62
|
-
site_logo: z.number().optional(),
|
|
63
|
-
site_icon: z.number().optional(),
|
|
64
|
-
site_icon_url: z.string().optional()
|
|
65
|
-
});
|
|
66
|
-
export {
|
|
67
|
-
CategorySchema,
|
|
68
|
-
PageSchema,
|
|
69
|
-
PostSchema,
|
|
70
|
-
SiteSettingsSchema,
|
|
71
|
-
TagSchema
|
|
72
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { PageContent, PageData } from './index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Converts a given page object to a PageData object.
|
|
4
|
-
*
|
|
5
|
-
* @param page - The page object to convert. This is expected to be of an unknown type.
|
|
6
|
-
* @param endpoint - The API endpoint to fetch additional data, such as media.
|
|
7
|
-
* @returns A promise that resolves to a PageData object containing the converted page data.
|
|
8
|
-
*
|
|
9
|
-
* @throws Will throw an error if fetching the title image fails.
|
|
10
|
-
*/
|
|
11
|
-
export declare const ConvertToPageData: (page: unknown, endpoint: string) => Promise<PageData>;
|
|
12
|
-
/**
|
|
13
|
-
* Converts the provided page data and page content into a PageContent object.
|
|
14
|
-
*
|
|
15
|
-
* @param pageData - The data of the page to be converted.
|
|
16
|
-
* @param page - The raw page content to be converted.
|
|
17
|
-
* @returns A promise that resolves to a PageContent object.
|
|
18
|
-
* @throws Will throw an error if the pageData is missing an id.
|
|
19
|
-
*/
|
|
20
|
-
export declare const ConvertToPageContent: (pageData: PageData, page: unknown) => Promise<PageContent>;
|
|
21
|
-
/**
|
|
22
|
-
* Generates and inserts categories into the database if they do not already exist.
|
|
23
|
-
*
|
|
24
|
-
* @param categories - An array of category IDs to be processed.
|
|
25
|
-
* @param endpoint - The API endpoint to fetch category data from.
|
|
26
|
-
* @returns A promise that resolves when the categories have been processed and inserted into the database.
|
|
27
|
-
*
|
|
28
|
-
* This function performs the following steps:
|
|
29
|
-
* 1. Iterates over the provided category IDs.
|
|
30
|
-
* 2. Checks if each category already exists in the database.
|
|
31
|
-
* 3. If a category does not exist, fetches the category data from the specified API endpoint.
|
|
32
|
-
* 4. Collects the new category data.
|
|
33
|
-
* 5. Maps the new category data to the database schema.
|
|
34
|
-
* 6. Inserts the new categories into the database.
|
|
35
|
-
*/
|
|
36
|
-
export declare const generateCategories: (categories: number[], endpoint: string) => Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Generates and inserts tags into the database if they do not already exist.
|
|
39
|
-
*
|
|
40
|
-
* @param {number[]} tags - An array of tag IDs to be processed.
|
|
41
|
-
* @param {string} endpoint - The API endpoint to fetch tag data from.
|
|
42
|
-
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* const tags = [1, 2, 3];
|
|
46
|
-
* const endpoint = 'https://example.com/wp-json/wp/v2';
|
|
47
|
-
* await generateTags(tags, endpoint);
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* This function checks if each tag ID already exists in the database. If a tag does not exist,
|
|
51
|
-
* it fetches the tag data from the specified API endpoint and inserts it into the database.
|
|
52
|
-
* The function logs messages to the console for each tag that is processed.
|
|
53
|
-
*/
|
|
54
|
-
export declare const generateTags: (tags: number[], endpoint: string) => Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Converts a given post object to PageData format.
|
|
57
|
-
*
|
|
58
|
-
* @param post - The post object to be converted.
|
|
59
|
-
* @param useBlogPkg - A boolean indicating whether to use the blog package.
|
|
60
|
-
* @param endpoint - The API endpoint to fetch additional data.
|
|
61
|
-
* @returns A promise that resolves to the converted PageData object.
|
|
62
|
-
*
|
|
63
|
-
* @throws Will throw an error if fetching the title image or downloading the post image fails.
|
|
64
|
-
*/
|
|
65
|
-
export declare const ConvertToPostData: (post: unknown, useBlogPkg: boolean, endpoint: string) => Promise<PageData>;
|
|
66
|
-
/**
|
|
67
|
-
* Converts the given post data to a PageContent object.
|
|
68
|
-
*
|
|
69
|
-
* @param pageData - The data of the page to which the post content belongs.
|
|
70
|
-
* @param post - The post data to be converted.
|
|
71
|
-
* @returns A promise that resolves to a PageContent object.
|
|
72
|
-
* @throws Will throw an error if the pageData is missing an id.
|
|
73
|
-
*/
|
|
74
|
-
export declare const ConvertToPostContent: (pageData: PageData, post: unknown) => Promise<PageContent>;
|