@panneau/protocol 5.0.0-alpha.36 → 5.0.0-alpha.37

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 (57) hide show
  1. package/dist/aggregates.d.ts +135 -0
  2. package/dist/aggregates.d.ts.map +1 -0
  3. package/dist/aggregates.js +236 -0
  4. package/dist/aggregates.js.map +1 -0
  5. package/dist/conformance/index.d.ts.map +1 -1
  6. package/dist/conformance/index.js +201 -24
  7. package/dist/conformance/index.js.map +1 -1
  8. package/dist/dashboards.d.ts +95 -0
  9. package/dist/dashboards.d.ts.map +1 -0
  10. package/dist/dashboards.js +140 -0
  11. package/dist/dashboards.js.map +1 -0
  12. package/dist/index.js +8 -5
  13. package/dist/lint.d.ts.map +1 -1
  14. package/dist/lint.js +237 -15
  15. package/dist/lint.js.map +1 -1
  16. package/dist/mock/index.d.ts +27 -8
  17. package/dist/mock/index.d.ts.map +1 -1
  18. package/dist/mock/index.js +42 -6
  19. package/dist/mock/index.js.map +1 -1
  20. package/dist/openapi.d.ts.map +1 -1
  21. package/dist/openapi.js +77 -3
  22. package/dist/openapi.js.map +1 -1
  23. package/dist/periods.d.ts +49 -0
  24. package/dist/periods.d.ts.map +1 -0
  25. package/dist/periods.js +93 -0
  26. package/dist/periods.js.map +1 -0
  27. package/dist/runtime/index.d.ts +4 -1
  28. package/dist/runtime/index.d.ts.map +1 -1
  29. package/dist/runtime/index.js +5 -2
  30. package/dist/schemas/definition.d.ts +125 -0
  31. package/dist/schemas/definition.d.ts.map +1 -1
  32. package/dist/schemas/definition.js +8 -3
  33. package/dist/schemas/definition.js.map +1 -1
  34. package/dist/schemas/index.d.ts +277 -1
  35. package/dist/schemas/index.d.ts.map +1 -1
  36. package/dist/schemas/index.js +11 -5
  37. package/dist/schemas/index.js.map +1 -1
  38. package/dist/schemas/list.d.ts +11 -0
  39. package/dist/schemas/list.d.ts.map +1 -1
  40. package/dist/schemas/list.js +8 -2
  41. package/dist/schemas/list.js.map +1 -1
  42. package/dist/schemas/resource.d.ts +98 -0
  43. package/dist/schemas/resource.d.ts.map +1 -1
  44. package/dist/schemas/resource.js +9 -1
  45. package/dist/schemas/resource.js.map +1 -1
  46. package/dist/schemas/widget.d.ts +62 -2
  47. package/dist/schemas/widget.d.ts.map +1 -1
  48. package/dist/schemas/widget.js +36 -8
  49. package/dist/schemas/widget.js.map +1 -1
  50. package/dist/widgets.d.ts +48 -9
  51. package/dist/widgets.d.ts.map +1 -1
  52. package/dist/widgets.js +81 -10
  53. package/dist/widgets.js.map +1 -1
  54. package/package.json +1 -1
  55. package/schema/boot.schema.json +232 -66
  56. package/schema/definition.schema.json +232 -66
  57. package/schema/openapi.json +504 -7
@@ -0,0 +1,135 @@
1
+ import { type FilterRange, type ListQuery } from './query.js';
2
+ import type { BreakdownWidgetData, SeriesWidgetData, StatWidgetData } from './schemas/index.js';
3
+ import { type WidgetSeriesPeriod } from './widgets.js';
4
+ /**
5
+ * The most points of a `series` that `GET /resources/{resource}/aggregate` answers: a year of
6
+ * days. A longer range keeps its latest periods.
7
+ */
8
+ export declare const AGGREGATE_MAX_POINTS = 366;
9
+ /** The measure that counts the items, the default one. */
10
+ export declare const AGGREGATE_COUNT = "count";
11
+ /** The aggregates a list declares (`list.aggregates`, decision 0084): nothing else is aggregated. */
12
+ export interface ListAggregatesLike {
13
+ /** Fields that can be summed. */
14
+ sum?: readonly string[] | undefined;
15
+ /** Fields whose values the items can be grouped by. */
16
+ groupBy?: readonly string[] | undefined;
17
+ /** Date fields whose periods the items can be grouped by. */
18
+ dates?: readonly string[] | undefined;
19
+ }
20
+ /** What is measured of the items: how many they are, or the sum of a field. */
21
+ export type AggregateMeasure = {
22
+ type: 'count';
23
+ } | {
24
+ type: 'sum';
25
+ field: string;
26
+ };
27
+ /** How the items are grouped: by the period of a date, or by the values of a field. */
28
+ export type AggregateGroup = {
29
+ type: 'period';
30
+ period: WidgetSeriesPeriod;
31
+ field: string;
32
+ } | {
33
+ type: 'field';
34
+ field: string;
35
+ };
36
+ /** A query of the aggregate endpoint, read: its measure, and its group if it has one. */
37
+ export interface AggregateQuery {
38
+ measure: AggregateMeasure;
39
+ group: AggregateGroup | null;
40
+ }
41
+ /**
42
+ * A request of `GET /resources/{resource}/aggregate`: the filters and the search of the list,
43
+ * the `measure` (`count` by default) and the `group`.
44
+ */
45
+ export interface AggregateRequest {
46
+ filter?: ListQuery['filter'];
47
+ q?: string | undefined;
48
+ /** `count`, or `sum:{field}`. Defaults to `count`. */
49
+ measure?: string | undefined;
50
+ /** `{day|week|month}:{date field}`, or a field of `groupBy`. */
51
+ group?: string | null | undefined;
52
+ }
53
+ /** The built-in widget type of an answer of the aggregate endpoint. */
54
+ export type AggregateWidgetType = 'stat' | 'series' | 'breakdown';
55
+ /** Reads a measure: `count`, or `sum:{field}`. `null` when it is neither. */
56
+ export declare function parseAggregateMeasure(value: string): AggregateMeasure | null;
57
+ /**
58
+ * Reads a group: `{period}:{date field}`, where the period is `day`, `week` or `month`, or the
59
+ * name of a field. `null` when it is neither.
60
+ */
61
+ export declare function parseAggregateGroup(value: string): AggregateGroup | null;
62
+ /** The shape of the answer to a group: a `stat` without one, a `series` or a `breakdown`. */
63
+ export declare function getAggregateWidgetType(group: AggregateGroup | null): AggregateWidgetType;
64
+ /** Serializes a request of the aggregate endpoint: the filters and the search, then its own. */
65
+ export declare function toAggregateParams(request: AggregateRequest): URLSearchParams;
66
+ /** An aggregate query as a backend reads it: valid, or the messages of its invalid parameters. */
67
+ export type ReadAggregateQueryResult = {
68
+ query: AggregateQuery;
69
+ errors?: undefined;
70
+ } | {
71
+ query?: undefined;
72
+ errors: Record<string, string[]>;
73
+ };
74
+ /**
75
+ * Reads `measure` and `group` of `GET /resources/{resource}/aggregate` against the aggregates of
76
+ * the list: the reference of how a backend validates them. `measure` defaults to `count`; a
77
+ * `sum:` names a field of `sum`, a period names a field of `dates`, and another group a field of
78
+ * `groupBy`. Invalid parameters are a `422`, with `errors` keyed by parameter. The filters and the
79
+ * search are read as the list reads them.
80
+ */
81
+ export declare function readAggregateQuery(params: URLSearchParams, aggregates: ListAggregatesLike): ReadAggregateQueryResult;
82
+ /**
83
+ * The first day of the period of a day: the day itself, the Monday of its week (ISO 8601), or the
84
+ * first day of its month. `2026-10-08` is in the week of `2026-10-05`.
85
+ */
86
+ export declare function startOfPeriod(day: string, period: WidgetSeriesPeriod): string;
87
+ /** The first day of the period after the one that starts on `start`. */
88
+ export declare function nextPeriod(start: string, period: WidgetSeriesPeriod): string;
89
+ /**
90
+ * The first days of the periods from the one of `from` to the one of `to`, both included: at most
91
+ * `max` of them, the latest. Empty when `to` is before `from`.
92
+ */
93
+ export declare function listPeriods(from: string, to: string, period: WidgetSeriesPeriod, max?: number): string[];
94
+ /** The fields an aggregate reads, as the definition declares them. */
95
+ export interface AggregateField {
96
+ name: string;
97
+ type: string;
98
+ options?: readonly {
99
+ value: unknown;
100
+ label: string;
101
+ tone?: string | undefined;
102
+ }[] | undefined;
103
+ }
104
+ export interface AggregateItemsOptions {
105
+ /** The fields of the resource: the options of a `select` give the labels and the tones. */
106
+ fields: readonly AggregateField[];
107
+ /**
108
+ * The bounds of the `date-range` filter of the query on the date of a period group, whose id is
109
+ * the name of that field: the range of the series. Without a bound, the series starts on the
110
+ * period of the first item, or ends on the period of the last.
111
+ */
112
+ range?: FilterRange | undefined;
113
+ /** The label of the part of the items without a value. Defaults to `None`. */
114
+ emptyLabel?: string;
115
+ }
116
+ /**
117
+ * Aggregates items that a list query already filtered: the reference of what
118
+ * `GET /resources/{resource}/aggregate` answers (decision 0084).
119
+ *
120
+ * - Without a group: a `stat`, the count or the sum of the items.
121
+ * - By a period: a `series`, one point per period from its range, 0 for the periods without items.
122
+ * The range is the bounds of the `date-range` filter on the date (`range`), and without a bound,
123
+ * the period of the first or the last item; at most `AGGREGATE_MAX_POINTS` periods, the latest.
124
+ * Items without a date are left out. `total` is the sum of the points.
125
+ * - By a field: a `breakdown`, a part per value, the largest first, at most
126
+ * `WIDGET_BREAKDOWN_MAX_ITEMS`, the rest in `other`. An item with several values counts in each
127
+ * of their parts, once in `total`; one without a value counts in the part of `key: null`. The
128
+ * options of a `select` give their labels and tones, a reference its `label`.
129
+ *
130
+ * A sum of `money` values adds their amounts, in minor units.
131
+ */
132
+ export declare function aggregateItems(items: readonly Record<string, unknown>[], query: AggregateQuery, options: AggregateItemsOptions): StatWidgetData | SeriesWidgetData | BreakdownWidgetData;
133
+ /** The bounds of the `date-range` filter on a field in a list query, if it has them. */
134
+ export declare function getFilterRange(query: Pick<ListQuery, 'filter'>, field: string): FilterRange | undefined;
135
+ //# sourceMappingURL=aggregates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregates.d.ts","sourceRoot":"","sources":["../src/aggregates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAiC,MAAM,SAAS,CAAC;AAC1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEvF,OAAO,EAGH,KAAK,kBAAkB,EAC1B,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,0DAA0D;AAC1D,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IAC/B,iCAAiC;IACjC,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACpC,uDAAuD;IACvD,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CACzC;AAED,+EAA+E;AAC/E,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM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,GAC/B,cAAc,GAAG,gBAAgB,GAAG,mBAAmB,CA2FzD;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAC1B,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAChC,KAAK,EAAE,MAAM,GACd,WAAW,GAAG,SAAS,CAGzB"}
@@ -0,0 +1,236 @@
1
+ import { isRecord } from "./values.js";
2
+ import { isFilterRange, toSearchParams } from "./query.js";
3
+ import { WIDGET_SERIES_PERIODS } from "./widgets.js";
4
+ //#region src/aggregates.ts
5
+ /**
6
+ * The most points of a `series` that `GET /resources/{resource}/aggregate` answers: a year of
7
+ * days. A longer range keeps its latest periods.
8
+ */
9
+ var AGGREGATE_MAX_POINTS = 366;
10
+ /** The measure that counts the items, the default one. */
11
+ var AGGREGATE_COUNT = "count";
12
+ /** Reads a measure: `count`, or `sum:{field}`. `null` when it is neither. */
13
+ function parseAggregateMeasure(value) {
14
+ if (value === "count") return { type: "count" };
15
+ const field = /^sum:(.+)$/.exec(value)?.[1];
16
+ return field !== void 0 ? {
17
+ type: "sum",
18
+ field
19
+ } : null;
20
+ }
21
+ /**
22
+ * Reads a group: `{period}:{date field}`, where the period is `day`, `week` or `month`, or the
23
+ * name of a field. `null` when it is neither.
24
+ */
25
+ function parseAggregateGroup(value) {
26
+ const match = /^([^:]*):(.*)$/.exec(value);
27
+ if (match === null) return value !== "" ? {
28
+ type: "field",
29
+ field: value
30
+ } : null;
31
+ const [, period = "", field = ""] = match;
32
+ return WIDGET_SERIES_PERIODS.includes(period) && field !== "" ? {
33
+ type: "period",
34
+ period,
35
+ field
36
+ } : null;
37
+ }
38
+ /** The shape of the answer to a group: a `stat` without one, a `series` or a `breakdown`. */
39
+ function getAggregateWidgetType(group) {
40
+ if (group === null) return "stat";
41
+ return group.type === "period" ? "series" : "breakdown";
42
+ }
43
+ /** Serializes a request of the aggregate endpoint: the filters and the search, then its own. */
44
+ function toAggregateParams(request) {
45
+ const params = toSearchParams({
46
+ ...request.filter !== void 0 && { filter: request.filter },
47
+ ...request.q !== void 0 && { q: request.q }
48
+ });
49
+ params.set("measure", request.measure ?? "count");
50
+ if (request.group !== void 0 && request.group !== null && request.group !== "") params.set("group", request.group);
51
+ return params;
52
+ }
53
+ /**
54
+ * Reads `measure` and `group` of `GET /resources/{resource}/aggregate` against the aggregates of
55
+ * the list: the reference of how a backend validates them. `measure` defaults to `count`; a
56
+ * `sum:` names a field of `sum`, a period names a field of `dates`, and another group a field of
57
+ * `groupBy`. Invalid parameters are a `422`, with `errors` keyed by parameter. The filters and the
58
+ * search are read as the list reads them.
59
+ */
60
+ function readAggregateQuery(params, aggregates) {
61
+ const errors = {};
62
+ const measure = parseAggregateMeasure(params.get("measure") ?? "count");
63
+ if (measure === null) errors.measure = ["The measure must be `count` or `sum:{field}`."];
64
+ else if (measure.type === "sum" && !(aggregates.sum ?? []).includes(measure.field)) errors.measure = [`The field \`${measure.field}\` can't be summed.`];
65
+ const rawGroup = params.get("group");
66
+ let group = null;
67
+ if (rawGroup !== null) {
68
+ group = parseAggregateGroup(rawGroup);
69
+ if (group === null) errors.group = ["The group must be `{day|week|month}:{date field}` or a field."];
70
+ else if (group.type === "period" && !(aggregates.dates ?? []).includes(group.field)) errors.group = [`The field \`${group.field}\` isn't a date that can be grouped.`];
71
+ else if (group.type === "field" && !(aggregates.groupBy ?? []).includes(group.field)) errors.group = [`The items can't be grouped by the field \`${group.field}\`.`];
72
+ }
73
+ if (Object.keys(errors).length > 0 || measure === null) return { errors };
74
+ return { query: {
75
+ measure,
76
+ group
77
+ } };
78
+ }
79
+ var DAY = /^\d{4}-\d{2}-\d{2}/;
80
+ /** The day of a `date` or `datetime` value, as the backend writes it: `null` without one. */
81
+ function dayOf(value) {
82
+ return typeof value === "string" && DAY.test(value) ? value.slice(0, 10) : null;
83
+ }
84
+ function toUtc(day) {
85
+ return /* @__PURE__ */ new Date(`${day.slice(0, 10)}T00:00:00Z`);
86
+ }
87
+ function fromUtc(date) {
88
+ return date.toISOString().slice(0, 10);
89
+ }
90
+ /**
91
+ * The first day of the period of a day: the day itself, the Monday of its week (ISO 8601), or the
92
+ * first day of its month. `2026-10-08` is in the week of `2026-10-05`.
93
+ */
94
+ function startOfPeriod(day, period) {
95
+ const date = toUtc(day);
96
+ if (period === "week") date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 6) % 7);
97
+ else if (period === "month") date.setUTCDate(1);
98
+ return fromUtc(date);
99
+ }
100
+ /** The first day of the period after the one that starts on `start`. */
101
+ function nextPeriod(start, period) {
102
+ const date = toUtc(start);
103
+ if (period === "month") date.setUTCMonth(date.getUTCMonth() + 1, 1);
104
+ else date.setUTCDate(date.getUTCDate() + (period === "week" ? 7 : 1));
105
+ return fromUtc(date);
106
+ }
107
+ /**
108
+ * The first days of the periods from the one of `from` to the one of `to`, both included: at most
109
+ * `max` of them, the latest. Empty when `to` is before `from`.
110
+ */
111
+ function listPeriods(from, to, period, max = 366) {
112
+ const last = startOfPeriod(to, period);
113
+ const periods = [];
114
+ for (let start = startOfPeriod(from, period); start <= last; start = nextPeriod(start, period)) {
115
+ periods.push(start);
116
+ if (periods.length > max) periods.shift();
117
+ }
118
+ return periods;
119
+ }
120
+ /** The value of an item, as a key of a part: the id of a reference, `null` when it is empty. */
121
+ function keysOf(value) {
122
+ if (Array.isArray(value)) {
123
+ const keys = value.flatMap((entry) => keysOf(entry).filter(({ key }) => key !== null));
124
+ return keys.length > 0 ? keys : [{ key: null }];
125
+ }
126
+ if (typeof value === "string") return [{ key: value === "" ? null : value }];
127
+ if (typeof value === "number" || typeof value === "boolean") return [{ key: value }];
128
+ if (isRecord(value) && (typeof value.id === "string" || typeof value.id === "number")) return [{
129
+ key: value.id,
130
+ ...typeof value.label === "string" && { label: value.label }
131
+ }];
132
+ return [{ key: null }];
133
+ }
134
+ /** The amount of a value that is summed: a number, or the amount of a `money` value. */
135
+ function amountOf(value) {
136
+ if (typeof value === "number" && Number.isFinite(value)) return value;
137
+ if (isRecord(value) && typeof value.amount === "number" && Number.isFinite(value.amount)) return value.amount;
138
+ return 0;
139
+ }
140
+ /**
141
+ * Aggregates items that a list query already filtered: the reference of what
142
+ * `GET /resources/{resource}/aggregate` answers (decision 0084).
143
+ *
144
+ * - Without a group: a `stat`, the count or the sum of the items.
145
+ * - By a period: a `series`, one point per period from its range, 0 for the periods without items.
146
+ * The range is the bounds of the `date-range` filter on the date (`range`), and without a bound,
147
+ * the period of the first or the last item; at most `AGGREGATE_MAX_POINTS` periods, the latest.
148
+ * Items without a date are left out. `total` is the sum of the points.
149
+ * - By a field: a `breakdown`, a part per value, the largest first, at most
150
+ * `WIDGET_BREAKDOWN_MAX_ITEMS`, the rest in `other`. An item with several values counts in each
151
+ * of their parts, once in `total`; one without a value counts in the part of `key: null`. The
152
+ * options of a `select` give their labels and tones, a reference its `label`.
153
+ *
154
+ * A sum of `money` values adds their amounts, in minor units.
155
+ */
156
+ function aggregateItems(items, query, options) {
157
+ const { measure, group } = query;
158
+ const measureOf = (item) => measure.type === "count" ? 1 : amountOf(item[measure.field]);
159
+ const total = items.reduce((sum, item) => sum + measureOf(item), 0);
160
+ if (group === null) return { value: total };
161
+ if (group.type === "period") {
162
+ const values = /* @__PURE__ */ new Map();
163
+ const days = [];
164
+ items.forEach((item) => {
165
+ const day = dayOf(item[group.field]);
166
+ if (day === null) return;
167
+ days.push(day);
168
+ const start = startOfPeriod(day, group.period);
169
+ values.set(start, (values.get(start) ?? 0) + measureOf(item));
170
+ });
171
+ days.sort();
172
+ const bound = (key) => {
173
+ const value = options.range?.[key];
174
+ return value !== void 0 && value !== "" ? dayOf(String(value)) : null;
175
+ };
176
+ const from = bound("from") ?? days[0] ?? bound("to");
177
+ const to = bound("to") ?? days.at(-1) ?? bound("from");
178
+ const points = from !== null && to !== null ? listPeriods(from, to, group.period).map((date) => ({
179
+ date,
180
+ value: values.get(date) ?? 0
181
+ })) : [];
182
+ return {
183
+ period: group.period,
184
+ points,
185
+ total: points.reduce((sum, point) => sum + point.value, 0)
186
+ };
187
+ }
188
+ const field = options.fields.find((candidate) => candidate.name === group.field);
189
+ const parts = /* @__PURE__ */ new Map();
190
+ items.forEach((item) => {
191
+ const amount = measureOf(item);
192
+ const seen = /* @__PURE__ */ new Set();
193
+ keysOf(item[group.field]).forEach(({ key, label }) => {
194
+ const id = JSON.stringify(key);
195
+ if (seen.has(id)) return;
196
+ seen.add(id);
197
+ const part = parts.get(id) ?? {
198
+ key,
199
+ label: key === null ? options.emptyLabel ?? "None" : label ?? String(key),
200
+ value: 0
201
+ };
202
+ part.value += amount;
203
+ parts.set(id, part);
204
+ });
205
+ });
206
+ const optionOf = (key) => field?.type === "select" ? field.options?.find((option) => String(option.value) === String(key)) : void 0;
207
+ const order = (key) => {
208
+ const index = field?.options?.findIndex((option) => String(option.value) === String(key));
209
+ return index === void 0 || index === -1 ? Infinity : index;
210
+ };
211
+ const sorted = [...parts.values()].sort((a, b) => b.value - a.value || order(a.key) - order(b.key) || a.label.localeCompare(b.label));
212
+ const shown = sorted.slice(0, 10);
213
+ const rest = sorted.slice(10);
214
+ return {
215
+ items: shown.map(({ key, label, value }) => {
216
+ const option = key !== null ? optionOf(key) : void 0;
217
+ return {
218
+ label: option?.label ?? label,
219
+ value,
220
+ key,
221
+ ...option?.tone !== void 0 && { tone: option.tone }
222
+ };
223
+ }),
224
+ total,
225
+ ...rest.length > 0 && { other: rest.reduce((sum, part) => sum + part.value, 0) }
226
+ };
227
+ }
228
+ /** The bounds of the `date-range` filter on a field in a list query, if it has them. */
229
+ function getFilterRange(query, field) {
230
+ const value = query.filter?.[field];
231
+ return isFilterRange(value) ? value : void 0;
232
+ }
233
+ //#endregion
234
+ export { AGGREGATE_COUNT, AGGREGATE_MAX_POINTS, aggregateItems, getAggregateWidgetType, getFilterRange, listPeriods, nextPeriod, parseAggregateGroup, parseAggregateMeasure, readAggregateQuery, startOfPeriod, toAggregateParams };
235
+
236
+ //# sourceMappingURL=aggregates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregates.js","names":[],"sources":["../src/aggregates.ts"],"sourcesContent":["import { type FilterRange, type ListQuery, isFilterRange, toSearchParams } from './query';\nimport type { BreakdownWidgetData, SeriesWidgetData, StatWidgetData } from './schemas';\nimport { isRecord } from './values';\nimport {\n WIDGET_BREAKDOWN_MAX_ITEMS,\n WIDGET_SERIES_PERIODS,\n type WidgetSeriesPeriod,\n} from './widgets';\n\n/**\n * The most points of a `series` that `GET /resources/{resource}/aggregate` answers: a year of\n * days. A longer range keeps its latest periods.\n */\nexport const AGGREGATE_MAX_POINTS = 366;\n\n/** The measure that counts the items, the default one. */\nexport const AGGREGATE_COUNT = 'count';\n\n/** The aggregates a list declares (`list.aggregates`, decision 0084): nothing else is aggregated. */\nexport interface ListAggregatesLike {\n /** Fields that can be summed. */\n sum?: readonly string[] | undefined;\n /** Fields whose values the items can be grouped by. */\n groupBy?: readonly string[] | undefined;\n /** Date fields whose periods the items can be grouped by. */\n dates?: readonly string[] | undefined;\n}\n\n/** What is measured of the items: how many they are, or the sum of a field. */\nexport type AggregateMeasure = { type: 'count' } | { type: 'sum'; field: string };\n\n/** How the items are grouped: by the period of a date, or by the values of a field. */\nexport type AggregateGroup =\n | { type: 'period'; period: WidgetSeriesPeriod; field: string }\n | { type: 'field'; field: string };\n\n/** A query of the aggregate endpoint, read: its measure, and its group if it has one. */\nexport interface AggregateQuery {\n measure: AggregateMeasure;\n group: AggregateGroup | null;\n}\n\n/**\n * A request of `GET /resources/{resource}/aggregate`: the filters and the search of the list,\n * the `measure` (`count` by default) and the `group`.\n */\nexport interface AggregateRequest {\n filter?: ListQuery['filter'];\n q?: string | undefined;\n /** `count`, or `sum:{field}`. Defaults to `count`. */\n measure?: string | undefined;\n /** `{day|week|month}:{date field}`, or a field of `groupBy`. */\n group?: string | null | undefined;\n}\n\n/** The built-in widget type of an answer of the aggregate endpoint. */\nexport type AggregateWidgetType = 'stat' | 'series' | 'breakdown';\n\n/** Reads a measure: `count`, or `sum:{field}`. `null` when it is neither. */\nexport function parseAggregateMeasure(value: string): AggregateMeasure | null {\n if (value === AGGREGATE_COUNT) {\n return { type: 'count' };\n }\n const field = /^sum:(.+)$/.exec(value)?.[1];\n return field !== undefined ? { type: 'sum', field } : null;\n}\n\n/**\n * Reads a group: `{period}:{date field}`, where the period is `day`, `week` or `month`, or the\n * name of a field. `null` when it is neither.\n */\nexport function parseAggregateGroup(value: string): AggregateGroup | null {\n const match = /^([^:]*):(.*)$/.exec(value);\n if (match === null) {\n return value !== '' ? { type: 'field', field: value } : null;\n }\n const [, period = '', field = ''] = match;\n return (WIDGET_SERIES_PERIODS as readonly string[]).includes(period) && field !== ''\n ? { type: 'period', period: period as WidgetSeriesPeriod, field }\n : null;\n}\n\n/** The shape of the answer to a group: a `stat` without one, a `series` or a `breakdown`. */\nexport function getAggregateWidgetType(group: AggregateGroup | null): AggregateWidgetType {\n if (group === null) {\n return 'stat';\n }\n return group.type === 'period' ? 'series' : 'breakdown';\n}\n\n/** Serializes a request of the aggregate endpoint: the filters and the search, then its own. */\nexport function toAggregateParams(request: AggregateRequest): URLSearchParams {\n const params = toSearchParams({\n ...(request.filter !== undefined && { filter: request.filter }),\n ...(request.q !== undefined && { q: request.q }),\n });\n params.set('measure', request.measure ?? AGGREGATE_COUNT);\n if (request.group !== undefined && request.group !== null && request.group !== '') {\n params.set('group', request.group);\n }\n return params;\n}\n\n/** An aggregate query as a backend reads it: valid, or the messages of its invalid parameters. */\nexport type ReadAggregateQueryResult =\n | { query: AggregateQuery; errors?: undefined }\n | { query?: undefined; errors: Record<string, string[]> };\n\n/**\n * Reads `measure` and `group` of `GET /resources/{resource}/aggregate` against the aggregates of\n * the list: the reference of how a backend validates them. `measure` defaults to `count`; a\n * `sum:` names a field of `sum`, a period names a field of `dates`, and another group a field of\n * `groupBy`. Invalid parameters are a `422`, with `errors` keyed by parameter. The filters and the\n * search are read as the list reads them.\n */\nexport function readAggregateQuery(\n params: URLSearchParams,\n aggregates: ListAggregatesLike,\n): ReadAggregateQueryResult {\n const errors: Record<string, string[]> = {};\n const rawMeasure = params.get('measure') ?? AGGREGATE_COUNT;\n const measure = parseAggregateMeasure(rawMeasure);\n if (measure === null) {\n errors.measure = ['The measure must be `count` or `sum:{field}`.'];\n } else if (measure.type === 'sum' && !(aggregates.sum ?? []).includes(measure.field)) {\n errors.measure = [`The field \\`${measure.field}\\` can't be summed.`];\n }\n\n const rawGroup = params.get('group');\n let group: AggregateGroup | null = null;\n if (rawGroup !== null) {\n group = parseAggregateGroup(rawGroup);\n if (group === null) {\n errors.group = ['The group must be `{day|week|month}:{date field}` or a field.'];\n } else if (group.type === 'period' && !(aggregates.dates ?? []).includes(group.field)) {\n errors.group = [`The field \\`${group.field}\\` isn't a date that can be grouped.`];\n } else if (group.type === 'field' && !(aggregates.groupBy ?? []).includes(group.field)) {\n errors.group = [`The items can't be grouped by the field \\`${group.field}\\`.`];\n }\n }\n\n if (Object.keys(errors).length > 0 || measure === null) {\n return { errors };\n }\n return { query: { measure, group } };\n}\n\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}/;\n\n/** The day of a `date` or `datetime` value, as the backend writes it: `null` without one. */\nfunction dayOf(value: unknown): string | null {\n return typeof value === 'string' && DAY.test(value) ? value.slice(0, 10) : null;\n}\n\nfunction toUtc(day: string): Date {\n return new Date(`${day.slice(0, 10)}T00:00:00Z`);\n}\n\nfunction fromUtc(date: Date): string {\n return date.toISOString().slice(0, 10);\n}\n\n/**\n * The first day of the period of a day: the day itself, the Monday of its week (ISO 8601), or the\n * first day of its month. `2026-10-08` is in the week of `2026-10-05`.\n */\nexport function startOfPeriod(day: string, period: WidgetSeriesPeriod): string {\n const date = toUtc(day);\n if (period === 'week') {\n date.setUTCDate(date.getUTCDate() - ((date.getUTCDay() + 6) % 7));\n } else if (period === 'month') {\n date.setUTCDate(1);\n }\n return fromUtc(date);\n}\n\n/** The first day of the period after the one that starts on `start`. */\nexport function nextPeriod(start: string, period: WidgetSeriesPeriod): string {\n const date = toUtc(start);\n if (period === 'month') {\n date.setUTCMonth(date.getUTCMonth() + 1, 1);\n } else {\n date.setUTCDate(date.getUTCDate() + (period === 'week' ? 7 : 1));\n }\n return fromUtc(date);\n}\n\n/**\n * The first days of the periods from the one of `from` to the one of `to`, both included: at most\n * `max` of them, the latest. Empty when `to` is before `from`.\n */\nexport function listPeriods(\n from: string,\n to: string,\n period: WidgetSeriesPeriod,\n max: number = AGGREGATE_MAX_POINTS,\n): string[] {\n const last = startOfPeriod(to, period);\n const periods: string[] = [];\n for (\n let start = startOfPeriod(from, period);\n start <= last;\n start = nextPeriod(start, period)\n ) {\n periods.push(start);\n if (periods.length > max) {\n periods.shift();\n }\n }\n return periods;\n}\n\n/** The fields an aggregate reads, as the definition declares them. */\nexport interface AggregateField {\n name: string;\n type: string;\n options?: readonly { value: unknown; label: string; tone?: string | undefined }[] | undefined;\n}\n\nexport interface AggregateItemsOptions {\n /** The fields of the resource: the options of a `select` give the labels and the tones. */\n fields: readonly AggregateField[];\n /**\n * The bounds of the `date-range` filter of the query on the date of a period group, whose id is\n * the name of that field: the range of the series. Without a bound, the series starts on the\n * period of the first item, or ends on the period of the last.\n */\n range?: FilterRange | undefined;\n /** The label of the part of the items without a value. Defaults to `None`. */\n emptyLabel?: string;\n}\n\n/** The value of an item, as a key of a part: the id of a reference, `null` when it is empty. */\nfunction keysOf(value: unknown): { key: string | number | boolean | null; label?: string }[] {\n if (Array.isArray(value)) {\n const keys = value.flatMap((entry) => keysOf(entry).filter(({ key }) => key !== null));\n return keys.length > 0 ? keys : [{ key: null }];\n }\n if (typeof value === 'string') {\n return [{ key: value === '' ? null : value }];\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return [{ key: value }];\n }\n // A reference to an item, of a `relation` (`{ \"id\", \"label\" }`)\n if (isRecord(value) && (typeof value.id === 'string' || typeof value.id === 'number')) {\n return [\n {\n key: value.id,\n ...(typeof value.label === 'string' && { label: value.label }),\n },\n ];\n }\n return [{ key: null }];\n}\n\n/** The amount of a value that is summed: a number, or the amount of a `money` value. */\nfunction amountOf(value: unknown): number {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n if (isRecord(value) && typeof value.amount === 'number' && Number.isFinite(value.amount)) {\n return value.amount;\n }\n return 0;\n}\n\n/**\n * Aggregates items that a list query already filtered: the reference of what\n * `GET /resources/{resource}/aggregate` answers (decision 0084).\n *\n * - Without a group: a `stat`, the count or the sum of the items.\n * - By a period: a `series`, one point per period from its range, 0 for the periods without items.\n * The range is the bounds of the `date-range` filter on the date (`range`), and without a bound,\n * the period of the first or the last item; at most `AGGREGATE_MAX_POINTS` periods, the latest.\n * Items without a date are left out. `total` is the sum of the points.\n * - By a field: a `breakdown`, a part per value, the largest first, at most\n * `WIDGET_BREAKDOWN_MAX_ITEMS`, the rest in `other`. An item with several values counts in each\n * of their parts, once in `total`; one without a value counts in the part of `key: null`. The\n * options of a `select` give their labels and tones, a reference its `label`.\n *\n * A sum of `money` values adds their amounts, in minor units.\n */\nexport function aggregateItems(\n items: readonly Record<string, unknown>[],\n query: AggregateQuery,\n options: AggregateItemsOptions,\n): StatWidgetData | SeriesWidgetData | BreakdownWidgetData {\n const { measure, group } = query;\n const measureOf = (item: Record<string, unknown>): number =>\n measure.type === 'count' ? 1 : amountOf(item[measure.field]);\n const total = items.reduce((sum, item) => sum + measureOf(item), 0);\n if (group === null) {\n return { value: total };\n }\n if (group.type === 'period') {\n const values = new Map<string, number>();\n const days: string[] = [];\n items.forEach((item) => {\n const day = dayOf(item[group.field]);\n if (day === null) {\n return;\n }\n days.push(day);\n const start = startOfPeriod(day, group.period);\n values.set(start, (values.get(start) ?? 0) + measureOf(item));\n });\n days.sort();\n const bound = (key: 'from' | 'to') => {\n const value = options.range?.[key];\n return value !== undefined && value !== '' ? dayOf(String(value)) : null;\n };\n const from = bound('from') ?? days[0] ?? bound('to');\n const to = bound('to') ?? days.at(-1) ?? bound('from');\n const points =\n from !== null && to !== null\n ? listPeriods(from, to, group.period).map((date) => ({\n date,\n value: values.get(date) ?? 0,\n }))\n : [];\n return {\n period: group.period,\n points,\n total: points.reduce((sum, point) => sum + point.value, 0),\n };\n }\n const field = options.fields.find((candidate) => candidate.name === group.field);\n const parts = new Map<\n string,\n { key: string | number | boolean | null; label: string; value: number }\n >();\n items.forEach((item) => {\n const amount = measureOf(item);\n const seen = new Set<string>();\n keysOf(item[group.field]).forEach(({ key, label }) => {\n const id = JSON.stringify(key);\n if (seen.has(id)) {\n return;\n }\n seen.add(id);\n const part = parts.get(id) ?? {\n key,\n label: key === null ? (options.emptyLabel ?? 'None') : (label ?? String(key)),\n value: 0,\n };\n part.value += amount;\n parts.set(id, part);\n });\n });\n const optionOf = (key: unknown) =>\n field?.type === 'select'\n ? field.options?.find((option) => String(option.value) === String(key))\n : undefined;\n const order = (key: unknown) => {\n const index = field?.options?.findIndex((option) => String(option.value) === String(key));\n return index === undefined || index === -1 ? Infinity : index;\n };\n // The largest first; equal parts in the order of the options, then of their labels\n const sorted = [...parts.values()].sort(\n (a, b) =>\n b.value - a.value || order(a.key) - order(b.key) || a.label.localeCompare(b.label),\n );\n const shown = sorted.slice(0, WIDGET_BREAKDOWN_MAX_ITEMS);\n const rest = sorted.slice(WIDGET_BREAKDOWN_MAX_ITEMS);\n return {\n items: shown.map(({ key, label, value }) => {\n const option = key !== null ? optionOf(key) : undefined;\n return {\n label: option?.label ?? label,\n value,\n key,\n ...(option?.tone !== undefined && { tone: option.tone }),\n };\n }),\n total,\n ...(rest.length > 0 && { other: rest.reduce((sum, part) => sum + part.value, 0) }),\n };\n}\n\n/** The bounds of the `date-range` filter on a field in a list query, if it has them. */\nexport function getFilterRange(\n query: Pick<ListQuery, 'filter'>,\n field: string,\n): FilterRange | undefined {\n const value = query.filter?.[field];\n return isFilterRange(value) ? value : undefined;\n}\n"],"mappings":";;;;;;;;AAaA,IAAa,uBAAuB;;AAGpC,IAAa,kBAAkB;;AA2C/B,SAAgB,sBAAsB,OAAwC;CAC1E,IAAI,UAAA,SACA,OAAO,EAAE,MAAM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