@adminforth/dashboard 1.4.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/custom/api/dashboardApi.ts +137 -5
  2. package/custom/model/dashboard.types.ts +32 -22
  3. package/custom/runtime/DashboardRuntime.vue +2 -3
  4. package/custom/skills/adminforth-dashboard/SKILL.md +165 -179
  5. package/custom/widgets/KpiCardWidget.vue +172 -9
  6. package/custom/widgets/chart/ChartWidget.vue +5 -5
  7. package/custom/widgets/registry.ts +4 -4
  8. package/dist/custom/api/dashboardApi.d.ts +46 -2
  9. package/dist/custom/api/dashboardApi.js +90 -5
  10. package/dist/custom/api/dashboardApi.ts +137 -5
  11. package/dist/custom/model/dashboard.types.d.ts +30 -14
  12. package/dist/custom/model/dashboard.types.js +2 -2
  13. package/dist/custom/model/dashboard.types.ts +32 -22
  14. package/dist/custom/queries/useDashboardConfig.d.ts +106 -104
  15. package/dist/custom/queries/useWidgetData.d.ts +106 -104
  16. package/dist/custom/runtime/DashboardRuntime.vue +2 -3
  17. package/dist/custom/skills/adminforth-dashboard/SKILL.md +165 -179
  18. package/dist/custom/widgets/KpiCardWidget.vue +172 -9
  19. package/dist/custom/widgets/chart/ChartWidget.vue +5 -5
  20. package/dist/custom/widgets/registry.js +4 -4
  21. package/dist/custom/widgets/registry.ts +4 -4
  22. package/dist/endpoint/dashboard.d.ts +2 -4
  23. package/dist/endpoint/dashboard.js +1 -21
  24. package/dist/endpoint/groups.d.ts +1 -0
  25. package/dist/endpoint/groups.js +61 -48
  26. package/dist/endpoint/widgets.d.ts +1 -0
  27. package/dist/endpoint/widgets.js +167 -64
  28. package/dist/schema/api.d.ts +11710 -2785
  29. package/dist/schema/api.js +118 -26
  30. package/dist/schema/widget.d.ts +425 -1980
  31. package/dist/schema/widget.js +13 -374
  32. package/dist/schema/widgets/charts.d.ts +1689 -0
  33. package/dist/schema/widgets/charts.js +92 -0
  34. package/dist/schema/widgets/common.d.ts +275 -0
  35. package/dist/schema/widgets/common.js +171 -0
  36. package/dist/schema/widgets/gauge-card.d.ts +172 -0
  37. package/dist/schema/widgets/gauge-card.js +28 -0
  38. package/dist/schema/widgets/kpi-card.d.ts +212 -0
  39. package/dist/schema/widgets/kpi-card.js +43 -0
  40. package/dist/schema/widgets/pivot-table.d.ts +196 -0
  41. package/dist/schema/widgets/pivot-table.js +17 -0
  42. package/dist/schema/widgets/table.d.ts +130 -0
  43. package/dist/schema/widgets/table.js +12 -0
  44. package/dist/services/dashboardConfigService.d.ts +4 -0
  45. package/dist/services/dashboardConfigService.js +46 -0
  46. package/dist/services/widgetDataService.js +96 -2
  47. package/endpoint/dashboard.ts +2 -33
  48. package/endpoint/groups.ts +91 -72
  49. package/endpoint/widgets.ts +260 -87
  50. package/package.json +1 -1
  51. package/schema/api.ts +148 -28
  52. package/schema/widget.ts +43 -425
  53. package/schema/widgets/charts.ts +113 -0
  54. package/schema/widgets/common.ts +194 -0
  55. package/schema/widgets/gauge-card.ts +34 -0
  56. package/schema/widgets/kpi-card.ts +49 -0
  57. package/schema/widgets/pivot-table.ts +24 -0
  58. package/schema/widgets/table.ts +18 -0
  59. package/services/dashboardConfigService.ts +73 -0
  60. package/services/widgetDataService.ts +129 -3
@@ -1,8 +1,5 @@
1
1
  import { toJSONSchema, z } from 'zod';
2
- import { EditableDashboardWidgetConfigSchema, StoredWidgetConfigSchema } from './widget.js';
3
- function toAdminForthJsonSchema(schema) {
4
- return toJSONSchema(schema, { target: 'draft-7' });
5
- }
2
+ import { BarChartSchema, FunnelChartSchema, FunnelQueryConfigSchema, GaugeCardViewConfigSchema, HistogramChartSchema, KpiCardViewConfigSchema, LineChartSchema, PieChartSchema, PivotTableViewConfigSchema, QueryConfigSchema, StackedBarChartSchema, TableViewConfigSchema, WidgetEditableBaseSchema, WidgetConfigSchema, } from './widget.js';
6
3
  export const DashboardErrorResponseZodSchema = z.object({
7
4
  error: z.string(),
8
5
  validationErrors: z.array(z.object({
@@ -18,7 +15,7 @@ export const DashboardGroupZodSchema = z.object({
18
15
  export const DashboardConfigZodSchema = z.object({
19
16
  version: z.number(),
20
17
  groups: z.array(DashboardGroupZodSchema),
21
- widgets: z.array(StoredWidgetConfigSchema),
18
+ widgets: z.array(WidgetConfigSchema),
22
19
  }).strict();
23
20
  export const DashboardResponseZodSchema = z.object({
24
21
  id: z.string(),
@@ -33,7 +30,7 @@ export const DashboardApiResponseZodSchema = z.union([
33
30
  ]);
34
31
  export const DashboardWidgetDataResponseZodSchema = z.union([
35
32
  z.object({
36
- widget: StoredWidgetConfigSchema,
33
+ widget: WidgetConfigSchema,
37
34
  data: z.unknown(),
38
35
  }),
39
36
  DashboardErrorResponseZodSchema,
@@ -41,10 +38,6 @@ export const DashboardWidgetDataResponseZodSchema = z.union([
41
38
  export const SlugRequestZodSchema = z.object({
42
39
  slug: z.string(),
43
40
  }).strict();
44
- export const SetDashboardConfigRequestZodSchema = z.object({
45
- slug: z.string(),
46
- config: DashboardConfigZodSchema,
47
- }).strict();
48
41
  export const GroupIdRequestZodSchema = z.object({
49
42
  slug: z.string(),
50
43
  groupId: z.string(),
@@ -79,23 +72,122 @@ export const MoveWidgetRequestZodSchema = z.object({
79
72
  widgetId: z.string(),
80
73
  direction: z.enum(['up', 'down']),
81
74
  }).strict();
75
+ const ConfigurableTableWidgetConfigSchema = WidgetEditableBaseSchema.extend({
76
+ target: z.literal('table'),
77
+ table: TableViewConfigSchema.optional(),
78
+ query: QueryConfigSchema,
79
+ });
80
+ const ConfigurableKpiCardWidgetConfigSchema = WidgetEditableBaseSchema.extend({
81
+ target: z.literal('kpi_card'),
82
+ card: KpiCardViewConfigSchema,
83
+ query: QueryConfigSchema,
84
+ });
85
+ const ConfigurableGaugeCardWidgetConfigSchema = WidgetEditableBaseSchema.extend({
86
+ target: z.literal('gauge_card'),
87
+ card: GaugeCardViewConfigSchema,
88
+ query: QueryConfigSchema,
89
+ });
90
+ const ConfigurableLineChartWidgetConfigSchema = WidgetEditableBaseSchema.extend({
91
+ target: z.literal('chart'),
92
+ chart: LineChartSchema,
93
+ query: QueryConfigSchema,
94
+ });
95
+ const ConfigurableBarChartWidgetConfigSchema = WidgetEditableBaseSchema.extend({
96
+ target: z.literal('chart'),
97
+ chart: BarChartSchema,
98
+ query: QueryConfigSchema,
99
+ });
100
+ const ConfigurableStackedBarChartWidgetConfigSchema = WidgetEditableBaseSchema.extend({
101
+ target: z.literal('chart'),
102
+ chart: StackedBarChartSchema,
103
+ query: QueryConfigSchema,
104
+ });
105
+ const ConfigurablePieChartWidgetConfigSchema = WidgetEditableBaseSchema.extend({
106
+ target: z.literal('chart'),
107
+ chart: PieChartSchema,
108
+ query: QueryConfigSchema,
109
+ });
110
+ const ConfigurableHistogramChartWidgetConfigSchema = WidgetEditableBaseSchema.extend({
111
+ target: z.literal('chart'),
112
+ chart: HistogramChartSchema,
113
+ query: QueryConfigSchema,
114
+ });
115
+ const ConfigurableFunnelChartWidgetConfigSchema = WidgetEditableBaseSchema.extend({
116
+ target: z.literal('chart'),
117
+ chart: FunnelChartSchema,
118
+ query: FunnelQueryConfigSchema,
119
+ });
120
+ const ConfigurablePivotTableWidgetConfigSchema = WidgetEditableBaseSchema.extend({
121
+ target: z.literal('pivot_table'),
122
+ pivot: PivotTableViewConfigSchema,
123
+ query: QueryConfigSchema,
124
+ });
125
+ const ConfigurableChartWidgetConfigSchema = z.union([
126
+ ConfigurableLineChartWidgetConfigSchema,
127
+ ConfigurableBarChartWidgetConfigSchema,
128
+ ConfigurableStackedBarChartWidgetConfigSchema,
129
+ ConfigurablePieChartWidgetConfigSchema,
130
+ ConfigurableHistogramChartWidgetConfigSchema,
131
+ ConfigurableFunnelChartWidgetConfigSchema,
132
+ ]);
133
+ export const ConfigurableWidgetConfigSchema = z.union([
134
+ ConfigurableTableWidgetConfigSchema,
135
+ ConfigurableKpiCardWidgetConfigSchema,
136
+ ConfigurableGaugeCardWidgetConfigSchema,
137
+ ConfigurableChartWidgetConfigSchema,
138
+ ConfigurablePivotTableWidgetConfigSchema,
139
+ ]);
82
140
  export const SetWidgetConfigRequestZodSchema = z.object({
83
141
  slug: z.string(),
84
142
  widgetId: z.string(),
85
- config: EditableDashboardWidgetConfigSchema,
143
+ config: ConfigurableWidgetConfigSchema,
86
144
  }).strict();
87
- export const DashboardErrorResponseSchema = toAdminForthJsonSchema(DashboardErrorResponseZodSchema);
88
- export const DashboardGroupSchema = toAdminForthJsonSchema(DashboardGroupZodSchema);
89
- export const DashboardConfigSchema = toAdminForthJsonSchema(DashboardConfigZodSchema);
90
- export const DashboardResponseSchema = toAdminForthJsonSchema(DashboardResponseZodSchema);
91
- export const DashboardApiResponseSchema = toAdminForthJsonSchema(DashboardApiResponseZodSchema);
92
- export const DashboardWidgetDataResponseSchema = toAdminForthJsonSchema(DashboardWidgetDataResponseZodSchema);
93
- export const SlugRequestSchema = toAdminForthJsonSchema(SlugRequestZodSchema);
94
- export const SetDashboardConfigRequestSchema = toAdminForthJsonSchema(SetDashboardConfigRequestZodSchema);
95
- export const GroupIdRequestSchema = toAdminForthJsonSchema(GroupIdRequestZodSchema);
96
- export const MoveGroupRequestSchema = toAdminForthJsonSchema(MoveGroupRequestZodSchema);
97
- export const SetGroupConfigRequestSchema = toAdminForthJsonSchema(SetGroupConfigRequestZodSchema);
98
- export const WidgetIdRequestSchema = toAdminForthJsonSchema(WidgetIdRequestZodSchema);
99
- export const WidgetDataRequestSchema = toAdminForthJsonSchema(WidgetDataRequestZodSchema);
100
- export const MoveWidgetRequestSchema = toAdminForthJsonSchema(MoveWidgetRequestZodSchema);
101
- export const SetWidgetConfigRequestSchema = toAdminForthJsonSchema(SetWidgetConfigRequestZodSchema);
145
+ function configureWidgetRequestSchema(configSchema) {
146
+ return z.object({
147
+ slug: z.string(),
148
+ widgetId: z.string(),
149
+ config: configSchema,
150
+ }).strict();
151
+ }
152
+ export const ConfigureTableWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurableTableWidgetConfigSchema);
153
+ export const ConfigureKpiCardWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurableKpiCardWidgetConfigSchema);
154
+ export const ConfigureGaugeCardWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurableGaugeCardWidgetConfigSchema);
155
+ export const ConfigureLineChartWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurableLineChartWidgetConfigSchema);
156
+ export const ConfigureBarChartWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurableBarChartWidgetConfigSchema);
157
+ export const ConfigureStackedBarChartWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurableStackedBarChartWidgetConfigSchema);
158
+ export const ConfigurePieChartWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurablePieChartWidgetConfigSchema);
159
+ export const ConfigureHistogramChartWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurableHistogramChartWidgetConfigSchema);
160
+ export const ConfigureFunnelChartWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurableFunnelChartWidgetConfigSchema);
161
+ export const ConfigurePivotTableWidgetRequestZodSchema = configureWidgetRequestSchema(ConfigurablePivotTableWidgetConfigSchema);
162
+ export const DashboardMutationResponseZodSchema = z.union([
163
+ z.object({
164
+ ok: z.literal(true),
165
+ slug: z.string(),
166
+ widgetId: z.string().optional(),
167
+ groupId: z.string().optional(),
168
+ target: z.string().optional(),
169
+ revision: z.number().optional(),
170
+ }).strict(),
171
+ DashboardErrorResponseZodSchema,
172
+ ]);
173
+ export const DashboardApiResponseSchema = toJSONSchema(DashboardApiResponseZodSchema, { target: 'draft-07' });
174
+ export const DashboardWidgetDataResponseSchema = toJSONSchema(DashboardWidgetDataResponseZodSchema, { target: 'draft-07' });
175
+ export const SlugRequestSchema = toJSONSchema(SlugRequestZodSchema, { target: 'draft-07' });
176
+ export const GroupIdRequestSchema = toJSONSchema(GroupIdRequestZodSchema, { target: 'draft-07' });
177
+ export const MoveGroupRequestSchema = toJSONSchema(MoveGroupRequestZodSchema, { target: 'draft-07' });
178
+ export const SetGroupConfigRequestSchema = toJSONSchema(SetGroupConfigRequestZodSchema, { target: 'draft-07' });
179
+ export const WidgetIdRequestSchema = toJSONSchema(WidgetIdRequestZodSchema, { target: 'draft-07' });
180
+ export const WidgetDataRequestSchema = toJSONSchema(WidgetDataRequestZodSchema, { target: 'draft-07' });
181
+ export const MoveWidgetRequestSchema = toJSONSchema(MoveWidgetRequestZodSchema, { target: 'draft-07' });
182
+ export const DashboardMutationResponseSchema = toJSONSchema(DashboardMutationResponseZodSchema, { target: 'draft-07' });
183
+ export const SetWidgetConfigRequestSchema = toJSONSchema(SetWidgetConfigRequestZodSchema, { target: 'draft-07' });
184
+ export const ConfigureTableWidgetRequestSchema = toJSONSchema(ConfigureTableWidgetRequestZodSchema, { target: 'draft-07' });
185
+ export const ConfigureKpiCardWidgetRequestSchema = toJSONSchema(ConfigureKpiCardWidgetRequestZodSchema, { target: 'draft-07' });
186
+ export const ConfigureGaugeCardWidgetRequestSchema = toJSONSchema(ConfigureGaugeCardWidgetRequestZodSchema, { target: 'draft-07' });
187
+ export const ConfigureLineChartWidgetRequestSchema = toJSONSchema(ConfigureLineChartWidgetRequestZodSchema, { target: 'draft-07' });
188
+ export const ConfigureBarChartWidgetRequestSchema = toJSONSchema(ConfigureBarChartWidgetRequestZodSchema, { target: 'draft-07' });
189
+ export const ConfigureStackedBarChartWidgetRequestSchema = toJSONSchema(ConfigureStackedBarChartWidgetRequestZodSchema, { target: 'draft-07' });
190
+ export const ConfigurePieChartWidgetRequestSchema = toJSONSchema(ConfigurePieChartWidgetRequestZodSchema, { target: 'draft-07' });
191
+ export const ConfigureHistogramChartWidgetRequestSchema = toJSONSchema(ConfigureHistogramChartWidgetRequestZodSchema, { target: 'draft-07' });
192
+ export const ConfigureFunnelChartWidgetRequestSchema = toJSONSchema(ConfigureFunnelChartWidgetRequestZodSchema, { target: 'draft-07' });
193
+ export const ConfigurePivotTableWidgetRequestSchema = toJSONSchema(ConfigurePivotTableWidgetRequestZodSchema, { target: 'draft-07' });