@wallarm-org/design-system 4.10.0-rc-feat-parser.1 → 4.10.1
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 +1 -1
- package/dist/components/Badge/generateBadgeVariants.js +9 -28
- package/dist/components/Checkbox/CheckboxGroup.d.ts +2 -1
- package/dist/components/Checkbox/CheckboxGroup.js +16 -13
- package/dist/components/CodeSnippet/internal/FoldToggle.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +0 -2
- package/dist/components/DropdownMenu/DropdownMenu.js +71 -84
- package/dist/components/DropdownMenu/DropdownMenuItemDescription.js +1 -1
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useFilterInputAutocomplete.js +1 -1
- package/dist/components/Radio/RadioGroup.d.ts +2 -1
- package/dist/components/Radio/RadioGroup.js +16 -13
- package/dist/components/SimpleCharts/Chart/classes.js +1 -1
- package/dist/components/SimpleCharts/HorizontalBarStack/classes.js +1 -1
- package/dist/components/SimpleCharts/Metric/classes.d.ts +2 -2
- package/dist/components/SimpleCharts/Metric/classes.js +2 -2
- package/dist/components/Table/TableBody/TableBodyCell.js +4 -1
- package/dist/guidelines/patterns/complex-drawer.md +1084 -0
- package/dist/guidelines/patterns/confirmation-dialogs.md +3 -11
- package/dist/guidelines/patterns/detail-drawer.md +31 -13
- package/dist/guidelines/patterns/empty-states.md +6 -5
- package/dist/guidelines/patterns/entity-table.md +25 -29
- package/dist/guidelines/patterns/feedback-toasts.md +3 -11
- package/dist/guidelines/patterns/resource-list-page.md +14 -16
- package/dist/guidelines/rules.md +6 -5
- package/dist/guidelines/templates/ai-assistant.md +1133 -0
- package/dist/guidelines/templates/api-inventory.md +905 -0
- package/dist/guidelines/templates/attack-events.md +2722 -0
- package/dist/guidelines/templates/incident-detail.md +2085 -0
- package/dist/guidelines/templates/integrations-settings.md +836 -0
- package/dist/guidelines/templates/page-states.md +798 -0
- package/dist/guidelines/templates/rule-editor.md +886 -0
- package/dist/guidelines/templates/security-dashboard.md +681 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/metadata/components.json +20 -108
- package/dist/metadata/guidelines.json +1204 -37
- package/dist/theme/tokens.test.ts +52 -0
- package/package.json +1 -4
- package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.d.ts +0 -14
- package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.js +0 -209
- package/dist/components/Rules/PointSelector/MatchStep.d.ts +0 -15
- package/dist/components/Rules/PointSelector/MatchStep.js +0 -186
- package/dist/components/Rules/PointSelector/MenuFooterHints.d.ts +0 -16
- package/dist/components/Rules/PointSelector/MenuFooterHints.js +0 -177
- package/dist/components/Rules/PointSelector/PointPreview.d.ts +0 -10
- package/dist/components/Rules/PointSelector/PointPreview.js +0 -88
- package/dist/components/Rules/PointSelector/PointSelector.d.ts +0 -17
- package/dist/components/Rules/PointSelector/PointSelector.js +0 -937
- package/dist/components/Rules/PointSelector/PointSelectorEmptyState.d.ts +0 -12
- package/dist/components/Rules/PointSelector/PointSelectorEmptyState.js +0 -173
- package/dist/components/Rules/PointSelector/PointSelectorError.d.ts +0 -31
- package/dist/components/Rules/PointSelector/PointSelectorError.js +0 -275
- package/dist/components/Rules/PointSelector/PointSelectorInput.d.ts +0 -20
- package/dist/components/Rules/PointSelector/PointSelectorInput.js +0 -130
- package/dist/components/Rules/PointSelector/PointSelectorMenu.d.ts +0 -31
- package/dist/components/Rules/PointSelector/PointSelectorMenu.js +0 -317
- package/dist/components/Rules/PointSelector/PointSelectorSkeleton.d.ts +0 -8
- package/dist/components/Rules/PointSelector/PointSelectorSkeleton.js +0 -73
- package/dist/components/Rules/PointSelector/SampleRequest.d.ts +0 -14
- package/dist/components/Rules/PointSelector/SampleRequest.js +0 -116
- package/dist/components/Rules/PointSelector/StepMenu.d.ts +0 -40
- package/dist/components/Rules/PointSelector/StepMenu.js +0 -210
- package/dist/components/Rules/PointSelector/VersionWarning.d.ts +0 -26
- package/dist/components/Rules/PointSelector/VersionWarning.js +0 -231
- package/dist/components/Rules/PointSelector/WhereBar.d.ts +0 -48
- package/dist/components/Rules/PointSelector/WhereBar.js +0 -263
- package/dist/components/Rules/PointSelector/classes.d.ts +0 -28
- package/dist/components/Rules/PointSelector/classes.js +0 -22
- package/dist/components/Rules/PointSelector/index.d.ts +0 -20
- package/dist/components/Rules/PointSelector/index.js +0 -18
- package/dist/components/Rules/PointSelector/liftLayer.d.ts +0 -8
- package/dist/components/Rules/PointSelector/liftLayer.js +0 -4
- package/dist/components/Rules/PointSelector/sampleValue.d.ts +0 -6
- package/dist/components/Rules/PointSelector/sampleValue.js +0 -51
- package/dist/components/Rules/PointSelector/sdkBridge.d.ts +0 -508
- package/dist/components/Rules/PointSelector/sdkBridge.js +0 -339
- package/dist/components/Rules/PointSelector/types.d.ts +0 -304
- package/dist/components/Rules/PointSelector/types.js +0 -0
- package/dist/components/Rules/PointSelector/usePointSelector.d.ts +0 -161
- package/dist/components/Rules/PointSelector/usePointSelector.js +0 -1088
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.d.ts +0 -28
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.js +0 -208
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.d.ts +0 -23
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.js +0 -950
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.d.ts +0 -21
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.js +0 -110
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.d.ts +0 -20
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.js +0 -31
- package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.d.ts +0 -23
- package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.js +0 -131
- package/dist/components/Rules/RuleBuilder/ActionEditor/classes.d.ts +0 -17
- package/dist/components/Rules/RuleBuilder/ActionEditor/classes.js +0 -14
- package/dist/components/Rules/RuleBuilder/ActionEditor/index.d.ts +0 -6
- package/dist/components/Rules/RuleBuilder/ActionEditor/index.js +0 -6
- package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.d.ts +0 -24
- package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.js +0 -245
- package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.d.ts +0 -15
- package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.js +0 -691
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.d.ts +0 -19
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.js +0 -72
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.d.ts +0 -27
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.js +0 -407
- package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.d.ts +0 -14
- package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.js +0 -269
- package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.d.ts +0 -25
- package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.js +0 -99
- package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.d.ts +0 -14
- package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.js +0 -118
- package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.d.ts +0 -14
- package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.js +0 -446
- package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.d.ts +0 -14
- package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.js +0 -266
- package/dist/components/Rules/RuleBuilder/ConditionTree/classes.d.ts +0 -35
- package/dist/components/Rules/RuleBuilder/ConditionTree/classes.js +0 -57
- package/dist/components/Rules/RuleBuilder/ConditionTree/index.d.ts +0 -15
- package/dist/components/Rules/RuleBuilder/ConditionTree/index.js +0 -10
- package/dist/components/Rules/RuleBuilder/RuleBuilder.d.ts +0 -67
- package/dist/components/Rules/RuleBuilder/RuleBuilder.js +0 -366
- package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.d.ts +0 -32
- package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.js +0 -420
- package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.d.ts +0 -27
- package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.js +0 -446
- package/dist/components/Rules/RuleBuilder/Summary/index.d.ts +0 -7
- package/dist/components/Rules/RuleBuilder/Summary/index.js +0 -2
- package/dist/components/Rules/RuleBuilder/classes.d.ts +0 -19
- package/dist/components/Rules/RuleBuilder/classes.js +0 -18
- package/dist/components/Rules/RuleBuilder/index.d.ts +0 -55
- package/dist/components/Rules/RuleBuilder/index.js +0 -11
- package/dist/components/Rules/RuleBuilder/models/actionModel.d.ts +0 -31
- package/dist/components/Rules/RuleBuilder/models/actionModel.js +0 -276
- package/dist/components/Rules/RuleBuilder/models/conditionModel.d.ts +0 -95
- package/dist/components/Rules/RuleBuilder/models/conditionModel.js +0 -418
- package/dist/components/Rules/RuleBuilder/models/index.d.ts +0 -3
- package/dist/components/Rules/RuleBuilder/models/index.js +0 -3
- package/dist/components/Rules/RuleBuilder/models/validation.d.ts +0 -176
- package/dist/components/Rules/RuleBuilder/models/validation.js +0 -242
- package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.d.ts +0 -27
- package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.js +0 -92
- package/dist/components/Rules/RuleBuilder/shared/index.d.ts +0 -1
- package/dist/components/Rules/RuleBuilder/shared/index.js +0 -1
- package/dist/components/Rules/RuleBuilder/types.d.ts +0 -384
- package/dist/components/Rules/RuleBuilder/types.js +0 -0
- package/dist/components/Rules/RuleBuilder/utils/constants.d.ts +0 -65
- package/dist/components/Rules/RuleBuilder/utils/constants.js +0 -356
- package/dist/components/Rules/RuleBuilder/utils/extractBindings.d.ts +0 -48
- package/dist/components/Rules/RuleBuilder/utils/extractBindings.js +0 -42
- package/dist/components/Rules/RuleBuilder/utils/helpers.d.ts +0 -92
- package/dist/components/Rules/RuleBuilder/utils/helpers.js +0 -54
- package/dist/components/Rules/RuleBuilder/utils/index.d.ts +0 -2
- package/dist/components/Rules/RuleBuilder/utils/index.js +0 -2
|
@@ -1,508 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SDK Bridge - Integrate Proton SDK with Point Selector
|
|
3
|
-
*
|
|
4
|
-
* **IMPORTANT: Proton SDK is the ONLY source of truth for point validation.**
|
|
5
|
-
*
|
|
6
|
-
* This file provides typed wrappers around SDK operations with proper error handling.
|
|
7
|
-
* All point grammar rules, tree-shape validation, and canonical rendering are handled
|
|
8
|
-
* by the SDK WASM module, which is identical to what proton backend uses.
|
|
9
|
-
*
|
|
10
|
-
* Architecture:
|
|
11
|
-
* - SDK validates ALL grammar rules (native-first, role termination, ordinal binding, etc.)
|
|
12
|
-
* - SDK provides canonical form, error messages, fixes, and incomplete state detection
|
|
13
|
-
* - NO custom UI-level validation should duplicate SDK logic
|
|
14
|
-
* - Legacy segment rendering (pointOf) has been fully replaced by SDK render()
|
|
15
|
-
*
|
|
16
|
-
* See:
|
|
17
|
-
* - /node/proton/docs/user/point-sdk.md - SDK API specification
|
|
18
|
-
* - /packages/docs/point-format.md - Point grammar (STAR notation)
|
|
19
|
-
* - /packages/docs/tree-shape.md - What can exist under each point
|
|
20
|
-
*/
|
|
21
|
-
import type { CheckOptions, Choices, CompleteOptions, Completion, CompletionItem, Layer, Proton, RuleContext, Segment, SegmentCheck, Verdict, Words } from '@wallarm-org/rules-lib';
|
|
22
|
-
export interface ValidationResult {
|
|
23
|
-
/** SDK canonical form (store this!) */
|
|
24
|
-
canonical: string | null;
|
|
25
|
-
/** Validation error if any */
|
|
26
|
-
error: Verdict | null;
|
|
27
|
-
/** Whether point is exact (one node, no wildcards/alternations) */
|
|
28
|
-
exact: boolean;
|
|
29
|
-
/** true = valid prefix, keep typing; false = actual error */
|
|
30
|
-
incomplete: boolean;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Validate point string using SDK
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const result = checkPoint(proton, '[http:header', { context: 'http_request' });
|
|
38
|
-
* if (result.incomplete) {
|
|
39
|
-
* // Show info: "Keep typing..."
|
|
40
|
-
* } else if (result.error) {
|
|
41
|
-
* // Show error with fixes: result.error.fixes
|
|
42
|
-
* } else {
|
|
43
|
-
* // Valid: store result.canonical
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare function checkPoint(proton: Proton | null, point: string, options: CheckOptions): ValidationResult;
|
|
48
|
-
/**
|
|
49
|
-
* Validate custom segments using SDK
|
|
50
|
-
*
|
|
51
|
-
* Converts custom Segment[] → point string → SDK check → canonical form
|
|
52
|
-
* Legacy compatibility - prefer checkPoint() for new code.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const result = validateSegments(proton, segments, 'http_request', 'tree');
|
|
57
|
-
* if (result.canonical) {
|
|
58
|
-
* // Store canonical form: "[http:header]['authorization']"
|
|
59
|
-
* } else if (result.incomplete) {
|
|
60
|
-
* // Show "Keep typing..."
|
|
61
|
-
* } else {
|
|
62
|
-
* // Show error: result.error.message
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export declare function validateSegments(proton: Proton | null, segments: readonly Segment[], context: RuleContext, profile?: Layer): ValidationResult;
|
|
67
|
-
/**
|
|
68
|
-
* Get autocomplete suggestions at cursor position
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* const completion = completePoint(proton, '[http:hea', 9, {
|
|
73
|
-
* context: 'http_request',
|
|
74
|
-
* keys: ['authorization', 'cookie'],
|
|
75
|
-
* });
|
|
76
|
-
*
|
|
77
|
-
* if (completion.error) {
|
|
78
|
-
* // Text before cursor already fails - show error and fixes
|
|
79
|
-
* }
|
|
80
|
-
*
|
|
81
|
-
* completion.items.forEach(item => {
|
|
82
|
-
* if (item.open) {
|
|
83
|
-
* // Template item - insert and complete again
|
|
84
|
-
* }
|
|
85
|
-
* // Show: item.label, item.detail, item.category
|
|
86
|
-
* });
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
export declare function completePoint(proton: Proton | null, point: string, cursor: number, options: CompleteOptions): Completion | null;
|
|
90
|
-
/**
|
|
91
|
-
* Get next possible segments at position (segment-based API)
|
|
92
|
-
*
|
|
93
|
-
* Alternative to complete() for UI that builds points from segments.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* const next = nextSegments(proton, segments, segments.length, {
|
|
98
|
-
* context: 'http_request',
|
|
99
|
-
* keys: provider,
|
|
100
|
-
* });
|
|
101
|
-
*
|
|
102
|
-
* if (next?.keySlot && next.query) {
|
|
103
|
-
* // User is typing a key - filter items by next.query
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
export declare function nextSegments(proton: Proton | null, segments: Segment[], at: number, options: CompleteOptions): Choices | null;
|
|
108
|
-
/**
|
|
109
|
-
* Check if point is valid for the "value" profile
|
|
110
|
-
*
|
|
111
|
-
* Value profile requires:
|
|
112
|
-
* - One node (no wildcards/alternations/ordinals except joins)
|
|
113
|
-
* - A node with data (not a container)
|
|
114
|
-
*
|
|
115
|
-
* Used for session-definition rules and other value-reading contexts.
|
|
116
|
-
*/
|
|
117
|
-
export declare function isValuePoint(proton: Proton | null, point: string, context: RuleContext): boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Render segments to canonical point string using SDK
|
|
120
|
-
*
|
|
121
|
-
* **Requires SDK**: This function requires a valid Proton instance.
|
|
122
|
-
* All segments must be in SDK-compatible format.
|
|
123
|
-
*
|
|
124
|
-
* **Segment compatibility:**
|
|
125
|
-
* - UI Segment type extends SDK Segment with metadata fields (label, desc, etc.)
|
|
126
|
-
* - SDK render() ignores unknown fields, reads only: kind, text, name, fuzzy, dup, multi, etc.
|
|
127
|
-
* - Cast to `any` is safe: SDK type is strict subset of UI type
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```typescript
|
|
131
|
-
* const point = renderSegments(proton, segments);
|
|
132
|
-
* // Returns: "[http:header]['authorization'][format:jwt]['payload']['sub']"
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
/**
|
|
136
|
-
* Normalize segment numeric fields to ensure proper i32 types for WASM
|
|
137
|
-
*/
|
|
138
|
-
export declare function normalizeSegment(seg: Segment): Segment;
|
|
139
|
-
export declare function renderSegments(proton: Proton | null, segments: Segment[]): string;
|
|
140
|
-
/**
|
|
141
|
-
* Alias for renderSegments - used by RuleBuilder models for converting segments to point strings.
|
|
142
|
-
*
|
|
143
|
-
* @param segments - Array of segments to render
|
|
144
|
-
* @param proton - Proton SDK instance (optional for backwards compatibility)
|
|
145
|
-
* @returns Canonical point string
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* const point = pointOf(segments, proton);
|
|
150
|
-
* // Returns: "[http:header]['authorization']"
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
export declare function pointOf(segments: Segment[], proton?: Proton | null): string;
|
|
154
|
-
/**
|
|
155
|
-
* Convert SDK CompletionItem to legacy MenuRow format
|
|
156
|
-
*
|
|
157
|
-
* Backward compatibility helper for gradual migration.
|
|
158
|
-
* Maps SDK completion structure to UI MenuRow for existing components.
|
|
159
|
-
*
|
|
160
|
-
* @param item - SDK CompletionItem from complete() or next()
|
|
161
|
-
* @param index - 0-based index for numbering (1-indexed in UI)
|
|
162
|
-
* @returns MenuRow compatible with StepMenu component
|
|
163
|
-
*/
|
|
164
|
-
export declare function completionToMenuRow(item: CompletionItem, index: number): {
|
|
165
|
-
id: string;
|
|
166
|
-
label: string;
|
|
167
|
-
desc: string;
|
|
168
|
-
number?: number;
|
|
169
|
-
custom?: boolean;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Get next segment options using SDK next()
|
|
173
|
-
*
|
|
174
|
-
* Replaces legacy nextFor() with SDK next() for richer completions.
|
|
175
|
-
* Uses SDK's segment-based next() API which provides:
|
|
176
|
-
* - source: 'grammar' | 'tree' | 'dictionary'
|
|
177
|
-
* - category: 'format' | 'encoding' | 'key' | ...
|
|
178
|
-
* - open: true if template (needs user input)
|
|
179
|
-
* - Tree-based suggestions (not just grammar)
|
|
180
|
-
* - Dictionary completions
|
|
181
|
-
*
|
|
182
|
-
* This is more direct than complete() for UI that builds points from segments,
|
|
183
|
-
* avoiding round-trip through point string serialization.
|
|
184
|
-
*
|
|
185
|
-
* @param proton - SDK instance
|
|
186
|
-
* @param segments - Current segments
|
|
187
|
-
* @param context - Rule context
|
|
188
|
-
* @param keys - Keys provider (array or sync function)
|
|
189
|
-
* @param profile - Point profile: 'tree' (default, any point) or 'value' (single node with data).
|
|
190
|
-
* 'tree' accepts wildcards/containers, 'value' requires a single readable node.
|
|
191
|
-
* Used for session rules and value extraction contexts.
|
|
192
|
-
* @returns Array of completion items or empty array if SDK unavailable
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* ```typescript
|
|
196
|
-
* const items = getNextSegmentOptions(proton, segments, 'http_request', myKeys, 'tree');
|
|
197
|
-
* const rows = items.map((item, i) => completionToMenuRow(item, i));
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
export declare function getNextSegmentOptions(proton: Proton | null, segments: Segment[], context: RuleContext, keys?: string[] | ((parent: string) => string[]), profile?: Layer): CompletionItem[];
|
|
201
|
-
/**
|
|
202
|
-
* Get human-readable error message with layer context
|
|
203
|
-
*
|
|
204
|
-
* Handles MCP-specific errors per point-sdk.md:184-195
|
|
205
|
-
*/
|
|
206
|
-
export declare function formatError(error: Verdict): string;
|
|
207
|
-
/**
|
|
208
|
-
* Get error span for highlighting in UI
|
|
209
|
-
*
|
|
210
|
-
* Returns UTF-16 indices suitable for JS string.slice()
|
|
211
|
-
*/
|
|
212
|
-
export declare function getErrorSpan(error: Verdict): [number, number];
|
|
213
|
-
/**
|
|
214
|
-
* Get context-aware vocabulary
|
|
215
|
-
*
|
|
216
|
-
* Returns available natives, formats, encodings, etc. for a context.
|
|
217
|
-
*
|
|
218
|
-
* @example
|
|
219
|
-
* ```typescript
|
|
220
|
-
* const vocab = getVocabulary(proton, 'http_request');
|
|
221
|
-
* // Returns: { natives: ['method', 'proto', 'url', ...], formats: ['json', 'xml', ...], ... }
|
|
222
|
-
*
|
|
223
|
-
* const vocab = getVocabulary(proton, 'grpc_request');
|
|
224
|
-
* // Returns: { natives: [], formats: ['protobuf', ...], ... } (gRPC has no natives)
|
|
225
|
-
* ```
|
|
226
|
-
*/
|
|
227
|
-
export declare function getVocabulary(proton: Proton | null, context?: RuleContext): Words;
|
|
228
|
-
/**
|
|
229
|
-
* Split point into display steps
|
|
230
|
-
*
|
|
231
|
-
* Returns SDK-canonical step rendering for display in UI.
|
|
232
|
-
*
|
|
233
|
-
* @example
|
|
234
|
-
* ```typescript
|
|
235
|
-
* const steps = getSteps(proton, "[http:header]['authorization'][format:jwt]['payload']['sub']");
|
|
236
|
-
* // Returns: [
|
|
237
|
-
* // { span: [0, 13], text: "http:header", closed: true },
|
|
238
|
-
* // { span: [13, 30], text: "'authorization'", closed: true },
|
|
239
|
-
* // { span: [30, 42], text: "format:jwt", closed: true },
|
|
240
|
-
* // { span: [42, 53], text: "'payload'", closed: true },
|
|
241
|
-
* // { span: [53, 58], text: "'sub'", closed: true }
|
|
242
|
-
* // ]
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
export declare function getSteps(proton: Proton | null, point: string): import("@wallarm-org/rules-lib").Step[];
|
|
246
|
-
/**
|
|
247
|
-
* Check if point needs re-canonicalization due to SDK version change
|
|
248
|
-
*
|
|
249
|
-
* SDK bumps canonical version when canonical spelling changes.
|
|
250
|
-
* Points stored with old version must be re-canonicalized.
|
|
251
|
-
*
|
|
252
|
-
* See point-sdk.md "Version" section (lines 331-349):
|
|
253
|
-
* > "Store `canonical` beside the canonical points you keep. Proton bumps it
|
|
254
|
-
* > whenever the canonical spelling of any point changes. When it moves,
|
|
255
|
-
* > re-canonicalize the stored points with `check`."
|
|
256
|
-
*
|
|
257
|
-
* @param currentVersion - Current SDK canonical version (from version().canonical)
|
|
258
|
-
* @param storedVersion - Canonical version when point was stored (undefined = needs canonicalization)
|
|
259
|
-
* @returns true if point needs re-canonicalization
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
* ```typescript
|
|
263
|
-
* const sdkVersion = proton.version().canonical;
|
|
264
|
-
* const point = loadedPoint; // from storage
|
|
265
|
-
*
|
|
266
|
-
* if (needsRecanonalization(sdkVersion, point.canonicalVersion)) {
|
|
267
|
-
* // Re-canonicalize with check()
|
|
268
|
-
* const result = checkPoint(proton, point.canonical, { context });
|
|
269
|
-
* if (result.canonical) {
|
|
270
|
-
* point.canonical = result.canonical;
|
|
271
|
-
* point.canonicalVersion = sdkVersion;
|
|
272
|
-
* }
|
|
273
|
-
* }
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
|
-
export declare function needsRecanonalization(currentVersion: number | undefined, storedVersion: number | undefined): boolean;
|
|
277
|
-
/**
|
|
278
|
-
* Re-canonicalize point if version changed
|
|
279
|
-
*
|
|
280
|
-
* Updates canonical form and version when SDK version changes.
|
|
281
|
-
* Returns updated value with new canonical form and version.
|
|
282
|
-
*
|
|
283
|
-
* @param proton - SDK instance
|
|
284
|
-
* @param value - Point selector value with canonical form and version
|
|
285
|
-
* @param context - Rule context for validation
|
|
286
|
-
* @returns Updated value with new canonical form and version, or original if no change needed
|
|
287
|
-
*
|
|
288
|
-
* @example
|
|
289
|
-
* ```typescript
|
|
290
|
-
* const updated = recanonicalizeIfNeeded(proton, loadedValue, 'http_request');
|
|
291
|
-
* if (updated !== loadedValue) {
|
|
292
|
-
* console.log('Point re-canonicalized:', updated.canonical);
|
|
293
|
-
* saveValue(updated); // Save updated form
|
|
294
|
-
* }
|
|
295
|
-
* ```
|
|
296
|
-
*/
|
|
297
|
-
export declare function recanonicalizeIfNeeded(proton: Proton | null, value: {
|
|
298
|
-
canonical?: string;
|
|
299
|
-
canonicalVersion?: number;
|
|
300
|
-
segments: Segment[];
|
|
301
|
-
}, context: RuleContext): typeof value;
|
|
302
|
-
/**
|
|
303
|
-
* Get SDK version info
|
|
304
|
-
*
|
|
305
|
-
* Returns version information for compatibility checking.
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
* ```typescript
|
|
309
|
-
* const version = getVersion(proton);
|
|
310
|
-
* // Returns: {
|
|
311
|
-
* // crate: "proton-new",
|
|
312
|
-
* // ruleset_format: "0.10.3",
|
|
313
|
-
* // canonical: 1,
|
|
314
|
-
* // commit: "abc123"
|
|
315
|
-
* // }
|
|
316
|
-
* ```
|
|
317
|
-
*/
|
|
318
|
-
export declare function getVersion(proton: Proton | null): import("@wallarm-org/rules-lib").VersionInfo | null;
|
|
319
|
-
/**
|
|
320
|
-
* Validate segments directly (segment-based API)
|
|
321
|
-
*
|
|
322
|
-
* Alternative to checkPoint() for UI that builds points from segments.
|
|
323
|
-
* This uses SDK's checkSegments() which validates segment structure directly.
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* ```typescript
|
|
327
|
-
* const result = checkSegmentsDirectly(proton, segments, { context: 'http_request', profile: 'tree' });
|
|
328
|
-
* if (result.ok) {
|
|
329
|
-
* // Valid: use result.canonical
|
|
330
|
-
* } else if (result.error.incomplete) {
|
|
331
|
-
* // Keep typing
|
|
332
|
-
* } else {
|
|
333
|
-
* // Show error: result.error.message
|
|
334
|
-
* }
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
export declare function checkSegmentsDirectly(proton: Proton | null, segments: Segment[], options: CheckOptions): SegmentCheck;
|
|
338
|
-
/**
|
|
339
|
-
* SDK Segment Constructors
|
|
340
|
-
*
|
|
341
|
-
* Type-safe helpers for creating SDK-canonical segment structures.
|
|
342
|
-
* These match the Proton SDK's segment format exactly.
|
|
343
|
-
*
|
|
344
|
-
* **CRITICAL**: Always use these constructors instead of manual object construction
|
|
345
|
-
* to ensure backend compatibility and type safety.
|
|
346
|
-
*
|
|
347
|
-
* @example
|
|
348
|
-
* ```typescript
|
|
349
|
-
* // ❌ Manual construction (wrong, breaks SDK compatibility)
|
|
350
|
-
* const seg = { kind: 'native', value: 'body' };
|
|
351
|
-
*
|
|
352
|
-
* // ✅ SDK constructor (correct, guaranteed compatible)
|
|
353
|
-
* const seg = sdkSeg.native('body');
|
|
354
|
-
* ```
|
|
355
|
-
*/
|
|
356
|
-
export declare const sdkSeg: {
|
|
357
|
-
/**
|
|
358
|
-
* Native segment: [http:body], [http:header], [sse:data], etc.
|
|
359
|
-
* SDK determines family internally from the word - do not pass family parameter.
|
|
360
|
-
* @example sdkSeg.native('body') → { kind: 'native', value: 'body' }
|
|
361
|
-
* @example sdkSeg.native('data') → { kind: 'native', value: 'data' }
|
|
362
|
-
*/
|
|
363
|
-
readonly native: (word: string) => any;
|
|
364
|
-
/**
|
|
365
|
-
* Key segment: ['user'], ['email'], etc.
|
|
366
|
-
* @example sdkSeg.key('user') → { kind: 'key', value: 'user' }
|
|
367
|
-
*/
|
|
368
|
-
readonly key: (value: string) => any;
|
|
369
|
-
/**
|
|
370
|
-
* Key name segment: ['user'][role:name]
|
|
371
|
-
* SDK uses a separate 'name' kind (not 'key' with role).
|
|
372
|
-
* @example sdkSeg.name('user') → { kind: 'name', value: 'user' }
|
|
373
|
-
*/
|
|
374
|
-
readonly name: (value: string) => any;
|
|
375
|
-
/**
|
|
376
|
-
* Attribute segment: [attr:'@id'], [attr:'@class'], etc.
|
|
377
|
-
* SDK uses kind 'typed' (not 'attr').
|
|
378
|
-
* @example sdkSeg.attr('@id') → { kind: 'typed', value: '@id' }
|
|
379
|
-
*/
|
|
380
|
-
readonly attr: (value: string) => any;
|
|
381
|
-
/**
|
|
382
|
-
* Attribute name segment: [attr:'@id'][role:name]
|
|
383
|
-
* SDK uses kind 'typed_name' (not 'attr' with role).
|
|
384
|
-
* @example sdkSeg.attrName('@id') → { kind: 'typed_name', value: '@id' }
|
|
385
|
-
*/
|
|
386
|
-
readonly attrName: (value: string) => any;
|
|
387
|
-
/**
|
|
388
|
-
* Format segment: [format:json], [format:xml], etc.
|
|
389
|
-
* @example sdkSeg.format('json') → { kind: 'content', name: 'json' }
|
|
390
|
-
*/
|
|
391
|
-
readonly format: (name: string) => any;
|
|
392
|
-
/**
|
|
393
|
-
* Encoding segment: [encoding:base64], [encoding:gzip], etc.
|
|
394
|
-
* @example sdkSeg.encoding('base64') → { kind: 'content', name: 'base64' }
|
|
395
|
-
*/
|
|
396
|
-
readonly encoding: (name: string) => any;
|
|
397
|
-
/**
|
|
398
|
-
* Array index segment: [0], [5], [42], etc.
|
|
399
|
-
* @example sdkSeg.index(3) → { kind: 'index', index: 3 }
|
|
400
|
-
*/
|
|
401
|
-
readonly index: (index: number) => any;
|
|
402
|
-
/**
|
|
403
|
-
* Duplicate ordinal: ['key'][dup:0], ['key'][dup:-1], etc.
|
|
404
|
-
* SDK uses field 'index' (not 'ord').
|
|
405
|
-
* @example sdkSeg.dup(0) → { kind: 'dup_index', index: 0 }
|
|
406
|
-
*/
|
|
407
|
-
readonly dup: (index: number) => any;
|
|
408
|
-
/**
|
|
409
|
-
* Duplicate all: ['key'][dup:all]
|
|
410
|
-
* @example sdkSeg.dupAll() → { kind: 'dup_all' }
|
|
411
|
-
*/
|
|
412
|
-
readonly dupAll: () => any;
|
|
413
|
-
/**
|
|
414
|
-
* Duplicate any: ['key'][dup:any] (default, usually omitted)
|
|
415
|
-
* @example sdkSeg.dupAny() → { kind: 'dup_any' }
|
|
416
|
-
*/
|
|
417
|
-
readonly dupAny: () => any;
|
|
418
|
-
/**
|
|
419
|
-
* Joined entry: ['key'][dup,joined:', ']
|
|
420
|
-
* SDK uses kind 'combined_key' (not 'joined').
|
|
421
|
-
* @example sdkSeg.joined('cookie', ', ') → { kind: 'combined_key', value: 'cookie', separator: ', ' }
|
|
422
|
-
*/
|
|
423
|
-
readonly joined: (value: string, separator: string) => any;
|
|
424
|
-
/**
|
|
425
|
-
* Wildcard segment: [*], [key:*], [arr|key:*], [key:*][role:value], etc.
|
|
426
|
-
* SDK uses kind 'wildcard' (not 'wild').
|
|
427
|
-
* Quant values per SDK spec: one (=*), zero_or_one (=?), zero_or_more (=**), one_or_more (=+)
|
|
428
|
-
* Role optional: narrows to 'name' or 'value' entries (only valid with key/attr kinds)
|
|
429
|
-
* @example sdkSeg.wild(['key'], 'one') → { kind: 'wildcard', kinds: ['key'], quant: 'one' }
|
|
430
|
-
* @example sdkSeg.wild(['key', 'arr'], 'zero_or_more', 'value') → { kind: 'wildcard', kinds: ['key', 'arr'], quant: 'zero_or_more', role: 'value' }
|
|
431
|
-
*/
|
|
432
|
-
readonly wild: (kinds: string[], quant: 'one' | 'zero_or_one' | 'zero_or_more' | 'one_or_more', role?: 'name' | 'value') => any;
|
|
433
|
-
/**
|
|
434
|
-
* Method segment (MCP alias): [method:'tools/call'] after [format:mcp]
|
|
435
|
-
* NOTE: This is a UI helper, not a real SDK constructor. The SDK has no seg.method().
|
|
436
|
-
* @example sdkSeg.method('tools/call') → { kind: 'key', value: 'tools/call' }
|
|
437
|
-
*/
|
|
438
|
-
readonly method: (value: string) => any;
|
|
439
|
-
/**
|
|
440
|
-
* Method any (MCP alias): [method:*] after [format:mcp]
|
|
441
|
-
* NOTE: This is a UI helper, not a real SDK constructor. The SDK has no seg.methodAny().
|
|
442
|
-
* @example sdkSeg.methodAny() → { kind: 'wildcard', kinds: ['key'], quant: 'one' }
|
|
443
|
-
*/
|
|
444
|
-
readonly methodAny: () => any;
|
|
445
|
-
/**
|
|
446
|
-
* Method value (MCP alias): [method] after [format:mcp]
|
|
447
|
-
* NOTE: This is a UI helper, not a real SDK constructor. The SDK has no seg.methodValue().
|
|
448
|
-
* @example sdkSeg.methodValue() → { kind: 'key' }
|
|
449
|
-
*/
|
|
450
|
-
readonly methodValue: () => any;
|
|
451
|
-
};
|
|
452
|
-
/**
|
|
453
|
-
* Create alternation segment: ['a'|'b'], [format:json|xml], [i:'header'|'authorization'], etc.
|
|
454
|
-
*
|
|
455
|
-
* Per SDK spec, alternation structure is:
|
|
456
|
-
* { kind: 'alts', alts: [{ segment: Segment, caseless: boolean }, ...] }
|
|
457
|
-
*
|
|
458
|
-
* @param segments - Array of segment choices (must be non-empty)
|
|
459
|
-
* @param caseless - Optional array of caseless flags per segment (for i: prefix)
|
|
460
|
-
* @returns Alternation segment or single segment if length === 1
|
|
461
|
-
* @throws {Error} If segments array is empty (would create empty_union error from SDK)
|
|
462
|
-
*
|
|
463
|
-
* @example
|
|
464
|
-
* ```typescript
|
|
465
|
-
* // Single format → direct segment
|
|
466
|
-
* sdkAlts([sdkSeg.format('json')]) → { kind: 'content', name: 'json' }
|
|
467
|
-
*
|
|
468
|
-
* // Multiple formats → alternation
|
|
469
|
-
* sdkAlts([sdkSeg.format('json'), sdkSeg.format('xml')])
|
|
470
|
-
* → { kind: 'alts', alts: [
|
|
471
|
-
* { segment: { kind: 'content', name: 'json' }, caseless: false },
|
|
472
|
-
* { segment: { kind: 'content', name: 'xml' }, caseless: false }
|
|
473
|
-
* ]}
|
|
474
|
-
*
|
|
475
|
-
* // Caseless alternation: [i:'Authorization'|'Cookie']
|
|
476
|
-
* sdkAlts([sdkSeg.key('Authorization'), sdkSeg.key('Cookie')], [true, true])
|
|
477
|
-
* → { kind: 'alts', alts: [
|
|
478
|
-
* { segment: { kind: 'key', value: 'Authorization' }, caseless: true },
|
|
479
|
-
* { segment: { kind: 'key', value: 'Cookie' }, caseless: true }
|
|
480
|
-
* ]}
|
|
481
|
-
* ```
|
|
482
|
-
*/
|
|
483
|
-
export declare function sdkAlts(segments: any[], caseless?: boolean[]): any;
|
|
484
|
-
/**
|
|
485
|
-
* Combine multiple choices into appropriate segment format
|
|
486
|
-
*
|
|
487
|
-
* Replaces legacy combine() function with SDK-compatible version.
|
|
488
|
-
*
|
|
489
|
-
* @param kind - Segment kind ('format', 'encoding', 'key', etc.)
|
|
490
|
-
* @param names - Array of values to combine (must be non-empty)
|
|
491
|
-
* @param caseless - Optional array of caseless flags per name (for i: prefix)
|
|
492
|
-
* @returns Single segment or alternation segment
|
|
493
|
-
* @throws {Error} If names array is empty (would create empty_union error from SDK)
|
|
494
|
-
*
|
|
495
|
-
* @example
|
|
496
|
-
* ```typescript
|
|
497
|
-
* // Single choice → direct segment
|
|
498
|
-
* sdkCombine('format', ['json']) → { kind: 'content', name: 'json' }
|
|
499
|
-
*
|
|
500
|
-
* // Multiple choices → alternation with correct structure
|
|
501
|
-
* sdkCombine('format', ['json', 'xml'])
|
|
502
|
-
* → { kind: 'alts', alts: [{ segment: {...}, caseless: false }, ...] }
|
|
503
|
-
*
|
|
504
|
-
* // Caseless keys: [i:'authorization'|'cookie']
|
|
505
|
-
* sdkCombine('key', ['authorization', 'cookie'], [true, true])
|
|
506
|
-
* ```
|
|
507
|
-
*/
|
|
508
|
-
export declare function sdkCombine(kind: string, names: string[], caseless?: boolean[]): any;
|