kizlo 0.21.0 → 0.22.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.
@@ -1,5 +1,5 @@
1
1
  import { log } from "../daemon/logger.js";
2
- import { callRoute, describeRoute, listRoutes } from "./tools.js";
2
+ import { callRoute, describeRoute, searchRoutes } from "./tools.js";
3
3
  import z from "zod/v4";
4
4
  import { createServer } from "node:http";
5
5
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -38,21 +38,92 @@ function isAllowedOrigin(origin) {
38
38
  return false;
39
39
  }
40
40
  }
41
- /** Render a tool's answer as the MCP content block a client reads, failures included. */
42
- function toolContent(result) {
41
+ /**
42
+ * Render a tool's answer for both kinds of reader: `structuredContent` for a client that parses, and
43
+ * a text block for one that does not.
44
+ *
45
+ * A failure carries no `structuredContent`. A client validates whatever it finds there against the
46
+ * tool's declared output schema whether or not the result is an error, and a failure is not that
47
+ * shape, so putting it there makes a client reject the answer outright instead of reading it. The
48
+ * detail rides in a second text block, which keeps it machine-readable without breaking the contract.
49
+ */
50
+ function toolContent(result, summarize = (value) => JSON.stringify(value, null, 2)) {
43
51
  if (!result.ok) return {
44
52
  content: [{
45
53
  type: "text",
46
- text: result.error
54
+ text: result.error.message
55
+ }, {
56
+ type: "text",
57
+ text: JSON.stringify(result.error, null, 2)
47
58
  }],
48
59
  isError: true
49
60
  };
50
- return { content: [{
51
- type: "text",
52
- text: JSON.stringify(result.value, null, 2)
53
- }] };
61
+ return {
62
+ content: [{
63
+ type: "text",
64
+ text: summarize(result.value)
65
+ }],
66
+ structuredContent: result.value
67
+ };
54
68
  }
55
69
  /**
70
+ * The one result long enough to be worth compressing. Describe and call put their payload in the
71
+ * text block because the payload is the answer; a ranked list is better read than parsed.
72
+ */
73
+ function summarizeSearch(value) {
74
+ const outcome = value;
75
+ if (outcome.count === 0) return outcome.message ?? "No route matches that search.";
76
+ const lines = outcome.routes.map((route) => {
77
+ const evidence = route.evidence.map((item) => `${item.field}:${item.term}`).join(", ");
78
+ const summary = route.summary === void 0 ? "" : ` — ${route.summary}`;
79
+ const deprecated = route.deprecated ? " (deprecated)" : "";
80
+ return `${route.name} — ${route.method} ${route.path}${summary}${deprecated}${evidence === "" ? "" : ` [${evidence}]`}`;
81
+ });
82
+ const more = outcome.nextCursor === void 0 ? "" : `\n${outcome.count - outcome.routes.length} more. Pass cursor "${outcome.nextCursor}" for the next page.`;
83
+ return `${outcome.count} route${outcome.count === 1 ? "" : "s"} match:\n${lines.join("\n")}${more}`;
84
+ }
85
+ /** A ranked result, and the named part of the contract that selected it. */
86
+ const SEARCH_OUTPUT = {
87
+ count: z.number().describe("Matches across the whole catalog, not just this page."),
88
+ routes: z.array(z.object({
89
+ name: z.string(),
90
+ namespace: z.string(),
91
+ method: z.string(),
92
+ path: z.string(),
93
+ summary: z.string().optional(),
94
+ deprecated: z.literal(true).optional(),
95
+ evidence: z.array(z.object({
96
+ field: z.string(),
97
+ term: z.string()
98
+ }))
99
+ })),
100
+ namespaces: z.array(z.string()).describe("Every REST namespace this WordPress serves."),
101
+ nextCursor: z.string().optional().describe("Hand back as `cursor` to read the next page."),
102
+ message: z.string().optional().describe("Present only when nothing matched.")
103
+ };
104
+ const DESCRIBE_OUTPUT = {
105
+ name: z.string(),
106
+ namespace: z.string(),
107
+ method: z.string(),
108
+ path: z.string(),
109
+ summary: z.string().optional(),
110
+ description: z.string().optional(),
111
+ deprecated: z.literal(true).optional(),
112
+ pathParameters: z.array(z.string()),
113
+ input: z.record(z.string(), z.unknown()).describe("JSON Schema for `{ params, query, body }`, with its `$defs`."),
114
+ responses: z.record(z.string(), z.unknown()).describe("Keyed by HTTP status."),
115
+ errors: z.array(z.string()).describe("Error codes this route declares.")
116
+ };
117
+ /**
118
+ * Deliberately permissive. The SDK validates `structuredContent` against this on every successful
119
+ * call, so anything narrower would turn a route whose response does not fit into a protocol error
120
+ * rather than an answer.
121
+ */
122
+ const CALL_OUTPUT = {
123
+ status: z.number(),
124
+ data: z.unknown().optional()
125
+ };
126
+ /**
56
127
  * Three dispatchers rather than a tool per route. The contract a seeded WordPress serves runs to well
57
128
  * over a hundred routes, and putting their schemas in front of a model up front would cost tens of
58
129
  * thousands of tokens in every message. These cost a few hundred and reach all of them — and because
@@ -63,24 +134,44 @@ function createMcpServer(state) {
63
134
  const server = new McpServer({
64
135
  name: "kizlo",
65
136
  version: "1.0.0"
66
- }, { instructions: "Read and call the WordPress REST routes of the Kizlo project this server was started in." });
67
- server.registerTool("kizlo_list_routes", {
68
- title: "List WordPress routes",
69
- description: "List every REST route this project's WordPress serves, with its method and summary. Start here: the route names it returns are what `kizlo_describe_route` and `kizlo_call` take.",
70
- inputSchema: { namespace: z.string().optional().describe("Only routes in this REST namespace, e.g. \"wp/v2\" or \"kizlo/v1\".") }
71
- }, async ({ namespace }) => toolContent(listRoutes(state, namespace === void 0 ? {} : { namespace })));
137
+ }, { instructions: [
138
+ "Read and change the WordPress of the Kizlo project this server was started in.",
139
+ "Every REST route that WordPress exposes is reachable here — core, Kizlo's own, and any plugin's — through three tools rather than one tool per route.",
140
+ "Work in that order: `kizlo_search_routes` to find a route, `kizlo_describe_route` to read its contract, `kizlo_call` to run it.",
141
+ "Describe a route before calling it unless you already know its contract. Arguments are grouped into `params`, `query`, and `body`, and the description says which fields belong where.",
142
+ "API errors are passed through unchanged: the code, message, and data are WordPress's own, not this server's summary of them."
143
+ ].join(" ") });
144
+ server.registerTool("kizlo_search_routes", {
145
+ title: "Search WordPress routes",
146
+ description: "Find routes by identity or by meaning: a route name, path, or namespace, or terms from a route's arguments, response fields, description, or error codes. Start here. Omit `query` to browse the whole catalog. Each result names the evidence that selected it, and the route names it returns are what `kizlo_describe_route` and `kizlo_call` take.",
147
+ inputSchema: {
148
+ query: z.string().optional().describe("Terms to rank on. Omit or leave empty to browse every route."),
149
+ namespace: z.string().optional().describe("Only routes in this REST namespace, e.g. \"wp/v2\" or \"kizlo/v1\"."),
150
+ method: z.string().optional().describe("Only routes served with this HTTP method, e.g. \"GET\"."),
151
+ access: z.enum(["read", "write"]).optional().describe("Only reading routes (GET, HEAD, OPTIONS) or only writing ones."),
152
+ limit: z.number().int().optional().describe("Results per page. Defaults to 20, at most 100."),
153
+ cursor: z.string().optional().describe("The `nextCursor` from a previous search, to read the next page.")
154
+ },
155
+ outputSchema: SEARCH_OUTPUT
156
+ }, async (input) => toolContent(searchRoutes(state, input), summarizeSearch));
72
157
  server.registerTool("kizlo_describe_route", {
73
158
  title: "Describe a WordPress route",
74
- description: "The JSON Schema for one route's arguments, plus which of them are interpolated into its path.",
75
- inputSchema: { route: z.string().describe("A route name from `kizlo_list_routes`, e.g. `postTypes.book.list`.") }
159
+ description: "The complete contract for one route: the JSON Schema for its `params`, `query`, and `body`, with the definitions they reference; the response schema for each HTTP status, with content types and headers; which arguments are interpolated into the path; and the error codes the route declares.",
160
+ inputSchema: { route: z.string().describe("A route name from `kizlo_search_routes`, e.g. `kizlo.postTypes.book.list`.") },
161
+ outputSchema: DESCRIBE_OUTPUT
76
162
  }, async ({ route }) => toolContent(describeRoute(state, { route })));
77
163
  server.registerTool("kizlo_call", {
78
164
  title: "Call a WordPress route",
79
- description: "Run one route against this project's WordPress and return its response. Path parameters, query parameters, and body fields all go in `input`; `kizlo_describe_route` says which are which.",
165
+ description: "Run one route against this project's WordPress and return its response. Arguments go in `input` under the part they belong to: `params` for the values interpolated into the path, `query` for query parameters, and `body` for the payload. `kizlo_describe_route` says which are which.",
80
166
  inputSchema: {
81
- route: z.string().describe("A route name from `kizlo_list_routes`."),
82
- input: z.record(z.string(), z.unknown()).optional().describe("The route's arguments, as described by `kizlo_describe_route`.")
83
- }
167
+ route: z.string().describe("A route name from `kizlo_search_routes`."),
168
+ input: z.object({
169
+ params: z.record(z.string(), z.unknown()).optional().describe("Values interpolated into the path."),
170
+ query: z.record(z.string(), z.unknown()).optional().describe("Query parameters."),
171
+ body: z.unknown().optional().describe("The request payload.")
172
+ }).optional().describe("The route's arguments, grouped as `kizlo_describe_route` describes them.")
173
+ },
174
+ outputSchema: CALL_OUTPUT
84
175
  }, async ({ route, input }) => toolContent(await callRoute(state, input === void 0 ? { route } : {
85
176
  route,
86
177
  input
@@ -1,52 +1,54 @@
1
1
  import { buildWordPressRequest } from "../../wordpress/endpoint.js";
2
2
  import { WordPressTransport } from "../../wordpress/transport.js";
3
- import { routesOf, sortRoutes } from "./routes.js";
4
- import { toJsonSchema } from "./schema.js";
3
+ import { routesOf } from "./routes.js";
4
+ import { inputJsonSchema, toJsonSchema } from "./schema.js";
5
+ import { searchRoutes } from "./search.js";
5
6
 
6
7
  //#region src/cli/mcp/tools.ts
7
8
  /** The document is fetched by the watcher, so the only reason it is missing is that none has arrived yet. */
8
9
  const NO_DOCUMENT = "The WordPress contract has not been fetched yet. Retry in a moment; `kizlo dev` refreshes it every few seconds.";
9
- /** Summaries only. The schemas behind these routes are far too large to put in front of a model at once. */
10
- function listRoutes(state, input = {}) {
11
- if (!state.document) return {
10
+ function failed(message) {
11
+ return {
12
12
  ok: false,
13
- error: NO_DOCUMENT
13
+ error: {
14
+ kind: "request",
15
+ message
16
+ }
14
17
  };
15
- const all = sortRoutes(routesOf(state.document).values());
16
- const routes = input.namespace ? all.filter((route) => route.namespace === input.namespace) : all;
17
- if (input.namespace && routes.length === 0) {
18
- const known = [...new Set(all.map((route) => route.namespace))].sort();
18
+ }
19
+ /**
20
+ * Rank the routes this WordPress serves against a query, or browse them all when there is none.
21
+ *
22
+ * Summaries and match evidence only. The schemas behind these routes are far too large to put in
23
+ * front of a model at once, which is what `kizlo_describe_route` is for.
24
+ */
25
+ function searchRoutes$1(state, input = {}) {
26
+ if (!state.document) return failed(NO_DOCUMENT);
27
+ const outcome = searchRoutes(state.document, input);
28
+ if (outcome.count === 0) {
29
+ const within = [
30
+ input.namespace !== void 0 ? `namespace "${input.namespace}"` : void 0,
31
+ input.method !== void 0 ? `method ${input.method.toUpperCase()}` : void 0,
32
+ input.access !== void 0 ? `${input.access} routes` : void 0
33
+ ].filter((part) => part !== void 0).join(", ");
19
34
  return {
20
- ok: false,
21
- error: `No routes in namespace "${input.namespace}". This WordPress serves: ${known.join(", ")}.`
35
+ ok: true,
36
+ value: {
37
+ ...outcome,
38
+ message: `No route matches that search${within === "" ? "" : ` within ${within}`}. This WordPress serves these namespaces: ${outcome.namespaces.join(", ")}.`
39
+ }
22
40
  };
23
41
  }
24
42
  return {
25
43
  ok: true,
26
- value: {
27
- count: routes.length,
28
- routes: routes.map((route) => ({
29
- name: route.name,
30
- namespace: route.namespace,
31
- method: route.method,
32
- path: route.path,
33
- ...route.summary !== void 0 ? { summary: route.summary } : {},
34
- ...route.deprecated ? { deprecated: true } : {}
35
- }))
36
- }
44
+ value: outcome
37
45
  };
38
46
  }
39
- /** The full argument schema for one route, which is what a caller needs before it can build a call. */
47
+ /** The full contract for one route, which is what a caller needs before it can build a call. */
40
48
  function describeRoute(state, input) {
41
- if (!state.document) return {
42
- ok: false,
43
- error: NO_DOCUMENT
44
- };
49
+ if (!state.document) return failed(NO_DOCUMENT);
45
50
  const route = routesOf(state.document).get(input.route);
46
- if (!route) return {
47
- ok: false,
48
- error: unknownRoute(input.route)
49
- };
51
+ if (!route) return failed(unknownRoute(input.route));
50
52
  return {
51
53
  ok: true,
52
54
  value: {
@@ -58,34 +60,36 @@ function describeRoute(state, input) {
58
60
  ...route.description !== void 0 ? { description: route.description } : {},
59
61
  ...route.deprecated ? { deprecated: true } : {},
60
62
  pathParameters: route.definition.pathParameters,
61
- input: toJsonSchema(route.operation.input, state.document)
63
+ input: inputJsonSchema(route.operation.input, state.document),
64
+ responses: responseSchemas(route.operation.responses, state.document),
65
+ errors: route.operation.errors
62
66
  }
63
67
  };
64
68
  }
65
69
  /** Run one route against the connected WordPress and hand back what it answered. */
66
70
  async function callRoute(state, input) {
67
- if (!state.document) return {
68
- ok: false,
69
- error: NO_DOCUMENT
70
- };
71
- if (!state.credentials) return {
72
- ok: false,
73
- error: "No WordPress connection is configured, so nothing can be called. Check the connection settings in `.env`."
74
- };
71
+ if (!state.document) return failed(NO_DOCUMENT);
72
+ if (!state.credentials) return failed("No WordPress connection is configured, so nothing can be called. Check the connection settings in `.env`.");
75
73
  const route = routesOf(state.document).get(input.route);
76
- if (!route) return {
77
- ok: false,
78
- error: unknownRoute(input.route)
79
- };
74
+ if (!route) return failed(unknownRoute(input.route));
80
75
  const built = buildWordPressRequest(route.definition, input.input ?? {});
81
- if (built.error) return {
82
- ok: false,
83
- error: built.error.message
84
- };
76
+ if (built.error) return failed(built.error.message);
85
77
  const response = await new WordPressTransport({ credentials: state.credentials }).request(built.request);
86
78
  if (response.error) return {
87
79
  ok: false,
88
- error: `${route.method} ${route.path} failed (${response.status || "no response"}): ${response.error.code} — ${response.error.message}`
80
+ error: {
81
+ kind: "response",
82
+ message: `${route.method} ${route.path} failed (${response.status || "no response"}): ${response.error.code} — ${response.error.message}`,
83
+ route: route.name,
84
+ method: route.method,
85
+ path: route.path,
86
+ status: response.status,
87
+ error: {
88
+ code: response.error.code,
89
+ message: response.error.message,
90
+ data: response.error.data
91
+ }
92
+ }
89
93
  };
90
94
  return {
91
95
  ok: true,
@@ -95,9 +99,18 @@ async function callRoute(state, input) {
95
99
  }
96
100
  };
97
101
  }
102
+ /** The response half of the contract, converted so a caller can read a success or a failure body. */
103
+ function responseSchemas(responses, document) {
104
+ return Object.fromEntries(Object.entries(responses).map(([status, response]) => [status, {
105
+ ...response.description !== void 0 ? { description: response.description } : {},
106
+ ...response.content_type !== void 0 ? { content_type: response.content_type } : {},
107
+ ...response.headers ? { headers: toJsonSchema(response.headers, document) } : {},
108
+ ...response.body ? { body: toJsonSchema(response.body, document) } : {}
109
+ }]));
110
+ }
98
111
  function unknownRoute(name) {
99
- return `No route named "${name}" in this WordPress contract. Call \`kizlo_list_routes\` for the routes it serves.`;
112
+ return `No route named "${name}" in this WordPress contract. Call \`kizlo_search_routes\` for the routes it serves.`;
100
113
  }
101
114
 
102
115
  //#endregion
103
- export { callRoute, describeRoute, listRoutes };
116
+ export { callRoute, describeRoute, searchRoutes$1 as searchRoutes };
@@ -17,8 +17,8 @@ const COMMENT_PROCEDURES = {
17
17
  output: Comment
18
18
  }, async ({ context, errors, input }) => {
19
19
  const response = await context.wordpress.comments.retrieve({
20
- id: input.params.id,
21
- password: input.query?.password
20
+ params: { id: input.params.id },
21
+ query: { password: input.query?.password }
22
22
  });
23
23
  if (response.error) switch (response.error.code) {
24
24
  case "rest_comment_invalid_id":
@@ -63,7 +63,7 @@ const COMMENT_PROCEDURES = {
63
63
  post: listed(input.query?.post),
64
64
  search: input.query?.search
65
65
  };
66
- const response = await context.wordpress.comments.list(searchParams);
66
+ const response = await context.wordpress.comments.list({ query: searchParams });
67
67
  if (response.error) switch (response.error.code) {
68
68
  case "rest_cannot_read":
69
69
  case "rest_cannot_read_post":
@@ -114,7 +114,7 @@ const COMMENT_PROCEDURES = {
114
114
  author_url: input.body.authorUrl,
115
115
  parent: input.body.parentId
116
116
  };
117
- const response = await context.wordpress.kizlo.comments.create(submission);
117
+ const response = await context.wordpress.kizlo.comments.create({ body: submission });
118
118
  if (response.error) switch (response.error.code) {
119
119
  case "require_name_email": throw errors.COMMENT_NAME_EMAIL_REQUIRED();
120
120
  case "require_valid_email": throw errors.COMMENT_INVALID_EMAIL();
@@ -5,7 +5,7 @@ var EmailService = class {
5
5
  this.wordpress = wordpress;
6
6
  }
7
7
  async send(params) {
8
- const { error } = await this.wordpress.email.send(params);
8
+ const { error } = await this.wordpress.kizlo.email.send({ body: params });
9
9
  if (error) throw error;
10
10
  }
11
11
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WP_Error } from "./wordpress/error.js";
2
- import { ActiveWordPressClient, WP_CallOptions, WP_Client, WP_CommonErrorCode, WP_CurrencyFormat, WP_CustomFields, WP_CustomFieldsPath, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointError, WP_EndpointInput, WP_EndpointPath, WP_EndpointResult, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_ResponseContentType, WP_Result, WP_Success, WP_TransportFailure, WP_TypedHeaders, WordPressClientRegistry, WordPressCredentials, WordPressCustomFieldsRegistry, WordPressEndpointRegistry } from "./wordpress/types.js";
2
+ import { ActiveWordPressClient, WP_CallOptions, WP_Client, WP_CommonErrorCode, WP_CurrencyFormat, WP_CustomFields, WP_CustomFieldsPath, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointError, WP_EndpointInput, WP_EndpointPath, WP_EndpointResult, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_RequestParts, WP_ResponseContentType, WP_Result, WP_Success, WP_TransportFailure, WP_TypedHeaders, WordPressClientRegistry, WordPressCredentials, WordPressCustomFieldsRegistry, WordPressEndpointRegistry } from "./wordpress/types.js";
3
3
  import { WordPressTransport, WordPressTransportOptions, WordPressTransportResult } from "./wordpress/transport.js";
4
4
  import { buildWordPressRequest, createWordPressClient, wpEndpoint } from "./wordpress/endpoint.js";
5
5
  import { isWordPressResourceError } from "./wordpress/utils.js";
@@ -43,4 +43,4 @@ import { ShaAlgorithm, compare, hash, hmac } from "./shared/crypto.js";
43
43
  import { Identifier, parseIdentifier } from "./shared/identifier.js";
44
44
  import { createOrpcRouter } from "./shared/router.js";
45
45
  import { deserializeCurrencyFormat, deserializeListMetadata, emptyList, serializeCurrencyFormat } from "./shared/serialize.js";
46
- export { ActiveWordPressClient, AnyContext, AnyEventSchema, AnyEvents, AnyIntegration, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureTree, AuthAdapter, AuthGetSession, AuthUser, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CaptchaAdapter, type Category, type CategoryCustomFields, CategoryCustomFieldsSchema, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, ConnInfo, ConnInfoFn, ConsoleLogAdapterOptions, ContentType, Context, ContextConfig, Contract, ContractProcedure, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, CookiesStorage, CoreProcedures, CrawlingSettings, CrawlingSettingsInput, CreateKizloOptions, CreateSitemapRouteOptions, CurrencyFormat, DefinedErrorMapLike, DevPluginSource, EnvReader, EnvRecord, EnvSource, ErrorDefinition, EventHandler, EventHandlerFn, ExtractIntegrationProcedures, ExtractMiddlewareContextOutput, ExtractParams, ExtractProcedureByScope, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, GeoAdapter, GeoGetConnInfo, HTTPMethod, HeadlessSettings, HeadlessSettingsInput, IconDescriptor, Identifier, IdentifierInput, IdentitySettings, IdentitySettingsInput, InferEventUnion, InferIntegrationProcedures, InferMiddlewares, InferProcedureData, InferProcedureError, InferProcedureInput, InferProcedureResult, Integration, IntegrationRequirements, InvocationScope, JsonValue, Kizlo, KizloClient, KizloClientConfig, KizloConfig, KizloEnv, KizloError, KizloErrorOptions, KizloErrorUnion, KizloResult, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeCallerOptions, MaybeOptionalOptions, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, type Page, type PageCustomFields, PageCustomFieldsSchema, PersonSettings, PersonSettingsInput, PluginSource, type Post, type PostCustomFields, PostCustomFieldsSchema, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureMethod, ProcedureOptions, ProcedureTreeDepthTuple, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, ResultClient, Robots, RobotsRule, RootProcedures, S2SClient, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, SessionFn, Settings, SettingsService, SettleContext, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, type Tag, type TagCustomFields, TagCustomFieldsSchema, TaxonomySettings, TaxonomySettingsInput, TestAdminUser, TestCredentials, TestUser, ThrowableErrorFn, ThrowableErrorMap, UploadsSettings, UploadsSettingsInput, VerifyCaptchaFn, VerifyPreviewTokenFn, WEB_MANIFEST_ROUTE, WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapUrl, WPK_SitemapUrlImage, WP_CallOptions, WP_Client, WP_CommonErrorCode, WP_CurrencyFormat, WP_CustomFields, WP_CustomFieldsPath, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointError, WP_EndpointInput, WP_EndpointPath, WP_EndpointResult, WP_Error, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_ResponseContentType, WP_Result, WP_Success, WP_TransportFailure, WP_TypedHeaders, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressClientRegistry, WordPressCredentials, WordPressCustomFieldsRegistry, WordPressEndpointRegistry, WordPressEnv, WordPressTransport, WordPressTransportOptions, WordPressTransportResult, altcha, arkose, assertIntegrationEndpoints, assertIntegrationEnv, authMock, buildProcedure, buildWebManifest, buildWordPressRequest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createGeoAdapter, createIntegration, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createResultClient, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, createWordPressClient, customFieldsSchema, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, integrationEnv, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, mergeServiceAdapters, missingEndpoints, missingEnv, noopAdapter, parseIdentifier, parseSitemapSlug, readEnv, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, resolveWordPressConnection, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, sortIntegrations, toKizloError, turnstile, wordPressConnectionComplete, wpEndpoint, xmlResponse };
46
+ export { ActiveWordPressClient, AnyContext, AnyEventSchema, AnyEvents, AnyIntegration, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureTree, AuthAdapter, AuthGetSession, AuthUser, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CaptchaAdapter, type Category, type CategoryCustomFields, CategoryCustomFieldsSchema, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, ConnInfo, ConnInfoFn, ConsoleLogAdapterOptions, ContentType, Context, ContextConfig, Contract, ContractProcedure, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, CookiesStorage, CoreProcedures, CrawlingSettings, CrawlingSettingsInput, CreateKizloOptions, CreateSitemapRouteOptions, CurrencyFormat, DefinedErrorMapLike, DevPluginSource, EnvReader, EnvRecord, EnvSource, ErrorDefinition, EventHandler, EventHandlerFn, ExtractIntegrationProcedures, ExtractMiddlewareContextOutput, ExtractParams, ExtractProcedureByScope, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, GeoAdapter, GeoGetConnInfo, HTTPMethod, HeadlessSettings, HeadlessSettingsInput, IconDescriptor, Identifier, IdentifierInput, IdentitySettings, IdentitySettingsInput, InferEventUnion, InferIntegrationProcedures, InferMiddlewares, InferProcedureData, InferProcedureError, InferProcedureInput, InferProcedureResult, Integration, IntegrationRequirements, InvocationScope, JsonValue, Kizlo, KizloClient, KizloClientConfig, KizloConfig, KizloEnv, KizloError, KizloErrorOptions, KizloErrorUnion, KizloResult, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeCallerOptions, MaybeOptionalOptions, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, type Page, type PageCustomFields, PageCustomFieldsSchema, PersonSettings, PersonSettingsInput, PluginSource, type Post, type PostCustomFields, PostCustomFieldsSchema, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureMethod, ProcedureOptions, ProcedureTreeDepthTuple, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, ResultClient, Robots, RobotsRule, RootProcedures, S2SClient, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, SessionFn, Settings, SettingsService, SettleContext, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, type Tag, type TagCustomFields, TagCustomFieldsSchema, TaxonomySettings, TaxonomySettingsInput, TestAdminUser, TestCredentials, TestUser, ThrowableErrorFn, ThrowableErrorMap, UploadsSettings, UploadsSettingsInput, VerifyCaptchaFn, VerifyPreviewTokenFn, WEB_MANIFEST_ROUTE, WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapUrl, WPK_SitemapUrlImage, WP_CallOptions, WP_Client, WP_CommonErrorCode, WP_CurrencyFormat, WP_CustomFields, WP_CustomFieldsPath, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointError, WP_EndpointInput, WP_EndpointPath, WP_EndpointResult, WP_Error, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_RequestParts, WP_ResponseContentType, WP_Result, WP_Success, WP_TransportFailure, WP_TypedHeaders, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressClientRegistry, WordPressCredentials, WordPressCustomFieldsRegistry, WordPressEndpointRegistry, WordPressEnv, WordPressTransport, WordPressTransportOptions, WordPressTransportResult, altcha, arkose, assertIntegrationEndpoints, assertIntegrationEnv, authMock, buildProcedure, buildWebManifest, buildWordPressRequest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createGeoAdapter, createIntegration, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createResultClient, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, createWordPressClient, customFieldsSchema, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, integrationEnv, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, mergeServiceAdapters, missingEndpoints, missingEnv, noopAdapter, parseIdentifier, parseSitemapSlug, readEnv, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, resolveWordPressConnection, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, sortIntegrations, toKizloError, turnstile, wordPressConnectionComplete, wpEndpoint, xmlResponse };
@@ -3,7 +3,7 @@ import { listed, stringifiedMetaRecord } from "@kizlo/shared";
3
3
  //#region src/menu/utils.ts
4
4
  function deserializeListMenuInput(input) {
5
5
  const orderby = input?.orderby === "relevance" && !input?.search || input?.orderby === "include" && input?.include === void 0 || input?.orderby === "include_slugs" && input?.slug === void 0 ? void 0 : input?.orderby;
6
- return {
6
+ return { query: {
7
7
  after: input?.after,
8
8
  before: input?.before,
9
9
  exclude: listed(input?.exclude),
@@ -21,7 +21,7 @@ function deserializeListMenuInput(input) {
21
21
  tax_relation: input?.taxRelation,
22
22
  search_columns: input?.searchColumns,
23
23
  status: ["publish"]
24
- };
24
+ } };
25
25
  }
26
26
  /**
27
27
  * The `href` a headless frontend links to. WP builds a non-custom item's `url` as an absolute same-site
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.21.0";
2
+ var version = "0.22.0";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -24,7 +24,7 @@ const PAGE_PROCEDURES = {
24
24
  if (input.query?.previewToken) {
25
25
  const result = await context.verifyPreviewToken(input.query.previewToken);
26
26
  if (!result) throw errors.PAGE_NOT_FOUND();
27
- const response$1 = await context.wordpress.postTypes.page.retrieve({ identifier: String(result.id) });
27
+ const response$1 = await context.wordpress.kizlo.postTypes.page.retrieve({ params: { identifier: String(result.id) } });
28
28
  if (response$1.error) switch (response$1.error.code) {
29
29
  case "invalid_post_type":
30
30
  case "post_type_not_found":
@@ -44,7 +44,7 @@ const PAGE_PROCEDURES = {
44
44
  }
45
45
  const identifier = parseIdentifier(input.params.identifier);
46
46
  if (!identifier) throw errors.PAGE_NOT_FOUND();
47
- const response = await context.wordpress.postTypes.page.retrieve({ identifier: String(identifier.value) });
47
+ const response = await context.wordpress.kizlo.postTypes.page.retrieve({ params: { identifier: String(identifier.value) } });
48
48
  if (response.error) switch (response.error.code) {
49
49
  case "invalid_post_type":
50
50
  case "post_type_not_found":
@@ -78,7 +78,7 @@ const PAGE_PROCEDURES = {
78
78
  }, async ({ input, context, errors }) => {
79
79
  const q = input.query;
80
80
  const orderby = q?.orderby === "relevance" && !q?.search || q?.orderby === "include" && q?.include === void 0 ? void 0 : q?.orderby;
81
- const response = await context.wordpress.postTypes.page.list({
81
+ const response = await context.wordpress.kizlo.postTypes.page.list({ query: {
82
82
  status: ["publish"],
83
83
  after: q?.after,
84
84
  author: normalizeArrayableValue(q?.author),
@@ -99,7 +99,7 @@ const PAGE_PROCEDURES = {
99
99
  search: q?.search,
100
100
  search_columns: q?.searchColumns,
101
101
  slug: normalizeArrayableValue(q?.slug)
102
- });
102
+ } });
103
103
  if (response.error) switch (response.error.code) {
104
104
  case "rest_post_invalid_page_number": throw errors.PAGE_INVALID_PAGE();
105
105
  case "rest_no_route": throw errors.PAGE_NOT_FOUND();
@@ -5,7 +5,7 @@ import z from "zod/v4";
5
5
 
6
6
  //#region src/page/schema.d.ts
7
7
 
8
- type PageCustomFields = WP_CustomFields<"postTypes.page">;
8
+ type PageCustomFields = WP_CustomFields<"kizlo.postTypes.page">;
9
9
  declare const PageCustomFieldsSchema: z.ZodType<PageCustomFields, PageCustomFields>;
10
10
  declare const Page: z.ZodObject<{
11
11
  id: z.ZodNumber;
@@ -24,7 +24,7 @@ const POST_PROCEDURES = {
24
24
  if (input.query?.previewToken) {
25
25
  const result = await context.verifyPreviewToken(input.query.previewToken);
26
26
  if (!result) throw errors.POST_NOT_FOUND();
27
- const response$1 = await context.wordpress.postTypes.post.retrieve({ identifier: String(result.id) });
27
+ const response$1 = await context.wordpress.kizlo.postTypes.post.retrieve({ params: { identifier: String(result.id) } });
28
28
  if (response$1.error) switch (response$1.error.code) {
29
29
  case "invalid_post_type":
30
30
  case "post_type_not_found":
@@ -44,7 +44,7 @@ const POST_PROCEDURES = {
44
44
  }
45
45
  const identifier = parseIdentifier(input.params.identifier);
46
46
  if (!identifier) throw errors.POST_NOT_FOUND();
47
- const response = await context.wordpress.postTypes.post.retrieve({ identifier: String(identifier.value) });
47
+ const response = await context.wordpress.kizlo.postTypes.post.retrieve({ params: { identifier: String(identifier.value) } });
48
48
  if (response.error) switch (response.error.code) {
49
49
  case "invalid_post_type":
50
50
  case "post_type_not_found":
@@ -78,7 +78,7 @@ const POST_PROCEDURES = {
78
78
  }, async ({ input, context, errors }) => {
79
79
  const q = input.query;
80
80
  const orderby = q?.orderby === "relevance" && !q?.search || q?.orderby === "include" && q?.include === void 0 ? void 0 : q?.orderby;
81
- const response = await context.wordpress.postTypes.post.list({
81
+ const response = await context.wordpress.kizlo.postTypes.post.list({ query: {
82
82
  status: ["publish"],
83
83
  after: q?.after,
84
84
  author: normalizeArrayableValue(q?.author),
@@ -102,7 +102,7 @@ const POST_PROCEDURES = {
102
102
  tags: normalizeArrayableValue(q?.tags),
103
103
  tags_exclude: normalizeArrayableValue(q?.tagsExclude),
104
104
  tax_relation: q?.taxRelation
105
- });
105
+ } });
106
106
  if (response.error) switch (response.error.code) {
107
107
  case "rest_post_invalid_page_number": throw errors.POST_INVALID_PAGE();
108
108
  case "rest_no_route": throw errors.POST_NOT_FOUND();
@@ -5,7 +5,7 @@ import z from "zod/v4";
5
5
 
6
6
  //#region src/post/schema.d.ts
7
7
 
8
- type PostCustomFields = WP_CustomFields<"postTypes.post">;
8
+ type PostCustomFields = WP_CustomFields<"kizlo.postTypes.post">;
9
9
  declare const PostCustomFieldsSchema: z.ZodType<PostCustomFields, PostCustomFields>;
10
10
  declare const Post: z.ZodObject<{
11
11
  id: z.ZodNumber;
@@ -26,13 +26,13 @@ declare const Post: z.ZodObject<{
26
26
  private: "private";
27
27
  }>;
28
28
  format: z.ZodEnum<{
29
- image: "image";
30
- link: "link";
31
29
  status: "status";
32
30
  standard: "standard";
33
31
  aside: "aside";
34
32
  chat: "chat";
35
33
  gallery: "gallery";
34
+ link: "link";
35
+ image: "image";
36
36
  quote: "quote";
37
37
  video: "video";
38
38
  audio: "audio";
@@ -150,13 +150,13 @@ declare const PostList: z.ZodObject<{
150
150
  private: "private";
151
151
  }>;
152
152
  format: z.ZodEnum<{
153
- image: "image";
154
- link: "link";
155
153
  status: "status";
156
154
  standard: "standard";
157
155
  aside: "aside";
158
156
  chat: "chat";
159
157
  gallery: "gallery";
158
+ link: "link";
159
+ image: "image";
160
160
  quote: "quote";
161
161
  video: "video";
162
162
  audio: "audio";
@@ -44,7 +44,7 @@ declare const CORE_PROCEDURES: {
44
44
  include?: string | number | (string | number)[] | undefined;
45
45
  offset?: string | number | undefined;
46
46
  order?: "asc" | "desc" | undefined;
47
- orderby?: "id" | "slug" | "parent" | "title" | "author" | "date" | "include" | "include_slugs" | "modified" | "relevance" | undefined;
47
+ orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | undefined;
48
48
  searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
49
49
  slug?: string | string[] | undefined;
50
50
  taxRelation?: "AND" | "OR" | undefined;
@@ -99,7 +99,7 @@ declare const CORE_PROCEDURES: {
99
99
  include?: string | number | (string | number)[] | undefined;
100
100
  offset?: string | number | undefined;
101
101
  order?: "asc" | "desc" | undefined;
102
- orderby?: "id" | "slug" | "parent" | "title" | "author" | "date" | "include" | "include_slugs" | "modified" | "relevance" | "menu_order" | undefined;
102
+ orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | "menu_order" | undefined;
103
103
  searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
104
104
  slug?: string | string[] | undefined;
105
105
  parent?: string | number | (string | number)[] | undefined;
@@ -136,7 +136,7 @@ declare const CORE_PROCEDURES: {
136
136
  exclude?: string | number | (string | number)[] | undefined;
137
137
  include?: string | number | (string | number)[] | undefined;
138
138
  order?: "asc" | "desc" | undefined;
139
- orderBy?: "id" | "name" | "slug" | "description" | "include" | "include_slugs" | "term_group" | "count" | undefined;
139
+ orderBy?: "id" | "count" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | undefined;
140
140
  hideEmpty?: string | boolean | undefined;
141
141
  parent?: string | number | undefined;
142
142
  post?: string | number | undefined;
@@ -172,7 +172,7 @@ declare const CORE_PROCEDURES: {
172
172
  exclude?: string | number | (string | number)[] | undefined;
173
173
  include?: string | number | (string | number)[] | undefined;
174
174
  order?: "asc" | "desc" | undefined;
175
- orderBy?: "id" | "name" | "slug" | "description" | "include" | "include_slugs" | "term_group" | "count" | undefined;
175
+ orderBy?: "id" | "count" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | undefined;
176
176
  hideEmpty?: string | boolean | undefined;
177
177
  post?: string | number | undefined;
178
178
  slug?: string | string[] | undefined;
@@ -241,7 +241,7 @@ declare const CORE_PROCEDURES: {
241
241
  sitemaps: {
242
242
  list: Procedure<"internal", {}, {
243
243
  key: string;
244
- type: "author" | "post_type" | "taxonomy";
244
+ type: "post_type" | "taxonomy" | "author";
245
245
  pages: number;
246
246
  lastmod: string;
247
247
  }[], DefinedErrorMapLike>;
@@ -249,7 +249,7 @@ declare const CORE_PROCEDURES: {
249
249
  origin: string;
250
250
  sitemaps: {
251
251
  key: string;
252
- type: "author" | "post_type" | "taxonomy";
252
+ type: "post_type" | "taxonomy" | "author";
253
253
  pages: number;
254
254
  lastmod: string;
255
255
  }[];
@@ -292,7 +292,7 @@ declare const CORE_PROCEDURES: {
292
292
  include?: string | number | (string | number)[] | undefined;
293
293
  offset?: string | number | undefined;
294
294
  order?: "asc" | "desc" | undefined;
295
- orderby?: "id" | "slug" | "parent" | "title" | "author" | "date" | "include" | "include_slugs" | "relevance" | "menu_order" | undefined;
295
+ orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
296
296
  searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
297
297
  slug?: string | string[] | undefined;
298
298
  taxRelation?: "AND" | "OR" | undefined;
@@ -371,7 +371,7 @@ declare const CORE_PROCEDURES: {
371
371
  include?: string | number | (string | number)[] | undefined;
372
372
  offset?: string | number | undefined;
373
373
  order?: "asc" | "desc" | undefined;
374
- orderby?: "id" | "slug" | "parent" | "title" | "author" | "date" | "include" | "include_slugs" | "relevance" | "menu_order" | undefined;
374
+ orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
375
375
  searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
376
376
  slug?: string | string[] | undefined;
377
377
  taxRelation?: "AND" | "OR" | undefined;
@@ -507,7 +507,7 @@ declare const CORE_PROCEDURES: {
507
507
  include?: string | number | (string | number)[] | undefined;
508
508
  offset?: string | number | undefined;
509
509
  order?: "asc" | "desc" | undefined;
510
- orderby?: "id" | "parent" | "date" | "include" | "post" | undefined;
510
+ orderby?: "id" | "date" | "parent" | "include" | "post" | undefined;
511
511
  parent?: string | number | (string | number)[] | undefined;
512
512
  parentExclude?: string | number | (string | number)[] | undefined;
513
513
  post?: string | number | (string | number)[] | undefined;
@@ -635,8 +635,8 @@ declare const CORE_PROCEDURES: {
635
635
  get: Procedure<"internal", {}, _kizlo_shared11.Settings, DefinedErrorMapLike>;
636
636
  site: {
637
637
  update: Procedure<"internal", {
638
- name?: string | null | undefined;
639
638
  url?: string | null | undefined;
639
+ name?: string | null | undefined;
640
640
  backend_url?: string | null | undefined;
641
641
  secret?: string | null | undefined;
642
642
  alternate_name?: string | null | undefined;