kizlo 0.7.0 → 0.8.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.
Files changed (85) hide show
  1. package/dist/category/error.js +14 -0
  2. package/dist/category/index.js +77 -0
  3. package/dist/category/schema.js +40 -0
  4. package/dist/category/utils.js +20 -0
  5. package/dist/cli/banner.js +1 -1
  6. package/dist/cli/commands/_setup.js +342 -0
  7. package/dist/cli/commands/create.js +146 -0
  8. package/dist/cli/commands/dev.js +1 -1
  9. package/dist/cli/commands/init.js +53 -300
  10. package/dist/cli/index.js +2 -1
  11. package/dist/cli/presets/generated/templates.js +59 -0
  12. package/dist/cli/presets/nextjs.js +3 -95
  13. package/dist/cli/presets/patch.js +133 -0
  14. package/dist/cli/presets/template.js +36 -0
  15. package/dist/comment/index.js +4 -4
  16. package/dist/context.d.ts +25 -8
  17. package/dist/context.js +15 -5
  18. package/dist/email/service.d.ts +4 -3
  19. package/dist/email/service.js +4 -4
  20. package/dist/index.d.ts +15 -11
  21. package/dist/index.js +10 -4
  22. package/dist/integrations/nextjs/metadata.js +6 -3
  23. package/dist/integrations/nextjs/sitemap.d.ts +8 -7
  24. package/dist/integrations/nextjs/sitemap.js +3 -3
  25. package/dist/menu/index.js +19 -14
  26. package/dist/menu/schema.d.ts +14 -0
  27. package/dist/menu/schema.js +35 -40
  28. package/dist/menu/utils.js +23 -14
  29. package/dist/nextjs/server.d.ts +2 -1
  30. package/dist/nextjs/server.js +2 -1
  31. package/dist/package.js +1 -1
  32. package/dist/page/error.js +20 -0
  33. package/dist/page/index.js +128 -0
  34. package/dist/page/schema.js +75 -0
  35. package/dist/page/utils.js +43 -0
  36. package/dist/post/error.js +4 -14
  37. package/dist/post/index.js +17 -9
  38. package/dist/post/schema.js +37 -66
  39. package/dist/post/utils.js +27 -24
  40. package/dist/router.d.ts +1006 -185
  41. package/dist/router.js +6 -0
  42. package/dist/seo/index.js +7 -44
  43. package/dist/seo/schema.d.ts +10 -6
  44. package/dist/seo/schema.js +7 -5
  45. package/dist/seo/sitemap.d.ts +9 -1
  46. package/dist/seo/sitemap.js +17 -1
  47. package/dist/seo/types.d.ts +17 -20
  48. package/dist/seo/utils.js +9 -7
  49. package/dist/settings/index.js +27 -24
  50. package/dist/settings/service.d.ts +14 -13
  51. package/dist/settings/service.interface.d.ts +2 -2
  52. package/dist/settings/service.js +9 -9
  53. package/dist/shared/middleware.d.ts +4 -4
  54. package/dist/shared/procedure.d.ts +6 -7
  55. package/dist/tag/error.js +14 -0
  56. package/dist/tag/index.js +76 -0
  57. package/dist/tag/schema.js +38 -0
  58. package/dist/tag/utils.js +19 -0
  59. package/dist/taxonomy/service.js +48 -0
  60. package/dist/test/fixtures.d.ts +1 -1
  61. package/dist/test/fixtures.js +1 -1
  62. package/dist/webhook/index.d.ts +2 -2
  63. package/dist/wordpress/category/service.d.ts +28 -0
  64. package/dist/wordpress/category/service.js +55 -0
  65. package/dist/wordpress/category/types.d.ts +120 -0
  66. package/dist/wordpress/category/types.js +15 -0
  67. package/dist/wordpress/comment/service.d.ts +1 -1
  68. package/dist/wordpress/index.d.ts +9 -4
  69. package/dist/wordpress/menu/items/types.d.ts +7 -4
  70. package/dist/wordpress/menu/items/types.js +22 -0
  71. package/dist/wordpress/page/service.d.ts +28 -0
  72. package/dist/wordpress/page/service.js +55 -0
  73. package/dist/wordpress/page/types.d.ts +270 -0
  74. package/dist/wordpress/page/types.js +27 -0
  75. package/dist/wordpress/post/types.d.ts +9 -5
  76. package/dist/wordpress/post/types.js +41 -0
  77. package/dist/wordpress/service.d.ts +7 -1
  78. package/dist/wordpress/service.js +6 -0
  79. package/dist/wordpress/tag/service.d.ts +28 -0
  80. package/dist/wordpress/tag/service.js +55 -0
  81. package/dist/wordpress/tag/types.d.ts +113 -0
  82. package/dist/wordpress/tag/types.js +15 -0
  83. package/package.json +5 -3
  84. package/dist/service.d.ts +0 -19
  85. package/dist/service.js +0 -20
package/dist/router.js CHANGED
@@ -1,12 +1,18 @@
1
+ import { CATEGORY_ROUTER_MAP } from "./category/index.js";
1
2
  import { COMMENT_ROUTER_MAP } from "./comment/index.js";
2
3
  import { MENU_ROUTER_MAP } from "./menu/index.js";
4
+ import { PAGE_ROUTER_MAP } from "./page/index.js";
3
5
  import { POST_ROUTER_MAP } from "./post/index.js";
4
6
  import { SEO_ROUTER_MAP } from "./seo/index.js";
5
7
  import { SETTINGS_ROUTER_MAP } from "./settings/index.js";
8
+ import { TAG_ROUTER_MAP } from "./tag/index.js";
6
9
 
7
10
  //#region src/router.ts
8
11
  const ROUTER_MAP = {
9
12
  posts: POST_ROUTER_MAP,
13
+ pages: PAGE_ROUTER_MAP,
14
+ categories: CATEGORY_ROUTER_MAP,
15
+ tags: TAG_ROUTER_MAP,
10
16
  seo: SEO_ROUTER_MAP,
11
17
  menus: MENU_ROUTER_MAP,
12
18
  comments: COMMENT_ROUTER_MAP,
package/dist/seo/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createProcedure } from "../shared/procedure.js";
2
2
  import { WP_KIZLO_BASE } from "../wordpress/constants.js";
3
3
  import { ListSitemapUrlInput, Robots, Seo, SitemapIndex, SitemapList, SitemapUrlList } from "./schema.js";
4
+ import { deserializeSeo } from "./utils.js";
4
5
 
5
6
  //#region src/seo/index.ts
6
7
  const SEO_ROUTER_MAP = {
@@ -8,57 +9,19 @@ const SEO_ROUTER_MAP = {
8
9
  scope: "internal",
9
10
  output: Seo
10
11
  }, async ({ context, errors }) => {
11
- const response = await context.service.wordpress.get("/seo/homepage", { base: WP_KIZLO_BASE });
12
+ const response = await context.wordpress.get("/seo/homepage", { base: WP_KIZLO_BASE });
12
13
  if (response.error) {
13
14
  context.logger.error("Get homepage seo unhandled error", response.error);
14
15
  throw errors.INTERNAL_SERVER_ERROR();
15
16
  }
16
- const { head } = response.data;
17
- return {
18
- head: {
19
- title: head.title,
20
- canonical: head.canonical,
21
- robots: {
22
- index: head.robots.index,
23
- follow: head.robots.follow,
24
- maxSnippet: head.robots["max-snippet"],
25
- maxImagePreview: head.robots["max-image-preview"],
26
- maxVideoPreview: head.robots["max-video-preview"]
27
- },
28
- og: {
29
- locale: head.og.locale,
30
- type: head.og.type,
31
- title: head.og.title,
32
- url: head.og.url,
33
- siteName: head.og.site_name,
34
- description: head.og.description ?? "",
35
- image: head.og.image
36
- },
37
- twitter: {
38
- card: head.twitter.card,
39
- title: head.twitter.title,
40
- site: head.twitter.site,
41
- creator: head.twitter.creator,
42
- description: head.twitter.description ?? "",
43
- image: head.twitter.image
44
- },
45
- article: head.article && {
46
- publishedTime: head.article.published_time,
47
- modifiedTime: head.article.modified_time,
48
- author: head.article.author,
49
- authorUrl: head.article.author_url,
50
- section: head.article.section
51
- }
52
- },
53
- schema: response.data.schema
54
- };
17
+ return deserializeSeo(response.data);
55
18
  }),
56
19
  sitemaps: {
57
20
  list: createProcedure({
58
21
  scope: "internal",
59
22
  output: SitemapList
60
23
  }, async ({ context, errors }) => {
61
- const response = await context.service.wordpress.get("/seo/sitemaps", { base: WP_KIZLO_BASE });
24
+ const response = await context.wordpress.get("/seo/sitemaps", { base: WP_KIZLO_BASE });
62
25
  if (response.error) {
63
26
  context.logger.error("List sitemaps unhandled error", response.error);
64
27
  throw errors.INTERNAL_SERVER_ERROR();
@@ -69,7 +32,7 @@ const SEO_ROUTER_MAP = {
69
32
  scope: "internal",
70
33
  output: SitemapIndex
71
34
  }, async ({ context, errors }) => {
72
- const response = await context.service.wordpress.get("/seo/sitemaps/index", { base: WP_KIZLO_BASE });
35
+ const response = await context.wordpress.get("/seo/sitemaps/index", { base: WP_KIZLO_BASE });
73
36
  if (response.error) {
74
37
  context.logger.error("Get sitemap index unhandled error", response.error);
75
38
  throw errors.INTERNAL_SERVER_ERROR();
@@ -84,7 +47,7 @@ const SEO_ROUTER_MAP = {
84
47
  scope: "internal",
85
48
  output: Robots
86
49
  }, async ({ context, errors }) => {
87
- const response = await context.service.wordpress.get(`/seo/robots`, { base: WP_KIZLO_BASE });
50
+ const response = await context.wordpress.get(`/seo/robots`, { base: WP_KIZLO_BASE });
88
51
  if (response.error) {
89
52
  context.logger.error("List robots unhandled error", response.error);
90
53
  throw errors.INTERNAL_SERVER_ERROR();
@@ -103,7 +66,7 @@ const SEO_ROUTER_MAP = {
103
66
  output: SitemapUrlList,
104
67
  input: ListSitemapUrlInput
105
68
  }, async ({ context, input, errors }) => {
106
- const response = await context.service.wordpress.get(`/seo/sitemaps/${input.type}/${input.type !== "author" ? input.key : ""}`, {
69
+ const response = await context.wordpress.get(`/seo/sitemaps/${input.type}/${input.type !== "author" ? input.key : ""}`, {
107
70
  base: WP_KIZLO_BASE,
108
71
  searchParams: { page: input.page ?? 1 }
109
72
  });
@@ -20,9 +20,9 @@ declare const SeoHead: z.ZodObject<{
20
20
  description: z.ZodString;
21
21
  image: z.ZodNullable<z.ZodObject<{
22
22
  url: z.ZodString;
23
- width: z.ZodString;
24
- height: z.ZodString;
25
- type: z.ZodString;
23
+ width: z.ZodNullable<z.ZodNumber>;
24
+ height: z.ZodNullable<z.ZodNumber>;
25
+ type: z.ZodNullable<z.ZodString>;
26
26
  alt: z.ZodNullable<z.ZodString>;
27
27
  }, z.core.$strip>>;
28
28
  }, z.core.$strip>;
@@ -36,6 +36,7 @@ declare const SeoHead: z.ZodObject<{
36
36
  creator: z.ZodNullable<z.ZodString>;
37
37
  description: z.ZodString;
38
38
  image: z.ZodNullable<z.ZodString>;
39
+ imageAlt: z.ZodNullable<z.ZodString>;
39
40
  }, z.core.$strip>;
40
41
  article: z.ZodNullable<z.ZodObject<{
41
42
  publishedTime: z.ZodString;
@@ -43,6 +44,7 @@ declare const SeoHead: z.ZodObject<{
43
44
  author: z.ZodString;
44
45
  authorUrl: z.ZodString;
45
46
  section: z.ZodString;
47
+ tags: z.ZodArray<z.ZodString>;
46
48
  }, z.core.$strip>>;
47
49
  }, z.core.$strip>;
48
50
  type SeoHead = z.infer<typeof SeoHead>;
@@ -71,9 +73,9 @@ declare const Seo: z.ZodObject<{
71
73
  description: z.ZodString;
72
74
  image: z.ZodNullable<z.ZodObject<{
73
75
  url: z.ZodString;
74
- width: z.ZodString;
75
- height: z.ZodString;
76
- type: z.ZodString;
76
+ width: z.ZodNullable<z.ZodNumber>;
77
+ height: z.ZodNullable<z.ZodNumber>;
78
+ type: z.ZodNullable<z.ZodString>;
77
79
  alt: z.ZodNullable<z.ZodString>;
78
80
  }, z.core.$strip>>;
79
81
  }, z.core.$strip>;
@@ -87,6 +89,7 @@ declare const Seo: z.ZodObject<{
87
89
  creator: z.ZodNullable<z.ZodString>;
88
90
  description: z.ZodString;
89
91
  image: z.ZodNullable<z.ZodString>;
92
+ imageAlt: z.ZodNullable<z.ZodString>;
90
93
  }, z.core.$strip>;
91
94
  article: z.ZodNullable<z.ZodObject<{
92
95
  publishedTime: z.ZodString;
@@ -94,6 +97,7 @@ declare const Seo: z.ZodObject<{
94
97
  author: z.ZodString;
95
98
  authorUrl: z.ZodString;
96
99
  section: z.ZodString;
100
+ tags: z.ZodArray<z.ZodString>;
97
101
  }, z.core.$strip>>;
98
102
  }, z.core.$strip>;
99
103
  schema: z.ZodObject<{
@@ -21,9 +21,9 @@ const SeoHead = z.object({
21
21
  description: z.string(),
22
22
  image: z.object({
23
23
  url: z.string(),
24
- width: z.string(),
25
- height: z.string(),
26
- type: z.string(),
24
+ width: z.number().nullable(),
25
+ height: z.number().nullable(),
26
+ type: z.string().nullable(),
27
27
  alt: z.string().nullable()
28
28
  }).nullable()
29
29
  }),
@@ -33,14 +33,16 @@ const SeoHead = z.object({
33
33
  site: z.string().nullable(),
34
34
  creator: z.string().nullable(),
35
35
  description: z.string(),
36
- image: z.string().nullable()
36
+ image: z.string().nullable(),
37
+ imageAlt: z.string().nullable()
37
38
  }),
38
39
  article: z.object({
39
40
  publishedTime: z.string(),
40
41
  modifiedTime: z.string(),
41
42
  author: z.string(),
42
43
  authorUrl: z.string(),
43
- section: z.string()
44
+ section: z.string(),
45
+ tags: z.array(z.string())
44
46
  }).nullable()
45
47
  });
46
48
  const SeoSchema = z.object({
@@ -35,5 +35,13 @@ interface CreateSitemapRouteOptions {
35
35
  * integration) add mount assertions on top.
36
36
  */
37
37
  declare function createSitemapRoute(client: S2SClient<[]>, options?: CreateSitemapRouteOptions): (request: Request) => Promise<Response>;
38
+ /**
39
+ * Builds a handler that permanently redirects the well-known `/sitemap.xml` to the generated
40
+ * sitemap index at `/sitemaps/index.xml`. Crawlers probe the standard path regardless of what
41
+ * robots.txt advertises, so this points them at the real index. The target is derived from the
42
+ * same `SITEMAP_BASE`/`SITEMAP_INDEX_SLUG` constants the sitemap route is mounted on, so there is
43
+ * a single source of truth for where the index lives. Framework-agnostic like `createSitemapRoute`.
44
+ */
45
+ declare function createSitemapRedirectRoute(): (_request: Request) => Response;
38
46
  //#endregion
39
- export { CreateSitemapRouteOptions, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SitemapRouteExtra, createSitemapRoute };
47
+ export { CreateSitemapRouteOptions, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SitemapRouteExtra, createSitemapRedirectRoute, createSitemapRoute };
@@ -53,6 +53,22 @@ function createSitemapRoute(client, options) {
53
53
  return xmlResponse(renderUrlSet(data));
54
54
  };
55
55
  }
56
+ /**
57
+ * Builds a handler that permanently redirects the well-known `/sitemap.xml` to the generated
58
+ * sitemap index at `/sitemaps/index.xml`. Crawlers probe the standard path regardless of what
59
+ * robots.txt advertises, so this points them at the real index. The target is derived from the
60
+ * same `SITEMAP_BASE`/`SITEMAP_INDEX_SLUG` constants the sitemap route is mounted on, so there is
61
+ * a single source of truth for where the index lives. Framework-agnostic like `createSitemapRoute`.
62
+ */
63
+ function createSitemapRedirectRoute() {
64
+ const location = `${SITEMAP_BASE}/${SITEMAP_INDEX_SLUG}`;
65
+ return function GET(_request) {
66
+ return new Response(null, {
67
+ status: 308,
68
+ headers: { Location: location }
69
+ });
70
+ };
71
+ }
56
72
  function lastPathSegment(url) {
57
73
  return decodeURIComponent(url.pathname.split("/").filter(Boolean).pop() ?? "");
58
74
  }
@@ -61,4 +77,4 @@ function notFound() {
61
77
  }
62
78
 
63
79
  //#endregion
64
- export { SITEMAP_BASE, SITEMAP_INDEX_SLUG, createSitemapRoute };
80
+ export { SITEMAP_BASE, SITEMAP_INDEX_SLUG, createSitemapRedirectRoute, createSitemapRoute };
@@ -16,29 +16,31 @@ interface WPK_Seo {
16
16
  title: string;
17
17
  url: string;
18
18
  site_name: string;
19
- description: string;
20
- image: {
19
+ description?: string;
20
+ image?: {
21
21
  url: string;
22
- width: string;
23
- height: string;
24
- type: string;
22
+ width: number | null;
23
+ height: number | null;
24
+ type: string | null;
25
25
  alt: string | null;
26
- } | null;
26
+ };
27
27
  };
28
28
  twitter: {
29
- card: "summary_large_image";
29
+ card: "summary" | "summary_large_image";
30
30
  title: string;
31
31
  site: string | null;
32
32
  creator: string | null;
33
- description: string;
34
- image: string | null;
33
+ description?: string;
34
+ image?: string;
35
+ image_alt?: string;
35
36
  };
36
37
  article: {
37
- published_time: string;
38
- modified_time: string;
39
- author: string;
40
- author_url: string;
41
- section: string;
38
+ published_time?: string;
39
+ modified_time?: string;
40
+ author?: string;
41
+ author_url?: string;
42
+ section?: string;
43
+ tags?: string[];
42
44
  } | null;
43
45
  };
44
46
  schema: {
@@ -75,10 +77,5 @@ interface WPK_SitemapUrl {
75
77
  lastmod: string;
76
78
  images: WPK_SitemapUrlImage[];
77
79
  }
78
- interface WPK_ListSitemapUrlInput {
79
- type: WPK_SitemapContentType;
80
- key?: string;
81
- page?: number;
82
- }
83
80
  //#endregion
84
- export { WPK_ListSitemapUrlInput, WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapContentType, WPK_SitemapIndex, WPK_SitemapUrl, WPK_SitemapUrlImage };
81
+ export { WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapContentType, WPK_SitemapIndex, WPK_SitemapUrl, WPK_SitemapUrlImage };
package/dist/seo/utils.js CHANGED
@@ -3,15 +3,16 @@ function deserializeSeo(data) {
3
3
  return {
4
4
  head: {
5
5
  article: data.head.article ? {
6
- author: data.head.article.author,
7
- authorUrl: data.head.article.author_url,
8
- modifiedTime: data.head.article.modified_time,
9
- publishedTime: data.head.article.published_time,
10
- section: data.head.article.section
6
+ author: data.head.article.author ?? "",
7
+ authorUrl: data.head.article.author_url ?? "",
8
+ modifiedTime: data.head.article.modified_time ?? "",
9
+ publishedTime: data.head.article.published_time ?? "",
10
+ section: data.head.article.section ?? "",
11
+ tags: data.head.article.tags ?? []
11
12
  } : null,
12
13
  canonical: data.head.canonical,
13
14
  og: {
14
- description: data.head.og.description,
15
+ description: data.head.og.description ?? "",
15
16
  image: data.head.og.image ?? null,
16
17
  locale: data.head.og.locale,
17
18
  siteName: data.head.og.site_name,
@@ -30,8 +31,9 @@ function deserializeSeo(data) {
30
31
  twitter: {
31
32
  card: data.head.twitter.card,
32
33
  creator: data.head.twitter.creator,
33
- description: data.head.twitter.description,
34
+ description: data.head.twitter.description ?? "",
34
35
  image: data.head.twitter.image ?? null,
36
+ imageAlt: data.head.twitter.image_alt ?? null,
35
37
  site: data.head.twitter.site,
36
38
  title: data.head.twitter.title
37
39
  }
@@ -1,12 +1,14 @@
1
1
  import { createProcedure, schemaType } from "../shared/procedure.js";
2
2
 
3
3
  //#region src/settings/index.ts
4
- /** Shared error handling for every settings write: `invalid_param` → 400, anything else → 500. */
4
+ /** Shared error handling for every settings write: `invalid_param` → 400, `rest_forbidden` → 403, anything else → 500. */
5
5
  function resolveUpdate(response, context, errors, label) {
6
- if (response.error) {
7
- if (response.error.code === "invalid_param") throw errors.BAD_REQUEST({ message: response.error.message });
8
- context.logger.error(`${label} unhandled error`, response.error);
9
- throw errors.INTERNAL_SERVER_ERROR();
6
+ if (response.error) switch (response.error.code) {
7
+ case "invalid_param": throw errors.BAD_REQUEST({ message: response.error.message });
8
+ case "rest_forbidden": throw errors.FORBIDDEN({ message: response.error.message });
9
+ default:
10
+ context.logger.error(`${label} unhandled error`, response.error);
11
+ throw errors.INTERNAL_SERVER_ERROR();
10
12
  }
11
13
  return response.data;
12
14
  }
@@ -15,58 +17,59 @@ const SETTINGS_ROUTER_MAP = {
15
17
  scope: "internal",
16
18
  output: schemaType()
17
19
  }, async ({ context, errors }) => {
18
- const response = await context.service.settings.get();
20
+ const response = await context.settings.get();
19
21
  if (response.error) {
22
+ if (response.error.code === "rest_forbidden") throw errors.FORBIDDEN({ message: response.error.message });
20
23
  context.logger.error("Get settings unhandled error", response.error);
21
24
  throw errors.INTERNAL_SERVER_ERROR();
22
25
  }
23
26
  return response.data;
24
27
  }),
25
- updateSite: createProcedure({
28
+ site: { update: createProcedure({
26
29
  scope: "internal",
27
30
  input: schemaType(),
28
31
  output: schemaType()
29
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updateSite(input), context, errors, "Update site settings")),
30
- updateBrand: createProcedure({
32
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updateSite(input), context, errors, "Update site settings")) },
33
+ brand: { update: createProcedure({
31
34
  scope: "internal",
32
35
  input: schemaType(),
33
36
  output: schemaType()
34
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updateBrand(input), context, errors, "Update brand settings")),
35
- updateIdentity: createProcedure({
37
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updateBrand(input), context, errors, "Update brand settings")) },
38
+ identity: { update: createProcedure({
36
39
  scope: "internal",
37
40
  input: schemaType(),
38
41
  output: schemaType()
39
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updateIdentity(input), context, errors, "Update identity settings")),
40
- updateAuthors: createProcedure({
42
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updateIdentity(input), context, errors, "Update identity settings")) },
43
+ authors: { update: createProcedure({
41
44
  scope: "internal",
42
45
  input: schemaType(),
43
46
  output: schemaType()
44
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updateAuthors(input), context, errors, "Update authors settings")),
45
- updateCrawling: createProcedure({
47
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updateAuthors(input), context, errors, "Update authors settings")) },
48
+ crawling: { update: createProcedure({
46
49
  scope: "internal",
47
50
  input: schemaType(),
48
51
  output: schemaType()
49
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updateCrawling(input), context, errors, "Update crawling settings")),
50
- updateWebhook: createProcedure({
52
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updateCrawling(input), context, errors, "Update crawling settings")) },
53
+ webhook: { update: createProcedure({
51
54
  scope: "internal",
52
55
  input: schemaType(),
53
56
  output: schemaType()
54
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updateWebhook(input), context, errors, "Update webhook settings")),
55
- updateUploads: createProcedure({
57
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updateWebhook(input), context, errors, "Update webhook settings")) },
58
+ uploads: { update: createProcedure({
56
59
  scope: "internal",
57
60
  input: schemaType(),
58
61
  output: schemaType()
59
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updateUploads(input), context, errors, "Update uploads settings")),
60
- updatePostType: createProcedure({
62
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updateUploads(input), context, errors, "Update uploads settings")) },
63
+ postType: { update: createProcedure({
61
64
  scope: "internal",
62
65
  input: schemaType(),
63
66
  output: schemaType()
64
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updatePostType(input.slug, input.data), context, errors, "Update post type settings")),
65
- updateTaxonomy: createProcedure({
67
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updatePostType(input.key, input.data), context, errors, "Update post type settings")) },
68
+ taxonomy: { update: createProcedure({
66
69
  scope: "internal",
67
70
  input: schemaType(),
68
71
  output: schemaType()
69
- }, async ({ context, input, errors }) => resolveUpdate(await context.service.settings.updateTaxonomy(input.slug, input.data), context, errors, "Update taxonomy settings"))
72
+ }, async ({ context, input, errors }) => resolveUpdate(await context.settings.updateTaxonomy(input.key, input.data), context, errors, "Update taxonomy settings")) }
70
73
  };
71
74
 
72
75
  //#endregion
@@ -1,23 +1,24 @@
1
1
  import { WP_Result } from "../wordpress/types.js";
2
- import { AuthorsSettingsInput, BrandSettingsInput, CrawlingSettingsInput, IdentitySettingsInput, PostTypeSettingsInput, Settings, SiteSettingsInput, TaxonomySettingsInput, UploadsSettingsInput, WebhookSettingsInput } from "./service.interface.js";
3
- import { Service } from "../service.js";
2
+ import { WordPressService } from "../wordpress/service.js";
3
+ import "../wordpress/index.js";
4
+ import { AuthorsSettings, AuthorsSettingsInput, BrandSettings, BrandSettingsInput, CrawlingSettings, CrawlingSettingsInput, IdentitySettings, IdentitySettingsInput, PostTypeSettings, PostTypeSettingsInput, Settings, SiteSettings, SiteSettingsInput, TaxonomySettings, TaxonomySettingsInput, UploadsSettings, UploadsSettingsInput, WebhookSettings, WebhookSettingsInput } from "./service.interface.js";
4
5
  import "../index.js";
5
6
 
6
7
  //#region src/settings/service.d.ts
7
8
  declare class SettingsService {
8
- private readonly service;
9
- constructor(service: Service);
9
+ private readonly wordpress;
10
+ constructor(wordpress: WordPressService);
10
11
  /** Fetch every Kizlo settings section in one response. */
11
12
  get(): Promise<WP_Result<Settings, never>>;
12
- updateSite(input: SiteSettingsInput): Promise<WP_Result<null, "invalid_param">>;
13
- updateBrand(input: BrandSettingsInput): Promise<WP_Result<null, "invalid_param">>;
14
- updateWebhook(input: WebhookSettingsInput): Promise<WP_Result<null, "invalid_param">>;
15
- updateIdentity(input: IdentitySettingsInput): Promise<WP_Result<null, "invalid_param">>;
16
- updateAuthors(input: AuthorsSettingsInput): Promise<WP_Result<null, "invalid_param">>;
17
- updateCrawling(input: CrawlingSettingsInput): Promise<WP_Result<null, "invalid_param">>;
18
- updateUploads(input: UploadsSettingsInput): Promise<WP_Result<null, "invalid_param">>;
19
- updatePostType(slug: string, input: PostTypeSettingsInput): Promise<WP_Result<null, "invalid_param">>;
20
- updateTaxonomy(slug: string, input: TaxonomySettingsInput): Promise<WP_Result<null, "invalid_param">>;
13
+ updateSite(input: SiteSettingsInput): Promise<WP_Result<SiteSettings, "invalid_param">>;
14
+ updateBrand(input: BrandSettingsInput): Promise<WP_Result<BrandSettings, "invalid_param">>;
15
+ updateWebhook(input: WebhookSettingsInput): Promise<WP_Result<WebhookSettings, "invalid_param">>;
16
+ updateIdentity(input: IdentitySettingsInput): Promise<WP_Result<IdentitySettings, "invalid_param">>;
17
+ updateAuthors(input: AuthorsSettingsInput): Promise<WP_Result<AuthorsSettings, "invalid_param">>;
18
+ updateCrawling(input: CrawlingSettingsInput): Promise<WP_Result<CrawlingSettings, "invalid_param">>;
19
+ updateUploads(input: UploadsSettingsInput): Promise<WP_Result<UploadsSettings, "invalid_param">>;
20
+ updatePostType(key: string, input: PostTypeSettingsInput): Promise<WP_Result<PostTypeSettings, "invalid_param">>;
21
+ updateTaxonomy(key: string, input: TaxonomySettingsInput): Promise<WP_Result<TaxonomySettings, "invalid_param">>;
21
22
  private update;
22
23
  }
23
24
  //#endregion
@@ -20,7 +20,7 @@ type IdentitySettingsInput = Partial<{
20
20
  type AuthorsSettingsInput = Partial<AuthorsSettings>;
21
21
  type CrawlingSettingsInput = Partial<CrawlingSettings>;
22
22
  type UploadsSettingsInput = Partial<UploadsSettings>;
23
- type PostTypeSettingsInput = Partial<Pick<PostTypeSettings, "title_structure" | "description_structure" | "search_engine_visibility" | "webpage_type" | "article_type" | "seo_enabled" | "pathname_structure" | "comment_action_structure" | "rest_api_enabled" | "publicly_queryable" | "breadcrumbs">>;
24
- type TaxonomySettingsInput = Partial<Pick<TaxonomySettings, "title_structure" | "description_structure" | "search_engine_visibility" | "seo_enabled" | "pathname_structure" | "rest_api_enabled" | "publicly_queryable" | "breadcrumbs">>;
23
+ type PostTypeSettingsInput = Partial<Pick<PostTypeSettings, "title_structure" | "description_structure" | "search_engine_visibility" | "webpage_type" | "article_type" | "seo_enabled" | "pathname_structure" | "comment_action_structure" | "rest_api_enabled" | "breadcrumbs">>;
24
+ type TaxonomySettingsInput = Partial<Pick<TaxonomySettings, "title_structure" | "description_structure" | "search_engine_visibility" | "seo_enabled" | "pathname_structure" | "rest_api_enabled" | "breadcrumbs">>;
25
25
  //#endregion
26
26
  export { type AuthorsSettings, AuthorsSettingsInput, type BrandSettings, BrandSettingsInput, type CrawlingSettings, CrawlingSettingsInput, type IdentitySettings, IdentitySettingsInput, type OrganizationFounder, type OrganizationSettings, OrganizationSettingsInput, type PersonSettings, PersonSettingsInput, type PostStatusDefinition, type PostTypeSettings, PostTypeSettingsInput, type Settings, type SiteSettings, SiteSettingsInput, type SocialProfile, type TaxonomySettings, TaxonomySettingsInput, type UploadsSettings, UploadsSettingsInput, type WebhookSettings, WebhookSettingsInput };
@@ -2,13 +2,13 @@ import { WP_KIZLO_BASE } from "../wordpress/constants.js";
2
2
 
3
3
  //#region src/settings/service.ts
4
4
  var SettingsService = class {
5
- service;
6
- constructor(service) {
7
- this.service = service;
5
+ wordpress;
6
+ constructor(wordpress) {
7
+ this.wordpress = wordpress;
8
8
  }
9
9
  /** Fetch every Kizlo settings section in one response. */
10
10
  async get() {
11
- return this.service.wordpress.get("/settings", { base: WP_KIZLO_BASE });
11
+ return this.wordpress.get("/settings", { base: WP_KIZLO_BASE });
12
12
  }
13
13
  async updateSite(input) {
14
14
  return this.update("/settings/site", input);
@@ -31,14 +31,14 @@ var SettingsService = class {
31
31
  async updateUploads(input) {
32
32
  return this.update("/settings/uploads", input);
33
33
  }
34
- async updatePostType(slug, input) {
35
- return this.update(`/settings/post_types/${slug}`, input);
34
+ async updatePostType(key, input) {
35
+ return this.update(`/settings/post_types/${key}`, input);
36
36
  }
37
- async updateTaxonomy(slug, input) {
38
- return this.update(`/settings/taxonomies/${slug}`, input);
37
+ async updateTaxonomy(key, input) {
38
+ return this.update(`/settings/taxonomies/${key}`, input);
39
39
  }
40
40
  async update(path, body) {
41
- return this.service.wordpress.put(path, {
41
+ return this.wordpress.put(path, {
42
42
  base: WP_KIZLO_BASE,
43
43
  body
44
44
  });
@@ -1,11 +1,11 @@
1
1
  import { AnyContext } from "./types.js";
2
- import { ServerContext } from "../context.js";
2
+ import { ProcedureContext } from "../context.js";
3
3
  import { DefinedErrorMapLike } from "./error.js";
4
4
  import { BaseHandlerOptions } from "./procedure.js";
5
5
  import { UnionToIntersection } from "@kizlo/shared";
6
6
 
7
7
  //#region src/shared/middleware.d.ts
8
- type InferUses<T extends readonly AnyMiddleware[] | undefined> = T extends readonly [] ? object : T extends readonly AnyMiddleware[] ? UnionToIntersection<ExtractMiddlewareContextOutput<T[number]>> : object;
8
+ type InferMiddlewares<T extends readonly AnyMiddleware[] | undefined> = T extends readonly [] ? object : T extends readonly AnyMiddleware[] ? UnionToIntersection<ExtractMiddlewareContextOutput<T[number]>> : object;
9
9
  interface MiddlewareResult<TOutContext extends AnyContext, TOutput> {
10
10
  /** The handler's return value, as it flows back up through any middleware that awaited `next()`. */
11
11
  output: TOutput;
@@ -19,7 +19,7 @@ type MiddlewareNextFn<TOutput> = {
19
19
  context: UOutContext;
20
20
  }): Promise<MiddlewareResult<UOutContext, TOutput>>;
21
21
  };
22
- type MiddlewareOptions<TInput, TOutput, TError extends DefinedErrorMapLike> = BaseHandlerOptions<TInput, ServerContext, TError> & {
22
+ type MiddlewareOptions<TInput, TOutput, TError extends DefinedErrorMapLike> = BaseHandlerOptions<TInput, ProcedureContext, TError> & {
23
23
  /** Run the next middleware (or the handler) and return its result; pass `{ context }` to extend the context for everything downstream. */
24
24
  next: MiddlewareNextFn<TOutput>;
25
25
  };
@@ -29,4 +29,4 @@ type AnyMiddleware = Middleware<any, any, any, any>;
29
29
  type ExtractMiddlewareContextOutput<M> = M extends Middleware<any, any, any, infer TOut> ? TOut : never;
30
30
  declare function createMiddleware<TInput = any, TOutput = any, TError extends DefinedErrorMapLike = DefinedErrorMapLike, TOutContext extends AnyContext = AnyContext>(handler: MiddlewareHandler<TInput, TOutput, TError, TOutContext>): Middleware<TInput, TOutput, TError, TOutContext>;
31
31
  //#endregion
32
- export { AnyMiddleware, ExtractMiddlewareContextOutput, InferUses, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, createMiddleware };
32
+ export { AnyMiddleware, ExtractMiddlewareContextOutput, InferMiddlewares, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, createMiddleware };
@@ -1,6 +1,6 @@
1
- import { ServerContext } from "../context.js";
1
+ import { ProcedureContext } from "../context.js";
2
2
  import { DefinedErrorMapLike, ThrowableErrorMap, WithCommonErrorMap } from "./error.js";
3
- import { AnyMiddleware, InferUses, Middleware } from "./middleware.js";
3
+ import { AnyMiddleware, InferMiddlewares, Middleware } from "./middleware.js";
4
4
  import * as _orpc_contract0 from "@orpc/contract";
5
5
  import { DeepMerge, Pathname, Prettify, Promisify, Schema, SchemaInput, SchemaOutput } from "@kizlo/shared";
6
6
  import * as _orpc_server0 from "@orpc/server";
@@ -25,11 +25,11 @@ interface BaseHandlerOptions<TInput, TContext, TError extends DefinedErrorMapLik
25
25
  type InvocationScope = "internal" | "remote" | "api";
26
26
  /** Callable map of a procedure's declared error codes plus the built-in common HTTP errors. */
27
27
  type ProcedureErrors<TError extends DefinedErrorMapLike = DefinedErrorMapLike> = ThrowableErrorMap<WithCommonErrorMap<TError>>;
28
- type ProcedureHandler<TInput, TOutput, TError extends DefinedErrorMapLike, TContext extends ServerContext> = (options: BaseHandlerOptions<TInput, TContext, TError>) => Promisify<TOutput>;
28
+ type ProcedureHandler<TInput, TOutput, TError extends DefinedErrorMapLike, TContext extends ProcedureContext> = (options: BaseHandlerOptions<TInput, TContext, TError>) => Promisify<TOutput>;
29
29
  interface Procedure<TScope extends InvocationScope, TInput, TOutput, TError extends DefinedErrorMapLike = DefinedErrorMapLike> {
30
30
  "~kizlo": {
31
31
  uses: AnyMiddleware[];
32
- handler: ProcedureHandler<TInput, TOutput, TError, ServerContext>;
32
+ handler: ProcedureHandler<TInput, TOutput, TError, ProcedureContext>;
33
33
  options: {
34
34
  scope: TScope;
35
35
  errors?: TError;
@@ -56,7 +56,6 @@ interface Procedure<TScope extends InvocationScope, TInput, TOutput, TError exte
56
56
  };
57
57
  }
58
58
  type AnyProcedure = Procedure<InvocationScope, any, any, any>;
59
- type ProcedureContext<TMiddlewares extends AnyMiddleware[]> = ServerContext & InferUses<TMiddlewares>;
60
59
  type SchemaIO<TSchema, TMap extends "output" | "input"> = TMap extends "output" ? SchemaOutput<TSchema> : SchemaInput<TSchema>;
61
60
  type OpenapiPart<TKey extends string, TSchema, TMap extends "output" | "input"> = [TSchema] extends [never] ? unknown : [TSchema] extends [Schema] ? undefined extends SchemaIO<TSchema, TMap> ? { [K in TKey]?: SchemaIO<TSchema, TMap> } : { [K in TKey]: SchemaIO<TSchema, TMap> } : unknown;
62
61
  type ExtractParams<T extends string> = T extends `${string}{${infer Param}}${infer Rest}` ? { [K in Param | keyof ExtractParams<Rest>]: string } : object;
@@ -111,10 +110,10 @@ type ProcedureOptions<TScope extends InvocationScope, TPathname extends Pathname
111
110
  /** Schema for the call's single input argument. */
112
111
  input?: TInput;
113
112
  });
114
- declare function createProcedure<TScope extends InvocationScope, TPathname extends Pathname, TInput extends Schema | undefined = undefined, TBody extends Schema | undefined = undefined, TParams extends Schema | undefined = undefined, TQuery extends Schema | undefined = undefined, THeaders extends Schema | undefined = undefined, TOutput extends Schema = Schema, TError extends DefinedErrorMapLike = DefinedErrorMapLike, TMiddlewares extends Middleware<ResolvedSchemaOutput<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders>, SchemaOutput<TOutput>, TError>[] = Middleware<ResolvedSchemaOutput<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders>, SchemaOutput<TOutput>, TError>[], TContext extends ProcedureContext<TMiddlewares> = ProcedureContext<TMiddlewares>>(options: ProcedureOptions<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders, TOutput, TError, TMiddlewares>, handler: ProcedureHandler<ResolvedSchemaOutput<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders>, SchemaOutput<TOutput>, TError, TContext>): Procedure<TScope, ResolvedSchemaInput<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders>, TScope extends "api" ? JsonifiedValue<SchemaOutput<TOutput>> : SchemaOutput<TOutput>, TError>;
113
+ declare function createProcedure<TScope extends InvocationScope, TPathname extends Pathname, TInput extends Schema | undefined = undefined, TBody extends Schema | undefined = undefined, TParams extends Schema | undefined = undefined, TQuery extends Schema | undefined = undefined, THeaders extends Schema | undefined = undefined, TOutput extends Schema = Schema, TError extends DefinedErrorMapLike = DefinedErrorMapLike, TMiddlewares extends Middleware<ResolvedSchemaOutput<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders>, SchemaOutput<TOutput>, TError>[] = Middleware<ResolvedSchemaOutput<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders>, SchemaOutput<TOutput>, TError>[], TContext extends ProcedureContext & InferMiddlewares<TMiddlewares> = ProcedureContext & InferMiddlewares<TMiddlewares>>(options: ProcedureOptions<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders, TOutput, TError, TMiddlewares>, handler: ProcedureHandler<ResolvedSchemaOutput<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders>, SchemaOutput<TOutput>, TError, TContext>): Procedure<TScope, ResolvedSchemaInput<TScope, TPathname, TInput, TBody, TParams, TQuery, THeaders>, TScope extends "api" ? JsonifiedValue<SchemaOutput<TOutput>> : SchemaOutput<TOutput>, TError>;
115
114
  declare function schemaType<TInput, TOutput = TInput>(schema?: Schema): Schema<TInput, TOutput>;
116
115
  declare function buildProcedure(procedure: AnyProcedure): _orpc_server0.DecoratedProcedure<_orpc_server0.Context & Record<never, never>, _orpc_server0.Context, _orpc_contract0.Schema<unknown, unknown>, _orpc_contract0.Schema<any, any>, Record<never, never>, Record<never, never>>;
117
116
  declare function handleUnexpectedError(error: unknown, errors?: DefinedErrorMapLike): never;
118
117
  declare function combineDetailed(parts: Record<string, Schema>): Schema;
119
118
  //#endregion
120
- export { AnyProcedure, AnyProcedureRouter, BaseHandlerOptions, ExtractParams, ExtractProcedureByScope, InvocationScope, OpenapiPart, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureOptions, ResolveParamsPart, ResolvedSchemaInput, ResolvedSchemaOutput, RouterDepthTuple, SchemaIO, buildProcedure, combineDetailed, createProcedure, handleUnexpectedError, schemaType };
119
+ export { AnyProcedure, AnyProcedureRouter, BaseHandlerOptions, ExtractParams, ExtractProcedureByScope, InvocationScope, OpenapiPart, Procedure, ProcedureErrors, ProcedureHandler, ProcedureOptions, ResolveParamsPart, ResolvedSchemaInput, ResolvedSchemaOutput, RouterDepthTuple, SchemaIO, buildProcedure, combineDetailed, createProcedure, handleUnexpectedError, schemaType };
@@ -0,0 +1,14 @@
1
+ import { defineErrorMap } from "../shared/error.js";
2
+
3
+ //#region src/tag/error.ts
4
+ const GET_TAG_ERROR_MAP = defineErrorMap({ TAG_NOT_FOUND: {
5
+ status: 404,
6
+ message: "Tag not found"
7
+ } });
8
+ const LIST_TAG_ERROR_MAP = defineErrorMap({ TAG_INVALID_PAGE: {
9
+ status: 400,
10
+ message: "The requested page does not exist."
11
+ } });
12
+
13
+ //#endregion
14
+ export { GET_TAG_ERROR_MAP, LIST_TAG_ERROR_MAP };