Skip to content

feat: add docs.update to cli and fix schema resolution#997

Open
jeremydw wants to merge 1 commit intomainfrom
feat/docs-update
Open

feat: add docs.update to cli and fix schema resolution#997
jeremydw wants to merge 1 commit intomainfrom
feat/docs-update

Conversation

@jeremydw
Copy link
Copy Markdown
Member

@jeremydw jeremydw commented Mar 27, 2026

This PR adds a docs.update to the CLI and fixes the schema resolution bug I introduced with schema.glob

  • Add docs.update <docId> <fieldPath> [value] CLI command for surgically updating a single field in a draft doc by its deep key path
  • Support inline JSON values, --file, and stdin for providing the value
  • Validate against collection schema by default (--no-validate to skip)
  • Add resolveFieldAtPath() to reject unknown field paths during validation (e.g. foo.bar on a schema without a foo field)
  • Fix import.meta.glob is not a function error in CLI context by loading schemas via viteSsrLoadModule and passing them through a new collectionSchema option on SaveDraftOptions/UpdateDraftOptions
  • Add optional collectionSchema to SaveDraftOptions and UpdateDraftOptions to bypass Vite-dependent getCollection() call

fixes #913

- Add `docs.update <docId> <fieldPath> [value]` CLI command for
  surgically updating a single field in a draft doc by its deep key path
- Support inline JSON values, --file, and stdin for providing the value
- Validate against collection schema by default (--no-validate to skip)
- Add `resolveFieldAtPath()` to reject unknown field paths during
  validation (e.g. `foo.bar` on a schema without a `foo` field)
- Fix `import.meta.glob is not a function` error in CLI context by
  loading schemas via `viteSsrLoadModule` and passing them through a new
  `collectionSchema` option on SaveDraftOptions/UpdateDraftOptions
- Add optional `collectionSchema` to SaveDraftOptions and
  UpdateDraftOptions to bypass Vite-dependent `getCollection()` call
@jeremydw jeremydw requested a review from stevenle March 27, 2026 05:40
@stevenle
Copy link
Copy Markdown
Member

i think we should add some consistency between docs.update, docs.set, and docs.get. if we choose to add --file flag to docs.update, we should update the latter two to do the same. and if docs.update accepts the value as a command line arg, the docs.set should probably do the same.

can you (or ai) take a stab at what all 3 interfaces should look like?

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.

saveDraftData with validate: true throws 'glob is not a function' error in Node.js scripts

2 participants