@hestia-earth/data-validation 0.41.1 → 0.41.3
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/file-errors/public-api.d.mts +237 -0
- package/file-errors/public-api.d.ts +237 -0
- package/file-errors/public-api.js +2281 -0
- package/file-errors/public-api.mjs +2260 -0
- package/index.js +12 -2
- package/index.mjs +12 -2
- package/package.json +26 -8
- package/validation.json +12 -2
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { NodeType, SchemaType } from '@hestia-earth/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A renderer abstracts every presentation primitive used to build an error message.
|
|
5
|
+
*
|
|
6
|
+
* The error catalog is a single source of truth; swapping the renderer changes only how
|
|
7
|
+
* the messages are presented:
|
|
8
|
+
* - `htmlRenderer` reproduces the exact Bulma-classed HTML consumed by the Angular app.
|
|
9
|
+
* - `textRenderer` produces framework-agnostic plain text (with lightweight markdown for
|
|
10
|
+
* code spans, links and lists) suitable for any non-Angular consumer.
|
|
11
|
+
*/
|
|
12
|
+
interface IErrorRenderer {
|
|
13
|
+
code: (text: string | number | boolean) => string;
|
|
14
|
+
link: (href: string, text: string, newTab?: boolean) => string;
|
|
15
|
+
list: (values: (string | string[])[], style?: 'disc' | 'decimal') => string;
|
|
16
|
+
paragraph: (text: string) => string;
|
|
17
|
+
bold: (text: string) => string;
|
|
18
|
+
subscript: (text: string) => string;
|
|
19
|
+
underline: (text: string) => string;
|
|
20
|
+
/** Inline line break, e.g. `<br/>` or `\n`. */
|
|
21
|
+
lineBreak: string;
|
|
22
|
+
/** Separator used when joining inline code spans (`joinValues`). */
|
|
23
|
+
inlineSeparator: string;
|
|
24
|
+
/** Wraps the leading sentence of a default (non-catalog) message. */
|
|
25
|
+
capitalizeFirst: (text: string) => string;
|
|
26
|
+
/** Wraps the whole formatted message; receives a non-empty string. */
|
|
27
|
+
wrapMessage: (text: string) => string;
|
|
28
|
+
}
|
|
29
|
+
declare const htmlRenderer: IErrorRenderer;
|
|
30
|
+
declare const textRenderer: IErrorRenderer;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Provides the base URLs used to build links inside error messages.
|
|
34
|
+
*
|
|
35
|
+
* Functions (rather than plain strings) keep the lookups lazy: the Angular app reads them
|
|
36
|
+
* from `window.location` at call time, while a non-Angular consumer can pass static values.
|
|
37
|
+
*/
|
|
38
|
+
interface IUrlConfig {
|
|
39
|
+
baseUrl: () => string;
|
|
40
|
+
glossaryBaseUrl: () => string;
|
|
41
|
+
schemaBaseUrl: () => string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Static, browser-free default configuration pointing at the public HESTIA platform.
|
|
45
|
+
*/
|
|
46
|
+
declare const defaultUrlConfig: IUrlConfig;
|
|
47
|
+
/**
|
|
48
|
+
* Builds a configuration from a single base URL.
|
|
49
|
+
*/
|
|
50
|
+
declare const urlConfig: (baseUrl?: string) => IUrlConfig;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Framework-agnostic validation types.
|
|
54
|
+
*
|
|
55
|
+
* These mirror the canonical definitions in `../schema/schema-validation.model` but are
|
|
56
|
+
* duplicated here so this entry point stays self-contained (no import from the Angular
|
|
57
|
+
* primary entry point). They are kept structurally compatible on purpose.
|
|
58
|
+
*/
|
|
59
|
+
type validationErrorLevel = 'error' | 'warning';
|
|
60
|
+
type validationErrorParam = 'missingProperty' | 'type' | 'term' | 'termType' | 'termIds' | 'model' | 'product' | 'range' | 'node' | 'allowedValues' | 'allowedValue' | 'additionalProperty' | 'expected' | 'default' | 'current' | 'percentage' | 'keys' | 'threshold' | 'outliers' | 'country' | 'min' | 'max' | 'mu' | 'sd' | 'defaultSource' | 'source' | 'group' | 'message' | 'distance' | 'siteType' | 'products' | 'units' | 'duplicatedIndexes' | 'invalidCoordinates' | 'ids' | 'limit' | 'delta';
|
|
61
|
+
type validationErrorKeyword = 'required' | 'type' | 'if' | 'then' | 'not';
|
|
62
|
+
interface ICustomValidationRules {
|
|
63
|
+
const?: any;
|
|
64
|
+
required?: string[];
|
|
65
|
+
enum?: string[];
|
|
66
|
+
contains?: ICustomValidationRules;
|
|
67
|
+
properties?: {
|
|
68
|
+
[property: string]: ICustomValidationRules;
|
|
69
|
+
};
|
|
70
|
+
not?: ICustomValidationRules;
|
|
71
|
+
items?: ICustomValidationRules;
|
|
72
|
+
allOf?: ICustomValidationRules[];
|
|
73
|
+
anyOf?: ICustomValidationRules[];
|
|
74
|
+
oneOf?: ICustomValidationRules[];
|
|
75
|
+
}
|
|
76
|
+
interface IValidationError {
|
|
77
|
+
index?: number;
|
|
78
|
+
nodeIndex?: number;
|
|
79
|
+
level?: validationErrorLevel;
|
|
80
|
+
dataPath?: string;
|
|
81
|
+
schemaPath?: string;
|
|
82
|
+
keyword?: validationErrorKeyword;
|
|
83
|
+
message: string;
|
|
84
|
+
params?: {
|
|
85
|
+
[key in validationErrorParam]?: any;
|
|
86
|
+
};
|
|
87
|
+
schema?: ICustomValidationRules;
|
|
88
|
+
}
|
|
89
|
+
interface IValidationErrorWithIndex {
|
|
90
|
+
error: IValidationError[];
|
|
91
|
+
index: number;
|
|
92
|
+
changed?: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface IDataPath {
|
|
95
|
+
path: string;
|
|
96
|
+
/**
|
|
97
|
+
* Human readable version of the path.
|
|
98
|
+
*/
|
|
99
|
+
label: string;
|
|
100
|
+
nodeType?: NodeType;
|
|
101
|
+
schemaType?: SchemaType;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Structured, framework-agnostic representation of a formatted validation error.
|
|
105
|
+
*/
|
|
106
|
+
interface IFormattedError {
|
|
107
|
+
level: validationErrorLevel;
|
|
108
|
+
/**
|
|
109
|
+
* The rendered message. Plain text (or lightweight markdown) by default, HTML when
|
|
110
|
+
* formatted with the html renderer.
|
|
111
|
+
*/
|
|
112
|
+
message: string;
|
|
113
|
+
/**
|
|
114
|
+
* Human readable location of the error within the document (derived from the dataPath).
|
|
115
|
+
*/
|
|
116
|
+
location?: string;
|
|
117
|
+
dataPath?: string;
|
|
118
|
+
keyword?: validationErrorKeyword;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* One failure inside a group, kept with the node it was raised on so a caller can show the offending
|
|
123
|
+
* entry rather than only the count.
|
|
124
|
+
*/
|
|
125
|
+
interface IErrorGroupEntry {
|
|
126
|
+
nodeIndex: number;
|
|
127
|
+
error: IValidationError;
|
|
128
|
+
node?: any;
|
|
129
|
+
/** The Term the failure is about, when the validator named one or the node carries one at that path. */
|
|
130
|
+
term?: any;
|
|
131
|
+
}
|
|
132
|
+
interface IErrorGroup {
|
|
133
|
+
level: validationErrorLevel;
|
|
134
|
+
/**
|
|
135
|
+
* The validator's own message, unformatted. It is the grouping key because it is also the key the error
|
|
136
|
+
* catalog and the validation list are addressed by — formatting first would group on presentation.
|
|
137
|
+
*/
|
|
138
|
+
message: string;
|
|
139
|
+
/** Human-readable location, e.g. `Cycle › Practice`. */
|
|
140
|
+
path: string;
|
|
141
|
+
/** `@type` of the nodes in the group, when they are known. */
|
|
142
|
+
nodeType?: string;
|
|
143
|
+
count: number;
|
|
144
|
+
nodeIndexes: number[];
|
|
145
|
+
entries: IErrorGroupEntry[];
|
|
146
|
+
terms: any[];
|
|
147
|
+
/** Present only when a formatter was given. */
|
|
148
|
+
formattedMessage?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The subset of `createErrorFormatter`'s result this module needs. Taking the functions rather than a
|
|
152
|
+
* renderer keeps the grouping independent of presentation: the same groups render as HTML in the platform
|
|
153
|
+
* UI and as plain text everywhere else.
|
|
154
|
+
*/
|
|
155
|
+
interface IErrorGroupFormatter {
|
|
156
|
+
dataPathLabel: (dataPath?: string) => string | undefined;
|
|
157
|
+
formatError: (error?: IValidationError, allErrors?: IValidationError[]) => IValidationError | undefined;
|
|
158
|
+
}
|
|
159
|
+
interface IGroupErrorsOptions {
|
|
160
|
+
/** The uploaded nodes, indexed as the errors are. Without them a group has no term and no node type. */
|
|
161
|
+
nodes?: any[];
|
|
162
|
+
formatter?: IErrorGroupFormatter;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Collapses a file's validation failures into one entry per distinct problem.
|
|
166
|
+
*
|
|
167
|
+
* An upload that fails one rule fails it on every row it applies to, so the raw list is mostly repetition:
|
|
168
|
+
* grouping on the message, the level and the location is what turns "247 failures" into the handful of
|
|
169
|
+
* things the uploader actually has to fix. Groups keep first-seen order — the order the file itself puts
|
|
170
|
+
* them in — and callers that want another order sort the result.
|
|
171
|
+
*/
|
|
172
|
+
declare const groupErrors: (errors?: IValidationErrorWithIndex[], { nodes, formatter }?: IGroupErrorsOptions) => IErrorGroup[];
|
|
173
|
+
|
|
174
|
+
declare const validationGuidePrefix = "guide-data-validation";
|
|
175
|
+
/**
|
|
176
|
+
* `guide-data-validation-cycle#validate_functionalUnit_not_1_ha`, and `undefined` for a message the
|
|
177
|
+
* validation list does not carry — a schema-level failure raises those too.
|
|
178
|
+
*/
|
|
179
|
+
declare const validationGuidePage: (nodeType: SchemaType | string, message: string) => string;
|
|
180
|
+
|
|
181
|
+
declare enum Repository {
|
|
182
|
+
glossary = "hestia-glossary",
|
|
183
|
+
models = "hestia-engine-models",
|
|
184
|
+
aggregation = "hestia-aggregation-engine",
|
|
185
|
+
community = "hestia-community-edition",
|
|
186
|
+
schema = "hestia-schema",
|
|
187
|
+
frontend = "hestia-front-end"
|
|
188
|
+
}
|
|
189
|
+
declare enum Template {
|
|
190
|
+
bug = "bug",
|
|
191
|
+
feature = "feature"
|
|
192
|
+
}
|
|
193
|
+
interface IIssueParams {
|
|
194
|
+
title?: string;
|
|
195
|
+
description?: string;
|
|
196
|
+
}
|
|
197
|
+
declare const reportIssueUrl: (repository: Repository, template?: Template, issueParams?: IIssueParams) => string;
|
|
198
|
+
|
|
199
|
+
declare const guidePageId: (nodeType: SchemaType, errorMessage: string) => string;
|
|
200
|
+
declare const isMigrationError: ({ params }: IValidationError) => boolean;
|
|
201
|
+
interface ICreateErrorFormatterOptions {
|
|
202
|
+
renderer: IErrorRenderer;
|
|
203
|
+
urls: IUrlConfig;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Builds the error formatting functions for a given presentation (`renderer`) and link
|
|
207
|
+
* configuration (`urls`). The error catalog below is the single source of truth; the
|
|
208
|
+
* renderer alone decides whether the output is HTML, plain text, etc.
|
|
209
|
+
*/
|
|
210
|
+
declare const createErrorFormatter: ({ renderer: r, urls }: ICreateErrorFormatterOptions) => {
|
|
211
|
+
parseDataPath: (dataPath?: string) => IDataPath[];
|
|
212
|
+
dataPathLabel: (dataPath?: string) => string;
|
|
213
|
+
migrationErrorMessage: ({ params }: IValidationError) => string;
|
|
214
|
+
formatCustomErrorMessage: (message?: string, error?: IValidationError, allErrors?: IValidationError[]) => string;
|
|
215
|
+
formatError: (error?: IValidationError, allErrors?: IValidationError[]) => IValidationError;
|
|
216
|
+
formatErrors: (errors?: IValidationError[]) => IFormattedError[];
|
|
217
|
+
locationLabel: (dataPath?: string) => string;
|
|
218
|
+
};
|
|
219
|
+
declare const errorHasError: (error?: IValidationError) => boolean;
|
|
220
|
+
declare const errorHasWarning: (error?: IValidationError) => boolean;
|
|
221
|
+
declare const isMissingPropertyError: ({ params }: IValidationError) => boolean;
|
|
222
|
+
declare const isMissingOneOfError: ({ keyword, schemaPath }: IValidationError) => boolean;
|
|
223
|
+
declare const filterError: (error: IValidationError) => boolean;
|
|
224
|
+
declare const missingNodeErrors: (errors: IValidationError[]) => IValidationError[];
|
|
225
|
+
|
|
226
|
+
interface IFormatErrorsOptions {
|
|
227
|
+
/** Presentation renderer. Defaults to `textRenderer` (plain text / lightweight markdown). */
|
|
228
|
+
renderer?: IErrorRenderer;
|
|
229
|
+
/** Base URLs used to build links. Defaults to the public HESTIA platform. */
|
|
230
|
+
urls?: IUrlConfig;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Formats a list of validation errors into structured, framework-agnostic objects.
|
|
234
|
+
*/
|
|
235
|
+
declare const formatErrors: (errors?: IValidationError[], options?: IFormatErrorsOptions) => IFormattedError[];
|
|
236
|
+
|
|
237
|
+
export { type ICreateErrorFormatterOptions, type ICustomValidationRules, type IDataPath, type IErrorGroup, type IErrorGroupEntry, type IErrorGroupFormatter, type IErrorRenderer, type IFormatErrorsOptions, type IFormattedError, type IGroupErrorsOptions, type IUrlConfig, type IValidationError, type IValidationErrorWithIndex, Repository, Template, createErrorFormatter, defaultUrlConfig, errorHasError, errorHasWarning, filterError, formatErrors, groupErrors, guidePageId, htmlRenderer, isMigrationError, isMissingOneOfError, isMissingPropertyError, missingNodeErrors, reportIssueUrl, textRenderer, urlConfig, type validationErrorKeyword, type validationErrorLevel, type validationErrorParam, validationGuidePage, validationGuidePrefix };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { NodeType, SchemaType } from '@hestia-earth/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A renderer abstracts every presentation primitive used to build an error message.
|
|
5
|
+
*
|
|
6
|
+
* The error catalog is a single source of truth; swapping the renderer changes only how
|
|
7
|
+
* the messages are presented:
|
|
8
|
+
* - `htmlRenderer` reproduces the exact Bulma-classed HTML consumed by the Angular app.
|
|
9
|
+
* - `textRenderer` produces framework-agnostic plain text (with lightweight markdown for
|
|
10
|
+
* code spans, links and lists) suitable for any non-Angular consumer.
|
|
11
|
+
*/
|
|
12
|
+
interface IErrorRenderer {
|
|
13
|
+
code: (text: string | number | boolean) => string;
|
|
14
|
+
link: (href: string, text: string, newTab?: boolean) => string;
|
|
15
|
+
list: (values: (string | string[])[], style?: 'disc' | 'decimal') => string;
|
|
16
|
+
paragraph: (text: string) => string;
|
|
17
|
+
bold: (text: string) => string;
|
|
18
|
+
subscript: (text: string) => string;
|
|
19
|
+
underline: (text: string) => string;
|
|
20
|
+
/** Inline line break, e.g. `<br/>` or `\n`. */
|
|
21
|
+
lineBreak: string;
|
|
22
|
+
/** Separator used when joining inline code spans (`joinValues`). */
|
|
23
|
+
inlineSeparator: string;
|
|
24
|
+
/** Wraps the leading sentence of a default (non-catalog) message. */
|
|
25
|
+
capitalizeFirst: (text: string) => string;
|
|
26
|
+
/** Wraps the whole formatted message; receives a non-empty string. */
|
|
27
|
+
wrapMessage: (text: string) => string;
|
|
28
|
+
}
|
|
29
|
+
declare const htmlRenderer: IErrorRenderer;
|
|
30
|
+
declare const textRenderer: IErrorRenderer;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Provides the base URLs used to build links inside error messages.
|
|
34
|
+
*
|
|
35
|
+
* Functions (rather than plain strings) keep the lookups lazy: the Angular app reads them
|
|
36
|
+
* from `window.location` at call time, while a non-Angular consumer can pass static values.
|
|
37
|
+
*/
|
|
38
|
+
interface IUrlConfig {
|
|
39
|
+
baseUrl: () => string;
|
|
40
|
+
glossaryBaseUrl: () => string;
|
|
41
|
+
schemaBaseUrl: () => string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Static, browser-free default configuration pointing at the public HESTIA platform.
|
|
45
|
+
*/
|
|
46
|
+
declare const defaultUrlConfig: IUrlConfig;
|
|
47
|
+
/**
|
|
48
|
+
* Builds a configuration from a single base URL.
|
|
49
|
+
*/
|
|
50
|
+
declare const urlConfig: (baseUrl?: string) => IUrlConfig;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Framework-agnostic validation types.
|
|
54
|
+
*
|
|
55
|
+
* These mirror the canonical definitions in `../schema/schema-validation.model` but are
|
|
56
|
+
* duplicated here so this entry point stays self-contained (no import from the Angular
|
|
57
|
+
* primary entry point). They are kept structurally compatible on purpose.
|
|
58
|
+
*/
|
|
59
|
+
type validationErrorLevel = 'error' | 'warning';
|
|
60
|
+
type validationErrorParam = 'missingProperty' | 'type' | 'term' | 'termType' | 'termIds' | 'model' | 'product' | 'range' | 'node' | 'allowedValues' | 'allowedValue' | 'additionalProperty' | 'expected' | 'default' | 'current' | 'percentage' | 'keys' | 'threshold' | 'outliers' | 'country' | 'min' | 'max' | 'mu' | 'sd' | 'defaultSource' | 'source' | 'group' | 'message' | 'distance' | 'siteType' | 'products' | 'units' | 'duplicatedIndexes' | 'invalidCoordinates' | 'ids' | 'limit' | 'delta';
|
|
61
|
+
type validationErrorKeyword = 'required' | 'type' | 'if' | 'then' | 'not';
|
|
62
|
+
interface ICustomValidationRules {
|
|
63
|
+
const?: any;
|
|
64
|
+
required?: string[];
|
|
65
|
+
enum?: string[];
|
|
66
|
+
contains?: ICustomValidationRules;
|
|
67
|
+
properties?: {
|
|
68
|
+
[property: string]: ICustomValidationRules;
|
|
69
|
+
};
|
|
70
|
+
not?: ICustomValidationRules;
|
|
71
|
+
items?: ICustomValidationRules;
|
|
72
|
+
allOf?: ICustomValidationRules[];
|
|
73
|
+
anyOf?: ICustomValidationRules[];
|
|
74
|
+
oneOf?: ICustomValidationRules[];
|
|
75
|
+
}
|
|
76
|
+
interface IValidationError {
|
|
77
|
+
index?: number;
|
|
78
|
+
nodeIndex?: number;
|
|
79
|
+
level?: validationErrorLevel;
|
|
80
|
+
dataPath?: string;
|
|
81
|
+
schemaPath?: string;
|
|
82
|
+
keyword?: validationErrorKeyword;
|
|
83
|
+
message: string;
|
|
84
|
+
params?: {
|
|
85
|
+
[key in validationErrorParam]?: any;
|
|
86
|
+
};
|
|
87
|
+
schema?: ICustomValidationRules;
|
|
88
|
+
}
|
|
89
|
+
interface IValidationErrorWithIndex {
|
|
90
|
+
error: IValidationError[];
|
|
91
|
+
index: number;
|
|
92
|
+
changed?: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface IDataPath {
|
|
95
|
+
path: string;
|
|
96
|
+
/**
|
|
97
|
+
* Human readable version of the path.
|
|
98
|
+
*/
|
|
99
|
+
label: string;
|
|
100
|
+
nodeType?: NodeType;
|
|
101
|
+
schemaType?: SchemaType;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Structured, framework-agnostic representation of a formatted validation error.
|
|
105
|
+
*/
|
|
106
|
+
interface IFormattedError {
|
|
107
|
+
level: validationErrorLevel;
|
|
108
|
+
/**
|
|
109
|
+
* The rendered message. Plain text (or lightweight markdown) by default, HTML when
|
|
110
|
+
* formatted with the html renderer.
|
|
111
|
+
*/
|
|
112
|
+
message: string;
|
|
113
|
+
/**
|
|
114
|
+
* Human readable location of the error within the document (derived from the dataPath).
|
|
115
|
+
*/
|
|
116
|
+
location?: string;
|
|
117
|
+
dataPath?: string;
|
|
118
|
+
keyword?: validationErrorKeyword;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* One failure inside a group, kept with the node it was raised on so a caller can show the offending
|
|
123
|
+
* entry rather than only the count.
|
|
124
|
+
*/
|
|
125
|
+
interface IErrorGroupEntry {
|
|
126
|
+
nodeIndex: number;
|
|
127
|
+
error: IValidationError;
|
|
128
|
+
node?: any;
|
|
129
|
+
/** The Term the failure is about, when the validator named one or the node carries one at that path. */
|
|
130
|
+
term?: any;
|
|
131
|
+
}
|
|
132
|
+
interface IErrorGroup {
|
|
133
|
+
level: validationErrorLevel;
|
|
134
|
+
/**
|
|
135
|
+
* The validator's own message, unformatted. It is the grouping key because it is also the key the error
|
|
136
|
+
* catalog and the validation list are addressed by — formatting first would group on presentation.
|
|
137
|
+
*/
|
|
138
|
+
message: string;
|
|
139
|
+
/** Human-readable location, e.g. `Cycle › Practice`. */
|
|
140
|
+
path: string;
|
|
141
|
+
/** `@type` of the nodes in the group, when they are known. */
|
|
142
|
+
nodeType?: string;
|
|
143
|
+
count: number;
|
|
144
|
+
nodeIndexes: number[];
|
|
145
|
+
entries: IErrorGroupEntry[];
|
|
146
|
+
terms: any[];
|
|
147
|
+
/** Present only when a formatter was given. */
|
|
148
|
+
formattedMessage?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The subset of `createErrorFormatter`'s result this module needs. Taking the functions rather than a
|
|
152
|
+
* renderer keeps the grouping independent of presentation: the same groups render as HTML in the platform
|
|
153
|
+
* UI and as plain text everywhere else.
|
|
154
|
+
*/
|
|
155
|
+
interface IErrorGroupFormatter {
|
|
156
|
+
dataPathLabel: (dataPath?: string) => string | undefined;
|
|
157
|
+
formatError: (error?: IValidationError, allErrors?: IValidationError[]) => IValidationError | undefined;
|
|
158
|
+
}
|
|
159
|
+
interface IGroupErrorsOptions {
|
|
160
|
+
/** The uploaded nodes, indexed as the errors are. Without them a group has no term and no node type. */
|
|
161
|
+
nodes?: any[];
|
|
162
|
+
formatter?: IErrorGroupFormatter;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Collapses a file's validation failures into one entry per distinct problem.
|
|
166
|
+
*
|
|
167
|
+
* An upload that fails one rule fails it on every row it applies to, so the raw list is mostly repetition:
|
|
168
|
+
* grouping on the message, the level and the location is what turns "247 failures" into the handful of
|
|
169
|
+
* things the uploader actually has to fix. Groups keep first-seen order — the order the file itself puts
|
|
170
|
+
* them in — and callers that want another order sort the result.
|
|
171
|
+
*/
|
|
172
|
+
declare const groupErrors: (errors?: IValidationErrorWithIndex[], { nodes, formatter }?: IGroupErrorsOptions) => IErrorGroup[];
|
|
173
|
+
|
|
174
|
+
declare const validationGuidePrefix = "guide-data-validation";
|
|
175
|
+
/**
|
|
176
|
+
* `guide-data-validation-cycle#validate_functionalUnit_not_1_ha`, and `undefined` for a message the
|
|
177
|
+
* validation list does not carry — a schema-level failure raises those too.
|
|
178
|
+
*/
|
|
179
|
+
declare const validationGuidePage: (nodeType: SchemaType | string, message: string) => string;
|
|
180
|
+
|
|
181
|
+
declare enum Repository {
|
|
182
|
+
glossary = "hestia-glossary",
|
|
183
|
+
models = "hestia-engine-models",
|
|
184
|
+
aggregation = "hestia-aggregation-engine",
|
|
185
|
+
community = "hestia-community-edition",
|
|
186
|
+
schema = "hestia-schema",
|
|
187
|
+
frontend = "hestia-front-end"
|
|
188
|
+
}
|
|
189
|
+
declare enum Template {
|
|
190
|
+
bug = "bug",
|
|
191
|
+
feature = "feature"
|
|
192
|
+
}
|
|
193
|
+
interface IIssueParams {
|
|
194
|
+
title?: string;
|
|
195
|
+
description?: string;
|
|
196
|
+
}
|
|
197
|
+
declare const reportIssueUrl: (repository: Repository, template?: Template, issueParams?: IIssueParams) => string;
|
|
198
|
+
|
|
199
|
+
declare const guidePageId: (nodeType: SchemaType, errorMessage: string) => string;
|
|
200
|
+
declare const isMigrationError: ({ params }: IValidationError) => boolean;
|
|
201
|
+
interface ICreateErrorFormatterOptions {
|
|
202
|
+
renderer: IErrorRenderer;
|
|
203
|
+
urls: IUrlConfig;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Builds the error formatting functions for a given presentation (`renderer`) and link
|
|
207
|
+
* configuration (`urls`). The error catalog below is the single source of truth; the
|
|
208
|
+
* renderer alone decides whether the output is HTML, plain text, etc.
|
|
209
|
+
*/
|
|
210
|
+
declare const createErrorFormatter: ({ renderer: r, urls }: ICreateErrorFormatterOptions) => {
|
|
211
|
+
parseDataPath: (dataPath?: string) => IDataPath[];
|
|
212
|
+
dataPathLabel: (dataPath?: string) => string;
|
|
213
|
+
migrationErrorMessage: ({ params }: IValidationError) => string;
|
|
214
|
+
formatCustomErrorMessage: (message?: string, error?: IValidationError, allErrors?: IValidationError[]) => string;
|
|
215
|
+
formatError: (error?: IValidationError, allErrors?: IValidationError[]) => IValidationError;
|
|
216
|
+
formatErrors: (errors?: IValidationError[]) => IFormattedError[];
|
|
217
|
+
locationLabel: (dataPath?: string) => string;
|
|
218
|
+
};
|
|
219
|
+
declare const errorHasError: (error?: IValidationError) => boolean;
|
|
220
|
+
declare const errorHasWarning: (error?: IValidationError) => boolean;
|
|
221
|
+
declare const isMissingPropertyError: ({ params }: IValidationError) => boolean;
|
|
222
|
+
declare const isMissingOneOfError: ({ keyword, schemaPath }: IValidationError) => boolean;
|
|
223
|
+
declare const filterError: (error: IValidationError) => boolean;
|
|
224
|
+
declare const missingNodeErrors: (errors: IValidationError[]) => IValidationError[];
|
|
225
|
+
|
|
226
|
+
interface IFormatErrorsOptions {
|
|
227
|
+
/** Presentation renderer. Defaults to `textRenderer` (plain text / lightweight markdown). */
|
|
228
|
+
renderer?: IErrorRenderer;
|
|
229
|
+
/** Base URLs used to build links. Defaults to the public HESTIA platform. */
|
|
230
|
+
urls?: IUrlConfig;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Formats a list of validation errors into structured, framework-agnostic objects.
|
|
234
|
+
*/
|
|
235
|
+
declare const formatErrors: (errors?: IValidationError[], options?: IFormatErrorsOptions) => IFormattedError[];
|
|
236
|
+
|
|
237
|
+
export { type ICreateErrorFormatterOptions, type ICustomValidationRules, type IDataPath, type IErrorGroup, type IErrorGroupEntry, type IErrorGroupFormatter, type IErrorRenderer, type IFormatErrorsOptions, type IFormattedError, type IGroupErrorsOptions, type IUrlConfig, type IValidationError, type IValidationErrorWithIndex, Repository, Template, createErrorFormatter, defaultUrlConfig, errorHasError, errorHasWarning, filterError, formatErrors, groupErrors, guidePageId, htmlRenderer, isMigrationError, isMissingOneOfError, isMissingPropertyError, missingNodeErrors, reportIssueUrl, textRenderer, urlConfig, type validationErrorKeyword, type validationErrorLevel, type validationErrorParam, validationGuidePage, validationGuidePrefix };
|