kizlo 0.15.2 → 0.16.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/adapters/logger.d.ts +2 -5
- package/dist/adapters/logger.js +1 -1
- package/dist/adapters/types.d.ts +19 -0
- package/dist/adapters/types.js +17 -0
- package/dist/astro/server.d.ts +2 -2
- package/dist/astro/server.js +2 -2
- package/dist/category/index.js +2 -2
- package/dist/cli/commands/_setup.js +10 -10
- package/dist/cli/commands/dev.js +7 -7
- package/dist/cli/daemon/generate.js +19 -9
- package/dist/cli/daemon/jiti.js +4 -5
- package/dist/cli/daemon/watch.js +3 -2
- package/dist/cli/presets/template.js +1 -1
- package/dist/cli/utils.js +6 -6
- package/dist/cli/wp/bootstrap.js +15 -11
- package/dist/cli/wp/constants.js +1 -1
- package/dist/cli/wp/dev.js +6 -23
- package/dist/cli/wp/types.d.ts +2 -2
- package/dist/cli/wp/utils.d.ts +1 -1
- package/dist/cli/wp/utils.js +1 -1
- package/dist/client.d.ts +7 -7
- package/dist/client.js +1 -1
- package/dist/comment/index.js +2 -2
- package/dist/config.d.ts +8 -8
- package/dist/context.d.ts +5 -5
- package/dist/context.js +5 -5
- package/dist/index.d.ts +7 -6
- package/dist/index.js +5 -4
- package/dist/integrations/astro/integration.d.ts +12 -0
- package/dist/integrations/astro/integration.js +14 -0
- package/dist/integrations/astro/kizlo.client.d.ts +4 -4
- package/dist/integrations/astro/utils.d.ts +4 -5
- package/dist/integrations/astro/utils.js +5 -6
- package/dist/integrations/nextjs/integration.d.ts +15 -0
- package/dist/integrations/nextjs/integration.js +18 -0
- package/dist/integrations/nextjs/kizlo.client.d.ts +2 -2
- package/dist/integrations/nextjs/revalidate.d.ts +2 -3
- package/dist/integrations/nextjs/revalidate.js +4 -4
- package/dist/integrations/nextjs/utils.js +2 -2
- package/dist/integrations/node/integration.d.ts +12 -0
- package/dist/integrations/node/integration.js +14 -0
- package/dist/integrations/runtime-env.js +25 -0
- package/dist/integrations/tanstack-start/api.d.ts +1 -1
- package/dist/integrations/tanstack-start/integration.d.ts +12 -0
- package/dist/integrations/tanstack-start/integration.js +14 -0
- package/dist/integrations/tanstack-start/kizlo.client.d.ts +4 -4
- package/dist/integrations/tanstack-start/utils.d.ts +1 -1
- package/dist/integrations/tanstack-start/utils.js +3 -3
- package/dist/kizlo.d.ts +33 -70
- package/dist/kizlo.js +91 -75
- package/dist/menu/index.js +2 -2
- package/dist/nextjs/server.d.ts +2 -2
- package/dist/nextjs/server.js +2 -2
- package/dist/node.d.ts +2 -0
- package/dist/node.js +3 -0
- package/dist/package.js +1 -1
- package/dist/page/index.js +2 -2
- package/dist/post/index.js +2 -2
- package/dist/{router.d.ts → procedures.d.ts} +11 -11
- package/dist/procedures.js +23 -0
- package/dist/seo/index.js +2 -2
- package/dist/settings/index.js +2 -2
- package/dist/shared/constants.js +1 -9
- package/dist/shared/contract-generation.js +14 -0
- package/dist/shared/contract.d.ts +2 -2
- package/dist/shared/contract.js +2 -2
- package/dist/shared/integration.d.ts +91 -0
- package/dist/shared/integration.js +59 -0
- package/dist/shared/procedure.d.ts +8 -8
- package/dist/shared/result.d.ts +2 -2
- package/dist/shared/router.d.ts +2 -2
- package/dist/shared/router.js +2 -2
- package/dist/tag/index.js +2 -2
- package/dist/tanstack-start/server.d.ts +2 -2
- package/dist/tanstack-start/server.js +2 -2
- package/package.json +8 -2
- package/dist/integrations/astro/kizlo.server.d.ts +0 -10
- package/dist/integrations/astro/kizlo.server.js +0 -12
- package/dist/integrations/nextjs/kizlo.server.d.ts +0 -11
- package/dist/integrations/nextjs/kizlo.server.js +0 -15
- package/dist/integrations/tanstack-start/kizlo.server.d.ts +0 -14
- package/dist/integrations/tanstack-start/kizlo.server.js +0 -15
- package/dist/router.js +0 -23
- package/dist/shared/extension.d.ts +0 -58
- package/dist/shared/extension.js +0 -37
package/dist/kizlo.d.ts
CHANGED
|
@@ -1,77 +1,49 @@
|
|
|
1
1
|
import { WordPressCredentials } from "./wordpress/types.js";
|
|
2
2
|
import "./wordpress/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import { CaptchaAdapter } from "./adapters/captcha.js";
|
|
5
|
-
import { CookiesAdapter } from "./shared/types.js";
|
|
6
|
-
import { GeoAdapter } from "./adapters/geo.js";
|
|
7
|
-
import { Environment, LoggerAdapter } from "./adapters/logger.js";
|
|
3
|
+
import { LogLevel } from "./adapters/logger.js";
|
|
8
4
|
import { Context } from "./context.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { CoreProcedures } from "./procedures.js";
|
|
6
|
+
import { AnyIntegration, EnvReader, InferIntegrationProcedures } from "./shared/integration.js";
|
|
11
7
|
import { ResultClient } from "./shared/result.js";
|
|
12
8
|
|
|
13
9
|
//#region src/kizlo.d.ts
|
|
14
10
|
type AnyKizloConfig = KizloConfig<any>;
|
|
15
|
-
|
|
16
|
-
* Which credential set to read from the environment. Independent of `environment`
|
|
17
|
-
* (which carries logging semantics off `NODE_ENV`): `"local"` reads the `KIZLO_LOCAL_WP_*`
|
|
18
|
-
* / `KIZLO_LOCAL_WP_SECRET` keys local WordPress manages, `"remote"` reads `KIZLO_WP_*` / `KIZLO_WP_SECRET`.
|
|
19
|
-
*/
|
|
20
|
-
type KizloConnect = "local" | "remote";
|
|
21
|
-
interface KizloConfig<TExts extends readonly AnyExtension[]> {
|
|
11
|
+
interface KizloConfig<TIntegrations extends readonly AnyIntegration[]> {
|
|
22
12
|
baseUrl: string;
|
|
23
13
|
siteSecret: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
connect: KizloConnect;
|
|
27
|
-
adapters?: ServiceAdapters;
|
|
14
|
+
integrations?: TIntegrations;
|
|
15
|
+
logging?: false | LogLevel;
|
|
28
16
|
credentials: WordPressCredentials;
|
|
29
17
|
wordpressEndpoints?: object;
|
|
30
18
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
logger?: LoggerAdapter;
|
|
35
|
-
captcha?: CaptchaAdapter;
|
|
36
|
-
cookies?: CookiesAdapter;
|
|
37
|
-
}
|
|
38
|
-
type RootRouter<TExts extends readonly AnyExtension[]> = InferExtensionRouter<TExts> & RouterMap;
|
|
39
|
-
type S2SClient<TExts extends readonly AnyExtension[]> = ResultClient<RootRouter<TExts>>;
|
|
40
|
-
declare class Kizlo<TExts extends readonly AnyExtension[] = []> {
|
|
19
|
+
type RootProcedures<TIntegrations extends readonly AnyIntegration[]> = InferIntegrationProcedures<TIntegrations> & CoreProcedures;
|
|
20
|
+
type S2SClient<TIntegrations extends readonly AnyIntegration[]> = ResultClient<RootProcedures<TIntegrations>>;
|
|
21
|
+
declare class Kizlo<TIntegrations extends readonly AnyIntegration[] = []> {
|
|
41
22
|
readonly context: Context;
|
|
42
|
-
readonly client: S2SClient<
|
|
43
|
-
readonly
|
|
23
|
+
readonly client: S2SClient<TIntegrations>;
|
|
24
|
+
readonly procedures: RootProcedures<TIntegrations>;
|
|
44
25
|
private readonly remoteHandler;
|
|
45
26
|
private readonly openapiHandler;
|
|
46
27
|
private readonly config;
|
|
47
|
-
constructor(config: KizloConfig<
|
|
28
|
+
constructor(config: KizloConfig<TIntegrations>);
|
|
48
29
|
handler(request: Request): Promise<Response>;
|
|
49
30
|
private errorInterceptor;
|
|
50
31
|
private checkInvocationScope;
|
|
51
|
-
private
|
|
32
|
+
private registerIntegrations;
|
|
52
33
|
}
|
|
53
|
-
interface CreateKizloOptions<
|
|
54
|
-
/** Public base URL of your Kizlo server
|
|
34
|
+
interface CreateKizloOptions<TIntegrations extends readonly AnyIntegration[] = []> {
|
|
35
|
+
/** Public base URL of your Kizlo server. Falls back to the `baseUrl` value contributed by an integration. */
|
|
55
36
|
baseUrl?: string;
|
|
56
|
-
/** Secret shared with
|
|
37
|
+
/** Secret shared with WordPress. Falls back to the `siteSecret` value contributed by an integration. */
|
|
57
38
|
siteSecret?: string;
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Which credential set to use. Falls back to the `KIZLO_CONNECT` env var, then `"remote"`.
|
|
64
|
-
* Independent of `environment`: `"local"` reads `KIZLO_LOCAL_WP_*` / `KIZLO_LOCAL_WP_SECRET` (the keys
|
|
65
|
-
* local WordPress manages), `"remote"` reads `KIZLO_WP_*` / `KIZLO_WP_SECRET`.
|
|
66
|
-
*/
|
|
67
|
-
connect?: KizloConnect;
|
|
68
|
-
/** Service adapters: auth, captcha, geo, logger, and cookies. */
|
|
69
|
-
adapters?: ServiceAdapters;
|
|
39
|
+
/** Integrations to compose, built with `createIntegration`. */
|
|
40
|
+
integrations?: TIntegrations;
|
|
41
|
+
/** Enable Kizlo's built-in console logger at this level. */
|
|
42
|
+
logging?: false | LogLevel;
|
|
70
43
|
/**
|
|
71
|
-
* The generated endpoints to run against WordPress, plus
|
|
72
|
-
* `endpoints` export of your generated barrel.
|
|
73
|
-
*
|
|
74
|
-
* `KIZLO_WP_APP_PASSWORD`, and with the `"local"` connect to their `KIZLO_LOCAL_WP_*` counterparts.
|
|
44
|
+
* The generated endpoints to run against WordPress, plus optional explicit credentials. Pass the
|
|
45
|
+
* `endpoints` export of your generated barrel. Missing credentials fall back to the `wordpressUrl`,
|
|
46
|
+
* `wordpressUsername`, and `wordpressPassword` values contributed by integrations.
|
|
75
47
|
*/
|
|
76
48
|
wordpress?: {
|
|
77
49
|
endpoints?: object;
|
|
@@ -79,30 +51,21 @@ interface CreateKizloOptions<TExts extends readonly AnyExtension[] = []> {
|
|
|
79
51
|
};
|
|
80
52
|
}
|
|
81
53
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* resolved the Astro-native way (through the dev server / adapter) rather than through `process.env`.
|
|
54
|
+
* Compose environment sources without letting `undefined` erase an earlier value, then resolve
|
|
55
|
+
* Kizlo's active WordPress connection from the canonical `mode` value.
|
|
85
56
|
*/
|
|
86
|
-
|
|
87
|
-
declare function resolveWordPressConnection(options: Pick<CreateKizloOptions, "
|
|
88
|
-
connect: KizloConnect;
|
|
57
|
+
declare function integrationEnv(integrations: readonly AnyIntegration[]): EnvReader;
|
|
58
|
+
declare function resolveWordPressConnection(options: Pick<CreateKizloOptions, "wordpress"> | undefined, env: EnvReader): {
|
|
89
59
|
credentials: WordPressCredentials;
|
|
90
60
|
};
|
|
91
61
|
/**
|
|
92
|
-
* Resolves a full `KizloConfig` from options and the environment.
|
|
93
|
-
* base `createKizlo` and each framework factory — the single place env values
|
|
94
|
-
* and credentials are read. `baseUrlEnvKey` is the only framework-varying part.
|
|
62
|
+
* Resolves a full `KizloConfig` from explicit options and the composed integration environment.
|
|
95
63
|
*/
|
|
96
|
-
declare function resolveKizloConfig<
|
|
97
|
-
baseUrlEnvKey: string;
|
|
98
|
-
adapters?: ServiceAdapters;
|
|
99
|
-
env?: EnvReader;
|
|
100
|
-
}): KizloConfig<TExts>;
|
|
64
|
+
declare function resolveKizloConfig<TIntegrations extends readonly AnyIntegration[]>(options: CreateKizloOptions<TIntegrations> | undefined): KizloConfig<TIntegrations>;
|
|
101
65
|
/**
|
|
102
|
-
* Creates a Kizlo server from
|
|
103
|
-
*
|
|
104
|
-
* with their own URL convention and adapters.
|
|
66
|
+
* Creates a Kizlo server from integration-contributed environment values, with explicit options
|
|
67
|
+
* taking precedence.
|
|
105
68
|
*/
|
|
106
|
-
declare function createKizlo<
|
|
69
|
+
declare function createKizlo<TIntegrations extends readonly AnyIntegration[] = []>(options?: CreateKizloOptions<TIntegrations>): Kizlo<TIntegrations>;
|
|
107
70
|
//#endregion
|
|
108
|
-
export { AnyKizloConfig, CreateKizloOptions,
|
|
71
|
+
export { AnyKizloConfig, CreateKizloOptions, Kizlo, KizloConfig, RootProcedures, S2SClient, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection };
|
package/dist/kizlo.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { consoleLog } from "./adapters/logger.js";
|
|
2
|
+
import { mergeServiceAdapters } from "./adapters/types.js";
|
|
3
|
+
import { RPC_PROTOCOL_HEADER } from "./shared/constants.js";
|
|
2
4
|
import { KizloError } from "./shared/error.js";
|
|
3
5
|
import { createOrpcRouter } from "./shared/router.js";
|
|
4
6
|
import { createResultClient } from "./shared/result.js";
|
|
5
7
|
import { isTypescriptObject } from "./shared/utils.js";
|
|
6
8
|
import { Context } from "./context.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
+
import { CORE_PROCEDURES } from "./procedures.js";
|
|
10
|
+
import { isContractGeneration } from "./shared/contract-generation.js";
|
|
11
|
+
import { assertIntegrationEndpoints, assertIntegrationEnv, readEnv } from "./shared/integration.js";
|
|
9
12
|
import { createWebhookRouter } from "./webhook/index.js";
|
|
10
13
|
import { tryCatch } from "@kizlo/shared";
|
|
11
14
|
import { ORPCError, createRouterClient } from "@orpc/server";
|
|
@@ -16,25 +19,25 @@ import { RPCHandler } from "@orpc/server/fetch";
|
|
|
16
19
|
var Kizlo = class {
|
|
17
20
|
context;
|
|
18
21
|
client;
|
|
19
|
-
|
|
22
|
+
procedures;
|
|
20
23
|
remoteHandler;
|
|
21
24
|
openapiHandler;
|
|
22
25
|
config;
|
|
23
26
|
constructor(config) {
|
|
24
27
|
this.config = config;
|
|
25
|
-
const
|
|
28
|
+
const integrations = this.registerIntegrations();
|
|
26
29
|
this.context = new Context({
|
|
27
|
-
adapters:
|
|
30
|
+
adapters: integrations.adapters,
|
|
28
31
|
siteSecret: config.siteSecret,
|
|
29
32
|
credentials: config.credentials,
|
|
30
33
|
wordpressEndpoints: config.wordpressEndpoints,
|
|
31
|
-
|
|
34
|
+
integrationPlugins: integrations.plugins
|
|
32
35
|
});
|
|
33
|
-
this.
|
|
34
|
-
...
|
|
35
|
-
...
|
|
36
|
-
}), { webhooks: createWebhookRouter({ events:
|
|
37
|
-
const orpcRouter = createOrpcRouter(this.
|
|
36
|
+
this.procedures = Object.assign(Object.assign({}, {
|
|
37
|
+
...integrations.procedures,
|
|
38
|
+
...CORE_PROCEDURES
|
|
39
|
+
}), { webhooks: createWebhookRouter({ events: integrations.events }) });
|
|
40
|
+
const orpcRouter = createOrpcRouter(this.procedures);
|
|
38
41
|
this.client = createResultClient(createRouterClient(orpcRouter, { context: () => this.context.createServerContext() }));
|
|
39
42
|
this.remoteHandler = new RPCHandler(orpcRouter, {
|
|
40
43
|
filter: (options) => {
|
|
@@ -90,93 +93,106 @@ var Kizlo = class {
|
|
|
90
93
|
checkInvocationScope(value, scope) {
|
|
91
94
|
return isTypescriptObject(value) && "scope" in value && value.scope === scope;
|
|
92
95
|
}
|
|
93
|
-
|
|
94
|
-
const
|
|
96
|
+
registerIntegrations() {
|
|
97
|
+
const procedures = {};
|
|
95
98
|
const events = [];
|
|
96
99
|
const plugins = [];
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
|
|
100
|
+
let adapters = mergeServiceAdapters(this.config.logging ? { logger: consoleLog({ levels: levelsFrom(this.config.logging) }) } : void 0);
|
|
101
|
+
const reservedIds = new Set([...Object.keys(CORE_PROCEDURES), "webhooks"]);
|
|
102
|
+
const integrationIds = /* @__PURE__ */ new Set();
|
|
103
|
+
const generating = isContractGeneration();
|
|
104
|
+
for (const integration of this.config.integrations ?? []) {
|
|
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
|
+
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
|
+
integrationIds.add(integration.id);
|
|
108
|
+
if (!generating) assertIntegrationEndpoints(integration, this.config.wordpressEndpoints ?? {});
|
|
109
|
+
plugins.push(...integration.requires?.plugins ?? []);
|
|
110
|
+
if (integration.procedures && Object.keys(integration.procedures).length > 0) procedures[integration.id] = integration.procedures;
|
|
111
|
+
for (const handler of integration.events ?? []) events.push(handler);
|
|
112
|
+
adapters = mergeServiceAdapters(adapters, integration.adapters);
|
|
104
113
|
}
|
|
105
114
|
return {
|
|
115
|
+
adapters,
|
|
106
116
|
events,
|
|
107
117
|
plugins,
|
|
108
|
-
|
|
118
|
+
procedures
|
|
109
119
|
};
|
|
110
120
|
}
|
|
111
121
|
};
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
const WORDPRESS_ENV_VALUES = new Set([
|
|
123
|
+
"siteSecret",
|
|
124
|
+
"wordpressUrl",
|
|
125
|
+
"wordpressUsername",
|
|
126
|
+
"wordpressPassword"
|
|
127
|
+
]);
|
|
128
|
+
/**
|
|
129
|
+
* Compose environment sources without letting `undefined` erase an earlier value, then resolve
|
|
130
|
+
* Kizlo's active WordPress connection from the canonical `mode` value.
|
|
131
|
+
*/
|
|
132
|
+
function integrationEnv(integrations) {
|
|
133
|
+
const composed = (name) => {
|
|
134
|
+
let value;
|
|
135
|
+
for (const integration of integrations) {
|
|
136
|
+
if (!integration.env) continue;
|
|
137
|
+
const contribution = readEnv(integration.env, name);
|
|
138
|
+
if (contribution !== void 0) value = contribution;
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
141
|
+
};
|
|
142
|
+
const mode = composed("mode")?.trim();
|
|
143
|
+
if (mode && mode !== "local" && mode !== "remote") throw new KizloError("INVALID_ENV_VALUE", { message: `The "mode" environment value must be "local" or "remote", got "${mode}".` });
|
|
144
|
+
const profile = mode === "local" ? "local" : "remote";
|
|
145
|
+
return (name) => {
|
|
146
|
+
return WORDPRESS_ENV_VALUES.has(name) ? composed(`${profile}.${name}`) : composed(name);
|
|
147
|
+
};
|
|
118
148
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
149
|
+
function levelsFrom(level) {
|
|
150
|
+
const levels = [
|
|
151
|
+
"debug",
|
|
152
|
+
"info",
|
|
153
|
+
"warn",
|
|
154
|
+
"error"
|
|
155
|
+
];
|
|
156
|
+
return levels.slice(levels.indexOf(level));
|
|
125
157
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
url: `${prefix}WP_URL`,
|
|
132
|
-
username: `${prefix}WP_USERNAME`,
|
|
133
|
-
password: `${prefix}WP_APP_PASSWORD`
|
|
134
|
-
};
|
|
158
|
+
function requireEnvValue(name, env) {
|
|
159
|
+
const value = env(name)?.trim();
|
|
160
|
+
if (value) return value;
|
|
161
|
+
if (isContractGeneration()) return "";
|
|
162
|
+
throw new KizloError("MISSING_ENV_VALUE", { message: `Kizlo requires the "${name}" environment value. Provide it through an integration or an explicit createKizlo option.` });
|
|
135
163
|
}
|
|
136
|
-
function resolveWordPressConnection(options, env
|
|
164
|
+
function resolveWordPressConnection(options, env) {
|
|
137
165
|
const credentials = options?.wordpress?.credentials;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
url: credentials?.url ?? requireEnv(keys.url, env),
|
|
144
|
-
username: credentials?.username ?? requireEnv(keys.username, env),
|
|
145
|
-
password: credentials?.password ?? requireEnv(keys.password, env)
|
|
146
|
-
}
|
|
147
|
-
};
|
|
166
|
+
return { credentials: {
|
|
167
|
+
url: credentials?.url ?? requireEnvValue("wordpressUrl", env),
|
|
168
|
+
username: credentials?.username ?? requireEnvValue("wordpressUsername", env),
|
|
169
|
+
password: credentials?.password ?? requireEnvValue("wordpressPassword", env)
|
|
170
|
+
} };
|
|
148
171
|
}
|
|
149
172
|
/**
|
|
150
|
-
* Resolves a full `KizloConfig` from options and the environment.
|
|
151
|
-
* base `createKizlo` and each framework factory — the single place env values
|
|
152
|
-
* and credentials are read. `baseUrlEnvKey` is the only framework-varying part.
|
|
173
|
+
* Resolves a full `KizloConfig` from explicit options and the composed integration environment.
|
|
153
174
|
*/
|
|
154
|
-
function resolveKizloConfig(options
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
const
|
|
175
|
+
function resolveKizloConfig(options) {
|
|
176
|
+
const integrations = options?.integrations ?? [];
|
|
177
|
+
const env = integrationEnv(integrations);
|
|
178
|
+
if (!isContractGeneration()) for (const integration of integrations) assertIntegrationEnv(integration, env);
|
|
179
|
+
const { credentials } = resolveWordPressConnection(options, env);
|
|
158
180
|
return {
|
|
159
|
-
baseUrl: options?.baseUrl ??
|
|
160
|
-
siteSecret: options?.siteSecret ??
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
extensions: options?.extensions,
|
|
164
|
-
adapters: {
|
|
165
|
-
...defaults.adapters,
|
|
166
|
-
...options?.adapters
|
|
167
|
-
},
|
|
181
|
+
baseUrl: options?.baseUrl ?? requireEnvValue("baseUrl", env),
|
|
182
|
+
siteSecret: options?.siteSecret ?? requireEnvValue("siteSecret", env),
|
|
183
|
+
integrations,
|
|
184
|
+
logging: options?.logging,
|
|
168
185
|
credentials,
|
|
169
186
|
wordpressEndpoints: options?.wordpress?.endpoints
|
|
170
187
|
};
|
|
171
188
|
}
|
|
172
189
|
/**
|
|
173
|
-
* Creates a Kizlo server from
|
|
174
|
-
*
|
|
175
|
-
* with their own URL convention and adapters.
|
|
190
|
+
* Creates a Kizlo server from integration-contributed environment values, with explicit options
|
|
191
|
+
* taking precedence.
|
|
176
192
|
*/
|
|
177
193
|
function createKizlo(options) {
|
|
178
|
-
return new Kizlo(resolveKizloConfig(options
|
|
194
|
+
return new Kizlo(resolveKizloConfig(options));
|
|
179
195
|
}
|
|
180
196
|
|
|
181
197
|
//#endregion
|
|
182
|
-
export { Kizlo, createKizlo, resolveKizloConfig, resolveWordPressConnection };
|
|
198
|
+
export { Kizlo, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection };
|
package/dist/menu/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { buildMenuGroupItem, deserializeListMenuInput, extractPath } from "./uti
|
|
|
6
6
|
import { stringifiedMetaRecord } from "@kizlo/shared";
|
|
7
7
|
|
|
8
8
|
//#region src/menu/index.ts
|
|
9
|
-
const
|
|
9
|
+
const MENU_PROCEDURES = { items: {
|
|
10
10
|
list: createProcedure({
|
|
11
11
|
scope: "api",
|
|
12
12
|
method: "GET",
|
|
@@ -86,4 +86,4 @@ const MENU_ROUTER_MAP = { items: {
|
|
|
86
86
|
} };
|
|
87
87
|
|
|
88
88
|
//#endregion
|
|
89
|
-
export {
|
|
89
|
+
export { MENU_PROCEDURES };
|
package/dist/nextjs/server.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { WEB_MANIFEST_ROUTE } from "../brand/manifest.js";
|
|
|
2
2
|
import { renderJsonLd } from "../seo/utils.js";
|
|
3
3
|
import { createSitemapRedirectRoute } from "../seo/sitemap.js";
|
|
4
4
|
import { NextRevalidateOptions, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, nextRevalidation } from "../integrations/nextjs/revalidate.js";
|
|
5
|
-
import {
|
|
5
|
+
import { NextjsOptions, nextjs } from "../integrations/nextjs/integration.js";
|
|
6
6
|
import { MANIFEST_CACHE_TAG, createManifestRoute } from "../integrations/nextjs/manifest.js";
|
|
7
7
|
import { createHomeMetadata, createPageMetadata, createRootMetadata, createRootViewport } from "../integrations/nextjs/metadata.js";
|
|
8
8
|
import { ROBOTS_CACHE_TAG, createRobotsRoute } from "../integrations/nextjs/robots.js";
|
|
9
9
|
import { SITEMAP_CACHE_TAG, SITEMAP_ROUTE, createSitemapRoute } from "../integrations/nextjs/sitemap.js";
|
|
10
10
|
import { createCachedTextRoute, createNextCookiesInterface, getServerBaseUrl } from "../integrations/nextjs/utils.js";
|
|
11
|
-
export {
|
|
11
|
+
export { MANIFEST_CACHE_TAG, NextRevalidateOptions, NextjsOptions, ROBOTS_CACHE_TAG, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, nextjs, renderJsonLd };
|
package/dist/nextjs/server.js
CHANGED
|
@@ -5,8 +5,8 @@ import { createCachedTextRoute, createNextCookiesInterface, getServerBaseUrl } f
|
|
|
5
5
|
import { ROBOTS_CACHE_TAG, createRobotsRoute } from "../integrations/nextjs/robots.js";
|
|
6
6
|
import { SITEMAP_CACHE_TAG, SITEMAP_ROUTE, createSitemapRoute } from "../integrations/nextjs/sitemap.js";
|
|
7
7
|
import { nextRevalidation } from "../integrations/nextjs/revalidate.js";
|
|
8
|
-
import {
|
|
8
|
+
import { nextjs } from "../integrations/nextjs/integration.js";
|
|
9
9
|
import { MANIFEST_CACHE_TAG, createManifestRoute } from "../integrations/nextjs/manifest.js";
|
|
10
10
|
import { createHomeMetadata, createPageMetadata, createRootMetadata, createRootViewport } from "../integrations/nextjs/metadata.js";
|
|
11
11
|
|
|
12
|
-
export { MANIFEST_CACHE_TAG, ROBOTS_CACHE_TAG, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata,
|
|
12
|
+
export { MANIFEST_CACHE_TAG, ROBOTS_CACHE_TAG, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, nextjs, renderJsonLd };
|
package/dist/node.d.ts
ADDED
package/dist/node.js
ADDED
package/dist/package.js
CHANGED
package/dist/page/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { deserializePage } from "./utils.js";
|
|
|
8
8
|
import { normalizeArrayableValue } from "@kizlo/shared";
|
|
9
9
|
|
|
10
10
|
//#region src/page/index.ts
|
|
11
|
-
const
|
|
11
|
+
const PAGE_PROCEDURES = {
|
|
12
12
|
get: createProcedure({
|
|
13
13
|
scope: "api",
|
|
14
14
|
method: "GET",
|
|
@@ -120,4 +120,4 @@ const PAGE_ROUTER_MAP = {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
//#endregion
|
|
123
|
-
export {
|
|
123
|
+
export { PAGE_PROCEDURES };
|
package/dist/post/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { deserializePost } from "./utils.js";
|
|
|
8
8
|
import { normalizeArrayableValue } from "@kizlo/shared";
|
|
9
9
|
|
|
10
10
|
//#region src/post/index.ts
|
|
11
|
-
const
|
|
11
|
+
const POST_PROCEDURES = {
|
|
12
12
|
get: createProcedure({
|
|
13
13
|
scope: "api",
|
|
14
14
|
method: "GET",
|
|
@@ -123,4 +123,4 @@ const POST_ROUTER_MAP = {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
//#endregion
|
|
126
|
-
export {
|
|
126
|
+
export { POST_PROCEDURES };
|
|
@@ -4,8 +4,8 @@ import { Procedure } from "./shared/procedure.js";
|
|
|
4
4
|
import "./index.js";
|
|
5
5
|
import * as _kizlo_shared0 from "@kizlo/shared";
|
|
6
6
|
|
|
7
|
-
//#region src/
|
|
8
|
-
declare const
|
|
7
|
+
//#region src/procedures.d.ts
|
|
8
|
+
declare const CORE_PROCEDURES: {
|
|
9
9
|
posts: {
|
|
10
10
|
get: Procedure<"api", {
|
|
11
11
|
params: {
|
|
@@ -179,7 +179,7 @@ declare const ROUTER_MAP: {
|
|
|
179
179
|
include?: string | number | (string | number)[] | undefined;
|
|
180
180
|
offset?: string | number | undefined;
|
|
181
181
|
order?: "asc" | "desc" | undefined;
|
|
182
|
-
orderby?: "
|
|
182
|
+
orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | undefined;
|
|
183
183
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
184
184
|
slug?: string | string[] | undefined;
|
|
185
185
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -511,7 +511,7 @@ declare const ROUTER_MAP: {
|
|
|
511
511
|
include?: string | number | (string | number)[] | undefined;
|
|
512
512
|
offset?: string | number | undefined;
|
|
513
513
|
order?: "asc" | "desc" | undefined;
|
|
514
|
-
orderby?: "
|
|
514
|
+
orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
515
515
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
516
516
|
slug?: string | string[] | undefined;
|
|
517
517
|
parent?: string | number | (string | number)[] | undefined;
|
|
@@ -772,7 +772,7 @@ declare const ROUTER_MAP: {
|
|
|
772
772
|
exclude?: string | number | (string | number)[] | undefined;
|
|
773
773
|
include?: string | number | (string | number)[] | undefined;
|
|
774
774
|
order?: "asc" | "desc" | undefined;
|
|
775
|
-
orderBy?: "
|
|
775
|
+
orderBy?: "count" | "id" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | undefined;
|
|
776
776
|
hideEmpty?: string | boolean | undefined;
|
|
777
777
|
parent?: string | number | undefined;
|
|
778
778
|
post?: string | number | undefined;
|
|
@@ -988,7 +988,7 @@ declare const ROUTER_MAP: {
|
|
|
988
988
|
exclude?: string | number | (string | number)[] | undefined;
|
|
989
989
|
include?: string | number | (string | number)[] | undefined;
|
|
990
990
|
order?: "asc" | "desc" | undefined;
|
|
991
|
-
orderBy?: "
|
|
991
|
+
orderBy?: "count" | "id" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | undefined;
|
|
992
992
|
hideEmpty?: string | boolean | undefined;
|
|
993
993
|
post?: string | number | undefined;
|
|
994
994
|
slug?: string | string[] | undefined;
|
|
@@ -1202,7 +1202,7 @@ declare const ROUTER_MAP: {
|
|
|
1202
1202
|
include?: string | number | (string | number)[] | undefined;
|
|
1203
1203
|
offset?: string | number | undefined;
|
|
1204
1204
|
order?: "asc" | "desc" | undefined;
|
|
1205
|
-
orderby?: "
|
|
1205
|
+
orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
1206
1206
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
1207
1207
|
slug?: string | string[] | undefined;
|
|
1208
1208
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -1281,7 +1281,7 @@ declare const ROUTER_MAP: {
|
|
|
1281
1281
|
include?: string | number | (string | number)[] | undefined;
|
|
1282
1282
|
offset?: string | number | undefined;
|
|
1283
1283
|
order?: "asc" | "desc" | undefined;
|
|
1284
|
-
orderby?: "
|
|
1284
|
+
orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
1285
1285
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
1286
1286
|
slug?: string | string[] | undefined;
|
|
1287
1287
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -1430,7 +1430,7 @@ declare const ROUTER_MAP: {
|
|
|
1430
1430
|
include?: string | number | (string | number)[] | undefined;
|
|
1431
1431
|
offset?: string | number | undefined;
|
|
1432
1432
|
order?: "asc" | "desc" | undefined;
|
|
1433
|
-
orderby?: "
|
|
1433
|
+
orderby?: "date" | "id" | "parent" | "post" | "include" | undefined;
|
|
1434
1434
|
parent?: string | number | (string | number)[] | undefined;
|
|
1435
1435
|
parentExclude?: string | number | (string | number)[] | undefined;
|
|
1436
1436
|
post?: string | number | (string | number)[] | undefined;
|
|
@@ -1690,6 +1690,6 @@ declare const ROUTER_MAP: {
|
|
|
1690
1690
|
};
|
|
1691
1691
|
};
|
|
1692
1692
|
};
|
|
1693
|
-
type
|
|
1693
|
+
type CoreProcedures = typeof CORE_PROCEDURES;
|
|
1694
1694
|
//#endregion
|
|
1695
|
-
export {
|
|
1695
|
+
export { CORE_PROCEDURES, CoreProcedures };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CATEGORY_PROCEDURES } from "./category/index.js";
|
|
2
|
+
import { COMMENT_PROCEDURES } from "./comment/index.js";
|
|
3
|
+
import { MENU_PROCEDURES } from "./menu/index.js";
|
|
4
|
+
import { PAGE_PROCEDURES } from "./page/index.js";
|
|
5
|
+
import { POST_PROCEDURES } from "./post/index.js";
|
|
6
|
+
import { SEO_PROCEDURES } from "./seo/index.js";
|
|
7
|
+
import { SETTINGS_PROCEDURES } from "./settings/index.js";
|
|
8
|
+
import { TAG_PROCEDURES } from "./tag/index.js";
|
|
9
|
+
|
|
10
|
+
//#region src/procedures.ts
|
|
11
|
+
const CORE_PROCEDURES = {
|
|
12
|
+
posts: POST_PROCEDURES,
|
|
13
|
+
pages: PAGE_PROCEDURES,
|
|
14
|
+
categories: CATEGORY_PROCEDURES,
|
|
15
|
+
tags: TAG_PROCEDURES,
|
|
16
|
+
seo: SEO_PROCEDURES,
|
|
17
|
+
menus: MENU_PROCEDURES,
|
|
18
|
+
comments: COMMENT_PROCEDURES,
|
|
19
|
+
settings: SETTINGS_PROCEDURES
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CORE_PROCEDURES };
|
package/dist/seo/index.js
CHANGED
|
@@ -23,7 +23,7 @@ function deserializeSitemapUrls(urls) {
|
|
|
23
23
|
}))
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const SEO_PROCEDURES = {
|
|
27
27
|
homepage: createProcedure({
|
|
28
28
|
scope: "internal",
|
|
29
29
|
output: Seo
|
|
@@ -111,4 +111,4 @@ const SEO_ROUTER_MAP = {
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
//#endregion
|
|
114
|
-
export {
|
|
114
|
+
export { SEO_PROCEDURES };
|
package/dist/settings/index.js
CHANGED
|
@@ -12,7 +12,7 @@ function resolveUpdate(response, context, errors, label) {
|
|
|
12
12
|
}
|
|
13
13
|
return response.data;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const SETTINGS_PROCEDURES = {
|
|
16
16
|
get: createProcedure({
|
|
17
17
|
scope: "internal",
|
|
18
18
|
output: schemaType()
|
|
@@ -73,4 +73,4 @@ const SETTINGS_ROUTER_MAP = {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
export {
|
|
76
|
+
export { SETTINGS_PROCEDURES };
|
package/dist/shared/constants.js
CHANGED
|
@@ -5,14 +5,6 @@ import { milliseconds } from "@kizlo/shared";
|
|
|
5
5
|
const VERSION = version;
|
|
6
6
|
const RPC_PROTOCOL_HEADER = "x-rpc-protocol";
|
|
7
7
|
const SESSION_EXPIRY_MARGIN_MS = milliseconds("5 minutes");
|
|
8
|
-
/**
|
|
9
|
-
* Set in `process.env` by the CLI daemon while it imports the server module solely to read the
|
|
10
|
-
* router's *shape* for contract generation. No request is served in that mode, so `requireEnv`
|
|
11
|
-
* returns a placeholder instead of aborting the import when connection env vars are absent — the
|
|
12
|
-
* router shape doesn't depend on any env value, and framework virtual modules (e.g. Astro's
|
|
13
|
-
* `getSecret`) are stubbed to `undefined` during the shape-only import anyway.
|
|
14
|
-
*/
|
|
15
|
-
const CONTRACT_GENERATION_ENV = "KIZLO_CONTRACT_GENERATION";
|
|
16
8
|
|
|
17
9
|
//#endregion
|
|
18
|
-
export {
|
|
10
|
+
export { RPC_PROTOCOL_HEADER };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/shared/contract-generation.ts
|
|
2
|
+
const CONTRACT_GENERATION = Symbol.for("kizlo.contract-generation");
|
|
3
|
+
function state() {
|
|
4
|
+
return globalThis;
|
|
5
|
+
}
|
|
6
|
+
function isContractGeneration() {
|
|
7
|
+
return state()[CONTRACT_GENERATION] === true;
|
|
8
|
+
}
|
|
9
|
+
function setContractGeneration(value) {
|
|
10
|
+
state()[CONTRACT_GENERATION] = value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { isContractGeneration, setContractGeneration };
|