kizlo 0.19.0 → 0.20.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/cli/daemon/generate.js +8 -8
- package/dist/cli/daemon/watch.js +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/context.js +1 -1
- package/dist/kizlo.d.ts +6 -9
- package/dist/kizlo.js +8 -9
- package/dist/package.js +1 -1
- package/dist/procedures.d.ts +7 -7
- package/dist/wordpress/generate.js +3 -3
- package/dist/wordpress/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -14,16 +14,16 @@ import fs from "node:fs";
|
|
|
14
14
|
|
|
15
15
|
//#region src/cli/daemon/generate.ts
|
|
16
16
|
/**
|
|
17
|
-
* The generated barrel is also written as a stub by `kizlo init`. It re-exports `
|
|
18
|
-
* than pre-wrapping it: a server entry passes `
|
|
19
|
-
*
|
|
17
|
+
* The generated barrel is also written as a stub by `kizlo init`. It re-exports `introspection`
|
|
18
|
+
* rather than pre-wrapping it: a server entry passes `createKizlo({ introspection })` itself, so the
|
|
19
|
+
* rest of the options stay visible at the call site instead of hiding inside a generated object.
|
|
20
20
|
*/
|
|
21
21
|
const CONTRACT_BARREL = [
|
|
22
22
|
`import type { procedures } from ".."`,
|
|
23
23
|
`import contractJson from "./contract.json"`,
|
|
24
24
|
``,
|
|
25
25
|
`export const contract = contractJson as unknown as typeof procedures`,
|
|
26
|
-
`export {
|
|
26
|
+
`export { introspection, type WordPressClient } from "./introspection"`,
|
|
27
27
|
``
|
|
28
28
|
].join("\n");
|
|
29
29
|
var LegacyRouterExportError = class extends Error {
|
|
@@ -42,13 +42,13 @@ var LegacyRouterExportError = class extends Error {
|
|
|
42
42
|
const INTROSPECTION_STUB = [
|
|
43
43
|
`import type { WP_Client } from "kizlo"`,
|
|
44
44
|
``,
|
|
45
|
-
`export const
|
|
45
|
+
`export const introspection = {} as any`,
|
|
46
46
|
``,
|
|
47
|
-
`export type WordPressClient = WP_Client<typeof
|
|
47
|
+
`export type WordPressClient = WP_Client<typeof introspection>`,
|
|
48
48
|
``,
|
|
49
49
|
`declare module "kizlo" {`,
|
|
50
50
|
`\tinterface WordPressClientRegistry {`,
|
|
51
|
-
`\t\
|
|
51
|
+
`\t\tintrospection: typeof introspection`,
|
|
52
52
|
`\t}`,
|
|
53
53
|
`\tinterface WordPressEndpointRegistry {`,
|
|
54
54
|
`\t\t[path: string]: any`,
|
|
@@ -177,7 +177,7 @@ function reportPluginVersion(installed) {
|
|
|
177
177
|
/** Fetch `/introspect`, reporting its diagnostics in the CLI's voice. Returns undefined on a 304. */
|
|
178
178
|
async function fetchDocument(cwd, options, etag) {
|
|
179
179
|
loadEnvFiles(cwd);
|
|
180
|
-
const result = await fetchIntrospection(options.credentials ?? resolveWordPressConnection(
|
|
180
|
+
const result = await fetchIntrospection(options.credentials ?? resolveWordPressConnection(integrationEnv([node()])).credentials, {
|
|
181
181
|
etag: options.strict ? void 0 : etag,
|
|
182
182
|
fetch: options.fetch
|
|
183
183
|
});
|
package/dist/cli/daemon/watch.js
CHANGED
|
@@ -140,7 +140,7 @@ async function startWatcher(cwd, opts) {
|
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
loadEnvFiles(cwd);
|
|
143
|
-
const { credentials } = resolveWordPressConnection(
|
|
143
|
+
const { credentials } = resolveWordPressConnection(integrationEnv([node()]));
|
|
144
144
|
try {
|
|
145
145
|
const result = await generateOnce(cfg, { credentials });
|
|
146
146
|
if (result.contract === "built") log.success("Contract generated");
|
package/dist/context.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ interface ContextConfig {
|
|
|
16
16
|
siteSecret: string;
|
|
17
17
|
adapters?: ServiceAdapters;
|
|
18
18
|
credentials: WordPressCredentials;
|
|
19
|
-
|
|
19
|
+
introspection?: object;
|
|
20
20
|
/** WordPress plugins the registered integrations need, checked against what each response reports. */
|
|
21
21
|
integrationPlugins?: IntegrationPluginRequirement[];
|
|
22
22
|
}
|
package/dist/context.js
CHANGED
|
@@ -55,7 +55,7 @@ var Context = class {
|
|
|
55
55
|
this.wordpress = createWordPressClient(new WordPressTransport({
|
|
56
56
|
credentials: config.credentials,
|
|
57
57
|
onResult: (result) => this.warnIfOutdated(result)
|
|
58
|
-
}), config.
|
|
58
|
+
}), config.introspection ?? {});
|
|
59
59
|
this.settings = new SettingsService(this.wordpress);
|
|
60
60
|
this.email = new EmailService(this.wordpress);
|
|
61
61
|
this.logger = this.createLogger();
|
package/dist/kizlo.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface KizloConfig<TIntegrations extends readonly AnyIntegration[]> {
|
|
|
14
14
|
integrations?: TIntegrations;
|
|
15
15
|
logging?: false | LogLevel;
|
|
16
16
|
credentials: WordPressCredentials;
|
|
17
|
-
|
|
17
|
+
introspection?: object;
|
|
18
18
|
}
|
|
19
19
|
type RootProcedures<TIntegrations extends readonly AnyIntegration[]> = InferIntegrationProcedures<TIntegrations> & CoreProcedures;
|
|
20
20
|
type S2SClient<TIntegrations extends readonly AnyIntegration[]> = ResultClient<RootProcedures<TIntegrations>>;
|
|
@@ -41,21 +41,18 @@ interface CreateKizloOptions<TIntegrations extends readonly AnyIntegration[] = [
|
|
|
41
41
|
/** Enable Kizlo's built-in console logger at this level. */
|
|
42
42
|
logging?: false | LogLevel;
|
|
43
43
|
/**
|
|
44
|
-
* The generated
|
|
45
|
-
* `
|
|
46
|
-
* `wordpressUsername`, and `wordpressPassword` values contributed by integrations.
|
|
44
|
+
* The generated WordPress introspection tree to run the typed client against. Pass the
|
|
45
|
+
* `introspection` export of your generated barrel. WordPress credentials resolve from the
|
|
46
|
+
* `wordpressUrl`, `wordpressUsername`, and `wordpressPassword` values contributed by integrations.
|
|
47
47
|
*/
|
|
48
|
-
|
|
49
|
-
endpoints?: object;
|
|
50
|
-
credentials?: Partial<WordPressCredentials>;
|
|
51
|
-
};
|
|
48
|
+
introspection?: object;
|
|
52
49
|
}
|
|
53
50
|
/**
|
|
54
51
|
* Compose environment sources without letting `undefined` erase an earlier value, then resolve
|
|
55
52
|
* Kizlo's active WordPress connection from the canonical `mode` value.
|
|
56
53
|
*/
|
|
57
54
|
declare function integrationEnv(integrations: readonly AnyIntegration[]): EnvReader;
|
|
58
|
-
declare function resolveWordPressConnection(
|
|
55
|
+
declare function resolveWordPressConnection(env: EnvReader): {
|
|
59
56
|
credentials: WordPressCredentials;
|
|
60
57
|
};
|
|
61
58
|
/**
|
package/dist/kizlo.js
CHANGED
|
@@ -30,7 +30,7 @@ var Kizlo = class {
|
|
|
30
30
|
adapters: integrations.adapters,
|
|
31
31
|
siteSecret: config.siteSecret,
|
|
32
32
|
credentials: config.credentials,
|
|
33
|
-
|
|
33
|
+
introspection: config.introspection,
|
|
34
34
|
integrationPlugins: integrations.plugins
|
|
35
35
|
});
|
|
36
36
|
this.procedures = Object.assign(Object.assign({}, {
|
|
@@ -105,7 +105,7 @@ var Kizlo = class {
|
|
|
105
105
|
if (reservedIds.has(integration.id)) throw new KizloError("INTEGRATION_ID_CONFLICT", { message: `The integration id "${integration.id}" is reserved by Kizlo. Choose a different integration id.` });
|
|
106
106
|
if (integrationIds.has(integration.id)) throw new KizloError("INTEGRATION_ID_CONFLICT", { message: `The integration id "${integration.id}" is registered more than once. Give every integration a unique id.` });
|
|
107
107
|
integrationIds.add(integration.id);
|
|
108
|
-
if (!generating) assertIntegrationEndpoints(integration, this.config.
|
|
108
|
+
if (!generating) assertIntegrationEndpoints(integration, this.config.introspection ?? {});
|
|
109
109
|
plugins.push(...integration.requires?.plugins ?? []);
|
|
110
110
|
if (integration.procedures && Object.keys(integration.procedures).length > 0) procedures[integration.id] = integration.procedures;
|
|
111
111
|
for (const handler of integration.events ?? []) events.push(handler);
|
|
@@ -161,12 +161,11 @@ 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
|
-
function resolveWordPressConnection(
|
|
165
|
-
const credentials = options?.wordpress?.credentials;
|
|
164
|
+
function resolveWordPressConnection(env) {
|
|
166
165
|
return { credentials: {
|
|
167
|
-
url:
|
|
168
|
-
username:
|
|
169
|
-
password:
|
|
166
|
+
url: requireEnvValue("wordpressUrl", env),
|
|
167
|
+
username: requireEnvValue("wordpressUsername", env),
|
|
168
|
+
password: requireEnvValue("wordpressPassword", env)
|
|
170
169
|
} };
|
|
171
170
|
}
|
|
172
171
|
/**
|
|
@@ -176,14 +175,14 @@ function resolveKizloConfig(options) {
|
|
|
176
175
|
const integrations = options?.integrations ?? [];
|
|
177
176
|
const env = integrationEnv(integrations);
|
|
178
177
|
if (!isContractGeneration()) for (const integration of integrations) assertIntegrationEnv(integration, env);
|
|
179
|
-
const { credentials } = resolveWordPressConnection(
|
|
178
|
+
const { credentials } = resolveWordPressConnection(env);
|
|
180
179
|
return {
|
|
181
180
|
baseUrl: options?.baseUrl ?? requireEnvValue("baseUrl", env),
|
|
182
181
|
siteSecret: options?.siteSecret ?? requireEnvValue("siteSecret", env),
|
|
183
182
|
integrations,
|
|
184
183
|
logging: options?.logging,
|
|
185
184
|
credentials,
|
|
186
|
-
|
|
185
|
+
introspection: options?.introspection
|
|
187
186
|
};
|
|
188
187
|
}
|
|
189
188
|
/**
|
package/dist/package.js
CHANGED
package/dist/procedures.d.ts
CHANGED
|
@@ -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?: "
|
|
47
|
+
orderby?: "date" | "id" | "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?: "
|
|
102
|
+
orderby?: "date" | "id" | "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?: "
|
|
139
|
+
orderBy?: "count" | "id" | "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?: "
|
|
175
|
+
orderBy?: "count" | "id" | "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?: "
|
|
295
|
+
orderby?: "date" | "id" | "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?: "
|
|
374
|
+
orderby?: "date" | "id" | "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?: "
|
|
510
|
+
orderby?: "date" | "id" | "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;
|
|
@@ -383,7 +383,7 @@ function renderRegistries(tree, document) {
|
|
|
383
383
|
return [
|
|
384
384
|
`declare module "kizlo" {`,
|
|
385
385
|
`\tinterface WordPressClientRegistry {`,
|
|
386
|
-
`\t\
|
|
386
|
+
`\t\tintrospection: typeof introspection`,
|
|
387
387
|
`\t}`,
|
|
388
388
|
`\tinterface WordPressEndpointRegistry {`,
|
|
389
389
|
...endpoints,
|
|
@@ -431,8 +431,8 @@ function generateWordPressModule(document) {
|
|
|
431
431
|
const endpointBody = renderEndpointNode(tree, " ");
|
|
432
432
|
const moduleBody = [
|
|
433
433
|
body,
|
|
434
|
-
`export const
|
|
435
|
-
`export type WordPressClient = WP_Client<typeof
|
|
434
|
+
`export const introspection = ${endpointBody}`,
|
|
435
|
+
`export type WordPressClient = WP_Client<typeof introspection>`,
|
|
436
436
|
renderRegistries(tree, document)
|
|
437
437
|
].join(DECLARATION_SEPARATOR);
|
|
438
438
|
const imports = `import { ${kizloImports(moduleBody, endpointBody !== "{}")} } from "kizlo"`;
|
|
@@ -48,7 +48,7 @@ interface WordPressCustomFieldsRegistry {}
|
|
|
48
48
|
* so a freshly scaffolded project compiles against endpoints it has not described yet.
|
|
49
49
|
*/
|
|
50
50
|
type ActiveWordPressClient = WordPressClientRegistry extends {
|
|
51
|
-
|
|
51
|
+
introspection: infer TEndpoints extends object;
|
|
52
52
|
} ? WP_Client<TEndpoints> & WordPressTransport : WordPressTransport;
|
|
53
53
|
/** Every raw WordPress operation path generated for the active project. */
|
|
54
54
|
type WP_EndpointPath = keyof WordPressEndpointRegistry extends never ? string : Extract<keyof WordPressEndpointRegistry, string>;
|