@jk2908/mdsrc 0.4.0 → 0.5.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/CHANGELOG.md +14 -0
- package/README.md +77 -22
- package/dist/index.d.ts +42 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +409 -177
- package/dist/index.js.map +7 -5
- package/dist/types.d.ts +9 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/validate.d.ts +18 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +366 -0
- package/dist/validate.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/config.ts", "../src/logger.ts", "../src/utils.ts"],
|
|
3
|
+
"sources": ["../src/index.ts", "../src/config.ts", "../src/logger.ts", "../src/utils.ts", "../src/types.ts", "../src/validate.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { realpathSync } from 'node:fs'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport type { Plugin, ViteDevServer } from 'vite'\n\nimport { markdownToHtml, type CompileOptions, type MarkdownToHtmlResult } from 'satteri'\n\nimport type {\n\tBuildContext,\n\tCollection,\n\tEntries,\n\tIssue,\n\tPluginConfig,\n\tRaw,\n\tResult,\n\tSchema,\n} from './types.js'\nimport { GENERATED_DIR, PKG_NAME } from './config.js'\nimport { Logger } from './logger.js'\nimport { capitalise, debounce, dedent, deep, isRecord, pluralise } from './utils.js'\n\nconst fileCache = new Map<string, string>()\n\nconst DEFAULT_COMPILE_OPTIONS = {\n\tfeatures: {\n\t\tfrontmatter: true,\n\t},\n} satisfies CompileOptions\n\nexport type { CompileOptions } from './types.js'\n\n/**\n * Parse YAML or TOML frontmatter\n */\nasync function parse(frontmatter: MarkdownToHtmlResult['frontmatter']) {\n\tif (!frontmatter) return {}\n\n\tconst { kind, value } = frontmatter\n\n\tswitch (kind) {\n\t\tcase 'yaml': {\n\t\t\treturn (await import('yaml')).parse(value)\n\t\t}\n\t\tcase 'toml': {\n\t\t\treturn (await import('smol-toml')).parse(value)\n\t\t}\n\t}\n}\n\n/**\n * Read every markdown file in a collection and turn it into the raw entry shape\n * add mdsrc metadata like slug and filename alongside the trimmed body\n * return an empty list if the directory read fails\n */\nexport async function create(dir: string, buildContext: BuildContext) {\n\tconst { logger, compileOptions = {} } = buildContext\n\tconst { features, ...restCompileOptions } = compileOptions\n\n\ttry {\n\t\t// only pick up markdown files from this directory\n\t\t// leave everything else alone\n\t\tconst files = (await fs.readdir(dir)).filter(\n\t\t\t(file: string) => path.extname(file) === '.md',\n\t\t)\n\t\tconst filePaths = files.map(file => path.join(dir, file))\n\n\t\tif (!files.length) {\n\t\t\tconsole.warn(`mdsrc: ${dir} is empty`)\n\t\t\treturn []\n\t\t}\n\n\t\treturn Promise.all(\n\t\t\tfilePaths.map(async filePath => {\n\t\t\t\tconst file = path.basename(filePath)\n\n\t\t\t\tconst { html, frontmatter: rawFrontmatter } = markdownToHtml(\n\t\t\t\t\tawait fs.readFile(filePath, 'utf-8'),\n\t\t\t\t\t{\n\t\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t\t...DEFAULT_COMPILE_OPTIONS.features,\n\t\t\t\t\t\t\t...features,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...restCompileOptions,\n\t\t\t\t\t},\n\t\t\t\t)\n\n\t\t\t\tconst frontmatter = await parse(rawFrontmatter)\n\n\t\t\t\treturn {\n\t\t\t\t\t...frontmatter,\n\t\t\t\t\t__mdsrc: {\n\t\t\t\t\t\tslug: path.basename(file, '.md').toLowerCase().replace(/\\s+/g, '-'),\n\t\t\t\t\t\tfilename: file,\n\t\t\t\t\t},\n\t\t\t\t\tbody: html.trim(),\n\t\t\t\t} satisfies Raw\n\t\t\t}),\n\t\t)\n\t} catch (err) {\n\t\tlogger.error('[create]: failed to create entries', err)\n\t\treturn []\n\t}\n}\n\n/**\n * Write a file only if the content has changed since the last build\n */\nasync function maybeWrite(filePath: string, content: string) {\n\tconst cached = fileCache.get(filePath)\n\n\tif (cached === content) {\n\t\ttry {\n\t\t\tawait fs.access(filePath)\n\t\t\treturn false\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof Error) || !('code' in err) || err.code !== 'ENOENT') {\n\t\t\t\tthrow err\n\t\t\t}\n\n\t\t\t// file was deleted since the last build, fall through and write it again\n\t\t}\n\t}\n\n\tif (cached === undefined) {\n\t\ttry {\n\t\t\tconst current = await fs.readFile(filePath, 'utf-8')\n\t\t\tfileCache.set(filePath, current)\n\n\t\t\tif (current === content) {\n\t\t\t\tfileCache.set(filePath, content)\n\t\t\t\treturn false\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof Error) || !('code' in err) || err.code !== 'ENOENT') {\n\t\t\t\tthrow err\n\t\t\t}\n\t\t}\n\t}\n\n\t// file is new or changed since the last build, write it and refresh the cache\n\tawait fs.writeFile(filePath, content)\n\tfileCache.set(filePath, content)\n\n\treturn true\n}\n\n/**\n * Check one entry against the declared schema and coerce what can be coerced\n * leave missing optional keys alone instead of treating them as errors\n * normalise dates to iso strings for output\n */\nfunction validate(input: Entries, schema: Schema) {\n\t// keep valid values separate so bad fields never sneak into output\n\tconst validated: Entries = {}\n\t// collect every problem so one pass can report the lot\n\tconst issues: Issue[] = []\n\n\t// bail out early if the frontmatter is not even an object\n\tif (typeof input !== 'object' || input === null) {\n\t\tissues.push({ message: 'Input must be an object' })\n\t\treturn { issues } satisfies Result<Entries>\n\t}\n\n\tfunction walk(key: string, schemaValue: Schema.Value, data: unknown) {\n\t\tconst { optional, key: parsedKey } = parseKey(key)\n\n\t\tif (data === undefined) {\n\t\t\tif (!optional) {\n\t\t\t\tissues.push({ message: `Missing required key: ${parsedKey}` })\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t\t// check primitives\n\t\tif (typeof schemaValue === 'string') {\n\t\t\tswitch (schemaValue) {\n\t\t\t\tcase 'string': {\n\t\t\t\t\tif (typeof data !== 'string') {\n\t\t\t\t\t\tissues.push({ message: `Key ${parsedKey} must be a string` })\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, data)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tcase 'number': {\n\t\t\t\t\tlet num = data\n\n\t\t\t\t\tif (typeof data === 'string' && !Number.isNaN(Number(data))) {\n\t\t\t\t\t\tnum = Number(data)\n\t\t\t\t\t}\n\n\t\t\t\t\tif (typeof num !== 'number' || Number.isNaN(num)) {\n\t\t\t\t\t\tissues.push({ message: `Key ${parsedKey} must be a number` })\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, num)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tcase 'boolean': {\n\t\t\t\t\tlet bool = data\n\n\t\t\t\t\tif (typeof data === 'string') {\n\t\t\t\t\t\tif (data.toLowerCase() === 'true') {\n\t\t\t\t\t\t\tbool = true\n\t\t\t\t\t\t} else if (data.toLowerCase() === 'false') {\n\t\t\t\t\t\t\tbool = false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (typeof bool !== 'boolean') {\n\t\t\t\t\t\tissues.push({ message: `Key ${parsedKey} must be a boolean` })\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, bool)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tcase 'date': {\n\t\t\t\t\tif (typeof data !== 'string') {\n\t\t\t\t\t\tissues.push({ message: `Key ${parsedKey} must be a date` })\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst date = new Date(data)\n\n\t\t\t\t\tif (Number.isNaN(date.getTime())) {\n\t\t\t\t\t\tissues.push({ message: `Key ${parsedKey} must be a valid date` })\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, date.toISOString())\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (!isRecord(data)) {\n\t\t\t\tissues.push({ message: `Key ${parsedKey} must be an object` })\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst obj = data\n\n\t\t\tfor (const subKey in schemaValue) {\n\t\t\t\twalk(`${parsedKey}.${subKey}`, schemaValue[subKey], obj[parseKey(subKey).key])\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const key in schema) {\n\t\twalk(key, schema[key], input[parseKey(key).key])\n\t}\n\n\t// return the clean entry when validation passes, otherwise return the full\n\t// issue list\n\treturn (issues.length ? { issues } : { value: validated }) satisfies Result<Entries>\n}\n\nfunction parseKey(k: string) {\n\tconst optional = k.endsWith('?')\n\n\treturn {\n\t\toptional,\n\t\tkey: optional ? k.slice(0, -1) : k,\n\t}\n}\n\nfunction schemaValueToType(schema: Schema) {\n\tconst fields = Object.entries(schema)\n\t\t.map(([k, v]) => {\n\t\t\tconst { key, optional } = parseKey(k)\n\n\t\t\tlet type: string\n\n\t\t\tif (typeof v === 'string') {\n\t\t\t\ttype = v === 'date' ? 'string' : v\n\t\t\t} else {\n\t\t\t\t// recursively call for record shapes\n\t\t\t\ttype = schemaValueToType(v)\n\t\t\t}\n\n\t\t\treturn `${key}${optional ? '?' : ''}: ${type}`\n\t\t})\n\t\t.join('\\n ')\n\n\treturn `{ ${fields} }`\n}\n\nasync function build(src: Collection[], buildContext: BuildContext) {\n\tconst { logger, outDir } = buildContext\n\tlet names: string[] = []\n\n\t// keep each validated collection beside its schema so emit stays in sync\n\tconst collections: Record<\n\t\tstring,\n\t\t{\n\t\t\titems: Raw[]\n\t\t\tschema: Schema\n\t\t}\n\t> = {}\n\n\ttry {\n\t\tif (!outDir) throw new Error('Output directory is not defined')\n\n\t\t// make sure the output directory exists before the writes begin\n\t\t// that way the emit step can stay simple\n\t\tawait fs.mkdir(outDir, { recursive: true })\n\n\t\t// read and validate every collection before writing anything out\n\t\t// this keeps the js and dts outputs in step\n\t\tfor (const collection of src) {\n\t\t\tconst raw = await create(path.join(process.cwd(), collection.dir), buildContext)\n\n\t\t\t// check each raw item before it makes it into the generated collection\n\t\t\t// bad entries get logged and dropped\n\t\t\tconst validated = await Promise.all(\n\t\t\t\traw.map(async item => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst { body, __mdsrc, ...metadata } = item\n\t\t\t\t\t\tconst res = validate(metadata, collection.schema)\n\n\t\t\t\t\t\tif (res.issues) throw new Error(JSON.stringify(res.issues, null, 2))\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...res.value,\n\t\t\t\t\t\t\tbody,\n\t\t\t\t\t\t\t__mdsrc,\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\t`[buildStart]: failed to validate item in ${collection.name}`,\n\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t)\n\n\t\t\tcollections[collection.name] = {\n\t\t\t\t// keep the cleaned items with the schema they came from\n\t\t\t\t// both js and dts generation read from this shape\n\t\t\t\titems: validated.filter(e => e !== null),\n\t\t\t\tschema: collection.schema,\n\t\t\t}\n\t\t}\n\n\t\t// take the collection names after validation has settled\n\t\t// every generated file then works from the same list\n\t\tnames = Object.keys(collections)\n\t\t// queue the file writes first so the emit phase can run together\n\t\t// wait for them once every output is ready\n\t\tconst promises = []\n\n\t\t// build the type file from the schema rather than the observed data\n\t\t// that keeps optional fields and date output honest\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'types.ts'),\n\t\t\t\t`\n\t\t\t\t\t${names\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\texport type ${capitalise(name)} = ${schemaValueToType(collections[name].schema)} & {\n\t\t\t\t\t\t\t\t\tbody: string,\n\t\t\t\t\t\t\t\t\t__mdsrc: {\n\t\t\t\t\t\t\t\t\t\tslug: string\n\t\t\t\t\t\t\t\t\t\tfilename: string\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('\\n\\n')}`.trim(),\n\t\t\t),\n\t\t)\n\n\t\t// write the package surface separately so consumers get typed named exports\n\t\t// this mirrors the generated js entry file\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'index.d.ts'),\n\t\t\t\t`\t\n\t\t\t\t\timport type { ${names.map(name => capitalise(name)).join(', ')} } from './types.js'\n\n\t\t\t\t\t${names\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\texport const all${capitalise(pluralise(name, 2))}: ${capitalise(name)}[]\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('\\n\\n')}\n\n\t\t\t\t\tdeclare module '${PKG_NAME}' {\n\t\t\t\t\t\t${names\n\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\t\texport const all${capitalise(pluralise(name, 2))}: ${capitalise(name)}[]\n\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.join('\\n\\n')}\n\t\t\t\t\t}\n\t\t\t\t`.trim(),\n\t\t\t),\n\t\t)\n\n\t\t// serialise each validated collection as a plain module for Vite to load\n\t\tfor (const name of names) {\n\t\t\tconst collection = collections[name]?.items\n\t\t\tconst fileName = toModuleName(name)\n\n\t\t\tpromises.push(\n\t\t\t\tmaybeWrite(\n\t\t\t\t\tpath.join(outDir, `${fileName}.js`),\n\t\t\t\t\t`export const all${capitalise(pluralise(name, 2))} = ${collection?.length ? JSON.stringify(collection) : '[]'}`.trim(),\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\t// stitch the per-collection modules into the public js entrypoint\n\t\t// this is the file the root package import resolves to\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'index.js'),\n\t\t\t\tnames.map(name => `export * from './${toModuleName(name)}.js'`).join('\\n'),\n\t\t\t),\n\t\t)\n\n\t\t// flush every generated artifact once all the content is ready\n\t\t// let any failed write fail the build\n\t\tconst writes = await Promise.all(promises)\n\t\tbuildContext.names = names\n\n\t\treturn writes.some(changed => changed)\n\t} catch (err) {\n\t\tlogger.error('[build]: failed to generate data', err)\n\t\tthrow err\n\t}\n}\n\n/**\n * Convert watcher paths to a consistent slash format before comparing them\n */\nfunction normaliseWatchPath(p: string) {\n\treturn p.replace(/\\\\/g, '/')\n}\n\n/**\n * Build the Vite plugin that validates collections and writes the generated modules\n * keep the runtime data and declaration files in the same pass\n * resolve package imports from the generated directory\n */\nexport default function mdsrc(config: PluginConfig): Plugin {\n\tconst src = config.collections\n\n\t// use one logger for the whole build so every step reports the same way\n\t// stay chatty outside production\n\tconst logger = new Logger(\n\t\tconfig.logger?.level ?? (process.env.NODE_ENV === 'production' ? 'error' : 'debug'),\n\t)\n\n\t// write generated files into a hidden folder at the project root\n\t// keep the generated surface out of src\n\tconst outDir = path.join(process.cwd(), GENERATED_DIR)\n\tconst watchRoot = normaliseWatchPath(realpathSync.native(process.cwd()))\n\tconst watchedRoots = src.map(c => `${normaliseWatchPath(path.join(watchRoot, c.dir))}/`)\n\n\t// watcher events can arrive through symlinked paths like /var while cwd has\n\t// already resolved to /private/var, so canonicalise the parent dir once and\n\t// reattach the file name for stable prefix checks\n\tconst resolveWatchFile = (filePath: string) => {\n\t\tconst absolutePath = path.resolve(watchRoot, filePath)\n\t\tconst parentPath = path.dirname(absolutePath)\n\n\t\ttry {\n\t\t\tconst resolvedParentPath = normaliseWatchPath(realpathSync.native(parentPath))\n\t\t\treturn normaliseWatchPath(\n\t\t\t\tpath.join(resolvedParentPath, path.basename(absolutePath)),\n\t\t\t)\n\t\t} catch {\n\t\t\treturn normaliseWatchPath(absolutePath)\n\t\t}\n\t}\n\n\tfunction watchedFile(filePath: string) {\n\t\treturn watchedRoots.some(root => resolveWatchFile(filePath).startsWith(root))\n\t}\n\n\t// pass shared build tools into helpers without dragging lots of state around\n\t// keep the helper signatures small\n\tconst buildContext = {\n\t\tlogger,\n\t\tcompileOptions: config.compileOptions,\n\t\toutDir,\n\t\tnames: [],\n\t} satisfies BuildContext\n\n\tlet rebuildRunning = false\n\tlet rebuildQueued = false\n\tlet rebuildReason = 'change'\n\n\tconst rebuild = debounce((event: string, filePath: string) => {\n\t\tfunction queue() {\n\t\t\tvoid (async () => {\n\t\t\t\t// collapse bursts of file events into one active rebuild plus a single\n\t\t\t\t// queued rerun when changes land mid-build\n\t\t\t\tif (rebuildRunning) {\n\t\t\t\t\trebuildQueued = true\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\trebuildRunning = true\n\n\t\t\t\tdo {\n\t\t\t\t\trebuildQueued = false\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst changed = await build(src, buildContext)\n\n\t\t\t\t\t\tif (changed) logger.info(`[watch]: content rebuilt (${rebuildReason})`)\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error('[watch] content rebuild failed', err)\n\t\t\t\t\t}\n\t\t\t\t} while (rebuildQueued)\n\n\t\t\t\trebuildRunning = false\n\t\t\t})()\n\t\t}\n\n\t\t// ignore anything outside the watched content dirs\n\t\tif (!watchedFile(filePath)) return\n\n\t\tconst file = resolveWatchFile(filePath)\n\n\t\trebuildReason = `${event}: ${path.relative(watchRoot, file)}`\n\t\tqueue()\n\t}, 75)\n\n\treturn {\n\t\tname: 'mdsrc',\n\t\tenforce: 'pre',\n\t\tconfig(viteConfig) {\n\t\t\tviteConfig.optimizeDeps ??= {}\n\t\t\tviteConfig.optimizeDeps.exclude = [\n\t\t\t\t...new Set([...(viteConfig.optimizeDeps.exclude ?? []), PKG_NAME]),\n\t\t\t]\n\n\t\t\tviteConfig.resolve ??= {}\n\n\t\t\tif (Array.isArray(viteConfig.resolve.alias)) {\n\t\t\t\tviteConfig.resolve.alias = [\n\t\t\t\t\t...viteConfig.resolve.alias,\n\t\t\t\t\t{\n\t\t\t\t\t\tfind: PKG_NAME,\n\t\t\t\t\t\treplacement: path.join(outDir, 'index.js'),\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t} else {\n\t\t\t\tviteConfig.resolve.alias = {\n\t\t\t\t\t...viteConfig.resolve.alias,\n\t\t\t\t\t[PKG_NAME]: path.join(outDir, 'index.js'),\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync buildStart() {\n\t\t\tawait build(src, buildContext)\n\t\t},\n\t\tconfigureServer(server: ViteDevServer) {\n\t\t\tlogger.info(\n\t\t\t\t`[configureServer]: Watching for changes in ./${src.map(c => c.dir).join(', ')}...`,\n\t\t\t)\n\n\t\t\tserver.watcher\n\t\t\t\t.on('add', (p: string) => rebuild('add', p))\n\t\t\t\t.on('change', (p: string) => rebuild('change', p))\n\t\t\t\t.on('unlink', (p: string) => rebuild('unlink', p))\n\t\t},\n\t\tresolveId(id) {\n\t\t\t// point imports at generated files rather than source files\n\t\t\t// that makes the package behave like a normal module\n\t\t\tif (id === PKG_NAME) {\n\t\t\t\treturn path.join(outDir, 'index.js')\n\t\t\t}\n\n\t\t\tif (id.startsWith(`${PKG_NAME}/`)) {\n\t\t\t\t// allow collection subpath imports once the build knows their names\n\t\t\t\t// leave unknown subpaths unresolved\n\t\t\t\tconst subpath = id.slice(PKG_NAME.length + 1)\n\t\t\t\tconst match = buildContext.names.find(\n\t\t\t\t\tname => name === subpath || toModuleName(name) === subpath,\n\t\t\t\t)\n\n\t\t\t\tif (match) {\n\t\t\t\t\treturn path.join(outDir, `${toModuleName(match)}.js`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null\n\t\t},\n\t}\n}\n\nfunction toModuleName(name: string) {\n\treturn name.toLowerCase()\n}\n\nif (import.meta.vitest) {\n\tconst { it, expect, describe } = import.meta.vitest\n\n\tconst now = Date.now()\n\n\tconst yaml = {\n\t\tkind: 'yaml',\n\t\tvalue: dedent(`\n\t\t\ttitle: mdsrc\n\t\t\tdate: ${now}\n\t\t`),\n\t} satisfies MarkdownToHtmlResult['frontmatter']\n\n\tconst toml = {\n\t\tkind: 'toml',\n\t\tvalue: dedent(`\n\t\t\ttitle = \"mdsrc\"\n\t\t\tdate = ${now}\n\t\t`),\n\t} satisfies MarkdownToHtmlResult['frontmatter']\n\n\tdescribe('markdown parsing', () => {\n\t\tit('parses frontmatter', async () => {\n\t\t\tfor (const f of [yaml, toml]) {\n\t\t\t\tconst frontmatter = await parse(f)\n\n\t\t\t\texpect(frontmatter).toEqual({\n\t\t\t\t\ttitle: 'mdsrc',\n\t\t\t\t\tdate: now,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tit('returns empty object for missing frontmatter', async () => {\n\t\t\tconst frontmatter = await parse(null)\n\t\t\texpect(frontmatter).toEqual({})\n\t\t})\n\t})\n}\n",
|
|
5
|
+
"import { realpathSync } from 'node:fs'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport type { Plugin, ViteDevServer } from 'vite'\n\nimport { markdownToHtml, type CompileOptions, type MarkdownToHtmlResult } from 'satteri'\n\nimport type { BuildContext, Collection, PluginConfig, Raw, Schema } from './types.js'\nimport { GENERATED_DIR, PKG_NAME } from './config.js'\nimport { Logger } from './logger.js'\nimport { capitalise, debounce, pluralise } from './utils.js'\nimport { parseKey, validate } from './validate.js'\n\nexport const DEFAULT_COMPILE_OPTIONS = {\n\tfeatures: {\n\t\tfrontmatter: true,\n\t},\n} satisfies CompileOptions\n\nexport type { CompileOptions } from './types.js'\n\n/**\n * Parse YAML or TOML frontmatter\n */\nexport async function parse(frontmatter: MarkdownToHtmlResult['frontmatter']) {\n\tif (!frontmatter) return {}\n\n\tconst { kind, value } = frontmatter\n\n\tswitch (kind) {\n\t\tcase 'yaml': {\n\t\t\treturn (await import('yaml')).parse(value)\n\t\t}\n\t\tcase 'toml': {\n\t\t\treturn (await import('smol-toml')).parse(value)\n\t\t}\n\t}\n}\n\n/**\n * Read every markdown file in a collection and turn it into the raw entry shape\n * add mdsrc metadata like slug and filename alongside the trimmed body\n * return an empty list if the directory read fails\n */\nexport async function create(dir: string, buildContext: BuildContext) {\n\tconst { logger, compileOptions = {} } = buildContext\n\tconst { features, ...restCompileOptions } = compileOptions\n\n\ttry {\n\t\t// only pick up markdown files from this directory\n\t\t// leave everything else alone\n\t\tconst files = (await fs.readdir(dir)).filter(\n\t\t\t(file: string) => path.extname(file) === '.md',\n\t\t)\n\t\tconst filePaths = files.map(file => path.join(dir, file))\n\n\t\tif (!files.length) {\n\t\t\tlogger.warn(`mdsrc: ${dir} is empty`)\n\t\t\treturn []\n\t\t}\n\n\t\treturn Promise.all(\n\t\t\tfilePaths.map(async filePath => {\n\t\t\t\tconst file = path.basename(filePath)\n\n\t\t\t\tconst { html, frontmatter: rawFrontmatter } = markdownToHtml(\n\t\t\t\t\tawait fs.readFile(filePath, 'utf-8'),\n\t\t\t\t\t{\n\t\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t\t...DEFAULT_COMPILE_OPTIONS.features,\n\t\t\t\t\t\t\t...features,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...restCompileOptions,\n\t\t\t\t\t},\n\t\t\t\t)\n\n\t\t\t\tconst frontmatter = await parse(rawFrontmatter)\n\n\t\t\t\treturn {\n\t\t\t\t\t...frontmatter,\n\t\t\t\t\t__mdsrc: {\n\t\t\t\t\t\tslug: path.basename(file, '.md').toLowerCase().replace(/\\s+/g, '-'),\n\t\t\t\t\t\tfilename: file,\n\t\t\t\t\t},\n\t\t\t\t\tbody: html.trim(),\n\t\t\t\t} satisfies Raw\n\t\t\t}),\n\t\t)\n\t} catch (err) {\n\t\tlogger.error('[create]: failed to create entries', err)\n\t\tthrow err\n\t}\n}\n\n/**\n * Returns whether the error was caused by a missing file or directory\n */\nexport function isENOENT(err: unknown) {\n\treturn err instanceof Error && 'code' in err && err.code === 'ENOENT'\n}\n\n/**\n * LRU cache for file content. Stores the last written content per file path\n * so `maybeWrite` can skip disk I/O when nothing has changed.\n *\n * Uses Map insertion order to track recency: the front of the map holds the\n * least recently used entries, which are evicted first when the cache is full.\n */\nexport const fileCache = new Map<string, string>()\n\nexport const FILE_CACHE_MAX_SIZE = 100\n\n/**\n * Promote an existing cache entry to most-recently-used by deleting and\n * re-inserting it, which moves it to the end of the Map's iteration\n * order. If the cache is at capacity, evict the least recently used\n * entry (front) before inserting\n */\nexport function setFileCache(filePath: string, content: string) {\n\tfileCache.delete(filePath)\n\n\tif (fileCache.size >= FILE_CACHE_MAX_SIZE) {\n\t\tconst lru = fileCache.keys().next().value\n\n\t\tif (lru !== undefined) {\n\t\t\tfileCache.delete(lru)\n\t\t}\n\t}\n\n\tfileCache.set(filePath, content)\n}\n\n/**\n * Retrieve a cached value and promote it to most-recently-used so it won't\n * be evicted while still actively referenced\n */\nexport function getFileCache(filePath: string) {\n\tconst content = fileCache.get(filePath)\n\n\tif (content !== undefined) {\n\t\tsetFileCache(filePath, content)\n\t}\n\n\treturn content\n}\n\n/**\n * Write a file only if the content has changed since the last build\n */\nexport async function maybeWrite(filePath: string, content: string) {\n\tconst cached = getFileCache(filePath)\n\n\tif (cached !== content) {\n\t\t// cache says content changed, write without reading\n\t\tawait fs.writeFile(filePath, content)\n\t\tsetFileCache(filePath, content)\n\n\t\treturn true\n\t}\n\n\t// cache miss or cache hit with same content — verify on disk\n\ttry {\n\t\tif ((await fs.readFile(filePath, 'utf-8')) === content) {\n\t\t\tsetFileCache(filePath, content)\n\t\t\treturn false\n\t\t}\n\t} catch (err) {\n\t\tif (!isENOENT(err)) throw err\n\t}\n\n\tawait fs.writeFile(filePath, content)\n\tsetFileCache(filePath, content)\n\n\treturn true\n}\n\nexport function schemaToType(schema: Schema) {\n\tconst fields = Object.entries(schema)\n\t\t.map(([k, v]) => {\n\t\t\tconst { key, optional } = parseKey(k)\n\n\t\t\tlet type: string\n\n\t\t\tif (typeof v === 'string') {\n\t\t\t\t// date will be an ISO string post validation\n\t\t\t\ttype = v === 'date' ? 'string' : v === 'array' ? 'any[]' : v\n\t\t\t} else {\n\t\t\t\t// recursively call for record shapes\n\t\t\t\ttype = schemaToType(v)\n\t\t\t}\n\n\t\t\treturn `${key}${optional ? '?' : ''}: ${type}`\n\t\t})\n\t\t.join('\\n ')\n\n\treturn `{ ${fields} }`\n}\n\nasync function build(src: Collection[], buildContext: BuildContext) {\n\tconst { logger, outDir } = buildContext\n\tlet names: string[] = []\n\n\t// keep each validated collection beside its schema so emit stays in sync\n\tconst collections: Record<\n\t\tstring,\n\t\t{\n\t\t\titems: Raw[]\n\t\t\tschema: Schema\n\t\t}\n\t> = {}\n\n\ttry {\n\t\tif (!outDir) throw new Error('Output directory is not defined')\n\n\t\t// make sure the output directory exists before the writes begin\n\t\t// that way the emit step can stay simple\n\t\tawait fs.mkdir(outDir, { recursive: true })\n\n\t\t// read and validate every collection before writing anything out\n\t\t// this keeps the js and dts outputs in step\n\t\tfor (const collection of src) {\n\t\t\tconst raw = await create(path.join(process.cwd(), collection.dir), buildContext)\n\n\t\t\t// check each raw item before it makes it into the generated collection\n\t\t\t// bad entries get logged and dropped\n\t\t\tconst validated = raw.map(item => {\n\t\t\t\tconst { body, __mdsrc, ...metadata } = item\n\t\t\t\tconst res = validate(metadata, collection.schema)\n\n\t\t\t\tif (res.issues) throw new Error(JSON.stringify(res.issues, null, 2))\n\n\t\t\t\treturn {\n\t\t\t\t\t...res.value,\n\t\t\t\t\tbody,\n\t\t\t\t\t__mdsrc,\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tcollections[collection.name] = {\n\t\t\t\t// keep the cleaned items with the schema they came from\n\t\t\t\t// both js and dts generation read from this shape\n\t\t\t\titems: validated,\n\t\t\t\tschema: collection.schema,\n\t\t\t}\n\t\t}\n\n\t\t// take the collection names after validation has settled\n\t\t// every generated file then works from the same list\n\t\tnames = Object.keys(collections)\n\t\t// queue the file writes first so the emit phase can run together\n\t\t// wait for them once every output is ready\n\t\tconst promises = []\n\n\t\t// build the type file from the schema rather than the observed data\n\t\t// that keeps optional fields and date output honest\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'types.ts'),\n\t\t\t\t`\n\t\t\t\t\t${names\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\texport type ${capitalise(name)} = ${schemaToType(collections[name].schema)} & {\n\t\t\t\t\t\t\t\t\tbody: string,\n\t\t\t\t\t\t\t\t\t__mdsrc: {\n\t\t\t\t\t\t\t\t\t\tslug: string\n\t\t\t\t\t\t\t\t\t\tfilename: string\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('\\n\\n')}`.trim(),\n\t\t\t),\n\t\t)\n\n\t\t// write the package surface separately so consumers get typed named exports\n\t\t// this mirrors the generated js entry file\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'index.d.ts'),\n\t\t\t\t`\t\n\t\t\t\t\timport type { ${names.map(name => capitalise(name)).join(', ')} } from './types.js'\n\n\t\t\t\t\t${names\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\texport const all${capitalise(pluralise(name, 2))}: ${capitalise(name)}[]\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('\\n\\n')}\n\n\t\t\t\t\tdeclare module '${PKG_NAME}' {\n\t\t\t\t\t\t${names\n\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\tname => `\n\t\t\t\t\t\t\t\t\texport const all${capitalise(pluralise(name, 2))}: ${capitalise(name)}[]\n\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.join('\\n\\n')}\n\t\t\t\t\t}\n\t\t\t\t`.trim(),\n\t\t\t),\n\t\t)\n\n\t\t// serialise each validated collection as a plain module for Vite to load\n\t\tfor (const name of names) {\n\t\t\tconst collection = collections[name]?.items\n\t\t\tconst fileName = toModuleName(name)\n\n\t\t\tpromises.push(\n\t\t\t\tmaybeWrite(\n\t\t\t\t\tpath.join(outDir, `${fileName}.js`),\n\t\t\t\t\t`export const all${capitalise(pluralise(name, 2))} = ${collection?.length ? JSON.stringify(collection) : '[]'}`.trim(),\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\t// stitch the per-collection modules into the public js entrypoint\n\t\t// this is the file the root package import resolves to\n\t\tpromises.push(\n\t\t\tmaybeWrite(\n\t\t\t\tpath.join(outDir, 'index.js'),\n\t\t\t\tnames.map(name => `export * from './${toModuleName(name)}.js'`).join('\\n'),\n\t\t\t),\n\t\t)\n\n\t\t// flush every generated artifact once all the content is ready\n\t\t// let any failed write fail the build\n\t\tconst writes = await Promise.all(promises)\n\t\tbuildContext.names = names\n\n\t\treturn writes.some(changed => changed)\n\t} catch (err) {\n\t\tlogger.error('[build]: failed to generate data', err)\n\t\tthrow err\n\t}\n}\n\n/**\n * Convert watcher paths to a consistent slash format before comparing them\n */\nfunction normaliseWatchPath(p: string) {\n\treturn p.replace(/\\\\/g, '/')\n}\n\n/**\n * Build the Vite plugin that validates collections and writes the generated modules\n * keep the runtime data and declaration files in the same pass\n * resolve package imports from the generated directory\n */\nexport default function mdsrc(config: PluginConfig): Plugin {\n\tconst src = config.collections\n\n\t// use one logger for the whole build so every step reports the same way\n\t// stay chatty outside production\n\tconst logger = new Logger(\n\t\tconfig.logger?.level ?? (process.env.NODE_ENV === 'production' ? 'error' : 'debug'),\n\t)\n\n\t// write generated files into a hidden folder at the project root\n\t// keep the generated surface out of src\n\tconst outDir = path.join(process.cwd(), GENERATED_DIR)\n\tconst watchRoot = normaliseWatchPath(realpathSync.native(process.cwd()))\n\tconst watchedRoots = src.map(c => `${normaliseWatchPath(path.join(watchRoot, c.dir))}/`)\n\n\t// watcher events can arrive through symlinked paths like /var while cwd has\n\t// already resolved to /private/var, so canonicalise the parent dir once and\n\t// reattach the file name for stable prefix checks\n\tconst resolveWatchFile = (filePath: string) => {\n\t\tconst absolutePath = path.resolve(watchRoot, filePath)\n\t\tconst parentPath = path.dirname(absolutePath)\n\n\t\ttry {\n\t\t\tconst resolvedParentPath = normaliseWatchPath(realpathSync.native(parentPath))\n\t\t\treturn normaliseWatchPath(\n\t\t\t\tpath.join(resolvedParentPath, path.basename(absolutePath)),\n\t\t\t)\n\t\t} catch {\n\t\t\treturn normaliseWatchPath(absolutePath)\n\t\t}\n\t}\n\n\tfunction watchedFile(filePath: string) {\n\t\treturn watchedRoots.some(root => resolveWatchFile(filePath).startsWith(root))\n\t}\n\n\t// pass shared build tools into helpers without dragging lots of state around\n\t// keep the helper signatures small\n\tconst buildContext = {\n\t\tlogger,\n\t\tcompileOptions: config.compileOptions,\n\t\toutDir,\n\t\tnames: [],\n\t} satisfies BuildContext\n\n\tlet rebuildRunning = false\n\tlet rebuildQueued = false\n\tlet rebuildReason = 'change'\n\n\tconst rebuild = debounce((event: string, filePath: string) => {\n\t\tfunction queue() {\n\t\t\tvoid (async () => {\n\t\t\t\t// collapse bursts of file events into one active rebuild plus a single\n\t\t\t\t// queued rerun when changes land mid-build\n\t\t\t\tif (rebuildRunning) {\n\t\t\t\t\trebuildQueued = true\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\trebuildRunning = true\n\n\t\t\t\tdo {\n\t\t\t\t\trebuildQueued = false\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst changed = await build(src, buildContext)\n\n\t\t\t\t\t\tif (changed) logger.info(`[watch]: content rebuilt (${rebuildReason})`)\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error('[watch] content rebuild failed', err)\n\t\t\t\t\t}\n\t\t\t\t} while (rebuildQueued)\n\n\t\t\t\trebuildRunning = false\n\t\t\t})()\n\t\t}\n\n\t\t// ignore anything outside the watched content dirs\n\t\tif (!watchedFile(filePath)) return\n\n\t\tconst file = resolveWatchFile(filePath)\n\n\t\trebuildReason = `${event}: ${path.relative(watchRoot, file)}`\n\t\tqueue()\n\t}, 75)\n\n\treturn {\n\t\tname: 'mdsrc',\n\t\tenforce: 'pre',\n\t\tconfig(viteConfig) {\n\t\t\tviteConfig.optimizeDeps ??= {}\n\t\t\tviteConfig.optimizeDeps.exclude = [\n\t\t\t\t...new Set([...(viteConfig.optimizeDeps.exclude ?? []), PKG_NAME]),\n\t\t\t]\n\n\t\t\tviteConfig.resolve ??= {}\n\n\t\t\tif (Array.isArray(viteConfig.resolve.alias)) {\n\t\t\t\tviteConfig.resolve.alias = [\n\t\t\t\t\t...viteConfig.resolve.alias,\n\t\t\t\t\t{\n\t\t\t\t\t\tfind: PKG_NAME,\n\t\t\t\t\t\treplacement: path.join(outDir, 'index.js'),\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t} else {\n\t\t\t\tviteConfig.resolve.alias = {\n\t\t\t\t\t...viteConfig.resolve.alias,\n\t\t\t\t\t[PKG_NAME]: path.join(outDir, 'index.js'),\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync buildStart() {\n\t\t\tawait build(src, buildContext)\n\t\t},\n\t\tconfigureServer(server: ViteDevServer) {\n\t\t\tlogger.info(\n\t\t\t\t`[configureServer]: Watching for changes in ./${src.map(c => c.dir).join(', ')}...`,\n\t\t\t)\n\n\t\t\tserver.watcher\n\t\t\t\t.on('add', (p: string) => rebuild('add', p))\n\t\t\t\t.on('change', (p: string) => rebuild('change', p))\n\t\t\t\t.on('unlink', (p: string) => rebuild('unlink', p))\n\t\t},\n\t\tresolveId(id) {\n\t\t\t// point imports at generated files rather than source files\n\t\t\t// that makes the package behave like a normal module\n\t\t\tif (id === PKG_NAME) return path.join(outDir, 'index.js')\n\n\t\t\tif (id.startsWith(`${PKG_NAME}/`)) {\n\t\t\t\t// allow collection subpath imports once the build knows their names\n\t\t\t\t// leave unknown subpaths unresolved\n\t\t\t\tconst subpath = id.slice(PKG_NAME.length + 1)\n\t\t\t\tconst match = buildContext.names.find(\n\t\t\t\t\tname => name === subpath || toModuleName(name) === subpath,\n\t\t\t\t)\n\n\t\t\t\tif (match) return path.join(outDir, `${toModuleName(match)}.js`)\n\t\t\t}\n\n\t\t\treturn null\n\t\t},\n\t}\n}\n\nexport function toModuleName(name: string) {\n\treturn name.toLowerCase()\n}\n",
|
|
6
6
|
"export const NAME = 'mdsrc'\nexport const PKG_NAME = `@jk2908/${NAME}`\nexport const GENERATED_DIR = `.${NAME}`",
|
|
7
7
|
"import { NAME } from './config.js'\n\nconst LEVELS = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n\tfatal: 4,\n} as const\n\nexport type LogLevel = keyof typeof LEVELS\n\ntype LogEntry = {\n\tts: number\n\tlevel: LogLevel\n\tmessage: string\n\terror?:\n\t\t| Error\n\t\t| {\n\t\t\t\tmessage: string\n\t\t\t\tstack?: string\n\t\t\t\tcause?: unknown\n\t\t }\n}\n\n/**\n * Log messages with different severity levels\n */\nexport class Logger {\n\tstatic #defaultLevel: LogLevel = 'info'\n\n\t#level?: LogLevel\n\n\tconstructor(level?: LogLevel) {\n\t\tthis.#level = level\n\t}\n\n\tstatic set defaultLevel(level: LogLevel) {\n\t\tLogger.#defaultLevel = level\n\t}\n\n\tstatic get defaultLevel() {\n\t\treturn Logger.#defaultLevel\n\t}\n\n\t/**\n\t * Convert a value to an Error instance\n\t */\n\tstatic toError(err: unknown) {\n\t\treturn err instanceof Error ? err : new Error(String(err), { cause: err })\n\t}\n\n\t/**\n\t * Stringify the error for logging\n\t */\n\tstatic print(err: unknown) {\n\t\tif (err instanceof Error) {\n\t\t\treturn err.message + (err.stack ? `\\n${err.stack}` : '')\n\t\t}\n\n\t\t// for plain objects, attempt to stringify with indentation\n\t\t// for readability\n\t\tif (typeof err === 'object' && err !== null) {\n\t\t\ttry {\n\t\t\t\treturn JSON.stringify(err, null, 2)\n\t\t\t} catch {\n\t\t\t\t// if stringify fails (e.g. circular reference), fall back\n\t\t\t\t// to basic string conversion\n\t\t\t\treturn String(err)\n\t\t\t}\n\t\t}\n\n\t\treturn String(err)\n\t}\n\n\tset level(level: LogLevel) {\n\t\tthis.#level = level\n\t}\n\n\tget level() {\n\t\treturn this.#level ?? Logger.#defaultLevel\n\t}\n\n\t/**\n\t * Log a message with a specific level\n\t */\n\tlog(level: LogLevel, message: string, error?: Error) {\n\t\tif (LEVELS[level] < LEVELS[this.level]) return\n\n\t\tconst entry: LogEntry = {\n\t\t\tts: Date.now(),\n\t\t\tlevel,\n\t\t\tmessage,\n\t\t}\n\n\t\tif (level === 'error' || level === 'fatal') {\n\t\t\tentry.error = error ? Logger.toError(error) : new Error(message)\n\t\t}\n\n\t\tconst line = `[${NAME}] [${entry.ts}] [${level.toUpperCase()}] ${message}`\n\t\tconst extra = entry.error ? `\\n${Logger.print(entry.error)}` : ''\n\n\t\tif (level === 'warn') {\n\t\t\tconsole.warn(line, extra)\n\t\t\treturn\n\t\t}\n\n\t\tif (level === 'error' || level === 'fatal') {\n\t\t\tconsole.error(line, extra)\n\t\t\treturn\n\t\t}\n\n\t\tconsole.log(line, extra)\n\t}\n\n\t/**\n\t * Log a debug message\n\t */\n\tdebug(...messages: string[]) {\n\t\tthis.log('debug', messages.join(' '))\n\t}\n\n\t/**\n\t * Log an info message\n\t */\n\tinfo(...messages: string[]) {\n\t\tthis.log('info', messages.join(' '))\n\t}\n\n\t/**\n\t * Log a warning message\n\t */\n\twarn(...messages: string[]) {\n\t\tthis.log('warn', messages.join(' '))\n\t}\n\n\t/**\n\t * Log an error message\n\t */\n\terror(message: string, error?: unknown) {\n\t\tthis.log('error', message, error === undefined ? undefined : Logger.toError(error))\n\t}\n\n\t/**\n\t * Log a fatal error message\n\t */\n\tfatal(message: string, error?: unknown) {\n\t\tthis.log('fatal', message, error === undefined ? undefined : Logger.toError(error))\n\t}\n}\n\nexport const logger = new Logger(\n\tprocess.env.NODE_ENV === 'production' ? 'error' : 'debug',\n)\n",
|
|
8
|
-
"export function capitalise(str: string) {\n\treturn str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport function pluralise(str: string, count: number) {\n\treturn count === 1 ? str : str.endsWith('s') ? str : `${str}s`\n}\n\nexport function debounce<T extends unknown[]>(fn: (...args: T) => void, wait: number) {\n\tlet timeoutId: ReturnType<typeof setTimeout> | null = null\n\n\treturn (...args: T) => {\n\t\tif (timeoutId) {\n\t\t\tclearTimeout(timeoutId)\n\t\t}\n\n\t\ttimeoutId = setTimeout(() => {\n\t\t\tfn.apply(null, args)\n\t\t}, wait)\n\t}\n}\n\nexport function dedent(str: string) {\n\treturn str\n\t\t.replace(/^\\n/, '')\n\t\t.replace(/\\s+$/, '')\n\t\t.split('\\n')\n\t\t.filter(Boolean)\n\t\t.map(line => line.replace(/^\\s+/, ''))\n\t\t.join('\\n')\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport function deep(obj: any, path: string, value: unknown) {\n\tconst parts = path.split('.')\n\tlet cur = obj\n\n\tfor (let i = 0; i < parts.length - 1; i++) {\n\t\tconst k = parts[i]\n\t\tcur[k] ??= {}\n\t\tcur = cur[k]\n\t}\n\n\tcur[parts.at(-1)!] = value\n}\n"
|
|
8
|
+
"export function capitalise(str: string) {\n\treturn str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport function pluralise(str: string, count: number) {\n\treturn count === 1 ? str : str.endsWith('s') ? str : `${str}s`\n}\n\nexport function debounce<T extends unknown[]>(fn: (...args: T) => void, wait: number) {\n\tlet timeoutId: ReturnType<typeof setTimeout> | null = null\n\n\treturn (...args: T) => {\n\t\tif (timeoutId) {\n\t\t\tclearTimeout(timeoutId)\n\t\t}\n\n\t\ttimeoutId = setTimeout(() => {\n\t\t\tfn.apply(null, args)\n\t\t}, wait)\n\t}\n}\n\nexport function dedent(str: string) {\n\treturn str\n\t\t.replace(/^\\n/, '')\n\t\t.replace(/\\s+$/, '')\n\t\t.split('\\n')\n\t\t.filter(Boolean)\n\t\t.map(line => line.replace(/^\\s+/, ''))\n\t\t.join('\\n')\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport function deep(obj: any, path: string, value: unknown) {\n\tconst parts = path.split('.')\n\tlet cur = obj\n\n\tfor (let i = 0; i < parts.length - 1; i++) {\n\t\tconst k = parts[i]\n\t\tcur[k] ??= {}\n\t\tcur = cur[k]\n\t}\n\n\tcur[parts.at(-1)!] = value\n}\n",
|
|
9
|
+
"import type { CompileOptions as SatteriCompileOptions } from 'satteri'\n\nimport type { LogLevel, Logger } from './logger.js'\n\nexport type CompileOptions = SatteriCompileOptions\n\nexport type PluginConfig = {\n\tcollections: Collection[]\n\tlogger?: {\n\t\tlevel?: LogLevel\n\t}\n\tcompileOptions?: CompileOptions\n}\n\nexport type BuildContext = {\n\tlogger: InstanceType<typeof Logger>\n\tcompileOptions?: CompileOptions\n\toutDir?: string\n\tnames?: string[]\n}\n\nexport const PRIMITIVE_NAMES = ['string', 'number', 'boolean', 'date', 'array'] as const\n\nexport const MODIFIER_NAMES = ['max', 'min'] as const\n\nexport namespace Schema {\n\texport type Primitive = 'string' | 'number' | 'boolean' | 'date' | 'array'\n\n\texport type ModifierName = (typeof MODIFIER_NAMES)[number]\n\n\texport type Modifier = `${ModifierName}=${string}`\n\n\texport type Key = string\n\n\texport type Value = Primitive | `${Primitive}|${string}` | { [key: Key]: Value }\n}\n\nexport interface Schema {\n\t[key: Schema.Key]: Schema.Value\n}\n\nexport type Collection = {\n\tname: string\n\tdir: string\n\tschema: Schema\n}\n\nexport type Entries = Record<string, unknown>\n\nexport type Raw = {\n\t__mdsrc: {\n\t\tslug: string\n\t\tfilename: string\n\t}\n\tbody: string\n} & Entries\n\nexport type Types = Record<string, string>\n\nexport type IssueCode =\n\t| 'MISSING_REQUIRED'\n\t| 'UNKNOWN_KEY'\n\t| 'INVALID_TYPE'\n\t| 'INVALID_DATE'\n\t| 'INVALID_INPUT'\n\t| 'INVALID_LENGTH'\n\t| 'INVALID_SIZE'\n\t| 'BAD_MODIFIER'\n\nexport type Issue = {\n\treadonly code: IssueCode\n\treadonly message: string\n}\n\nexport type Fail = {\n\treadonly issues: Issue[]\n}\n\nexport type Success<Output> = {\n\treadonly value: Output\n\treadonly issues?: Issue[]\n\treadonly types?: Record<string, string>\n}\n\nexport type Result<Output> = Success<Output> | Fail\n",
|
|
10
|
+
"import {\n\tMODIFIER_NAMES,\n\tPRIMITIVE_NAMES,\n\ttype Entries,\n\ttype Issue,\n\ttype Result,\n\ttype Schema,\n} from './types.js'\nimport { deep, isRecord } from './utils.js'\n\n/**\n * Check one entry against the declared schema and coerce what can be coerced\n * leave missing optional keys alone instead of treating them as errors\n * normalise dates to ISO strings for output\n */\nexport function validate(input: Entries, schema: Schema) {\n\t// keep valid values separate so bad fields never sneak into output\n\tconst validated: Entries = {}\n\t// collect every problem so one pass can report the lot\n\tconst issues: Issue[] = []\n\n\t// bail out early if the frontmatter is not even an object\n\tif (typeof input !== 'object' || input === null) {\n\t\tissues.push({ message: 'Input must be an object', code: 'INVALID_INPUT' })\n\t\treturn { issues } satisfies Result<Entries>\n\t}\n\n\tconst schemaKeys = new Set(Object.keys(schema).map(k => parseKey(k).key))\n\n\t// bail out early on unknown keys\n\tfor (const key in input) {\n\t\tif (!schemaKeys.has(key)) {\n\t\t\tissues.push({ message: `Unknown key: ${key}`, code: 'UNKNOWN_KEY' })\n\t\t}\n\t}\n\n\t// bail\n\tif (issues.length) return { issues } satisfies Result<Entries>\n\n\tfunction walk(key: string, schemaValue: Schema.Value, data: unknown) {\n\t\tconst { optional, key: parsedKey } = parseKey(key)\n\n\t\tif (data === undefined) {\n\t\t\tif (!optional) {\n\t\t\t\tissues.push({\n\t\t\t\t\tmessage: `Missing required key: ${parsedKey}`,\n\t\t\t\t\tcode: 'MISSING_REQUIRED',\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t\t// check primitives\n\t\tif (typeof schemaValue === 'string') {\n\t\t\tconst { types, modifiers } = parseSchemaValue(schemaValue)\n\n\t\t\tfor (const type of types) {\n\t\t\t\tif (type === 'string') {\n\t\t\t\t\tif (typeof data !== 'string') {\n\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be a string`,\n\t\t\t\t\t\t\t\tcode: 'INVALID_TYPE',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tif (modifiers.min) {\n\t\t\t\t\t\tconst min = Number(modifiers.min)\n\n\t\t\t\t\t\tif (Number.isNaN(min)) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} contains a bad modifier (${modifiers.min}) that could not be converted to type (number)`,\n\t\t\t\t\t\t\t\tcode: 'BAD_MODIFIER',\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (data.length < min) {\n\t\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be greater than or equal to minimum length (${min})`,\n\t\t\t\t\t\t\t\t\tcode: 'INVALID_LENGTH',\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (modifiers.max) {\n\t\t\t\t\t\tconst max = Number(modifiers.max)\n\n\t\t\t\t\t\tif (Number.isNaN(max)) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} contains a bad modifier (${modifiers.max}) that could not be converted to type (number)`,\n\t\t\t\t\t\t\t\tcode: 'BAD_MODIFIER',\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (data.length > max) {\n\t\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be less than or equal to maximum length (${max})`,\n\t\t\t\t\t\t\t\t\tcode: 'INVALID_LENGTH',\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, data)\n\t\t\t\t\treturn\n\t\t\t\t} else if (type === 'number') {\n\t\t\t\t\tlet num = data\n\n\t\t\t\t\tif (typeof data === 'string' && !Number.isNaN(Number(data))) {\n\t\t\t\t\t\tnum = Number(data)\n\t\t\t\t\t}\n\n\t\t\t\t\tif (typeof num !== 'number' || Number.isNaN(num)) {\n\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be a number`,\n\t\t\t\t\t\t\t\tcode: 'INVALID_TYPE',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tif (modifiers.min) {\n\t\t\t\t\t\tconst min = Number(modifiers.min)\n\n\t\t\t\t\t\tif (Number.isNaN(min)) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} contains a bad modifier (${modifiers.min}) that could not be converted to type (number)`,\n\t\t\t\t\t\t\t\tcode: 'BAD_MODIFIER',\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (num < min) {\n\t\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be greater than or equal to minimum size (${min})`,\n\t\t\t\t\t\t\t\t\tcode: 'INVALID_SIZE',\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (modifiers.max) {\n\t\t\t\t\t\tconst max = Number(modifiers.max)\n\n\t\t\t\t\t\tif (Number.isNaN(max)) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} contains a bad modifier (${modifiers.max}) that could not be converted to type (number)`,\n\t\t\t\t\t\t\t\tcode: 'BAD_MODIFIER',\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (num > max) {\n\t\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be less than or equal to maximum size (${max})`,\n\t\t\t\t\t\t\t\t\tcode: 'INVALID_SIZE',\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, num)\n\t\t\t\t\treturn\n\t\t\t\t} else if (type === 'boolean') {\n\t\t\t\t\tlet bool = data\n\n\t\t\t\t\tif (typeof data === 'string') {\n\t\t\t\t\t\tif (data.toLowerCase() === 'true') {\n\t\t\t\t\t\t\tbool = true\n\t\t\t\t\t\t} else if (data.toLowerCase() === 'false') {\n\t\t\t\t\t\t\tbool = false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (typeof bool !== 'boolean') {\n\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be a boolean`,\n\t\t\t\t\t\t\t\tcode: 'INVALID_TYPE',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, bool)\n\t\t\t\t\treturn\n\t\t\t\t} else if (type === 'date') {\n\t\t\t\t\tlet date: Date\n\n\t\t\t\t\tif (data instanceof Date) {\n\t\t\t\t\t\tdate = data\n\t\t\t\t\t} else if (typeof data === 'string' || typeof data === 'number') {\n\t\t\t\t\t\tdate = new Date(data)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be a Date, string or number`,\n\t\t\t\t\t\t\t\tcode: 'INVALID_TYPE',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tconst dt = date.getTime()\n\n\t\t\t\t\tif (Number.isNaN(dt)) {\n\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be a valid date`,\n\t\t\t\t\t\t\t\tcode: 'INVALID_DATE',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tif (modifiers.min) {\n\t\t\t\t\t\tconst min = new Date(Number(modifiers.min))\n\n\t\t\t\t\t\tif (Number.isNaN(min.getTime())) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} contains a bad modifier (${modifiers.min}) that could not be converted to instance (Date)`,\n\t\t\t\t\t\t\t\tcode: 'BAD_MODIFIER',\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (dt < min.getTime()) {\n\t\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be greater than or equal to minimum date (${min.toISOString()})`,\n\t\t\t\t\t\t\t\t\tcode: 'INVALID_DATE',\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (modifiers.max) {\n\t\t\t\t\t\tconst max = new Date(Number(modifiers.max))\n\n\t\t\t\t\t\tif (Number.isNaN(max.getTime())) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} contains a bad modifier (${modifiers.max}) that could not be converted to instance (Date)`,\n\t\t\t\t\t\t\t\tcode: 'BAD_MODIFIER',\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (dt > max.getTime()) {\n\t\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be less than or equal to maximum date (${max.toISOString()})`,\n\t\t\t\t\t\t\t\t\tcode: 'INVALID_DATE',\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, date.toISOString())\n\t\t\t\t\treturn\n\t\t\t\t} else if (type === 'array') {\n\t\t\t\t\tif (!Array.isArray(data)) {\n\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be an array`,\n\t\t\t\t\t\t\t\tcode: 'INVALID_TYPE',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tif (modifiers.min) {\n\t\t\t\t\t\tconst min = Number(modifiers.min)\n\n\t\t\t\t\t\tif (Number.isNaN(min)) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} contains a bad modifier (${modifiers.min}) that could not be converted to type (number)`,\n\t\t\t\t\t\t\t\tcode: 'BAD_MODIFIER',\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (data.length < min) {\n\t\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be greater than or equal to minimum array length (${min})`,\n\t\t\t\t\t\t\t\t\tcode: 'INVALID_LENGTH',\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (modifiers.max) {\n\t\t\t\t\t\tconst max = Number(modifiers.max)\n\n\t\t\t\t\t\tif (Number.isNaN(max)) {\n\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} contains a bad modifier (${modifiers.max}) that could not be converted to type (number)`,\n\t\t\t\t\t\t\t\tcode: 'BAD_MODIFIER',\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (data.length > max) {\n\t\t\t\t\t\t\tif (types.length === 1) {\n\t\t\t\t\t\t\t\tissues.push({\n\t\t\t\t\t\t\t\t\tmessage: `Key ${parsedKey} must be less than or equal to maximum array length (${max})`,\n\t\t\t\t\t\t\t\t\tcode: 'INVALID_LENGTH',\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tdeep(validated, parsedKey, data)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// no type matched\n\t\t\tissues.push({\n\t\t\t\tmessage: `Key ${parsedKey} must be one of: ${types.join(', ')}`,\n\t\t\t\tcode: 'INVALID_TYPE',\n\t\t\t})\n\t\t} else {\n\t\t\tif (!isRecord(data)) {\n\t\t\t\tissues.push({\n\t\t\t\t\tmessage: `Key ${parsedKey} must be an object`,\n\t\t\t\t\tcode: 'INVALID_TYPE',\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst obj = data\n\n\t\t\tfor (const subKey in schemaValue) {\n\t\t\t\twalk(`${parsedKey}.${subKey}`, schemaValue[subKey], obj[parseKey(subKey).key])\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const key in schema) {\n\t\twalk(key, schema[key], input[parseKey(key).key])\n\t}\n\n\t// return the clean entry when validation passes, otherwise return the full\n\t// issue list\n\treturn (issues.length ? { issues } : { value: validated }) satisfies Result<Entries>\n}\n\nexport function parseKey(k: string) {\n\tconst optional = k.endsWith('?')\n\n\treturn {\n\t\toptional,\n\t\tkey: optional ? k.slice(0, -1) : k,\n\t}\n}\n\nfunction parseSchemaValue(value: Schema.Value) {\n\tif (isRecord(value)) throw new Error('Cannot parse object schema values')\n\n\tconst parts = value.split('|')\n\tconst types: string[] = []\n\tconst modifiers: Partial<Record<Schema.ModifierName, string>> = {}\n\n\tfor (const p of parts) {\n\t\tif (p.indexOf('=') > -1) {\n\t\t\tconst [m, v] = p.split('=')\n\n\t\t\tif (!isModifierName(m)) throw new Error(`Unrecognised modifier: ${m}`)\n\n\t\t\tmodifiers[m] = v\n\t\t} else {\n\t\t\tif (!isPrimitive(p)) throw new Error(`Unrecognised type: ${p}`)\n\t\t\ttypes.push(p)\n\t\t}\n\t}\n\n\treturn { types, modifiers }\n}\n\nfunction isModifierName(name: string): name is Schema.ModifierName {\n\treturn MODIFIER_NAMES.some(n => n === name)\n}\n\nfunction isPrimitive(name: string): name is Schema.Primitive {\n\treturn PRIMITIVE_NAMES.some(n => n === name)\n}\n"
|
|
9
11
|
],
|
|
10
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAIA;;;ACNO,IAAM,OAAO;AACb,IAAM,WAAW,WAAW;AAC5B,IAAM,gBAAgB,IAAI;;;ACAjC,IAAM,SAAS;AAAA,EACd,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACR;AAAA;AAoBO,MAAM,OAAO;AAAA,SACZ,gBAA0B;AAAA,EAEjC;AAAA,EAEA,WAAW,CAAC,OAAkB;AAAA,IAC7B,KAAK,SAAS;AAAA;AAAA,aAGJ,YAAY,CAAC,OAAiB;AAAA,IACxC,OAAO,gBAAgB;AAAA;AAAA,aAGb,YAAY,GAAG;AAAA,IACzB,OAAO,OAAO;AAAA;AAAA,SAMR,OAAO,CAAC,KAAc;AAAA,IAC5B,OAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,GAAG,EAAE,OAAO,IAAI,CAAC;AAAA;AAAA,SAMnE,KAAK,CAAC,KAAc;AA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U,CAAC,CAAC;AAAA;AAAA,IAEnD,SAAS,CAAC,IAAI;AAAA,MAGb,IAAI,OAAO;AAAA,QAAU,OAAO,KAAK,KAAK,QAAQ,UAAU;AAAA,MAExD,IAAI,GAAG,WAAW,GAAG,WAAW,GAAG;AAAA,QAGlC,MAAM,UAAU,GAAG,MAAM,SAAS,SAAS,CAAC;AAAA,QAC5C,MAAM,QAAQ,aAAa,MAAM,KAChC,UAAQ,SAAS,WAAW,aAAa,IAAI,MAAM,OACpD;AAAA,QAEA,IAAI;AAAA,UAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,aAAa,KAAK,MAAM;AAAA,MAChE;AAAA,MAEA,OAAO;AAAA;AAAA,EAET;AAAA;AAGM,SAAS,YAAY,CAAC,MAAc;AAAA,EAC1C,OAAO,KAAK,YAAY;AAAA;",
|
|
13
|
+
"debugId": "49D42D1A4493323164756E2164756E21",
|
|
12
14
|
"names": []
|
|
13
15
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,13 +14,16 @@ export type BuildContext = {
|
|
|
14
14
|
outDir?: string;
|
|
15
15
|
names?: string[];
|
|
16
16
|
};
|
|
17
|
+
export declare const PRIMITIVE_NAMES: readonly ['string', 'number', 'boolean', 'date', 'array'];
|
|
18
|
+
export declare const MODIFIER_NAMES: readonly ['max', 'min'];
|
|
17
19
|
export declare namespace Schema {
|
|
18
|
-
type Primitive = 'string' | 'number' | 'boolean' | 'date' | '
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
type Primitive = 'string' | 'number' | 'boolean' | 'date' | 'array';
|
|
21
|
+
type ModifierName = (typeof MODIFIER_NAMES)[number];
|
|
22
|
+
type Modifier = `${ModifierName}=${string}`;
|
|
23
|
+
type Key = string;
|
|
24
|
+
type Value = Primitive | `${Primitive}|${string}` | {
|
|
21
25
|
[key: Key]: Value;
|
|
22
26
|
};
|
|
23
|
-
export {};
|
|
24
27
|
}
|
|
25
28
|
export interface Schema {
|
|
26
29
|
[key: Schema.Key]: Schema.Value;
|
|
@@ -39,7 +42,9 @@ export type Raw = {
|
|
|
39
42
|
body: string;
|
|
40
43
|
} & Entries;
|
|
41
44
|
export type Types = Record<string, string>;
|
|
45
|
+
export type IssueCode = 'MISSING_REQUIRED' | 'UNKNOWN_KEY' | 'INVALID_TYPE' | 'INVALID_DATE' | 'INVALID_INPUT' | 'INVALID_LENGTH' | 'INVALID_SIZE' | 'BAD_MODIFIER';
|
|
42
46
|
export type Issue = {
|
|
47
|
+
readonly code: IssueCode;
|
|
43
48
|
readonly message: string;
|
|
44
49
|
};
|
|
45
50
|
export type Fail = {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEnD,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAA;AAElD,MAAM,MAAM,YAAY,GAAG;IAC1B,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,MAAM,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,QAAQ,CAAA;KAChB,CAAA;IACD,cAAc,CAAC,EAAE,cAAc,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,YAAY,CAAC,OAAO,MAAM,CAAC,CAAA;IACnC,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,yBAAiB,MAAM,CAAC,CAAC;IACxB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM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UAAU,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAE7C,MAAM,MAAM,GAAG,GAAG;IACjB,OAAO,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,IAAI,EAAE,MAAM,CAAA;CACZ,GAAG,OAAO,CAAA;AAEX,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE1C,MAAM,MAAM,SAAS,GAClB,kBAAkB,GAClB,aAAa,GACb,cAAc,GACd,cAAc,GACd,eAAe,GACf,gBAAgB,GAChB,cAAc,GACd,cAAc,CAAA;AAEjB,MAAM,MAAM,KAAK,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,IAAI,GAAG;IAClB,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,OAAO,CAAC,MAAM,IAAI;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAU,CAAA;AAExF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Entries, type Issue, type Schema } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Check one entry against the declared schema and coerce what can be coerced
|
|
4
|
+
* leave missing optional keys alone instead of treating them as errors
|
|
5
|
+
* normalise dates to ISO strings for output
|
|
6
|
+
*/
|
|
7
|
+
export declare function validate(input: Entries, schema: Schema): {
|
|
8
|
+
issues: Issue[];
|
|
9
|
+
value?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
issues?: undefined;
|
|
12
|
+
value: Entries;
|
|
13
|
+
};
|
|
14
|
+
export declare function parseKey(k: string): {
|
|
15
|
+
optional: boolean;
|
|
16
|
+
key: string;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,MAAM,EACX,MAAM,YAAY,CAAA;AAGnB;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;;;;;;EA0YtD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM;;;EAOjC"}
|