Skip to content

Commit 2465feb

Browse files
Copilothotlong
andcommitted
Add ReportInput type for configuration contexts with optional defaults
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 489c763 commit 2465feb

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

examples/crm/src/ui/reports.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Report } from '@objectstack/spec/ui';
1+
import type { ReportInput } from '@objectstack/spec/ui';
22

33
// Sales Report - Opportunities by Stage
4-
export const OpportunitiesByStageReport: Report = {
4+
export const OpportunitiesByStageReport: ReportInput = {
55
name: 'opportunities_by_stage',
66
label: 'Opportunities by Stage',
77
description: 'Summary of opportunities grouped by stage',
@@ -56,7 +56,7 @@ export const OpportunitiesByStageReport: Report = {
5656
};
5757

5858
// Sales Report - Won Opportunities by Owner
59-
export const WonOpportunitiesByOwnerReport: Report = {
59+
export const WonOpportunitiesByOwnerReport: ReportInput = {
6060
name: 'won_opportunities_by_owner',
6161
label: 'Won Opportunities by Owner',
6262
description: 'Closed won opportunities grouped by owner',
@@ -105,7 +105,7 @@ export const WonOpportunitiesByOwnerReport: Report = {
105105
};
106106

107107
// Account Report - Accounts by Industry and Type (Matrix)
108-
export const AccountsByIndustryTypeReport: Report = {
108+
export const AccountsByIndustryTypeReport: ReportInput = {
109109
name: 'accounts_by_industry_type',
110110
label: 'Accounts by Industry and Type',
111111
description: 'Matrix report showing accounts by industry and type',
@@ -144,7 +144,7 @@ export const AccountsByIndustryTypeReport: Report = {
144144
};
145145

146146
// Support Report - Cases by Status and Priority
147-
export const CasesByStatusPriorityReport: Report = {
147+
export const CasesByStatusPriorityReport: ReportInput = {
148148
name: 'cases_by_status_priority',
149149
label: 'Cases by Status and Priority',
150150
description: 'Summary of cases by status and priority',
@@ -197,7 +197,7 @@ export const CasesByStatusPriorityReport: Report = {
197197
};
198198

199199
// Support Report - SLA Performance
200-
export const SlaPerformanceReport: Report = {
200+
export const SlaPerformanceReport: ReportInput = {
201201
name: 'sla_performance',
202202
label: 'SLA Performance Report',
203203
description: 'Analysis of SLA compliance',
@@ -243,7 +243,7 @@ export const SlaPerformanceReport: Report = {
243243
};
244244

245245
// Lead Report - Leads by Source and Status
246-
export const LeadsBySourceReport: Report = {
246+
export const LeadsBySourceReport: ReportInput = {
247247
name: 'leads_by_source',
248248
label: 'Leads by Source and Status',
249249
description: 'Lead pipeline analysis',
@@ -291,7 +291,7 @@ export const LeadsBySourceReport: Report = {
291291
};
292292

293293
// Contact Report - Contacts by Account
294-
export const ContactsByAccountReport: Report = {
294+
export const ContactsByAccountReport: ReportInput = {
295295
name: 'contacts_by_account',
296296
label: 'Contacts by Account',
297297
description: 'List of contacts grouped by account',
@@ -331,7 +331,7 @@ export const ContactsByAccountReport: Report = {
331331
};
332332

333333
// Activity Report - Tasks by Owner
334-
export const TasksByOwnerReport: Report = {
334+
export const TasksByOwnerReport: ReportInput = {
335335
name: 'tasks_by_owner',
336336
label: 'Tasks by Owner',
337337
description: 'Task summary by owner',

packages/spec/src/ui/report.zod.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,29 @@ export const ReportSchema = z.object({
7070
chart: ReportChartSchema.optional().describe('Embedded chart configuration'),
7171
});
7272

73+
/**
74+
* Report Types
75+
*
76+
* Note: For configuration/definition contexts, use the Input types (e.g., ReportInput)
77+
* which allow optional fields with defaults to be omitted.
78+
*/
7379
export type Report = z.infer<typeof ReportSchema>;
7480
export type ReportColumn = z.infer<typeof ReportColumnSchema>;
7581
export type ReportGrouping = z.infer<typeof ReportGroupingSchema>;
7682
export type ReportChart = z.infer<typeof ReportChartSchema>;
7783

84+
/**
85+
* Input Types for Report Configuration
86+
* Use these when defining reports in configuration files.
87+
*/
88+
export type ReportInput = z.input<typeof ReportSchema>;
89+
export type ReportColumnInput = z.input<typeof ReportColumnSchema>;
90+
export type ReportGroupingInput = z.input<typeof ReportGroupingSchema>;
91+
export type ReportChartInput = z.input<typeof ReportChartSchema>;
92+
7893
/**
7994
* Report Factory Helper
8095
*/
8196
export const Report = {
82-
create: (config: z.input<typeof ReportSchema>): Report => ReportSchema.parse(config),
97+
create: (config: ReportInput): Report => ReportSchema.parse(config),
8398
} as const;

0 commit comments

Comments
 (0)