-
Notifications
You must be signed in to change notification settings - Fork 1
feat: implement DX Phase 2 define* helpers and enhance ObjectSchema.create() #643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -331,11 +331,46 @@ const ObjectSchemaBase = z.object({ | |||||||||||||||||||||||||
| keyPrefix: z.string().max(5).optional().describe('Short prefix for record IDs (e.g., "001" for Account)'), | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Converts a snake_case name to a human-readable Title Case label. | ||||||||||||||||||||||||||
| * @example snakeCaseToLabel('project_task') → 'Project Task' | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| function snakeCaseToLabel(name: string): string { | ||||||||||||||||||||||||||
| return name | ||||||||||||||||||||||||||
| .split('_') | ||||||||||||||||||||||||||
|
Comment on lines
+339
to
+340
|
||||||||||||||||||||||||||
| return name | |
| .split('_') | |
| const segments = name | |
| .split(/_+/) | |
| .map(segment => segment.trim()) | |
| .filter(segment => segment.length > 0); | |
| if (segments.length === 0) { | |
| return ''; | |
| } | |
| return segments |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -224,6 +224,27 @@ export const App = { | |||||||||
| create: (config: z.input<typeof AppSchema>): App => AppSchema.parse(config), | ||||||||||
| } as const; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Type-safe factory for creating application definitions. | ||||||||||
| * | ||||||||||
| * Validates the config at creation time using Zod `.parse()`. | ||||||||||
| * | ||||||||||
| * @example | ||||||||||
| * ```ts | ||||||||||
| * const crmApp = defineApp({ | ||||||||||
| * name: 'crm', | ||||||||||
| * label: 'CRM', | ||||||||||
| * navigation: [ | ||||||||||
| * { id: 'nav_accounts', label: 'Accounts', type: 'object', objectName: 'account' }, | ||||||||||
| * { id: 'nav_contacts', label: 'Contacts', type: 'object', objectName: 'contact' }, | ||||||||||
| * ], | ||||||||||
| * }); | ||||||||||
| * ``` | ||||||||||
| */ | ||||||||||
| export function defineApp(config: z.input<typeof AppSchema>): App { | ||||||||||
| return AppSchema.parse(config); | ||||||||||
| } | ||||||||||
|
Comment on lines
+244
to
+246
|
||||||||||
| export function defineApp(config: z.input<typeof AppSchema>): App { | |
| return AppSchema.parse(config); | |
| } | |
| export const defineApp = App.create; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type
FlowParsedis inconsistent with most other schemas, where the primary exported type name is the parsed (z.infer) shape and the input type is suffixed withInput. Consider renaming toexport type Flow = z.infer<typeof FlowSchema>andexport type FlowInput = z.input<typeof FlowSchema>, then havedefineFlow()returnFlow, to keep the public API consistent.