Skip to content

Add schema manifest output and CLI#5

Merged
PatrickJS merged 1 commit into
mainfrom
codex/schema-manifest-defaults
May 12, 2026
Merged

Add schema manifest output and CLI#5
PatrickJS merged 1 commit into
mainfrom
codex/schema-manifest-defaults

Conversation

@PatrickJS
Copy link
Copy Markdown
Owner

@PatrickJS PatrickJS commented May 12, 2026

Introduce committed JSON schema manifest generation for model-driven admin/CMS UIs. Adds a new generator (src/schema-manifest.js) and exports generateSchemaManifest/renderSchemaManifest from the public API and CLI. New config options schemaOutFile and schemaManifest (customizeField hook) are supported, and schemaOutFile is resolved in loadConfig. The sync flow writes the manifest when configured, and a new CLI subcommand jsondb schema manifest [--out ] is implemented. Type definitions, Vite plugin options, README, SPEC, and example config are updated, and comprehensive tests were added to verify UI inference, nested/array/relation handling, customizeField overrides/omissions, serialization diagnostics, and CLI output.

Summary by CodeRabbit

  • New Features

    • Added schema manifest generation for local-first admin/CMS UIs with schemaOutFile configuration option.
    • Introduced schemaManifest.customizeField hook to customize or suppress per-field metadata output.
    • Added CLI command jsondb schema manifest [--out] for direct manifest generation.
    • Schema manifests now auto-generate during jsondb sync when configured.
  • Documentation

    • Updated README and specification with schema manifest configuration examples and UI customization guidance.

Review Change Stack

Introduce committed JSON schema manifest generation for model-driven admin/CMS UIs. Adds a new generator (src/schema-manifest.js) and exports generateSchemaManifest/renderSchemaManifest from the public API and CLI. New config options schemaOutFile and schemaManifest (customizeField hook) are supported, and schemaOutFile is resolved in loadConfig. The sync flow writes the manifest when configured, and a new CLI subcommand jsondb schema manifest [--out <file>] is implemented. Type definitions, Vite plugin options, README, SPEC, and example config are updated, and comprehensive tests were added to verify UI inference, nested/array/relation handling, customizeField overrides/omissions, serialization diagnostics, and CLI output.
@PatrickJS PatrickJS merged commit 11a2d8d into main May 12, 2026
6 of 7 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2f7cc1a5-da65-4c66-86a0-32a239f7c9f3

📥 Commits

Reviewing files that changed from the base of the PR and between 7dffcc0 and 860d908.

📒 Files selected for processing (11)
  • README.md
  • SPEC.md
  • jsondb.config.example.mjs
  • src/cli.js
  • src/config.js
  • src/index.d.ts
  • src/index.js
  • src/schema-manifest.js
  • src/sync.js
  • src/vite.d.ts
  • test/jsondb.test.js

📝 Walkthrough

Walkthrough

This PR adds schema manifest generation to jsondb, enabling local-first admin/CMS UIs to derive model-driven component metadata from project resources. A new schemaOutFile configuration triggers manifest output during sync; a schemaManifest.customizeField hook permits per-field UI customization. The feature includes CLI support, comprehensive tests, and specification updates.

Changes

Schema Manifest Generation

Layer / File(s) Summary
Configuration & Type Contracts
src/index.d.ts, src/config.js, jsondb.config.example.mjs, src/vite.d.ts
New types JsonDbSchemaManifestFieldContext and JsonDbSchemaManifestOptions extend JsonDbOptions with schemaOutFile (optional output file path) and schemaManifest (customization hook config). DEFAULT_CONFIG gains both properties; loadConfig resolves schemaOutFile to absolute/relative paths.
Core Schema Manifest Implementation
src/schema-manifest.js
generateSchemaManifest(config, options) loads project schema, renders manifest via renderSchemaManifest(resources, config), stringifies to JSON, writes output file(s), and returns manifest/content/file list/diagnostics. renderSchemaManifest segregates resources into documents vs collections, renders per-resource field trees, applies optional config.schemaManifest.customizeField hooks (with exception/null/non-serializable handling), and infers UI components (label, component type, readonly flags, relation options) based on field type/name/structure heuristics.
CLI & Sync Integration
src/cli.js, src/sync.js, src/index.js
CLI adds jsondb schema manifest [--out <file>] subcommand that calls generateSchemaManifest and prints manifest content or logs generated file paths. syncJsonFixtureDb conditionally calls generateSchemaManifest when config.schemaOutFile is set. Both generateSchemaManifest and renderSchemaManifest are re-exported as public API.
Specification, Documentation & Tests
SPEC.md, README.md, test/jsondb.test.js
Specification defines manifest JSON shape, required resource/field metadata, UI component inference rules, customizeField hook contract (JSON-serializability requirement, null omits fields), and excludes seeds/diagnostics/routes from manifest. README adds configuration examples, CLI usage, and "Schema Manifest Output" section. Tests validate manifest generation with UI defaults, customizeField override/omit behavior, non-serializable rejection with diagnostics, and CLI relative path handling.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant generateSchemaManifest
  participant renderSchemaManifest
  participant customizeField
  participant FileSystem
  User->>CLI: jsondb schema manifest --out ./schema.json
  CLI->>generateSchemaManifest: config, {outFile: ./schema.json}
  generateSchemaManifest->>renderSchemaManifest: resources, config
  renderSchemaManifest->>customizeField: field context, defaultManifest
  customizeField-->>renderSchemaManifest: customized or null manifest
  renderSchemaManifest-->>generateSchemaManifest: final manifest object
  generateSchemaManifest->>FileSystem: write schema.json
  generateSchemaManifest-->>CLI: {manifest, content, outFiles}
  CLI-->>User: Generated ./schema.json
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • PatrickJS/jsondb#4: Implements the same schema manifest feature (generateSchemaManifest/renderSchemaManifest, CLI integration, configuration, type definitions, tests) and changes the same files.

Poem

🐰 A manifest of fields, so bright and fair,
With UI hints and metadata to share—
Collections dance with documents aligned,
Customization hooks, a treasure to find!
The admin UI blooms where manifests bind. 🌸

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/schema-manifest-defaults

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PatrickJS PatrickJS deleted the codex/schema-manifest-defaults branch May 12, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant