Skip to content

feat: implement DX Phase 2 define* helpers and enhance ObjectSchema.create()#643

Merged
hotlong merged 2 commits intomainfrom
copilot/continue-road-map-development
Feb 12, 2026
Merged

feat: implement DX Phase 2 define* helpers and enhance ObjectSchema.create()#643
hotlong merged 2 commits intomainfrom
copilot/continue-road-map-development

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 12, 2026

Implements DX Roadmap Phase 2 schema helper functions, bringing define* count from 1 to 6.

ObjectSchema.create() enhancement

No longer a pass-through identity function. Now auto-generates label from snake_case name and validates via .parse():

const Task = ObjectSchema.create({
  name: 'project_task',
  // label auto-generated as 'Project Task'
  fields: {
    subject: { type: 'text', label: 'Subject', required: true },
  },
});
// Task.label === 'Project Task'
// Task.active === true (defaults applied)

New define*() factories

All follow the defineStudioPlugin() pattern — accept z.input<Schema>, return parsed output with defaults applied and validation enforced:

  • defineView()src/ui/view.zod.ts
  • defineApp()src/ui/app.zod.ts
  • defineFlow()src/automation/flow.zod.ts
  • defineAgent()src/ai/agent.zod.ts

All re-exported from root src/index.ts for top-level access:

import { defineView, defineApp, defineFlow, defineAgent } from '@objectstack/spec';

Tests

21 new tests across 5 files. Full suite: 191 files, 5178 tests passing.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 12, 2026

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

Project Deployment Actions Updated (UTC)
objectstack-play Canceled Canceled Feb 12, 2026 0:52am
spec Ready Ready Preview, Comment Feb 12, 2026 0:52am

Request Review

…reate()

- Add defineView(), defineApp(), defineFlow(), defineAgent() factory functions
- Enhance ObjectSchema.create() with auto-label from snake_case and validation
- Export all new helpers from root index.ts
- Add comprehensive tests (21 new tests, 5178 total)
- Update DX_ROADMAP.md Phase 2 checklist

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Continue development according to the road map feat: implement DX Phase 2 define* helpers and enhance ObjectSchema.create() Feb 12, 2026
Copilot AI requested a review from hotlong February 12, 2026 09:38
@hotlong hotlong marked this pull request as ready for review February 12, 2026 09:53
Copilot AI review requested due to automatic review settings February 12, 2026 09:53
@hotlong hotlong merged commit cfe89f8 into main Feb 12, 2026
1 of 3 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements DX Roadmap Phase 2 helper factories across @objectstack/spec, making definition creation consistent (validated + defaults applied) and improving ObjectSchema.create() ergonomics.

Changes:

  • Enhanced ObjectSchema.create() to auto-generate label from name and validate/apply defaults via Zod .parse().
  • Added defineView(), defineApp(), defineFlow(), defineAgent() helper factories plus corresponding tests.
  • Re-exported new DX helpers from the root src/index.ts and updated DX roadmap checklist.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/spec/src/ui/view.zod.ts Adds defineView() factory that parses ViewSchema input.
packages/spec/src/ui/view.test.ts Adds tests for defineView() behavior and validation failures.
packages/spec/src/ui/app.zod.ts Adds defineApp() factory that parses AppSchema input.
packages/spec/src/ui/app.test.ts Adds tests for defineApp() defaults and validation failures.
packages/spec/src/index.ts Re-exports defineView/defineApp/defineFlow/defineAgent from root.
packages/spec/src/data/object.zod.ts Enhances ObjectSchema.create() with auto-label + .parse() validation.
packages/spec/src/data/object.test.ts Adds tests covering ObjectSchema.create() label/defaults/validation.
packages/spec/src/automation/flow.zod.ts Adds defineFlow() factory that parses FlowSchema input.
packages/spec/src/automation/flow.test.ts Adds tests for defineFlow() defaults and validation failures.
packages/spec/src/ai/agent.zod.ts Adds defineAgent() factory that parses AgentSchema input.
packages/spec/src/ai/agent.test.ts Adds tests for defineAgent() defaults, tools, and validation failures.
DX_ROADMAP.md Marks Phase 2 checklist items as completed.

Comment on lines +339 to +340
return name
.split('_')
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

snakeCaseToLabel() can produce leading/trailing or double spaces when name contains leading underscores or consecutive underscores (allowed by the current /^[a-z_][a-z0-9_]*$/ regex). Consider normalizing by splitting on /_+/, filtering empty segments, and trimming the result before joining.

Suggested change
return name
.split('_')
const segments = name
.split(/_+/)
.map(segment => segment.trim())
.filter(segment => segment.length > 0);
if (segments.length === 0) {
return '';
}
return segments

Copilot uses AI. Check for mistakes.
Comment on lines +244 to +246
export function defineApp(config: z.input<typeof AppSchema>): App {
return AppSchema.parse(config);
}
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

defineApp() duplicates the existing App.create() helper above. To avoid two factory entry points drifting over time, consider exporting defineApp as an alias of App.create (or removing one of them) so there’s a single source of truth for app parsing/defaults.

Suggested change
export function defineApp(config: z.input<typeof AppSchema>): App {
return AppSchema.parse(config);
}
export const defineApp = App.create;

Copilot uses AI. Check for mistakes.
Comment on lines +169 to 174
export function defineFlow(config: z.input<typeof FlowSchema>): FlowParsed {
return FlowSchema.parse(config);
}

export type Flow = z.input<typeof FlowSchema>;
export type FlowParsed = z.infer<typeof FlowSchema>;
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The return type FlowParsed is inconsistent with most other schemas, where the primary exported type name is the parsed (z.infer) shape and the input type is suffixed with Input. Consider renaming to export type Flow = z.infer<typeof FlowSchema> and export type FlowInput = z.input<typeof FlowSchema>, then have defineFlow() return Flow, to keep the public API consistent.

Suggested change
export function defineFlow(config: z.input<typeof FlowSchema>): FlowParsed {
return FlowSchema.parse(config);
}
export type Flow = z.input<typeof FlowSchema>;
export type FlowParsed = z.infer<typeof FlowSchema>;
export function defineFlow(config: FlowInput): Flow {
return FlowSchema.parse(config);
}
export type Flow = z.infer<typeof FlowSchema>;
export type FlowInput = z.input<typeof FlowSchema>;
export type FlowParsed = Flow;

Copilot uses AI. Check for mistakes.
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