@schemacast/core 0.0.0-stage → 0.5.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.
Files changed (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -2
  3. package/dist/compiler/aggregate-bar-categories.d.ts +88 -0
  4. package/dist/compiler/aggregate-bar-categories.js +202 -0
  5. package/dist/compiler/apply-view-hints.d.ts +79 -0
  6. package/dist/compiler/apply-view-hints.js +339 -0
  7. package/dist/compiler/bucket-long-tail.d.ts +39 -0
  8. package/dist/compiler/bucket-long-tail.js +132 -0
  9. package/dist/compiler/build-ast.d.ts +51 -0
  10. package/dist/compiler/build-ast.js +360 -0
  11. package/dist/compiler/explain-rejections.d.ts +30 -0
  12. package/dist/compiler/explain-rejections.js +65 -0
  13. package/dist/compiler/judge-edge-rows.d.ts +31 -0
  14. package/dist/compiler/judge-edge-rows.js +65 -0
  15. package/dist/compiler/label-formatter.d.ts +22 -0
  16. package/dist/compiler/label-formatter.js +73 -0
  17. package/dist/compiler/long-format-line.d.ts +90 -0
  18. package/dist/compiler/long-format-line.js +144 -0
  19. package/dist/compiler/refresh-view-reasons.d.ts +17 -0
  20. package/dist/compiler/refresh-view-reasons.js +55 -0
  21. package/dist/compiler/stream-caster.d.ts +35 -0
  22. package/dist/compiler/stream-caster.js +45 -0
  23. package/dist/index.d.ts +34 -0
  24. package/dist/index.js +28 -0
  25. package/dist/normalizer/flatten.d.ts +24 -0
  26. package/dist/normalizer/flatten.js +82 -0
  27. package/dist/normalizer/graph-edge-keys.d.ts +80 -0
  28. package/dist/normalizer/graph-edge-keys.js +169 -0
  29. package/dist/normalizer/parse-safe.d.ts +37 -0
  30. package/dist/normalizer/parse-safe.js +389 -0
  31. package/dist/normalizer/promote-edge-list.d.ts +18 -0
  32. package/dist/normalizer/promote-edge-list.js +60 -0
  33. package/dist/normalizer/unwrap-envelope.d.ts +75 -0
  34. package/dist/normalizer/unwrap-envelope.js +309 -0
  35. package/dist/profiler/parse-locale-date.d.ts +46 -0
  36. package/dist/profiler/parse-locale-date.js +114 -0
  37. package/dist/profiler/parse-numeric.d.ts +23 -0
  38. package/dist/profiler/parse-numeric.js +79 -0
  39. package/dist/profiler/semantic-types.d.ts +79 -0
  40. package/dist/profiler/semantic-types.js +439 -0
  41. package/dist/profiler/stats.d.ts +63 -0
  42. package/dist/profiler/stats.js +186 -0
  43. package/dist/profiler/topology.d.ts +16 -0
  44. package/dist/profiler/topology.js +49 -0
  45. package/dist/profiler/unit-source.d.ts +28 -0
  46. package/dist/profiler/unit-source.js +104 -0
  47. package/dist/profiler/value-type-mix.d.ts +49 -0
  48. package/dist/profiler/value-type-mix.js +200 -0
  49. package/dist/report/ignored-field-reasons.d.ts +33 -0
  50. package/dist/report/ignored-field-reasons.js +200 -0
  51. package/dist/report/pagination.d.ts +50 -0
  52. package/dist/report/pagination.js +158 -0
  53. package/dist/report/visualize-report.d.ts +92 -0
  54. package/dist/report/visualize-report.js +459 -0
  55. package/dist/scorer/axis-scale.d.ts +36 -0
  56. package/dist/scorer/axis-scale.js +62 -0
  57. package/dist/scorer/bands.d.ts +33 -0
  58. package/dist/scorer/bands.js +39 -0
  59. package/dist/scorer/intent-matcher.d.ts +26 -0
  60. package/dist/scorer/intent-matcher.js +88 -0
  61. package/dist/scorer/metric-quality.d.ts +116 -0
  62. package/dist/scorer/metric-quality.js +195 -0
  63. package/dist/scorer/node-graph-color.d.ts +14 -0
  64. package/dist/scorer/node-graph-color.js +19 -0
  65. package/dist/scorer/numeric-x.d.ts +101 -0
  66. package/dist/scorer/numeric-x.js +190 -0
  67. package/dist/scorer/ranker.d.ts +46 -0
  68. package/dist/scorer/ranker.js +213 -0
  69. package/dist/scorer/rules.d.ts +109 -0
  70. package/dist/scorer/rules.js +1107 -0
  71. package/dist/scorer/view-reasons.d.ts +47 -0
  72. package/dist/scorer/view-reasons.js +78 -0
  73. package/dist/types/ast.d.ts +201 -0
  74. package/dist/types/ast.js +2 -0
  75. package/dist/types/options.d.ts +58 -0
  76. package/dist/types/options.js +2 -0
  77. package/dist/types/profile.d.ts +40 -0
  78. package/dist/types/profile.js +2 -0
  79. package/dist/utils/clone-json-value.d.ts +13 -0
  80. package/dist/utils/clone-json-value.js +52 -0
  81. package/dist/utils/key-tokens.d.ts +27 -0
  82. package/dist/utils/key-tokens.js +40 -0
  83. package/dist/utils/pluralize.d.ts +9 -0
  84. package/dist/utils/pluralize.js +11 -0
  85. package/dist/utils/safe-serialize.d.ts +12 -0
  86. package/dist/utils/safe-serialize.js +43 -0
  87. package/dist/utils/type-guards.d.ts +59 -0
  88. package/dist/utils/type-guards.js +89 -0
  89. package/package.json +39 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wael Zohny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # `@schemacast/core`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Zero-dependency JSON profiler, scorer, and Visual AST compiler.
4
+
5
+ **0.x — API may change.**
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @schemacast/core
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { cast } from '@schemacast/core';
17
+
18
+ const spec = cast([
19
+ { recorded_at: '2026-12-01T10:00:00Z', requests: 42 },
20
+ { recorded_at: '2026-12-01T11:00:00Z', requests: 57 },
21
+ ]);
22
+
23
+ console.log(spec.primaryView.archetype); // e.g. 'line-chart'
24
+ ```
@@ -0,0 +1,88 @@
1
+ import type { FieldDescriptor, OmittedField } from '../types/ast.js';
2
+ /**
3
+ * Key tokens of numbers that are averages, rates, per-unit prices, or point-in-time readings.
4
+ * Adding two of them is meaningless, so they are never summed even when the column holds plain
5
+ * numbers. Matching is by whole token (`unit_price` and `unitPrice` hit `price`; `percentile`
6
+ * does not hit `rate`, and `pricey` does not hit `price`), so a token only needs listing once.
7
+ */
8
+ export declare const NON_ADDITIVE_METRIC_KEY_TOKENS: readonly string[];
9
+ /**
10
+ * Key tokens that say a column is an average (`avg_count`, `median_total`). They win over every
11
+ * other token, including the count-like ones: an average of counts is still not additive.
12
+ */
13
+ export declare const AVERAGE_METRIC_KEY_TOKENS: readonly string[];
14
+ /**
15
+ * Key tokens that say a column counts or totals something (`retry_level_count`, `total_price`).
16
+ * They win over the other `NON_ADDITIVE_METRIC_KEY_TOKENS`: a count of retries is additive even
17
+ * when the name also mentions a level, but not when it is an average (see
18
+ * `AVERAGE_METRIC_KEY_TOKENS`). Matching is by whole token.
19
+ */
20
+ export declare const COUNT_LIKE_METRIC_KEY_TOKENS: readonly string[];
21
+ /**
22
+ * Rows of a bar chart whose category repeats, summed into one row per category.
23
+ *
24
+ * @example
25
+ * const grouped: BarAggregation = {
26
+ * rows: [{ region: 'EMEA', revenue: 300 }],
27
+ * groupedRowCount: 3,
28
+ * categoryCount: 1,
29
+ * xKey: 'region',
30
+ * summedKeys: ['revenue'],
31
+ * omittedFields: [{ field: 'growth_pct', reason: 'a percentage cannot be summed' }],
32
+ * };
33
+ */
34
+ export interface BarAggregation {
35
+ /** One row per category, in first-seen order, holding only the category and summed metrics */
36
+ rows: Record<string, unknown>[];
37
+ /** Source rows that were grouped */
38
+ groupedRowCount: number;
39
+ /** Distinct categories, i.e. `rows.length` */
40
+ categoryCount: number;
41
+ /** Category field */
42
+ xKey: string;
43
+ /** Metric fields that were summed; these are the view's `y` bindings afterwards */
44
+ summedKeys: string[];
45
+ /** Bound metrics that cannot be summed and were left out of the bar view, with why */
46
+ omittedFields: OmittedField[];
47
+ }
48
+ /**
49
+ * True for a field whose values can be added together: a number or currency column whose name
50
+ * does not mark it as an average, rate, price, reading or id. Percentages are never additive.
51
+ *
52
+ * @example
53
+ * isAdditiveMetric({ key: 'revenue', semanticType: 'currency' }); // true
54
+ * isAdditiveMetric({ key: 'avg_latency', semanticType: 'number' }); // false
55
+ */
56
+ export declare function isAdditiveMetric(field: Pick<FieldDescriptor, 'key' | 'semanticType'> | undefined): boolean;
57
+ /**
58
+ * Sums the additive metrics of a bar chart whose category repeats (`EMEA` three times becomes
59
+ * one `EMEA` row). Metrics that cannot be summed are left out of the result and listed in
60
+ * `omittedFields`, so the bar view never shows a half-summed series. Returns `null` when the
61
+ * category does not repeat or no bound metric is additive (the raw rows are charted instead, see
62
+ * {@link explainBlockedAggregation}). The input rows are not mutated.
63
+ *
64
+ * @param records - Normalized dataset rows.
65
+ * @param xKey - Category field.
66
+ * @param yKeys - Metric fields bound to the bar chart.
67
+ * @param fields - Field descriptors, used to decide which metrics are additive.
68
+ *
69
+ * @example
70
+ * aggregateRepeatedCategories(
71
+ * [{ region: 'EMEA', revenue: 100 }, { region: 'EMEA', revenue: 200 }],
72
+ * 'region',
73
+ * ['revenue'],
74
+ * fields,
75
+ * )?.rows; // [{ region: 'EMEA', revenue: 300 }]
76
+ */
77
+ export declare function aggregateRepeatedCategories(records: readonly Record<string, unknown>[], xKey: string, yKeys: readonly string[], fields: readonly FieldDescriptor[]): BarAggregation | null;
78
+ /**
79
+ * Says why a repeating category was left unaggregated: no bound metric can be summed. Names every
80
+ * such metric. Returns `undefined` when the category does not repeat or at least one metric is
81
+ * additive (that case aggregates and omits the rest instead).
82
+ *
83
+ * @example
84
+ * explainBlockedAggregation(rows, 'region', ['growth_pct'], fields);
85
+ * // 'growth_pct is a percentage, which cannot be summed'
86
+ */
87
+ export declare function explainBlockedAggregation(records: readonly Record<string, unknown>[], xKey: string, yKeys: readonly string[], fields: readonly FieldDescriptor[]): string | undefined;
88
+ //# sourceMappingURL=aggregate-bar-categories.d.ts.map
@@ -0,0 +1,202 @@
1
+ import { parseNumericValue } from '../profiler/parse-numeric.js';
2
+ import { ID_KEY_TOKENS } from '../profiler/semantic-types.js';
3
+ import { hasKeyToken, splitKeyTokens } from '../utils/key-tokens.js';
4
+ /**
5
+ * Key tokens of numbers that are averages, rates, per-unit prices, or point-in-time readings.
6
+ * Adding two of them is meaningless, so they are never summed even when the column holds plain
7
+ * numbers. Matching is by whole token (`unit_price` and `unitPrice` hit `price`; `percentile`
8
+ * does not hit `rate`, and `pricey` does not hit `price`), so a token only needs listing once.
9
+ */
10
+ export const NON_ADDITIVE_METRIC_KEY_TOKENS = [
11
+ 'avg',
12
+ 'average',
13
+ 'mean',
14
+ 'median',
15
+ 'rate',
16
+ 'ratio',
17
+ 'score',
18
+ 'rating',
19
+ 'latency',
20
+ 'price',
21
+ 'temperature',
22
+ 'temp',
23
+ 'percentile',
24
+ 'age',
25
+ 'balance',
26
+ 'level',
27
+ ];
28
+ /**
29
+ * Key tokens that say a column is an average (`avg_count`, `median_total`). They win over every
30
+ * other token, including the count-like ones: an average of counts is still not additive.
31
+ */
32
+ export const AVERAGE_METRIC_KEY_TOKENS = ['avg', 'average', 'mean', 'median'];
33
+ /**
34
+ * Key tokens that say a column counts or totals something (`retry_level_count`, `total_price`).
35
+ * They win over the other `NON_ADDITIVE_METRIC_KEY_TOKENS`: a count of retries is additive even
36
+ * when the name also mentions a level, but not when it is an average (see
37
+ * `AVERAGE_METRIC_KEY_TOKENS`). Matching is by whole token.
38
+ */
39
+ export const COUNT_LIKE_METRIC_KEY_TOKENS = [
40
+ 'count',
41
+ 'total',
42
+ 'qty',
43
+ 'quantity',
44
+ 'num',
45
+ 'sum',
46
+ ];
47
+ /** Decimal places kept when a sum is rounded, so float noise does not reach the chart. */
48
+ const SUM_ROUNDING_FACTOR = 1000;
49
+ /**
50
+ * True for a field whose values can be added together: a number or currency column whose name
51
+ * does not mark it as an average, rate, price, reading or id. Percentages are never additive.
52
+ *
53
+ * @example
54
+ * isAdditiveMetric({ key: 'revenue', semanticType: 'currency' }); // true
55
+ * isAdditiveMetric({ key: 'avg_latency', semanticType: 'number' }); // false
56
+ */
57
+ export function isAdditiveMetric(field) {
58
+ if (field === undefined) {
59
+ return false;
60
+ }
61
+ if (field.semanticType !== 'number' && field.semanticType !== 'currency') {
62
+ return false;
63
+ }
64
+ if (isNumericIdentifier(field.key)) {
65
+ return false;
66
+ }
67
+ return findNonAdditiveToken(field.key) === undefined;
68
+ }
69
+ /** A number named `id` or `user_id` labels a row; adding two of them means nothing. */
70
+ function isNumericIdentifier(key) {
71
+ return hasKeyToken(key, ID_KEY_TOKENS);
72
+ }
73
+ /**
74
+ * Sums the additive metrics of a bar chart whose category repeats (`EMEA` three times becomes
75
+ * one `EMEA` row). Metrics that cannot be summed are left out of the result and listed in
76
+ * `omittedFields`, so the bar view never shows a half-summed series. Returns `null` when the
77
+ * category does not repeat or no bound metric is additive (the raw rows are charted instead, see
78
+ * {@link explainBlockedAggregation}). The input rows are not mutated.
79
+ *
80
+ * @param records - Normalized dataset rows.
81
+ * @param xKey - Category field.
82
+ * @param yKeys - Metric fields bound to the bar chart.
83
+ * @param fields - Field descriptors, used to decide which metrics are additive.
84
+ *
85
+ * @example
86
+ * aggregateRepeatedCategories(
87
+ * [{ region: 'EMEA', revenue: 100 }, { region: 'EMEA', revenue: 200 }],
88
+ * 'region',
89
+ * ['revenue'],
90
+ * fields,
91
+ * )?.rows; // [{ region: 'EMEA', revenue: 300 }]
92
+ */
93
+ export function aggregateRepeatedCategories(records, xKey, yKeys, fields) {
94
+ if (!hasRepeatedCategory(records, xKey)) {
95
+ return null;
96
+ }
97
+ const { summedKeys, omittedFields } = splitAdditiveMetrics(yKeys, fields);
98
+ if (summedKeys.length === 0) {
99
+ return null;
100
+ }
101
+ const fieldByKey = new Map(fields.map((field) => [field.key, field]));
102
+ const groups = new Map();
103
+ for (const record of records) {
104
+ const groupKey = String(record[xKey]);
105
+ const members = groups.get(groupKey) ?? [];
106
+ members.push(record);
107
+ groups.set(groupKey, members);
108
+ }
109
+ const rows = [...groups.values()].map((members) => {
110
+ const row = { [xKey]: members[0]?.[xKey] };
111
+ for (const yKey of summedKeys) {
112
+ row[yKey] = sumMetric(members, yKey, fieldByKey.get(yKey));
113
+ }
114
+ return row;
115
+ });
116
+ return {
117
+ rows,
118
+ groupedRowCount: records.length,
119
+ categoryCount: rows.length,
120
+ xKey,
121
+ summedKeys,
122
+ omittedFields,
123
+ };
124
+ }
125
+ /**
126
+ * Says why a repeating category was left unaggregated: no bound metric can be summed. Names every
127
+ * such metric. Returns `undefined` when the category does not repeat or at least one metric is
128
+ * additive (that case aggregates and omits the rest instead).
129
+ *
130
+ * @example
131
+ * explainBlockedAggregation(rows, 'region', ['growth_pct'], fields);
132
+ * // 'growth_pct is a percentage, which cannot be summed'
133
+ */
134
+ export function explainBlockedAggregation(records, xKey, yKeys, fields) {
135
+ if (!hasRepeatedCategory(records, xKey)) {
136
+ return undefined;
137
+ }
138
+ const { summedKeys, omittedFields } = splitAdditiveMetrics(yKeys, fields);
139
+ if (summedKeys.length > 0 || omittedFields.length === 0) {
140
+ return undefined;
141
+ }
142
+ return omittedFields
143
+ .map((omitted) => `${omitted.field} is ${omitted.reason.replace(' cannot be summed', ', which cannot be summed')}`)
144
+ .join('; ');
145
+ }
146
+ function splitAdditiveMetrics(yKeys, fields) {
147
+ const summedKeys = [];
148
+ const omittedFields = [];
149
+ for (const yKey of yKeys) {
150
+ const field = fields.find((candidate) => candidate.key === yKey);
151
+ if (isAdditiveMetric(field)) {
152
+ summedKeys.push(yKey);
153
+ continue;
154
+ }
155
+ omittedFields.push({ field: yKey, reason: describeNonAdditiveReason(yKey, field) });
156
+ }
157
+ return { summedKeys, omittedFields };
158
+ }
159
+ function describeNonAdditiveReason(key, field) {
160
+ if (field?.semanticType === 'percentage') {
161
+ return 'a percentage cannot be summed';
162
+ }
163
+ if (isNumericIdentifier(key)) {
164
+ return 'an identifier cannot be summed';
165
+ }
166
+ const token = findNonAdditiveToken(key);
167
+ if (token !== undefined) {
168
+ return `an average, rate or per-unit measure ("${token}") cannot be summed`;
169
+ }
170
+ return `a ${field?.semanticType ?? 'non-numeric'} field cannot be summed`;
171
+ }
172
+ function findNonAdditiveToken(key) {
173
+ const tokens = splitKeyTokens(key);
174
+ const averageToken = tokens.find((token) => AVERAGE_METRIC_KEY_TOKENS.includes(token));
175
+ if (averageToken !== undefined) {
176
+ return averageToken;
177
+ }
178
+ if (tokens.some((token) => COUNT_LIKE_METRIC_KEY_TOKENS.includes(token))) {
179
+ return undefined;
180
+ }
181
+ return tokens.find((token) => NON_ADDITIVE_METRIC_KEY_TOKENS.includes(token));
182
+ }
183
+ function hasRepeatedCategory(records, xKey) {
184
+ const seen = new Set();
185
+ for (const record of records) {
186
+ seen.add(String(record[xKey]));
187
+ }
188
+ return seen.size < records.length;
189
+ }
190
+ function sumMetric(members, yKey, field) {
191
+ let sum = 0;
192
+ let parsedCount = 0;
193
+ for (const member of members) {
194
+ const parsed = parseNumericValue(member[yKey], field?.semanticType);
195
+ if (parsed !== null) {
196
+ sum += parsed;
197
+ parsedCount++;
198
+ }
199
+ }
200
+ return parsedCount === 0 ? null : Math.round(sum * SUM_ROUNDING_FACTOR) / SUM_ROUNDING_FACTOR;
201
+ }
202
+ //# sourceMappingURL=aggregate-bar-categories.js.map
@@ -0,0 +1,79 @@
1
+ import type { VisualSpec } from '../types/ast.js';
2
+ /**
3
+ * Field hints an agent can give to override inferred bindings.
4
+ *
5
+ * @example
6
+ * const fields: FieldHints = { x: 'region', y: ['revenue'] };
7
+ */
8
+ export interface FieldHints {
9
+ /** Field shown as the item title / category label */
10
+ label?: string;
11
+ /** Field used for grouping, colors, or lanes */
12
+ group?: string;
13
+ /** Numeric field for the single measured value (same as `y` with one field) */
14
+ value?: string;
15
+ /** Field for the horizontal / category axis */
16
+ x?: string;
17
+ /** Numeric field(s) for the vertical axis */
18
+ y?: string | string[];
19
+ /** Graph edge source field */
20
+ source?: string;
21
+ /** Graph edge target field */
22
+ target?: string;
23
+ }
24
+ /**
25
+ * Caller preferences applied on top of a cast result.
26
+ *
27
+ * @example
28
+ * const hints: ViewHints = { preferView: 'bar-chart', fields: { x: 'name' } };
29
+ */
30
+ export interface ViewHints {
31
+ /** Archetype to put first (e.g. `bar-chart`); must already qualify for the data */
32
+ preferView?: string;
33
+ /** Field overrides per role */
34
+ fields?: FieldHints;
35
+ }
36
+ /**
37
+ * A hint that could not be applied, with the reason.
38
+ *
39
+ * @example
40
+ * const rejection: HintRejection = { hint: 'fields.x', reason: 'field "foo" does not exist' };
41
+ */
42
+ export interface HintRejection {
43
+ /** Hint name, e.g. `preferView` or `fields.x` */
44
+ hint: string;
45
+ /** Why the hint was ignored */
46
+ reason: string;
47
+ }
48
+ /**
49
+ * Result of {@link applyViewHints}.
50
+ *
51
+ * @example
52
+ * const { spec, applied, rejected } = applyViewHints(cast(data), { preferView: 'table' });
53
+ */
54
+ export interface AppliedViewHints {
55
+ /** New spec with hints applied (`data` is shared, never mutated) */
56
+ spec: VisualSpec;
57
+ /** Hints that changed at least one view, e.g. `fields.x` */
58
+ applied: string[];
59
+ /** Hints that were ignored, with reasons */
60
+ rejected: HintRejection[];
61
+ /** Caveats about hints that were applied, e.g. a geo coordinate used as a metric */
62
+ notes: string[];
63
+ }
64
+ /**
65
+ * Applies agent hints to a `VisualSpec`: `preferView` reorders qualified views and
66
+ * `fields` override bindings on every view where the role applies. Invalid hints are
67
+ * reported, never thrown. The input spec and its `data` are not mutated.
68
+ *
69
+ * @param spec - Spec returned by `cast()`.
70
+ * @param hints - Caller preferences.
71
+ * @returns The adjusted spec plus applied and rejected hints.
72
+ *
73
+ * @example
74
+ * const result = applyViewHints(cast(rows), { fields: { x: 'name' } });
75
+ */
76
+ export declare function applyViewHints(spec: VisualSpec, hints: ViewHints): AppliedViewHints;
77
+ /** Suffix appended to the reason of a view the caller asked for. */
78
+ export declare const PREFERRED_BY_CALLER_NOTE = "preferred by caller";
79
+ //# sourceMappingURL=apply-view-hints.d.ts.map