@jupiterone/jupiterone-mcp 2.1.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -2
- package/dist/client/graphql/queries.d.ts +48 -1
- package/dist/client/graphql/queries.d.ts.map +1 -1
- package/dist/client/graphql/queries.js +329 -1
- package/dist/client/graphql/queries.js.map +1 -1
- package/dist/client/jupiterone-client.d.ts +8 -0
- package/dist/client/jupiterone-client.d.ts.map +1 -1
- package/dist/client/jupiterone-client.js +13 -0
- package/dist/client/jupiterone-client.js.map +1 -1
- package/dist/client/services/threat-service.d.ts +31 -0
- package/dist/client/services/threat-service.d.ts.map +1 -0
- package/dist/client/services/threat-service.js +72 -0
- package/dist/client/services/threat-service.js.map +1 -0
- package/dist/generated/description-map.d.ts.map +1 -1
- package/dist/generated/description-map.js +602 -14
- package/dist/generated/description-map.js.map +1 -1
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +51 -1
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/tools/alerts.d.ts.map +1 -1
- package/dist/server/tools/alerts.js +2 -5
- package/dist/server/tools/alerts.js.map +1 -1
- package/dist/server/tools/dashboard-layout.d.ts +80 -3
- package/dist/server/tools/dashboard-layout.d.ts.map +1 -1
- package/dist/server/tools/dashboard-layout.js +220 -15
- package/dist/server/tools/dashboard-layout.js.map +1 -1
- package/dist/server/tools/dashboards.d.ts.map +1 -1
- package/dist/server/tools/dashboards.js +379 -10
- package/dist/server/tools/dashboards.js.map +1 -1
- package/dist/server/tools/errors.d.ts +61 -10
- package/dist/server/tools/errors.d.ts.map +1 -1
- package/dist/server/tools/errors.js +201 -10
- package/dist/server/tools/errors.js.map +1 -1
- package/dist/server/tools/index.d.ts.map +1 -1
- package/dist/server/tools/index.js +2 -0
- package/dist/server/tools/index.js.map +1 -1
- package/dist/server/tools/integrations.d.ts.map +1 -1
- package/dist/server/tools/integrations.js +15 -4
- package/dist/server/tools/integrations.js.map +1 -1
- package/dist/server/tools/j1ql.d.ts.map +1 -1
- package/dist/server/tools/j1ql.js +72 -4
- package/dist/server/tools/j1ql.js.map +1 -1
- package/dist/server/tools/rules.d.ts.map +1 -1
- package/dist/server/tools/rules.js +57 -6
- package/dist/server/tools/rules.js.map +1 -1
- package/dist/server/tools/telemetry.d.ts +7 -1
- package/dist/server/tools/telemetry.d.ts.map +1 -1
- package/dist/server/tools/telemetry.js.map +1 -1
- package/dist/server/tools/threat.d.ts +3 -0
- package/dist/server/tools/threat.d.ts.map +1 -0
- package/dist/server/tools/threat.js +284 -0
- package/dist/server/tools/threat.js.map +1 -0
- package/dist/server/tools/types.d.ts +5 -0
- package/dist/server/tools/types.d.ts.map +1 -1
- package/dist/server/tools/types.js +7 -1
- package/dist/server/tools/types.js.map +1 -1
- package/dist/server/tools/usage.d.ts +13 -3
- package/dist/server/tools/usage.d.ts.map +1 -1
- package/dist/server/tools/usage.js +186 -7
- package/dist/server/tools/usage.js.map +1 -1
- package/dist/server/tools/value-probe.d.ts +85 -0
- package/dist/server/tools/value-probe.d.ts.map +1 -0
- package/dist/server/tools/value-probe.js +473 -0
- package/dist/server/tools/value-probe.js.map +1 -0
- package/dist/server/tools/widget-config-lint.d.ts +39 -0
- package/dist/server/tools/widget-config-lint.d.ts.map +1 -0
- package/dist/server/tools/widget-config-lint.js +290 -0
- package/dist/server/tools/widget-config-lint.js.map +1 -0
- package/dist/server/tools/widget-preflight.d.ts +63 -0
- package/dist/server/tools/widget-preflight.d.ts.map +1 -0
- package/dist/server/tools/widget-preflight.js +238 -0
- package/dist/server/tools/widget-preflight.js.map +1 -0
- package/dist/server/tools/widget-render-contract.d.ts +134 -0
- package/dist/server/tools/widget-render-contract.d.ts.map +1 -0
- package/dist/server/tools/widget-render-contract.js +421 -0
- package/dist/server/tools/widget-render-contract.js.map +1 -0
- package/dist/server/tools/widget-settings-keys.d.ts +51 -0
- package/dist/server/tools/widget-settings-keys.d.ts.map +1 -0
- package/dist/server/tools/widget-settings-keys.js +152 -0
- package/dist/server/tools/widget-settings-keys.js.map +1 -0
- package/dist/types/jupiterone.d.ts +139 -0
- package/dist/types/jupiterone.d.ts.map +1 -1
- package/dist/utils/j1ql-filters.d.ts +48 -0
- package/dist/utils/j1ql-filters.d.ts.map +1 -0
- package/dist/utils/j1ql-filters.js +184 -0
- package/dist/utils/j1ql-filters.js.map +1 -0
- package/dist/utils/j1ql-validator.d.ts +0 -5
- package/dist/utils/j1ql-validator.d.ts.map +1 -1
- package/dist/utils/j1ql-validator.js +27 -6
- package/dist/utils/j1ql-validator.js.map +1 -1
- package/node_modules/dtrace-provider/build/Makefile +1 -1
- package/package.json +1 -1
- package/dist/utils/description-loader.d.ts +0 -2
- package/dist/utils/description-loader.d.ts.map +0 -1
- package/dist/utils/description-loader.js +0 -17
- package/dist/utils/description-loader.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-preflight.js","sourceRoot":"","sources":["../../../src/server/tools/widget-preflight.ts"],"names":[],"mappings":";;AAqOA,gDAkHC;AArVD,2EAKqC;AACrC,qDAK0B;AAE1B;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEzC,wGAAwG;AACxG,MAAM,kCAAkC,GAAG,MAAM,CAAC;AAsDlD;;;;;;;;;GASG;AACH,SAAS,QAAQ,CAAC,MAAe;IAC/B,MAAM,QAAQ,GAAG,MAA+C,CAAC;IACjE,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChG,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,QAAQ,CA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,CAAC,IAAI,CAAC;IACX,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,KAAK,GAAG,IAAA,oCAAmB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE;YACrF,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC;QACH,IAAI,KAAK;YAAE,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,YAAY,GAAG,oBAAoB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE9D,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,YAAY;QACZ,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;QACnC,kGAAkG;QAClG,eAAe,EAAE,YAAY,KAAK,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;QAC9D,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9C,IAAI,EAAE,SAAS,CAAC,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,SAAS,EAAE,YAAY,CAAC;KAC5F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which RETURN columns each Insights chart type needs in order to render.
|
|
3
|
+
*
|
|
4
|
+
* These are renderer-side conventions: the API accepts any valid J1QL for any chart type, so a
|
|
5
|
+
* mismatch is created successfully and then draws nothing — a number widget shows 0, a pie shows a
|
|
6
|
+
* blank ring — with no error anywhere in the flow (TD-9016). The contract is not derivable from the
|
|
7
|
+
* GraphQL schema (`CreateInsightsWidgetInput` says nothing about columns), so it is transcribed
|
|
8
|
+
* here from the shipped tool description.
|
|
9
|
+
*
|
|
10
|
+
* `required` BLOCKS widget creation when missing, so a row belongs there only when a missing column
|
|
11
|
+
* certainly means a blank widget. `recommended` is reported but never blocks — the chart uses the
|
|
12
|
+
* column when present and copes without it. Multi-query widgets label their series by query name
|
|
13
|
+
* (`mapColorsByQuery`), which is why the series/label columns sit in `recommended`: requiring one
|
|
14
|
+
* would hard-block a legitimate two-query chart.
|
|
15
|
+
*
|
|
16
|
+
* `number`, `pie`, `bar` and `matrix` are confirmed against rendering widgets on live j1dev boards
|
|
17
|
+
* (`All Chart Types`, the J1-managed `device-management`, `CSPM Progress`). `line` and `area` are
|
|
18
|
+
* from the tool description only — hence the conservative required sets.
|
|
19
|
+
*
|
|
20
|
+
* SOURCE OF TRUTH. `src/descriptions/server-instructions.md` republishes this table for the model,
|
|
21
|
+
* and `widget-render-contract.test.ts` fails if the two drift apart or if a chart type is added to
|
|
22
|
+
* the API's list without a decision here.
|
|
23
|
+
*/
|
|
24
|
+
export interface ChartColumnContract {
|
|
25
|
+
required: readonly string[];
|
|
26
|
+
/**
|
|
27
|
+
* Columns that are required only when the widget carries exactly ONE query.
|
|
28
|
+
*
|
|
29
|
+
* `pie` is the case this exists for. The renderer GROUPS slices by the `name` column, so a lone
|
|
30
|
+
* query without it does not draw an unlabelled pie — every row collapses into a single slice
|
|
31
|
+
* labelled `undefined` summing the whole population (seen on a live board: one slice, 193,770).
|
|
32
|
+
* A multi-query pie labels each slice by its query name (`mapColorsByQuery`) and needs no `name`
|
|
33
|
+
* column at all, which is why this cannot go in `required`: doing so false-positived five
|
|
34
|
+
* rendering widgets in the live corpus audit, every one of them multi-query.
|
|
35
|
+
*/
|
|
36
|
+
singleQueryRequired?: readonly string[];
|
|
37
|
+
recommended?: readonly string[];
|
|
38
|
+
/**
|
|
39
|
+
* A projection the query must use instead of column aliases. `graph` renders the tree J1QL
|
|
40
|
+
* returns for `RETURN TREE`; anything else gives it rows it cannot draw.
|
|
41
|
+
*/
|
|
42
|
+
projection?: 'tree';
|
|
43
|
+
/** Checked on every query the widget carries, not just the first — `status` correlates several. */
|
|
44
|
+
perQuery?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Each query reads exactly the required columns and nothing else. A per-QUERY rule, not a
|
|
47
|
+
* per-widget one: a `number` widget legitimately carries several queries in percentage mode, and
|
|
48
|
+
* each of them still returns a single `value`.
|
|
49
|
+
*
|
|
50
|
+
* Reported, never blocked: field experience is that extras "can break" the render, but whether
|
|
51
|
+
* the current renderer tolerates them is unverified.
|
|
52
|
+
*/
|
|
53
|
+
exactColumns?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Every chart type the API accepts. The widget input schema builds its enum from this list, so a
|
|
57
|
+
* new chart type is added in exactly one place — and the drift test then fails until it is either
|
|
58
|
+
* given a contract below or declared exempt.
|
|
59
|
+
*/
|
|
60
|
+
export declare const CHART_TYPES: readonly ["area", "bar", "graph", "line", "markdown", "matrix", "number", "pie", "status", "table"];
|
|
61
|
+
export type ChartType = (typeof CHART_TYPES)[number];
|
|
62
|
+
export declare const WIDGET_COLUMN_CONTRACT: Readonly<Partial<Record<ChartType, ChartColumnContract>>>;
|
|
63
|
+
/**
|
|
64
|
+
* Chart types deliberately outside the contract: `table` renders whatever columns it is given,
|
|
65
|
+
* `graph` takes `RETURN TREE`, `status` correlates several free-form queries keyed on `id`, and
|
|
66
|
+
* `markdown` carries no query at all.
|
|
67
|
+
*/
|
|
68
|
+
export declare const CONTRACT_EXEMPT_CHART_TYPES: ReadonlySet<ChartType>;
|
|
69
|
+
/** Why a query was not checked. Every one of these is a deliberate pass, never a failure. */
|
|
70
|
+
export type SkipReason = 'exempt-chart-type' | 'unknown-chart-type' | 'parameterized' | 'unparseable' | 'tree-projection';
|
|
71
|
+
/** The property a chart groups its categories by, with the target it is read from. */
|
|
72
|
+
export interface CategorySource {
|
|
73
|
+
target: string;
|
|
74
|
+
field: string;
|
|
75
|
+
/**
|
|
76
|
+
* The RETURN alias the category arrives under, which is the row key to group the results on.
|
|
77
|
+
*
|
|
78
|
+
* Read from the query rather than assumed from the chart type: a widget can alias its category
|
|
79
|
+
* anything and still group on it, and reading `row.name` when the query wrote `AS severity` finds
|
|
80
|
+
* nothing to judge.
|
|
81
|
+
*/
|
|
82
|
+
column: string;
|
|
83
|
+
/**
|
|
84
|
+
* The chart's measure alias (`value` or `y`), so advice about this source can show a per-category
|
|
85
|
+
* query in the shape the render gate accepts for THIS chart type — a `count(e) AS value` example
|
|
86
|
+
* on a bar widget is advice the gate itself then rejects.
|
|
87
|
+
*/
|
|
88
|
+
measure: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The property this chart will group its categories by, if it has one.
|
|
92
|
+
*
|
|
93
|
+
* A chart groups on whatever feeds its category column, and the values of that property become the
|
|
94
|
+
* bars or slices. If those values are stored inconsistently the chart splits one category across
|
|
95
|
+
* several — which is why this is worth knowing before the widget is built.
|
|
96
|
+
*
|
|
97
|
+
* `queryCount` gates the fallback below, and nothing else.
|
|
98
|
+
*/
|
|
99
|
+
export declare function categorySource(chartType: string, query: string, options?: {
|
|
100
|
+
queryCount?: number;
|
|
101
|
+
}): CategorySource | null;
|
|
102
|
+
export interface WidgetContractCheck {
|
|
103
|
+
/** Set when the query was not checked; callers must treat this as a pass. */
|
|
104
|
+
skipped?: SkipReason;
|
|
105
|
+
/** Aliases the query actually declares, in order. `null` marks a selector with no `AS`. */
|
|
106
|
+
aliases: Array<string | null>;
|
|
107
|
+
/** Required columns the query does not declare. Non-empty means the widget cannot render. */
|
|
108
|
+
missingRequired: string[];
|
|
109
|
+
/** Recommended columns the query does not declare. Never blocks. */
|
|
110
|
+
missingRecommended: string[];
|
|
111
|
+
/**
|
|
112
|
+
* Columns beyond what the chart reads, where each query is documented to return exactly the
|
|
113
|
+
* required ones. Never blocks.
|
|
114
|
+
*/
|
|
115
|
+
extraColumns?: string[];
|
|
116
|
+
/** A ready-to-run rewrite, when one can be derived unambiguously and verified. */
|
|
117
|
+
correctedQuery?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check one widget query against its chart type's column contract.
|
|
121
|
+
*
|
|
122
|
+
* Purely static — the bundled grammar parses locally, so this costs no backend round-trip. Fails
|
|
123
|
+
* open on every uncertainty (unknown chart type, unparseable query, dashboard parameters, and any
|
|
124
|
+
* error the rewriter throws), because a stale or confused contract must never block a widget that
|
|
125
|
+
* would have rendered.
|
|
126
|
+
*
|
|
127
|
+
* `queryCount` is how many queries the whole widget carries, not how many are being checked here.
|
|
128
|
+
* Some requirements only bind on a lone query — see `singleQueryRequired` — and omitting it keeps
|
|
129
|
+
* the unconditional contract.
|
|
130
|
+
*/
|
|
131
|
+
export declare function checkWidgetContract(chartType: string, query: string, options?: {
|
|
132
|
+
queryCount?: number;
|
|
133
|
+
}): WidgetContractCheck;
|
|
134
|
+
//# sourceMappingURL=widget-render-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-render-contract.d.ts","sourceRoot":"","sources":["../../../src/server/tools/widget-render-contract.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mGAAmG;IACnG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IACH,YA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;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpC,mBAAmB,CAoErB"}
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONTRACT_EXEMPT_CHART_TYPES = exports.WIDGET_COLUMN_CONTRACT = exports.CHART_TYPES = void 0;
|
|
4
|
+
exports.categorySource = categorySource;
|
|
5
|
+
exports.checkWidgetContract = checkWidgetContract;
|
|
6
|
+
const query_language_parser_1 = require("@jupiterone/query-language-parser");
|
|
7
|
+
const j1ql_filters_js_1 = require("../../utils/j1ql-filters.js");
|
|
8
|
+
/**
|
|
9
|
+
* Every chart type the API accepts. The widget input schema builds its enum from this list, so a
|
|
10
|
+
* new chart type is added in exactly one place — and the drift test then fails until it is either
|
|
11
|
+
* given a contract below or declared exempt.
|
|
12
|
+
*/
|
|
13
|
+
exports.CHART_TYPES = [
|
|
14
|
+
'area',
|
|
15
|
+
'bar',
|
|
16
|
+
'graph',
|
|
17
|
+
'line',
|
|
18
|
+
'markdown',
|
|
19
|
+
'matrix',
|
|
20
|
+
'number',
|
|
21
|
+
'pie',
|
|
22
|
+
'status',
|
|
23
|
+
'table',
|
|
24
|
+
];
|
|
25
|
+
exports.WIDGET_COLUMN_CONTRACT = {
|
|
26
|
+
// Not a supported Insights widget type. JupiterOne's own documentation lists Number, Pie, Line,
|
|
27
|
+
// Bar, Matrix, Table, Graph and Status, and says "Area Chart is coming soon" (Questions only).
|
|
28
|
+
// No rendering `area` widget exists anywhere in j1dev. Aliasing columns cannot make one draw, so
|
|
29
|
+
// blocking on columns would reject it for a reason that is not the real one — the config lint's
|
|
30
|
+
// `unsupported-chart-type` finding refuses the write and names the real one.
|
|
31
|
+
area: { required: [], recommended: ['x', 'y'] },
|
|
32
|
+
bar: { required: ['x', 'y'] },
|
|
33
|
+
line: { required: ['y'], recommended: ['x', 'line'] },
|
|
34
|
+
matrix: { required: ['x', 'y'], recommended: ['label'] },
|
|
35
|
+
number: { required: ['value'], exactColumns: true },
|
|
36
|
+
pie: { required: ['value'], singleQueryRequired: ['name'], recommended: ['name'] },
|
|
37
|
+
// Structural rather than alias-shaped, and both were exempt until a field test found them
|
|
38
|
+
// accepted silently — `graph` is usually the demo hero widget, so its blank is the visible one.
|
|
39
|
+
graph: { required: [], projection: 'tree' },
|
|
40
|
+
status: { required: ['id'], perQuery: true },
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Chart types deliberately outside the contract: `table` renders whatever columns it is given,
|
|
44
|
+
* `graph` takes `RETURN TREE`, `status` correlates several free-form queries keyed on `id`, and
|
|
45
|
+
* `markdown` carries no query at all.
|
|
46
|
+
*/
|
|
47
|
+
exports.CONTRACT_EXEMPT_CHART_TYPES = new Set([
|
|
48
|
+
'markdown',
|
|
49
|
+
'table',
|
|
50
|
+
]);
|
|
51
|
+
/**
|
|
52
|
+
* The property this chart will group its categories by, if it has one.
|
|
53
|
+
*
|
|
54
|
+
* A chart groups on whatever feeds its category column, and the values of that property become the
|
|
55
|
+
* bars or slices. If those values are stored inconsistently the chart splits one category across
|
|
56
|
+
* several — which is why this is worth knowing before the widget is built.
|
|
57
|
+
*
|
|
58
|
+
* `queryCount` gates the fallback below, and nothing else.
|
|
59
|
+
*/
|
|
60
|
+
function categorySource(chartType, query, options = {}) {
|
|
61
|
+
const semantics = COLUMN_SEMANTICS[chartType];
|
|
62
|
+
if (!semantics?.category)
|
|
63
|
+
return null;
|
|
64
|
+
let returnNode;
|
|
65
|
+
try {
|
|
66
|
+
returnNode = rootReturnNode(query);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
if (!returnNode || returnNode.projections?.type === 'tree')
|
|
72
|
+
return null;
|
|
73
|
+
const selector = categorySelector(readSelectors(returnNode), semantics.category, options);
|
|
74
|
+
if (!selector?.field || !selector.alias)
|
|
75
|
+
return null;
|
|
76
|
+
// The property belongs to the hop the selector reads, not to the root FIND. Reading the root
|
|
77
|
+
// reported `Host`.`severity` for `FIND Host AS h THAT HAS Finding AS f RETURN f.severity AS x`,
|
|
78
|
+
// so the split probe counted a property the chart never drew and the note's example query named
|
|
79
|
+
// the wrong type. An alias that resolves to nothing (a relationship binding, or a selector with
|
|
80
|
+
// no source at all) yields no source: a probe against the wrong population is worse than none.
|
|
81
|
+
const target = (0, j1ql_filters_js_1.aliasEntityTargets)(query).get(selector.sourceIdentifier ?? '');
|
|
82
|
+
if (!target)
|
|
83
|
+
return null;
|
|
84
|
+
return { target, field: selector.field, column: selector.alias, measure: semantics.measure };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Which selector feeds the chart's category column.
|
|
88
|
+
*
|
|
89
|
+
* Keyed on the recommended alias first, then — on a single-query widget only — on the sole
|
|
90
|
+
* non-aggregate selector. Matching the alias alone missed the widgets most likely to be malformed:
|
|
91
|
+
* the live pie that split into eighteen casing slices aliased its category `severity`, so the one
|
|
92
|
+
* widget that ignored the `name` advisory was also the one the split check never looked at.
|
|
93
|
+
*
|
|
94
|
+
* Two candidates means silence. Which one a chart groups by is not knowable from the AST, and a
|
|
95
|
+
* split reported against the wrong property is a finding about data the chart does not draw.
|
|
96
|
+
*/
|
|
97
|
+
function categorySelector(selectors, category, options) {
|
|
98
|
+
const candidates = selectors.filter((candidate) => !candidate.isAggregate && candidate.field);
|
|
99
|
+
const aliased = candidates.find((candidate) => candidate.alias?.toLowerCase() === category.toLowerCase());
|
|
100
|
+
if (aliased)
|
|
101
|
+
return aliased;
|
|
102
|
+
return options.queryCount === 1 && candidates.length === 1 ? candidates[0] : undefined;
|
|
103
|
+
}
|
|
104
|
+
const PASS = (skipped) => ({
|
|
105
|
+
skipped,
|
|
106
|
+
aliases: [],
|
|
107
|
+
missingRequired: [],
|
|
108
|
+
missingRecommended: [],
|
|
109
|
+
});
|
|
110
|
+
function readSelectors(returnNode) {
|
|
111
|
+
return (returnNode.projections?.selectors ?? []).map((selector) => {
|
|
112
|
+
const isAggregate = typeof selector.aggregatingFunction === 'string';
|
|
113
|
+
const identifier = selector.node?.sourceIdentifier ?? selector.sourceIdentifier ?? '';
|
|
114
|
+
const field = selector.node?.field ?? selector.field;
|
|
115
|
+
const projection = field ? `${identifier}.${field}` : identifier;
|
|
116
|
+
return {
|
|
117
|
+
alias: selector.alias ?? null,
|
|
118
|
+
isAggregate,
|
|
119
|
+
expression: isAggregate ? `${selector.aggregatingFunction}(${projection})` : projection,
|
|
120
|
+
field: isAggregate ? undefined : field,
|
|
121
|
+
sourceIdentifier: identifier,
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Which required column carries the measure and which the category, for chart types where the two
|
|
127
|
+
* roles are distinct. `matrix` is absent deliberately: its `x` and `y` are both dimensions, so
|
|
128
|
+
* knowing which selector aggregates says nothing about which axis it belongs on.
|
|
129
|
+
*/
|
|
130
|
+
const COLUMN_SEMANTICS = {
|
|
131
|
+
area: { category: 'x', measure: 'y' },
|
|
132
|
+
bar: { category: 'x', measure: 'y' },
|
|
133
|
+
line: { category: 'x', measure: 'y' },
|
|
134
|
+
number: { measure: 'value' },
|
|
135
|
+
pie: { category: 'name', measure: 'value' },
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* The root traversal's RETURN clause, or null when the query has none.
|
|
139
|
+
*
|
|
140
|
+
* Reads `ast.return` at the root and nothing else. A traversal chain (`FIND X THAT HAS Y`) builds a
|
|
141
|
+
* CYCLIC ast — `next` carries back-references — so walking it to find a `return` node overflows the
|
|
142
|
+
* stack. The root node carries `return` directly even for chains, which is why no walk is needed.
|
|
143
|
+
*/
|
|
144
|
+
function rootReturnNode(query) {
|
|
145
|
+
const ast = (0, query_language_parser_1.parse)(query);
|
|
146
|
+
return ast?.return ?? null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Resolve the contract against how many queries the widget carries.
|
|
150
|
+
*
|
|
151
|
+
* `queryCount` is optional and absence means "not stated" rather than "many": a caller that does not
|
|
152
|
+
* know gets the unconditional contract, so a single-query requirement can only ever block a widget
|
|
153
|
+
* whose shape was actually established. A column promoted to required drops out of `recommended`,
|
|
154
|
+
* because reporting the same column as both missing-required and missing-recommended reads as two
|
|
155
|
+
* separate problems.
|
|
156
|
+
*/
|
|
157
|
+
function columnSets(contract, queryCount) {
|
|
158
|
+
const required = queryCount === 1 && contract.singleQueryRequired
|
|
159
|
+
? [...contract.required, ...contract.singleQueryRequired]
|
|
160
|
+
: contract.required;
|
|
161
|
+
const promoted = new Set(required.map((column) => column.toLowerCase()));
|
|
162
|
+
return {
|
|
163
|
+
required,
|
|
164
|
+
recommended: (contract.recommended ?? []).filter((column) => !promoted.has(column.toLowerCase())),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Compare the query's aliases against the contract. Pure and non-recursive — the rewriter re-runs
|
|
169
|
+
* this to verify its own output, so it must never call back into the rewriting entry point.
|
|
170
|
+
*
|
|
171
|
+
* Alias matching is case-INSENSITIVE. Whether the renderer resolves `AS Value` is unverified, and
|
|
172
|
+
* the two ways of being wrong are not symmetric: matching case-sensitively risks hard-blocking a
|
|
173
|
+
* widget that renders, while matching loosely risks passing one that does not — the status quo,
|
|
174
|
+
* which the row-count preflight still reports on.
|
|
175
|
+
*/
|
|
176
|
+
function evaluateContract(columns, aliases) {
|
|
177
|
+
const declared = new Set(aliases.filter((alias) => alias !== null).map((alias) => alias.toLowerCase()));
|
|
178
|
+
return {
|
|
179
|
+
missingRequired: columns.required.filter((column) => !declared.has(column.toLowerCase())),
|
|
180
|
+
missingRecommended: columns.recommended.filter((column) => !declared.has(column.toLowerCase())),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The verdict on a query that declares no column the chart can read.
|
|
185
|
+
*
|
|
186
|
+
* Two shapes reach it and neither can render: a query with no RETURN clause at all, and a
|
|
187
|
+
* `RETURN TREE` on a chart that draws columns. Both used to pass the gate — a `number` query with
|
|
188
|
+
* no RETURN was created and drew blank, and so was a pie returning a tree. No corrected query is
|
|
189
|
+
* offered: there are no selectors to rename, and deriving columns from a tree projection would be
|
|
190
|
+
* a guess about what the widget meant to count.
|
|
191
|
+
*/
|
|
192
|
+
function noReadableColumns(columns) {
|
|
193
|
+
return { aliases: [], ...evaluateContract(columns, []) };
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Check one widget query against its chart type's column contract.
|
|
197
|
+
*
|
|
198
|
+
* Purely static — the bundled grammar parses locally, so this costs no backend round-trip. Fails
|
|
199
|
+
* open on every uncertainty (unknown chart type, unparseable query, dashboard parameters, and any
|
|
200
|
+
* error the rewriter throws), because a stale or confused contract must never block a widget that
|
|
201
|
+
* would have rendered.
|
|
202
|
+
*
|
|
203
|
+
* `queryCount` is how many queries the whole widget carries, not how many are being checked here.
|
|
204
|
+
* Some requirements only bind on a lone query — see `singleQueryRequired` — and omitting it keeps
|
|
205
|
+
* the unconditional contract.
|
|
206
|
+
*/
|
|
207
|
+
function checkWidgetContract(chartType, query, options = {}) {
|
|
208
|
+
if (exports.CONTRACT_EXEMPT_CHART_TYPES.has(chartType))
|
|
209
|
+
return PASS('exempt-chart-type');
|
|
210
|
+
const contract = exports.WIDGET_COLUMN_CONTRACT[chartType];
|
|
211
|
+
if (!contract)
|
|
212
|
+
return PASS('unknown-chart-type');
|
|
213
|
+
// Parsed BEFORE the `{{parameter}}` check, because most parameterized queries are checkable: a
|
|
214
|
+
// parameter inside a string literal (`WITH name = '{{param}}'`) parses and leaves the RETURN
|
|
215
|
+
// aliases entirely static, which is the part being judged. Only a query the parameters make
|
|
216
|
+
// unparseable is not ours to judge — substituting a placeholder value to force a parse would
|
|
217
|
+
// risk hard-blocking an interactive board over a mangled parse.
|
|
218
|
+
let returnNode;
|
|
219
|
+
try {
|
|
220
|
+
returnNode = rootReturnNode(query);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
// Syntax is the J1QL validator's job; it runs first and owns the error message.
|
|
224
|
+
return PASS(query.includes('{{') ? 'parameterized' : 'unparseable');
|
|
225
|
+
}
|
|
226
|
+
// A parameterized query with no RETURN clause keeps the benefit of the doubt: the stored form is
|
|
227
|
+
// not what renders, and hard-blocking an interactive board is the expensive direction.
|
|
228
|
+
if (!returnNode && query.includes('{{'))
|
|
229
|
+
return PASS('parameterized');
|
|
230
|
+
const isTree = returnNode?.projections?.type === 'tree';
|
|
231
|
+
if (contract.projection === 'tree') {
|
|
232
|
+
return isTree
|
|
233
|
+
? PASS('tree-projection')
|
|
234
|
+
: {
|
|
235
|
+
aliases: [],
|
|
236
|
+
missingRequired: ['RETURN TREE'],
|
|
237
|
+
missingRecommended: [],
|
|
238
|
+
correctedQuery: treeCorrection(query),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const columns = columnSets(contract, options.queryCount);
|
|
242
|
+
// A query with no RETURN declares no column, and a tree projection carries none — neither can
|
|
243
|
+
// render in a chart that draws columns.
|
|
244
|
+
if (isTree || !returnNode)
|
|
245
|
+
return noReadableColumns(columns);
|
|
246
|
+
const selectors = readSelectors(returnNode);
|
|
247
|
+
const aliases = selectors.map((selector) => selector.alias);
|
|
248
|
+
const { missingRequired, missingRecommended } = evaluateContract(columns, aliases);
|
|
249
|
+
const check = { aliases, missingRequired, missingRecommended };
|
|
250
|
+
if (contract.exactColumns) {
|
|
251
|
+
const allowed = new Set(columns.required.map((column) => column.toLowerCase()));
|
|
252
|
+
const extras = aliases.filter((alias) => alias !== null && !allowed.has(alias.toLowerCase()));
|
|
253
|
+
if (extras.length > 0)
|
|
254
|
+
check.extraColumns = extras;
|
|
255
|
+
}
|
|
256
|
+
if (missingRequired.length > 0) {
|
|
257
|
+
try {
|
|
258
|
+
const corrected = suggestCorrectedQuery(query, chartType, columns, selectors, missingRequired);
|
|
259
|
+
if (corrected)
|
|
260
|
+
check.correctedQuery = corrected;
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
// A rewrite is a convenience; never let one turn a clean rejection into a crash.
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return check;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Give a graph widget's query the `RETURN TREE` it draws.
|
|
270
|
+
*
|
|
271
|
+
* The traversal is what the widget draws; the columns are what stops it drawing. A query with no
|
|
272
|
+
* RETURN at all gets one appended — that is the same widget one clause short, and the graph is the
|
|
273
|
+
* demo hero widget, so its blank is the visible one. Either edit is verified by re-parsing and
|
|
274
|
+
* abandoned rather than guessed at.
|
|
275
|
+
*/
|
|
276
|
+
function treeCorrection(query) {
|
|
277
|
+
const replaced = query.replace(/\bRETURN\b[\s\S]*$/i, 'RETURN TREE');
|
|
278
|
+
const corrected = replaced === query ? `${query.trimEnd()} RETURN TREE` : replaced;
|
|
279
|
+
try {
|
|
280
|
+
const verified = rootReturnNode(corrected);
|
|
281
|
+
return verified?.projections?.type === 'tree' ? corrected : undefined;
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/** Escapes a literal for embedding in a RegExp. */
|
|
288
|
+
function escapeRegExp(literal) {
|
|
289
|
+
return literal.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
290
|
+
}
|
|
291
|
+
/** Single- and double-quoted J1QL string literals, spanning escaped quotes. */
|
|
292
|
+
const STRING_LITERAL = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g;
|
|
293
|
+
/**
|
|
294
|
+
* Apply a substitution to the query's code, never to its string literals.
|
|
295
|
+
*
|
|
296
|
+
* A filter value can legitimately contain the text being rewritten — `WITH tag.Category =
|
|
297
|
+
* 'Infrastructure as Code'` holds a real ` as Code` sequence — and rewriting inside it silently
|
|
298
|
+
* changes what the query matches while still parsing and still satisfying the contract, so no
|
|
299
|
+
* amount of re-verification catches it. Segmenting on literals is the only reliable guard.
|
|
300
|
+
*/
|
|
301
|
+
function replaceOutsideLiterals(query, pattern, replacement) {
|
|
302
|
+
const apply = (segment) => typeof replacement === 'string'
|
|
303
|
+
? segment.replace(pattern, replacement)
|
|
304
|
+
: segment.replace(pattern, replacement);
|
|
305
|
+
let out = '';
|
|
306
|
+
let cursor = 0;
|
|
307
|
+
STRING_LITERAL.lastIndex = 0;
|
|
308
|
+
let literal;
|
|
309
|
+
while ((literal = STRING_LITERAL.exec(query)) !== null) {
|
|
310
|
+
out += apply(query.slice(cursor, literal.index)) + literal[0];
|
|
311
|
+
cursor = literal.index + literal[0].length;
|
|
312
|
+
}
|
|
313
|
+
return out + apply(query.slice(cursor));
|
|
314
|
+
}
|
|
315
|
+
/** A selector's target column: the measure if it aggregates, otherwise the category. */
|
|
316
|
+
function targetColumn(selector, semantics) {
|
|
317
|
+
return selector.isAggregate ? semantics.measure : semantics.category;
|
|
318
|
+
}
|
|
319
|
+
/** Count occurrences of a pattern in the query's code, ignoring string literals. */
|
|
320
|
+
function countInCode(query, pattern) {
|
|
321
|
+
return (query.replace(STRING_LITERAL, "''").match(pattern) ?? []).length;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Give an unaliased selector the alias its chart reads: `RETURN count(u)` becomes
|
|
325
|
+
* `RETURN count(u) AS value`.
|
|
326
|
+
*
|
|
327
|
+
* The most common way to build a blank number widget, and the one violation class that previously
|
|
328
|
+
* got no runnable query back at all. The projection is rebuilt from the AST and matched with
|
|
329
|
+
* flexible whitespace, so `count( u )` is found as readily as `count(u)`; it must occur exactly
|
|
330
|
+
* once outside string literals, or the alias could land on the wrong copy.
|
|
331
|
+
*/
|
|
332
|
+
function appendAlias(query, selector, column) {
|
|
333
|
+
const open = selector.expression.indexOf('(');
|
|
334
|
+
const pattern = open === -1
|
|
335
|
+
? new RegExp(`\\b${escapeRegExp(selector.expression)}\\b`, 'g')
|
|
336
|
+
: new RegExp(`\\b${escapeRegExp(selector.expression.slice(0, open))}\\s*\\(\\s*` +
|
|
337
|
+
`${escapeRegExp(selector.expression.slice(open + 1, -1))}\\s*\\)`, 'gi');
|
|
338
|
+
if (countInCode(query, pattern) !== 1)
|
|
339
|
+
return null;
|
|
340
|
+
return replaceOutsideLiterals(query, pattern, (match) => `${match} AS ${column}`);
|
|
341
|
+
}
|
|
342
|
+
/** Rename one alias everywhere it is used, or return null if it is used somewhere unmodelled. */
|
|
343
|
+
function renameAlias(query, oldAlias, newAlias) {
|
|
344
|
+
const escaped = escapeRegExp(oldAlias);
|
|
345
|
+
const definition = new RegExp(`\\bAS\\s+${escaped}\\b`, 'gi');
|
|
346
|
+
const ordering = new RegExp(`(\\bORDER\\s+BY\\s+)${escaped}\\b`, 'gi');
|
|
347
|
+
// Every occurrence must be one we know how to rewrite; otherwise the alias is load-bearing
|
|
348
|
+
// somewhere we do not model and the rewrite would be a guess. A dot-prefixed occurrence is not
|
|
349
|
+
// one of them: it is the tail of a property path, and J1QL has no syntax for reaching a RETURN
|
|
350
|
+
// alias through a dot. Counting those made the commonest shape of all unfixable — a selector
|
|
351
|
+
// aliased after the property it reads (`f.severity AS severity`), which is exactly how the
|
|
352
|
+
// undefined-donut pie was written.
|
|
353
|
+
const total = countInCode(query, new RegExp(`(?<!\\.)\\b${escaped}\\b`, 'g'));
|
|
354
|
+
if (total !== countInCode(query, definition) + countInCode(query, ordering))
|
|
355
|
+
return null;
|
|
356
|
+
return replaceOutsideLiterals(replaceOutsideLiterals(query, definition, `AS ${newAlias}`), ordering, `$1${newAlias}`);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Derive a ready-to-run rewrite, or return null.
|
|
360
|
+
*
|
|
361
|
+
* Every edit is driven by the AST rather than by position or by alias spelling. A selector that
|
|
362
|
+
* aggregates is the measure, anything else is the category — so `count(p) AS total, p.displayName
|
|
363
|
+
* AS label` maps the count to `y` and the name to `x`. Pairing by position got that backwards, and
|
|
364
|
+
* pairing by alias name could not decide it at all. Chart types whose columns are both dimensions
|
|
365
|
+
* (`matrix`) have no semantics entry and are never rewritten.
|
|
366
|
+
*
|
|
367
|
+
* Two edits are attempted, both verified by re-parsing the result: renaming a wrong alias, and
|
|
368
|
+
* giving an unaliased selector the alias the chart reads.
|
|
369
|
+
*
|
|
370
|
+
* `columns` is the widget's resolved contract rather than the chart's, which is what lets this fix
|
|
371
|
+
* the whole violation. Correcting only `value` on a single-query pie is how the undefined-donut got
|
|
372
|
+
* built: the rewrite satisfied the gate as it stood, left the category aliased `severity`, and
|
|
373
|
+
* shipped a widget drawing one slice labelled `undefined` over the entire population.
|
|
374
|
+
*/
|
|
375
|
+
function suggestCorrectedQuery(query, chartType, columns, selectors, missingRequired) {
|
|
376
|
+
const semantics = COLUMN_SEMANTICS[chartType];
|
|
377
|
+
if (!semantics)
|
|
378
|
+
return null;
|
|
379
|
+
const wanted = new Set([...columns.required, ...columns.recommended].map((column) => column.toLowerCase()));
|
|
380
|
+
const needed = new Set(missingRequired.map((column) => column.toLowerCase()));
|
|
381
|
+
let corrected = query;
|
|
382
|
+
const filled = new Set();
|
|
383
|
+
for (const selector of selectors) {
|
|
384
|
+
const column = targetColumn(selector, semantics);
|
|
385
|
+
// Only touch a selector whose target column is one we are actually missing, and only once per
|
|
386
|
+
// column: two aggregates competing for `value` is ambiguous, so bail rather than pick.
|
|
387
|
+
if (!column || !needed.has(column.toLowerCase()))
|
|
388
|
+
continue;
|
|
389
|
+
if (selector.alias && wanted.has(selector.alias.toLowerCase()))
|
|
390
|
+
continue;
|
|
391
|
+
if (filled.has(column))
|
|
392
|
+
return null;
|
|
393
|
+
filled.add(column);
|
|
394
|
+
const next = selector.alias
|
|
395
|
+
? renameAlias(corrected, selector.alias, column)
|
|
396
|
+
: appendAlias(corrected, selector, column);
|
|
397
|
+
if (!next)
|
|
398
|
+
return null;
|
|
399
|
+
corrected = next;
|
|
400
|
+
}
|
|
401
|
+
// No textual change means every candidate was already correct or unreachable — a quoted alias
|
|
402
|
+
// (`AS "Total Users"`), which the parser reports unquoted. Returning the query verbatim would
|
|
403
|
+
// hand back the rejected one; re-verifying it would recurse forever on identical input.
|
|
404
|
+
if (corrected === query)
|
|
405
|
+
return null;
|
|
406
|
+
let verified;
|
|
407
|
+
try {
|
|
408
|
+
verified = rootReturnNode(corrected);
|
|
409
|
+
}
|
|
410
|
+
catch {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
if (!verified || verified.projections?.type === 'tree')
|
|
414
|
+
return null;
|
|
415
|
+
// Verified against the SAME resolved column sets the gate used. Verifying against the chart's
|
|
416
|
+
// unconditional contract would bless a query the gate then rejects, which is worse than offering
|
|
417
|
+
// no correction: the caller runs what the server handed it and gets the same refusal back.
|
|
418
|
+
const verifiedAliases = readSelectors(verified).map((selector) => selector.alias);
|
|
419
|
+
return evaluateContract(columns, verifiedAliases).missingRequired.length === 0 ? corrected : null;
|
|
420
|
+
}
|
|
421
|
+
//# sourceMappingURL=widget-render-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-render-contract.js","sourceRoot":"","sources":["../../../src/server/tools/widget-render-contract.ts"],"names":[],"mappings":";;;AA+IA,wCA4BC;AA0MD,kDAwEC;AA7bD,6EAA0D;AAC1D,iEAAiE;AAyDjE;;;;GAIG;AACU,QAAA,WAAW,GAAG;IACzB,MAAM;IACN,KAAK;IACL,OAAO;IACP,MAAM;IACN,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,OAAO;CACC,CAAC;AAIE,QAAA,sBAAsB,GAA8D;IAC/F,gGAAgG;IAChG,+FAA+F;IAC/F,iGAAiG;IACjG,gGAAgG;IAChG,6EAA6E;IAC7E,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;IAC/C,GAAG,EAAE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C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ChartType } from './widget-render-contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* The settings keys each chart type's persistence schema accepts.
|
|
4
|
+
*
|
|
5
|
+
* Unknown keys are stripped silently on save, at every level, so a widget written with
|
|
6
|
+
* `settings.number.format` is created, reports success, and renders the default appearance. A model
|
|
7
|
+
* whose cached tool docs predate a deploy therefore cannot discover a setting by trying one:
|
|
8
|
+
* measured on a live board (Sonnet, board `b383b41c`), a capable model guessed eight key names for
|
|
9
|
+
* features that all exist under other names — `format` for `showAsPercentage`, `numerator` for
|
|
10
|
+
* `numeratorQueryName`, `decimals` for `decimalLimit`, `thresholds` for the threshold keys — had
|
|
11
|
+
* every guess correctly reported as dropped, and concluded from that the capability does not exist.
|
|
12
|
+
* Tool descriptions and instructions are cached for a session's whole life, so the write-path
|
|
13
|
+
* response is the only channel that reaches a session already running: these names live here so the
|
|
14
|
+
* response can name them.
|
|
15
|
+
*
|
|
16
|
+
* SOURCE OF TRUTH: dashboard-service `src/commands/widget/types.ts`, which is what actually decides
|
|
17
|
+
* whether a key survives a save. Transcribed, so this table can only be as current as this server
|
|
18
|
+
* version — every note built from it says so rather than claiming the API accepts nothing else.
|
|
19
|
+
* `widget-settings-keys.test.ts` fails if a chart type is added to `CHART_TYPES` without a decision
|
|
20
|
+
* here.
|
|
21
|
+
*/
|
|
22
|
+
export declare const WIDGET_SETTINGS_KEYS: Readonly<Partial<Record<ChartType, readonly string[]>>>;
|
|
23
|
+
/**
|
|
24
|
+
* Chart types whose settings block the service stores as an arbitrary record.
|
|
25
|
+
*
|
|
26
|
+
* `status` has no key schema at all, so nothing sent under it is ever dropped for being unknown and
|
|
27
|
+
* there is no list to offer. A note must not invent one: telling a caller its `status` key is
|
|
28
|
+
* invalid, when the service accepts any key, sends it looking for a spelling mistake that is not
|
|
29
|
+
* there.
|
|
30
|
+
*/
|
|
31
|
+
export declare const FREE_FORM_SETTINGS_CHART_TYPES: ReadonlySet<ChartType>;
|
|
32
|
+
/** Threshold keys, which colour a chart by value rather than configuring its appearance. */
|
|
33
|
+
export declare const THRESHOLD_SETTINGS_KEYS: readonly string[];
|
|
34
|
+
/** The comparison a threshold applies, from the same service schema. */
|
|
35
|
+
export declare const THRESHOLD_LIMIT_CONDITIONS: readonly string[];
|
|
36
|
+
/**
|
|
37
|
+
* The object a threshold key takes.
|
|
38
|
+
*
|
|
39
|
+
* Built from `THRESHOLD_LIMIT_CONDITIONS` rather than written out, so the prose cannot drift from
|
|
40
|
+
* the list a caller is told to choose from. Sub-keys are stripped on the same rules as top-level
|
|
41
|
+
* ones — `error: {above: 0}` persists as `error: {}`, a stored threshold that colours nothing.
|
|
42
|
+
*/
|
|
43
|
+
export declare const THRESHOLD_SETTINGS_SHAPE: string;
|
|
44
|
+
/**
|
|
45
|
+
* The keys this server knows a chart type accepts, or `undefined` when it has nothing to say.
|
|
46
|
+
*
|
|
47
|
+
* `undefined` covers both an unrecognised chart type and a free-form one, because the caller-facing
|
|
48
|
+
* consequence is the same: no list to publish.
|
|
49
|
+
*/
|
|
50
|
+
export declare function settingsKeysFor(chartType: string): readonly string[] | undefined;
|
|
51
|
+
//# sourceMappingURL=widget-settings-keys.d.ts.map
|