Skip to content

fix: add map format support to CLI commands and fix docs field syntax#684

Merged
hotlong merged 3 commits into
mainfrom
copilot/evaluate-map-syntax-support
Feb 15, 2026
Merged

fix: add map format support to CLI commands and fix docs field syntax#684
hotlong merged 3 commits into
mainfrom
copilot/evaluate-map-syntax-support

Conversation

Copilot AI commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

CLI commands (lint, doctor, validate, compile, info) used Array.isArray() on raw config input, silently skipping map-formatted metadata collections. Documentation examples incorrectly showed fields as arrays when ObjectSchema defines fields as z.record() (map-only).

CLI: normalize before processing

All commands that consume raw user configs now call normalizeStackInput() before processing:

const { config: rawConfig } = await loadConfig(configPath);
const config = normalizeStackInput(rawConfig as Record<string, unknown>);
  • lint.ts — map-formatted objects/apps/flows/agents now lint correctly
  • doctor.ts — circular dependency, orphan view, unused object checks work with maps
  • validate.ts / compile.tsnormalizeStackInput() before safeParse() so map configs pass validation
  • info.ts — metadata stats report correct counts for map configs
  • format.tscollectMetadataStats() count helper handles both formats defensively

Docs: fields must always be map format

Fixed all "Array Format" tab examples where fields was incorrectly shown as fields: [{ name: 'x', ... }]. Per ObjectSchema, fields is z.record() — only the top-level collection (objects, apps, etc.) varies between array/map:

// ✗ Wrong — fields is never an array
objects: [{ name: 'user', fields: [{ name: 'email', type: 'email' }] }]

// ✓ Correct — fields is always a map, only objects uses array format here
objects: [{ name: 'user', fields: { email: { type: 'email' } } }]

Files: core-concepts.mdx, common-patterns.mdx (CRUD, master-detail, approval, field-level security, summary)

Audit: packages with correct support (no changes)

core, client, rest, runtime, objectql (explicit dual-format handling in registerPlugin), metadata, studio — all already handle map format correctly or don't consume raw stack configs.

Original prompt

拉取请求: #680

评估所有的内核软件包,所有的api 和client是不是都已经支持新的map语法


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel

vercel Bot commented Feb 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Canceled Canceled Feb 15, 2026 2:50am
spec Ready Ready Preview, Comment Feb 15, 2026 2:50am

Request Review

Copilot AI and others added 2 commits February 15, 2026 02:07
- lint.ts: normalize config before linting
- doctor.ts: normalize config before health checks
- validate.ts: normalize config before schema validation
- compile.ts: normalize config before compilation
- info.ts: normalize config before displaying info
- format.ts: make collectMetadataStats handle both formats
- core-concepts.mdx: fix fields to use map format in Array tab
- common-patterns.mdx: fix fields to use map format in all examples

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Simplify count() redundant Array.isArray check
- Improve normalization comments in validate.ts and compile.ts

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Assess support for new map syntax in all kernel packages fix: add map format support to CLI commands and fix docs field syntax Feb 15, 2026
Copilot AI requested a review from hotlong February 15, 2026 02:13
@hotlong
hotlong marked this pull request as ready for review February 15, 2026 02:15
Copilot AI review requested due to automatic review settings February 15, 2026 02:15
@hotlong
hotlong merged commit 98938bf into main Feb 15, 2026
1 of 3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds map format support to CLI commands and fixes documentation examples where fields was incorrectly shown as an array instead of a map. The changes ensure all CLI tools (lint, doctor, validate, compile, info) correctly process both array and map-formatted metadata collections by calling normalizeStackInput() before processing raw configs.

Changes:

  • CLI commands now normalize stack input before validation/processing to support map-formatted metadata
  • Documentation examples corrected to show fields as map format (Record) not array format
  • collectMetadataStats helper made defensive to handle both array and map formats

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/cli/src/utils/format.ts Enhanced count helper and field counting logic to handle both array and map formats defensively
packages/cli/src/commands/validate.ts Added normalizeStackInput() call before schema validation
packages/cli/src/commands/lint.ts Added normalizeStackInput() call before linting
packages/cli/src/commands/info.ts Added normalizeStackInput() call before collecting stats
packages/cli/src/commands/doctor.ts Added normalizeStackInput() call before running diagnostic checks
packages/cli/src/commands/compile.ts Added normalizeStackInput() call before validation and compilation
content/docs/guides/common-patterns.mdx Fixed CRUD, master-detail, approval, field-level security, and summary examples to show fields as map format
content/docs/getting-started/core-concepts.mdx Fixed first defineStack() example to show fields as map format in both Array and Map tabs

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.

3 participants