@panneau/protocol 5.0.0-alpha.39 → 5.0.0-alpha.41
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/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +29 -7
- package/dist/conformance/index.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +176 -20
- package/dist/lint.js.map +1 -1
- package/dist/mock/index.js +2 -2
- package/dist/mock/index.js.map +1 -1
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +3 -1
- package/dist/openapi.js.map +1 -1
- package/dist/periods.d.ts +12 -0
- package/dist/periods.d.ts.map +1 -1
- package/dist/periods.js +38 -1
- package/dist/periods.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/schemas/definition.d.ts +930 -2
- package/dist/schemas/definition.d.ts.map +1 -1
- package/dist/schemas/index.d.ts +4158 -4
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +14 -3
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/resource.d.ts +464 -0
- package/dist/schemas/resource.d.ts.map +1 -1
- package/dist/schemas/theme.d.ts +2 -2
- package/dist/schemas/widget.d.ts +4210 -0
- package/dist/schemas/widget.d.ts.map +1 -1
- package/dist/schemas/widget.js +184 -17
- package/dist/schemas/widget.js.map +1 -1
- package/dist/widgets.d.ts +158 -7
- package/dist/widgets.d.ts.map +1 -1
- package/dist/widgets.js +469 -40
- package/dist/widgets.js.map +1 -1
- package/package.json +1 -1
- package/schema/boot.schema.json +459 -0
- package/schema/definition.schema.json +459 -0
- package/schema/openapi.json +976 -5
package/dist/index.js
CHANGED
|
@@ -11,9 +11,9 @@ import { checkRules, checkValues } from "./rules.js";
|
|
|
11
11
|
import { getImageUrl, getItemImageField, getMediaLibraries } from "./libraries.js";
|
|
12
12
|
import { ITEM_TYPE_KEY, getCreatableTypes, getItemType, getResourceType, getTypeFields, hasResourceTypes } from "./resourceTypes.js";
|
|
13
13
|
import { fromSearchParams, isCursorPage, isFilterRange, matchesFilterRange, toSearchParams } from "./query.js";
|
|
14
|
-
import { 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 } from "./widgets.js";
|
|
14
|
+
import { BUILT_IN_WIDGET_TYPES, GROUPED_WIDGET_TYPES, RESOURCE_WIDGET_TYPES, WIDGET_BREAKDOWN_MAX_ITEMS, WIDGET_FORMAT_CURRENCY_DISPLAYS, WIDGET_FORMAT_NOTATIONS, WIDGET_FORMAT_SIGN_DISPLAYS, WIDGET_FORMAT_STYLES, WIDGET_FORMAT_UNITS, WIDGET_FORMAT_UNIT_DISPLAYS, WIDGET_GOOD_WHEN, WIDGET_LIST_MAX_ITEMS, WIDGET_METRIC_MAX_PARTS, WIDGET_RESERVED_QUERY_PARAMS, WIDGET_SERIES_MAX_SERIES, WIDGET_SERIES_PERIODS, WIDGET_SOURCES_MAX, WIDGET_TABLE_ALIGNS, WIDGET_TABLE_MAX_COLUMNS, WIDGET_TABLE_MAX_ROWS, checkWidgetData, followsList, followsPeriod, getChangeTone, getWidgetAggregates, getWidgetChange, getWidgetResource, getWidgetSources, isBuiltInWidgetType, isCombinedWidget, isWidgetDataEmpty, isWidgetUnit, readWidgetFormat, readsResources } from "./widgets.js";
|
|
15
15
|
import { AGGREGATE_COUNT, AGGREGATE_MAX_POINTS, aggregateItems, getAggregateWidgetType, getFilterRange, listPeriods, nextPeriod, parseAggregateGroup, parseAggregateMeasure, readAggregateQuery, startOfPeriod, toAggregateParams } from "./aggregates.js";
|
|
16
|
-
import { OVERVIEW_PERIODS, PERIOD_PARAM, findPeriodOption, getDefaultPeriod, getPeriodRange, isDay, isOverviewPeriod, localDay, readPeriodOption } from "./periods.js";
|
|
16
|
+
import { OVERVIEW_PERIODS, PERIOD_PARAM, findPeriodOption, getDefaultPeriod, getPeriodRange, getPreviousRange, isDay, isOverviewPeriod, localDay, readPeriodOption } from "./periods.js";
|
|
17
17
|
import { DASHBOARD_COMPONENT, HOME_PAGE, getDashboardPages, getDashboardPeriod, getDashboardWidgets, getSummaryPeriodFilter, getSummaryResources, getSummaryWidgets, readWidgetDataQuery, toWidgetDataParams } from "./dashboards.js";
|
|
18
18
|
import { lintDefinition } from "./lint.js";
|
|
19
19
|
import { SEARCH_DEFAULT_LIMIT, SEARCH_MAX_LENGTH, SEARCH_MAX_LIMIT, SEARCH_MIN_LENGTH, isSearchableResource, readSearchQuery, toSearchQueryParams } from "./search.js";
|
|
@@ -25,7 +25,7 @@ import { AddressSettings, BlockType, DateRangeSettings, DurationSettings, Field,
|
|
|
25
25
|
import { LayoutNode } from "./schemas/layout.js";
|
|
26
26
|
import { Action, ActionConfirm, ActionPlacement, ActionScope } from "./schemas/action.js";
|
|
27
27
|
import { Column, Filter, ListAggregates, ListCalendar, ListDefinition } from "./schemas/list.js";
|
|
28
|
-
import { BreakdownWidgetData, BreakdownWidgetItem, ListWidgetData, ListWidgetItem, OverviewPeriod, SeriesPoint, SeriesWidgetData, StatWidgetData, Widget, WidgetBadge, WidgetSettings, widgetDataSchemas } from "./schemas/widget.js";
|
|
28
|
+
import { BreakdownWidgetData, BreakdownWidgetItem, ListWidgetData, ListWidgetItem, MetricWidgetData, OverviewPeriod, SeriesPoint, SeriesWidgetData, SeriesWidgetSeries, StatWidgetData, TableWidgetCell, TableWidgetColumn, TableWidgetData, TableWidgetRow, Widget, WidgetAlert, WidgetAlertSettings, WidgetBadge, WidgetNumberFormat, WidgetRowSource, WidgetSeriesSource, WidgetSettings, widgetDataSchemas } from "./schemas/widget.js";
|
|
29
29
|
import { Resource, ResourceFeatures, ResourceSummary, ResourceType, SummaryPeriod } from "./schemas/resource.js";
|
|
30
30
|
import { DefinitionTheme, Theme, ThemeFont, ThemeFontFace, ThemeFontStylesheet, ThemeTokens, ToneInput, ToneValues } from "./schemas/theme.js";
|
|
31
31
|
import { Auth, AuthProvider, AuthToken, ContextOption, ContextParam, Definition, DefinitionContext, InterfaceLocale, MenuItem, Page, Uploads, User } from "./schemas/definition.js";
|
|
@@ -34,4 +34,4 @@ import { BootConfig } from "./schemas/boot.js";
|
|
|
34
34
|
import { createSchemaRegistry, namedSchemas } from "./schemas/index.js";
|
|
35
35
|
import { validate, validateBootConfig, validateDefinition } from "./validate.js";
|
|
36
36
|
import { createBootConfigJsonSchema, createComponentSchemas, createDefinitionJsonSchema, createOpenApiDocument, createThemeJsonSchema } from "./openapi.js";
|
|
37
|
-
export { ADDRESS_PARTS, AGGREGATE_COUNT, AGGREGATE_MAX_POINTS, AUTH_ERROR_CODES, AUTH_ERROR_PARAM, AUTH_PAGE_PATHS, Abilities, Action, ActionConfirm, ActionItemResult, ActionPlacement, ActionRequest, ActionResult, ActionRun, ActionRunResponse, ActionScope, AddressSettings, AddressValue, Auth, AuthProvider, AuthToken, BOOT_CONFIG_ELEMENT_ID, BUILT_IN_ACTIONS, BUILT_IN_FIELD_TYPES, BUILT_IN_ITEM_ACTIONS, BUILT_IN_LAYOUT_NODE_TYPES, BUILT_IN_LINK_ACTIONS, BUILT_IN_LINK_TYPES, BUILT_IN_LIST_LAYOUTS, BUILT_IN_WIDGET_TYPES, BlockType, BootConfig, BreakdownWidgetData, BreakdownWidgetItem, CONTEXT_HEADER, CONTEXT_PROBLEM_TYPE, CURRENCY_CODES, Column, Condition, ContextOption, ContextOptionsResponse, ContextParam, CursorPagination, DASHBOARD_COMPONENT, DATE_RANGE_OPEN_BOUNDS, DEFAULT_ADDRESS_REQUIRED_PARTS, DURATION_UNITS, DateRangeSettings, DateRangeValue, Definition, DefinitionContext, DefinitionTheme, DurationSettings, EMAIL_UNVERIFIED_PROBLEM_TYPE, EmbedResponse, EmbedValue, Field, FieldCheckRequest, FieldCheckResponse, Filter, GROUPED_WIDGET_TYPES, HOME_PAGE, IDS_FILTER, IDS_FILTER_LIMIT, ITEM_ACTION_ABILITIES, ITEM_TYPE_KEY, Id, InterfaceLocale, Item, ItemResponse, LayoutNode, LinkSettings, LinkTypeSetting, LinkValue, ListAggregates, ListCalendar, ListDefinition, ListResponse, ListWidgetData, ListWidgetItem, LocationValue, MediaInfo, MediaItem, MediaReference, MediaTransform, MenuItem, MoneySettings, MoneyValue, OVERVIEW_PERIODS, Option, OverviewPeriod, PASSWORD_CONFIRMATION_PROBLEM_TYPE, PERIOD_PARAM, PORTABLE_RULES, POSTAL_CODE_COUNTRIES, PROBLEM_CONTENT_TYPE, PROTOCOL_VERSION, Page, Pagination, Passkey, PreviewResponse, Problem, RESERVED_ROUTE_SEGMENTS, RESOURCE_WIDGET_TYPES, RICH_TEXT_STYLE_ELEMENTS, RecoveryCodes, Resource, ResourceFeatures, ResourceSummary, ResourceType, RichTextSettings, RichTextStyle, RouteReference, Rule, SEARCH_DEFAULT_LIMIT, SEARCH_MAX_LENGTH, SEARCH_MAX_LIMIT, SEARCH_MIN_LENGTH, SearchResponse, Selection, SeriesPoint, SeriesWidgetData, Session, StatWidgetData, StoredFile, SummaryPeriod, TWO_FACTOR_REQUIRED_PROBLEM_TYPE, Theme, ThemeFont, ThemeFontFace, ThemeFontStylesheet, ThemeTokens, ToneInput, ToneValues, TwoFactorChallenge, TwoFactorSetup, TwoFactorStatus, UNDO_LIMIT, Upload, UploadReference, UploadResponse, UploadSignRequest, UploadSignResponse, Uploads, User, WIDGET_BREAKDOWN_MAX_ITEMS, WIDGET_LIST_MAX_ITEMS, WIDGET_RESERVED_QUERY_PARAMS, WIDGET_SERIES_PERIODS, WebAuthnOptions, Widget, WidgetBadge, WidgetSettings, aggregateItems, checkRules, checkValues, checkWidgetData, contextBefore, createBootConfigJsonSchema, createComponentSchemas, createDefinitionJsonSchema, createOpenApiDocument, createSchemaRegistry, createThemeJsonSchema, evaluateCondition, findPeriodOption, followsList, followsPeriod, formatContextHeader, fromMinorUnits, fromSearchParams, getAddressRequiredParts, getAggregateWidgetType, getCreatableTypes, getCurrencyDigits, getDashboardPages, getDashboardPeriod, getDashboardWidgets, getDefaultPeriod, getFilterRange, getImageUrl, getItemImageField, getItemType, getLinkNewTab, getLinkTypes, getMediaLibraries, getNestedShape, getPeriodRange, getResourceType, getSummaryPeriodFilter, getSummaryResources, getSummaryWidgets, getTypeFields, getValue, getWidgetResource, hasResourceTypes, isAddressPart, isBuiltInFieldType, isBuiltInItemAction, isBuiltInLink, isBuiltInLinkType, isBuiltInWidgetType, isCompoundField, isCurrencyCode, isCursorPage, isDay, isExternalUrl, isFilled, isFilterRange, isOverviewPeriod, isPostalCode, isProblem, isSearchableResource, lintDefinition, listPeriods, localDay, matchesFilterRange, matchesRatio, mergeThemes, namedSchemas, nextPeriod, normalizePostalCode, parseAggregateGroup, parseAggregateMeasure, parseContextHeader, parseRatio, readAggregateQuery, readPeriodOption, readSearchQuery, readWidgetDataQuery, renderedCropSize, resolveLinkNewTab, startOfPeriod, toAggregateParams, toMinorUnits, toSearchParams, toSearchQueryParams, toWidgetDataParams, validate, validateBootConfig, validateDefinition, widgetDataSchemas };
|
|
37
|
+
export { ADDRESS_PARTS, AGGREGATE_COUNT, AGGREGATE_MAX_POINTS, AUTH_ERROR_CODES, AUTH_ERROR_PARAM, AUTH_PAGE_PATHS, Abilities, Action, ActionConfirm, ActionItemResult, ActionPlacement, ActionRequest, ActionResult, ActionRun, ActionRunResponse, ActionScope, AddressSettings, AddressValue, Auth, AuthProvider, AuthToken, BOOT_CONFIG_ELEMENT_ID, BUILT_IN_ACTIONS, BUILT_IN_FIELD_TYPES, BUILT_IN_ITEM_ACTIONS, BUILT_IN_LAYOUT_NODE_TYPES, BUILT_IN_LINK_ACTIONS, BUILT_IN_LINK_TYPES, BUILT_IN_LIST_LAYOUTS, BUILT_IN_WIDGET_TYPES, BlockType, BootConfig, BreakdownWidgetData, BreakdownWidgetItem, CONTEXT_HEADER, CONTEXT_PROBLEM_TYPE, CURRENCY_CODES, Column, Condition, ContextOption, ContextOptionsResponse, ContextParam, CursorPagination, DASHBOARD_COMPONENT, DATE_RANGE_OPEN_BOUNDS, DEFAULT_ADDRESS_REQUIRED_PARTS, DURATION_UNITS, DateRangeSettings, DateRangeValue, Definition, DefinitionContext, DefinitionTheme, DurationSettings, EMAIL_UNVERIFIED_PROBLEM_TYPE, EmbedResponse, EmbedValue, Field, FieldCheckRequest, FieldCheckResponse, Filter, GROUPED_WIDGET_TYPES, HOME_PAGE, IDS_FILTER, IDS_FILTER_LIMIT, ITEM_ACTION_ABILITIES, ITEM_TYPE_KEY, Id, InterfaceLocale, Item, ItemResponse, LayoutNode, LinkSettings, LinkTypeSetting, LinkValue, ListAggregates, ListCalendar, ListDefinition, ListResponse, ListWidgetData, ListWidgetItem, LocationValue, MediaInfo, MediaItem, MediaReference, MediaTransform, MenuItem, MetricWidgetData, MoneySettings, MoneyValue, OVERVIEW_PERIODS, Option, OverviewPeriod, PASSWORD_CONFIRMATION_PROBLEM_TYPE, PERIOD_PARAM, PORTABLE_RULES, POSTAL_CODE_COUNTRIES, PROBLEM_CONTENT_TYPE, PROTOCOL_VERSION, Page, Pagination, Passkey, PreviewResponse, Problem, RESERVED_ROUTE_SEGMENTS, RESOURCE_WIDGET_TYPES, RICH_TEXT_STYLE_ELEMENTS, RecoveryCodes, Resource, ResourceFeatures, ResourceSummary, ResourceType, RichTextSettings, RichTextStyle, RouteReference, Rule, SEARCH_DEFAULT_LIMIT, SEARCH_MAX_LENGTH, SEARCH_MAX_LIMIT, SEARCH_MIN_LENGTH, SearchResponse, Selection, SeriesPoint, SeriesWidgetData, SeriesWidgetSeries, Session, StatWidgetData, StoredFile, SummaryPeriod, TWO_FACTOR_REQUIRED_PROBLEM_TYPE, TableWidgetCell, TableWidgetColumn, TableWidgetData, TableWidgetRow, Theme, ThemeFont, ThemeFontFace, ThemeFontStylesheet, ThemeTokens, ToneInput, ToneValues, TwoFactorChallenge, TwoFactorSetup, TwoFactorStatus, UNDO_LIMIT, Upload, UploadReference, UploadResponse, UploadSignRequest, UploadSignResponse, Uploads, User, WIDGET_BREAKDOWN_MAX_ITEMS, WIDGET_FORMAT_CURRENCY_DISPLAYS, WIDGET_FORMAT_NOTATIONS, WIDGET_FORMAT_SIGN_DISPLAYS, WIDGET_FORMAT_STYLES, WIDGET_FORMAT_UNITS, WIDGET_FORMAT_UNIT_DISPLAYS, WIDGET_GOOD_WHEN, WIDGET_LIST_MAX_ITEMS, WIDGET_METRIC_MAX_PARTS, WIDGET_RESERVED_QUERY_PARAMS, WIDGET_SERIES_MAX_SERIES, WIDGET_SERIES_PERIODS, WIDGET_SOURCES_MAX, WIDGET_TABLE_ALIGNS, WIDGET_TABLE_MAX_COLUMNS, WIDGET_TABLE_MAX_ROWS, WebAuthnOptions, Widget, WidgetAlert, WidgetAlertSettings, WidgetBadge, WidgetNumberFormat, WidgetRowSource, WidgetSeriesSource, WidgetSettings, aggregateItems, checkRules, checkValues, checkWidgetData, contextBefore, createBootConfigJsonSchema, createComponentSchemas, createDefinitionJsonSchema, createOpenApiDocument, createSchemaRegistry, createThemeJsonSchema, evaluateCondition, findPeriodOption, followsList, followsPeriod, formatContextHeader, fromMinorUnits, fromSearchParams, getAddressRequiredParts, getAggregateWidgetType, getChangeTone, getCreatableTypes, getCurrencyDigits, getDashboardPages, getDashboardPeriod, getDashboardWidgets, getDefaultPeriod, getFilterRange, getImageUrl, getItemImageField, getItemType, getLinkNewTab, getLinkTypes, getMediaLibraries, getNestedShape, getPeriodRange, getPreviousRange, getResourceType, getSummaryPeriodFilter, getSummaryResources, getSummaryWidgets, getTypeFields, getValue, getWidgetAggregates, getWidgetChange, getWidgetResource, getWidgetSources, hasResourceTypes, isAddressPart, isBuiltInFieldType, isBuiltInItemAction, isBuiltInLink, isBuiltInLinkType, isBuiltInWidgetType, isCombinedWidget, isCompoundField, isCurrencyCode, isCursorPage, isDay, isExternalUrl, isFilled, isFilterRange, isOverviewPeriod, isPostalCode, isProblem, isSearchableResource, isWidgetDataEmpty, isWidgetUnit, lintDefinition, listPeriods, localDay, matchesFilterRange, matchesRatio, mergeThemes, namedSchemas, nextPeriod, normalizePostalCode, parseAggregateGroup, parseAggregateMeasure, parseContextHeader, parseRatio, readAggregateQuery, readPeriodOption, readSearchQuery, readWidgetDataQuery, readWidgetFormat, readsResources, renderedCropSize, resolveLinkNewTab, startOfPeriod, toAggregateParams, toMinorUnits, toSearchParams, toSearchQueryParams, toWidgetDataParams, validate, validateBootConfig, validateDefinition, widgetDataSchemas };
|
package/dist/lint.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,eAAe,EAMlB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,eAAe,EAMlB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAsQlD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,eAAe,GAAG,eAAe,EAAE,CAuF7E"}
|
package/dist/lint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITEM_TYPE_KEY } from "./resourceTypes.js";
|
|
2
|
-
import { GROUPED_WIDGET_TYPES, RESOURCE_WIDGET_TYPES, WIDGET_RESERVED_QUERY_PARAMS, getWidgetResource, isBuiltInWidgetType } from "./widgets.js";
|
|
2
|
+
import { GROUPED_WIDGET_TYPES, RESOURCE_WIDGET_TYPES, WIDGET_RESERVED_QUERY_PARAMS, getWidgetResource, getWidgetSources, isBuiltInWidgetType } from "./widgets.js";
|
|
3
3
|
import { parseAggregateGroup, parseAggregateMeasure } from "./aggregates.js";
|
|
4
4
|
import { DASHBOARD_COMPONENT, HOME_PAGE, getSummaryPeriodFilter } from "./dashboards.js";
|
|
5
5
|
//#region src/lint.ts
|
|
@@ -313,8 +313,130 @@ var RESOURCE_SETTINGS = [
|
|
|
313
313
|
"query",
|
|
314
314
|
"measure",
|
|
315
315
|
"group",
|
|
316
|
-
"target"
|
|
316
|
+
"target",
|
|
317
|
+
"points",
|
|
318
|
+
"by",
|
|
319
|
+
"split"
|
|
317
320
|
];
|
|
321
|
+
/** The settings of a built-in widget that only some types have (decision 0089), and those types. */
|
|
322
|
+
var TYPED_SETTINGS = {
|
|
323
|
+
goodWhen: ["metric", "table"],
|
|
324
|
+
points: ["metric", "table"],
|
|
325
|
+
by: ["metric"],
|
|
326
|
+
split: ["series"],
|
|
327
|
+
sources: ["series"],
|
|
328
|
+
stacked: ["series"],
|
|
329
|
+
rows: ["table"]
|
|
330
|
+
};
|
|
331
|
+
/** A `measure` of the aggregates of a list: `count`, or the `sum:` of a field of its `sum`. */
|
|
332
|
+
function checkMeasure(value, resource, path, issues) {
|
|
333
|
+
if (value === void 0) return;
|
|
334
|
+
const measure = typeof value === "string" ? parseAggregateMeasure(value) : null;
|
|
335
|
+
if (measure === null) issues.push({
|
|
336
|
+
path,
|
|
337
|
+
message: "The measure must be `count` or `sum:{field}`."
|
|
338
|
+
});
|
|
339
|
+
else if (measure.type === "sum" && !(resource.list?.aggregates?.sum ?? []).includes(measure.field)) issues.push({
|
|
340
|
+
path,
|
|
341
|
+
message: `The list of \`${resource.id}\` can't sum \`${measure.field}\`: it isn't in the \`sum\` of its aggregates.`
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
/** A group on the period of a date of the aggregates of a list: `day:created_at`. */
|
|
345
|
+
function checkPeriodGroup(value, resource, path, issues, what) {
|
|
346
|
+
const group = typeof value === "string" ? parseAggregateGroup(value) : null;
|
|
347
|
+
if (group?.type !== "period") issues.push({
|
|
348
|
+
path,
|
|
349
|
+
message: `${what} needs a period of a date: \`day:created_at\`.`
|
|
350
|
+
});
|
|
351
|
+
else if (!(resource.list?.aggregates?.dates ?? []).includes(group.field)) issues.push({
|
|
352
|
+
path,
|
|
353
|
+
message: `The list of \`${resource.id}\` can't group by \`${group.field}\`: it isn't in the \`dates\` of its aggregates.`
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/** A field of the `groupBy` of the aggregates of a list. */
|
|
357
|
+
function checkGroupByField(value, resource, path, issues) {
|
|
358
|
+
if (typeof value !== "string" || !(resource.list?.aggregates?.groupBy ?? []).includes(value)) issues.push({
|
|
359
|
+
path,
|
|
360
|
+
message: `The list of \`${resource.id}\` can't group by \`${String(value)}\`: it isn't in the \`groupBy\` of its aggregates.`
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/** The filters of a query of a widget or of a source: filters of the list, never the paging. */
|
|
364
|
+
function checkQuery(query, resource, path, issues) {
|
|
365
|
+
if (query === null || typeof query !== "object") return;
|
|
366
|
+
const filters = new Set((resource.list?.filters ?? []).map((filter) => filter.id));
|
|
367
|
+
Object.keys(query).forEach((key) => {
|
|
368
|
+
const filter = FILTER_PARAM.exec(key)?.[1];
|
|
369
|
+
if (WIDGET_RESERVED_QUERY_PARAMS.includes(key)) issues.push({
|
|
370
|
+
path: `${path}.${key}`,
|
|
371
|
+
message: `The client sets \`${key}\`.`
|
|
372
|
+
});
|
|
373
|
+
else if (filter !== void 0 && !filters.has(filter)) issues.push({
|
|
374
|
+
path: `${path}.${key}`,
|
|
375
|
+
message: `The list of \`${resource.id}\` has no filter \`${filter}\`.`
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
/** `period`: a `date-range` filter of the list of the resource. */
|
|
380
|
+
function checkPeriodFilter(period, resource, path, issues) {
|
|
381
|
+
if (typeof period === "string" && !(resource.list?.filters ?? []).some((filter) => filter.id === period && filter.type === "date-range")) issues.push({
|
|
382
|
+
path,
|
|
383
|
+
message: `The list of \`${resource.id}\` has no \`date-range\` filter \`${period}\`.`
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* The `sources` of a `series` or the `rows` of a `table` (decision 0089): each on a resource that
|
|
388
|
+
* exists and declares aggregates, with a measure, a group on a period of a date (required for a
|
|
389
|
+
* line of a series), a period and a query, and an alert, that its list declares.
|
|
390
|
+
*/
|
|
391
|
+
function checkSources(definition, widget, path, issues, hasPeriod) {
|
|
392
|
+
const settings = widget.settings ?? {};
|
|
393
|
+
const key = widget.type === "series" ? "sources" : "rows";
|
|
394
|
+
const entries = settings[key];
|
|
395
|
+
if (!Array.isArray(entries)) return;
|
|
396
|
+
const sources = getWidgetSources(widget);
|
|
397
|
+
const periods = new Set(sources.flatMap((source) => {
|
|
398
|
+
const group = source.group !== null ? parseAggregateGroup(source.group) : null;
|
|
399
|
+
return group?.type === "period" ? [group.period] : [];
|
|
400
|
+
}));
|
|
401
|
+
if (periods.size > 1) issues.push({
|
|
402
|
+
path: `${path}.settings.${key}`,
|
|
403
|
+
message: `Its ${widget.type === "series" ? "lines" : "trends"} have different periods (${[...periods].join(", ")}): they share one.`
|
|
404
|
+
});
|
|
405
|
+
entries.forEach((entry, index) => {
|
|
406
|
+
const sourcePath = `${path}.settings.${key}.${index}`;
|
|
407
|
+
const source = sources[index];
|
|
408
|
+
if (source === void 0 || entry === null || typeof entry !== "object") return;
|
|
409
|
+
const raw = entry;
|
|
410
|
+
const resource = definition.resources.find((candidate) => candidate.id === source.resource);
|
|
411
|
+
if (resource === void 0) {
|
|
412
|
+
issues.push({
|
|
413
|
+
path: `${sourcePath}.resource`,
|
|
414
|
+
message: `No resource \`${source.resource}\`.`
|
|
415
|
+
});
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (resource.list?.aggregates === void 0) {
|
|
419
|
+
issues.push({
|
|
420
|
+
path: `${sourcePath}.resource`,
|
|
421
|
+
message: `The list of \`${resource.id}\` declares no \`aggregates\`.`
|
|
422
|
+
});
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
checkMeasure(raw.measure, resource, `${sourcePath}.measure`, issues);
|
|
426
|
+
const groupKey = widget.type === "series" ? "group" : "points";
|
|
427
|
+
if (widget.type === "series" || source.group !== null) checkPeriodGroup(source.group, resource, `${raw[groupKey] !== void 0 ? sourcePath : `${path}.settings`}.${groupKey}`, issues, widget.type === "series" ? "A line of a `series`" : "The trend of a row");
|
|
428
|
+
if (typeof source.period === "string") {
|
|
429
|
+
if (!hasPeriod && raw.period !== void 0) issues.push({
|
|
430
|
+
path: `${raw.period !== void 0 ? sourcePath : `${path}.settings`}.period`,
|
|
431
|
+
message: "Its overview has no `period`."
|
|
432
|
+
});
|
|
433
|
+
checkPeriodFilter(source.period, resource, `${raw.period !== void 0 ? sourcePath : `${path}.settings`}.period`, issues);
|
|
434
|
+
}
|
|
435
|
+
checkQuery(raw.query, resource, `${sourcePath}.query`, issues);
|
|
436
|
+
const alert = raw.alert;
|
|
437
|
+
if (alert !== void 0 && alert !== null && typeof alert === "object") checkQuery(alert.query, resource, `${sourcePath}.alert.query`, issues);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
318
440
|
/**
|
|
319
441
|
* The measure and the group of a widget on a resource (decision 0084): a `sum:` and a group name
|
|
320
442
|
* aggregates of its list, a `series` needs a period of a date, a `breakdown` a field of `groupBy`,
|
|
@@ -349,6 +471,17 @@ function checkAggregateSettings(widget, resource, path, issues) {
|
|
|
349
471
|
path: `${path}.settings.group`,
|
|
350
472
|
message: `A \`${widget.type}\` isn't grouped: only a \`series\` and a \`breakdown\` are.`
|
|
351
473
|
});
|
|
474
|
+
if (widget.type === "metric") {
|
|
475
|
+
if (resource.list?.aggregates === void 0) {
|
|
476
|
+
issues.push({
|
|
477
|
+
path: `${path}.settings.resource`,
|
|
478
|
+
message: `The list of \`${resource.id}\` declares no \`aggregates\`: a \`metric\` reads them.`
|
|
479
|
+
});
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (settings.points !== void 0) checkPeriodGroup(settings.points, resource, `${path}.settings.points`, issues, "The trend of a `metric`");
|
|
483
|
+
if (settings.by !== void 0) checkGroupByField(settings.by, resource, `${path}.settings.by`, issues);
|
|
484
|
+
}
|
|
352
485
|
return;
|
|
353
486
|
}
|
|
354
487
|
const group = typeof settings.group === "string" ? parseAggregateGroup(settings.group) : null;
|
|
@@ -361,6 +494,13 @@ function checkAggregateSettings(widget, resource, path, issues) {
|
|
|
361
494
|
path: `${path}.settings.group`,
|
|
362
495
|
message: `The list of \`${resource.id}\` can't group by \`${group.field}\`: it isn't in the \`dates\` of its aggregates.`
|
|
363
496
|
});
|
|
497
|
+
if (settings.split !== void 0) {
|
|
498
|
+
checkGroupByField(settings.split, resource, `${path}.settings.split`, issues);
|
|
499
|
+
if (!(resource.list?.filters ?? []).some((filter) => filter.id === settings.split && filter.type !== "date-range")) issues.push({
|
|
500
|
+
path: `${path}.settings.split`,
|
|
501
|
+
message: `The list of \`${resource.id}\` has no filter \`${String(settings.split)}\` to read each of its values.`
|
|
502
|
+
});
|
|
503
|
+
}
|
|
364
504
|
return;
|
|
365
505
|
}
|
|
366
506
|
if (group?.type !== "field") issues.push({
|
|
@@ -406,6 +546,36 @@ function checkWidgets(definition, widgets, widgetsPath, issues, { summaryOf, has
|
|
|
406
546
|
path: `${path}.settings.period`,
|
|
407
547
|
message: `Its ${summaryOf !== void 0 ? "summary" : "dashboard"} has no \`period\`.`
|
|
408
548
|
});
|
|
549
|
+
Object.entries(TYPED_SETTINGS).forEach(([key, types]) => {
|
|
550
|
+
if (settings[key] !== void 0 && !types.includes(widget.type)) issues.push({
|
|
551
|
+
path: `${path}.settings.${key}`,
|
|
552
|
+
message: `Only a ${types.map((type) => `\`${type}\``).join(" or a ")} has \`${key}\`.`
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
const sourcesKey = widget.type === "series" ? "sources" : "rows";
|
|
556
|
+
if (settings[sourcesKey] !== void 0 && TYPED_SETTINGS[sourcesKey]?.includes(widget.type)) {
|
|
557
|
+
if (onResource) {
|
|
558
|
+
issues.push({
|
|
559
|
+
path: `${path}.settings.${sourcesKey}`,
|
|
560
|
+
message: `\`${sourcesKey}\` name their resources: the widget has no \`resource\`.`
|
|
561
|
+
});
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
[
|
|
565
|
+
"query",
|
|
566
|
+
"measure",
|
|
567
|
+
"target",
|
|
568
|
+
"by",
|
|
569
|
+
"split"
|
|
570
|
+
].forEach((key) => {
|
|
571
|
+
if (settings[key] !== void 0) issues.push({
|
|
572
|
+
path: `${path}.settings.${key}`,
|
|
573
|
+
message: `\`${key}\` goes with a \`resource\`, not \`${sourcesKey}\`.`
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
checkSources(definition, widget, path, issues, hasPeriod);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
409
579
|
if (!onResource) {
|
|
410
580
|
if (typeof settings.period === "string") issues.push({
|
|
411
581
|
path: `${path}.settings.period`,
|
|
@@ -434,9 +604,9 @@ function checkWidgets(definition, widgets, widgetsPath, issues, { summaryOf, has
|
|
|
434
604
|
});
|
|
435
605
|
return;
|
|
436
606
|
}
|
|
437
|
-
if (settings.target !== void 0 && widget.type !== "stat") issues.push({
|
|
607
|
+
if (settings.target !== void 0 && widget.type !== "stat" && widget.type !== "metric") issues.push({
|
|
438
608
|
path: `${path}.settings.target`,
|
|
439
|
-
message: "Only a `stat`
|
|
609
|
+
message: "Only a `stat` and a `metric` have a `target`."
|
|
440
610
|
});
|
|
441
611
|
checkAggregateSettings(widget, resource, path, issues);
|
|
442
612
|
const sums = typeof settings.measure === "string" && settings.measure.startsWith("sum:");
|
|
@@ -444,22 +614,8 @@ function checkWidgets(definition, widgets, widgetsPath, issues, { summaryOf, has
|
|
|
444
614
|
path: `${path}.settings.resource`,
|
|
445
615
|
message: `The list of \`${resource.id}\` is paged with cursors and has no total: it can't feed a \`stat\` that counts.`
|
|
446
616
|
});
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
message: `The list of \`${resource.id}\` has no \`date-range\` filter \`${settings.period}\`.`
|
|
450
|
-
});
|
|
451
|
-
const filters = new Set((resource.list?.filters ?? []).map((filter) => filter.id));
|
|
452
|
-
Object.keys(settings.query ?? {}).forEach((key) => {
|
|
453
|
-
const filter = FILTER_PARAM.exec(key)?.[1];
|
|
454
|
-
if (WIDGET_RESERVED_QUERY_PARAMS.includes(key)) issues.push({
|
|
455
|
-
path: `${path}.settings.query.${key}`,
|
|
456
|
-
message: `The client sets \`${key}\`.`
|
|
457
|
-
});
|
|
458
|
-
else if (filter !== void 0 && !filters.has(filter)) issues.push({
|
|
459
|
-
path: `${path}.settings.query.${key}`,
|
|
460
|
-
message: `The list of \`${resource.id}\` has no filter \`${filter}\`.`
|
|
461
|
-
});
|
|
462
|
-
});
|
|
617
|
+
checkPeriodFilter(settings.period, resource, `${path}.settings.period`, issues);
|
|
618
|
+
checkQuery(settings.query, resource, `${path}.settings.query`, issues);
|
|
463
619
|
});
|
|
464
620
|
}
|
|
465
621
|
//#endregion
|
package/dist/lint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","names":[],"sources":["../src/lint.ts"],"sourcesContent":["import { parseAggregateGroup, parseAggregateMeasure } from './aggregates';\nimport { DASHBOARD_COMPONENT, HOME_PAGE, getSummaryPeriodFilter } from './dashboards';\nimport { ITEM_TYPE_KEY } from './resourceTypes';\nimport type {\n DefinitionInput,\n Field,\n LayoutNode,\n OverviewPeriod,\n ResourceInput,\n Widget,\n} from './schemas';\nimport type { ValidationIssue } from './validate';\nimport {\n GROUPED_WIDGET_TYPES,\n RESOURCE_WIDGET_TYPES,\n WIDGET_RESERVED_QUERY_PARAMS,\n getWidgetResource,\n isBuiltInWidgetType,\n} from './widgets';\n\nfunction fieldNames(fields: Field[]): Set<string> {\n return new Set(fields.map((field) => field.name));\n}\n\nfunction checkLayout(\n nodes: LayoutNode[],\n names: Set<string>,\n path: string,\n issues: ValidationIssue[],\n) {\n nodes.forEach((node, index) => {\n const nodePath = `${path}.${index}`;\n if (node.type === 'field') {\n if (node.name === undefined) {\n issues.push({ path: nodePath, message: 'A `field` node needs a `name`.' });\n } else if (!names.has(node.name)) {\n issues.push({\n path: `${nodePath}.name`,\n message: `No field named \\`${node.name}\\`.`,\n });\n }\n }\n if (node.type === 'component' && node.component === undefined) {\n issues.push({ path: nodePath, message: 'A `component` node needs a `component`.' });\n }\n if (node.type === 'tabs' && node.children?.some((child) => child.type !== 'tab')) {\n issues.push({\n path: `${nodePath}.children`,\n message: 'The children of `tabs` must be `tab` nodes.',\n });\n }\n if (node.children !== undefined) {\n checkLayout(node.children, names, `${nodePath}.children`, issues);\n }\n });\n}\n\n/**\n * The types of a resource (decision 0077): unique ids, fields named apart from those of the\n * resource, and no field `type` in the form, which holds the item's type.\n */\nfunction checkTypes(\n resource: ResourceInput,\n names: Set<string>,\n path: string,\n issues: ValidationIssue[],\n) {\n const ids = new Set<string>();\n (resource.types ?? []).forEach((type, index) => {\n const typePath = `${path}.types.${index}`;\n if (ids.has(type.id)) {\n issues.push({ path: `${typePath}.id`, message: `Duplicate type id \\`${type.id}\\`.` });\n }\n ids.add(type.id);\n const own = fieldNames(type.fields);\n if (own.size !== type.fields.length) {\n issues.push({ path: `${typePath}.fields`, message: 'Field names must be unique.' });\n }\n type.fields.forEach((field, fieldIndex) => {\n if (names.has(field.name)) {\n issues.push({\n path: `${typePath}.fields.${fieldIndex}.name`,\n message: `The resource already has a field named \\`${field.name}\\`.`,\n });\n } else if (field.name === ITEM_TYPE_KEY) {\n issues.push({\n path: `${typePath}.fields.${fieldIndex}.name`,\n message: `\\`${ITEM_TYPE_KEY}\\` holds the type of the item.`,\n });\n }\n });\n });\n const typeField = resource.fields.findIndex((field) => field.name === ITEM_TYPE_KEY);\n if (ids.size > 0 && typeField !== -1 && resource.fields[typeField]?.notInForm !== true) {\n issues.push({\n path: `${path}.fields.${typeField}`,\n message: `\\`${ITEM_TYPE_KEY}\\` holds the type of the item, set when it is created: its field must be \\`notInForm\\`.`,\n });\n }\n}\n\n/** The fields of a resource and of its types, with their paths. */\nfunction allFields(resource: ResourceInput, path: string): { field: Field; path: string }[] {\n return [\n ...resource.fields.map((field, index) => ({ field, path: `${path}.fields.${index}` })),\n ...(resource.types ?? []).flatMap((type, typeIndex) =>\n type.fields.map((field, index) => ({\n field,\n path: `${path}.types.${typeIndex}.fields.${index}`,\n })),\n ),\n ];\n}\n\n/** Field types whose values can be summed: numbers, and amounts of `money` of one currency. */\nconst SUMMABLE_TYPES = ['number', 'range', 'duration', 'money'];\n/** Field types whose days can be grouped by. */\nconst DATE_TYPES = ['date', 'datetime'];\n/** Field types whose values are structures that can't be grouped by. */\nconst UNGROUPABLE_TYPES = [\n 'richtext',\n 'media',\n 'image',\n 'file',\n 'group',\n 'repeater',\n 'json',\n 'embed',\n 'location',\n 'address',\n 'link',\n 'daterange',\n 'money',\n];\n\n/**\n * The aggregates of a list (decision 0084): each one names a field of the resource that the user\n * can view, `sum` a number or `money` of one currency, `dates` a date, `groupBy` a value.\n */\nfunction checkAggregates(resource: ResourceInput, path: string, issues: ValidationIssue[]) {\n const aggregates = resource.list?.aggregates;\n if (aggregates === undefined) {\n return;\n }\n const fields = allFields(resource, path).map(({ field }) => field);\n const check = (key: 'sum' | 'groupBy' | 'dates', accepts: (field: Field) => string | null) => {\n (aggregates[key] ?? []).forEach((name, index) => {\n const issuePath = `${path}.list.aggregates.${key}.${index}`;\n const field = fields.find((candidate) => candidate.name === name);\n const message =\n field === undefined\n ? `No field named \\`${name}\\`.`\n : field.abilities?.view === false\n ? `The user can't view \\`${name}\\`: it can't be aggregated.`\n : accepts(field);\n if (message !== null) {\n issues.push({ path: issuePath, message });\n }\n });\n };\n check('sum', (field) => {\n if (!SUMMABLE_TYPES.includes(field.type)) {\n return `\\`${field.name}\\` can't be summed: only \\`number\\`, \\`range\\`, \\`duration\\` and \\`money\\` fields can.`;\n }\n const currency = (field.settings as { currency?: unknown } | undefined)?.currency;\n return field.type === 'money' && typeof currency !== 'string'\n ? `\\`${field.name}\\` can't be summed: amounts add up only in one \\`currency\\`.`\n : null;\n });\n check('dates', (field) =>\n DATE_TYPES.includes(field.type)\n ? null\n : `\\`${field.name}\\` must be a \\`date\\` or a \\`datetime\\` to be grouped by period.`,\n );\n check('groupBy', (field) =>\n UNGROUPABLE_TYPES.includes(field.type)\n ? `The items can't be grouped by a \\`${field.type}\\` field.`\n : null,\n );\n}\n\nfunction checkResource(resource: ResourceInput, path: string, issues: ValidationIssue[]) {\n const names = fieldNames(resource.fields);\n if (names.size !== resource.fields.length) {\n issues.push({ path: `${path}.fields`, message: 'Field names must be unique.' });\n }\n checkTypes(resource, names, path, issues);\n if (resource.form?.layout !== undefined) {\n // The layout can name the fields of the types: the forms of the other types leave them out.\n const typeNames = (resource.types ?? []).flatMap((type) => [...fieldNames(type.fields)]);\n checkLayout(\n resource.form.layout,\n new Set([...names, ...typeNames]),\n `${path}.form.layout`,\n issues,\n );\n }\n (resource.list?.columns ?? []).forEach((column, index) => {\n if (column.field !== undefined && !names.has(column.field)) {\n issues.push({\n path: `${path}.list.columns.${index}.field`,\n message: `No field named \\`${column.field}\\`.`,\n });\n }\n });\n const calendar = resource.list?.calendar;\n if (calendar !== undefined) {\n const field = resource.fields.find((candidate) => candidate.name === calendar.field);\n const filter = calendar.filter ?? calendar.field;\n if (field === undefined) {\n issues.push({\n path: `${path}.list.calendar.field`,\n message: `No field named \\`${calendar.field}\\`.`,\n });\n } else if (!['date', 'datetime', 'daterange'].includes(field.type)) {\n issues.push({\n path: `${path}.list.calendar.field`,\n message: 'The field of a calendar must be a `date`, a `datetime` or a `daterange`.',\n });\n }\n if (\n !(resource.list?.filters ?? []).some(\n (candidate) => candidate.id === filter && candidate.type === 'date-range',\n )\n ) {\n issues.push({\n path: `${path}.list.calendar`,\n message: `The calendar needs a \\`date-range\\` filter \\`${filter}\\` in the list.`,\n });\n }\n }\n checkAggregates(resource, path, issues);\n (resource.actions ?? []).forEach((action, index) => {\n if (action.layout !== undefined) {\n checkLayout(\n action.layout,\n fieldNames(action.fields ?? []),\n `${path}.actions.${index}.layout`,\n issues,\n );\n }\n });\n if (resource.kind === 'media') {\n const file = resource.fields.findIndex((field) => field.name === 'file');\n const field = resource.fields[file];\n if (field === undefined) {\n issues.push({\n path: `${path}.fields`,\n message: 'A resource of kind `media` needs a `file` field.',\n });\n } else if (field.type !== 'file' || field.multiple === true) {\n issues.push({\n path: `${path}.fields.${file}`,\n message: 'The `file` field of a `media` resource must be a single `file`.',\n });\n }\n }\n allFields(resource, path).forEach(({ field, path: fieldPath }) => {\n if (field.type === 'relation' && field.resource === undefined) {\n issues.push({\n path: `${fieldPath}.resource`,\n message: 'A `relation` field needs a `resource`.',\n });\n } else if (field.type === 'relation' && Array.isArray(field.resource)) {\n issues.push({\n path: `${fieldPath}.resource`,\n message: 'A `relation` field names one resource.',\n });\n }\n });\n}\n\n/**\n * Checks what the schema can't: references between parts of a definition (layout nodes and\n * columns that name existing fields, relations, `media` and `image` fields that name a resource,\n * unique names), the types of resources, and the `file` field of `media` resources.\n */\nexport function lintDefinition(definition: DefinitionInput): ValidationIssue[] {\n const issues: ValidationIssue[] = [];\n const resourceIds = new Set(definition.resources.map((resource) => resource.id));\n const libraries = definition.resources\n .filter((resource) => resource.kind === 'media')\n .map((resource) => resource.id);\n definition.resources.forEach((resource, index) => {\n checkResource(resource, `resources.${index}`, issues);\n if (resource.summary !== undefined) {\n const summaryPath = `resources.${index}.summary`;\n const period = resource.summary.period;\n if (period !== undefined) {\n checkPeriod(period, `${summaryPath}.period`, issues);\n if (getSummaryPeriodFilter(resource) === null) {\n issues.push({\n path: `${summaryPath}.period${period.filter !== undefined ? '.filter' : ''}`,\n message:\n period.filter !== undefined\n ? `The list of \\`${resource.id}\\` has no \\`date-range\\` filter \\`${period.filter}\\`.`\n : `The period of a summary is a \\`date-range\\` filter of the list of \\`${resource.id}\\`: it has none.`,\n });\n }\n }\n checkWidgets(definition, resource.summary.widgets, `${summaryPath}.widgets`, issues, {\n summaryOf: resource.id,\n hasPeriod: period !== undefined,\n });\n }\n allFields(resource, `resources.${index}`).forEach(({ field, path }) => {\n if (\n field.type === 'relation' &&\n typeof field.resource === 'string' &&\n !resourceIds.has(field.resource)\n ) {\n issues.push({\n path: `${path}.resource`,\n message: `No resource \\`${field.resource}\\`.`,\n });\n }\n if (field.type === 'media' || field.type === 'image') {\n const fieldPath = `${path}.resource`;\n if (field.resource === undefined) {\n // Every library of the definition (decision 0027).\n if (libraries.length === 0) {\n issues.push({\n path: fieldPath,\n message: `${field.type === 'image' ? 'An' : 'A'} \\`${field.type}\\` field needs a resource of kind \\`media\\`.`,\n });\n }\n } else {\n const named =\n typeof field.resource === 'string' ? [field.resource] : field.resource;\n named.forEach((id, idIndex) => {\n if (!libraries.includes(id)) {\n issues.push({\n path:\n typeof field.resource === 'string'\n ? fieldPath\n : `${fieldPath}.${String(idIndex)}`,\n message: `No resource of kind \\`media\\` named \\`${id}\\`.`,\n });\n }\n });\n }\n // A field without transforms keeps no crop (decision 0087).\n if (field.transforms === false) {\n if (field.ratios !== undefined && field.ratios.length > 0) {\n issues.push({\n path: `${path}.ratios`,\n message: 'A field without transforms has no editor to suggest ratios.',\n });\n }\n field.rules?.forEach((rule, ruleIndex) => {\n if (rule.rule === 'crop') {\n issues.push({\n path: `${path}.rules.${String(ruleIndex)}`,\n message:\n 'A field without transforms keeps no crop for the `crop` rule.',\n });\n }\n });\n }\n }\n });\n });\n checkDashboards(definition, issues);\n return issues;\n}\n\n/**\n * The dashboards (decision 0084): the widgets of each page whose component is the built-in\n * `dashboard`, and those of `dashboard`, the shorthand of the home page, unless `pages.home` has\n * its own, which can't come with them. Only a `dashboard` page has widgets.\n */\nfunction checkDashboards(definition: DefinitionInput, issues: ValidationIssue[]) {\n const home = definition.pages?.[HOME_PAGE];\n const homePeriod =\n (home?.component === DASHBOARD_COMPONENT ? home.period : undefined) ??\n definition.dashboard?.period;\n Object.entries(definition.pages ?? {}).forEach(([id, page]) => {\n if (page.period !== undefined) {\n if (page.component !== DASHBOARD_COMPONENT) {\n issues.push({\n path: `pages.${id}.period`,\n message: `Only a \\`${DASHBOARD_COMPONENT}\\` page has a period.`,\n });\n } else {\n checkPeriod(page.period, `pages.${id}.period`, issues);\n }\n }\n if (page.widgets === undefined) {\n return;\n }\n if (page.component !== DASHBOARD_COMPONENT) {\n issues.push({\n path: `pages.${id}.widgets`,\n message: `Only a \\`${DASHBOARD_COMPONENT}\\` page has widgets.`,\n });\n return;\n }\n checkWidgets(definition, page.widgets, `pages.${id}.widgets`, issues, {\n hasPeriod: (id === HOME_PAGE ? homePeriod : page.period) !== undefined,\n });\n });\n if (definition.dashboard === undefined) {\n return;\n }\n if (definition.dashboard.period !== undefined) {\n if (home?.component === DASHBOARD_COMPONENT && home.period !== undefined) {\n issues.push({\n path: 'dashboard.period',\n message: `\\`pages.${HOME_PAGE}.period\\` replaces it: set only one.`,\n });\n } else {\n checkPeriod(definition.dashboard.period, 'dashboard.period', issues);\n }\n }\n if (home?.component === DASHBOARD_COMPONENT && home.widgets !== undefined) {\n if (definition.dashboard.widgets.length > 0) {\n issues.push({\n path: 'dashboard.widgets',\n message: `\\`pages.${HOME_PAGE}.widgets\\` replaces them: set only one.`,\n });\n }\n return;\n }\n checkWidgets(definition, definition.dashboard.widgets, 'dashboard.widgets', issues, {\n hasPeriod: homePeriod !== undefined,\n });\n}\n\n/** A period (decision 0084): its options once each, and its default among them. */\nfunction checkPeriod(period: OverviewPeriod, path: string, issues: ValidationIssue[]) {\n if (new Set(period.options).size !== period.options.length) {\n issues.push({ path: `${path}.options`, message: 'Each period is offered once.' });\n }\n if (period.default !== undefined && !period.options.includes(period.default)) {\n issues.push({\n path: `${path}.default`,\n message: `\\`${period.default}\\` isn't one of the options.`,\n });\n }\n}\n\nconst FILTER_PARAM = /^filter\\[([^\\]]+)\\]/;\n\n/** The settings of a widget that go with a `resource`. */\nconst RESOURCE_SETTINGS = ['query', 'measure', 'group', 'target'] as const;\n\n/**\n * The measure and the group of a widget on a resource (decision 0084): a `sum:` and a group name\n * aggregates of its list, a `series` needs a period of a date, a `breakdown` a field of `groupBy`,\n * and a `list` has neither.\n */\nfunction checkAggregateSettings(\n widget: { type: string; settings?: Record<string, unknown> | undefined },\n resource: ResourceInput,\n path: string,\n issues: ValidationIssue[],\n) {\n const settings = widget.settings ?? {};\n const aggregates = resource.list?.aggregates ?? {};\n const grouped = (GROUPED_WIDGET_TYPES as readonly string[]).includes(widget.type);\n if (widget.type === 'list') {\n ['measure', 'group'].forEach((key) => {\n if (settings[key] !== undefined) {\n issues.push({\n path: `${path}.settings.${key}`,\n message: `A \\`list\\` shows items: it has no \\`${key}\\`.`,\n });\n }\n });\n return;\n }\n if (settings.measure !== undefined) {\n const measure =\n typeof settings.measure === 'string' ? parseAggregateMeasure(settings.measure) : null;\n if (measure === null) {\n issues.push({\n path: `${path}.settings.measure`,\n message: 'The measure must be `count` or `sum:{field}`.',\n });\n } else if (measure.type === 'sum' && !(aggregates.sum ?? []).includes(measure.field)) {\n issues.push({\n path: `${path}.settings.measure`,\n message: `The list of \\`${resource.id}\\` can't sum \\`${measure.field}\\`: it isn't in the \\`sum\\` of its aggregates.`,\n });\n }\n }\n if (!grouped) {\n if (settings.group !== undefined) {\n issues.push({\n path: `${path}.settings.group`,\n message: `A \\`${widget.type}\\` isn't grouped: only a \\`series\\` and a \\`breakdown\\` are.`,\n });\n }\n return;\n }\n const group = typeof settings.group === 'string' ? parseAggregateGroup(settings.group) : null;\n if (widget.type === 'series') {\n if (group?.type !== 'period') {\n issues.push({\n path: `${path}.settings.group`,\n message:\n 'A `series` on a resource needs a `group` on the period of a date: `day:created_at`.',\n });\n } else if (!(aggregates.dates ?? []).includes(group.field)) {\n issues.push({\n path: `${path}.settings.group`,\n message: `The list of \\`${resource.id}\\` can't group by \\`${group.field}\\`: it isn't in the \\`dates\\` of its aggregates.`,\n });\n }\n return;\n }\n if (group?.type !== 'field') {\n issues.push({\n path: `${path}.settings.group`,\n message: 'A `breakdown` on a resource needs a `group` on a field: `status`.',\n });\n } else if (!(aggregates.groupBy ?? []).includes(group.field)) {\n issues.push({\n path: `${path}.settings.group`,\n message: `The list of \\`${resource.id}\\` can't group by \\`${group.field}\\`: it isn't in the \\`groupBy\\` of its aggregates.`,\n });\n }\n}\n\n/**\n * The widgets of a dashboard or of the summary of a resource (decisions 0064 and 0084): unique ids,\n * and the built-in types on a resource that exists, with filters of its list and aggregates it\n * declares. A `stat` that counts reads the total of the list, so the list can't be paged with\n * cursors, which give no total. Only the widgets of a summary follow its list (`followsList`): those\n * on its resource, and those with data of their own.\n */\nfunction checkWidgets(\n definition: DefinitionInput,\n widgets: Widget[],\n widgetsPath: string,\n issues: ValidationIssue[],\n { summaryOf, hasPeriod = false }: { summaryOf?: string; hasPeriod?: boolean } = {},\n) {\n const ids = new Set<string>();\n widgets.forEach((widget, index) => {\n const path = `${widgetsPath}.${index}`;\n if (ids.has(widget.id)) {\n issues.push({ path: `${path}.id`, message: `Duplicate widget id \\`${widget.id}\\`.` });\n }\n ids.add(widget.id);\n const follows = widget.settings?.followsList;\n if (follows !== undefined) {\n const other = getWidgetResource(widget)?.resource;\n if (summaryOf === undefined) {\n issues.push({\n path: `${path}.settings.followsList`,\n message: 'Only the widgets of the summary of a resource follow its list.',\n });\n } else if (other !== undefined && other !== summaryOf) {\n issues.push({\n path: `${path}.settings.followsList`,\n message: `A widget on \\`${other}\\` doesn't follow the list of \\`${summaryOf}\\`.`,\n });\n }\n }\n if (!isBuiltInWidgetType(widget.type)) {\n return;\n }\n const settings = widget.settings ?? {};\n const onResource = typeof settings.resource === 'string';\n if (settings.period !== undefined && !hasPeriod) {\n issues.push({\n path: `${path}.settings.period`,\n message: `Its ${summaryOf !== undefined ? 'summary' : 'dashboard'} has no \\`period\\`.`,\n });\n }\n if (!onResource) {\n if (typeof settings.period === 'string') {\n issues.push({\n path: `${path}.settings.period`,\n message:\n '`period` names a `date-range` filter of the list of its `resource`: without one, it can only be `false`.',\n });\n }\n RESOURCE_SETTINGS.forEach((key) => {\n if (settings[key] !== undefined) {\n issues.push({\n path: `${path}.settings.${key}`,\n message: `\\`${key}\\` goes with a \\`resource\\`.`,\n });\n }\n });\n return;\n }\n if (!(RESOURCE_WIDGET_TYPES as readonly string[]).includes(widget.type)) {\n issues.push({\n path: `${path}.settings.resource`,\n message: `A \\`${widget.type}\\` widget has data of its own: it can't read a resource.`,\n });\n return;\n }\n const resource = definition.resources.find(\n (candidate) => candidate.id === settings.resource,\n );\n if (resource === undefined) {\n issues.push({\n path: `${path}.settings.resource`,\n message: `No resource \\`${String(settings.resource)}\\`.`,\n });\n return;\n }\n if (settings.target !== undefined && widget.type !== 'stat') {\n issues.push({\n path: `${path}.settings.target`,\n message: 'Only a `stat` has a `target`.',\n });\n }\n checkAggregateSettings(widget, resource, path, issues);\n const sums = typeof settings.measure === 'string' && settings.measure.startsWith('sum:');\n if (widget.type === 'stat' && !sums && resource.list?.pagination === 'cursor') {\n issues.push({\n path: `${path}.settings.resource`,\n message: `The list of \\`${resource.id}\\` is paged with cursors and has no total: it can't feed a \\`stat\\` that counts.`,\n });\n }\n if (\n typeof settings.period === 'string' &&\n !(resource.list?.filters ?? []).some(\n (filter) => filter.id === settings.period && filter.type === 'date-range',\n )\n ) {\n issues.push({\n path: `${path}.settings.period`,\n message: `The list of \\`${resource.id}\\` has no \\`date-range\\` filter \\`${settings.period}\\`.`,\n });\n }\n const filters = new Set((resource.list?.filters ?? []).map((filter) => filter.id));\n Object.keys(settings.query ?? {}).forEach((key) => {\n const filter = FILTER_PARAM.exec(key)?.[1];\n if ((WIDGET_RESERVED_QUERY_PARAMS as readonly string[]).includes(key)) {\n issues.push({\n path: `${path}.settings.query.${key}`,\n message: `The client sets \\`${key}\\`.`,\n });\n } else if (filter !== undefined && !filters.has(filter)) {\n issues.push({\n path: `${path}.settings.query.${key}`,\n message: `The list of \\`${resource.id}\\` has no filter \\`${filter}\\`.`,\n });\n }\n });\n });\n}\n"],"mappings":";;;;;AAoBA,SAAS,WAAW,QAA8B;CAC9C,OAAO,IAAI,IAAI,OAAO,KAAK,UAAU,MAAM,IAAI,CAAC;AACpD;AAEA,SAAS,YACL,OACA,OACA,MACA,QACF;CACE,MAAM,SAAS,MAAM,UAAU;EAC3B,MAAM,WAAW,GAAG,KAAK,GAAG;EAC5B,IAAI,KAAK,SAAS,SAAS;GACvB,IAAI,KAAK,SAAS,KAAA,GACd,OAAO,KAAK;IAAE,MAAM;IAAU,SAAS;GAAiC,CAAC;QACtE,IAAI,CAAC,MAAM,IAAI,KAAK,IAAI,GAC3B,OAAO,KAAK;IACR,MAAM,GAAG,SAAS;IAClB,SAAS,oBAAoB,KAAK,KAAK;GAC3C,CAAC;EAET;EACA,IAAI,KAAK,SAAS,eAAe,KAAK,cAAc,KAAA,GAChD,OAAO,KAAK;GAAE,MAAM;GAAU,SAAS;EAA0C,CAAC;EAEtF,IAAI,KAAK,SAAS,UAAU,KAAK,UAAU,MAAM,UAAU,MAAM,SAAS,KAAK,GAC3E,OAAO,KAAK;GACR,MAAM,GAAG,SAAS;GAClB,SAAS;EACb,CAAC;EAEL,IAAI,KAAK,aAAa,KAAA,GAClB,YAAY,KAAK,UAAU,OAAO,GAAG,SAAS,YAAY,MAAM;CAExE,CAAC;AACL;;;;;AAMA,SAAS,WACL,UACA,OACA,MACA,QACF;CACE,MAAM,sBAAM,IAAI,IAAY;CAC5B,CAAC,SAAS,SAAS,CAAC,EAAA,CAAG,SAAS,MAAM,UAAU;EAC5C,MAAM,WAAW,GAAG,KAAK,SAAS;EAClC,IAAI,IAAI,IAAI,KAAK,EAAE,GACf,OAAO,KAAK;GAAE,MAAM,GAAG,SAAS;GAAM,SAAS,uBAAuB,KAAK,GAAG;EAAK,CAAC;EAExF,IAAI,IAAI,KAAK,EA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D,MAAM,OAAO,OAAO,SAAS,YAAY,YAAY,SAAS,QAAQ,WAAW,MAAM;EACvF,IAAI,OAAO,SAAS,UAAU,CAAC,QAAQ,SAAS,MAAM,eAAe,UACjE,OAAO,KAAK;GACR,MAAM,GAAG,KAAK;GACd,SAAS,iBAAiB,SAAS,GAAG;EAC1C,CAAC;EAEL,IACI,OAAO,SAAS,WAAW,YAC3B,EAAE,SAAS,MAAM,WAAW,CAAC,EAAA,CAAG,MAC3B,WAAW,OAAO,OAAO,SAAS,UAAU,OAAO,SAAS,YACjE,GAEA,OAAO,KAAK;GACR,MAAM,GAAG,KAAK;GACd,SAAS,iBAAiB,SAAS,GAAG,oCAAoC,SAAS,OAAO;EAC9F,CAAC;EAEL,MAAM,UAAU,IAAI,KAAK,SAAS,MAAM,WAAW,CAAC,EAAA,CAAG,KAAK,WAAW,OAAO,EAAE,CAAC;EACjF,OAAO,KAAK,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ;GAC/C,MAAM,SAAS,aAAa,KAAK,GAAG,CAAC,GAAG;GACxC,IAAK,6BAAmD,SAAS,GAAG,GAChE,OAAO,KAAK;IACR,MAAM,GAAG,KAAK,kBAAkB;IAChC,SAAS,qBAAqB,IAAI;GACtC,CAAC;QACE,IAAI,WAAW,KAAA,KAAa,CAAC,QAAQ,IAAI,MAAM,GAClD,OAAO,KAAK;IACR,MAAM,GAAG,KAAK,kBAAkB;IAChC,SAAS,iBAAiB,SAAS,GAAG,qBAAqB,OAAO;GACtE,CAAC;EAET,CAAC;CACL,CAAC;AACL"}
|
|
1
|
+
{"version":3,"file":"lint.js","names":[],"sources":["../src/lint.ts"],"sourcesContent":["import { parseAggregateGroup, parseAggregateMeasure } from './aggregates';\nimport { DASHBOARD_COMPONENT, HOME_PAGE, getSummaryPeriodFilter } from './dashboards';\nimport { ITEM_TYPE_KEY } from './resourceTypes';\nimport type {\n DefinitionInput,\n Field,\n LayoutNode,\n OverviewPeriod,\n ResourceInput,\n Widget,\n} from './schemas';\nimport type { ValidationIssue } from './validate';\nimport {\n GROUPED_WIDGET_TYPES,\n RESOURCE_WIDGET_TYPES,\n WIDGET_RESERVED_QUERY_PARAMS,\n getWidgetResource,\n getWidgetSources,\n isBuiltInWidgetType,\n} from './widgets';\n\nfunction fieldNames(fields: Field[]): Set<string> {\n return new Set(fields.map((field) => field.name));\n}\n\nfunction checkLayout(\n nodes: LayoutNode[],\n names: Set<string>,\n path: string,\n issues: ValidationIssue[],\n) {\n nodes.forEach((node, index) => {\n const nodePath = `${path}.${index}`;\n if (node.type === 'field') {\n if (node.name === undefined) {\n issues.push({ path: nodePath, message: 'A `field` node needs a `name`.' });\n } else if (!names.has(node.name)) {\n issues.push({\n path: `${nodePath}.name`,\n message: `No field named \\`${node.name}\\`.`,\n });\n }\n }\n if (node.type === 'component' && node.component === undefined) {\n issues.push({ path: nodePath, message: 'A `component` node needs a `component`.' });\n }\n if (node.type === 'tabs' && node.children?.some((child) => child.type !== 'tab')) {\n issues.push({\n path: `${nodePath}.children`,\n message: 'The children of `tabs` must be `tab` nodes.',\n });\n }\n if (node.children !== undefined) {\n checkLayout(node.children, names, `${nodePath}.children`, issues);\n }\n });\n}\n\n/**\n * The types of a resource (decision 0077): unique ids, fields named apart from those of the\n * resource, and no field `type` in the form, which holds the item's type.\n */\nfunction checkTypes(\n resource: ResourceInput,\n names: Set<string>,\n path: string,\n issues: ValidationIssue[],\n) {\n const ids = new Set<string>();\n (resource.types ?? []).forEach((type, index) => {\n const typePath = `${path}.types.${index}`;\n if (ids.has(type.id)) {\n issues.push({ path: `${typePath}.id`, message: `Duplicate type id \\`${type.id}\\`.` });\n }\n ids.add(type.id);\n const own = fieldNames(type.fields);\n if (own.size !== type.fields.length) {\n issues.push({ path: `${typePath}.fields`, message: 'Field names must be unique.' });\n }\n type.fields.forEach((field, fieldIndex) => {\n if (names.has(field.name)) {\n issues.push({\n path: `${typePath}.fields.${fieldIndex}.name`,\n message: `The resource already has a field named \\`${field.name}\\`.`,\n });\n } else if (field.name === ITEM_TYPE_KEY) {\n issues.push({\n path: `${typePath}.fields.${fieldIndex}.name`,\n message: `\\`${ITEM_TYPE_KEY}\\` holds the type of the item.`,\n });\n }\n });\n });\n const typeField = resource.fields.findIndex((field) => field.name === ITEM_TYPE_KEY);\n if (ids.size > 0 && typeField !== -1 && resource.fields[typeField]?.notInForm !== true) {\n issues.push({\n path: `${path}.fields.${typeField}`,\n message: `\\`${ITEM_TYPE_KEY}\\` holds the type of the item, set when it is created: its field must be \\`notInForm\\`.`,\n });\n }\n}\n\n/** The fields of a resource and of its types, with their paths. */\nfunction allFields(resource: ResourceInput, path: string): { field: Field; path: string }[] {\n return [\n ...resource.fields.map((field, index) => ({ field, path: `${path}.fields.${index}` })),\n ...(resource.types ?? []).flatMap((type, typeIndex) =>\n type.fields.map((field, index) => ({\n field,\n path: `${path}.types.${typeIndex}.fields.${index}`,\n })),\n ),\n ];\n}\n\n/** Field types whose values can be summed: numbers, and amounts of `money` of one currency. */\nconst SUMMABLE_TYPES = ['number', 'range', 'duration', 'money'];\n/** Field types whose days can be grouped by. */\nconst DATE_TYPES = ['date', 'datetime'];\n/** Field types whose values are structures that can't be grouped by. */\nconst UNGROUPABLE_TYPES = [\n 'richtext',\n 'media',\n 'image',\n 'file',\n 'group',\n 'repeater',\n 'json',\n 'embed',\n 'location',\n 'address',\n 'link',\n 'daterange',\n 'money',\n];\n\n/**\n * The aggregates of a list (decision 0084): each one names a field of the resource that the user\n * can view, `sum` a number or `money` of one currency, `dates` a date, `groupBy` a value.\n */\nfunction checkAggregates(resource: ResourceInput, path: string, issues: ValidationIssue[]) {\n const aggregates = resource.list?.aggregates;\n if (aggregates === undefined) {\n return;\n }\n const fields = allFields(resource, path).map(({ field }) => field);\n const check = (key: 'sum' | 'groupBy' | 'dates', accepts: (field: Field) => string | null) => {\n (aggregates[key] ?? []).forEach((name, index) => {\n const issuePath = `${path}.list.aggregates.${key}.${index}`;\n const field = fields.find((candidate) => candidate.name === name);\n const message =\n field === undefined\n ? `No field named \\`${name}\\`.`\n : field.abilities?.view === false\n ? `The user can't view \\`${name}\\`: it can't be aggregated.`\n : accepts(field);\n if (message !== null) {\n issues.push({ path: issuePath, message });\n }\n });\n };\n check('sum', (field) => {\n if (!SUMMABLE_TYPES.includes(field.type)) {\n return `\\`${field.name}\\` can't be summed: only \\`number\\`, \\`range\\`, \\`duration\\` and \\`money\\` fields can.`;\n }\n const currency = (field.settings as { currency?: unknown } | undefined)?.currency;\n return field.type === 'money' && typeof currency !== 'string'\n ? `\\`${field.name}\\` can't be summed: amounts add up only in one \\`currency\\`.`\n : null;\n });\n check('dates', (field) =>\n DATE_TYPES.includes(field.type)\n ? null\n : `\\`${field.name}\\` must be a \\`date\\` or a \\`datetime\\` to be grouped by period.`,\n );\n check('groupBy', (field) =>\n UNGROUPABLE_TYPES.includes(field.type)\n ? `The items can't be grouped by a \\`${field.type}\\` field.`\n : null,\n );\n}\n\nfunction checkResource(resource: ResourceInput, path: string, issues: ValidationIssue[]) {\n const names = fieldNames(resource.fields);\n if (names.size !== resource.fields.length) {\n issues.push({ path: `${path}.fields`, message: 'Field names must be unique.' });\n }\n checkTypes(resource, names, path, issues);\n if (resource.form?.layout !== undefined) {\n // The layout can name the fields of the types: the forms of the other types leave them out.\n const typeNames = (resource.types ?? []).flatMap((type) => [...fieldNames(type.fields)]);\n checkLayout(\n resource.form.layout,\n new Set([...names, ...typeNames]),\n `${path}.form.layout`,\n issues,\n );\n }\n (resource.list?.columns ?? []).forEach((column, index) => {\n if (column.field !== undefined && !names.has(column.field)) {\n issues.push({\n path: `${path}.list.columns.${index}.field`,\n message: `No field named \\`${column.field}\\`.`,\n });\n }\n });\n const calendar = resource.list?.calendar;\n if (calendar !== undefined) {\n const field = resource.fields.find((candidate) => candidate.name === calendar.field);\n const filter = calendar.filter ?? calendar.field;\n if (field === undefined) {\n issues.push({\n path: `${path}.list.calendar.field`,\n message: `No field named \\`${calendar.field}\\`.`,\n });\n } else if (!['date', 'datetime', 'daterange'].includes(field.type)) {\n issues.push({\n path: `${path}.list.calendar.field`,\n message: 'The field of a calendar must be a `date`, a `datetime` or a `daterange`.',\n });\n }\n if (\n !(resource.list?.filters ?? []).some(\n (candidate) => candidate.id === filter && candidate.type === 'date-range',\n )\n ) {\n issues.push({\n path: `${path}.list.calendar`,\n message: `The calendar needs a \\`date-range\\` filter \\`${filter}\\` in the list.`,\n });\n }\n }\n checkAggregates(resource, path, issues);\n (resource.actions ?? []).forEach((action, index) => {\n if (action.layout !== undefined) {\n checkLayout(\n action.layout,\n fieldNames(action.fields ?? []),\n `${path}.actions.${index}.layout`,\n issues,\n );\n }\n });\n if (resource.kind === 'media') {\n const file = resource.fields.findIndex((field) => field.name === 'file');\n const field = resource.fields[file];\n if (field === undefined) {\n issues.push({\n path: `${path}.fields`,\n message: 'A resource of kind `media` needs a `file` field.',\n });\n } else if (field.type !== 'file' || field.multiple === true) {\n issues.push({\n path: `${path}.fields.${file}`,\n message: 'The `file` field of a `media` resource must be a single `file`.',\n });\n }\n }\n allFields(resource, path).forEach(({ field, path: fieldPath }) => {\n if (field.type === 'relation' && field.resource === undefined) {\n issues.push({\n path: `${fieldPath}.resource`,\n message: 'A `relation` field needs a `resource`.',\n });\n } else if (field.type === 'relation' && Array.isArray(field.resource)) {\n issues.push({\n path: `${fieldPath}.resource`,\n message: 'A `relation` field names one resource.',\n });\n }\n });\n}\n\n/**\n * Checks what the schema can't: references between parts of a definition (layout nodes and\n * columns that name existing fields, relations, `media` and `image` fields that name a resource,\n * unique names), the types of resources, and the `file` field of `media` resources.\n */\nexport function lintDefinition(definition: DefinitionInput): ValidationIssue[] {\n const issues: ValidationIssue[] = [];\n const resourceIds = new Set(definition.resources.map((resource) => resource.id));\n const libraries = definition.resources\n .filter((resource) => resource.kind === 'media')\n .map((resource) => resource.id);\n definition.resources.forEach((resource, index) => {\n checkResource(resource, `resources.${index}`, issues);\n if (resource.summary !== undefined) {\n const summaryPath = `resources.${index}.summary`;\n const period = resource.summary.period;\n if (period !== undefined) {\n checkPeriod(period, `${summaryPath}.period`, issues);\n if (getSummaryPeriodFilter(resource) === null) {\n issues.push({\n path: `${summaryPath}.period${period.filter !== undefined ? '.filter' : ''}`,\n message:\n period.filter !== undefined\n ? `The list of \\`${resource.id}\\` has no \\`date-range\\` filter \\`${period.filter}\\`.`\n : `The period of a summary is a \\`date-range\\` filter of the list of \\`${resource.id}\\`: it has none.`,\n });\n }\n }\n checkWidgets(definition, resource.summary.widgets, `${summaryPath}.widgets`, issues, {\n summaryOf: resource.id,\n hasPeriod: period !== undefined,\n });\n }\n allFields(resource, `resources.${index}`).forEach(({ field, path }) => {\n if (\n field.type === 'relation' &&\n typeof field.resource === 'string' &&\n !resourceIds.has(field.resource)\n ) {\n issues.push({\n path: `${path}.resource`,\n message: `No resource \\`${field.resource}\\`.`,\n });\n }\n if (field.type === 'media' || field.type === 'image') {\n const fieldPath = `${path}.resource`;\n if (field.resource === undefined) {\n // Every library of the definition (decision 0027).\n if (libraries.length === 0) {\n issues.push({\n path: fieldPath,\n message: `${field.type === 'image' ? 'An' : 'A'} \\`${field.type}\\` field needs a resource of kind \\`media\\`.`,\n });\n }\n } else {\n const named =\n typeof field.resource === 'string' ? [field.resource] : field.resource;\n named.forEach((id, idIndex) => {\n if (!libraries.includes(id)) {\n issues.push({\n path:\n typeof field.resource === 'string'\n ? fieldPath\n : `${fieldPath}.${String(idIndex)}`,\n message: `No resource of kind \\`media\\` named \\`${id}\\`.`,\n });\n }\n });\n }\n // A field without transforms keeps no crop (decision 0087).\n if (field.transforms === false) {\n if (field.ratios !== undefined && field.ratios.length > 0) {\n issues.push({\n path: `${path}.ratios`,\n message: 'A field without transforms has no editor to suggest ratios.',\n });\n }\n field.rules?.forEach((rule, ruleIndex) => {\n if (rule.rule === 'crop') {\n issues.push({\n path: `${path}.rules.${String(ruleIndex)}`,\n message:\n 'A field without transforms keeps no crop for the `crop` rule.',\n });\n }\n });\n }\n }\n });\n });\n checkDashboards(definition, issues);\n return issues;\n}\n\n/**\n * The dashboards (decision 0084): the widgets of each page whose component is the built-in\n * `dashboard`, and those of `dashboard`, the shorthand of the home page, unless `pages.home` has\n * its own, which can't come with them. Only a `dashboard` page has widgets.\n */\nfunction checkDashboards(definition: DefinitionInput, issues: ValidationIssue[]) {\n const home = definition.pages?.[HOME_PAGE];\n const homePeriod =\n (home?.component === DASHBOARD_COMPONENT ? home.period : undefined) ??\n definition.dashboard?.period;\n Object.entries(definition.pages ?? {}).forEach(([id, page]) => {\n if (page.period !== undefined) {\n if (page.component !== DASHBOARD_COMPONENT) {\n issues.push({\n path: `pages.${id}.period`,\n message: `Only a \\`${DASHBOARD_COMPONENT}\\` page has a period.`,\n });\n } else {\n checkPeriod(page.period, `pages.${id}.period`, issues);\n }\n }\n if (page.widgets === undefined) {\n return;\n }\n if (page.component !== DASHBOARD_COMPONENT) {\n issues.push({\n path: `pages.${id}.widgets`,\n message: `Only a \\`${DASHBOARD_COMPONENT}\\` page has widgets.`,\n });\n return;\n }\n checkWidgets(definition, page.widgets, `pages.${id}.widgets`, issues, {\n hasPeriod: (id === HOME_PAGE ? homePeriod : page.period) !== undefined,\n });\n });\n if (definition.dashboard === undefined) {\n return;\n }\n if (definition.dashboard.period !== undefined) {\n if (home?.component === DASHBOARD_COMPONENT && home.period !== undefined) {\n issues.push({\n path: 'dashboard.period',\n message: `\\`pages.${HOME_PAGE}.period\\` replaces it: set only one.`,\n });\n } else {\n checkPeriod(definition.dashboard.period, 'dashboard.period', issues);\n }\n }\n if (home?.component === DASHBOARD_COMPONENT && home.widgets !== undefined) {\n if (definition.dashboard.widgets.length > 0) {\n issues.push({\n path: 'dashboard.widgets',\n message: `\\`pages.${HOME_PAGE}.widgets\\` replaces them: set only one.`,\n });\n }\n return;\n }\n checkWidgets(definition, definition.dashboard.widgets, 'dashboard.widgets', issues, {\n hasPeriod: homePeriod !== undefined,\n });\n}\n\n/** A period (decision 0084): its options once each, and its default among them. */\nfunction checkPeriod(period: OverviewPeriod, path: string, issues: ValidationIssue[]) {\n if (new Set(period.options).size !== period.options.length) {\n issues.push({ path: `${path}.options`, message: 'Each period is offered once.' });\n }\n if (period.default !== undefined && !period.options.includes(period.default)) {\n issues.push({\n path: `${path}.default`,\n message: `\\`${period.default}\\` isn't one of the options.`,\n });\n }\n}\n\nconst FILTER_PARAM = /^filter\\[([^\\]]+)\\]/;\n\n/** The settings of a widget that go with a `resource`. */\nconst RESOURCE_SETTINGS = ['query', 'measure', 'group', 'target', 'points', 'by', 'split'] as const;\n\n/** The settings of a built-in widget that only some types have (decision 0089), and those types. */\nconst TYPED_SETTINGS: Record<string, readonly string[]> = {\n goodWhen: ['metric', 'table'],\n points: ['metric', 'table'],\n by: ['metric'],\n split: ['series'],\n sources: ['series'],\n stacked: ['series'],\n rows: ['table'],\n};\n\n/** A `measure` of the aggregates of a list: `count`, or the `sum:` of a field of its `sum`. */\nfunction checkMeasure(\n value: unknown,\n resource: ResourceInput,\n path: string,\n issues: ValidationIssue[],\n) {\n if (value === undefined) {\n return;\n }\n const measure = typeof value === 'string' ? parseAggregateMeasure(value) : null;\n if (measure === null) {\n issues.push({ path, message: 'The measure must be `count` or `sum:{field}`.' });\n } else if (\n measure.type === 'sum' &&\n !(resource.list?.aggregates?.sum ?? []).includes(measure.field)\n ) {\n issues.push({\n path,\n message: `The list of \\`${resource.id}\\` can't sum \\`${measure.field}\\`: it isn't in the \\`sum\\` of its aggregates.`,\n });\n }\n}\n\n/** A group on the period of a date of the aggregates of a list: `day:created_at`. */\nfunction checkPeriodGroup(\n value: unknown,\n resource: ResourceInput,\n path: string,\n issues: ValidationIssue[],\n what: string,\n) {\n const group = typeof value === 'string' ? parseAggregateGroup(value) : null;\n if (group?.type !== 'period') {\n issues.push({ path, message: `${what} needs a period of a date: \\`day:created_at\\`.` });\n } else if (!(resource.list?.aggregates?.dates ?? []).includes(group.field)) {\n issues.push({\n path,\n message: `The list of \\`${resource.id}\\` can't group by \\`${group.field}\\`: it isn't in the \\`dates\\` of its aggregates.`,\n });\n }\n}\n\n/** A field of the `groupBy` of the aggregates of a list. */\nfunction checkGroupByField(\n value: unknown,\n resource: ResourceInput,\n path: string,\n issues: ValidationIssue[],\n) {\n if (typeof value !== 'string' || !(resource.list?.aggregates?.groupBy ?? []).includes(value)) {\n issues.push({\n path,\n message: `The list of \\`${resource.id}\\` can't group by \\`${String(value)}\\`: it isn't in the \\`groupBy\\` of its aggregates.`,\n });\n }\n}\n\n/** The filters of a query of a widget or of a source: filters of the list, never the paging. */\nfunction checkQuery(\n query: unknown,\n resource: ResourceInput,\n path: string,\n issues: ValidationIssue[],\n) {\n if (query === null || typeof query !== 'object') {\n return;\n }\n const filters = new Set((resource.list?.filters ?? []).map((filter) => filter.id));\n Object.keys(query).forEach((key) => {\n const filter = FILTER_PARAM.exec(key)?.[1];\n if ((WIDGET_RESERVED_QUERY_PARAMS as readonly string[]).includes(key)) {\n issues.push({ path: `${path}.${key}`, message: `The client sets \\`${key}\\`.` });\n } else if (filter !== undefined && !filters.has(filter)) {\n issues.push({\n path: `${path}.${key}`,\n message: `The list of \\`${resource.id}\\` has no filter \\`${filter}\\`.`,\n });\n }\n });\n}\n\n/** `period`: a `date-range` filter of the list of the resource. */\nfunction checkPeriodFilter(\n period: unknown,\n resource: ResourceInput,\n path: string,\n issues: ValidationIssue[],\n) {\n if (\n typeof period === 'string' &&\n !(resource.list?.filters ?? []).some(\n (filter) => filter.id === period && filter.type === 'date-range',\n )\n ) {\n issues.push({\n path,\n message: `The list of \\`${resource.id}\\` has no \\`date-range\\` filter \\`${period}\\`.`,\n });\n }\n}\n\n/**\n * The `sources` of a `series` or the `rows` of a `table` (decision 0089): each on a resource that\n * exists and declares aggregates, with a measure, a group on a period of a date (required for a\n * line of a series), a period and a query, and an alert, that its list declares.\n */\nfunction checkSources(\n definition: DefinitionInput,\n widget: Widget,\n path: string,\n issues: ValidationIssue[],\n hasPeriod: boolean,\n) {\n const settings = widget.settings ?? {};\n const key = widget.type === 'series' ? 'sources' : 'rows';\n const entries = settings[key];\n if (!Array.isArray(entries)) {\n return;\n }\n const sources = getWidgetSources(widget);\n // One chart has one period: the lines of a series, or the trends of a table, share it\n const periods = new Set(\n sources.flatMap((source) => {\n const group = source.group !== null ? parseAggregateGroup(source.group) : null;\n return group?.type === 'period' ? [group.period] : [];\n }),\n );\n if (periods.size > 1) {\n issues.push({\n path: `${path}.settings.${key}`,\n message: `Its ${widget.type === 'series' ? 'lines' : 'trends'} have different periods (${[...periods].join(', ')}): they share one.`,\n });\n }\n entries.forEach((entry: unknown, index) => {\n const sourcePath = `${path}.settings.${key}.${index}`;\n const source = sources[index];\n if (source === undefined || entry === null || typeof entry !== 'object') {\n return;\n }\n const raw = entry as Record<string, unknown>;\n const resource = definition.resources.find((candidate) => candidate.id === source.resource);\n if (resource === undefined) {\n issues.push({\n path: `${sourcePath}.resource`,\n message: `No resource \\`${source.resource}\\`.`,\n });\n return;\n }\n if (resource.list?.aggregates === undefined) {\n issues.push({\n path: `${sourcePath}.resource`,\n message: `The list of \\`${resource.id}\\` declares no \\`aggregates\\`.`,\n });\n return;\n }\n checkMeasure(raw.measure, resource, `${sourcePath}.measure`, issues);\n const groupKey = widget.type === 'series' ? 'group' : 'points';\n if (widget.type === 'series' || source.group !== null) {\n checkPeriodGroup(\n source.group,\n resource,\n `${raw[groupKey] !== undefined ? sourcePath : `${path}.settings`}.${groupKey}`,\n issues,\n widget.type === 'series' ? 'A line of a `series`' : 'The trend of a row',\n );\n }\n if (typeof source.period === 'string') {\n // The widget's own `period` is checked with the widget\n if (!hasPeriod && raw.period !== undefined) {\n issues.push({\n path: `${raw.period !== undefined ? sourcePath : `${path}.settings`}.period`,\n message: 'Its overview has no `period`.',\n });\n }\n checkPeriodFilter(\n source.period,\n resource,\n `${raw.period !== undefined ? sourcePath : `${path}.settings`}.period`,\n issues,\n );\n }\n checkQuery(raw.query, resource, `${sourcePath}.query`, issues);\n const alert = raw.alert as Record<string, unknown> | undefined;\n if (alert !== undefined && alert !== null && typeof alert === 'object') {\n checkQuery(alert.query, resource, `${sourcePath}.alert.query`, issues);\n }\n });\n}\n\n/**\n * The measure and the group of a widget on a resource (decision 0084): a `sum:` and a group name\n * aggregates of its list, a `series` needs a period of a date, a `breakdown` a field of `groupBy`,\n * and a `list` has neither.\n */\nfunction checkAggregateSettings(\n widget: { type: string; settings?: Record<string, unknown> | undefined },\n resource: ResourceInput,\n path: string,\n issues: ValidationIssue[],\n) {\n const settings = widget.settings ?? {};\n const aggregates = resource.list?.aggregates ?? {};\n const grouped = (GROUPED_WIDGET_TYPES as readonly string[]).includes(widget.type);\n if (widget.type === 'list') {\n ['measure', 'group'].forEach((key) => {\n if (settings[key] !== undefined) {\n issues.push({\n path: `${path}.settings.${key}`,\n message: `A \\`list\\` shows items: it has no \\`${key}\\`.`,\n });\n }\n });\n return;\n }\n if (settings.measure !== undefined) {\n const measure =\n typeof settings.measure === 'string' ? parseAggregateMeasure(settings.measure) : null;\n if (measure === null) {\n issues.push({\n path: `${path}.settings.measure`,\n message: 'The measure must be `count` or `sum:{field}`.',\n });\n } else if (measure.type === 'sum' && !(aggregates.sum ?? []).includes(measure.field)) {\n issues.push({\n path: `${path}.settings.measure`,\n message: `The list of \\`${resource.id}\\` can't sum \\`${measure.field}\\`: it isn't in the \\`sum\\` of its aggregates.`,\n });\n }\n }\n if (!grouped) {\n if (settings.group !== undefined) {\n issues.push({\n path: `${path}.settings.group`,\n message: `A \\`${widget.type}\\` isn't grouped: only a \\`series\\` and a \\`breakdown\\` are.`,\n });\n }\n if (widget.type === 'metric') {\n if (resource.list?.aggregates === undefined) {\n issues.push({\n path: `${path}.settings.resource`,\n message: `The list of \\`${resource.id}\\` declares no \\`aggregates\\`: a \\`metric\\` reads them.`,\n });\n return;\n }\n if (settings.points !== undefined) {\n checkPeriodGroup(\n settings.points,\n resource,\n `${path}.settings.points`,\n issues,\n 'The trend of a `metric`',\n );\n }\n if (settings.by !== undefined) {\n checkGroupByField(settings.by, resource, `${path}.settings.by`, issues);\n }\n }\n return;\n }\n const group = typeof settings.group === 'string' ? parseAggregateGroup(settings.group) : null;\n if (widget.type === 'series') {\n if (group?.type !== 'period') {\n issues.push({\n path: `${path}.settings.group`,\n message:\n 'A `series` on a resource needs a `group` on the period of a date: `day:created_at`.',\n });\n } else if (!(aggregates.dates ?? []).includes(group.field)) {\n issues.push({\n path: `${path}.settings.group`,\n message: `The list of \\`${resource.id}\\` can't group by \\`${group.field}\\`: it isn't in the \\`dates\\` of its aggregates.`,\n });\n }\n if (settings.split !== undefined) {\n checkGroupByField(settings.split, resource, `${path}.settings.split`, issues);\n // Each line reads the aggregates filtered by its value\n if (\n !(resource.list?.filters ?? []).some(\n (filter) => filter.id === settings.split && filter.type !== 'date-range',\n )\n ) {\n issues.push({\n path: `${path}.settings.split`,\n message: `The list of \\`${resource.id}\\` has no filter \\`${String(settings.split)}\\` to read each of its values.`,\n });\n }\n }\n return;\n }\n if (group?.type !== 'field') {\n issues.push({\n path: `${path}.settings.group`,\n message: 'A `breakdown` on a resource needs a `group` on a field: `status`.',\n });\n } else if (!(aggregates.groupBy ?? []).includes(group.field)) {\n issues.push({\n path: `${path}.settings.group`,\n message: `The list of \\`${resource.id}\\` can't group by \\`${group.field}\\`: it isn't in the \\`groupBy\\` of its aggregates.`,\n });\n }\n}\n\n/**\n * The widgets of a dashboard or of the summary of a resource (decisions 0064 and 0084): unique ids,\n * and the built-in types on a resource that exists, with filters of its list and aggregates it\n * declares. A `stat` that counts reads the total of the list, so the list can't be paged with\n * cursors, which give no total. Only the widgets of a summary follow its list (`followsList`): those\n * on its resource, and those with data of their own.\n */\nfunction checkWidgets(\n definition: DefinitionInput,\n widgets: Widget[],\n widgetsPath: string,\n issues: ValidationIssue[],\n { summaryOf, hasPeriod = false }: { summaryOf?: string; hasPeriod?: boolean } = {},\n) {\n const ids = new Set<string>();\n widgets.forEach((widget, index) => {\n const path = `${widgetsPath}.${index}`;\n if (ids.has(widget.id)) {\n issues.push({ path: `${path}.id`, message: `Duplicate widget id \\`${widget.id}\\`.` });\n }\n ids.add(widget.id);\n const follows = widget.settings?.followsList;\n if (follows !== undefined) {\n const other = getWidgetResource(widget)?.resource;\n if (summaryOf === undefined) {\n issues.push({\n path: `${path}.settings.followsList`,\n message: 'Only the widgets of the summary of a resource follow its list.',\n });\n } else if (other !== undefined && other !== summaryOf) {\n issues.push({\n path: `${path}.settings.followsList`,\n message: `A widget on \\`${other}\\` doesn't follow the list of \\`${summaryOf}\\`.`,\n });\n }\n }\n if (!isBuiltInWidgetType(widget.type)) {\n return;\n }\n const settings = widget.settings ?? {};\n const onResource = typeof settings.resource === 'string';\n if (settings.period !== undefined && !hasPeriod) {\n issues.push({\n path: `${path}.settings.period`,\n message: `Its ${summaryOf !== undefined ? 'summary' : 'dashboard'} has no \\`period\\`.`,\n });\n }\n Object.entries(TYPED_SETTINGS).forEach(([key, types]) => {\n if (settings[key] !== undefined && !types.includes(widget.type)) {\n issues.push({\n path: `${path}.settings.${key}`,\n message: `Only a ${types.map((type) => `\\`${type}\\``).join(' or a ')} has \\`${key}\\`.`,\n });\n }\n });\n const sourcesKey = widget.type === 'series' ? 'sources' : 'rows';\n if (\n settings[sourcesKey] !== undefined &&\n TYPED_SETTINGS[sourcesKey]?.includes(widget.type)\n ) {\n if (onResource) {\n issues.push({\n path: `${path}.settings.${sourcesKey}`,\n message: `\\`${sourcesKey}\\` name their resources: the widget has no \\`resource\\`.`,\n });\n return;\n }\n ['query', 'measure', 'target', 'by', 'split'].forEach((key) => {\n if (settings[key] !== undefined) {\n issues.push({\n path: `${path}.settings.${key}`,\n message: `\\`${key}\\` goes with a \\`resource\\`, not \\`${sourcesKey}\\`.`,\n });\n }\n });\n checkSources(definition, widget, path, issues, hasPeriod);\n return;\n }\n if (!onResource) {\n if (typeof settings.period === 'string') {\n issues.push({\n path: `${path}.settings.period`,\n message:\n '`period` names a `date-range` filter of the list of its `resource`: without one, it can only be `false`.',\n });\n }\n RESOURCE_SETTINGS.forEach((key) => {\n if (settings[key] !== undefined) {\n issues.push({\n path: `${path}.settings.${key}`,\n message: `\\`${key}\\` goes with a \\`resource\\`.`,\n });\n }\n });\n return;\n }\n if (!(RESOURCE_WIDGET_TYPES as readonly string[]).includes(widget.type)) {\n issues.push({\n path: `${path}.settings.resource`,\n message: `A \\`${widget.type}\\` widget has data of its own: it can't read a resource.`,\n });\n return;\n }\n const resource = definition.resources.find(\n (candidate) => candidate.id === settings.resource,\n );\n if (resource === undefined) {\n issues.push({\n path: `${path}.settings.resource`,\n message: `No resource \\`${String(settings.resource)}\\`.`,\n });\n return;\n }\n if (settings.target !== undefined && widget.type !== 'stat' && widget.type !== 'metric') {\n issues.push({\n path: `${path}.settings.target`,\n message: 'Only a `stat` and a `metric` have a `target`.',\n });\n }\n checkAggregateSettings(widget, resource, path, issues);\n const sums = typeof settings.measure === 'string' && settings.measure.startsWith('sum:');\n if (widget.type === 'stat' && !sums && resource.list?.pagination === 'cursor') {\n issues.push({\n path: `${path}.settings.resource`,\n message: `The list of \\`${resource.id}\\` is paged with cursors and has no total: it can't feed a \\`stat\\` that counts.`,\n });\n }\n checkPeriodFilter(settings.period, resource, `${path}.settings.period`, issues);\n checkQuery(settings.query, resource, `${path}.settings.query`, issues);\n });\n}\n"],"mappings":";;;;;AAqBA,SAAS,WAAW,QAA8B;CAC9C,OAAO,IAAI,IAAI,OAAO,KAAK,UAAU,MAAM,IAAI,CAAC;AACpD;AAEA,SAAS,YACL,OACA,OACA,MACA,QACF;CACE,MAAM,SAAS,MAAM,UAAU;EAC3B,MAAM,WAAW,GAAG,KAAK,GAAG;EAC5B,IAAI,KAAK,SAAS,SAAS;GACvB,IAAI,KAAK,SAAS,KAAA,GACd,OAAO,KAAK;IAAE,MAAM;IAAU,SAAS;GAAiC,CAAC;QACtE,IAAI,CAAC,MAAM,IAAI,KAAK,IAAI,GAC3B,OAAO,KAAK;IACR,MAAM,GAAG,SAAS;IAClB,SAAS,oBAAoB,KAAK,KAAK;GAC3C,CAAC;EA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AAQ,SAAS,MAAM,eAAe,UACjE,OAAO,KAAK;GACR,MAAM,GAAG,KAAK;GACd,SAAS,iBAAiB,SAAS,GAAG;EAC1C,CAAC;EAEL,kBAAkB,SAAS,QAAQ,UAAU,GAAG,KAAK,mBAAmB,MAAM;EAC9E,WAAW,SAAS,OAAO,UAAU,GAAG,KAAK,kBAAkB,MAAM;CACzE,CAAC;AACL"}
|
package/dist/mock/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { checkValues } from "../rules.js";
|
|
|
5
5
|
import { getMediaLibraries } from "../libraries.js";
|
|
6
6
|
import { ITEM_TYPE_KEY, getResourceType, getTypeFields, hasResourceTypes } from "../resourceTypes.js";
|
|
7
7
|
import { fromSearchParams, isFilterRange, matchesFilterRange } from "../query.js";
|
|
8
|
-
import { checkWidgetData,
|
|
8
|
+
import { checkWidgetData, readsResources } from "../widgets.js";
|
|
9
9
|
import { aggregateItems, getFilterRange, readAggregateQuery } from "../aggregates.js";
|
|
10
10
|
import { getDashboardWidgets, getSummaryWidgets, readWidgetDataQuery } from "../dashboards.js";
|
|
11
11
|
import { readSearchQuery } from "../search.js";
|
|
@@ -510,7 +510,7 @@ function createMockBackend(options) {
|
|
|
510
510
|
}
|
|
511
511
|
const widget = (read.resource !== void 0 ? getSummaryWidgets(current, read.resource) : getDashboardWidgets(current, read.page)).find((candidate) => candidate.id === id);
|
|
512
512
|
const data = options.widgets?.[id];
|
|
513
|
-
if (widget === void 0 ||
|
|
513
|
+
if (widget === void 0 || readsResources(widget) || data === void 0) return problem(404, "Widget not found.");
|
|
514
514
|
const answer = typeof data === "function" ? await data({
|
|
515
515
|
context: values,
|
|
516
516
|
page: read.page ?? null,
|