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,120 @@
|
|
|
1
|
+
import { IdentifierInput, ListMetadata, ListOrder, Media } from "../shared/schema.js";
|
|
2
|
+
import { Seo } from "../seo/schema.js";
|
|
3
|
+
import { BooleanLike, Metadata, NumberLike, arrayable } from "@kizlo/shared";
|
|
4
|
+
import z from "zod/v4";
|
|
5
|
+
|
|
6
|
+
//#region src/post/schema.ts
|
|
7
|
+
const POST_TYPE_FORMATS = [
|
|
8
|
+
"standard",
|
|
9
|
+
"aside",
|
|
10
|
+
"chat",
|
|
11
|
+
"gallery",
|
|
12
|
+
"link",
|
|
13
|
+
"image",
|
|
14
|
+
"quote",
|
|
15
|
+
"status",
|
|
16
|
+
"video",
|
|
17
|
+
"audio"
|
|
18
|
+
];
|
|
19
|
+
const PostTypeFormat = z.enum(POST_TYPE_FORMATS);
|
|
20
|
+
const POST_STATUSES = [
|
|
21
|
+
"publish",
|
|
22
|
+
"future",
|
|
23
|
+
"draft",
|
|
24
|
+
"pending",
|
|
25
|
+
"private"
|
|
26
|
+
];
|
|
27
|
+
const PostStatus = z.enum(POST_STATUSES);
|
|
28
|
+
const POST_COMMENT_STATUSES = [
|
|
29
|
+
"approved",
|
|
30
|
+
"hold",
|
|
31
|
+
"spam",
|
|
32
|
+
"trash"
|
|
33
|
+
];
|
|
34
|
+
const PostCommentStatus = z.enum(POST_COMMENT_STATUSES);
|
|
35
|
+
const POST_COMMENT_TYPES = [
|
|
36
|
+
"comment",
|
|
37
|
+
"pingback",
|
|
38
|
+
"trackback"
|
|
39
|
+
];
|
|
40
|
+
const PostCommentType = z.enum(POST_COMMENT_TYPES);
|
|
41
|
+
const PostAuthorRef = z.object({
|
|
42
|
+
id: z.number(),
|
|
43
|
+
name: z.string(),
|
|
44
|
+
avatar: Media.nullable()
|
|
45
|
+
});
|
|
46
|
+
const PostCategoryRef = z.object({
|
|
47
|
+
id: z.number(),
|
|
48
|
+
name: z.string(),
|
|
49
|
+
slug: z.string()
|
|
50
|
+
});
|
|
51
|
+
const PostTagRef = z.object({
|
|
52
|
+
id: z.number(),
|
|
53
|
+
name: z.string(),
|
|
54
|
+
slug: z.string()
|
|
55
|
+
});
|
|
56
|
+
const Post = z.object({
|
|
57
|
+
id: z.number(),
|
|
58
|
+
slug: z.string(),
|
|
59
|
+
title: z.string().nullable(),
|
|
60
|
+
content: z.string().nullable(),
|
|
61
|
+
excerpt: z.string().nullable(),
|
|
62
|
+
commentsEnabled: z.boolean(),
|
|
63
|
+
protected: z.boolean(),
|
|
64
|
+
format: PostTypeFormat,
|
|
65
|
+
sticky: z.boolean(),
|
|
66
|
+
author: PostAuthorRef.nullable(),
|
|
67
|
+
featuredMedia: Media.nullable(),
|
|
68
|
+
categories: z.array(PostCategoryRef),
|
|
69
|
+
tags: z.array(PostTagRef),
|
|
70
|
+
seo: Seo.nullable(),
|
|
71
|
+
createdAt: z.number(),
|
|
72
|
+
updatedAt: z.number(),
|
|
73
|
+
meta: Metadata
|
|
74
|
+
});
|
|
75
|
+
const RetrievePostInput = z.object({
|
|
76
|
+
identifier: IdentifierInput,
|
|
77
|
+
password: z.string().optional(),
|
|
78
|
+
previewToken: z.string().optional()
|
|
79
|
+
});
|
|
80
|
+
const PostList = z.object({
|
|
81
|
+
items: z.array(Post),
|
|
82
|
+
meta: ListMetadata
|
|
83
|
+
});
|
|
84
|
+
const POST_ORDER_BYES = [
|
|
85
|
+
"author",
|
|
86
|
+
"date",
|
|
87
|
+
"id",
|
|
88
|
+
"include",
|
|
89
|
+
"parent",
|
|
90
|
+
"relevance",
|
|
91
|
+
"slug",
|
|
92
|
+
"include_slugs",
|
|
93
|
+
"title"
|
|
94
|
+
];
|
|
95
|
+
const PostOrderBy = z.enum(POST_ORDER_BYES);
|
|
96
|
+
const ListPostInput = z.object({
|
|
97
|
+
page: NumberLike.optional(),
|
|
98
|
+
perPage: NumberLike.optional(),
|
|
99
|
+
search: z.string().optional(),
|
|
100
|
+
after: z.string().optional(),
|
|
101
|
+
before: z.string().optional(),
|
|
102
|
+
author: arrayable(NumberLike).optional(),
|
|
103
|
+
authorExclude: arrayable(NumberLike).optional(),
|
|
104
|
+
exclude: arrayable(NumberLike).optional(),
|
|
105
|
+
include: arrayable(NumberLike).optional(),
|
|
106
|
+
offset: NumberLike.optional(),
|
|
107
|
+
order: ListOrder.optional(),
|
|
108
|
+
orderby: PostOrderBy.optional(),
|
|
109
|
+
searchColumns: z.array(z.string()).optional(),
|
|
110
|
+
slug: arrayable(z.string()).optional(),
|
|
111
|
+
taxRelation: z.enum(["AND", "OR"]).optional(),
|
|
112
|
+
categories: arrayable(NumberLike).optional(),
|
|
113
|
+
categoriesExclude: arrayable(NumberLike).optional(),
|
|
114
|
+
tags: arrayable(NumberLike).optional(),
|
|
115
|
+
tagsExclude: arrayable(NumberLike).optional(),
|
|
116
|
+
sticky: BooleanLike.optional()
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
export { ListPostInput, Post, PostList, RetrievePostInput };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { deserializeSeo } from "../seo/utils.js";
|
|
2
|
+
import { stringifiedMetaRecord } from "@kizlo/shared";
|
|
3
|
+
|
|
4
|
+
//#region src/post/utils.ts
|
|
5
|
+
function deserializePost(data) {
|
|
6
|
+
return {
|
|
7
|
+
id: data.id,
|
|
8
|
+
title: data.title.rendered,
|
|
9
|
+
content: !data.password.length ? data.content?.rendered ?? null : null,
|
|
10
|
+
excerpt: !data.password.length ? data.excerpt.rendered : null,
|
|
11
|
+
protected: !!data.password.length,
|
|
12
|
+
featuredMedia: data.kizlo?.featured_media ? {
|
|
13
|
+
id: data.kizlo.featured_media.id,
|
|
14
|
+
alt: data.kizlo.featured_media.alt,
|
|
15
|
+
name: data.title.rendered,
|
|
16
|
+
src: data.kizlo.featured_media.url
|
|
17
|
+
} : null,
|
|
18
|
+
commentsEnabled: data.comment_status === "open",
|
|
19
|
+
slug: data.slug,
|
|
20
|
+
sticky: data.sticky ?? false,
|
|
21
|
+
tags: data.kizlo.tags ?? [],
|
|
22
|
+
categories: data.kizlo.categories ?? [],
|
|
23
|
+
author: data.kizlo.author ? {
|
|
24
|
+
id: data.kizlo.author.id,
|
|
25
|
+
name: data.kizlo.author.name,
|
|
26
|
+
avatar: data.kizlo.author.avatar_url ? {
|
|
27
|
+
id: 0,
|
|
28
|
+
alt: data.kizlo.author.name,
|
|
29
|
+
name: data.kizlo.author.name,
|
|
30
|
+
src: data.kizlo.author.avatar_url
|
|
31
|
+
} : null
|
|
32
|
+
} : null,
|
|
33
|
+
format: data.format ?? "standard",
|
|
34
|
+
seo: data.kizlo.seo ? deserializeSeo(data.kizlo.seo) : null,
|
|
35
|
+
createdAt: new Date(data.date ?? "").getTime(),
|
|
36
|
+
updatedAt: new Date(data.modified ?? "").getTime(),
|
|
37
|
+
meta: stringifiedMetaRecord(data.meta ?? {})
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { deserializePost };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { WP_KIZLO_BASE } from "../wordpress/constants.js";
|
|
2
|
+
import { trimLeadingTrailingSlashes } from "@kizlo/shared";
|
|
3
|
+
|
|
4
|
+
//#region src/post-type/service.ts
|
|
5
|
+
var PostTypeService = class {
|
|
6
|
+
key;
|
|
7
|
+
wordpress;
|
|
8
|
+
constructor(key, wordpress) {
|
|
9
|
+
this.key = key;
|
|
10
|
+
this.wordpress = wordpress;
|
|
11
|
+
}
|
|
12
|
+
async get(identifier) {
|
|
13
|
+
return await this.wordpress.get(this.resolvePath(identifier), { base: WP_KIZLO_BASE });
|
|
14
|
+
}
|
|
15
|
+
async list(input) {
|
|
16
|
+
return await this.wordpress.get(this.resolvePath(), {
|
|
17
|
+
base: WP_KIZLO_BASE,
|
|
18
|
+
searchParams: { ...input }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async create(input) {
|
|
22
|
+
return await this.wordpress.post(this.resolvePath(), {
|
|
23
|
+
base: WP_KIZLO_BASE,
|
|
24
|
+
body: input
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async update(input) {
|
|
28
|
+
return await this.wordpress.put(this.resolvePath(input.identifier), {
|
|
29
|
+
base: WP_KIZLO_BASE,
|
|
30
|
+
body: input
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async delete(input) {
|
|
34
|
+
return await this.wordpress.delete(this.resolvePath(input.identifier), {
|
|
35
|
+
base: WP_KIZLO_BASE,
|
|
36
|
+
searchParams: { force: input.force }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
resolvePath(identifier) {
|
|
40
|
+
return `/post-types/${trimLeadingTrailingSlashes(this.key)}${identifier ? `/${identifier.value}` : ``}`;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function getPostTypeService(key, wordpress) {
|
|
44
|
+
return new PostTypeService(key, wordpress);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { getPostTypeService };
|