kizlo 0.10.0 → 0.12.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/README.md +4 -4
- package/dist/astro/server.d.ts +9 -0
- package/dist/astro/server.js +10 -0
- package/dist/astro.d.ts +2 -0
- package/dist/astro.js +3 -0
- package/dist/cli/commands/_setup.js +19 -10
- package/dist/cli/commands/create.js +102 -72
- package/dist/cli/commands/dev.js +113 -20
- package/dist/cli/commands/generate.js +4 -0
- package/dist/cli/commands/init.js +111 -57
- package/dist/cli/daemon/config.js +13 -7
- package/dist/cli/daemon/generate.js +2 -3
- package/dist/cli/daemon/jiti.js +101 -0
- package/dist/cli/daemon/logger.js +1 -1
- package/dist/cli/daemon/reload.js +66 -0
- package/dist/cli/daemon/watch.js +7 -4
- package/dist/cli/presets/source.js +122 -24
- package/dist/cli/presets/template.js +75 -17
- package/dist/cli/wp/settings.js +8 -2
- package/dist/comment/schema.js +2 -2
- package/dist/context.d.ts +9 -0
- package/dist/context.js +20 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/integrations/astro/kizlo.client.d.ts +15 -0
- package/dist/integrations/astro/kizlo.client.js +13 -0
- package/dist/integrations/astro/kizlo.server.d.ts +10 -0
- package/dist/integrations/astro/kizlo.server.js +12 -0
- package/dist/integrations/astro/manifest.d.ts +9 -0
- package/dist/integrations/astro/manifest.js +11 -0
- package/dist/integrations/astro/metadata.d.ts +64 -0
- package/dist/integrations/astro/metadata.js +71 -0
- package/dist/integrations/astro/robots.d.ts +8 -0
- package/dist/integrations/astro/robots.js +11 -0
- package/dist/integrations/astro/sitemap.d.ts +16 -0
- package/dist/integrations/astro/sitemap.js +20 -0
- package/dist/integrations/astro/utils.d.ts +19 -0
- package/dist/integrations/astro/utils.js +17 -0
- package/dist/integrations/nextjs/metadata.d.ts +1 -0
- package/dist/integrations/nextjs/metadata.js +1 -0
- package/dist/kizlo.d.ts +8 -1
- package/dist/kizlo.js +16 -13
- package/dist/nextjs/server.d.ts +2 -1
- package/dist/nextjs/server.js +2 -1
- package/dist/package.js +1 -1
- package/dist/page/schema.js +2 -2
- package/dist/post/schema.js +2 -2
- package/dist/seo/utils.d.ts +8 -2
- package/dist/seo/utils.js +9 -1
- package/dist/shared/constants.js +9 -1
- package/dist/shared/schema.d.ts +1 -2
- package/dist/shared/schema.js +2 -2
- package/dist/wordpress/service.d.ts +4 -0
- package/dist/wordpress/service.js +5 -0
- package/package.json +18 -2
- package/dist/cli/presets/base.js +0 -40
- package/dist/cli/presets/index.js +0 -16
- package/dist/cli/presets/nextjs.js +0 -16
|
@@ -4,36 +4,39 @@ import os from "node:os";
|
|
|
4
4
|
import { downloadTemplate } from "giget";
|
|
5
5
|
|
|
6
6
|
//#region src/cli/presets/source.ts
|
|
7
|
-
/**
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
/** The default registry: the templates workspace on the repo's default branch. */
|
|
8
|
+
const DEFAULT_REGISTRY = "github:kizlo-io/kizlo/templates";
|
|
9
|
+
function resolveRegistry(registryArg) {
|
|
10
|
+
if (!registryArg) return {
|
|
11
|
+
local: false,
|
|
12
|
+
source: DEFAULT_REGISTRY
|
|
13
|
+
};
|
|
14
|
+
const abs = path.resolve(registryArg);
|
|
15
|
+
if (fs.existsSync(abs) && fs.statSync(abs).isDirectory()) return {
|
|
16
|
+
local: true,
|
|
17
|
+
source: abs
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
local: false,
|
|
21
|
+
source: registryArg
|
|
22
|
+
};
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
|
-
* Get
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
+
* Get a registry as a readable directory both commands can scan and copy from. A local registry is
|
|
26
|
+
* returned as-is (cleanup is a no-op); a remote one is downloaded once into a fresh temp directory the
|
|
27
|
+
* caller cleans up. The whole registry is fetched in one shot so listing and applying share the same
|
|
28
|
+
* bytes and never re-download per template.
|
|
25
29
|
*/
|
|
26
|
-
async function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!fs.existsSync(source.local)) throw new Error(`Local template not found: ${source.local}`);
|
|
30
|
+
async function fetchRegistry(registry) {
|
|
31
|
+
if (registry.local) {
|
|
32
|
+
if (!fs.existsSync(registry.source)) throw new Error(`Registry directory not found: ${registry.source}`);
|
|
30
33
|
return {
|
|
31
|
-
dir: source
|
|
34
|
+
dir: registry.source,
|
|
32
35
|
cleanup: () => {}
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "kizlo-
|
|
36
|
-
await downloadTemplate(source
|
|
38
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "kizlo-registry-"));
|
|
39
|
+
await downloadTemplate(registry.source, {
|
|
37
40
|
dir,
|
|
38
41
|
forceClean: true
|
|
39
42
|
});
|
|
@@ -45,6 +48,101 @@ async function fetchTemplate(template) {
|
|
|
45
48
|
})
|
|
46
49
|
};
|
|
47
50
|
}
|
|
51
|
+
/** The display fields from a raw `template.json`, read leniently so one bad manifest can't break discovery. */
|
|
52
|
+
function readMeta(manifestPath) {
|
|
53
|
+
try {
|
|
54
|
+
const raw = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
55
|
+
return {
|
|
56
|
+
name: typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : void 0,
|
|
57
|
+
framework: typeof raw.framework === "string" && raw.framework.trim() ? raw.framework.trim() : void 0
|
|
58
|
+
};
|
|
59
|
+
} catch {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Every template a fetched registry contains. A registry can be either shape, and both "just work":
|
|
65
|
+
*
|
|
66
|
+
* - A collection: a directory of templates, each an immediate subdirectory with its own `template.json`
|
|
67
|
+
* (Kizlo's own `templates/` dir, or a community registry of several). The subdirectory name is the
|
|
68
|
+
* template's addressable id. A subdirectory without a manifest is skipped so an unrelated folder can't
|
|
69
|
+
* break the listing.
|
|
70
|
+
* - A single template: a directory that is itself a template (`template.json` at its root) — the escape
|
|
71
|
+
* hatch for a community template shipped on its own, e.g. `--source github:acme/kizlo-astro-template`.
|
|
72
|
+
* Its id comes from the manifest's `framework` (a stable name that also matches what `init`'s detected
|
|
73
|
+
* preset asks for), not the directory name, which for a downloaded repo is a random temp folder.
|
|
74
|
+
*
|
|
75
|
+
* Discovery is by scanning, not a hardcoded list, and the manifest is read only for its display fields
|
|
76
|
+
* here. Sorted by id for a stable prompt order.
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* True when the fetched source is itself a single template (a `template.json` at its root) rather than a
|
|
80
|
+
* registry of many. `init` uses this to tell the two `--source` shapes apart: a single template is an
|
|
81
|
+
* explicit, deliberate choice (applied even against detection, with a warning), whereas a registry is
|
|
82
|
+
* filtered down to the templates whose framework the project matches.
|
|
83
|
+
*/
|
|
84
|
+
function isSingleTemplate(registryDir) {
|
|
85
|
+
return fs.existsSync(path.join(registryDir, "template.json"));
|
|
86
|
+
}
|
|
87
|
+
function listTemplates(registryDir) {
|
|
88
|
+
if (!fs.existsSync(registryDir)) return [];
|
|
89
|
+
if (isSingleTemplate(registryDir)) {
|
|
90
|
+
const meta = readMeta(path.join(registryDir, "template.json"));
|
|
91
|
+
const id = meta.framework ?? path.basename(registryDir);
|
|
92
|
+
return [{
|
|
93
|
+
id,
|
|
94
|
+
label: meta.name ?? meta.framework ?? id,
|
|
95
|
+
dir: registryDir
|
|
96
|
+
}];
|
|
97
|
+
}
|
|
98
|
+
const entries = [];
|
|
99
|
+
for (const dirent of fs.readdirSync(registryDir, { withFileTypes: true })) {
|
|
100
|
+
if (!dirent.isDirectory()) continue;
|
|
101
|
+
const dir = path.join(registryDir, dirent.name);
|
|
102
|
+
const manifestPath = path.join(dir, "template.json");
|
|
103
|
+
if (!fs.existsSync(manifestPath)) continue;
|
|
104
|
+
const meta = readMeta(manifestPath);
|
|
105
|
+
entries.push({
|
|
106
|
+
id: dirent.name,
|
|
107
|
+
label: meta.name ?? meta.framework ?? dirent.name,
|
|
108
|
+
dir
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return entries.sort((a, b) => a.id.localeCompare(b.id));
|
|
112
|
+
}
|
|
113
|
+
/** A template's detection dependency list, read leniently so one bad manifest can't break detection. */
|
|
114
|
+
function readDetectDeps(templateDir) {
|
|
115
|
+
try {
|
|
116
|
+
const deps = JSON.parse(fs.readFileSync(path.join(templateDir, "template.json"), "utf8")).detect?.dependencies;
|
|
117
|
+
return Array.isArray(deps) ? deps.filter((name) => typeof name === "string") : [];
|
|
118
|
+
} catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The templates whose framework a project is built with, best match(es) first, or an empty array when
|
|
124
|
+
* none matches (use the base fallback). Detection is data: each template's manifest declares the
|
|
125
|
+
* `detect.dependencies` whose presence in the project's deps identify its framework, and this scores
|
|
126
|
+
* every entry by how many of its declared deps the project has, returning every entry that ties for the
|
|
127
|
+
* top score. One match is the common one-per-framework registry; more than one means the registry ships
|
|
128
|
+
* same-framework variants that dependency presence alone can't disambiguate, and the caller decides
|
|
129
|
+
* (prompt, or force with `--template`). Ties preserve the entries' incoming order (id-sorted from
|
|
130
|
+
* {@link listTemplates}). Read leniently — a malformed manifest scores zero rather than throwing — so one
|
|
131
|
+
* bad template in a registry can't break detection for the rest.
|
|
132
|
+
*/
|
|
133
|
+
function detectTemplates(entries, deps) {
|
|
134
|
+
let bestScore = 0;
|
|
135
|
+
let best = [];
|
|
136
|
+
for (const entry of entries) {
|
|
137
|
+
const score = readDetectDeps(entry.dir).filter((name) => name in deps).length;
|
|
138
|
+
if (score === 0) continue;
|
|
139
|
+
if (score > bestScore) {
|
|
140
|
+
bestScore = score;
|
|
141
|
+
best = [entry];
|
|
142
|
+
} else if (score === bestScore) best.push(entry);
|
|
143
|
+
}
|
|
144
|
+
return best;
|
|
145
|
+
}
|
|
48
146
|
|
|
49
147
|
//#endregion
|
|
50
|
-
export {
|
|
148
|
+
export { DEFAULT_REGISTRY, detectTemplates, fetchRegistry, isSingleTemplate, listTemplates, resolveRegistry };
|
|
@@ -8,17 +8,25 @@ import fs from "node:fs";
|
|
|
8
8
|
/**
|
|
9
9
|
* The template's `template.json`. It is the single declaration of what Kizlo lays onto a project and
|
|
10
10
|
* how — the same engine drives both `create` (onto a fresh app the framework CLI just bootstrapped)
|
|
11
|
-
* and `init` (onto the user's existing project). Changes are grouped into three sections
|
|
12
|
-
*
|
|
11
|
+
* and `init` (onto the user's existing project). Changes are grouped into three sections by the one
|
|
12
|
+
* question that decides whether a command may safely apply them — *where is this safe to land?* — and
|
|
13
|
+
* no command ever reads another command's section:
|
|
13
14
|
*
|
|
14
|
-
* - `base` —
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - `create` —
|
|
18
|
-
* the root layout (written whole,
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* - `base` — safe on any project: additive, Kizlo-owned paths that never collide with the user's own
|
|
16
|
+
* files (the server entry, client, routes, and additive demo pages like a new blog route). Applied
|
|
17
|
+
* by both commands.
|
|
18
|
+
* - `create` — safe only on a freshly bootstrapped app `create` may freely overwrite: the files the
|
|
19
|
+
* framework CLI already scaffolded, like the root layout (written whole, SEO-wired) and the homepage
|
|
20
|
+
* showcase. Applied only by `create`, never `init` — overwriting these on a real project would
|
|
21
|
+
* clobber the user's work.
|
|
22
|
+
* - `init` — the non-destructive counterpart for the user's existing project: the root-layout SEO
|
|
23
|
+
* wiring lands here as a `patch` that merges into the layout the user already owns.
|
|
24
|
+
*
|
|
25
|
+
* Cutting across all three is the orthogonal `example` flag: opt-in demo content, applied only when the
|
|
26
|
+
* user answers yes to "Add example pages?". A cross-cutting example (e.g. a blog) files each of its
|
|
27
|
+
* pieces in the section that matches its safety — the additive new route in `base`, the homepage
|
|
28
|
+
* showcase that overwrites an app-owned file in `create` — so `init` picks up only the additive half and
|
|
29
|
+
* never touches a file the user owns, while `create` gets the whole demo. See {@link changesFor}.
|
|
22
30
|
*
|
|
23
31
|
* Each section is a list of changes, every one a member of a small closed set — deliberately no
|
|
24
32
|
* "patch an arbitrary source file" kind, so a dangerous strategy is unrepresentable:
|
|
@@ -83,18 +91,61 @@ const envSchema = z.object({
|
|
|
83
91
|
});
|
|
84
92
|
/** A package name → version-range map, package.json's own vocabulary. */
|
|
85
93
|
const depsSchema = z.record(z.string(), z.string());
|
|
94
|
+
/**
|
|
95
|
+
* The package names whose presence in a project's dependencies identify this framework — how `init`
|
|
96
|
+
* recognizes which template to apply to an existing project (e.g. `["next"]`, `["astro"]`). Detection is
|
|
97
|
+
* data, so a community template declares its own signal and needs no CLI change. See {@link detectTemplate}.
|
|
98
|
+
*/
|
|
99
|
+
const detectSchema = z.object({ dependencies: z.array(z.string()).default([]) });
|
|
100
|
+
/**
|
|
101
|
+
* An `init` precondition on the project's shape: at least one of `anyDir` must exist in the project,
|
|
102
|
+
* else `init` stops with `message`. Replaces framework-specific `if` branches — e.g. Next.js needs an
|
|
103
|
+
* `app` or `src/app` directory (the App Router), which the Pages Router lacks. Dormant when absent.
|
|
104
|
+
*/
|
|
105
|
+
const requiresSchema = z.object({
|
|
106
|
+
anyDir: z.array(z.string()),
|
|
107
|
+
message: z.string()
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* A post-setup manual step `init` prints after wiring — the piece Kizlo can't auto-wire into a file the
|
|
111
|
+
* user owns (e.g. Astro's SEO tags render through a `.astro` component, not a patchable export). `create`
|
|
112
|
+
* owns files whole, so it never prints these. `body` may carry one token, `{{importPrefix}}`, substituted
|
|
113
|
+
* by {@link renderNote} with the project's source-root import prefix (an alias like `@/`, else `../`).
|
|
114
|
+
*/
|
|
115
|
+
const noteSchema = z.object({
|
|
116
|
+
title: z.string(),
|
|
117
|
+
body: z.string()
|
|
118
|
+
});
|
|
86
119
|
const manifestSchema = z.object({
|
|
87
120
|
framework: z.string(),
|
|
121
|
+
name: z.string().optional(),
|
|
88
122
|
env: envSchema.optional(),
|
|
89
123
|
dependencies: depsSchema.optional(),
|
|
90
124
|
devDependencies: depsSchema.optional(),
|
|
91
125
|
minCli: z.string().optional(),
|
|
126
|
+
apiPath: z.string().optional(),
|
|
127
|
+
detect: detectSchema.optional(),
|
|
128
|
+
requires: requiresSchema.optional(),
|
|
129
|
+
notes: z.array(noteSchema).default([]),
|
|
92
130
|
bootstrap: bootstrapSchema.optional(),
|
|
93
131
|
conventions: conventionsSchema,
|
|
94
132
|
base: z.array(changeSchema).default([]),
|
|
95
133
|
create: z.array(changeSchema).default([]),
|
|
96
134
|
init: z.array(changeSchema).default([])
|
|
97
135
|
});
|
|
136
|
+
/**
|
|
137
|
+
* Render a manual-step note for display, substituting the `{{importPrefix}}` token with the project's
|
|
138
|
+
* source-root import prefix — the configured alias (normalized to a trailing slash, e.g. `@/`) when one
|
|
139
|
+
* is set, else the relative `../`. Reproduces the old `alias ? "@/…" : "../…"` behavior exactly, so a
|
|
140
|
+
* template's note reads correctly whichever import style the project uses.
|
|
141
|
+
*/
|
|
142
|
+
function renderNote(note, alias) {
|
|
143
|
+
const importPrefix = alias ? `${alias.replace(/\/+$/, "")}/` : "../";
|
|
144
|
+
return {
|
|
145
|
+
title: note.title,
|
|
146
|
+
body: note.body.replaceAll("{{importPrefix}}", importPrefix)
|
|
147
|
+
};
|
|
148
|
+
}
|
|
98
149
|
/** Role → the human label init uses in prompts and logs. */
|
|
99
150
|
const ROLE_LABELS = {
|
|
100
151
|
"server-entry": "Kizlo server instance",
|
|
@@ -107,6 +158,9 @@ const ROLE_LABELS = {
|
|
|
107
158
|
"root-layout": "root layout",
|
|
108
159
|
"home-page": "home page",
|
|
109
160
|
"blog-post": "blog post page",
|
|
161
|
+
"head-component": "SEO head component",
|
|
162
|
+
"framework-config": "framework config",
|
|
163
|
+
tsconfig: "TypeScript config",
|
|
110
164
|
styles: "global styles"
|
|
111
165
|
};
|
|
112
166
|
/** Read and validate the template's manifest from a fetched template directory. */
|
|
@@ -162,12 +216,16 @@ function minCliError(manifest) {
|
|
|
162
216
|
return `This template needs the kizlo CLI >= ${manifest.minCli} (you have ${running}). Run \`npx kizlo@latest\` and try again.`;
|
|
163
217
|
}
|
|
164
218
|
/**
|
|
165
|
-
* The changes a command applies: the shared `base` set plus the command's own section
|
|
166
|
-
*
|
|
167
|
-
*
|
|
219
|
+
* The changes a command applies: the shared `base` set plus the command's own section (`base` first, so
|
|
220
|
+
* a later section can override it). Section placement is the *safety* axis — `base` is additive and safe
|
|
221
|
+
* on any project, `create`/`init` carry the fresh-app-vs-existing-project halves — while the `example`
|
|
222
|
+
* flag is the orthogonal *opt-in* axis. Example changes are dropped unless `includeExamples`, so the same
|
|
223
|
+
* call serves both "core wiring only" and "plus the demo pages", and each command only ever sees its own
|
|
224
|
+
* section: init's opt-in examples are the additive ones in `base`, never create's homepage overwrite.
|
|
168
225
|
*/
|
|
169
|
-
function changesFor(manifest, command) {
|
|
170
|
-
|
|
226
|
+
function changesFor(manifest, command, opts = {}) {
|
|
227
|
+
const changes = [...manifest.base, ...manifest[command]];
|
|
228
|
+
return opts.includeExamples ? changes : changes.filter((change) => !isExample(change));
|
|
171
229
|
}
|
|
172
230
|
/** The whole-file changes in a resolved change list. */
|
|
173
231
|
function fileEntries(changes) {
|
|
@@ -177,7 +235,7 @@ function fileEntries(changes) {
|
|
|
177
235
|
function patchEntries(changes) {
|
|
178
236
|
return changes.filter((change) => change.kind === "patch");
|
|
179
237
|
}
|
|
180
|
-
/** Whether a change is opt-in demo content —
|
|
238
|
+
/** Whether a change is opt-in demo content — applied only when example pages are requested. */
|
|
181
239
|
function isExample(change) {
|
|
182
240
|
return change.kind === "file" && change.example === true;
|
|
183
241
|
}
|
|
@@ -267,4 +325,4 @@ function rendersHtml(file) {
|
|
|
267
325
|
}
|
|
268
326
|
|
|
269
327
|
//#endregion
|
|
270
|
-
export { adaptFile, changesFor, fileEntries, findRootLayout,
|
|
328
|
+
export { adaptFile, changesFor, fileEntries, findRootLayout, isOlderVersion, minCliError, patchEntries, readManifest, renderNote, resolveDependencies, resolvePatch };
|
package/dist/cli/wp/settings.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WP_KIZLO_BASE } from "../../wordpress/constants.js";
|
|
2
2
|
import { WordPressService } from "../../wordpress/service.js";
|
|
3
|
+
import { PLUGIN_VERSION_HEADER } from "@kizlo/shared";
|
|
3
4
|
|
|
4
5
|
//#region src/cli/wp/settings.ts
|
|
5
6
|
/** Loopback hosts that, from inside the dev Docker stack, must be rewritten to reach the host. */
|
|
@@ -52,11 +53,16 @@ async function syncSiteSettings(credentials, settings) {
|
|
|
52
53
|
base: WP_KIZLO_BASE,
|
|
53
54
|
body
|
|
54
55
|
});
|
|
56
|
+
const pluginVersion = response.headers.get(PLUGIN_VERSION_HEADER);
|
|
55
57
|
if (response.error) return {
|
|
56
58
|
ok: false,
|
|
57
|
-
error: describeError(response.status, response.error)
|
|
59
|
+
error: describeError(response.status, response.error),
|
|
60
|
+
pluginVersion
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
ok: true,
|
|
64
|
+
pluginVersion
|
|
58
65
|
};
|
|
59
|
-
return { ok: true };
|
|
60
66
|
}
|
|
61
67
|
/**
|
|
62
68
|
* A short, log-friendly summary of a failed request. A transport failure has no HTTP status (`0`), so
|
package/dist/comment/schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ListMetadata, ListOrder
|
|
2
|
-
import { NumberLike, arrayable } from "@kizlo/shared";
|
|
1
|
+
import { ListMetadata, ListOrder } from "../shared/schema.js";
|
|
2
|
+
import { Media, NumberLike, arrayable } from "@kizlo/shared";
|
|
3
3
|
import z from "zod/v4";
|
|
4
4
|
|
|
5
5
|
//#region src/comment/schema.ts
|
package/dist/context.d.ts
CHANGED
|
@@ -60,6 +60,15 @@ declare class Context {
|
|
|
60
60
|
private readonly settings;
|
|
61
61
|
private readonly email;
|
|
62
62
|
constructor(config: ContextConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Warn when the WordPress plugin is older than {@link isPluginVersionSupported} allows, read from the
|
|
65
|
+
* `X-Kizlo-Version` header the plugin stamps on every response. A version mismatch is a serious
|
|
66
|
+
* contract break, so this fires on every WordPress response rather than once — the header rides
|
|
67
|
+
* responses the runtime already makes, so it costs no extra request. Emitted through `console.warn`
|
|
68
|
+
* rather than the logger adapter on purpose: the adapter is optional (it defaults to a no-op), and
|
|
69
|
+
* this is a setup problem every user must see regardless of whether they've wired up logging.
|
|
70
|
+
*/
|
|
71
|
+
private warnIfPluginOutdated;
|
|
63
72
|
createRestContext(request: Request): {
|
|
64
73
|
headers: Headers;
|
|
65
74
|
request: Request;
|
package/dist/context.js
CHANGED
|
@@ -5,7 +5,7 @@ import { CookiesStorage } from "./cookie.js";
|
|
|
5
5
|
import { WordPressService } from "./wordpress/service.js";
|
|
6
6
|
import { EmailService } from "./email/service.js";
|
|
7
7
|
import { SettingsService } from "./settings/service.js";
|
|
8
|
-
import { base64Decode, tryCatchSync } from "@kizlo/shared";
|
|
8
|
+
import { PLUGIN_VERSION_HEADER, base64Decode, isPluginVersionSupported, pluginUpdateMessage, tryCatchSync } from "@kizlo/shared";
|
|
9
9
|
import { serialize } from "cookie";
|
|
10
10
|
|
|
11
11
|
//#region src/context.ts
|
|
@@ -17,11 +17,29 @@ var Context = class {
|
|
|
17
17
|
email;
|
|
18
18
|
constructor(config) {
|
|
19
19
|
this.config = config;
|
|
20
|
-
this.wordpress = new WordPressService(
|
|
20
|
+
this.wordpress = new WordPressService({
|
|
21
|
+
...config,
|
|
22
|
+
onResponse: (headers) => this.warnIfPluginOutdated(headers)
|
|
23
|
+
});
|
|
21
24
|
this.settings = new SettingsService(this.wordpress);
|
|
22
25
|
this.email = new EmailService(this.wordpress);
|
|
23
26
|
this.logger = this.createLogger();
|
|
24
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Warn when the WordPress plugin is older than {@link isPluginVersionSupported} allows, read from the
|
|
30
|
+
* `X-Kizlo-Version` header the plugin stamps on every response. A version mismatch is a serious
|
|
31
|
+
* contract break, so this fires on every WordPress response rather than once — the header rides
|
|
32
|
+
* responses the runtime already makes, so it costs no extra request. Emitted through `console.warn`
|
|
33
|
+
* rather than the logger adapter on purpose: the adapter is optional (it defaults to a no-op), and
|
|
34
|
+
* this is a setup problem every user must see regardless of whether they've wired up logging.
|
|
35
|
+
*/
|
|
36
|
+
warnIfPluginOutdated(headers) {
|
|
37
|
+
const installed = headers.get(PLUGIN_VERSION_HEADER);
|
|
38
|
+
if (isPluginVersionSupported(installed)) return;
|
|
39
|
+
const inner = ` ${pluginUpdateMessage(installed)} `;
|
|
40
|
+
const border = "-".repeat(inner.length + 2);
|
|
41
|
+
console.warn(`\n\x1b[1m\x1b[33m${border}\n|${inner}|\n${border}\x1b[0m\n`);
|
|
42
|
+
}
|
|
25
43
|
createRestContext(request) {
|
|
26
44
|
const headers = new Headers();
|
|
27
45
|
return {
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ import "./wordpress/index.js";
|
|
|
22
22
|
import { DevPluginSource, Fixture, FixtureCleanupFn, FixtureSeedFn, JsonValue, LocalPlugin, PluginSource, SeedContext, TestAdminUser, TestCredentials, TestUser, defineFixture, isLocalPlugin } from "./cli/wp/types.js";
|
|
23
23
|
import { AuthAdapter, AuthGetUser, AuthUser, authMock, createAuthAdapter } from "./adapters/auth.js";
|
|
24
24
|
import { CaptchaAdapter, altcha, arkose, createCaptchaAdapter, friendlyCaptcha, hcaptcha, recaptcha, turnstile } from "./adapters/captcha.js";
|
|
25
|
-
import { CurrencyFormat, IdentifierInput, LIST_ORDER, ListMetadata, ListOrder,
|
|
25
|
+
import { CurrencyFormat, IdentifierInput, LIST_ORDER, ListMetadata, ListOrder, PreviewTokenData, PreviewTokenPayload } from "./shared/schema.js";
|
|
26
26
|
import { AnyContext, AnyNestedClient, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, HTTPMethod, List, MaybeOptionalOptions, RedirectInput, RedirectStatus } from "./shared/types.js";
|
|
27
27
|
import { createCookiesAdapter } from "./adapters/cookies.js";
|
|
28
28
|
import { ConnInfo, GeoAdapter, GeoGetConnInfo, createGeoAdapter, geoMock } from "./adapters/geo.js";
|
|
@@ -39,17 +39,17 @@ import { COMMON_ERRORS, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, Def
|
|
|
39
39
|
import { AnyMiddleware, ExtractMiddlewareContextOutput, InferMiddlewares, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, createMiddleware } from "./shared/middleware.js";
|
|
40
40
|
import { AnyProcedure, AnyProcedureRouter, BaseHandlerOptions, ExtractParams, ExtractProcedureByScope, InvocationScope, OpenapiPart, Procedure, ProcedureErrors, ProcedureHandler, ProcedureOptions, ResolveParamsPart, ResolvedSchemaInput, ResolvedSchemaOutput, RouterDepthTuple, SchemaIO, buildProcedure, combineDetailed, createProcedure, handleUnexpectedError, schemaType } from "./shared/procedure.js";
|
|
41
41
|
import { AnyExtension, Extension, ExtensionInitFn, ExtensionInitOptions, ExtensionInitResult, ExtractExtensionRouter, InferExtensionRouter, createExtension } from "./shared/extension.js";
|
|
42
|
-
import { AnyKizloConfig, CreateKizloOptions, Kizlo, KizloConfig, KizloConnect, RootRouter, S2SClient, ServiceAdapters, createKizlo, resolveKizloConfig } from "./kizlo.js";
|
|
42
|
+
import { AnyKizloConfig, CreateKizloOptions, EnvReader, Kizlo, KizloConfig, KizloConnect, RootRouter, S2SClient, ServiceAdapters, createKizlo, resolveKizloConfig } from "./kizlo.js";
|
|
43
43
|
import { WEB_MANIFEST_ROUTE, WebManifest, buildWebManifest, createManifestRoute } from "./brand/manifest.js";
|
|
44
44
|
import "./brand/index.js";
|
|
45
45
|
import { KizloClient, KizloClientConfig, createKizloClient } from "./client.js";
|
|
46
46
|
import { CONTENT_TYPES, ContentType, ListSitemapUrlInput, ListSitemapUrlInputBase, Robots, RobotsRule, Seo, SeoHead, SeoSchema, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList } from "./seo/schema.js";
|
|
47
47
|
import { WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapContentType, WPK_SitemapIndex, WPK_SitemapUrl, WPK_SitemapUrlImage } from "./seo/types.js";
|
|
48
|
-
import { SitemapIndexEntry, deserializeSeo, parseSitemapSlug, renderSitemapIndex, renderUrlSet, sitemapEntryPath, xmlResponse } from "./seo/utils.js";
|
|
48
|
+
import { SitemapIndexEntry, deserializeSeo, parseSitemapSlug, renderJsonLd, renderSitemapIndex, renderUrlSet, sitemapEntryPath, xmlResponse } from "./seo/utils.js";
|
|
49
49
|
import { CreateSitemapRouteOptions, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SitemapRouteExtra, createSitemapRedirectRoute, createSitemapRoute } from "./seo/sitemap.js";
|
|
50
50
|
import { Contract, ContractProcedure, generateContract, isContractProcedure, restoreContract } from "./shared/contract.js";
|
|
51
51
|
import { ShaAlgorithm, compare, hash, hmac } from "./shared/crypto.js";
|
|
52
52
|
import { Identifier, parseIdentifier } from "./shared/identifier.js";
|
|
53
53
|
import { createOrpcRouter } from "./shared/router.js";
|
|
54
54
|
import { deserializeCurrencyFormat, deserializeListMetadata, emptyList, serializeCurrencyFormat } from "./shared/serialize.js";
|
|
55
|
-
export { AnyContext, AnyEventSchema, AnyEvents, AnyExtension, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureRouter, AuthAdapter, AuthGetUser, AuthUser, AuthUserFn, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, CART_HASH_HEADER_KEY, COMMON_ERRORS, CONTENT_TYPES, CaptchaAdapter, CategoryService, CommentService, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, ConnInfo, ConnInfoFn, ConsoleLogAdapterOptions, ContentType, Context, ContextConfig, Contract, ContractProcedure, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, CookiesStorage, CrawlingSettings, CrawlingSettingsInput, CreateKizloOptions, CreateSitemapRouteOptions, CurrencyFormat, DefinedErrorMapLike, DevPluginSource, Environment, ErrorDefinition, EventHandler, EventHandlerFn, Extension, ExtensionInitFn, ExtensionInitOptions, ExtensionInitResult, ExtractExtensionRouter, ExtractMiddlewareContextOutput, ExtractParams, ExtractProcedureByScope, Fixture, FixtureCleanupFn, FixtureSeedFn, GeoAdapter, GeoGetConnInfo, HTTPMethod, IconDescriptor, Identifier, IdentifierInput, IdentitySettings, IdentitySettingsInput, InferEventUnion, InferExtensionRouter, InferMiddlewares, InvocationScope, JsonValue, Kizlo, KizloClient, KizloClientConfig, KizloConfig, KizloConnect, KizloError, KizloErrorOptions, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeOptionalOptions,
|
|
55
|
+
export { AnyContext, AnyEventSchema, AnyEvents, AnyExtension, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureRouter, AuthAdapter, AuthGetUser, AuthUser, AuthUserFn, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, CART_HASH_HEADER_KEY, COMMON_ERRORS, CONTENT_TYPES, CaptchaAdapter, CategoryService, CommentService, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, ConnInfo, ConnInfoFn, ConsoleLogAdapterOptions, ContentType, Context, ContextConfig, Contract, ContractProcedure, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, CookiesStorage, CrawlingSettings, CrawlingSettingsInput, CreateKizloOptions, CreateSitemapRouteOptions, CurrencyFormat, DefinedErrorMapLike, DevPluginSource, EnvReader, Environment, ErrorDefinition, EventHandler, EventHandlerFn, Extension, ExtensionInitFn, ExtensionInitOptions, ExtensionInitResult, ExtractExtensionRouter, ExtractMiddlewareContextOutput, ExtractParams, ExtractProcedureByScope, Fixture, FixtureCleanupFn, FixtureSeedFn, GeoAdapter, GeoGetConnInfo, HTTPMethod, IconDescriptor, Identifier, IdentifierInput, IdentitySettings, IdentitySettingsInput, InferEventUnion, InferExtensionRouter, InferMiddlewares, InvocationScope, JsonValue, Kizlo, KizloClient, KizloClientConfig, KizloConfig, KizloConnect, KizloError, KizloErrorOptions, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeOptionalOptions, MenuItemService, MenuService, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, PageService, PersonSettings, PersonSettingsInput, PluginSource, PostService, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureOptions, ROUTER_MAP, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, Robots, RobotsRule, RootRouter, RouterDepthTuple, RouterMap, S2SClient, SAFE_REQUEST_TIMEOUT, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, Settings, SettingsService, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, TaxonomySettings, TaxonomySettingsInput, TestAdminUser, TestCredentials, TestUser, ThrowableErrorFn, ThrowableErrorMap, UNEXPECTED_BODY_SNIPPET_LENGTH, UploadsSettings, UploadsSettingsInput, UserService, VerifyCaptchaFn, VerifyPreviewTokenFn, WC_CORE_BASE, WC_STORE_BASE, WEB_MANIFEST_ROUTE, WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapContentType, WPK_SitemapIndex, WPK_SitemapUrl, WPK_SitemapUrlImage, WP_AUTH_HEADER_KEY, WP_AUTH_TYPE, WP_CATEGORY_ORDER_BYS, WP_CORE_BASE, WP_Category, WP_CategoryCreateErrorCode, WP_CategoryCreateInput, WP_CategoryDeleteErrorCode, WP_CategoryDeleteInput, WP_CategoryDeleteResponse, WP_CategoryLinks, WP_CategoryListErrorCode, WP_CategoryListInput, WP_CategoryOrderBy, WP_CategoryRetrieveErrorCode, WP_CategoryRetrieveInput, WP_CategoryTaxonomy, WP_CategoryUpdateErrorCode, WP_CategoryUpdateInput, WP_Comment, WP_CommentAvatarUrls, WP_CommentContent, WP_CommentContentInput, WP_CommentCreateErrorCode, WP_CommentCreateInput, WP_CommentDeleteErrorCode, WP_CommentDeleteInput, WP_CommentDeleteResponse, WP_CommentLinks, WP_CommentListErrorCode, WP_CommentListInput, WP_CommentOrderBy, WP_CommentRetrieveErrorCode, WP_CommentRetrieveInput, WP_CommentStatus, WP_CommentStatusFilter, WP_CommentStatusInput, WP_CommentType, WP_CommentUpdateErrorCode, WP_CommentUpdateInput, WP_CommonErrorCode, WP_Context, WP_CurrencyFormat, WP_Error, WP_ErrorData, WP_KIZLO_BASE, WP_Link, WP_List, WP_ListMetadata, WP_ListOrder, WP_MENU_ITEM_ORDER_BYES, WP_MENU_ITEM_TARGETS, WP_MENU_ITEM_TAX_RELATIONS, WP_Menu, WP_MenuCreateErrorCode, WP_MenuCreateInput, WP_MenuDeleteErrorCode, WP_MenuDeleteInput, WP_MenuDeleteResponse, WP_MenuItem, WP_MenuItemCreateErrorCode, WP_MenuItemCreateInput, WP_MenuItemDeleteErrorCode, WP_MenuItemDeleteInput, WP_MenuItemDeleteResponse, WP_MenuItemLinks, WP_MenuItemListErrorCode, WP_MenuItemListInput, WP_MenuItemOrderBy, WP_MenuItemRetrieveErrorCode, WP_MenuItemRetrieveInput, WP_MenuItemStatus, WP_MenuItemStatusFilter, WP_MenuItemTarget, WP_MenuItemTaxRelation, WP_MenuItemTitle, WP_MenuItemTitleInput, WP_MenuItemType, WP_MenuItemUpdateErrorCode, WP_MenuItemUpdateInput, WP_MenuLinks, WP_MenuListErrorCode, WP_MenuListInput, WP_MenuOrderBy, WP_MenuRetrieveErrorCode, WP_MenuRetrieveInput, WP_MenuUpdateErrorCode, WP_MenuUpdateInput, WP_PAGE_ORDER_BYES, WP_PAGE_STATUSES, WP_POST_FORMATS, WP_POST_ORDER_BYES, WP_POST_STATUSES, WP_POST_TAX_RELATIONS, WP_Page, WP_PageCommentStatus, WP_PageContent, WP_PageContentInput, WP_PageCreateErrorCode, WP_PageCreateInput, WP_PageDeleteErrorCode, WP_PageDeleteInput, WP_PageDeleteResponse, WP_PageExcerpt, WP_PageExcerptInput, WP_PageGuid, WP_PageLinks, WP_PageListErrorCode, WP_PageListInput, WP_PageOrderBy, WP_PageRetrieveErrorCode, WP_PageRetrieveInput, WP_PageStatus, WP_PageStatusFilter, WP_PageTitle, WP_PageTitleInput, WP_PageUpdateErrorCode, WP_PageUpdateInput, WP_Post, WP_PostCommentStatus, WP_PostContent, WP_PostContentInput, WP_PostCreateErrorCode, WP_PostCreateInput, WP_PostDeleteErrorCode, WP_PostDeleteInput, WP_PostDeleteResponse, WP_PostExcerpt, WP_PostExcerptInput, WP_PostFormat, WP_PostGuid, WP_PostLinks, WP_PostListErrorCode, WP_PostListInput, WP_PostOrderBy, WP_PostRetrieveErrorCode, WP_PostRetrieveInput, WP_PostStatus, WP_PostStatusFilter, WP_PostTaxRelation, WP_PostTitle, WP_PostTitleInput, WP_PostUpdateErrorCode, WP_PostUpdateInput, WP_RequestInput, WP_Result, WP_TAG_ORDER_BYS, WP_Tag, WP_TagCreateErrorCode, WP_TagCreateInput, WP_TagDeleteErrorCode, WP_TagDeleteInput, WP_TagDeleteResponse, WP_TagLinks, WP_TagListErrorCode, WP_TagListInput, WP_TagOrderBy, WP_TagRetrieveErrorCode, WP_TagRetrieveInput, WP_TagTaxonomy, WP_TagUpdateErrorCode, WP_TagUpdateInput, WP_User, WP_UserAvatarUrls, WP_UserCapabilities, WP_UserCreateErrorCode, WP_UserCreateInput, WP_UserDeleteErrorCode, WP_UserDeleteInput, WP_UserDeleteMeErrorCode, WP_UserDeleteMeInput, WP_UserDeleteMeResponse, WP_UserDeleteResponse, WP_UserLinks, WP_UserListErrorCode, WP_UserListInput, WP_UserOrderBy, WP_UserRetrieveErrorCode, WP_UserRetrieveInput, WP_UserRetrieveMeErrorCode, WP_UserRetrieveMeInput, WP_UserUpdateErrorCode, WP_UserUpdateInput, WP_UserUpdateMeErrorCode, WP_UserUpdateMeInput, WP_UserWho, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressCredentials, WordPressService, altcha, arkose, authMock, buildProcedure, buildWebManifest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createExtension, createGeoAdapter, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, noopAdapter, parseIdentifier, parseSitemapSlug, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, toKizloError, turnstile, xmlResponse };
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { COMMON_ERRORS, KizloError, createThrowableErrorMap, defineErrorMap, isK
|
|
|
12
12
|
import { buildProcedure, combineDetailed, createProcedure, handleUnexpectedError, schemaType } from "./shared/procedure.js";
|
|
13
13
|
import { createOrpcRouter } from "./shared/router.js";
|
|
14
14
|
import { generateContract, isContractProcedure, restoreContract } from "./shared/contract.js";
|
|
15
|
-
import { CurrencyFormat, IdentifierInput, LIST_ORDER, ListMetadata, ListOrder,
|
|
15
|
+
import { CurrencyFormat, IdentifierInput, LIST_ORDER, ListMetadata, ListOrder, PreviewTokenData, PreviewTokenPayload } from "./shared/schema.js";
|
|
16
16
|
import { KizloClient, createKizloClient } from "./client.js";
|
|
17
17
|
import { CookiesStorage } from "./cookie.js";
|
|
18
18
|
import { CART_HASH_HEADER_KEY, SAFE_REQUEST_TIMEOUT, UNEXPECTED_BODY_SNIPPET_LENGTH, WC_CORE_BASE, WC_STORE_BASE, WP_AUTH_HEADER_KEY, WP_AUTH_TYPE, WP_CORE_BASE, WP_KIZLO_BASE } from "./wordpress/constants.js";
|
|
@@ -36,7 +36,7 @@ import { Context } from "./context.js";
|
|
|
36
36
|
import { parseIdentifier } from "./shared/identifier.js";
|
|
37
37
|
import { deserializeCurrencyFormat, deserializeListMetadata, emptyList, serializeCurrencyFormat } from "./shared/serialize.js";
|
|
38
38
|
import { CONTENT_TYPES, ContentType, ListSitemapUrlInput, ListSitemapUrlInputBase, Robots, RobotsRule, Seo, SeoHead, SeoSchema, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList } from "./seo/schema.js";
|
|
39
|
-
import { deserializeSeo, parseSitemapSlug, renderSitemapIndex, renderUrlSet, sitemapEntryPath, xmlResponse } from "./seo/utils.js";
|
|
39
|
+
import { deserializeSeo, parseSitemapSlug, renderJsonLd, renderSitemapIndex, renderUrlSet, sitemapEntryPath, xmlResponse } from "./seo/utils.js";
|
|
40
40
|
import { ROUTER_MAP } from "./router.js";
|
|
41
41
|
import { createEventHandler, createWebhookRouter } from "./webhook/index.js";
|
|
42
42
|
import { Kizlo, createKizlo, resolveKizloConfig } from "./kizlo.js";
|
|
@@ -44,4 +44,4 @@ import { SITEMAP_BASE, SITEMAP_INDEX_SLUG, createSitemapRedirectRoute, createSit
|
|
|
44
44
|
import { createExtension } from "./shared/extension.js";
|
|
45
45
|
import { createMiddleware } from "./shared/middleware.js";
|
|
46
46
|
|
|
47
|
-
export { CART_HASH_HEADER_KEY, COMMON_ERRORS, CONTENT_TYPES, CategoryService, CommentService, ContentType, Context, CookiesStorage, CurrencyFormat, IdentifierInput, Kizlo, KizloClient, KizloError, LIST_ORDER, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase,
|
|
47
|
+
export { CART_HASH_HEADER_KEY, COMMON_ERRORS, CONTENT_TYPES, CategoryService, CommentService, ContentType, Context, CookiesStorage, CurrencyFormat, IdentifierInput, Kizlo, KizloClient, KizloError, LIST_ORDER, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, MenuItemService, MenuService, PageService, PostService, PreviewTokenData, PreviewTokenPayload, ROUTER_MAP, Robots, RobotsRule, SAFE_REQUEST_TIMEOUT, SITEMAP_BASE, SITEMAP_INDEX_SLUG, Seo, SeoHead, SeoSchema, SettingsService, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList, UNEXPECTED_BODY_SNIPPET_LENGTH, UserService, WC_CORE_BASE, WC_STORE_BASE, WEB_MANIFEST_ROUTE, WP_AUTH_HEADER_KEY, WP_AUTH_TYPE, WP_CATEGORY_ORDER_BYS, WP_CORE_BASE, WP_Error, WP_KIZLO_BASE, WP_MENU_ITEM_ORDER_BYES, WP_MENU_ITEM_TARGETS, WP_MENU_ITEM_TAX_RELATIONS, WP_PAGE_ORDER_BYES, WP_PAGE_STATUSES, WP_POST_FORMATS, WP_POST_ORDER_BYES, WP_POST_STATUSES, WP_POST_TAX_RELATIONS, WP_TAG_ORDER_BYS, WordPressService, altcha, arkose, authMock, buildProcedure, buildWebManifest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createExtension, createGeoAdapter, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, noopAdapter, parseIdentifier, parseSitemapSlug, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, toKizloError, turnstile, xmlResponse };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AnyProcedureRouter } from "../../shared/procedure.js";
|
|
2
|
+
import { KizloClient } from "../../client.js";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/astro/kizlo.client.d.ts
|
|
5
|
+
interface KizloClientOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Backend URL. In the browser, pass `import.meta.env.PUBLIC_KIZLO_API_URL` at the call site so Vite
|
|
8
|
+
* inlines it into the client bundle (see the template's `client.ts`); when omitted it falls back to
|
|
9
|
+
* `PUBLIC_KIZLO_API_URL` from `process.env`.
|
|
10
|
+
*/
|
|
11
|
+
url?: string;
|
|
12
|
+
}
|
|
13
|
+
declare function createKizloClient<T extends AnyProcedureRouter>(contract: T, options?: KizloClientOptions): KizloClient<T>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { KizloClientOptions, createKizloClient };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KizloClient } from "../../client.js";
|
|
2
|
+
import { getServerBaseUrl } from "./utils.js";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/astro/kizlo.client.ts
|
|
5
|
+
function createKizloClient(contract, options) {
|
|
6
|
+
return new KizloClient({
|
|
7
|
+
url: options?.url ?? getServerBaseUrl(),
|
|
8
|
+
contract
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createKizloClient };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnyExtension } from "../../shared/extension.js";
|
|
2
|
+
import { CreateKizloOptions, EnvReader, Kizlo } from "../../kizlo.js";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/astro/kizlo.server.d.ts
|
|
5
|
+
type KizloServerOptions<TExts extends readonly AnyExtension[] = []> = CreateKizloOptions<TExts> & {
|
|
6
|
+
getSecret: EnvReader;
|
|
7
|
+
};
|
|
8
|
+
declare function createKizlo<TExts extends readonly AnyExtension[] = []>(options: KizloServerOptions<TExts>): Kizlo<TExts>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { KizloServerOptions, createKizlo };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Kizlo, resolveKizloConfig } from "../../kizlo.js";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/astro/kizlo.server.ts
|
|
4
|
+
function createKizlo(options) {
|
|
5
|
+
return new Kizlo(resolveKizloConfig(options, {
|
|
6
|
+
baseUrlEnvKey: "PUBLIC_KIZLO_API_URL",
|
|
7
|
+
env: options?.getSecret
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { createKizlo };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { S2SClient } from "../../kizlo.js";
|
|
2
|
+
import { WEB_MANIFEST_ROUTE } from "../../brand/manifest.js";
|
|
3
|
+
import { AstroRoute } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
//#region src/integrations/astro/manifest.d.ts
|
|
6
|
+
/** Astro endpoint for `src/pages/site.webmanifest.ts`. SSR refetches live on each request. */
|
|
7
|
+
declare function createManifestRoute(client: S2SClient<[]>): AstroRoute;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { createManifestRoute };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WEB_MANIFEST_ROUTE, createManifestRoute } from "../../brand/manifest.js";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/astro/manifest.ts
|
|
4
|
+
/** Astro endpoint for `src/pages/site.webmanifest.ts`. SSR refetches live on each request. */
|
|
5
|
+
function createManifestRoute$1(client) {
|
|
6
|
+
const handler = createManifestRoute(client);
|
|
7
|
+
return (context) => handler(context.request);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createManifestRoute$1 as createManifestRoute };
|