@redocly/config-rules-builder 0.0.1 → 0.1.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/dist/components/AssertionsEditor.d.ts +12 -0
- package/dist/components/ConfigPreview.d.ts +7 -0
- package/dist/components/ImportPanel.d.ts +5 -0
- package/dist/components/Modal.d.ts +10 -0
- package/dist/components/OverviewRuler.d.ts +13 -0
- package/dist/components/ProblemsPanel.d.ts +9 -0
- package/dist/components/RuleCard.d.ts +17 -0
- package/dist/components/RuleList.d.ts +16 -0
- package/dist/components/RulesBuilder.d.ts +11 -0
- package/dist/components/SpecPanel.d.ts +48 -0
- package/dist/components/SubjectEditor.d.ts +11 -0
- package/dist/components/controls/ChipListInput.d.ts +7 -0
- package/dist/components/controls/Combobox.d.ts +9 -0
- package/dist/components/controls/Segmented.d.ts +12 -0
- package/dist/components/controls/SeverityPill.d.ts +5 -0
- package/dist/components/controls/primitives.d.ts +31 -0
- package/dist/config-rules-builder.js +4091 -0
- package/dist/config-rules-builder.js.map +1 -0
- package/dist/constants.d.ts +13 -0
- package/dist/default-spec.d.ts +1 -0
- package/dist/engine/evaluate.d.ts +2 -0
- package/dist/engine/offsets.d.ts +11 -0
- package/dist/index.d.ts +6 -0
- package/dist/normalize.d.ts +43 -0
- package/dist/state.d.ts +10 -0
- package/dist/styles.d.ts +17 -0
- package/dist/types.d.ts +82 -0
- package/dist/validation.d.ts +4 -0
- package/dist/yaml/parse.d.ts +7 -0
- package/dist/yaml/serialize.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AssertionKey, CasingStyle } from './types';
|
|
2
|
+
export declare const CASING_STYLES: CasingStyle[];
|
|
3
|
+
export declare const NODE_TYPES: string[];
|
|
4
|
+
export type AssertionValueKind = 'casing' | 'text' | 'regex' | 'stringList' | 'number' | 'boolean' | 'refValue';
|
|
5
|
+
export interface AssertionMeta {
|
|
6
|
+
key: AssertionKey;
|
|
7
|
+
kind: AssertionValueKind;
|
|
8
|
+
propertyMode: 'forbidden' | 'required' | 'either';
|
|
9
|
+
hint: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const ASSERTION_META: AssertionMeta[];
|
|
12
|
+
export declare const ASSERTION_META_BY_KEY: Record<string, AssertionMeta>;
|
|
13
|
+
export declare const MESSAGE_PLACEHOLDERS: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_SPEC: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CharRange {
|
|
2
|
+
from: number;
|
|
3
|
+
to: number;
|
|
4
|
+
}
|
|
5
|
+
export interface PointerRangeResolver {
|
|
6
|
+
resolve(pointer: string, reportOnKey: boolean): CharRange | undefined;
|
|
7
|
+
lineAt(offset: number): number;
|
|
8
|
+
lineCount: number;
|
|
9
|
+
lineRange(line: number): CharRange;
|
|
10
|
+
}
|
|
11
|
+
export declare function createPointerRangeResolver(specText: string): PointerRangeResolver;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { RulesBuilder, type RulesBuilderProps } from './components/RulesBuilder';
|
|
2
|
+
export { evaluateRules } from './engine/evaluate';
|
|
3
|
+
export { serializeRules } from './yaml/serialize';
|
|
4
|
+
export { parseImportedRules, type ImportResult } from './yaml/parse';
|
|
5
|
+
export { DEFAULT_SPEC } from './default-spec';
|
|
6
|
+
export type { AssertionKey, AssertionObject, CasingStyle, ConfigurableRule, EvaluationResult, HostAdapters, MatchedNode, NamedRule, ProblemInfo, Severity, SubjectObject, WhereObject, } from './types';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ConfigurableRule, SubjectObject } from './types';
|
|
2
|
+
export declare function pruneRule(rule: ConfigurableRule): {
|
|
3
|
+
severity?: "warn" | "off" | undefined;
|
|
4
|
+
reference?: string | undefined;
|
|
5
|
+
suggest?: string[] | undefined;
|
|
6
|
+
message?: string | undefined;
|
|
7
|
+
where?: {
|
|
8
|
+
subject: {
|
|
9
|
+
matchParentKeys?: string | undefined;
|
|
10
|
+
filterOutParentKeys?: string[] | undefined;
|
|
11
|
+
filterInParentKeys?: string[] | undefined;
|
|
12
|
+
property?: string | string[] | undefined;
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
assertions: import('./types').AssertionObject;
|
|
16
|
+
}[] | undefined;
|
|
17
|
+
subject: {
|
|
18
|
+
matchParentKeys?: string | undefined;
|
|
19
|
+
filterOutParentKeys?: string[] | undefined;
|
|
20
|
+
filterInParentKeys?: string[] | undefined;
|
|
21
|
+
property?: string | string[] | undefined;
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
assertions: import('./types').AssertionObject;
|
|
25
|
+
};
|
|
26
|
+
export declare function pruneWhere(where: ConfigurableRule['where']): {
|
|
27
|
+
subject: {
|
|
28
|
+
matchParentKeys?: string | undefined;
|
|
29
|
+
filterOutParentKeys?: string[] | undefined;
|
|
30
|
+
filterInParentKeys?: string[] | undefined;
|
|
31
|
+
property?: string | string[] | undefined;
|
|
32
|
+
type: string;
|
|
33
|
+
};
|
|
34
|
+
assertions: import('./types').AssertionObject;
|
|
35
|
+
}[] | undefined;
|
|
36
|
+
export declare function cleanSubject(subject: SubjectObject): {
|
|
37
|
+
matchParentKeys?: string | undefined;
|
|
38
|
+
filterOutParentKeys?: string[] | undefined;
|
|
39
|
+
filterInParentKeys?: string[] | undefined;
|
|
40
|
+
property?: string | string[] | undefined;
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function ruleId(name: string, index: number): string;
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConfigurableRule, NamedRule } from './types';
|
|
2
|
+
export interface RuleEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
rule: ConfigurableRule;
|
|
6
|
+
}
|
|
7
|
+
export declare function makeId(): string;
|
|
8
|
+
export declare function toNamedRules(entries: RuleEntry[]): NamedRule[];
|
|
9
|
+
export declare function createRuleEntry(named: NamedRule): RuleEntry;
|
|
10
|
+
export declare function createDefaultRule(existingNames: string[]): RuleEntry;
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Severity } from './types';
|
|
2
|
+
export declare const FONT_FAMILY = "var(--font-family-base, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif)";
|
|
3
|
+
export declare const MONO_FONT_FAMILY = "var(--font-family-monospaced, 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Monaco, 'Courier New', monospace)";
|
|
4
|
+
export type SectionTone = 'subject' | 'where' | 'assert' | 'message' | 'suggest';
|
|
5
|
+
export declare const SECTION_TONES: Record<SectionTone, {
|
|
6
|
+
fg: string;
|
|
7
|
+
line: string;
|
|
8
|
+
soft: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const SUCCESS_COLORS: {
|
|
11
|
+
bg: string;
|
|
12
|
+
fg: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const SEVERITY_COLORS: Record<Severity, {
|
|
15
|
+
bg: string;
|
|
16
|
+
fg: string;
|
|
17
|
+
}>;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export type Severity = 'error' | 'warn' | 'off';
|
|
2
|
+
export type CasingStyle = 'camelCase' | 'kebab-case' | 'snake_case' | 'PascalCase' | 'MACRO_CASE' | 'COBOL-CASE' | 'flatcase';
|
|
3
|
+
export interface SubjectObject {
|
|
4
|
+
type: string;
|
|
5
|
+
property?: string | string[] | null;
|
|
6
|
+
filterInParentKeys?: string[];
|
|
7
|
+
filterOutParentKeys?: string[];
|
|
8
|
+
matchParentKeys?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AssertionObject {
|
|
11
|
+
casing?: CasingStyle;
|
|
12
|
+
const?: string;
|
|
13
|
+
contains?: string[];
|
|
14
|
+
defined?: boolean;
|
|
15
|
+
disallowed?: string[];
|
|
16
|
+
enum?: string[];
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
minLength?: number;
|
|
19
|
+
mutuallyExclusive?: string[];
|
|
20
|
+
mutuallyRequired?: string[];
|
|
21
|
+
nonEmpty?: boolean;
|
|
22
|
+
notPattern?: string;
|
|
23
|
+
pattern?: string;
|
|
24
|
+
ref?: boolean | string;
|
|
25
|
+
required?: string[];
|
|
26
|
+
requireAny?: string[];
|
|
27
|
+
schema?: Record<string, unknown> | boolean;
|
|
28
|
+
sortOrder?: 'asc' | 'desc' | {
|
|
29
|
+
direction: 'asc' | 'desc';
|
|
30
|
+
property?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export type AssertionKey = keyof AssertionObject;
|
|
34
|
+
export interface WhereObject {
|
|
35
|
+
subject: SubjectObject;
|
|
36
|
+
assertions: AssertionObject;
|
|
37
|
+
}
|
|
38
|
+
export interface ConfigurableRule {
|
|
39
|
+
subject: SubjectObject;
|
|
40
|
+
assertions: AssertionObject;
|
|
41
|
+
where?: WhereObject[];
|
|
42
|
+
message?: string;
|
|
43
|
+
suggest?: string[];
|
|
44
|
+
reference?: string;
|
|
45
|
+
severity?: Severity;
|
|
46
|
+
}
|
|
47
|
+
export interface NamedRule {
|
|
48
|
+
name: string;
|
|
49
|
+
rule: ConfigurableRule;
|
|
50
|
+
}
|
|
51
|
+
export interface MatchedNode {
|
|
52
|
+
ruleIndex: number;
|
|
53
|
+
pointer: string;
|
|
54
|
+
nodeType: string;
|
|
55
|
+
key: string;
|
|
56
|
+
propertyPointers: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface ProblemInfo {
|
|
59
|
+
ruleIndex: number;
|
|
60
|
+
ruleId: string;
|
|
61
|
+
severity: 'error' | 'warn';
|
|
62
|
+
message: string;
|
|
63
|
+
suggest: string[];
|
|
64
|
+
pointer: string;
|
|
65
|
+
reportOnKey: boolean;
|
|
66
|
+
line?: number;
|
|
67
|
+
col?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface EvaluationResult {
|
|
70
|
+
matches: MatchedNode[];
|
|
71
|
+
problems: ProblemInfo[];
|
|
72
|
+
ruleErrors: string[];
|
|
73
|
+
specError?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface HostAdapters {
|
|
76
|
+
copyToClipboard?: (text: string) => Promise<void>;
|
|
77
|
+
pickSpecFile?: () => Promise<{
|
|
78
|
+
name: string;
|
|
79
|
+
content: string;
|
|
80
|
+
} | undefined>;
|
|
81
|
+
downloadFile?: (fileName: string, content: string) => Promise<void> | void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ConfigurableRule, SubjectObject } from './types';
|
|
2
|
+
export type RuleErrors = Record<string, string>;
|
|
3
|
+
export declare function hasSubjectProperty(subject: SubjectObject): boolean;
|
|
4
|
+
export declare function validateRule(name: string, rule: ConfigurableRule): RuleErrors;
|
package/package.json
CHANGED