@gridframe/core 1.0.0 → 1.0.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,uBAAuB;;;;;;;;;EASlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,2BAA2B;;;iBAGtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,wBAAwB;;;iBAGnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,yBAAyB;;;;;iBAKpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;iBAOpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;iBAEvC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAA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,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;iBAEpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,6BAA6B;;;iBAGxC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AAEF,eAAO,MAAM,gCAAgC;;iBAE3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AAEF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAG9C,CAAC;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC;AAEF,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,MAAM,MAAM,+BAA+B,GACvC;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GACf;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEvC,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,mBAAmB,EAAE,EACrC,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,+BAA+B,CA2CjC"}
package/dist/index.js ADDED
@@ -0,0 +1,322 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DASHBOARD_GRID_COLUMNS = exports.DashboardCardMutationResponseSchema = exports.RemoveDashboardCardRequestSchema = exports.AddDashboardCardRequestSchema = exports.CardLibraryResponseSchema = exports.CardLibraryItemSchema = exports.UpdateDashboardCardRequestSchema = exports.UpdateDashboardLayoutRequestSchema = exports.DashboardApiErrorSchema = exports.DashboardApiErrorCodeSchema = exports.DashboardBootstrapResponseSchema = exports.DashboardBootstrapRequestSchema = exports.DashboardDocumentSchema = exports.DashboardSummarySchema = exports.PanelCardDataWithSourceResponseSchema = exports.PanelCardDataResponseSchema = exports.SourceDataTableSchema = exports.PanelCardPayloadSchema = exports.TableCardDataSchema = exports.TableRowSchema = exports.TableColumnSchema = exports.RadialChartCardDataSchema = exports.RadarChartCardDataSchema = exports.PieChartCardDataSchema = exports.LineChartCardDataSchema = exports.AreaChartCardDataSchema = exports.BarChartCardDataSchema = exports.ChartTooltipOptionsSchema = exports.ChartDatumSchema = exports.ChartSeriesSchema = exports.MetricCardDataSchema = exports.MetricTrendSchema = exports.ApiPanelDashboardConfigSchema = exports.PanelDashboardConfigSchema = exports.ApiDashboardCardConfigSchema = exports.DashboardCardConfigSchema = exports.DashboardCardLayoutSchema = exports.CardDeeplinkConfigSchema = exports.DashboardFooterConfigSchema = exports.VisualizationTypeSchema = void 0;
4
+ exports.validateDashboardLayout = validateDashboardLayout;
5
+ const zod_1 = require("zod");
6
+ const nullableScalarSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.null()]);
7
+ exports.VisualizationTypeSchema = zod_1.z.enum([
8
+ "metric",
9
+ "area",
10
+ "bar",
11
+ "line",
12
+ "pie",
13
+ "radar",
14
+ "radial",
15
+ "table",
16
+ ]);
17
+ exports.DashboardFooterConfigSchema = zod_1.z.object({
18
+ text: zod_1.z.string(),
19
+ href: zod_1.z.string().optional(),
20
+ });
21
+ exports.CardDeeplinkConfigSchema = zod_1.z.object({
22
+ href: zod_1.z.string(),
23
+ label: zod_1.z.string().optional(),
24
+ });
25
+ exports.DashboardCardLayoutSchema = zod_1.z.object({
26
+ x: zod_1.z.number().int().nonnegative(),
27
+ y: zod_1.z.number().int().nonnegative(),
28
+ width: zod_1.z.number().int().positive(),
29
+ height: zod_1.z.number().int().positive(),
30
+ });
31
+ exports.DashboardCardConfigSchema = zod_1.z.object({
32
+ id: zod_1.z.string(),
33
+ name: zod_1.z.string(),
34
+ visualization: exports.VisualizationTypeSchema,
35
+ query: zod_1.z.string(),
36
+ deeplink: exports.CardDeeplinkConfigSchema.optional(),
37
+ layout: exports.DashboardCardLayoutSchema.optional(),
38
+ });
39
+ exports.ApiDashboardCardConfigSchema = exports.DashboardCardConfigSchema.extend({
40
+ layout: exports.DashboardCardLayoutSchema,
41
+ });
42
+ exports.PanelDashboardConfigSchema = zod_1.z.object({
43
+ title: zod_1.z.string(),
44
+ description: zod_1.z.string().optional(),
45
+ footer: exports.DashboardFooterConfigSchema.optional(),
46
+ cards: zod_1.z.array(exports.DashboardCardConfigSchema),
47
+ });
48
+ exports.ApiPanelDashboardConfigSchema = exports.PanelDashboardConfigSchema.extend({
49
+ cards: zod_1.z.array(exports.ApiDashboardCardConfigSchema),
50
+ });
51
+ exports.MetricTrendSchema = zod_1.z.object({
52
+ direction: zod_1.z.enum(["up", "down", "neutral"]),
53
+ value: zod_1.z.string(),
54
+ label: zod_1.z.string().optional(),
55
+ });
56
+ exports.MetricCardDataSchema = zod_1.z.object({
57
+ visualization: zod_1.z.literal("metric"),
58
+ value: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]),
59
+ label: zod_1.z.string().optional(),
60
+ helperText: zod_1.z.string().optional(),
61
+ trend: exports.MetricTrendSchema.optional(),
62
+ });
63
+ exports.ChartSeriesSchema = zod_1.z.object({
64
+ key: zod_1.z.string(),
65
+ label: zod_1.z.string(),
66
+ color: zod_1.z.string(),
67
+ icon: zod_1.z.string().optional(),
68
+ });
69
+ exports.ChartDatumSchema = zod_1.z.record(zod_1.z.string(), nullableScalarSchema);
70
+ exports.ChartTooltipOptionsSchema = zod_1.z.object({
71
+ indicator: zod_1.z.enum(["dot", "line", "dashed", "none"]).optional(),
72
+ hideLabel: zod_1.z.boolean().optional(),
73
+ label: zod_1.z.string().optional(),
74
+ labelFormatter: zod_1.z.literal("date").optional(),
75
+ valueFormatter: zod_1.z.enum(["compact", "currency", "percent"]).optional(),
76
+ advanced: zod_1.z.boolean().optional(),
77
+ });
78
+ exports.BarChartCardDataSchema = zod_1.z.object({
79
+ visualization: zod_1.z.literal("bar"),
80
+ indexKey: zod_1.z.string(),
81
+ data: zod_1.z.array(exports.ChartDatumSchema),
82
+ series: zod_1.z.array(exports.ChartSeriesSchema),
83
+ variant: zod_1.z.string().optional(),
84
+ layout: zod_1.z.enum(["vertical", "horizontal"]).optional(),
85
+ stacked: zod_1.z.boolean().optional(),
86
+ showLabels: zod_1.z.boolean().optional(),
87
+ customLabels: zod_1.z.boolean().optional(),
88
+ mixed: zod_1.z.boolean().optional(),
89
+ activeIndex: zod_1.z.number().int().optional(),
90
+ tooltip: exports.ChartTooltipOptionsSchema.optional(),
91
+ });
92
+ exports.AreaChartCardDataSchema = zod_1.z.object({
93
+ visualization: zod_1.z.literal("area"),
94
+ indexKey: zod_1.z.string(),
95
+ data: zod_1.z.array(exports.ChartDatumSchema),
96
+ series: zod_1.z.array(exports.ChartSeriesSchema),
97
+ variant: zod_1.z.string().optional(),
98
+ curveType: zod_1.z.enum(["natural", "linear", "step"]).optional(),
99
+ stacked: zod_1.z.boolean().optional(),
100
+ stackOffset: zod_1.z.literal("expand").optional(),
101
+ showLegend: zod_1.z.boolean().optional(),
102
+ showGradient: zod_1.z.boolean().optional(),
103
+ showAxes: zod_1.z.boolean().optional(),
104
+ interactive: zod_1.z.boolean().optional(),
105
+ tooltip: exports.ChartTooltipOptionsSchema.optional(),
106
+ });
107
+ exports.LineChartCardDataSchema = zod_1.z.object({
108
+ visualization: zod_1.z.literal("line"),
109
+ indexKey: zod_1.z.string(),
110
+ data: zod_1.z.array(exports.ChartDatumSchema),
111
+ series: zod_1.z.array(exports.ChartSeriesSchema),
112
+ variant: zod_1.z.string().optional(),
113
+ curveType: zod_1.z.enum(["monotone", "linear", "step"]).optional(),
114
+ showDots: zod_1.z.boolean().optional(),
115
+ customDots: zod_1.z.boolean().optional(),
116
+ colorDots: zod_1.z.boolean().optional(),
117
+ showLabels: zod_1.z.boolean().optional(),
118
+ customLabels: zod_1.z.boolean().optional(),
119
+ interactive: zod_1.z.boolean().optional(),
120
+ tooltip: exports.ChartTooltipOptionsSchema.optional(),
121
+ });
122
+ exports.PieChartCardDataSchema = zod_1.z.object({
123
+ visualization: zod_1.z.literal("pie"),
124
+ nameKey: zod_1.z.string(),
125
+ valueKey: zod_1.z.string(),
126
+ data: zod_1.z.array(exports.ChartDatumSchema),
127
+ series: zod_1.z.array(exports.ChartSeriesSchema),
128
+ variant: zod_1.z.string().optional(),
129
+ separator: zod_1.z.boolean().optional(),
130
+ showLabels: zod_1.z.boolean().optional(),
131
+ customLabels: zod_1.z.boolean().optional(),
132
+ labelList: zod_1.z.boolean().optional(),
133
+ showLegend: zod_1.z.boolean().optional(),
134
+ donut: zod_1.z.boolean().optional(),
135
+ activeIndex: zod_1.z.number().int().optional(),
136
+ centerText: zod_1.z.string().optional(),
137
+ stacked: zod_1.z.boolean().optional(),
138
+ interactive: zod_1.z.boolean().optional(),
139
+ tooltip: exports.ChartTooltipOptionsSchema.optional(),
140
+ });
141
+ exports.RadarChartCardDataSchema = zod_1.z.object({
142
+ visualization: zod_1.z.literal("radar"),
143
+ indexKey: zod_1.z.string(),
144
+ data: zod_1.z.array(exports.ChartDatumSchema),
145
+ series: zod_1.z.array(exports.ChartSeriesSchema),
146
+ variant: zod_1.z.string().optional(),
147
+ showDots: zod_1.z.boolean().optional(),
148
+ linesOnly: zod_1.z.boolean().optional(),
149
+ customLabels: zod_1.z.boolean().optional(),
150
+ gridType: zod_1.z.enum(["polygon", "circle"]).optional(),
151
+ gridFill: zod_1.z.boolean().optional(),
152
+ gridLines: zod_1.z.boolean().optional(),
153
+ radialLines: zod_1.z.boolean().optional(),
154
+ showLegend: zod_1.z.boolean().optional(),
155
+ tooltip: exports.ChartTooltipOptionsSchema.optional(),
156
+ });
157
+ exports.RadialChartCardDataSchema = zod_1.z.object({
158
+ visualization: zod_1.z.literal("radial"),
159
+ nameKey: zod_1.z.string(),
160
+ valueKey: zod_1.z.string(),
161
+ data: zod_1.z.array(exports.ChartDatumSchema),
162
+ series: zod_1.z.array(exports.ChartSeriesSchema),
163
+ variant: zod_1.z.string().optional(),
164
+ showLabel: zod_1.z.boolean().optional(),
165
+ showGrid: zod_1.z.boolean().optional(),
166
+ centerText: zod_1.z.string().optional(),
167
+ shape: zod_1.z.enum(["round", "square"]).optional(),
168
+ stacked: zod_1.z.boolean().optional(),
169
+ tooltip: exports.ChartTooltipOptionsSchema.optional(),
170
+ });
171
+ exports.TableColumnSchema = zod_1.z.object({
172
+ key: zod_1.z.string(),
173
+ label: zod_1.z.string(),
174
+ align: zod_1.z.enum(["left", "right"]).optional(),
175
+ });
176
+ exports.TableRowSchema = zod_1.z.record(zod_1.z.string(), nullableScalarSchema);
177
+ exports.TableCardDataSchema = zod_1.z.object({
178
+ visualization: zod_1.z.literal("table"),
179
+ columns: zod_1.z.array(exports.TableColumnSchema),
180
+ rows: zod_1.z.array(exports.TableRowSchema),
181
+ });
182
+ exports.PanelCardPayloadSchema = zod_1.z.discriminatedUnion("visualization", [
183
+ exports.MetricCardDataSchema,
184
+ exports.AreaChartCardDataSchema,
185
+ exports.BarChartCardDataSchema,
186
+ exports.LineChartCardDataSchema,
187
+ exports.PieChartCardDataSchema,
188
+ exports.RadarChartCardDataSchema,
189
+ exports.RadialChartCardDataSchema,
190
+ exports.TableCardDataSchema,
191
+ ]);
192
+ exports.SourceDataTableSchema = zod_1.z.object({
193
+ columns: zod_1.z.array(exports.TableColumnSchema),
194
+ rows: zod_1.z.array(exports.TableRowSchema),
195
+ });
196
+ const panelCardDataSuccessSchema = zod_1.z.object({
197
+ status: zod_1.z.literal("success"),
198
+ data: exports.PanelCardPayloadSchema,
199
+ sourceData: exports.SourceDataTableSchema.optional(),
200
+ });
201
+ const panelCardDataEmptySchema = zod_1.z.object({
202
+ status: zod_1.z.literal("empty"),
203
+ message: zod_1.z.string().optional(),
204
+ });
205
+ const panelCardDataErrorSchema = zod_1.z.object({
206
+ status: zod_1.z.literal("error"),
207
+ message: zod_1.z.string(),
208
+ });
209
+ exports.PanelCardDataResponseSchema = zod_1.z.discriminatedUnion("status", [
210
+ panelCardDataSuccessSchema,
211
+ panelCardDataEmptySchema,
212
+ panelCardDataErrorSchema,
213
+ ]);
214
+ exports.PanelCardDataWithSourceResponseSchema = zod_1.z.discriminatedUnion("status", [
215
+ panelCardDataSuccessSchema.extend({ sourceData: exports.SourceDataTableSchema }),
216
+ panelCardDataEmptySchema,
217
+ panelCardDataErrorSchema,
218
+ ]);
219
+ exports.DashboardSummarySchema = zod_1.z.object({
220
+ id: zod_1.z.string(),
221
+ title: zod_1.z.string(),
222
+ isDefault: zod_1.z.boolean(),
223
+ });
224
+ exports.DashboardDocumentSchema = zod_1.z.object({
225
+ id: zod_1.z.string(),
226
+ revision: zod_1.z.string(),
227
+ config: exports.ApiPanelDashboardConfigSchema,
228
+ });
229
+ exports.DashboardBootstrapRequestSchema = zod_1.z.object({
230
+ dashboardId: zod_1.z.string().optional(),
231
+ });
232
+ exports.DashboardBootstrapResponseSchema = zod_1.z.object({
233
+ dashboards: zod_1.z.array(exports.DashboardSummarySchema),
234
+ dashboard: exports.DashboardDocumentSchema,
235
+ });
236
+ exports.DashboardApiErrorCodeSchema = zod_1.z.enum([
237
+ "INVALID_REQUEST",
238
+ "DASHBOARD_NOT_FOUND",
239
+ "DASHBOARD_LOAD_FAILED",
240
+ "DASHBOARD_CARD_NOT_FOUND",
241
+ "CARD_QUERY_FAILED",
242
+ "REVISION_CONFLICT",
243
+ "CARD_ALREADY_ADDED",
244
+ ]);
245
+ exports.DashboardApiErrorSchema = zod_1.z.object({
246
+ error: zod_1.z.object({
247
+ code: exports.DashboardApiErrorCodeSchema,
248
+ message: zod_1.z.string(),
249
+ }),
250
+ });
251
+ exports.UpdateDashboardLayoutRequestSchema = zod_1.z.object({
252
+ revision: zod_1.z.string(),
253
+ cards: zod_1.z.array(zod_1.z.object({
254
+ id: zod_1.z.string(),
255
+ ...exports.DashboardCardLayoutSchema.shape,
256
+ })),
257
+ });
258
+ exports.UpdateDashboardCardRequestSchema = zod_1.z.object({
259
+ revision: zod_1.z.string(),
260
+ name: zod_1.z.string(),
261
+ });
262
+ exports.CardLibraryItemSchema = zod_1.z.object({
263
+ key: zod_1.z.string(),
264
+ name: zod_1.z.string(),
265
+ description: zod_1.z.string().optional(),
266
+ visualization: exports.VisualizationTypeSchema,
267
+ defaultLayout: zod_1.z.object({
268
+ width: zod_1.z.number().int().positive(),
269
+ height: zod_1.z.number().int().positive(),
270
+ }),
271
+ addedCardId: zod_1.z.string().optional(),
272
+ });
273
+ exports.CardLibraryResponseSchema = zod_1.z.object({
274
+ items: zod_1.z.array(exports.CardLibraryItemSchema),
275
+ });
276
+ exports.AddDashboardCardRequestSchema = zod_1.z.object({
277
+ revision: zod_1.z.string(),
278
+ libraryItemKey: zod_1.z.string(),
279
+ });
280
+ exports.RemoveDashboardCardRequestSchema = zod_1.z.object({
281
+ revision: zod_1.z.string(),
282
+ });
283
+ exports.DashboardCardMutationResponseSchema = zod_1.z.object({
284
+ dashboard: exports.DashboardDocumentSchema,
285
+ cardLibrary: exports.CardLibraryResponseSchema,
286
+ });
287
+ exports.DASHBOARD_GRID_COLUMNS = 4;
288
+ function validateDashboardLayout(cards, expectedCardIds) {
289
+ const errors = [];
290
+ const cardIds = cards.map((card) => card.id);
291
+ const uniqueCardIds = new Set(cardIds);
292
+ if (uniqueCardIds.size !== cardIds.length) {
293
+ errors.push("Card IDs must be unique");
294
+ }
295
+ const expectedIds = new Set(expectedCardIds);
296
+ if (cards.length !== expectedCardIds.length ||
297
+ [...uniqueCardIds].some((cardId) => !expectedIds.has(cardId)) ||
298
+ [...expectedIds].some((cardId) => !uniqueCardIds.has(cardId))) {
299
+ errors.push("Layout must contain exactly the Dashboard's Cards");
300
+ }
301
+ for (const card of cards) {
302
+ if (card.x + card.width > exports.DASHBOARD_GRID_COLUMNS) {
303
+ errors.push(`Card ${card.id} extends beyond the ${exports.DASHBOARD_GRID_COLUMNS}-column grid`);
304
+ }
305
+ }
306
+ for (let index = 0; index < cards.length; index += 1) {
307
+ const first = cards[index];
308
+ for (let otherIndex = index + 1; otherIndex < cards.length; otherIndex += 1) {
309
+ const second = cards[otherIndex];
310
+ if (first && second && rectanglesOverlap(first, second)) {
311
+ errors.push(`Cards ${first.id} and ${second.id} overlap`);
312
+ }
313
+ }
314
+ }
315
+ return errors.length ? { valid: false, errors } : { valid: true };
316
+ }
317
+ function rectanglesOverlap(first, second) {
318
+ return (first.x < second.x + second.width &&
319
+ first.x + first.width > second.x &&
320
+ first.y < second.y + second.height &&
321
+ first.y + first.height > second.y);
322
+ }
package/package.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "name": "@gridframe/core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
+ "main": "./dist/index.js",
5
+ "types": "./dist/index.d.ts",
4
6
  "exports": {
5
- ".": "./src/index.ts"
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ }
6
13
  },
7
14
  "files": [
8
- "src",
15
+ "dist",
9
16
  "README.md"
10
17
  ],
11
18
  "publishConfig": {
@@ -22,6 +29,7 @@
22
29
  "zod": "^4.4.3"
23
30
  },
24
31
  "scripts": {
32
+ "build": "rm -rf dist && tsc",
25
33
  "lint": "eslint . --max-warnings 0",
26
34
  "test": "vitest run src",
27
35
  "check-types": "tsc --noEmit"
package/src/index.test.ts DELETED
@@ -1,133 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- import {
4
- DashboardBootstrapResponseSchema,
5
- PanelCardDataResponseSchema,
6
- validateDashboardLayout,
7
- } from "./index";
8
-
9
- const barCardData = {
10
- visualization: "bar",
11
- indexKey: "month",
12
- data: [{ month: "January", revenue: 1200 }],
13
- series: [
14
- {
15
- key: "revenue",
16
- label: "Revenue",
17
- color: "var(--chart-1)",
18
- },
19
- ],
20
- } as const;
21
-
22
- describe("PanelCardDataResponseSchema", () => {
23
- it("accepts a valid Visualization payload with source data", () => {
24
- const response = {
25
- status: "success",
26
- data: barCardData,
27
- sourceData: {
28
- columns: [{ key: "revenue", label: "Revenue", align: "right" }],
29
- rows: [{ revenue: 1200 }],
30
- },
31
- };
32
-
33
- expect(PanelCardDataResponseSchema.parse(response)).toEqual(response);
34
- });
35
-
36
- it("rejects a malformed Visualization payload", () => {
37
- const response = {
38
- status: "success",
39
- data: {
40
- ...barCardData,
41
- data: [{ month: { nested: "not a chart value" }, revenue: 1200 }],
42
- },
43
- };
44
-
45
- expect(() => PanelCardDataResponseSchema.parse(response)).toThrow();
46
- });
47
- });
48
-
49
- describe("DashboardBootstrapResponseSchema", () => {
50
- it("accepts an API-managed Dashboard with persisted layout", () => {
51
- const response = {
52
- dashboards: [{ id: "dashboard-1", title: "Operations", isDefault: true }],
53
- dashboard: {
54
- id: "dashboard-1",
55
- revision: "1",
56
- config: {
57
- title: "Operations",
58
- cards: [
59
- {
60
- id: "card-1",
61
- name: "Revenue",
62
- visualization: "bar",
63
- query:
64
- "/api/gridframe/users/user-1/dashboards/dashboard-1/cards/card-1/data",
65
- layout: { x: 0, y: 0, width: 2, height: 4 },
66
- },
67
- ],
68
- },
69
- },
70
- };
71
-
72
- expect(DashboardBootstrapResponseSchema.parse(response)).toEqual(response);
73
- });
74
-
75
- it("rejects a Dashboard document without Card layout", () => {
76
- const response = {
77
- dashboards: [{ id: "dashboard-1", title: "Operations", isDefault: true }],
78
- dashboard: {
79
- id: "dashboard-1",
80
- revision: "1",
81
- config: {
82
- title: "Operations",
83
- cards: [
84
- {
85
- id: "card-1",
86
- name: "Revenue",
87
- visualization: "bar",
88
- query: "/api/cards/card-1/data",
89
- },
90
- ],
91
- },
92
- },
93
- };
94
-
95
- expect(() => DashboardBootstrapResponseSchema.parse(response)).toThrow();
96
- });
97
- });
98
-
99
- describe("validateDashboardLayout", () => {
100
- it("accepts exact, non-overlapping Card membership", () => {
101
- expect(
102
- validateDashboardLayout(
103
- [
104
- { id: "card-1", x: 0, y: 0, width: 2, height: 2 },
105
- { id: "card-2", x: 2, y: 0, width: 2, height: 2 },
106
- ],
107
- ["card-1", "card-2"],
108
- ),
109
- ).toEqual({ valid: true });
110
- });
111
-
112
- it("rejects duplicate, missing, overlapping, and out-of-bounds Cards", () => {
113
- const result = validateDashboardLayout(
114
- [
115
- { id: "card-1", x: 0, y: 0, width: 3, height: 2 },
116
- { id: "card-1", x: 2, y: 0, width: 3, height: 2 },
117
- ],
118
- ["card-1", "card-2"],
119
- );
120
-
121
- expect(result.valid).toBe(false);
122
- if (!result.valid) {
123
- expect(result.errors).toEqual(
124
- expect.arrayContaining([
125
- "Card IDs must be unique",
126
- "Layout must contain exactly the Dashboard's Cards",
127
- "Card card-1 extends beyond the 4-column grid",
128
- "Cards card-1 and card-1 overlap",
129
- ]),
130
- );
131
- }
132
- });
133
- });