Move docs/ package mirror into document-navigator plugin

Relocate the ~6k-file docs tree from the repo root into
plugins/document-navigator/docs/ so the plugin is self-contained and
portable. docs/superpowers/ (specs and plans) stays at the repo root.

Moved via cp+rm rather than git mv because directory rename() fails with
EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the
identical-content files at commit time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 01:10:00 +01:00
parent fe3fedf42e
commit 9bf56a806b
6022 changed files with 12437 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
# `options` — `RedocUiOptions` schema + parser
<!-- begin:auto-docs -->
_(no submodules)_
<!-- end:auto-docs -->
## Purpose
This module defines the Zod schema and parser for `RedocUiOptions`, the
configuration bundle the ReDoc UI handler accepts. It is the single boundary
where caller-supplied option values transition from untrusted input to a
fully-defaulted, immutable typed record the rest of the package treats as
ground truth. Refusing malformed input here means the rendered HTML shell
never has to defend against half-validated values at request time.
## Features
- Strict schema — unknown keys are refused so typos surface immediately
instead of silently producing a misconfigured shell.
- Sensible defaults so the bare `createRedocUiHandler()` call still produces
a working `/docs/ui/redoc` shell against `/openapi.json`.
- `expandResponses` is a regex-validated comma-separated list of three-character
HTTP status codes (or `"all"`), matching the official ReDoc option.
- `uiAssets` strategy literal — one of `"cdn"`, `"bundled"`, `"inline"`.
- Zod failures are wrapped as `OpenapiUiRedocError(INVALID_OPTIONS)` with the
original `ZodError` attached as `cause`.
## Usage: Basic
```ts
import { parseRedocUiOptions } from "@suaveplan/api-openapi-ui-redoc/options";
const opts = parseRedocUiOptions({
openapiUrl: "/openapi.json",
theme: "dark",
});
```
## Usage: Advanced
Combine with the host-config layer to validate `host.openapi.ui = "redoc"`
options at ingestion time, before any handler is constructed:
```ts
import {
parseRedocUiOptions,
redocUiOptionsSchema,
type RedocUiOptionsInput,
} from "@suaveplan/api-openapi-ui-redoc/options";
const hostConfigSchema = z.object({
openapi: z.object({
ui: z.literal("redoc"),
redoc: redocUiOptionsSchema.partial().default({}),
}),
});
function buildHandler(raw: unknown) {
const cfg = hostConfigSchema.parse(raw);
const opts: RedocUiOptionsInput = cfg.openapi.redoc;
return parseRedocUiOptions(opts);
}
```
## API Reference
| Symbol | Kind | Description |
| ------------------------- | ------ | ----------- |
| `redocUiOptionsSchema` | const | `z.ZodObject` of the strict options shape |
| `RedocUiOptions` | type | `z.infer<typeof redocUiOptionsSchema>` (defaulted) |
| `RedocUiOptionsInput` | type | `z.input<typeof redocUiOptionsSchema>` (caller-facing) |
| `parseRedocUiOptions` | fn | `(input?) => RedocUiOptions` — throws `OpenapiUiRedocError(INVALID_OPTIONS)` |
## Implementation Notes
The schema is `.strict()` so additional keys raise the catch-all
`INVALID_OPTIONS` code rather than silently passing through. We use
`safeParse` internally so we can wrap the error rather than re-throw the raw
`ZodError`; the wrapper carries the registry code and stable message but the
underlying issue list remains accessible via `err.cause`. Defaults are baked
into the schema so a `parseRedocUiOptions({})` call returns a fully-formed
options record without callers having to reach for any other layer.