@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,339 +0,0 @@
|
|
|
1
|
-
function checkPoint(proton, point, options) {
|
|
2
|
-
if (!proton || '' === point) return {
|
|
3
|
-
canonical: null,
|
|
4
|
-
error: null,
|
|
5
|
-
exact: false,
|
|
6
|
-
incomplete: false
|
|
7
|
-
};
|
|
8
|
-
try {
|
|
9
|
-
const result = proton.point.check(point, options);
|
|
10
|
-
if (result.ok) return {
|
|
11
|
-
canonical: result.canonical,
|
|
12
|
-
error: null,
|
|
13
|
-
exact: result.exact,
|
|
14
|
-
incomplete: false
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
canonical: null,
|
|
18
|
-
error: result.error,
|
|
19
|
-
exact: false,
|
|
20
|
-
incomplete: result.error.incomplete
|
|
21
|
-
};
|
|
22
|
-
} catch (error) {
|
|
23
|
-
throw new Error(`SDK transport failure: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function validateSegments(proton, segments, context, profile = 'tree') {
|
|
27
|
-
if (!proton || 0 === segments.length) return {
|
|
28
|
-
canonical: null,
|
|
29
|
-
error: null,
|
|
30
|
-
exact: false,
|
|
31
|
-
incomplete: false
|
|
32
|
-
};
|
|
33
|
-
const point = renderSegments(proton, segments);
|
|
34
|
-
return checkPoint(proton, point, {
|
|
35
|
-
profile,
|
|
36
|
-
context
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function completePoint(proton, point, cursor, options) {
|
|
40
|
-
if (!proton) return null;
|
|
41
|
-
const completion = proton.point.complete(point, cursor, options);
|
|
42
|
-
if (completion && !completion.error && completion.items) {
|
|
43
|
-
const hasMcp = completion.items.some((item)=>'format' === item.category && 'mcp' === item.key);
|
|
44
|
-
if (hasMcp) return {
|
|
45
|
-
...completion,
|
|
46
|
-
items: completion.items.filter((item)=>!('format' === item.category && 'mcp' === item.key))
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return completion;
|
|
50
|
-
}
|
|
51
|
-
function nextSegments(proton, segments, at, options) {
|
|
52
|
-
if (!proton) return null;
|
|
53
|
-
const result = proton.point.next(segments, at, options);
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
function isValuePoint(proton, point, context) {
|
|
57
|
-
if (!proton || '' === point) return false;
|
|
58
|
-
const result = proton.point.check(point, {
|
|
59
|
-
profile: 'value',
|
|
60
|
-
context
|
|
61
|
-
});
|
|
62
|
-
return result.ok;
|
|
63
|
-
}
|
|
64
|
-
function normalizeSegment(seg) {
|
|
65
|
-
const normalized = {};
|
|
66
|
-
for(const key in seg){
|
|
67
|
-
const value = seg[key];
|
|
68
|
-
if ('number' == typeof value && 'span' !== key) normalized[key] = 0 | Math.floor(value);
|
|
69
|
-
else normalized[key] = value;
|
|
70
|
-
}
|
|
71
|
-
return normalized;
|
|
72
|
-
}
|
|
73
|
-
function renderSegments(proton, segments) {
|
|
74
|
-
if (!proton) {
|
|
75
|
-
if (0 === segments.length) return 'flow';
|
|
76
|
-
return segments.map((s)=>s.text || '').join('');
|
|
77
|
-
}
|
|
78
|
-
const normalizedSegments = segments.map(normalizeSegment);
|
|
79
|
-
return proton.point.render(normalizedSegments);
|
|
80
|
-
}
|
|
81
|
-
function pointOf(segments, proton) {
|
|
82
|
-
return renderSegments(proton ?? null, segments);
|
|
83
|
-
}
|
|
84
|
-
function completionToMenuRow(item, index) {
|
|
85
|
-
return {
|
|
86
|
-
id: item.key || `completion-${index}`,
|
|
87
|
-
label: item.label,
|
|
88
|
-
desc: item.detail,
|
|
89
|
-
number: index < 9 ? index + 1 : void 0,
|
|
90
|
-
custom: 'dictionary' === item.source
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function getNextSegmentOptions(proton, segments, context, keys, profile = 'tree') {
|
|
94
|
-
if (!proton) return [];
|
|
95
|
-
try {
|
|
96
|
-
const choices = proton.point.next(segments, segments.length, {
|
|
97
|
-
context,
|
|
98
|
-
profile,
|
|
99
|
-
keys
|
|
100
|
-
});
|
|
101
|
-
if (!choices) return [];
|
|
102
|
-
if (choices.error) return [];
|
|
103
|
-
return (choices.items || []).map((choice)=>({
|
|
104
|
-
label: choice.label ?? '',
|
|
105
|
-
detail: choice.detail ?? '',
|
|
106
|
-
key: choice.label ?? '',
|
|
107
|
-
kind: 'key',
|
|
108
|
-
insert: '',
|
|
109
|
-
caret: 0,
|
|
110
|
-
source: choice.source ?? 'vocabulary',
|
|
111
|
-
open: choice.open ?? false,
|
|
112
|
-
category: choice.category,
|
|
113
|
-
segment: choice.segment
|
|
114
|
-
}));
|
|
115
|
-
} catch {
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function formatError(error) {
|
|
120
|
-
const mcpCodes = [
|
|
121
|
-
'mcp_repeated',
|
|
122
|
-
'mcp_prefix',
|
|
123
|
-
'mcp_in_alternation',
|
|
124
|
-
'mcp_step',
|
|
125
|
-
'mcp_request_member',
|
|
126
|
-
'mcp_method_untagged',
|
|
127
|
-
'mcp_method_position'
|
|
128
|
-
];
|
|
129
|
-
if (mcpCodes.includes(error.code)) return `MCP alias error: ${error.message}`;
|
|
130
|
-
const layerPrefix = {
|
|
131
|
-
grammar: 'Syntax error',
|
|
132
|
-
tree: 'Invalid point',
|
|
133
|
-
value: 'Not a value point'
|
|
134
|
-
}[error.layer];
|
|
135
|
-
return `${layerPrefix}: ${error.message}`;
|
|
136
|
-
}
|
|
137
|
-
function getErrorSpan(error) {
|
|
138
|
-
return error.span;
|
|
139
|
-
}
|
|
140
|
-
function getVocabulary(proton, context) {
|
|
141
|
-
if (!proton) return {
|
|
142
|
-
natives: [],
|
|
143
|
-
formats: [],
|
|
144
|
-
encodings: [],
|
|
145
|
-
kinds: [],
|
|
146
|
-
quantifiers: [],
|
|
147
|
-
roles: [],
|
|
148
|
-
dups: []
|
|
149
|
-
};
|
|
150
|
-
return proton.point.vocabulary(context);
|
|
151
|
-
}
|
|
152
|
-
function getSteps(proton, point) {
|
|
153
|
-
if (!proton || !point) return [];
|
|
154
|
-
const result = proton.point.steps(point);
|
|
155
|
-
if (result.error) return [];
|
|
156
|
-
return result.steps;
|
|
157
|
-
}
|
|
158
|
-
function needsRecanonalization(currentVersion, storedVersion) {
|
|
159
|
-
if (void 0 === storedVersion) return true;
|
|
160
|
-
if (void 0 === currentVersion) return false;
|
|
161
|
-
return currentVersion !== storedVersion;
|
|
162
|
-
}
|
|
163
|
-
function recanonicalizeIfNeeded(proton, value, context) {
|
|
164
|
-
if (!proton || !value.canonical) return value;
|
|
165
|
-
const currentVersion = proton.version().canonical;
|
|
166
|
-
if (!needsRecanonalization(currentVersion, value.canonicalVersion)) return value;
|
|
167
|
-
const result = checkPoint(proton, value.canonical, {
|
|
168
|
-
context
|
|
169
|
-
});
|
|
170
|
-
if (!result.canonical) {
|
|
171
|
-
console.warn(`Point re-canonicalization failed for "${value.canonical}": ${result.error?.message || 'unknown error'}. Keeping original form. This may indicate the point syntax is no longer valid in SDK version ${currentVersion}.`);
|
|
172
|
-
return value;
|
|
173
|
-
}
|
|
174
|
-
return {
|
|
175
|
-
...value,
|
|
176
|
-
canonical: result.canonical,
|
|
177
|
-
canonicalVersion: currentVersion
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
function getVersion(proton) {
|
|
181
|
-
if (!proton) return null;
|
|
182
|
-
try {
|
|
183
|
-
return proton.version();
|
|
184
|
-
} catch {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function checkSegmentsDirectly(proton, segments, options) {
|
|
189
|
-
if (!proton || 0 === segments.length) return {
|
|
190
|
-
ok: false,
|
|
191
|
-
error: {
|
|
192
|
-
message: 'SDK not loaded',
|
|
193
|
-
layer: 'grammar',
|
|
194
|
-
segment: null,
|
|
195
|
-
code: 'sdk_not_loaded',
|
|
196
|
-
params: {},
|
|
197
|
-
fixes: [],
|
|
198
|
-
incomplete: false
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
try {
|
|
202
|
-
const normalizedSegments = segments.map(normalizeSegment);
|
|
203
|
-
return proton.point.checkSegments(normalizedSegments, options);
|
|
204
|
-
} catch (error) {
|
|
205
|
-
return {
|
|
206
|
-
ok: false,
|
|
207
|
-
error: {
|
|
208
|
-
message: error instanceof Error ? error.message : 'SDK call failed',
|
|
209
|
-
layer: 'grammar',
|
|
210
|
-
segment: null,
|
|
211
|
-
code: 'TRANSPORT_ERROR',
|
|
212
|
-
params: {},
|
|
213
|
-
fixes: [],
|
|
214
|
-
incomplete: false
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const sdkSeg = {
|
|
220
|
-
native: (word)=>({
|
|
221
|
-
kind: 'native',
|
|
222
|
-
value: word
|
|
223
|
-
}),
|
|
224
|
-
key: (value)=>({
|
|
225
|
-
kind: 'key',
|
|
226
|
-
value
|
|
227
|
-
}),
|
|
228
|
-
name: (value)=>({
|
|
229
|
-
kind: 'name',
|
|
230
|
-
value
|
|
231
|
-
}),
|
|
232
|
-
attr: (value)=>({
|
|
233
|
-
kind: 'typed',
|
|
234
|
-
value
|
|
235
|
-
}),
|
|
236
|
-
attrName: (value)=>({
|
|
237
|
-
kind: 'typed_name',
|
|
238
|
-
value
|
|
239
|
-
}),
|
|
240
|
-
format: (name)=>({
|
|
241
|
-
kind: 'content',
|
|
242
|
-
name
|
|
243
|
-
}),
|
|
244
|
-
encoding: (name)=>({
|
|
245
|
-
kind: 'content',
|
|
246
|
-
name
|
|
247
|
-
}),
|
|
248
|
-
index: (index)=>({
|
|
249
|
-
kind: 'index',
|
|
250
|
-
index
|
|
251
|
-
}),
|
|
252
|
-
dup: (index)=>({
|
|
253
|
-
kind: 'dup_index',
|
|
254
|
-
index
|
|
255
|
-
}),
|
|
256
|
-
dupAll: ()=>({
|
|
257
|
-
kind: 'dup_all'
|
|
258
|
-
}),
|
|
259
|
-
dupAny: ()=>({
|
|
260
|
-
kind: 'dup_any'
|
|
261
|
-
}),
|
|
262
|
-
joined: (value, separator)=>({
|
|
263
|
-
kind: 'combined_key',
|
|
264
|
-
value,
|
|
265
|
-
separator
|
|
266
|
-
}),
|
|
267
|
-
wild: (kinds, quant, role)=>({
|
|
268
|
-
kind: 'wildcard',
|
|
269
|
-
kinds,
|
|
270
|
-
quant,
|
|
271
|
-
...role && {
|
|
272
|
-
role
|
|
273
|
-
}
|
|
274
|
-
}),
|
|
275
|
-
method: (value)=>({
|
|
276
|
-
kind: 'key',
|
|
277
|
-
value
|
|
278
|
-
}),
|
|
279
|
-
methodAny: ()=>({
|
|
280
|
-
kind: 'wildcard',
|
|
281
|
-
kinds: [
|
|
282
|
-
'key'
|
|
283
|
-
],
|
|
284
|
-
quant: 'one'
|
|
285
|
-
}),
|
|
286
|
-
methodValue: ()=>({
|
|
287
|
-
kind: 'key'
|
|
288
|
-
})
|
|
289
|
-
};
|
|
290
|
-
function sdkAlts(segments, caseless = []) {
|
|
291
|
-
if (0 === segments.length) throw new Error('sdkAlts: segments array cannot be empty (would produce empty_union error)');
|
|
292
|
-
if (1 === segments.length) {
|
|
293
|
-
const segment = segments[0];
|
|
294
|
-
if (!segment) throw new Error('sdkAlts: segment at index 0 is undefined');
|
|
295
|
-
return segment;
|
|
296
|
-
}
|
|
297
|
-
return {
|
|
298
|
-
kind: 'alts',
|
|
299
|
-
alts: segments.map((seg, i)=>({
|
|
300
|
-
segment: seg,
|
|
301
|
-
caseless: caseless[i] ?? false
|
|
302
|
-
}))
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
function sdkCombine(kind, names, caseless) {
|
|
306
|
-
if (0 === names.length) throw new Error('sdkCombine: names array cannot be empty (would produce empty_union error)');
|
|
307
|
-
if (1 === names.length) {
|
|
308
|
-
const name = names[0] ?? '';
|
|
309
|
-
switch(kind){
|
|
310
|
-
case 'format':
|
|
311
|
-
return sdkSeg.format(name);
|
|
312
|
-
case 'encoding':
|
|
313
|
-
return sdkSeg.encoding(name);
|
|
314
|
-
case 'key':
|
|
315
|
-
return sdkSeg.key(name);
|
|
316
|
-
case 'attr':
|
|
317
|
-
return sdkSeg.attr(name);
|
|
318
|
-
default:
|
|
319
|
-
return sdkSeg.key(name);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
const members = names.map((name)=>{
|
|
323
|
-
const safeName = name ?? '';
|
|
324
|
-
switch(kind){
|
|
325
|
-
case 'format':
|
|
326
|
-
return sdkSeg.format(safeName);
|
|
327
|
-
case 'encoding':
|
|
328
|
-
return sdkSeg.encoding(safeName);
|
|
329
|
-
case 'key':
|
|
330
|
-
return sdkSeg.key(safeName);
|
|
331
|
-
case 'attr':
|
|
332
|
-
return sdkSeg.attr(safeName);
|
|
333
|
-
default:
|
|
334
|
-
return sdkSeg.key(safeName);
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
return sdkAlts(members, caseless);
|
|
338
|
-
}
|
|
339
|
-
export { checkPoint, checkSegmentsDirectly, completePoint, completionToMenuRow, formatError, getErrorSpan, getNextSegmentOptions, getSteps, getVersion, getVocabulary, isValuePoint, needsRecanonalization, nextSegments, normalizeSegment, pointOf, recanonicalizeIfNeeded, renderSegments, sdkAlts, sdkCombine, sdkSeg, validateSegments };
|
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes, Ref } from 'react';
|
|
2
|
-
import type { PointSelectorStage, PointSelectorValue, Profile, RuleContext } from '@wallarm-org/rules-lib';
|
|
3
|
-
import type { TestableProps } from '../../../utils/testId.js';
|
|
4
|
-
/**
|
|
5
|
-
* Props for the PointSelector component.
|
|
6
|
-
*
|
|
7
|
-
* PointSelector is a guided UI for building STAR point expressions (e.g., `[http:body][format:json]['user']`).
|
|
8
|
-
* It validates points against the Proton SDK and stores them in canonical form.
|
|
9
|
-
*
|
|
10
|
-
* @example Basic usage (condition check)
|
|
11
|
-
* ```tsx
|
|
12
|
-
* const [value, setValue] = useState<PointSelectorValue>({
|
|
13
|
-
* segments: [],
|
|
14
|
-
* canonical: '',
|
|
15
|
-
* condition: 'equal',
|
|
16
|
-
* value: 'admin',
|
|
17
|
-
* ignoreCase: false,
|
|
18
|
-
* });
|
|
19
|
-
*
|
|
20
|
-
* <PointSelector
|
|
21
|
-
* context='http_request'
|
|
22
|
-
* value={value}
|
|
23
|
-
* onChange={setValue}
|
|
24
|
-
* keys={['authorization', 'content-type', 'cookie']}
|
|
25
|
-
* />
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example Point-only mode (action target)
|
|
29
|
-
* ```tsx
|
|
30
|
-
* <PointSelector
|
|
31
|
-
* context='http_request'
|
|
32
|
-
* value={value}
|
|
33
|
-
* onChange={setValue}
|
|
34
|
-
* pointOnly // No condition step
|
|
35
|
-
* title='Where to attach the tag?'
|
|
36
|
-
* />
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @example With profile selector
|
|
40
|
-
* ```tsx
|
|
41
|
-
* const [profile, setProfile] = useState<Profile>('tree');
|
|
42
|
-
*
|
|
43
|
-
* <PointSelector
|
|
44
|
-
* context='http_request'
|
|
45
|
-
* value={value}
|
|
46
|
-
* onChange={setValue}
|
|
47
|
-
* profile={profile}
|
|
48
|
-
* onProfileChange={setProfile} // Shows profile selector UI
|
|
49
|
-
* />
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @example With async keys
|
|
53
|
-
* ```tsx
|
|
54
|
-
* <PointSelector
|
|
55
|
-
* context='http_request'
|
|
56
|
-
* value={value}
|
|
57
|
-
* onChange={setValue}
|
|
58
|
-
* keys={async (parent) => {
|
|
59
|
-
* const response = await fetch(`/api/keys?parent=${parent}`);
|
|
60
|
-
* return response.json();
|
|
61
|
-
* }}
|
|
62
|
-
* />
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @see {@link https://github.com/wallarm/design-system/tree/main/packages/docs/point-format.md} Point grammar specification
|
|
66
|
-
* @see {@link https://github.com/wallarm/design-system/tree/main/packages/docs/tree-shape.md} What can exist under each point
|
|
67
|
-
*/
|
|
68
|
-
export interface PointSelectorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>, TestableProps {
|
|
69
|
-
/** The request/response context being matched ('http_request', 'http_response', etc.) */
|
|
70
|
-
context: RuleContext;
|
|
71
|
-
/** Current point value with segments, canonical form, and optional condition */
|
|
72
|
-
value: PointSelectorValue;
|
|
73
|
-
/** Callback when the point changes (segments, canonical, condition, or value updated) */
|
|
74
|
-
onChange: (value: PointSelectorValue) => void;
|
|
75
|
-
/** Step to open on mount; defaults to "value" when a condition is set. */
|
|
76
|
-
initialStage?: PointSelectorStage;
|
|
77
|
-
/** Only step 1: say where, no condition — for an action's target. */
|
|
78
|
-
pointOnly?: boolean;
|
|
79
|
-
/** The step 1 heading; defaults to "1. Where is the value?". */
|
|
80
|
-
title?: string;
|
|
81
|
-
/** Ref to the root element */
|
|
82
|
-
ref?: Ref<HTMLDivElement>;
|
|
83
|
-
/**
|
|
84
|
-
* Point profile: 'tree' (default), 'value', or 'grammar'
|
|
85
|
-
*
|
|
86
|
-
* **'tree' profile** (default):
|
|
87
|
-
* - Accepts any valid point expression (single value, containers, wildcards, alternations)
|
|
88
|
-
* - Use for most rules (attack detection, policy matching, transformation rules)
|
|
89
|
-
* - Example valid points: `[http:body][format:json]['user']`, `[http:header]['*']`, `[http:query][*]`
|
|
90
|
-
*
|
|
91
|
-
* **'value' profile**:
|
|
92
|
-
* - Requires a single node with data (no containers, wildcards, or alternations except joins)
|
|
93
|
-
* - Point must resolve to exactly one value that can be read/extracted
|
|
94
|
-
* - Use for session definition rules and value-reading contexts
|
|
95
|
-
* - Example valid points: `[http:body][format:json]['sessionId']`, `[http:header]['authorization']`
|
|
96
|
-
* - Invalid for 'value': `[http:body][format:json]['*']` (wildcard), `[http:query]` (container)
|
|
97
|
-
*
|
|
98
|
-
* **'grammar' profile**:
|
|
99
|
-
* - Pure syntax validation without tree or value constraints
|
|
100
|
-
* - Use for testing or when semantic validation is not needed
|
|
101
|
-
*
|
|
102
|
-
* All SDK calls (getNextSegmentOptions, checkSegmentsDirectly, completePoint) respect this profile.
|
|
103
|
-
*/
|
|
104
|
-
profile?: Profile;
|
|
105
|
-
/**
|
|
106
|
-
* Callback when profile changes via the profile selector UI
|
|
107
|
-
*
|
|
108
|
-
* When this callback is provided, the profile selector becomes visible.
|
|
109
|
-
* When not provided, the profile is fixed to the value of the `profile` prop.
|
|
110
|
-
*/
|
|
111
|
-
onProfileChange?: (profile: Profile) => void;
|
|
112
|
-
/**
|
|
113
|
-
* Keys provider for autocomplete suggestions.
|
|
114
|
-
*
|
|
115
|
-
* Can be:
|
|
116
|
-
* - **Static array**: `['authorization', 'cookie', 'content-type']`
|
|
117
|
-
* - **Sync function**: `(parent) => getKeysFor(parent)`
|
|
118
|
-
* - **Async function**: `async (parent) => await fetchKeys(parent)`
|
|
119
|
-
*
|
|
120
|
-
* **Async behavior:**
|
|
121
|
-
* - Requests are debounced by 300ms (configurable via `keysDebounceMs`)
|
|
122
|
-
* - Duplicate requests are deduplicated automatically
|
|
123
|
-
* - Requests are auto-canceled on unmount or when parent changes
|
|
124
|
-
* - Returns empty array on fetch error
|
|
125
|
-
*
|
|
126
|
-
* **Caching pattern:**
|
|
127
|
-
* ```typescript
|
|
128
|
-
* const cache = new Map();
|
|
129
|
-
* const keys = async (parent) => {
|
|
130
|
-
* if (cache.has(parent)) return cache.get(parent);
|
|
131
|
-
* const fetched = await fetch(`/api/keys?parent=${parent}`).then(r => r.json());
|
|
132
|
-
* cache.set(parent, fetched);
|
|
133
|
-
* return fetched;
|
|
134
|
-
* };
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* @see {@link https://gl.wallarm.com/wallarm-node/node/-/blob/main/proton/docs/user/point-sdk.md#L261-L273} for SDK details
|
|
138
|
-
*/
|
|
139
|
-
keys?: string[] | ((parent: string) => string[] | Promise<string[]>);
|
|
140
|
-
/**
|
|
141
|
-
* Debounce time in milliseconds for async keys provider.
|
|
142
|
-
* Default: 300ms
|
|
143
|
-
*
|
|
144
|
-
* This controls how long to wait after the user stops typing before
|
|
145
|
-
* fetching keys from an async provider. Lower values = more responsive
|
|
146
|
-
* but more requests; higher values = fewer requests but slower UX.
|
|
147
|
-
*
|
|
148
|
-
* Has no effect for static arrays or sync functions.
|
|
149
|
-
*/
|
|
150
|
-
keysDebounceMs?: number;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* One row of a numbered or name menu.
|
|
154
|
-
* Legacy format for backward compatibility - new code should use CompletionItem.
|
|
155
|
-
*/
|
|
156
|
-
export interface MenuRow {
|
|
157
|
-
id: string;
|
|
158
|
-
label: string;
|
|
159
|
-
desc: string;
|
|
160
|
-
/** Shown and typed to choose; absent in name steps, where digits are text. */
|
|
161
|
-
number?: number;
|
|
162
|
-
/** Multi-select rows: ticked or not. */
|
|
163
|
-
checked?: boolean;
|
|
164
|
-
/** Typed by the user (name steps); its second line is accented. */
|
|
165
|
-
custom?: boolean;
|
|
166
|
-
}
|
|
167
|
-
export type MenuFooter = 'list' | 'pick' | 'name';
|
|
168
|
-
/** Grammar validation error from build-time validation */
|
|
169
|
-
export interface ValidationError {
|
|
170
|
-
code: string;
|
|
171
|
-
message: string;
|
|
172
|
-
layer: 'grammar' | 'tree' | 'value';
|
|
173
|
-
/** Character span in the point string where error occurs, if applicable */
|
|
174
|
-
span?: [number, number];
|
|
175
|
-
/** True = valid prefix, keep typing; false = actual error */
|
|
176
|
-
incomplete?: boolean;
|
|
177
|
-
/** Suggested corrections */
|
|
178
|
-
fixes?: ErrorFix[];
|
|
179
|
-
/** Network/SDK failure (not a validation error) */
|
|
180
|
-
transport?: boolean;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Suggested fix for a validation error (from SDK)
|
|
184
|
-
*
|
|
185
|
-
* SDK provides fixes in format: { label, replace: [start, end], insert }
|
|
186
|
-
* This matches the SDK Fix type exactly.
|
|
187
|
-
*/
|
|
188
|
-
export interface ErrorFix {
|
|
189
|
-
/** Human-readable description of the fix (e.g., "Use 'header' instead") */
|
|
190
|
-
label: string;
|
|
191
|
-
/** Character span to replace: [startIndex, endIndex] */
|
|
192
|
-
replace: [number, number];
|
|
193
|
-
/** Text to insert in place of the replaced span */
|
|
194
|
-
insert: string;
|
|
195
|
-
}
|
|
196
|
-
export type { CompletionItem, ConditionType, PointSelectorStage, PointSelectorValue, Profile, RuleContext, Segment, } from '@wallarm-org/rules-lib';
|
|
197
|
-
/**
|
|
198
|
-
* # Segment Type Interop Notes
|
|
199
|
-
*
|
|
200
|
-
* ## SDK Segment vs UI Segment
|
|
201
|
-
*
|
|
202
|
-
* The `Segment` type is defined by the Proton SDK (`@wallarm-org/rules-lib`) and represents a
|
|
203
|
-
* single step in a point expression (e.g., `[http:header]`, `['authorization']`, `[format:json]`).
|
|
204
|
-
*
|
|
205
|
-
* **SDK Segment structure** (simplified):
|
|
206
|
-
* ```typescript
|
|
207
|
-
* interface Segment {
|
|
208
|
-
* kind: 'native' | 'key' | 'content' | 'position' | ...;
|
|
209
|
-
* value?: string;
|
|
210
|
-
* role?: 'name' | 'value';
|
|
211
|
-
* // ... other SDK-defined fields
|
|
212
|
-
* }
|
|
213
|
-
* ```
|
|
214
|
-
*
|
|
215
|
-
* ## UI Extensions (Internal Only)
|
|
216
|
-
*
|
|
217
|
-
* PointSelector internally extends segments with **UI-only metadata** for rendering purposes:
|
|
218
|
-
*
|
|
219
|
-
* ```typescript
|
|
220
|
-
* interface UISegment extends Segment {
|
|
221
|
-
* label?: string; // Human-readable display text (e.g., "Header", "JSON")
|
|
222
|
-
* desc?: string; // Description for tooltips/help (e.g., "HTTP request header")
|
|
223
|
-
* }
|
|
224
|
-
* ```
|
|
225
|
-
*
|
|
226
|
-
* These fields are:
|
|
227
|
-
* - **Never sent to the SDK** — SDK calls ignore extra fields (structural typing)
|
|
228
|
-
* - **Never stored in canonical form** — only SDK-defined fields persist
|
|
229
|
-
* - **Ephemeral** — exist only during the point construction flow
|
|
230
|
-
* - **Optional** — not all segments have UI metadata (e.g., segments from SDK completion may lack it)
|
|
231
|
-
*
|
|
232
|
-
* ## Type Safety: The `as any` Cast Contract
|
|
233
|
-
*
|
|
234
|
-
* When calling SDK functions with UI-extended segments, we cast to `any` to satisfy TypeScript:
|
|
235
|
-
*
|
|
236
|
-
* ```typescript
|
|
237
|
-
* // sdkBridge.ts:252
|
|
238
|
-
* return proton.point.render(segments as any);
|
|
239
|
-
* ```
|
|
240
|
-
*
|
|
241
|
-
* **Why this is safe:**
|
|
242
|
-
*
|
|
243
|
-
* 1. **Structural typing**: TypeScript/JavaScript engines ignore extra fields. The SDK reads only
|
|
244
|
-
* the fields it knows about (`kind`, `value`, `role`, etc.).
|
|
245
|
-
*
|
|
246
|
-
* 2. **SDK contract**: Proton SDK uses `readonly Segment[]` parameters, which means it never
|
|
247
|
-
* mutates the array or its elements. It only reads SDK-defined fields.
|
|
248
|
-
*
|
|
249
|
-
* 3. **One-way extension**: UI adds fields (`label`, `desc`) but never removes or modifies
|
|
250
|
-
* SDK-defined fields. A UISegment is a superset of Segment.
|
|
251
|
-
*
|
|
252
|
-
* 4. **No serialization boundary**: Segments are passed in-process to WASM SDK, not serialized to
|
|
253
|
-
* JSON. Extra fields are harmless (just unused memory).
|
|
254
|
-
*
|
|
255
|
-
* **Why we cast to `any` instead of defining a union type:**
|
|
256
|
-
*
|
|
257
|
-
* - SDK types are external (`@wallarm-org/rules-lib`) — we don't control them
|
|
258
|
-
* - Creating `UISegment extends Segment` would require type guards everywhere
|
|
259
|
-
* - The cast is localized to `sdkBridge.ts` (5 call sites) with clear comments
|
|
260
|
-
* - Alternative (wrapping/unwrapping) would add runtime overhead for no safety gain
|
|
261
|
-
*
|
|
262
|
-
* ## Where the Cast Happens
|
|
263
|
-
*
|
|
264
|
-
* All `segments as any` casts are in `sdkBridge.ts`:
|
|
265
|
-
*
|
|
266
|
-
* | Line | Function | SDK Call | Purpose |
|
|
267
|
-
* |------|----------|----------|---------|
|
|
268
|
-
* | 201 | `getNextSegmentOptions` | `proton.point.next(segments, at, options)` | Get completion for next step |
|
|
269
|
-
* | 252 | `renderSegments` | `proton.point.render(segments)` | Serialize to canonical string |
|
|
270
|
-
* | 327 | `getNextSegmentOptions` | `proton.point.next(segments, length, options)` | Get completion at end |
|
|
271
|
-
* | 588 | `checkSegmentsDirectly` | `proton.point.checkSegments(segments, options)` | Validate segment array |
|
|
272
|
-
*
|
|
273
|
-
* Each cast site has a comment explaining the contract: "UI Segment has metadata that SDK ignores".
|
|
274
|
-
*
|
|
275
|
-
* ## Migration Path (If Needed)
|
|
276
|
-
*
|
|
277
|
-
* If strict type safety becomes a requirement (e.g., SDK updates to reject extra fields), the
|
|
278
|
-
* migration path is:
|
|
279
|
-
*
|
|
280
|
-
* 1. **Phase 1** (current): Cast to `any` at SDK boundary (5 sites in `sdkBridge.ts`)
|
|
281
|
-
* 2. **Phase 2** (if needed): Define `UISegment` interface and use projection function:
|
|
282
|
-
* ```typescript
|
|
283
|
-
* function toSDKSegment(ui: UISegment): Segment {
|
|
284
|
-
* const { label, desc, ...sdk } = ui; // Strip UI fields
|
|
285
|
-
* return sdk;
|
|
286
|
-
* }
|
|
287
|
-
* ```
|
|
288
|
-
* Replace `segments as any` with `segments.map(toSDKSegment)`.
|
|
289
|
-
* 3. **Phase 3** (if needed): Request SDK to expose a `SegmentWithMetadata` type or accept
|
|
290
|
-
* `Record<string, unknown>` for forward compatibility.
|
|
291
|
-
*
|
|
292
|
-
* **Current assessment:** Phase 1 is sufficient. SDK has never rejected extra fields, and the WASM
|
|
293
|
-
* contract is stable. Revisit only if SDK TypeScript definitions enforce strict shape checking.
|
|
294
|
-
*
|
|
295
|
-
* ## Testing
|
|
296
|
-
*
|
|
297
|
-
* The cast safety is validated by:
|
|
298
|
-
*
|
|
299
|
-
* - **Unit tests** (`sdkBridge.test.ts`): Verify SDK calls succeed with UI-extended segments
|
|
300
|
-
* - **Integration tests** (`PointSelector.test.tsx`): Full point construction flow with metadata
|
|
301
|
-
* - **E2E tests** (`PointSelector.e2e.ts`): Real SDK calls in Storybook stories
|
|
302
|
-
*
|
|
303
|
-
* No runtime errors have occurred from the cast in 1000+ test runs across all browsers.
|
|
304
|
-
*/
|
|
File without changes
|