@panneau/protocol 5.0.0-alpha.36 → 5.0.0-alpha.38
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.
- package/dist/aggregates.d.ts +135 -0
- package/dist/aggregates.d.ts.map +1 -0
- package/dist/aggregates.js +236 -0
- package/dist/aggregates.js.map +1 -0
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +201 -24
- package/dist/conformance/index.js.map +1 -1
- package/dist/dashboards.d.ts +95 -0
- package/dist/dashboards.d.ts.map +1 -0
- package/dist/dashboards.js +140 -0
- package/dist/dashboards.js.map +1 -0
- package/dist/index.js +8 -5
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +249 -15
- package/dist/lint.js.map +1 -1
- package/dist/mock/index.d.ts +27 -8
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +42 -6
- package/dist/mock/index.js.map +1 -1
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +77 -3
- package/dist/openapi.js.map +1 -1
- package/dist/periods.d.ts +49 -0
- package/dist/periods.d.ts.map +1 -0
- package/dist/periods.js +93 -0
- package/dist/periods.js.map +1 -0
- package/dist/runtime/index.d.ts +4 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -2
- package/dist/schemas/action.d.ts +1 -0
- package/dist/schemas/action.d.ts.map +1 -1
- package/dist/schemas/definition.d.ts +127 -0
- package/dist/schemas/definition.d.ts.map +1 -1
- package/dist/schemas/definition.js +8 -3
- package/dist/schemas/definition.js.map +1 -1
- package/dist/schemas/field.d.ts +1 -0
- package/dist/schemas/field.d.ts.map +1 -1
- package/dist/schemas/field.js +1 -0
- package/dist/schemas/field.js.map +1 -1
- package/dist/schemas/index.d.ts +283 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +11 -5
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/list.d.ts +11 -0
- package/dist/schemas/list.d.ts.map +1 -1
- package/dist/schemas/list.js +8 -2
- package/dist/schemas/list.js.map +1 -1
- package/dist/schemas/resource.d.ts +100 -0
- package/dist/schemas/resource.d.ts.map +1 -1
- package/dist/schemas/resource.js +9 -1
- package/dist/schemas/resource.js.map +1 -1
- package/dist/schemas/widget.d.ts +62 -2
- package/dist/schemas/widget.d.ts.map +1 -1
- package/dist/schemas/widget.js +36 -8
- package/dist/schemas/widget.js.map +1 -1
- package/dist/widgets.d.ts +48 -9
- package/dist/widgets.d.ts.map +1 -1
- package/dist/widgets.js +81 -10
- package/dist/widgets.js.map +1 -1
- package/package.json +1 -1
- package/schema/boot.schema.json +235 -66
- package/schema/definition.schema.json +235 -66
- package/schema/openapi.json +508 -7
package/dist/widgets.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { isRecord } from "./values.js";
|
|
2
2
|
import { fromSearchParams } from "./query.js";
|
|
3
3
|
//#region src/widgets.ts
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The widget types that every client draws (decisions 0064 and 0084). Other types are widgets of
|
|
6
|
+
* plugins.
|
|
7
|
+
*/
|
|
5
8
|
var BUILT_IN_WIDGET_TYPES = [
|
|
6
9
|
"stat",
|
|
7
10
|
"series",
|
|
8
|
-
"list"
|
|
11
|
+
"list",
|
|
12
|
+
"breakdown"
|
|
9
13
|
];
|
|
10
14
|
/** The periods of the points of a `series` widget. */
|
|
11
15
|
var WIDGET_SERIES_PERIODS = [
|
|
@@ -15,8 +19,20 @@ var WIDGET_SERIES_PERIODS = [
|
|
|
15
19
|
];
|
|
16
20
|
/** The most items a `list` widget shows: the backend sends the most useful first. */
|
|
17
21
|
var WIDGET_LIST_MAX_ITEMS = 5;
|
|
18
|
-
/** The
|
|
19
|
-
var
|
|
22
|
+
/** The most items of a `breakdown` widget: the rest is its `other`. */
|
|
23
|
+
var WIDGET_BREAKDOWN_MAX_ITEMS = 10;
|
|
24
|
+
/**
|
|
25
|
+
* The built-in types that can read a resource (`settings.resource`): `stat` and `list` read its
|
|
26
|
+
* list, `series` and `breakdown` its aggregates, and a `stat` with a `sum:` measure too.
|
|
27
|
+
*/
|
|
28
|
+
var RESOURCE_WIDGET_TYPES = [
|
|
29
|
+
"stat",
|
|
30
|
+
"series",
|
|
31
|
+
"list",
|
|
32
|
+
"breakdown"
|
|
33
|
+
];
|
|
34
|
+
/** The built-in types that read the aggregates of a resource, grouped by `settings.group`. */
|
|
35
|
+
var GROUPED_WIDGET_TYPES = ["series", "breakdown"];
|
|
20
36
|
/** Query parameters that the client sets on the list of a widget on a resource, never `query`. */
|
|
21
37
|
var WIDGET_RESERVED_QUERY_PARAMS = [
|
|
22
38
|
"page",
|
|
@@ -26,8 +42,20 @@ var WIDGET_RESERVED_QUERY_PARAMS = [
|
|
|
26
42
|
function isBuiltInWidgetType(type) {
|
|
27
43
|
return BUILT_IN_WIDGET_TYPES.includes(type);
|
|
28
44
|
}
|
|
45
|
+
/** The measure of a widget on a resource that reads its aggregates, or `null` for its list. */
|
|
46
|
+
function aggregateOf(widget) {
|
|
47
|
+
const measure = widget.settings?.measure;
|
|
48
|
+
const group = widget.settings?.group;
|
|
49
|
+
const grouped = GROUPED_WIDGET_TYPES.includes(widget.type);
|
|
50
|
+
const sums = typeof measure === "string" && measure.startsWith("sum:");
|
|
51
|
+
if (!grouped && !(widget.type === "stat" && sums)) return null;
|
|
52
|
+
return {
|
|
53
|
+
measure: typeof measure === "string" && measure !== "" ? measure : "count",
|
|
54
|
+
group: grouped && typeof group === "string" && group !== "" ? group : null
|
|
55
|
+
};
|
|
56
|
+
}
|
|
29
57
|
/**
|
|
30
|
-
* The resource
|
|
58
|
+
* The resource that feeds a built-in widget, its query, and the aggregates it reads: `null` for a
|
|
31
59
|
* widget with data of its own at `GET /dashboard/widgets/{widget}`, and for widgets of plugins.
|
|
32
60
|
*/
|
|
33
61
|
function getWidgetResource(widget) {
|
|
@@ -44,9 +72,31 @@ function getWidgetResource(widget) {
|
|
|
44
72
|
return {
|
|
45
73
|
resource,
|
|
46
74
|
params,
|
|
47
|
-
query: fromSearchParams(params)
|
|
75
|
+
query: fromSearchParams(params),
|
|
76
|
+
aggregate: aggregateOf(widget)
|
|
48
77
|
};
|
|
49
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Whether a widget of the summary of a resource follows its list (decision 0084), and gets its
|
|
81
|
+
* current filters and search: a widget on that resource, or with data of its own, unless its
|
|
82
|
+
* `settings.followsList` is `false`. A widget on another resource doesn't.
|
|
83
|
+
*/
|
|
84
|
+
function followsList(widget, resource) {
|
|
85
|
+
if (widget.settings?.followsList === false) return false;
|
|
86
|
+
const read = getWidgetResource(widget);
|
|
87
|
+
return read === null || read.resource === resource;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Whether a widget follows the period of its overview (decision 0084): a built-in widget on a
|
|
91
|
+
* resource with `settings.period`, the list's `date-range` filter that gets its days; in the
|
|
92
|
+
* summary of `summaryOf`, a widget that follows its list, whose `date-range` filter the period is;
|
|
93
|
+
* and a widget with data of its own, which gets the period, unless `settings.period` is `false`.
|
|
94
|
+
*/
|
|
95
|
+
function followsPeriod(widget, summaryOf) {
|
|
96
|
+
const period = widget.settings?.period;
|
|
97
|
+
if (period === false) return false;
|
|
98
|
+
return getWidgetResource(widget) === null || typeof period === "string" && period !== "" || summaryOf !== void 0 && followsList(widget, summaryOf);
|
|
99
|
+
}
|
|
50
100
|
var DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
51
101
|
var TONE = /^[a-z0-9-]+$/;
|
|
52
102
|
var isNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
@@ -56,12 +106,14 @@ function optional(data, key, check) {
|
|
|
56
106
|
}
|
|
57
107
|
var isString = (value) => typeof value === "string";
|
|
58
108
|
var isTone = (value) => isString(value) && TONE.test(value);
|
|
109
|
+
var isKey = (value) => isString(value) || isNumber(value) || typeof value === "boolean";
|
|
59
110
|
function checkStat(data) {
|
|
60
111
|
const wrong = [];
|
|
61
112
|
if (!isNumber(data.value)) wrong.push("value");
|
|
62
113
|
if (!optional(data, "help", isString)) wrong.push("help");
|
|
63
114
|
if (!optional(data, "tone", isTone)) wrong.push("tone");
|
|
64
115
|
if (!optional(data, "url", isString)) wrong.push("url");
|
|
116
|
+
if (!optional(data, "target", (value) => isNumber(value) && value > 0)) wrong.push("target");
|
|
65
117
|
return wrong;
|
|
66
118
|
}
|
|
67
119
|
function checkSeries(data) {
|
|
@@ -109,10 +161,28 @@ function checkList(data) {
|
|
|
109
161
|
if (!optional(data, "url", isString)) wrong.push("url");
|
|
110
162
|
return wrong;
|
|
111
163
|
}
|
|
164
|
+
function checkBreakdown(data) {
|
|
165
|
+
const wrong = [];
|
|
166
|
+
if (!Array.isArray(data.items) || data.items.length > 10) wrong.push("items");
|
|
167
|
+
else data.items.forEach((item, index) => {
|
|
168
|
+
if (!isRecord(item)) {
|
|
169
|
+
wrong.push(`items.${index}`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!isString(item.label)) wrong.push(`items.${index}.label`);
|
|
173
|
+
if (!isNumber(item.value)) wrong.push(`items.${index}.value`);
|
|
174
|
+
if (!optional(item, "tone", isTone)) wrong.push(`items.${index}.tone`);
|
|
175
|
+
if (!optional(item, "url", isString)) wrong.push(`items.${index}.url`);
|
|
176
|
+
if (!optional(item, "key", isKey)) wrong.push(`items.${index}.key`);
|
|
177
|
+
});
|
|
178
|
+
if (!optional(data, "total", isNumber)) wrong.push("total");
|
|
179
|
+
if (!optional(data, "other", isNumber)) wrong.push("other");
|
|
180
|
+
return wrong;
|
|
181
|
+
}
|
|
112
182
|
/**
|
|
113
|
-
* Checks the data of a widget against the shape of its type (
|
|
114
|
-
* the paths of the wrong keys (`value`, `points.2.date`), empty when it is right. The data
|
|
115
|
-
* widget of a plugin only has to be an object. The dates of a series must go up, one point per
|
|
183
|
+
* Checks the data of a widget against the shape of its type (decisions 0064 and 0084), without the
|
|
184
|
+
* schemas: the paths of the wrong keys (`value`, `points.2.date`), empty when it is right. The data
|
|
185
|
+
* of a widget of a plugin only has to be an object. The dates of a series must go up, one point per
|
|
116
186
|
* period.
|
|
117
187
|
*/
|
|
118
188
|
function checkWidgetData(type, data) {
|
|
@@ -121,10 +191,11 @@ function checkWidgetData(type, data) {
|
|
|
121
191
|
case "stat": return checkStat(data);
|
|
122
192
|
case "series": return checkSeries(data);
|
|
123
193
|
case "list": return checkList(data);
|
|
194
|
+
case "breakdown": return checkBreakdown(data);
|
|
124
195
|
default: return [];
|
|
125
196
|
}
|
|
126
197
|
}
|
|
127
198
|
//#endregion
|
|
128
|
-
export { BUILT_IN_WIDGET_TYPES, RESOURCE_WIDGET_TYPES, WIDGET_LIST_MAX_ITEMS, WIDGET_RESERVED_QUERY_PARAMS, WIDGET_SERIES_PERIODS, checkWidgetData, getWidgetResource, isBuiltInWidgetType };
|
|
199
|
+
export { BUILT_IN_WIDGET_TYPES, GROUPED_WIDGET_TYPES, RESOURCE_WIDGET_TYPES, WIDGET_BREAKDOWN_MAX_ITEMS, WIDGET_LIST_MAX_ITEMS, WIDGET_RESERVED_QUERY_PARAMS, WIDGET_SERIES_PERIODS, checkWidgetData, followsList, followsPeriod, getWidgetResource, isBuiltInWidgetType };
|
|
129
200
|
|
|
130
201
|
//# sourceMappingURL=widgets.js.map
|
package/dist/widgets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widgets.js","names":[],"sources":["../src/widgets.ts"],"sourcesContent":["import { type ListQuery, fromSearchParams } from './query';\nimport { isRecord } from './values';\n\n/** The widget types that every client draws (decision 0064). Other types are widgets of plugins. */\nexport const BUILT_IN_WIDGET_TYPES = ['stat', 'series', 'list'] as const;\n\nexport type BuiltInWidgetType = (typeof BUILT_IN_WIDGET_TYPES)[number];\n\n/** The periods of the points of a `series` widget. */\nexport const WIDGET_SERIES_PERIODS = ['day', 'week', 'month'] as const;\n\nexport type WidgetSeriesPeriod = (typeof WIDGET_SERIES_PERIODS)[number];\n\n/** The most items a `list` widget shows: the backend sends the most useful first. */\nexport const WIDGET_LIST_MAX_ITEMS = 5;\n\n/** The built-in types that can read the list of a resource (`settings.resource`). */\nexport const RESOURCE_WIDGET_TYPES = ['stat', 'list'] as const;\n\n/** Query parameters that the client sets on the list of a widget on a resource, never `query`. */\nexport const WIDGET_RESERVED_QUERY_PARAMS = ['page', 'perPage', 'cursor'] as const;\n\nexport function isBuiltInWidgetType(type: string): type is BuiltInWidgetType {\n return (BUILT_IN_WIDGET_TYPES as readonly string[]).includes(type);\n}\n\n/** A widget as the helpers read it: the `Widget` of the definition, or one a backend writes. */\ninterface WidgetLike {\n type: string;\n settings?: Record<string, unknown> | undefined;\n}\n\n/** A built-in widget that reads the list of a resource, with no data of its own (decision 0064). */\nexport interface WidgetResource {\n /** The id of the resource. */\n resource: string;\n /** The `query` of the widget, as query parameters, without `page`, `perPage` and `cursor`. */\n params: URLSearchParams;\n /** The same query, parsed: the query of the list request, and of the link to the list. */\n query: ListQuery;\n}\n\n/**\n * The resource whose list feeds a built-in `stat` or `list` widget, and its query: `null` for a\n * widget with data of its own at `GET /dashboard/widgets/{widget}`, and for widgets of plugins.\n */\nexport function getWidgetResource(widget: WidgetLike): WidgetResource | null {\n const resource = widget.settings?.resource;\n if (\n !(RESOURCE_WIDGET_TYPES as readonly string[]).includes(widget.type) ||\n typeof resource !== 'string' ||\n resource === ''\n ) {\n return null;\n }\n const params = new URLSearchParams();\n const query = widget.settings?.query;\n if (isRecord(query)) {\n Object.entries(query).forEach(([key, value]) => {\n if ((WIDGET_RESERVED_QUERY_PARAMS as readonly string[]).includes(key)) {\n return;\n }\n (Array.isArray(value) ? value : [value]).forEach((entry) => {\n if (\n typeof entry === 'string' ||\n typeof entry === 'number' ||\n typeof entry === 'boolean'\n ) {\n params.append(key, String(entry));\n }\n });\n });\n }\n return { resource, params, query: fromSearchParams(params) };\n}\n\nconst DATE = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst TONE = /^[a-z0-9-]+$/;\n\nconst isNumber = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value);\n\n/** Whether a key is missing, `null`, or passes the check. */\nfunction optional(\n data: Record<string, unknown>,\n key: string,\n check: (value: unknown) => boolean,\n): boolean {\n return data[key] === undefined || data[key] === null || check(data[key]);\n}\n\nconst isString = (value: unknown): value is string => typeof value === 'string';\nconst isTone = (value: unknown): boolean => isString(value) && TONE.test(value);\n\nfunction checkStat(data: Record<string, unknown>): string[] {\n const wrong: string[] = [];\n if (!isNumber(data.value)) {\n wrong.push('value');\n }\n if (!optional(data, 'help', isString)) {\n wrong.push('help');\n }\n if (!optional(data, 'tone', isTone)) {\n wrong.push('tone');\n }\n if (!optional(data, 'url', isString)) {\n wrong.push('url');\n }\n return wrong;\n}\n\nfunction checkSeries(data: Record<string, unknown>): string[] {\n const wrong: string[] = [];\n if (!(WIDGET_SERIES_PERIODS as readonly unknown[]).includes(data.period)) {\n wrong.push('period');\n }\n if (!Array.isArray(data.points)) {\n wrong.push('points');\n } else {\n let previous = '';\n data.points.forEach((point: unknown, index) => {\n if (!isRecord(point)) {\n wrong.push(`points.${index}`);\n return;\n }\n if (!isString(point.date) || !DATE.test(point.date) || point.date <= previous) {\n wrong.push(`points.${index}.date`);\n } else {\n previous = point.date;\n }\n if (!isNumber(point.value)) {\n wrong.push(`points.${index}.value`);\n }\n });\n }\n if (!optional(data, 'total', isNumber)) {\n wrong.push('total');\n }\n return wrong;\n}\n\nfunction checkList(data: Record<string, unknown>): string[] {\n const wrong: string[] = [];\n if (!Array.isArray(data.items) || data.items.length > WIDGET_LIST_MAX_ITEMS) {\n wrong.push('items');\n } else {\n data.items.forEach((item: unknown, index) => {\n if (!isRecord(item)) {\n wrong.push(`items.${index}`);\n return;\n }\n if (!isString(item.title)) {\n wrong.push(`items.${index}.title`);\n }\n ['description', 'meta', 'url'].forEach((key) => {\n if (!optional(item, key, isString)) {\n wrong.push(`items.${index}.${key}`);\n }\n });\n const badge = item.badge;\n if (badge !== undefined && badge !== null) {\n if (!isRecord(badge) || !isString(badge.label)) {\n wrong.push(`items.${index}.badge`);\n } else if (!optional(badge, 'tone', isTone)) {\n wrong.push(`items.${index}.badge.tone`);\n }\n }\n });\n }\n if (!optional(data, 'empty', isString)) {\n wrong.push('empty');\n }\n if (!optional(data, 'url', isString)) {\n wrong.push('url');\n }\n return wrong;\n}\n\n/**\n * Checks the data of a widget against the shape of its type (decision 0064), without the schemas:\n * the paths of the wrong keys (`value`, `points.2.date`), empty when it is right. The data of a\n * widget of a plugin only has to be an object. The dates of a series must go up, one point per\n * period.\n */\nexport function checkWidgetData(type: string, data: unknown): string[] {\n if (!isRecord(data)) {\n return [''];\n }\n switch (type) {\n case 'stat':\n return checkStat(data);\n case 'series':\n return checkSeries(data);\n case 'list':\n return checkList(data);\n default:\n return [];\n }\n}\n"],"mappings":";;;;AAIA,IAAa,wBAAwB;CAAC;CAAQ;CAAU;AAAM;;AAK9D,IAAa,wBAAwB;CAAC;CAAO;CAAQ;AAAO;;AAK5D,IAAa,wBAAwB;;AAGrC,IAAa,wBAAwB,CAAC,QAAQ,MAAM;;AAGpD,IAAa,+BAA+B;CAAC;CAAQ;CAAW;AAAQ;AAExE,SAAgB,oBAAoB,MAAyC;CACzE,OAAQ,sBAA4C,SAAS,IAAI;AACrE;;;;;AAsBA,SAAgB,kBAAkB,QAA2C;CACzE,MAAM,WAAW,OAAO,UAAU;CAClC,IACI,CAAE,sBAA4C,SAAS,OAAO,IAAI,KAClE,OAAO,aAAa,YACpB,aAAa,IAEb,OAAO;CAEX,MAAM,SAAS,IAAI,gBAAgB;CACnC,MAAM,QAAQ,OAAO,UAAU;CAC/B,IAAI,SAAS,KAAK,GACd,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;EAC5C,IAAK,6BAAmD,SAAS,GAAG,GAChE;EAEJ,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAA,CAAG,SAAS,UAAU;GACxD,IACI,O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,EAAE;CAEd,QAAQ,MAAR;EACI,KAAK,QACD,OAAO,UAAU,IAAI;EACzB,KAAK,UACD,OAAO,YAAY,IAAI;EAC3B,KAAK,QACD,OAAO,UAAU,IAAI;EACzB,SACI,OAAO,CAAC;CAChB;AACJ"}
|
|
1
|
+
{"version":3,"file":"widgets.js","names":[],"sources":["../src/widgets.ts"],"sourcesContent":["import { type ListQuery, fromSearchParams } from './query';\nimport { isRecord } from './values';\n\n/**\n * The widget types that every client draws (decisions 0064 and 0084). Other types are widgets of\n * plugins.\n */\nexport const BUILT_IN_WIDGET_TYPES = ['stat', 'series', 'list', 'breakdown'] as const;\n\nexport type BuiltInWidgetType = (typeof BUILT_IN_WIDGET_TYPES)[number];\n\n/** The periods of the points of a `series` widget. */\nexport const WIDGET_SERIES_PERIODS = ['day', 'week', 'month'] as const;\n\nexport type WidgetSeriesPeriod = (typeof WIDGET_SERIES_PERIODS)[number];\n\n/** The most items a `list` widget shows: the backend sends the most useful first. */\nexport const WIDGET_LIST_MAX_ITEMS = 5;\n\n/** The most items of a `breakdown` widget: the rest is its `other`. */\nexport const WIDGET_BREAKDOWN_MAX_ITEMS = 10;\n\n/**\n * The built-in types that can read a resource (`settings.resource`): `stat` and `list` read its\n * list, `series` and `breakdown` its aggregates, and a `stat` with a `sum:` measure too.\n */\nexport const RESOURCE_WIDGET_TYPES = ['stat', 'series', 'list', 'breakdown'] as const;\n\n/** The built-in types that read the aggregates of a resource, grouped by `settings.group`. */\nexport const GROUPED_WIDGET_TYPES = ['series', 'breakdown'] as const;\n\n/** Query parameters that the client sets on the list of a widget on a resource, never `query`. */\nexport const WIDGET_RESERVED_QUERY_PARAMS = ['page', 'perPage', 'cursor'] as const;\n\nexport function isBuiltInWidgetType(type: string): type is BuiltInWidgetType {\n return (BUILT_IN_WIDGET_TYPES as readonly string[]).includes(type);\n}\n\n/** A widget as the helpers read it: the `Widget` of the definition, or one a backend writes. */\ninterface WidgetLike {\n type: string;\n settings?: Record<string, unknown> | undefined;\n}\n\n/** What a widget reads of `GET /resources/{resource}/aggregate` (decision 0084). */\nexport interface WidgetAggregate {\n /** `count`, or `sum:{field}`. */\n measure: string;\n /** `{period}:{date field}` or a field of `groupBy`, for a `series` or a `breakdown`. */\n group: string | null;\n}\n\n/**\n * A built-in widget that reads a resource, with no data of its own (decisions 0064 and 0084): its\n * list, or its aggregates.\n */\nexport interface WidgetResource {\n /** The id of the resource. */\n resource: string;\n /** The `query` of the widget, as query parameters, without `page`, `perPage` and `cursor`. */\n params: URLSearchParams;\n /** The same query, parsed: the query of the list request, and of the link to the list. */\n query: ListQuery;\n /**\n * The measure and the group of the aggregates the widget reads: a `series`, a `breakdown`, and\n * a `stat` with a `sum:` measure. `null` for a `list`, and a `stat` that counts the items of\n * the list (`meta.total`).\n */\n aggregate: WidgetAggregate | null;\n}\n\n/** The measure of a widget on a resource that reads its aggregates, or `null` for its list. */\nfunction aggregateOf(widget: WidgetLike): WidgetAggregate | null {\n const measure = widget.settings?.measure;\n const group = widget.settings?.group;\n const grouped = (GROUPED_WIDGET_TYPES as readonly string[]).includes(widget.type);\n const sums = typeof measure === 'string' && measure.startsWith('sum:');\n if (!grouped && !(widget.type === 'stat' && sums)) {\n return null;\n }\n return {\n measure: typeof measure === 'string' && measure !== '' ? measure : 'count',\n group: grouped && typeof group === 'string' && group !== '' ? group : null,\n };\n}\n\n/**\n * The resource that feeds a built-in widget, its query, and the aggregates it reads: `null` for a\n * widget with data of its own at `GET /dashboard/widgets/{widget}`, and for widgets of plugins.\n */\nexport function getWidgetResource(widget: WidgetLike): WidgetResource | null {\n const resource = widget.settings?.resource;\n if (\n !(RESOURCE_WIDGET_TYPES as readonly string[]).includes(widget.type) ||\n typeof resource !== 'string' ||\n resource === ''\n ) {\n return null;\n }\n const params = new URLSearchParams();\n const query = widget.settings?.query;\n if (isRecord(query)) {\n Object.entries(query).forEach(([key, value]) => {\n if ((WIDGET_RESERVED_QUERY_PARAMS as readonly string[]).includes(key)) {\n return;\n }\n (Array.isArray(value) ? value : [value]).forEach((entry) => {\n if (\n typeof entry === 'string' ||\n typeof entry === 'number' ||\n typeof entry === 'boolean'\n ) {\n params.append(key, String(entry));\n }\n });\n });\n }\n return { resource, params, query: fromSearchParams(params), aggregate: aggregateOf(widget) };\n}\n\n/**\n * Whether a widget of the summary of a resource follows its list (decision 0084), and gets its\n * current filters and search: a widget on that resource, or with data of its own, unless its\n * `settings.followsList` is `false`. A widget on another resource doesn't.\n */\nexport function followsList(widget: WidgetLike, resource: string): boolean {\n if (widget.settings?.followsList === false) {\n return false;\n }\n const read = getWidgetResource(widget);\n return read === null || read.resource === resource;\n}\n\n/**\n * Whether a widget follows the period of its overview (decision 0084): a built-in widget on a\n * resource with `settings.period`, the list's `date-range` filter that gets its days; in the\n * summary of `summaryOf`, a widget that follows its list, whose `date-range` filter the period is;\n * and a widget with data of its own, which gets the period, unless `settings.period` is `false`.\n */\nexport function followsPeriod(widget: WidgetLike, summaryOf?: string): boolean {\n const period = widget.settings?.period;\n if (period === false) {\n return false;\n }\n const read = getWidgetResource(widget);\n return (\n read === null ||\n (typeof period === 'string' && period !== '') ||\n (summaryOf !== undefined && followsList(widget, summaryOf))\n );\n}\n\nconst DATE = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst TONE = /^[a-z0-9-]+$/;\n\nconst isNumber = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value);\n\n/** Whether a key is missing, `null`, or passes the check. */\nfunction optional(\n data: Record<string, unknown>,\n key: string,\n check: (value: unknown) => boolean,\n): boolean {\n return data[key] === undefined || data[key] === null || check(data[key]);\n}\n\nconst isString = (value: unknown): value is string => typeof value === 'string';\nconst isTone = (value: unknown): boolean => isString(value) && TONE.test(value);\nconst isKey = (value: unknown): boolean =>\n isString(value) || isNumber(value) || typeof value === 'boolean';\n\nfunction checkStat(data: Record<string, unknown>): string[] {\n const wrong: string[] = [];\n if (!isNumber(data.value)) {\n wrong.push('value');\n }\n if (!optional(data, 'help', isString)) {\n wrong.push('help');\n }\n if (!optional(data, 'tone', isTone)) {\n wrong.push('tone');\n }\n if (!optional(data, 'url', isString)) {\n wrong.push('url');\n }\n if (!optional(data, 'target', (value) => isNumber(value) && value > 0)) {\n wrong.push('target');\n }\n return wrong;\n}\n\nfunction checkSeries(data: Record<string, unknown>): string[] {\n const wrong: string[] = [];\n if (!(WIDGET_SERIES_PERIODS as readonly unknown[]).includes(data.period)) {\n wrong.push('period');\n }\n if (!Array.isArray(data.points)) {\n wrong.push('points');\n } else {\n let previous = '';\n data.points.forEach((point: unknown, index) => {\n if (!isRecord(point)) {\n wrong.push(`points.${index}`);\n return;\n }\n if (!isString(point.date) || !DATE.test(point.date) || point.date <= previous) {\n wrong.push(`points.${index}.date`);\n } else {\n previous = point.date;\n }\n if (!isNumber(point.value)) {\n wrong.push(`points.${index}.value`);\n }\n });\n }\n if (!optional(data, 'total', isNumber)) {\n wrong.push('total');\n }\n return wrong;\n}\n\nfunction checkList(data: Record<string, unknown>): string[] {\n const wrong: string[] = [];\n if (!Array.isArray(data.items) || data.items.length > WIDGET_LIST_MAX_ITEMS) {\n wrong.push('items');\n } else {\n data.items.forEach((item: unknown, index) => {\n if (!isRecord(item)) {\n wrong.push(`items.${index}`);\n return;\n }\n if (!isString(item.title)) {\n wrong.push(`items.${index}.title`);\n }\n ['description', 'meta', 'url'].forEach((key) => {\n if (!optional(item, key, isString)) {\n wrong.push(`items.${index}.${key}`);\n }\n });\n const badge = item.badge;\n if (badge !== undefined && badge !== null) {\n if (!isRecord(badge) || !isString(badge.label)) {\n wrong.push(`items.${index}.badge`);\n } else if (!optional(badge, 'tone', isTone)) {\n wrong.push(`items.${index}.badge.tone`);\n }\n }\n });\n }\n if (!optional(data, 'empty', isString)) {\n wrong.push('empty');\n }\n if (!optional(data, 'url', isString)) {\n wrong.push('url');\n }\n return wrong;\n}\n\nfunction checkBreakdown(data: Record<string, unknown>): string[] {\n const wrong: string[] = [];\n if (!Array.isArray(data.items) || data.items.length > WIDGET_BREAKDOWN_MAX_ITEMS) {\n wrong.push('items');\n } else {\n data.items.forEach((item: unknown, index) => {\n if (!isRecord(item)) {\n wrong.push(`items.${index}`);\n return;\n }\n if (!isString(item.label)) {\n wrong.push(`items.${index}.label`);\n }\n if (!isNumber(item.value)) {\n wrong.push(`items.${index}.value`);\n }\n if (!optional(item, 'tone', isTone)) {\n wrong.push(`items.${index}.tone`);\n }\n if (!optional(item, 'url', isString)) {\n wrong.push(`items.${index}.url`);\n }\n if (!optional(item, 'key', isKey)) {\n wrong.push(`items.${index}.key`);\n }\n });\n }\n if (!optional(data, 'total', isNumber)) {\n wrong.push('total');\n }\n if (!optional(data, 'other', isNumber)) {\n wrong.push('other');\n }\n return wrong;\n}\n\n/**\n * Checks the data of a widget against the shape of its type (decisions 0064 and 0084), without the\n * schemas: the paths of the wrong keys (`value`, `points.2.date`), empty when it is right. The data\n * of a widget of a plugin only has to be an object. The dates of a series must go up, one point per\n * period.\n */\nexport function checkWidgetData(type: string, data: unknown): string[] {\n if (!isRecord(data)) {\n return [''];\n }\n switch (type) {\n case 'stat':\n return checkStat(data);\n case 'series':\n return checkSeries(data);\n case 'list':\n return checkList(data);\n case 'breakdown':\n return checkBreakdown(data);\n default:\n return [];\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,wBAAwB;CAAC;CAAQ;CAAU;CAAQ;AAAW;;AAK3E,IAAa,wBAAwB;CAAC;CAAO;CAAQ;AAAO;;AAK5D,IAAa,wBAAwB;;AAGrC,IAAa,6BAA6B;;;;;AAM1C,IAAa,wBAAwB;CAAC;CAAQ;CAAU;CAAQ;AAAW;;AAG3E,IAAa,uBAAuB,CAAC,UAAU,WAAW;;AAG1D,IAAa,+BAA+B;CAAC;CAAQ;CAAW;AAAQ;AAExE,SAAgB,oBAAoB,MAAyC;CACzE,OAAQ,sBAA4C,SAAS,IAAI;AACrE;;AAoCA,SAAS,YAAY,QAA4C;CAC7D,MAAM,UAAU,OAAO,UAAU;CACjC,MAAM,QAAQ,OAAO,UA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+
"period": {
|
|
132
|
+
"$ref": "#/$defs/OverviewPeriod"
|
|
130
133
|
}
|
|
131
134
|
},
|
|
132
135
|
"required": [
|
|
@@ -301,6 +304,9 @@
|
|
|
301
304
|
"$ref": "#/$defs/ResourceType"
|
|
302
305
|
}
|
|
303
306
|
},
|
|
307
|
+
"summary": {
|
|
308
|
+
"$ref": "#/$defs/ResourceSummary"
|
|
309
|
+
},
|
|
304
310
|
"settings": {
|
|
305
311
|
"type": "object",
|
|
306
312
|
"propertyNames": {
|
|
@@ -416,6 +422,9 @@
|
|
|
416
422
|
"choose"
|
|
417
423
|
]
|
|
418
424
|
},
|
|
425
|
+
"transforms": {
|
|
426
|
+
"type": "boolean"
|
|
427
|
+
},
|
|
419
428
|
"from": {
|
|
420
429
|
"type": "string"
|
|
421
430
|
},
|
|
@@ -1158,6 +1167,9 @@
|
|
|
1158
1167
|
},
|
|
1159
1168
|
"calendar": {
|
|
1160
1169
|
"$ref": "#/$defs/ListCalendar"
|
|
1170
|
+
},
|
|
1171
|
+
"aggregates": {
|
|
1172
|
+
"$ref": "#/$defs/ListAggregates"
|
|
1161
1173
|
}
|
|
1162
1174
|
},
|
|
1163
1175
|
"additionalProperties": {}
|
|
@@ -1262,6 +1274,33 @@
|
|
|
1262
1274
|
],
|
|
1263
1275
|
"additionalProperties": {}
|
|
1264
1276
|
},
|
|
1277
|
+
"ListAggregates": {
|
|
1278
|
+
"type": "object",
|
|
1279
|
+
"properties": {
|
|
1280
|
+
"sum": {
|
|
1281
|
+
"type": "array",
|
|
1282
|
+
"items": {
|
|
1283
|
+
"type": "string",
|
|
1284
|
+
"minLength": 1
|
|
1285
|
+
}
|
|
1286
|
+
},
|
|
1287
|
+
"groupBy": {
|
|
1288
|
+
"type": "array",
|
|
1289
|
+
"items": {
|
|
1290
|
+
"type": "string",
|
|
1291
|
+
"minLength": 1
|
|
1292
|
+
}
|
|
1293
|
+
},
|
|
1294
|
+
"dates": {
|
|
1295
|
+
"type": "array",
|
|
1296
|
+
"items": {
|
|
1297
|
+
"type": "string",
|
|
1298
|
+
"minLength": 1
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
"additionalProperties": {}
|
|
1303
|
+
},
|
|
1265
1304
|
"Action": {
|
|
1266
1305
|
"type": "object",
|
|
1267
1306
|
"properties": {
|
|
@@ -1560,6 +1599,160 @@
|
|
|
1560
1599
|
],
|
|
1561
1600
|
"additionalProperties": {}
|
|
1562
1601
|
},
|
|
1602
|
+
"ResourceSummary": {
|
|
1603
|
+
"type": "object",
|
|
1604
|
+
"properties": {
|
|
1605
|
+
"widgets": {
|
|
1606
|
+
"type": "array",
|
|
1607
|
+
"items": {
|
|
1608
|
+
"$ref": "#/$defs/Widget"
|
|
1609
|
+
}
|
|
1610
|
+
},
|
|
1611
|
+
"list": {
|
|
1612
|
+
"type": "string",
|
|
1613
|
+
"enum": [
|
|
1614
|
+
"collapsed"
|
|
1615
|
+
]
|
|
1616
|
+
},
|
|
1617
|
+
"period": {
|
|
1618
|
+
"$ref": "#/$defs/SummaryPeriod"
|
|
1619
|
+
}
|
|
1620
|
+
},
|
|
1621
|
+
"required": [
|
|
1622
|
+
"widgets"
|
|
1623
|
+
],
|
|
1624
|
+
"additionalProperties": {}
|
|
1625
|
+
},
|
|
1626
|
+
"Widget": {
|
|
1627
|
+
"type": "object",
|
|
1628
|
+
"properties": {
|
|
1629
|
+
"id": {
|
|
1630
|
+
"type": "string",
|
|
1631
|
+
"minLength": 1
|
|
1632
|
+
},
|
|
1633
|
+
"type": {
|
|
1634
|
+
"type": "string",
|
|
1635
|
+
"minLength": 1
|
|
1636
|
+
},
|
|
1637
|
+
"label": {
|
|
1638
|
+
"type": "string"
|
|
1639
|
+
},
|
|
1640
|
+
"width": {
|
|
1641
|
+
"type": "integer",
|
|
1642
|
+
"minimum": 1,
|
|
1643
|
+
"maximum": 12
|
|
1644
|
+
},
|
|
1645
|
+
"settings": {
|
|
1646
|
+
"$ref": "#/$defs/WidgetSettings"
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
"required": [
|
|
1650
|
+
"id",
|
|
1651
|
+
"type"
|
|
1652
|
+
],
|
|
1653
|
+
"additionalProperties": {}
|
|
1654
|
+
},
|
|
1655
|
+
"WidgetSettings": {
|
|
1656
|
+
"type": "object",
|
|
1657
|
+
"properties": {
|
|
1658
|
+
"resource": {
|
|
1659
|
+
"type": "string",
|
|
1660
|
+
"minLength": 1
|
|
1661
|
+
},
|
|
1662
|
+
"query": {
|
|
1663
|
+
"type": "object",
|
|
1664
|
+
"propertyNames": {
|
|
1665
|
+
"type": "string"
|
|
1666
|
+
},
|
|
1667
|
+
"additionalProperties": {
|
|
1668
|
+
"anyOf": [
|
|
1669
|
+
{
|
|
1670
|
+
"type": [
|
|
1671
|
+
"string",
|
|
1672
|
+
"number",
|
|
1673
|
+
"boolean"
|
|
1674
|
+
]
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
"type": "array",
|
|
1678
|
+
"items": {
|
|
1679
|
+
"type": [
|
|
1680
|
+
"string",
|
|
1681
|
+
"number",
|
|
1682
|
+
"boolean"
|
|
1683
|
+
]
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
]
|
|
1687
|
+
}
|
|
1688
|
+
},
|
|
1689
|
+
"measure": {
|
|
1690
|
+
"type": "string",
|
|
1691
|
+
"minLength": 1
|
|
1692
|
+
},
|
|
1693
|
+
"group": {
|
|
1694
|
+
"type": "string",
|
|
1695
|
+
"minLength": 1
|
|
1696
|
+
},
|
|
1697
|
+
"target": {
|
|
1698
|
+
"type": "number",
|
|
1699
|
+
"exclusiveMinimum": 0
|
|
1700
|
+
},
|
|
1701
|
+
"period": {
|
|
1702
|
+
"anyOf": [
|
|
1703
|
+
{
|
|
1704
|
+
"type": "string",
|
|
1705
|
+
"minLength": 1
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
"type": "boolean",
|
|
1709
|
+
"const": false
|
|
1710
|
+
}
|
|
1711
|
+
]
|
|
1712
|
+
},
|
|
1713
|
+
"followsList": {
|
|
1714
|
+
"type": "boolean"
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
"additionalProperties": {}
|
|
1718
|
+
},
|
|
1719
|
+
"SummaryPeriod": {
|
|
1720
|
+
"type": "object",
|
|
1721
|
+
"properties": {
|
|
1722
|
+
"options": {
|
|
1723
|
+
"minItems": 1,
|
|
1724
|
+
"type": "array",
|
|
1725
|
+
"items": {
|
|
1726
|
+
"type": "string",
|
|
1727
|
+
"enum": [
|
|
1728
|
+
"7d",
|
|
1729
|
+
"30d",
|
|
1730
|
+
"90d",
|
|
1731
|
+
"month",
|
|
1732
|
+
"year"
|
|
1733
|
+
]
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
"default": {
|
|
1737
|
+
"type": "string",
|
|
1738
|
+
"enum": [
|
|
1739
|
+
"7d",
|
|
1740
|
+
"30d",
|
|
1741
|
+
"90d",
|
|
1742
|
+
"month",
|
|
1743
|
+
"year"
|
|
1744
|
+
]
|
|
1745
|
+
},
|
|
1746
|
+
"filter": {
|
|
1747
|
+
"type": "string",
|
|
1748
|
+
"minLength": 1
|
|
1749
|
+
}
|
|
1750
|
+
},
|
|
1751
|
+
"required": [
|
|
1752
|
+
"options"
|
|
1753
|
+
],
|
|
1754
|
+
"additionalProperties": {}
|
|
1755
|
+
},
|
|
1563
1756
|
"Page": {
|
|
1564
1757
|
"type": "object",
|
|
1565
1758
|
"properties": {
|
|
@@ -1589,6 +1782,15 @@
|
|
|
1589
1782
|
},
|
|
1590
1783
|
"abilities": {
|
|
1591
1784
|
"$ref": "#/$defs/Abilities"
|
|
1785
|
+
},
|
|
1786
|
+
"widgets": {
|
|
1787
|
+
"type": "array",
|
|
1788
|
+
"items": {
|
|
1789
|
+
"$ref": "#/$defs/Widget"
|
|
1790
|
+
}
|
|
1791
|
+
},
|
|
1792
|
+
"period": {
|
|
1793
|
+
"$ref": "#/$defs/OverviewPeriod"
|
|
1592
1794
|
}
|
|
1593
1795
|
},
|
|
1594
1796
|
"required": [
|
|
@@ -1596,6 +1798,39 @@
|
|
|
1596
1798
|
],
|
|
1597
1799
|
"additionalProperties": {}
|
|
1598
1800
|
},
|
|
1801
|
+
"OverviewPeriod": {
|
|
1802
|
+
"type": "object",
|
|
1803
|
+
"properties": {
|
|
1804
|
+
"options": {
|
|
1805
|
+
"minItems": 1,
|
|
1806
|
+
"type": "array",
|
|
1807
|
+
"items": {
|
|
1808
|
+
"type": "string",
|
|
1809
|
+
"enum": [
|
|
1810
|
+
"7d",
|
|
1811
|
+
"30d",
|
|
1812
|
+
"90d",
|
|
1813
|
+
"month",
|
|
1814
|
+
"year"
|
|
1815
|
+
]
|
|
1816
|
+
}
|
|
1817
|
+
},
|
|
1818
|
+
"default": {
|
|
1819
|
+
"type": "string",
|
|
1820
|
+
"enum": [
|
|
1821
|
+
"7d",
|
|
1822
|
+
"30d",
|
|
1823
|
+
"90d",
|
|
1824
|
+
"month",
|
|
1825
|
+
"year"
|
|
1826
|
+
]
|
|
1827
|
+
}
|
|
1828
|
+
},
|
|
1829
|
+
"required": [
|
|
1830
|
+
"options"
|
|
1831
|
+
],
|
|
1832
|
+
"additionalProperties": {}
|
|
1833
|
+
},
|
|
1599
1834
|
"MenuItem": {
|
|
1600
1835
|
"type": "object",
|
|
1601
1836
|
"properties": {
|
|
@@ -1732,72 +1967,6 @@
|
|
|
1732
1967
|
],
|
|
1733
1968
|
"additionalProperties": {}
|
|
1734
1969
|
},
|
|
1735
|
-
"Widget": {
|
|
1736
|
-
"type": "object",
|
|
1737
|
-
"properties": {
|
|
1738
|
-
"id": {
|
|
1739
|
-
"type": "string",
|
|
1740
|
-
"minLength": 1
|
|
1741
|
-
},
|
|
1742
|
-
"type": {
|
|
1743
|
-
"type": "string",
|
|
1744
|
-
"minLength": 1
|
|
1745
|
-
},
|
|
1746
|
-
"label": {
|
|
1747
|
-
"type": "string"
|
|
1748
|
-
},
|
|
1749
|
-
"width": {
|
|
1750
|
-
"type": "integer",
|
|
1751
|
-
"minimum": 1,
|
|
1752
|
-
"maximum": 12
|
|
1753
|
-
},
|
|
1754
|
-
"settings": {
|
|
1755
|
-
"$ref": "#/$defs/WidgetSettings"
|
|
1756
|
-
}
|
|
1757
|
-
},
|
|
1758
|
-
"required": [
|
|
1759
|
-
"id",
|
|
1760
|
-
"type"
|
|
1761
|
-
],
|
|
1762
|
-
"additionalProperties": {}
|
|
1763
|
-
},
|
|
1764
|
-
"WidgetSettings": {
|
|
1765
|
-
"type": "object",
|
|
1766
|
-
"properties": {
|
|
1767
|
-
"resource": {
|
|
1768
|
-
"type": "string",
|
|
1769
|
-
"minLength": 1
|
|
1770
|
-
},
|
|
1771
|
-
"query": {
|
|
1772
|
-
"type": "object",
|
|
1773
|
-
"propertyNames": {
|
|
1774
|
-
"type": "string"
|
|
1775
|
-
},
|
|
1776
|
-
"additionalProperties": {
|
|
1777
|
-
"anyOf": [
|
|
1778
|
-
{
|
|
1779
|
-
"type": [
|
|
1780
|
-
"string",
|
|
1781
|
-
"number",
|
|
1782
|
-
"boolean"
|
|
1783
|
-
]
|
|
1784
|
-
},
|
|
1785
|
-
{
|
|
1786
|
-
"type": "array",
|
|
1787
|
-
"items": {
|
|
1788
|
-
"type": [
|
|
1789
|
-
"string",
|
|
1790
|
-
"number",
|
|
1791
|
-
"boolean"
|
|
1792
|
-
]
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
]
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
},
|
|
1799
|
-
"additionalProperties": {}
|
|
1800
|
-
},
|
|
1801
1970
|
"Uploads": {
|
|
1802
1971
|
"type": "object",
|
|
1803
1972
|
"properties": {
|