kizlo 0.11.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/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 +8 -8
- package/dist/cli/commands/create.js +98 -68
- package/dist/cli/commands/generate.js +4 -0
- package/dist/cli/commands/init.js +109 -59
- package/dist/cli/daemon/config.js +12 -6
- package/dist/cli/daemon/generate.js +2 -3
- package/dist/cli/daemon/jiti.js +101 -0
- package/dist/cli/daemon/watch.js +7 -3
- package/dist/cli/presets/source.js +122 -24
- package/dist/cli/presets/template.js +47 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- 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/seo/utils.d.ts +8 -2
- package/dist/seo/utils.js +9 -1
- package/dist/shared/constants.js +9 -1
- package/package.json +17 -1
- package/dist/cli/presets/base.js +0 -40
- package/dist/cli/presets/index.js +0 -16
- package/dist/cli/presets/nextjs.js +0 -16
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { generateContract } from "../../shared/contract.js";
|
|
2
2
|
import { loadEnvFiles } from "../utils.js";
|
|
3
|
+
import { importIgnoringVirtualModules } from "./jiti.js";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import fs from "node:fs";
|
|
5
|
-
import { createJiti } from "jiti";
|
|
6
6
|
|
|
7
7
|
//#region src/cli/daemon/generate.ts
|
|
8
8
|
/** The generated contract barrel — also written as a stub by `kizlo init`. */
|
|
@@ -25,9 +25,8 @@ function atomicWrite(file, data) {
|
|
|
25
25
|
*/
|
|
26
26
|
async function generateOnce(cfg) {
|
|
27
27
|
loadEnvFiles(cfg.cwd);
|
|
28
|
-
const jiti = createJiti(cfg.cwd, { moduleCache: false });
|
|
29
28
|
const entry = path.resolve(cfg.cwd, cfg.serverEntry);
|
|
30
|
-
const { router } = await
|
|
29
|
+
const { router } = await importIgnoringVirtualModules(cfg.cwd, entry);
|
|
31
30
|
if (!router) return false;
|
|
32
31
|
const contract = JSON.stringify(await generateContract(router));
|
|
33
32
|
fs.mkdirSync(path.resolve(cfg.cwd, cfg.generatedDir), { recursive: true });
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CONTRACT_GENERATION_ENV } from "../../shared/constants.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { createJiti } from "jiti";
|
|
5
|
+
|
|
6
|
+
//#region src/cli/daemon/jiti.ts
|
|
7
|
+
/**
|
|
8
|
+
* Loads a TypeScript module through jiti while tolerating framework virtual modules
|
|
9
|
+
* (`astro:env/server`, `virtual:*`, `#imports`, `$env/*`, …). These are synthesized by the
|
|
10
|
+
* framework's bundler at build time and don't exist on disk, so jiti can't resolve them — but
|
|
11
|
+
* contract generation only needs the module's exported *shape*, never the runtime values a
|
|
12
|
+
* virtual module carries. We discover them from the project's own source rather than maintaining
|
|
13
|
+
* a per-framework list: import, and whenever jiti reports a missing module, stub it and retry.
|
|
14
|
+
*
|
|
15
|
+
* A virtual module is distinguished from a genuinely missing dependency by the one property that
|
|
16
|
+
* always holds — a virtual module is never a declared dependency, so a bare specifier whose
|
|
17
|
+
* package isn't in `package.json` is treated as virtual, while a declared-but-unresolvable
|
|
18
|
+
* dependency is surfaced as the real error it is.
|
|
19
|
+
*/
|
|
20
|
+
async function importIgnoringVirtualModules(cwd, entry) {
|
|
21
|
+
const deps = declaredDeps(cwd);
|
|
22
|
+
const virtualModules = {};
|
|
23
|
+
const previousGenerationFlag = process.env[CONTRACT_GENERATION_ENV];
|
|
24
|
+
process.env[CONTRACT_GENERATION_ENV] = "1";
|
|
25
|
+
try {
|
|
26
|
+
return await importLoop(cwd, entry, deps, virtualModules);
|
|
27
|
+
} finally {
|
|
28
|
+
if (previousGenerationFlag === void 0) delete process.env[CONTRACT_GENERATION_ENV];
|
|
29
|
+
else process.env[CONTRACT_GENERATION_ENV] = previousGenerationFlag;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function importLoop(cwd, entry, deps, virtualModules) {
|
|
33
|
+
for (;;) {
|
|
34
|
+
const jiti = createJiti(cwd, {
|
|
35
|
+
moduleCache: false,
|
|
36
|
+
tsconfigPaths: true,
|
|
37
|
+
virtualModules
|
|
38
|
+
});
|
|
39
|
+
try {
|
|
40
|
+
return await jiti.import(entry);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
const spec = missingSpecifier(error);
|
|
43
|
+
if (!spec || !isBareSpecifier(spec) || spec in virtualModules || deps.has(packageNameOf(spec))) throw error;
|
|
44
|
+
virtualModules[spec] = makeVirtualStub();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A no-op module namespace that satisfies any import shape (named, default, nested, callable),
|
|
50
|
+
* so a virtual module can be stubbed without knowing what it exports. The `has` trap is required:
|
|
51
|
+
* without it jiti's `interopDefault` sees a truthy `.default` and routes named lookups down a path
|
|
52
|
+
* that misses.
|
|
53
|
+
*
|
|
54
|
+
* Every export — named, default, nested, callable — is a no-op, so contract generation only ever
|
|
55
|
+
* reads the module's shape, never a real value a virtual module would carry at runtime.
|
|
56
|
+
*/
|
|
57
|
+
function makeVirtualStub() {
|
|
58
|
+
const stub = new Proxy(() => {}, {
|
|
59
|
+
apply: () => void 0,
|
|
60
|
+
has: (_t, prop) => typeof prop === "string" && prop !== "then",
|
|
61
|
+
get: (_t, prop) => {
|
|
62
|
+
if (prop === "__esModule") return true;
|
|
63
|
+
if (prop === "then") return void 0;
|
|
64
|
+
if (typeof prop === "symbol") return void 0;
|
|
65
|
+
return stub;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return stub;
|
|
69
|
+
}
|
|
70
|
+
/** Names of every declared dependency; empty when `package.json` is absent or unreadable. */
|
|
71
|
+
function declaredDeps(cwd) {
|
|
72
|
+
try {
|
|
73
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf8"));
|
|
74
|
+
return new Set([
|
|
75
|
+
...Object.keys(pkg.dependencies ?? {}),
|
|
76
|
+
...Object.keys(pkg.devDependencies ?? {}),
|
|
77
|
+
...Object.keys(pkg.peerDependencies ?? {}),
|
|
78
|
+
...Object.keys(pkg.optionalDependencies ?? {})
|
|
79
|
+
]);
|
|
80
|
+
} catch {
|
|
81
|
+
return /* @__PURE__ */ new Set();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** The specifier jiti/Node reported unresolvable, or undefined when the error isn't a resolution failure. */
|
|
85
|
+
function missingSpecifier(error) {
|
|
86
|
+
const err = error;
|
|
87
|
+
if (err?.code !== "MODULE_NOT_FOUND" && err?.code !== "ERR_MODULE_NOT_FOUND") return void 0;
|
|
88
|
+
return /Cannot find module '([^']+)'/.exec(err.message ?? "")?.[1];
|
|
89
|
+
}
|
|
90
|
+
/** Virtual specifiers are always bare; a missing relative/absolute path is a real bug, not a virtual module. */
|
|
91
|
+
function isBareSpecifier(spec) {
|
|
92
|
+
return !spec.startsWith(".") && !spec.startsWith("/");
|
|
93
|
+
}
|
|
94
|
+
/** Package name of a bare specifier: `@scope/x/sub` → `@scope/x`, `astro:env/server` → `astro:env`. */
|
|
95
|
+
function packageNameOf(spec) {
|
|
96
|
+
const parts = spec.split("/");
|
|
97
|
+
return spec.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? spec;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
export { importIgnoringVirtualModules };
|
package/dist/cli/daemon/watch.js
CHANGED
|
@@ -37,9 +37,9 @@ async function watch(cfg) {
|
|
|
37
37
|
* Acquire the single-instance lock, generate the contract once, and start the file
|
|
38
38
|
* watcher. Returns a synchronous `stop()` that closes the watcher and releases the
|
|
39
39
|
* lock — or `undefined` when another watcher already holds the lock (a framework dev
|
|
40
|
-
* script, or a second `kizlo dev`),
|
|
41
|
-
* watching. Used by `kizlo dev`, both when it boots a local
|
|
42
|
-
* the watcher alone, so a single terminal covers the whole dev loop.
|
|
40
|
+
* script, or a second `kizlo dev`), or when no server `dir` is configured, in which case
|
|
41
|
+
* the caller carries on without watching. Used by `kizlo dev`, both when it boots a local
|
|
42
|
+
* stack and when it runs the watcher alone, so a single terminal covers the whole dev loop.
|
|
43
43
|
*/
|
|
44
44
|
async function startWatcher(cwd, opts) {
|
|
45
45
|
const lock = lockPath(cwd);
|
|
@@ -48,6 +48,10 @@ async function startWatcher(cwd, opts) {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
const cfg = await resolveConfig(cwd, { dir: opts?.dir });
|
|
51
|
+
if (!cfg) {
|
|
52
|
+
log.info("skipping the contract generation.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
51
55
|
acquire(lock);
|
|
52
56
|
try {
|
|
53
57
|
if (await generateOnce(cfg)) log.success("Contract generated");
|
|
@@ -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 };
|
|
@@ -91,18 +91,61 @@ const envSchema = z.object({
|
|
|
91
91
|
});
|
|
92
92
|
/** A package name → version-range map, package.json's own vocabulary. */
|
|
93
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
|
+
});
|
|
94
119
|
const manifestSchema = z.object({
|
|
95
120
|
framework: z.string(),
|
|
121
|
+
name: z.string().optional(),
|
|
96
122
|
env: envSchema.optional(),
|
|
97
123
|
dependencies: depsSchema.optional(),
|
|
98
124
|
devDependencies: depsSchema.optional(),
|
|
99
125
|
minCli: z.string().optional(),
|
|
126
|
+
apiPath: z.string().optional(),
|
|
127
|
+
detect: detectSchema.optional(),
|
|
128
|
+
requires: requiresSchema.optional(),
|
|
129
|
+
notes: z.array(noteSchema).default([]),
|
|
100
130
|
bootstrap: bootstrapSchema.optional(),
|
|
101
131
|
conventions: conventionsSchema,
|
|
102
132
|
base: z.array(changeSchema).default([]),
|
|
103
133
|
create: z.array(changeSchema).default([]),
|
|
104
134
|
init: z.array(changeSchema).default([])
|
|
105
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
|
+
}
|
|
106
149
|
/** Role → the human label init uses in prompts and logs. */
|
|
107
150
|
const ROLE_LABELS = {
|
|
108
151
|
"server-entry": "Kizlo server instance",
|
|
@@ -115,6 +158,9 @@ const ROLE_LABELS = {
|
|
|
115
158
|
"root-layout": "root layout",
|
|
116
159
|
"home-page": "home page",
|
|
117
160
|
"blog-post": "blog post page",
|
|
161
|
+
"head-component": "SEO head component",
|
|
162
|
+
"framework-config": "framework config",
|
|
163
|
+
tsconfig: "TypeScript config",
|
|
118
164
|
styles: "global styles"
|
|
119
165
|
};
|
|
120
166
|
/** Read and validate the template's manifest from a fetched template directory. */
|
|
@@ -279,4 +325,4 @@ function rendersHtml(file) {
|
|
|
279
325
|
}
|
|
280
326
|
|
|
281
327
|
//#endregion
|
|
282
|
-
export { adaptFile, changesFor, fileEntries, findRootLayout, isOlderVersion, minCliError, patchEntries, readManifest, resolveDependencies, resolvePatch };
|
|
328
|
+
export { adaptFile, changesFor, fileEntries, findRootLayout, isOlderVersion, minCliError, patchEntries, readManifest, renderNote, resolveDependencies, resolvePatch };
|
package/dist/index.d.ts
CHANGED
|
@@ -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, 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, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, toKizloError, turnstile, xmlResponse };
|
|
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
|
@@ -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, 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, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, toKizloError, turnstile, xmlResponse };
|
|
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 };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { IconDescriptor } from "../../brand/icons.js";
|
|
2
|
+
import { S2SClient } from "../../kizlo.js";
|
|
3
|
+
import { SeoHead } from "../../seo/schema.js";
|
|
4
|
+
import { renderJsonLd } from "../../seo/utils.js";
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/astro/metadata.d.ts
|
|
7
|
+
/** A `<meta name="theme-color">` entry, optionally scoped to a `prefers-color-scheme` media query. */
|
|
8
|
+
interface ThemeColor {
|
|
9
|
+
media?: string;
|
|
10
|
+
color: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Brand + site data for the document `<head>`, resolved from WordPress settings. The `.astro`
|
|
14
|
+
* head component maps this to `<title>`/`<link>`/`<meta>` tags (Astro has no `generateMetadata`,
|
|
15
|
+
* and this package can't compile `.astro`, so the rendering lives in the template).
|
|
16
|
+
*/
|
|
17
|
+
interface RootHead {
|
|
18
|
+
/** Web manifest route to link with `rel="manifest"`. */
|
|
19
|
+
manifest: string;
|
|
20
|
+
icons: {
|
|
21
|
+
icon: IconDescriptor[];
|
|
22
|
+
appleTouch: IconDescriptor[];
|
|
23
|
+
};
|
|
24
|
+
/** Site origin used to resolve relative URLs, when set in WordPress. */
|
|
25
|
+
metadataBase?: string;
|
|
26
|
+
/** Browser-chrome theme color(s); a light/dark pair carries `prefers-color-scheme` media queries. */
|
|
27
|
+
themeColor: ThemeColor[];
|
|
28
|
+
}
|
|
29
|
+
/** Per-page SEO tags, mapped from a post's SEO head. Consumed by the template's head component. */
|
|
30
|
+
interface PageHead {
|
|
31
|
+
title: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
canonical: string;
|
|
34
|
+
robots: string;
|
|
35
|
+
og: {
|
|
36
|
+
type: string;
|
|
37
|
+
title: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
url: string;
|
|
40
|
+
siteName: string;
|
|
41
|
+
locale: string;
|
|
42
|
+
image?: {
|
|
43
|
+
url: string;
|
|
44
|
+
width?: number;
|
|
45
|
+
height?: number;
|
|
46
|
+
alt?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
twitter: {
|
|
50
|
+
card: string;
|
|
51
|
+
title: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
site?: string;
|
|
54
|
+
creator?: string;
|
|
55
|
+
image?: string;
|
|
56
|
+
imageAlt?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Resolve the root brand/site head from WordPress settings (icons, manifest, theme color, base URL). */
|
|
60
|
+
declare function resolveRootHead(client: S2SClient<[]>): Promise<RootHead>;
|
|
61
|
+
/** Map a post's SEO head to the flat descriptors the template's head component renders. */
|
|
62
|
+
declare function resolvePageHead(head: SeoHead): PageHead;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { PageHead, RootHead, ThemeColor, resolvePageHead, resolveRootHead };
|