nimbus-docs 0.1.6 → 0.1.8
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 +23 -0
- package/dist/cli/index.js +20 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/content.d.ts +62 -6
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +11 -5
- package/dist/content.js.map +1 -1
- package/dist/{diagnostic-C6OaBe_o.d.ts → diagnostic-ewiZxpSO.d.ts} +4 -1
- package/dist/diagnostic-ewiZxpSO.d.ts.map +1 -0
- package/dist/index.d.ts +52 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +349 -159
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +350 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +782 -0
- package/dist/react.js.map +1 -0
- package/dist/{rules-DnAP-j89.js → rules-B7o0k3TA.js} +249 -2
- package/dist/rules-B7o0k3TA.js.map +1 -0
- package/dist/schemas.d.ts +85 -2
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +32 -6
- package/dist/schemas.js.map +1 -1
- package/dist/strict-keys-fbKKxxKL.js +141 -0
- package/dist/strict-keys-fbKKxxKL.js.map +1 -0
- package/dist/types.d.ts +49 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +37 -19
- package/dist/diagnostic-C6OaBe_o.d.ts.map +0 -1
- package/dist/rules-DnAP-j89.js.map +0 -1
- package/dist/strict-keys-BiXiT3pq.js +0 -35
- package/dist/strict-keys-BiXiT3pq.js.map +0 -1
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region src/_internal/strict-keys.ts
|
|
2
|
-
/**
|
|
3
|
-
* Wrap `schema` so unknown keys raise issues at parse time. Captures
|
|
4
|
-
* `Object.keys(schema.shape)` eagerly (before turning the schema into a
|
|
5
|
-
* `ZodEffects` via `superRefine`) so the known-key set reflects the
|
|
6
|
-
* schema as passed in. Call this AFTER any `.extend()` / `.merge()` so
|
|
7
|
-
* user-added fields are recognized.
|
|
8
|
-
*/
|
|
9
|
-
function withStrictKeys(schema, options) {
|
|
10
|
-
const knownKeys = new Set(Object.keys(schema.shape));
|
|
11
|
-
return schema.passthrough().superRefine((data, ctx) => {
|
|
12
|
-
if (!data || typeof data !== "object") return;
|
|
13
|
-
for (const key of Object.keys(data)) {
|
|
14
|
-
if (knownKeys.has(key)) continue;
|
|
15
|
-
const removal = options.removedKeys[key];
|
|
16
|
-
if (removal) ctx.addIssue({
|
|
17
|
-
code: "custom",
|
|
18
|
-
path: [key],
|
|
19
|
-
message: `${options.contextLabel} "${key}" ${removal}`
|
|
20
|
-
});
|
|
21
|
-
else {
|
|
22
|
-
const hint = options.unknownHint?.(key);
|
|
23
|
-
ctx.addIssue({
|
|
24
|
-
code: "custom",
|
|
25
|
-
path: [key],
|
|
26
|
-
message: hint ? `Unknown ${options.contextLabel.toLowerCase()} "${key}". ${hint}` : `Unknown ${options.contextLabel.toLowerCase()} "${key}".`
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
export { withStrictKeys as t };
|
|
35
|
-
//# sourceMappingURL=strict-keys-BiXiT3pq.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strict-keys-BiXiT3pq.js","names":[],"sources":["../src/_internal/strict-keys.ts"],"sourcesContent":["/**\n * Strict-key validation helper for Zod object schemas.\n *\n * Zod's default `.strip()` behavior silently drops unknown keys, which is\n * the wrong default for an authoring contract: a stale frontmatter or\n * config field that's been renamed or removed should fail loudly, not\n * vanish at parse time and produce subtly different behavior.\n *\n * This module wraps a `ZodObject` with `.passthrough().superRefine()` so\n * unknown keys survive the parse and get rejected with one issue per\n * key. Known-removed keys (passed via `removedKeys`) emit a friendly\n * migration message; everything else emits a generic \"unknown key\"\n * error with an actionable hint.\n *\n * Used by both the frontmatter schema (`src/schemas.ts`) and the config\n * schema (`src/_internal/validate.ts`). Each call site provides its own\n * `removedKeys` map and a `contextLabel` (\"Frontmatter key\" vs \"Config\n * field\" vs \"features.<key>\") so error messages read naturally.\n */\n\nimport type { z } from \"astro/zod\";\n\nexport interface StrictKeyOptions {\n /**\n * Map of removed-or-renamed keys → migration message. The message\n * follows the contextLabel + key prefix; phrase it as the back-half of\n * the sentence. Example: `'was renamed to \"mode\". Replace ...'`.\n */\n removedKeys: Record<string, string>;\n /**\n * Sentence-start label for the issue message. Examples: `Frontmatter\n * key`, `Config field`, `features sub-key`. The key name (quoted) is\n * appended automatically.\n */\n contextLabel: string;\n /**\n * Optional hint appended to the generic \"unknown key\" message for\n * keys NOT in `removedKeys`. Receives the offending key. Use this to\n * point users at the right escape hatch (e.g. how to add a custom\n * field in their schema).\n */\n unknownHint?: (key: string) => string;\n}\n\n/**\n * Wrap `schema` so unknown keys raise issues at parse time. Captures\n * `Object.keys(schema.shape)` eagerly (before turning the schema into a\n * `ZodEffects` via `superRefine`) so the known-key set reflects the\n * schema as passed in. Call this AFTER any `.extend()` / `.merge()` so\n * user-added fields are recognized.\n */\nexport function withStrictKeys<T extends z.ZodObject<z.ZodRawShape>>(\n schema: T,\n options: StrictKeyOptions,\n) {\n const knownKeys = new Set(Object.keys(schema.shape));\n return schema.passthrough().superRefine((data, ctx) => {\n if (!data || typeof data !== \"object\") return;\n for (const key of Object.keys(data as Record<string, unknown>)) {\n if (knownKeys.has(key)) continue;\n const removal = options.removedKeys[key];\n if (removal) {\n ctx.addIssue({\n code: \"custom\",\n path: [key],\n message: `${options.contextLabel} \"${key}\" ${removal}`,\n });\n } else {\n const hint = options.unknownHint?.(key);\n ctx.addIssue({\n code: \"custom\",\n path: [key],\n message: hint\n ? `Unknown ${options.contextLabel.toLowerCase()} \"${key}\". ${hint}`\n : `Unknown ${options.contextLabel.toLowerCase()} \"${key}\".`,\n });\n }\n }\n });\n}\n"],"mappings":";;;;;;;;AAmDA,SAAgB,eACd,QACA,SACA;CACA,MAAM,YAAY,IAAI,IAAI,OAAO,KAAK,OAAO,MAAM,CAAC;AACpD,QAAO,OAAO,aAAa,CAAC,aAAa,MAAM,QAAQ;AACrD,MAAI,CAAC,QAAQ,OAAO,SAAS,SAAU;AACvC,OAAK,MAAM,OAAO,OAAO,KAAK,KAAgC,EAAE;AAC9D,OAAI,UAAU,IAAI,IAAI,CAAE;GACxB,MAAM,UAAU,QAAQ,YAAY;AACpC,OAAI,QACF,KAAI,SAAS;IACX,MAAM;IACN,MAAM,CAAC,IAAI;IACX,SAAS,GAAG,QAAQ,aAAa,IAAI,IAAI,IAAI;IAC9C,CAAC;QACG;IACL,MAAM,OAAO,QAAQ,cAAc,IAAI;AACvC,QAAI,SAAS;KACX,MAAM;KACN,MAAM,CAAC,IAAI;KACX,SAAS,OACL,WAAW,QAAQ,aAAa,aAAa,CAAC,IAAI,IAAI,KAAK,SAC3D,WAAW,QAAQ,aAAa,aAAa,CAAC,IAAI,IAAI;KAC3D,CAAC;;;GAGN"}
|