kizlo 0.20.1 → 0.20.2
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/cli/commands/_wiring.js +2 -1
- package/dist/cli/commands/generate.js +21 -7
- package/dist/cli/daemon/config.js +36 -11
- package/dist/cli/daemon/generate.js +1 -0
- package/dist/cli/daemon/watch.js +12 -14
- package/dist/config.d.ts +12 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kizlo.d.ts +7 -1
- package/dist/kizlo.js +16 -2
- package/dist/package.js +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,8 @@ import * as p from "@clack/prompts";
|
|
|
10
10
|
//#region src/cli/commands/_wiring.ts
|
|
11
11
|
/** The kizlo.config.ts a scaffolded project gets: the Kizlo directory, the import-alias preference, and,
|
|
12
12
|
* when local WordPress is chosen, `local: true` so `kizlo dev` and `kizlo test` boot the fixed
|
|
13
|
-
* `.kizlo/local` install (both stacks on with defaults; the object form
|
|
13
|
+
* `.kizlo/local` install (both stacks on with defaults; the object form configures them and turns each
|
|
14
|
+
* on with its own `enable: true`). The
|
|
14
15
|
* alias is always written (`""` for relative imports included) so it records a made decision a later
|
|
15
16
|
* `kizlo init` reads back instead of prompting for it again. The alias is written in its canonical `@/`
|
|
16
17
|
* form (never a bare `@`) so it reads like the imports it produces. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { log } from "../daemon/logger.js";
|
|
2
|
-
import { resolveConfig } from "../daemon/config.js";
|
|
2
|
+
import { resolveConfig, resolveWatchCredentials } from "../daemon/config.js";
|
|
3
3
|
import { PartialContractError, generateOnce, reportGenerationError } from "../daemon/generate.js";
|
|
4
4
|
import { testWordPressCredentials } from "./_test-wordpress.js";
|
|
5
5
|
import path from "node:path";
|
|
@@ -38,18 +38,31 @@ const generate = defineCommand({
|
|
|
38
38
|
async run({ args }) {
|
|
39
39
|
const cwd = process.cwd();
|
|
40
40
|
const strict = args.strict === true;
|
|
41
|
-
let
|
|
41
|
+
let options;
|
|
42
42
|
if (args.test) try {
|
|
43
|
-
|
|
43
|
+
options = {
|
|
44
|
+
credentials: await testWordPressCredentials(cwd),
|
|
45
|
+
strict
|
|
46
|
+
};
|
|
44
47
|
} catch (error) {
|
|
45
48
|
log.error(error instanceof Error ? error.message : String(error));
|
|
46
49
|
process.exitCode = 1;
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
|
-
|
|
50
|
-
credentials
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
else {
|
|
53
|
+
const credentials = await resolveWatchCredentials(cwd);
|
|
54
|
+
if (credentials) options = {
|
|
55
|
+
credentials,
|
|
56
|
+
strict
|
|
57
|
+
};
|
|
58
|
+
else {
|
|
59
|
+
log.info("No WordPress connection configured; generating the contract only, introspection skipped.");
|
|
60
|
+
options = {
|
|
61
|
+
skipIntrospection: true,
|
|
62
|
+
strict
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
53
66
|
const cfg = await resolveConfig(cwd, { dir: args.dir });
|
|
54
67
|
if (!cfg) {
|
|
55
68
|
log.info("Nothing to generate. Set `dir` in kizlo.config.ts or pass --dir.");
|
|
@@ -66,6 +79,7 @@ const generate = defineCommand({
|
|
|
66
79
|
process.exit(1);
|
|
67
80
|
}
|
|
68
81
|
if (result.contract === "none") {
|
|
82
|
+
if (result.introspection === "skipped") return;
|
|
69
83
|
const file = path.resolve(cwd, cfg.introspectionPath);
|
|
70
84
|
log.success(`WordPress introspection ${result.introspection === "generated" ? "written to" : "already current at"} ${file}`);
|
|
71
85
|
return;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { integrationEnv, resolveWordPressConnection, wordPressConnectionComplete } from "../../kizlo.js";
|
|
1
2
|
import { DEFAULT_WORDPRESS_TAG, INTROSPECTION_META_REL, LOCAL_DIR_REL } from "../wp/constants.js";
|
|
2
3
|
import { credentialsPath, findConfigDir } from "../wp/utils.js";
|
|
4
|
+
import { node } from "../../integrations/node/integration.js";
|
|
3
5
|
import { log } from "./logger.js";
|
|
4
|
-
import { detectPackageManager } from "../utils.js";
|
|
6
|
+
import { detectPackageManager, loadEnvFiles } from "../utils.js";
|
|
5
7
|
import { WORDPRESS_TAG_PATTERN } from "../wp/version.js";
|
|
6
8
|
import { importIgnoringVirtualModules } from "./jiti.js";
|
|
7
9
|
import z from "zod/v4";
|
|
@@ -66,21 +68,31 @@ const configSchema = z.object({
|
|
|
66
68
|
dev: removedKey("`dev` is no longer a config root key. Move it under `local.dev`."),
|
|
67
69
|
test: removedKey("`test` is no longer a config root key. Move it under `local.test`.")
|
|
68
70
|
});
|
|
69
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Normalize `local` (absent, `true`, `false`, or the object form) into one shape the resolvers read.
|
|
73
|
+
* A stack is off unless its own `enable: true` is set; `local: true` is the shorthand that turns both on.
|
|
74
|
+
*/
|
|
70
75
|
function resolveLocal(fileConfig) {
|
|
71
76
|
const local = fileConfig?.local;
|
|
72
77
|
if (local === true) return {
|
|
73
78
|
enabled: true,
|
|
79
|
+
devEnabled: true,
|
|
80
|
+
testEnabled: true,
|
|
74
81
|
dev: {},
|
|
75
82
|
test: {}
|
|
76
83
|
};
|
|
77
84
|
if (!local) return {
|
|
78
85
|
enabled: false,
|
|
86
|
+
devEnabled: false,
|
|
87
|
+
testEnabled: false,
|
|
79
88
|
dev: {},
|
|
80
89
|
test: {}
|
|
81
90
|
};
|
|
91
|
+
const enabled = local.enable !== false;
|
|
82
92
|
return {
|
|
83
|
-
enabled
|
|
93
|
+
enabled,
|
|
94
|
+
devEnabled: enabled && local.dev?.enable === true,
|
|
95
|
+
testEnabled: enabled && local.test?.enable === true,
|
|
84
96
|
name: local.name,
|
|
85
97
|
worktrees: local.worktrees,
|
|
86
98
|
dev: local.dev ?? {},
|
|
@@ -241,7 +253,7 @@ async function resolveTestConfig(cwd) {
|
|
|
241
253
|
const inherit = test.inherit !== false;
|
|
242
254
|
return {
|
|
243
255
|
configDir,
|
|
244
|
-
local: local.
|
|
256
|
+
local: local.testEnabled,
|
|
245
257
|
project: stackProject(resolveStackName(configDir, {
|
|
246
258
|
name: local.name,
|
|
247
259
|
worktrees: local.worktrees
|
|
@@ -256,14 +268,27 @@ async function resolveTestConfig(cwd) {
|
|
|
256
268
|
};
|
|
257
269
|
}
|
|
258
270
|
/**
|
|
259
|
-
* Whether this project runs local WordPress under `kizlo dev`: local is enabled and the dev
|
|
260
|
-
* on
|
|
261
|
-
* runs the contract watcher alone, the path a project pointing at its
|
|
262
|
-
* `create`/`init` when local WordPress is chosen, so it's committed and
|
|
271
|
+
* Whether this project runs local WordPress under `kizlo dev`: the `local` block is enabled and the dev
|
|
272
|
+
* stack is turned on with `local.dev.enable: true` (or `local: true`) in `kizlo.config.*`. When false,
|
|
273
|
+
* `kizlo dev` has nothing to boot and runs the contract watcher alone, the path a project pointing at its
|
|
274
|
+
* own WordPress takes. Written by `create`/`init` when local WordPress is chosen, so it's committed and
|
|
275
|
+
* survives `kizlo dev reset`.
|
|
263
276
|
*/
|
|
264
277
|
async function usesLocalWordPress(cwd) {
|
|
265
|
-
|
|
266
|
-
|
|
278
|
+
return resolveLocal(await loadConfigFile(findConfigDir(cwd))).devEnabled;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* WordPress credentials for the dev/generate watcher, or `undefined` when there is nothing to introspect:
|
|
282
|
+
* the active profile is `local` but no local dev stack is enabled, or the active profile's connection
|
|
283
|
+
* envs are incomplete. Callers then generate the contract with introspection skipped rather than fetching
|
|
284
|
+
* from a WordPress that is not there. Unlike {@link resolveWordPressConnection}, this never throws.
|
|
285
|
+
*/
|
|
286
|
+
async function resolveWatchCredentials(cwd) {
|
|
287
|
+
loadEnvFiles(cwd);
|
|
288
|
+
const env = integrationEnv([node()]);
|
|
289
|
+
if (env("mode")?.trim() === "local" && !await usesLocalWordPress(cwd)) return void 0;
|
|
290
|
+
if (!wordPressConnectionComplete(env)) return void 0;
|
|
291
|
+
return resolveWordPressConnection(env).credentials;
|
|
267
292
|
}
|
|
268
293
|
/**
|
|
269
294
|
* Resolve the dev stack (`local.dev`) into concrete values for the `dev` command, applying defaults
|
|
@@ -293,4 +318,4 @@ async function resolveDevConfig(cwd) {
|
|
|
293
318
|
}
|
|
294
319
|
|
|
295
320
|
//#endregion
|
|
296
|
-
export { CONFIG_FILES, DEFAULT_DEV_DB_PORT, DEFAULT_DEV_PORT, resolveConfig, resolveDevConfig, resolveStackName, resolveTestConfig, stackProject, usesLocalWordPress };
|
|
321
|
+
export { CONFIG_FILES, DEFAULT_DEV_DB_PORT, DEFAULT_DEV_PORT, resolveConfig, resolveDevConfig, resolveStackName, resolveTestConfig, resolveWatchCredentials, stackProject, usesLocalWordPress };
|
|
@@ -205,6 +205,7 @@ async function generateIntrospectionSource(cwd, options = {}) {
|
|
|
205
205
|
* it under `generated/`, and a package that only ships procedures writes it at its own `dir.introspection`.
|
|
206
206
|
*/
|
|
207
207
|
async function generateIntrospectionOnce(cfg, options = {}) {
|
|
208
|
+
if (options.skipIntrospection) return "skipped";
|
|
208
209
|
const file = path.resolve(cfg.cwd, cfg.introspectionPath);
|
|
209
210
|
const metaPath = path.resolve(cfg.cwd, cfg.introspectionMetaPath);
|
|
210
211
|
const result = await fetchDocument(cfg.cwd, options, readWordPressMeta(metaPath, file)?.etag);
|
package/dist/cli/daemon/watch.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { integrationEnv, resolveWordPressConnection } from "../../kizlo.js";
|
|
2
|
-
import { node } from "../../integrations/node/integration.js";
|
|
3
1
|
import { log } from "./logger.js";
|
|
4
|
-
import {
|
|
5
|
-
import { resolveConfig } from "./config.js";
|
|
2
|
+
import { resolveConfig, resolveWatchCredentials } from "./config.js";
|
|
6
3
|
import { IntrospectionFetchError } from "../../wordpress/fetch-introspection.js";
|
|
7
4
|
import { generateIntrospectionOnce, generateOnce, reportGenerationError } from "./generate.js";
|
|
8
5
|
import { acquire, lockPath, release } from "./lock.js";
|
|
@@ -17,9 +14,9 @@ function debounce(fn, delay) {
|
|
|
17
14
|
timer = setTimeout(() => void fn(...args), delay);
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
|
-
async function regenerate(cfg,
|
|
17
|
+
async function regenerate(cfg, options) {
|
|
21
18
|
try {
|
|
22
|
-
const result = await generateOnce(cfg,
|
|
19
|
+
const result = await generateOnce(cfg, options);
|
|
23
20
|
if (result.contract === "built") log.success("Contract updated");
|
|
24
21
|
else if (result.contract === "empty" && cfg.server) log.warn(`No Kizlo server found in ${cfg.server.entry}`);
|
|
25
22
|
} catch (error) {
|
|
@@ -27,13 +24,13 @@ async function regenerate(cfg, credentials) {
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
/** Watches the server directory and regenerates the contract on change. Only called when a server is present. */
|
|
30
|
-
async function watch(cfg, server,
|
|
27
|
+
async function watch(cfg, server, options) {
|
|
31
28
|
const watcher = new FSWatcher({
|
|
32
29
|
persistent: true,
|
|
33
30
|
ignoreInitial: true,
|
|
34
31
|
ignored: path.resolve(cfg.cwd, server.contractDir)
|
|
35
32
|
});
|
|
36
|
-
const onChange = debounce(() => regenerate(cfg,
|
|
33
|
+
const onChange = debounce(() => regenerate(cfg, options), 300);
|
|
37
34
|
watcher.add(path.resolve(cfg.cwd, server.dir));
|
|
38
35
|
watcher.on("all", () => void onChange());
|
|
39
36
|
return watcher;
|
|
@@ -139,25 +136,26 @@ async function startWatcher(cwd, opts) {
|
|
|
139
136
|
log.info("skipping the contract generation.");
|
|
140
137
|
return;
|
|
141
138
|
}
|
|
142
|
-
|
|
143
|
-
const { credentials }
|
|
139
|
+
const credentials = await resolveWatchCredentials(cwd);
|
|
140
|
+
const options = credentials ? { credentials } : { skipIntrospection: true };
|
|
141
|
+
if (!credentials) log.info("No WordPress connection configured; running the contract watcher only, introspection skipped.");
|
|
144
142
|
try {
|
|
145
|
-
const result = await generateOnce(cfg,
|
|
143
|
+
const result = await generateOnce(cfg, options);
|
|
146
144
|
if (result.contract === "built") log.success("Contract generated");
|
|
147
145
|
else if (result.contract === "empty" && cfg.server) log.warn(`No Kizlo server found in ${cfg.server.entry}`);
|
|
148
146
|
else if (result.introspection === "generated") log.success("WordPress introspection generated");
|
|
149
147
|
} catch (error) {
|
|
150
148
|
reportGenerationError("Failed to generate the Kizlo contract:", error);
|
|
151
149
|
}
|
|
152
|
-
const watcher = cfg.server ? await watch(cfg, cfg.server,
|
|
153
|
-
const wordpressRefresh = refreshWordPress(cfg, credentials, opts?.stack);
|
|
150
|
+
const watcher = cfg.server ? await watch(cfg, cfg.server, options) : void 0;
|
|
151
|
+
const wordpressRefresh = credentials ? refreshWordPress(cfg, credentials, opts?.stack) : void 0;
|
|
154
152
|
let stopped = false;
|
|
155
153
|
handedOver = true;
|
|
156
154
|
return () => {
|
|
157
155
|
if (stopped) return;
|
|
158
156
|
stopped = true;
|
|
159
157
|
release(lock);
|
|
160
|
-
clearInterval(wordpressRefresh);
|
|
158
|
+
if (wordpressRefresh) clearInterval(wordpressRefresh);
|
|
161
159
|
watcher?.close();
|
|
162
160
|
};
|
|
163
161
|
} finally {
|
package/dist/config.d.ts
CHANGED
|
@@ -20,8 +20,9 @@ type KizloDir = string | {
|
|
|
20
20
|
};
|
|
21
21
|
interface KizloDevConfig {
|
|
22
22
|
/**
|
|
23
|
-
* Run the dev stack
|
|
24
|
-
*
|
|
23
|
+
* Run the dev stack under `kizlo dev`. Off unless set to `true`; `local: true` is the shorthand that
|
|
24
|
+
* turns both stacks on. Leave it off to keep the stack configured while `kizlo dev` runs the contract
|
|
25
|
+
* watcher alone (for example when only `kizlo test` boots local WordPress).
|
|
25
26
|
*/
|
|
26
27
|
enable?: boolean;
|
|
27
28
|
/** Published WP port (default 8080). */
|
|
@@ -59,8 +60,9 @@ interface KizloDevConfig {
|
|
|
59
60
|
}
|
|
60
61
|
interface KizloTestConfig {
|
|
61
62
|
/**
|
|
62
|
-
* Run the test stack
|
|
63
|
-
*
|
|
63
|
+
* Run the test stack under `kizlo test`. Off unless set to `true`; `local: true` is the shorthand that
|
|
64
|
+
* turns both stacks on. Leave it off and `kizlo test` just runs the project's own test script without
|
|
65
|
+
* booting local WordPress.
|
|
64
66
|
*/
|
|
65
67
|
enable?: boolean;
|
|
66
68
|
/**
|
|
@@ -91,8 +93,9 @@ interface KizloTestConfig {
|
|
|
91
93
|
}
|
|
92
94
|
interface KizloLocalConfig {
|
|
93
95
|
/**
|
|
94
|
-
*
|
|
95
|
-
* stacks configured but off, the same as omitting `local` entirely.
|
|
96
|
+
* Master switch for local Docker WordPress (default `true` in this object form). Set `false` to keep
|
|
97
|
+
* the stacks configured but off, the same as omitting `local` entirely. Each stack is still off until
|
|
98
|
+
* its own `enable: true` — see {@link KizloDevConfig.enable} and {@link KizloTestConfig.enable}.
|
|
96
99
|
*/
|
|
97
100
|
enable?: boolean;
|
|
98
101
|
/**
|
|
@@ -131,9 +134,9 @@ interface KizloGlobalConfig {
|
|
|
131
134
|
*/
|
|
132
135
|
alias?: string;
|
|
133
136
|
/**
|
|
134
|
-
* Local Docker WordPress, off unless set. `true` enables both the dev and test stacks with
|
|
135
|
-
*
|
|
136
|
-
* per-branch `worktrees` toggle, and the two stacks live.
|
|
137
|
+
* Local Docker WordPress, off unless set. `true` enables both the dev and test stacks with defaults;
|
|
138
|
+
* the object form configures them, with each stack off until its own `enable: true`, and is where the
|
|
139
|
+
* stack name, the per-branch `worktrees` toggle, and the two stacks live.
|
|
137
140
|
*/
|
|
138
141
|
local?: boolean | KizloLocalConfig;
|
|
139
142
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ import { AnyMiddleware, ExtractMiddlewareContextOutput, InferMiddlewares, Middle
|
|
|
30
30
|
import { AnyProcedure, AnyProcedureTree, BaseHandlerOptions, ExtractParams, ExtractProcedureByScope, InvocationScope, OpenapiPart, Procedure, ProcedureErrors, ProcedureHandler, ProcedureOptions, ProcedureTreeDepthTuple, ResolveParamsPart, ResolvedSchemaInput, ResolvedSchemaOutput, SchemaIO, buildProcedure, combineDetailed, createProcedure, handleUnexpectedError, schemaType } from "./shared/procedure.js";
|
|
31
31
|
import { AnyIntegration, EnvReader, EnvRecord, EnvSource, ExtractIntegrationProcedures, InferIntegrationProcedures, Integration, IntegrationRequirements, KizloEnv, WordPressEnv, assertIntegrationEndpoints, assertIntegrationEnv, createIntegration, missingEndpoints, missingEnv, readEnv } from "./shared/integration.js";
|
|
32
32
|
import { InferProcedureData, InferProcedureError, InferProcedureInput, InferProcedureResult, KizloErrorUnion, KizloResult, MaybeCallerOptions, ProcedureMethod, ResultClient, createResultClient } from "./shared/result.js";
|
|
33
|
-
import { AnyKizloConfig, CreateKizloOptions, Kizlo, KizloConfig, RootProcedures, S2SClient, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection } from "./kizlo.js";
|
|
33
|
+
import { AnyKizloConfig, CreateKizloOptions, Kizlo, KizloConfig, RootProcedures, S2SClient, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection, wordPressConnectionComplete } from "./kizlo.js";
|
|
34
34
|
import { WEB_MANIFEST_ROUTE, WebManifest, buildWebManifest, createManifestRoute } from "./brand/manifest.js";
|
|
35
35
|
import "./brand/index.js";
|
|
36
36
|
import { KizloClient, KizloClientConfig, createKizloClient } from "./client.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, 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, wordPressConnectionComplete, wpEndpoint, xmlResponse };
|
package/dist/index.js
CHANGED
|
@@ -34,8 +34,8 @@ import { TagCustomFieldsSchema } from "./tag/schema.js";
|
|
|
34
34
|
import { CORE_PROCEDURES } from "./procedures.js";
|
|
35
35
|
import { assertIntegrationEndpoints, assertIntegrationEnv, createIntegration, missingEndpoints, missingEnv, readEnv } from "./shared/integration.js";
|
|
36
36
|
import { createEventHandler, createWebhookRouter } from "./webhook/index.js";
|
|
37
|
-
import { Kizlo, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection } from "./kizlo.js";
|
|
37
|
+
import { Kizlo, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection, wordPressConnectionComplete } from "./kizlo.js";
|
|
38
38
|
import { SITEMAP_BASE, SITEMAP_INDEX_SLUG, createSitemapRedirectRoute, createSitemapRoute } from "./seo/sitemap.js";
|
|
39
39
|
import { createMiddleware } from "./shared/middleware.js";
|
|
40
40
|
|
|
41
|
-
export { COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CategoryCustomFieldsSchema, ContentType, Context, CookiesStorage, CurrencyFormat, IdentifierInput, Kizlo, KizloClient, KizloError, LIST_ORDER, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, PageCustomFieldsSchema, PostCustomFieldsSchema, PreviewTokenData, PreviewTokenPayload, Robots, RobotsRule, SITEMAP_BASE, SITEMAP_INDEX_SLUG, Seo, SeoHead, SeoSchema, SettingsService, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList, TagCustomFieldsSchema, WEB_MANIFEST_ROUTE, WP_Error, WordPressTransport, 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 };
|
|
41
|
+
export { COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CategoryCustomFieldsSchema, ContentType, Context, CookiesStorage, CurrencyFormat, IdentifierInput, Kizlo, KizloClient, KizloError, LIST_ORDER, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, PageCustomFieldsSchema, PostCustomFieldsSchema, PreviewTokenData, PreviewTokenPayload, Robots, RobotsRule, SITEMAP_BASE, SITEMAP_INDEX_SLUG, Seo, SeoHead, SeoSchema, SettingsService, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList, TagCustomFieldsSchema, WEB_MANIFEST_ROUTE, WP_Error, WordPressTransport, 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, wordPressConnectionComplete, wpEndpoint, xmlResponse };
|
package/dist/kizlo.d.ts
CHANGED
|
@@ -52,6 +52,12 @@ interface CreateKizloOptions<TIntegrations extends readonly AnyIntegration[] = [
|
|
|
52
52
|
* Kizlo's active WordPress connection from the canonical `mode` value.
|
|
53
53
|
*/
|
|
54
54
|
declare function integrationEnv(integrations: readonly AnyIntegration[]): EnvReader;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the active profile carries a full WordPress connection, without throwing. The dev/generate
|
|
57
|
+
* flow uses this to decide whether introspection can be fetched at all; {@link resolveWordPressConnection}
|
|
58
|
+
* throws for the request path that must have a connection.
|
|
59
|
+
*/
|
|
60
|
+
declare function wordPressConnectionComplete(env: EnvReader): boolean;
|
|
55
61
|
declare function resolveWordPressConnection(env: EnvReader): {
|
|
56
62
|
credentials: WordPressCredentials;
|
|
57
63
|
};
|
|
@@ -65,4 +71,4 @@ declare function resolveKizloConfig<TIntegrations extends readonly AnyIntegratio
|
|
|
65
71
|
*/
|
|
66
72
|
declare function createKizlo<TIntegrations extends readonly AnyIntegration[] = []>(options?: CreateKizloOptions<TIntegrations>): Kizlo<TIntegrations>;
|
|
67
73
|
//#endregion
|
|
68
|
-
export { AnyKizloConfig, CreateKizloOptions, Kizlo, KizloConfig, RootProcedures, S2SClient, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection };
|
|
74
|
+
export { AnyKizloConfig, CreateKizloOptions, Kizlo, KizloConfig, RootProcedures, S2SClient, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection, wordPressConnectionComplete };
|
package/dist/kizlo.js
CHANGED
|
@@ -8,7 +8,7 @@ import { isTypescriptObject } from "./shared/utils.js";
|
|
|
8
8
|
import { Context } from "./context.js";
|
|
9
9
|
import { CORE_PROCEDURES } from "./procedures.js";
|
|
10
10
|
import { isContractGeneration } from "./shared/contract-generation.js";
|
|
11
|
-
import { assertIntegrationEndpoints, assertIntegrationEnv, readEnv } from "./shared/integration.js";
|
|
11
|
+
import { assertIntegrationEndpoints, assertIntegrationEnv, missingEnv, readEnv } from "./shared/integration.js";
|
|
12
12
|
import { createWebhookRouter } from "./webhook/index.js";
|
|
13
13
|
import { tryCatch } from "@kizlo/shared";
|
|
14
14
|
import { ORPCError, createRouterClient } from "@orpc/server";
|
|
@@ -161,6 +161,20 @@ function requireEnvValue(name, env) {
|
|
|
161
161
|
if (isContractGeneration()) return "";
|
|
162
162
|
throw new KizloError("MISSING_ENV_VALUE", { message: `Kizlo requires the "${name}" environment value. Provide it through an integration or an explicit createKizlo option.` });
|
|
163
163
|
}
|
|
164
|
+
/** The three connection values a WordPress request needs, scoped to the active profile by {@link integrationEnv}. */
|
|
165
|
+
const WORDPRESS_CONNECTION_VALUES = [
|
|
166
|
+
"wordpressUrl",
|
|
167
|
+
"wordpressUsername",
|
|
168
|
+
"wordpressPassword"
|
|
169
|
+
];
|
|
170
|
+
/**
|
|
171
|
+
* Whether the active profile carries a full WordPress connection, without throwing. The dev/generate
|
|
172
|
+
* flow uses this to decide whether introspection can be fetched at all; {@link resolveWordPressConnection}
|
|
173
|
+
* throws for the request path that must have a connection.
|
|
174
|
+
*/
|
|
175
|
+
function wordPressConnectionComplete(env) {
|
|
176
|
+
return missingEnv(env, WORDPRESS_CONNECTION_VALUES).length === 0;
|
|
177
|
+
}
|
|
164
178
|
function resolveWordPressConnection(env) {
|
|
165
179
|
return { credentials: {
|
|
166
180
|
url: requireEnvValue("wordpressUrl", env),
|
|
@@ -194,4 +208,4 @@ function createKizlo(options) {
|
|
|
194
208
|
}
|
|
195
209
|
|
|
196
210
|
//#endregion
|
|
197
|
-
export { Kizlo, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection };
|
|
211
|
+
export { Kizlo, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection, wordPressConnectionComplete };
|
package/dist/package.js
CHANGED