kizlo 0.18.0 → 0.19.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/dist/config.d.ts CHANGED
@@ -2,14 +2,28 @@ import { Fixture } from "./cli/wp/types.js";
2
2
  import "./test.js";
3
3
 
4
4
  //#region src/config.d.ts
5
+
6
+ /**
7
+ * Where Kizlo generates, and what it watches. A string is the home directory Kizlo owns the layout
8
+ * under: sources in `<dir>/server`, and the generated files (`contract.json`, the barrel, and
9
+ * `introspection.ts`) under `<dir>/server/generated`. The object form sets each path on its own. Omit
10
+ * `server` and there are no sources to watch and no contract is built, so only the introspection is
11
+ * generated (the shape a package that ships procedures but no server takes).
12
+ */
13
+ type KizloDir = string | {
14
+ /** Server sources (extensions and procedures). Watched by `kizlo dev`; its presence is what builds a contract. */
15
+ server?: string;
16
+ /** Where `contract.json` and the generated barrel are written. Defaults to `generated/` under `server`. */
17
+ contract?: string;
18
+ /** Where the generated `introspection.ts` is written. Defaults to `generated/` under `server`. */
19
+ introspection?: string;
20
+ };
5
21
  interface KizloDevConfig {
6
22
  /**
7
- * Run local WordPress under `kizlo dev`. When `true`, `kizlo dev` boots a Docker WordPress in
8
- * `.kizlo/local` alongside the contract watcher; when unset or `false`, it runs the watcher alone
9
- * (for a project pointing at your own WordPress). Set for you by `kizlo create` / `kizlo init`
10
- * when you choose local WordPress.
23
+ * Run the dev stack. On by default when local WordPress is enabled; set `false` to keep local
24
+ * WordPress on for `kizlo test` while `kizlo dev` runs the contract watcher alone.
11
25
  */
12
- local?: boolean;
26
+ enable?: boolean;
13
27
  /** Published WP port (default 8080). */
14
28
  port?: number;
15
29
  /**
@@ -17,8 +31,8 @@ interface KizloDevConfig {
17
31
  * Hub: a bare version (`"7.1.0"`), or a full tag (`"7.1.0-php8.3-apache"`) when you need
18
32
  * a specific PHP. Defaults to `latest`, so an unconfigured project gets current WordPress.
19
33
  *
20
- * Worth setting once you commit a generated WordPress client, which is derived from
21
- * whatever the stack serves: on `latest` that client goes stale the day WordPress ships.
34
+ * Worth setting once you commit a generated introspection, which is derived from
35
+ * whatever the stack serves: on `latest` that introspection goes stale the day WordPress ships.
22
36
  *
23
37
  * An existing install keeps the core files it was provisioned with, so changing this
24
38
  * takes effect on the next `kizlo dev reset` and Kizlo says so when the two disagree.
@@ -45,27 +59,24 @@ interface KizloDevConfig {
45
59
  }
46
60
  interface KizloTestConfig {
47
61
  /**
48
- * Run local WordPress under `kizlo test`. When `true`, `kizlo test` boots a disposable Docker
49
- * WordPress, seeds it, and runs your suite against it; when unset or `false`, `kizlo test` just
50
- * runs your project's test script. Set for you by `kizlo create` / `kizlo init` when you choose
51
- * local WordPress.
62
+ * Run the test stack. On by default when local WordPress is enabled; set `false` to keep local
63
+ * WordPress on for `kizlo dev` while `kizlo test` just runs the project's own test script.
64
+ */
65
+ enable?: boolean;
66
+ /**
67
+ * Fall back to the dev stack's `version` and `fixtures` when this stack leaves them unset (default
68
+ * `true`), so the two stacks a local-WordPress project always wants together are declared once.
69
+ * Set `false` to configure the test stack independently, taking Kizlo's defaults where it is silent.
52
70
  */
53
- local?: boolean;
71
+ inherit?: boolean;
54
72
  /** Published WP port (default 8889). */
55
73
  port?: number;
56
74
  /**
57
75
  * WordPress version the local stack boots, given as the tag after `wordpress:` on Docker
58
- * Hub: a bare version (`"7.1.0"`), or a full tag (`"7.1.0-php8.3-apache"`) when you need
59
- * a specific PHP. Defaults to `latest`, so an unconfigured project gets current WordPress.
60
- *
61
- * Worth setting once you commit a generated WordPress client, which is derived from
62
- * whatever the stack serves: on `latest` that client goes stale the day WordPress ships.
63
- *
64
- * An existing install keeps the core files it was provisioned with, so changing this
65
- * takes effect on the next `kizlo test reset` and Kizlo says so when the two disagree.
76
+ * Hub. Falls back to the dev stack's `version` unless `inherit` is `false`; defaults to `latest`.
66
77
  */
67
78
  version?: string;
68
- /** Integration fixtures to install + seed. */
79
+ /** Integration fixtures to install + seed. Falls back to the dev stack's `fixtures` unless `inherit` is `false`. */
69
80
  fixtures?: Fixture[];
70
81
  /**
71
82
  * Package manager used to launch the test script (default: auto-detected from
@@ -78,20 +89,12 @@ interface KizloTestConfig {
78
89
  */
79
90
  command?: string;
80
91
  }
81
- interface KizloGlobalConfig {
82
- /**
83
- * Kizlo's home directory. Kizlo owns the layout inside it: your server
84
- * (`server/`, whose `index.ts` exports `procedures` plus your integrations), the
85
- * browser `client.ts`, and the generated contract.
86
- * @default 'src/lib/kizlo' (or 'lib/kizlo' without a src dir)
87
- */
88
- dir?: string;
92
+ interface KizloLocalConfig {
89
93
  /**
90
- * Import alias prefix for generated imports (e.g. `@`). Recorded by `kizlo init`
91
- * from your `--alias` flag or its prompt, so later runs reuse it instead of asking
92
- * again; an empty string (`""`) is the recorded choice to use relative imports.
94
+ * Enable local Docker WordPress (default `true` in this object form). Set `false` to keep the
95
+ * stacks configured but off, the same as omitting `local` entirely.
93
96
  */
94
- alias?: string;
97
+ enable?: boolean;
95
98
  /**
96
99
  * Base name for the local Docker stacks (`kizlo-<name>-dev`, `kizlo-<name>-test`). Defaults
97
100
  * to the sanitized `package.json` name, falling back to the config dir basename.
@@ -99,8 +102,8 @@ interface KizloGlobalConfig {
99
102
  name?: string;
100
103
  /**
101
104
  * Give each branch its own local Docker stacks, by appending the checked-out branch to
102
- * {@link name} (`kizlo-<name>-<branch>-dev`). Off unless set, since the stacks it isolates
103
- * are the ones an existing project is already using.
105
+ * {@link KizloLocalConfig.name} (`kizlo-<name>-<branch>-dev`). Off unless set, since the stacks it
106
+ * isolates are the ones an existing project is already using.
104
107
  *
105
108
  * Turn it on when you work in several checkouts at once, typically git worktrees: without it
106
109
  * every checkout of a project resolves to one stack, so parallel `kizlo dev` and `kizlo test`
@@ -109,20 +112,31 @@ interface KizloGlobalConfig {
109
112
  * A detached `HEAD` names no branch and keeps the unsuffixed stack.
110
113
  */
111
114
  worktrees?: boolean;
112
- /**
113
- * Directory to write the WordPress client into, as `<wordpressClientDir>/wordpress.ts`. For a package or
114
- * workspace that ships procedures but no Kizlo server: there is no procedure tree to build a contract from,
115
- * yet those procedures still call the generated tree, so they need the client on its own.
116
- *
117
- * Independent of `dir`. An app leaves this unset and gets its client inside `dir` alongside the
118
- * contract; set both only if a project is somehow each of those things at once.
119
- */
120
- wordpressClientDir?: string;
121
- /** Local WordPress and contract watcher run by `kizlo dev`. */
115
+ /** The dev stack run by `kizlo dev`. */
122
116
  dev?: KizloDevConfig;
123
- /** WordPress test environment run by `kizlo test`. */
117
+ /** The test stack run by `kizlo test`. Inherits `version` and `fixtures` from {@link KizloLocalConfig.dev}. */
124
118
  test?: KizloTestConfig;
125
119
  }
120
+ interface KizloGlobalConfig {
121
+ /**
122
+ * Where Kizlo generates, and what it watches. A string names the home directory Kizlo owns the
123
+ * layout under; the object form sets the server, contract, and introspection paths independently.
124
+ * @default 'src/lib/kizlo' (or 'lib/kizlo' without a src dir)
125
+ */
126
+ dir?: KizloDir;
127
+ /**
128
+ * Import alias prefix for generated imports (e.g. `@`). Recorded by `kizlo init`
129
+ * from your `--alias` flag or its prompt, so later runs reuse it instead of asking
130
+ * again; an empty string (`""`) is the recorded choice to use relative imports.
131
+ */
132
+ alias?: string;
133
+ /**
134
+ * Local Docker WordPress, off unless set. `true` enables both the dev and test stacks with
135
+ * defaults; the object form enables and configures them, and is where the stack name, the
136
+ * per-branch `worktrees` toggle, and the two stacks live.
137
+ */
138
+ local?: boolean | KizloLocalConfig;
139
+ }
126
140
  declare function defineConfig(config: KizloGlobalConfig): KizloGlobalConfig;
127
141
  //#endregion
128
- export { KizloDevConfig, KizloGlobalConfig, KizloTestConfig, defineConfig };
142
+ export { KizloDevConfig, KizloDir, KizloGlobalConfig, KizloLocalConfig, KizloTestConfig, defineConfig };
package/dist/context.d.ts CHANGED
@@ -20,7 +20,7 @@ interface ContextConfig {
20
20
  /** WordPress plugins the registered integrations need, checked against what each response reports. */
21
21
  integrationPlugins?: IntegrationPluginRequirement[];
22
22
  }
23
- type AuthUserFn = () => Promise<AuthUser | null>;
23
+ type SessionFn = () => Promise<AuthUser | null>;
24
24
  type ConnInfoFn = () => Promise<ConnInfo | null>;
25
25
  type VerifyCaptchaFn = (token: string) => Promise<boolean>;
26
26
  type VerifyPreviewTokenFn = (token: string) => Promise<PreviewTokenPayload | null>;
@@ -46,8 +46,8 @@ interface ProcedureContext {
46
46
  config: ContextConfig;
47
47
  /** Resolve the caller's connection info (IP, geo) via the geo adapter, or `null`. */
48
48
  getConnInfo: ConnInfoFn;
49
- /** Resolve the authenticated user via the auth adapter, or `null`. */
50
- getAuthUser: AuthUserFn;
49
+ /** Resolve the authenticated session via the auth adapter, or `null`. */
50
+ getSession: SessionFn;
51
51
  /** Read and write cookies through the cookies adapter. */
52
52
  cookies: CookiesStorage;
53
53
  /** Verify a CAPTCHA token via the captcha adapter. */
@@ -84,7 +84,7 @@ declare class Context {
84
84
  email: EmailService;
85
85
  getConnInfo: ConnInfoFn;
86
86
  verifyCaptcha: VerifyCaptchaFn;
87
- getAuthUser: AuthUserFn;
87
+ getSession: SessionFn;
88
88
  verifyPreviewToken: VerifyPreviewTokenFn;
89
89
  cookies: CookiesStorage;
90
90
  invokedBy: "client";
@@ -98,7 +98,7 @@ declare class Context {
98
98
  wordpress: WordPressTransport;
99
99
  settings: SettingsService;
100
100
  email: EmailService;
101
- getAuthUser: AuthUserFn;
101
+ getSession: SessionFn;
102
102
  getConnInfo: ConnInfoFn;
103
103
  verifyCaptcha: VerifyCaptchaFn;
104
104
  verifyPreviewToken: VerifyPreviewTokenFn;
@@ -107,9 +107,9 @@ declare class Context {
107
107
  private createRestCookieStorage;
108
108
  private createVerifyCaptchaFn;
109
109
  private createConnInfoFn;
110
- private createGetUserFn;
110
+ private createGetSessionFn;
111
111
  private createVerifyPreviewTokenFn;
112
112
  private createLogger;
113
113
  }
114
114
  //#endregion
115
- export { AuthUserFn, ConnInfoFn, Context, ContextConfig, ProcedureContext, VerifyCaptchaFn, VerifyPreviewTokenFn };
115
+ export { ConnInfoFn, Context, ContextConfig, ProcedureContext, SessionFn, VerifyCaptchaFn, VerifyPreviewTokenFn };
package/dist/context.js CHANGED
@@ -102,7 +102,7 @@ var Context = class {
102
102
  email: this.email,
103
103
  getConnInfo: this.createConnInfoFn(request),
104
104
  verifyCaptcha: this.createVerifyCaptchaFn(request),
105
- getAuthUser: this.createGetUserFn(request),
105
+ getSession: this.createGetSessionFn(request),
106
106
  verifyPreviewToken: this.createVerifyPreviewTokenFn(),
107
107
  cookies: this.createRestCookieStorage(request, headers),
108
108
  invokedBy: "client"
@@ -118,7 +118,7 @@ var Context = class {
118
118
  wordpress: this.wordpress,
119
119
  settings: this.settings,
120
120
  email: this.email,
121
- getAuthUser: this.createGetUserFn(null),
121
+ getSession: this.createGetSessionFn(null),
122
122
  getConnInfo: this.createConnInfoFn(null),
123
123
  verifyCaptcha: this.createVerifyCaptchaFn(null),
124
124
  verifyPreviewToken: this.createVerifyPreviewTokenFn(),
@@ -176,9 +176,9 @@ var Context = class {
176
176
  return await this.config.adapters?.geo?.getConnInfo?.(request) ?? null;
177
177
  };
178
178
  }
179
- createGetUserFn(request) {
179
+ createGetSessionFn(request) {
180
180
  return async () => {
181
- return await Promise.resolve(this.config.adapters?.auth?.getUser?.(request)) ?? null;
181
+ return await Promise.resolve(this.config.adapters?.auth?.getSession?.(request)) ?? null;
182
182
  };
183
183
  }
184
184
  createVerifyPreviewTokenFn() {
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import { buildWordPressRequest, createWordPressClient, wpEndpoint } from "./word
5
5
  import { isWordPressResourceError } from "./wordpress/utils.js";
6
6
  import "./wordpress/index.js";
7
7
  import { DevPluginSource, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, JsonValue, LocalPlugin, PluginSource, SeedContext, SettleContext, TestAdminUser, TestCredentials, TestUser, defineFixture, isLocalPlugin } from "./cli/wp/types.js";
8
- import { AuthAdapter, AuthGetUser, AuthUser, authMock, createAuthAdapter } from "./adapters/auth.js";
8
+ import { AuthAdapter, AuthGetSession, AuthUser, authMock, createAuthAdapter } from "./adapters/auth.js";
9
9
  import { CaptchaAdapter, altcha, arkose, createCaptchaAdapter, friendlyCaptcha, hcaptcha, recaptcha, turnstile } from "./adapters/captcha.js";
10
10
  import { CurrencyFormat, IdentifierInput, LIST_ORDER, ListMetadata, ListOrder, PreviewTokenData, PreviewTokenPayload, customFieldsSchema } from "./shared/schema.js";
11
11
  import { AnyContext, AnyNestedClient, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, HTTPMethod, List, MaybeOptionalOptions, RedirectInput, RedirectStatus } from "./shared/types.js";
@@ -18,7 +18,7 @@ import { AuthorsSettings, AuthorsSettingsInput, BrandSettings, BrandSettingsInpu
18
18
  import { IconDescriptor, ManifestIcon, ResolvedIcons, resolveIcons } from "./brand/icons.js";
19
19
  import { CookiesStorage } from "./cookie.js";
20
20
  import { SettingsService } from "./settings/service.js";
21
- import { AuthUserFn, ConnInfoFn, Context, ContextConfig, ProcedureContext, VerifyCaptchaFn, VerifyPreviewTokenFn } from "./context.js";
21
+ import { ConnInfoFn, Context, ContextConfig, ProcedureContext, SessionFn, VerifyCaptchaFn, VerifyPreviewTokenFn } from "./context.js";
22
22
  import { Post, PostCustomFields, PostCustomFieldsSchema } from "./post/schema.js";
23
23
  import { Page, PageCustomFields, PageCustomFieldsSchema } from "./page/schema.js";
24
24
  import { Category, CategoryCustomFields, CategoryCustomFieldsSchema } from "./category/schema.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, AuthGetUser, AuthUser, AuthUserFn, 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, 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, toKizloError, turnstile, 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_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, toKizloError, turnstile, wpEndpoint, xmlResponse };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.18.0";
2
+ var version = "0.19.0";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -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?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | 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?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | "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?: "count" | "id" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | 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?: "count" | "id" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | 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;
@@ -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?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "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?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "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?: "date" | "id" | "parent" | "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;
@@ -611,7 +611,6 @@ declare const CORE_PROCEDURES: {
611
611
  postedAt: number;
612
612
  isApproved: boolean;
613
613
  }, {
614
- readonly COMMENT_USER_NOT_FOUND: {};
615
614
  readonly COMMENT_ID_NOT_FOUND: {};
616
615
  readonly COMMENT_CLOSED: {};
617
616
  readonly COMMENT_LOGIN_REQUIRED: {};
package/dist/test/auth.js CHANGED
@@ -1,10 +1,9 @@
1
1
  //#region src/test/auth.ts
2
2
  function testAuthAdapter(user) {
3
- return { getUser() {
3
+ return { getSession() {
4
4
  return {
5
- id: user.wpUserId,
5
+ id: user.id,
6
6
  email: user.email,
7
- phone: user.phone,
8
7
  firstName: user.firstName,
9
8
  lastName: user.lastName
10
9
  };
@@ -2,12 +2,10 @@ import { TestCredentials } from "../cli/wp/types.js";
2
2
 
3
3
  //#region src/test/users.d.ts
4
4
  interface TestAuthAdapterUser {
5
- wpUserId: number;
6
- username: string;
5
+ id: string;
6
+ email: string;
7
7
  firstName: string;
8
8
  lastName: string;
9
- email: string;
10
- phone: string;
11
9
  }
12
10
  declare function toTestUser(user: TestCredentials["users"]["user"]): TestAuthAdapterUser;
13
11
  //#endregion
@@ -1,15 +1,10 @@
1
1
  //#region src/test/users.ts
2
- const STATIC_FIELDS = {
3
- firstName: "Test",
4
- lastName: "Customer",
5
- email: "customer@example.com",
6
- phone: "+10000000002"
7
- };
8
2
  function toTestUser(user) {
9
3
  return {
10
- wpUserId: user.id,
11
- username: user.username,
12
- ...STATIC_FIELDS
4
+ id: String(user.id),
5
+ email: user.email,
6
+ firstName: "Test",
7
+ lastName: "Customer"
13
8
  };
14
9
  }
15
10
 
package/dist/test.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DevPluginSource, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, JsonValue, LocalPlugin, PluginSource, SeedContext, SettleContext, TestAdminUser, TestCredentials, TestUser, defineFixture, isLocalPlugin } from "./cli/wp/types.js";
2
- import { COMPOSE_FILE, CONFIG_FILES, CREDENTIALS_REL, DEFAULT_PLUGINS, DEFAULT_PORT, DEFAULT_WORDPRESS_TAG, LOCAL_DIR_REL, OPCACHE_INI, REMAP_ENTRYPOINT, SEED_MARKER_OPTION, SEED_VERSION, TEST_ADMIN, TEST_USER, WORDPRESS_CLIENT_META_REL, WORDPRESS_META_REL, githubRelease, kizloRelease } from "./cli/wp/constants.js";
2
+ import { COMPOSE_FILE, CONFIG_FILES, CREDENTIALS_REL, DEFAULT_PLUGINS, DEFAULT_PORT, DEFAULT_WORDPRESS_TAG, INTROSPECTION_META_REL, LOCAL_DIR_REL, OPCACHE_INI, REMAP_ENTRYPOINT, SEED_MARKER_OPTION, SEED_VERSION, TEST_ADMIN, TEST_USER, githubRelease, kizloRelease } from "./cli/wp/constants.js";
3
3
  import { DockerStack, DockerStatus, RunResult, Stack, StackStatus, compose, composeDown, composePull, composeStop, composeUp, createStack, dockerAvailable, dockerHint, dockerStatus, runningProjectContainers, stackStatus, stopProjectContainers, wpCli, wpEval } from "./cli/wp/docker.js";
4
4
  import { activateLocalPlugin, credentialsPath, ensurePlugin, ensurePlugins, findConfigDir, getTestCredentials, isSeeded, recordedPort, resolvePluginSource, settleFixtures } from "./cli/wp/utils.js";
5
5
  import { TestAuthAdapterUser, toTestUser } from "./test/users.js";
@@ -8,4 +8,4 @@ import { CAPTCHA_TEST_TOKEN_PASS, captchaMock } from "./test/captcha.js";
8
8
  import { menuFixture } from "./menu/fixture.js";
9
9
  import { postFixture } from "./post/fixture.js";
10
10
  import { coreFixtures } from "./test/fixtures.js";
11
- export { CAPTCHA_TEST_TOKEN_PASS, COMPOSE_FILE, CONFIG_FILES, CREDENTIALS_REL, DEFAULT_PLUGINS, DEFAULT_PORT, DEFAULT_WORDPRESS_TAG, DevPluginSource, DockerStack, DockerStatus, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, JsonValue, LOCAL_DIR_REL, LocalPlugin, OPCACHE_INI, PluginSource, REMAP_ENTRYPOINT, RunResult, SEED_MARKER_OPTION, SEED_VERSION, SeedContext, SettleContext, Stack, StackStatus, TEST_ADMIN, TEST_USER, TestAdminUser, TestAuthAdapterUser, TestCredentials, TestUser, WORDPRESS_CLIENT_META_REL, WORDPRESS_META_REL, activateLocalPlugin, captchaMock, compose, composeDown, composePull, composeStop, composeUp, coreFixtures, createStack, credentialsPath, defineFixture, dockerAvailable, dockerHint, dockerStatus, ensurePlugin, ensurePlugins, findConfigDir, getTestCredentials, githubRelease, isLocalPlugin, isSeeded, kizloRelease, menuFixture, postFixture, recordedPort, resolvePluginSource, runningProjectContainers, settleFixtures, stackStatus, stopProjectContainers, testAuthAdapter, toTestUser, wpCli, wpEval };
11
+ export { CAPTCHA_TEST_TOKEN_PASS, COMPOSE_FILE, CONFIG_FILES, CREDENTIALS_REL, DEFAULT_PLUGINS, DEFAULT_PORT, DEFAULT_WORDPRESS_TAG, DevPluginSource, DockerStack, DockerStatus, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, INTROSPECTION_META_REL, JsonValue, LOCAL_DIR_REL, LocalPlugin, OPCACHE_INI, PluginSource, REMAP_ENTRYPOINT, RunResult, SEED_MARKER_OPTION, SEED_VERSION, SeedContext, SettleContext, Stack, StackStatus, TEST_ADMIN, TEST_USER, TestAdminUser, TestAuthAdapterUser, TestCredentials, TestUser, activateLocalPlugin, captchaMock, compose, composeDown, composePull, composeStop, composeUp, coreFixtures, createStack, credentialsPath, defineFixture, dockerAvailable, dockerHint, dockerStatus, ensurePlugin, ensurePlugins, findConfigDir, getTestCredentials, githubRelease, isLocalPlugin, isSeeded, kizloRelease, menuFixture, postFixture, recordedPort, resolvePluginSource, runningProjectContainers, settleFixtures, stackStatus, stopProjectContainers, testAuthAdapter, toTestUser, wpCli, wpEval };
package/dist/test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineFixture, isLocalPlugin } from "./cli/wp/types.js";
2
- import { COMPOSE_FILE, CONFIG_FILES, CREDENTIALS_REL, DEFAULT_PLUGINS, DEFAULT_PORT, DEFAULT_WORDPRESS_TAG, LOCAL_DIR_REL, OPCACHE_INI, REMAP_ENTRYPOINT, SEED_MARKER_OPTION, SEED_VERSION, TEST_ADMIN, TEST_USER, WORDPRESS_CLIENT_META_REL, WORDPRESS_META_REL, githubRelease, kizloRelease } from "./cli/wp/constants.js";
2
+ import { COMPOSE_FILE, CONFIG_FILES, CREDENTIALS_REL, DEFAULT_PLUGINS, DEFAULT_PORT, DEFAULT_WORDPRESS_TAG, INTROSPECTION_META_REL, LOCAL_DIR_REL, OPCACHE_INI, REMAP_ENTRYPOINT, SEED_MARKER_OPTION, SEED_VERSION, TEST_ADMIN, TEST_USER, githubRelease, kizloRelease } from "./cli/wp/constants.js";
3
3
  import { compose, composeDown, composePull, composeStop, composeUp, createStack, dockerAvailable, dockerHint, dockerStatus, runningProjectContainers, stackStatus, stopProjectContainers, wpCli, wpEval } from "./cli/wp/docker.js";
4
4
  import { activateLocalPlugin, credentialsPath, ensurePlugin, ensurePlugins, findConfigDir, getTestCredentials, isSeeded, recordedPort, resolvePluginSource, settleFixtures } from "./cli/wp/utils.js";
5
5
  import { testAuthAdapter } from "./test/auth.js";
@@ -9,4 +9,4 @@ import { postFixture } from "./post/fixture.js";
9
9
  import { coreFixtures } from "./test/fixtures.js";
10
10
  import { toTestUser } from "./test/users.js";
11
11
 
12
- export { CAPTCHA_TEST_TOKEN_PASS, COMPOSE_FILE, CONFIG_FILES, CREDENTIALS_REL, DEFAULT_PLUGINS, DEFAULT_PORT, DEFAULT_WORDPRESS_TAG, LOCAL_DIR_REL, OPCACHE_INI, REMAP_ENTRYPOINT, SEED_MARKER_OPTION, SEED_VERSION, TEST_ADMIN, TEST_USER, WORDPRESS_CLIENT_META_REL, WORDPRESS_META_REL, activateLocalPlugin, captchaMock, compose, composeDown, composePull, composeStop, composeUp, coreFixtures, createStack, credentialsPath, defineFixture, dockerAvailable, dockerHint, dockerStatus, ensurePlugin, ensurePlugins, findConfigDir, getTestCredentials, githubRelease, isLocalPlugin, isSeeded, kizloRelease, menuFixture, postFixture, recordedPort, resolvePluginSource, runningProjectContainers, settleFixtures, stackStatus, stopProjectContainers, testAuthAdapter, toTestUser, wpCli, wpEval };
12
+ export { CAPTCHA_TEST_TOKEN_PASS, COMPOSE_FILE, CONFIG_FILES, CREDENTIALS_REL, DEFAULT_PLUGINS, DEFAULT_PORT, DEFAULT_WORDPRESS_TAG, INTROSPECTION_META_REL, LOCAL_DIR_REL, OPCACHE_INI, REMAP_ENTRYPOINT, SEED_MARKER_OPTION, SEED_VERSION, TEST_ADMIN, TEST_USER, activateLocalPlugin, captchaMock, compose, composeDown, composePull, composeStop, composeUp, coreFixtures, createStack, credentialsPath, defineFixture, dockerAvailable, dockerHint, dockerStatus, ensurePlugin, ensurePlugins, findConfigDir, getTestCredentials, githubRelease, isLocalPlugin, isSeeded, kizloRelease, menuFixture, postFixture, recordedPort, resolvePluginSource, runningProjectContainers, settleFixtures, stackStatus, stopProjectContainers, testAuthAdapter, toTestUser, wpCli, wpEval };
@@ -66,7 +66,8 @@ function buildWordPressRequest(definition, input) {
66
66
  body: rest,
67
67
  requestContentType: definition.requestContentType
68
68
  } : { searchParams: rest },
69
- responseContentTypes: definition.responseContentTypes
69
+ responseContentTypes: definition.responseContentTypes,
70
+ dataResponseStatuses: definition.dataResponseStatuses
70
71
  },
71
72
  error: null
72
73
  };
@@ -3,6 +3,7 @@ import { WP_CommonErrorCode, WP_ErrorData } from "./types.js";
3
3
  //#region src/wordpress/error.d.ts
4
4
  declare class WP_Error<TCode extends string = string> extends Error {
5
5
  code: TCode | WP_CommonErrorCode;
6
+ readonly data: unknown;
6
7
  constructor(error: WP_ErrorData<TCode>);
7
8
  }
8
9
  //#endregion
@@ -1,10 +1,12 @@
1
1
  //#region src/wordpress/error.ts
2
2
  var WP_Error = class extends Error {
3
3
  code;
4
+ data;
4
5
  constructor(error) {
5
6
  super(error.message ?? "Internal server error, please try again.");
6
7
  this.name = "WordPress Error";
7
8
  this.code = error.code;
9
+ this.data = error.data ?? null;
8
10
  }
9
11
  };
10
12
 
@@ -6,7 +6,7 @@ import { PLUGIN_VERSION_HEADER } from "@kizlo/shared";
6
6
  * WordPress could not be asked, or did not answer with a contract: a transport failure, a non-2xx
7
7
  * status, a body that is not JSON. A document that parsed is never one of these, however much of it
8
8
  * WordPress had to exclude, because what to do about an exclusion is the generator's policy and not
9
- * this function's. It reports; {@link generateWordPressOnce} decides.
9
+ * this function's. It reports; {@link generateIntrospectionOnce} decides.
10
10
  */
11
11
  var IntrospectionFetchError = class extends Error {
12
12
  /**
@@ -182,6 +182,9 @@ function responseStatus(status) {
182
182
  function isSuccessStatus(status) {
183
183
  return /^2\d\d$/.test(status);
184
184
  }
185
+ function isWordPressErrorResponse(response) {
186
+ return response.body?.$ref === "kizlo.error";
187
+ }
185
188
  /**
186
189
  * Every failing status of an endpoint carries the same error union, so spelling one member per
187
190
  * status would repeat it four or five times for no discrimination anyone can act on. They collapse
@@ -193,10 +196,10 @@ function renderResult(apiId, operationId, operation, context) {
193
196
  const name = endpointName(apiId, operationId, "EndpointResult");
194
197
  const errors = operation.errors.map(literal).join(" | ") || "never";
195
198
  const responses = sortedEntries(operation.responses);
196
- const failures = responses.filter(([status]) => !isSuccessStatus(status));
199
+ const failures = responses.filter(([, response]) => isWordPressErrorResponse(response));
197
200
  const headerNames = [...new Set(responses.flatMap(([, response]) => responseHeaderNames(response, context)))].sort((left, right) => left.localeCompare(right)).map(literal).join(" | ");
198
201
  const sharedHeaderNames = headerNames ? `, ${headerNames}` : "";
199
- const variants = responses.filter(([status]) => isSuccessStatus(status)).map(([status, response]) => `WP_Success<${responseBody(response, context)}, ${status}, ${responseHeaders(response, context)}${sharedHeaderNames}>`);
202
+ const variants = responses.filter(([, response]) => !isWordPressErrorResponse(response)).map(([status, response]) => `WP_Success<${responseBody(response, context)}, ${status}, ${responseHeaders(response, context)}${sharedHeaderNames}>`);
200
203
  if (new Set([NO_HEADERS, ...failures.map(([, response]) => responseHeaders(response, context))]).size === 1) variants.push(`WP_Failure<${errors}, number, ${NO_HEADERS}${sharedHeaderNames}>`);
201
204
  else {
202
205
  for (const [status, response] of failures) variants.push(`WP_Failure<${errors}, ${responseStatus(status)}, ${responseHeaders(response, context)}${sharedHeaderNames}>`);
@@ -257,13 +260,15 @@ function sortedEndpoints(node) {
257
260
  function endpointDefinition(entry) {
258
261
  const pathParameters = sortedEntries(entry.operation.input.properties ?? {}).filter(([, schema]) => schema.in === "path").map(([name]) => name);
259
262
  const responseContentTypes = Object.fromEntries(sortedEntries(entry.operation.responses).map(([status, response]) => [status, response.content_type]));
263
+ const dataResponseStatuses = sortedEntries(entry.operation.responses).filter(([status, response]) => !isSuccessStatus(status) && !isWordPressErrorResponse(response)).map(([status]) => status);
260
264
  return {
261
265
  namespace: entry.namespace,
262
266
  path: entry.path,
263
267
  method: entry.operation.method,
264
268
  pathParameters,
265
269
  ...entry.operation.input.content_type ? { requestContentType: entry.operation.input.content_type } : {},
266
- responseContentTypes
270
+ responseContentTypes,
271
+ ...dataResponseStatuses.length > 0 ? { dataResponseStatuses } : {}
267
272
  };
268
273
  }
269
274
  function renderRecord(value) {
@@ -279,7 +284,8 @@ function renderDefinition(definition) {
279
284
  `method: ${literal(definition.method)}`,
280
285
  `pathParameters: [${definition.pathParameters.map(literal).join(", ")}]`,
281
286
  ...definition.requestContentType ? [`requestContentType: ${literal(definition.requestContentType)}`] : [],
282
- `responseContentTypes: ${renderRecord(definition.responseContentTypes)}`
287
+ `responseContentTypes: ${renderRecord(definition.responseContentTypes)}`,
288
+ ...definition.dataResponseStatuses?.length ? [`dataResponseStatuses: [${definition.dataResponseStatuses.map(literal).join(", ")}]`] : []
283
289
  ].join(", ")} }`;
284
290
  }
285
291
  /**
@@ -112,6 +112,7 @@ var WordPressTransport = class {
112
112
  headers: response.headers
113
113
  });
114
114
  const expectedContentType = input.responseContentTypes?.[String(response.status)] ?? input.responseContentTypes?.default;
115
+ const acceptsData = response.ok || input.dataResponseStatuses?.includes(String(response.status)) === true || input.dataResponseStatuses?.includes("default") === true;
115
116
  const contentType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() || expectedContentType || "application/json";
116
117
  let body;
117
118
  try {
@@ -127,7 +128,7 @@ var WordPressTransport = class {
127
128
  })
128
129
  };
129
130
  }
130
- if (response.ok && typeof body === "string" && body.trim() === "") return {
131
+ if (acceptsData && typeof body === "string" && body.trim() === "") return {
131
132
  data: null,
132
133
  status: response.status,
133
134
  headers: response.headers,
@@ -147,10 +148,11 @@ var WordPressTransport = class {
147
148
  headers: response.headers,
148
149
  error: new WP_Error({
149
150
  code: data.code,
150
- message: data.message
151
+ message: data.message,
152
+ data: data.data
151
153
  })
152
154
  };
153
- return {
155
+ if (!acceptsData) return {
154
156
  data: null,
155
157
  status: response.status,
156
158
  headers: response.headers,
@@ -113,6 +113,7 @@ type WP_CommonErrorCode = "rest_no_route" | "rest_cookie_invalid_nonce" | "inval
113
113
  interface WP_ErrorData<T extends string> {
114
114
  code: T | WP_CommonErrorCode;
115
115
  message: string;
116
+ data?: unknown;
116
117
  }
117
118
  interface WP_ListMetadata {
118
119
  page: number;
@@ -145,6 +146,7 @@ interface WP_RequestInput {
145
146
  method: WP_RequestMethod;
146
147
  requestContentType?: WP_RequestContentType;
147
148
  responseContentTypes?: Record<string, WP_ResponseContentType | undefined>;
149
+ dataResponseStatuses?: string[];
148
150
  signal?: AbortSignal;
149
151
  timeout?: Duration;
150
152
  }
@@ -170,6 +172,8 @@ interface WP_EndpointDefinition {
170
172
  pathParameters: string[];
171
173
  requestContentType?: WP_RequestContentType;
172
174
  responseContentTypes: Record<string, WP_ResponseContentType | undefined>;
175
+ /** Non-2xx statuses whose declared body is data rather than a WordPress error envelope. */
176
+ dataResponseStatuses?: string[];
173
177
  }
174
178
  interface WordPressCredentials {
175
179
  url: string;
@@ -2,6 +2,7 @@
2
2
  declare function isWordPressResourceError<TCode extends string>(data: unknown): data is {
3
3
  code: TCode;
4
4
  message: string;
5
+ data?: unknown;
5
6
  };
6
7
  //#endregion
7
8
  export { isWordPressResourceError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kizlo",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "description": "A headless WordPress framework for TypeScript.",
6
6
  "keywords": [