Skip to content

Commit 7712160

Browse files
committed
updated keywords based on OPA spec
1 parent 34e6663 commit 7712160

File tree

1 file changed

+189
-46
lines changed
  • packages/components/src/modifiers/hds-code-editor/languages

1 file changed

+189
-46
lines changed

packages/components/src/modifiers/hds-code-editor/languages/rego.ts

+189-46
Original file line numberDiff line numberDiff line change
@@ -22,72 +22,215 @@ function wordRegexp(words: string[]): RegExp {
2222

2323
// keywords
2424
const regoKeywords = [
25-
'package',
26-
'import',
25+
'as',
26+
'contains',
27+
'data',
2728
'default',
28-
'with',
2929
'else',
30-
'some',
30+
'every',
31+
'false',
32+
'if',
33+
'in',
34+
'import',
35+
'input',
36+
'package',
3137
'not',
32-
'as',
38+
'null',
39+
'some',
40+
'true',
41+
'with',
3342
];
3443

3544
// built-ins / constants
3645
const regoBuiltins = [
37-
// constants and implicit variables
38-
'true',
39-
'false',
40-
'null',
41-
'data',
42-
// general built-ins:
43-
'all',
44-
'any',
45-
'append',
46-
'base64.decode',
47-
'base64.encode',
48-
'base64url.decode',
49-
'base64url.encode',
46+
// numbers
47+
'abs',
5048
'ceil',
49+
'floor',
50+
'numbers.range',
51+
'numbers.range_step',
52+
'rand.intn',
53+
'round',
54+
// aggregates
55+
'count',
56+
'max',
57+
'min',
58+
'product',
59+
'sort',
60+
'sum',
61+
// arrays
62+
'array.concat',
63+
'array.reverse',
64+
'array.slice',
65+
// sets
66+
'intersection',
67+
'union',
68+
// objects
69+
'json.filter',
70+
'json.match_scema',
71+
'json.patch',
72+
'json.remove',
73+
'json.verify_schema',
74+
'object.filter',
75+
'object.get',
76+
'object.keys',
77+
'object.remove',
78+
'object.subset',
79+
'object.union',
80+
'object.union_n',
81+
// strings
5182
'concat',
52-
'concat_array',
5383
'contains',
54-
'count',
55-
'decodejson',
56-
'encodejson',
5784
'endswith',
58-
'flatten',
59-
'floor',
60-
'indexof',
61-
'is_number',
62-
'is_string',
63-
'keys',
85+
'format_int',
86+
'indexof_n',
6487
'lower',
65-
'max',
66-
'merge',
67-
'min',
68-
'regex.match',
69-
'regex.find',
70-
'regex.split',
71-
'reverse',
72-
'round',
73-
'set',
88+
'replace',
7489
'split',
7590
'sprintf',
7691
'startswith',
77-
'substr',
78-
'sum',
79-
'trace',
80-
'type_name',
81-
'union',
92+
'strings.any_prefix_match',
93+
'strings.count',
94+
'strings.render_template',
95+
'strings.replace_n',
96+
'strings.reverse',
97+
'substring',
98+
'trim',
99+
'trim_left',
100+
'trim_prefix',
101+
'trim_right',
102+
'trim_space',
103+
'trim_suffix',
82104
'upper',
83-
'uuid',
84-
// namespaced built-ins:
105+
// regex
106+
'regex.find_all_string_submatch_n',
107+
'regex.find_n',
108+
'regex.globs_match',
109+
'regex.is_valid',
110+
'regex.match',
111+
'regex.replace',
112+
'regex.split',
113+
'regex.template_match',
114+
// glob
115+
'glob.match',
116+
'glob.quote_meta',
117+
// bitwise
118+
'bits.and',
119+
'bits.lsh',
120+
'bits.negate',
121+
'bits.or',
122+
'bits.rsh',
123+
'bits.xor',
124+
// conversions
125+
'to_number',
126+
// units
127+
'units.parse',
128+
'units.parse_bytes',
129+
// types
130+
'is_array',
131+
'is_boolean',
132+
'is_null',
133+
'is_number',
134+
'is_object',
135+
'is_set',
136+
'is_string',
137+
'type_name',
138+
// encoding
139+
'base64.decode',
140+
'base64.encode',
141+
'base64.is_valid',
142+
'base64url.decode',
143+
'base64url.encode',
144+
'base64url.encode_no_pad',
145+
'hex.decode',
146+
'hex.encode',
147+
'json.is_valid',
85148
'json.marshal',
149+
'json.marshal_with_options',
86150
'json.unmarshal',
151+
'urlquery.decode',
152+
'urlquery.decode_object',
153+
'urlquery.encode',
154+
'urlquery.encode_object',
155+
'yaml.is_valid',
156+
'yaml.marshal',
157+
'yaml.unmarshal',
158+
// token signing
159+
'io.jwt.encode_sign',
160+
'io.jwt.encode_sign_raw',
161+
// token verification
162+
'io.jwt.decode',
163+
'io.jwt.decode_verify',
164+
'io.jwt.verify_es256',
165+
'io.jwt.verify_es384',
166+
'io.jwt.verify_es512',
167+
'io.jwt.verify_hs256',
168+
'io.jwt.verify_hs384',
169+
'io.jwt.verify_hs512',
170+
'io.jwt.verify_ps384',
171+
'io.jwt.verify_ps512',
172+
'io.jwt.verify_rs256',
173+
'io.jwt.verify_rs384',
174+
'io.jwt.verify_rs512',
175+
// time
176+
'time.add_date',
177+
'time.clock',
178+
'time.date',
179+
'time.diff',
180+
'time.format',
181+
'time.now_ns',
182+
'time.parse_duration_ns',
183+
'time.parse_ns',
184+
'time.parse_rfc3339_ns',
185+
'time.weekday',
186+
// crypto
187+
'crypto.hmac.equal',
188+
'crypto.hmac.md5',
189+
'crypto.hmac.sha1',
190+
'crypto.hmac.sha256',
191+
'crypto.hmac.sha512',
192+
'crypto.md5',
193+
'crypto.parse_private_keys',
194+
'crypto.sha1',
195+
'crypto.sha256',
196+
'crypto.x509.parse_and_verify_certificates',
197+
'crypto.x509.parse_and_verify_certificates_with_options',
198+
'crypto.x509.parse_certificates',
199+
'crypto.x509.parse_keypair',
200+
'crypto.x509.parse_rsa_private_key',
201+
// graphs
202+
'graph.reachable',
203+
'graph.reachable_paths',
204+
'walk',
205+
// graphql
206+
'graphql.is_valid',
207+
'graphql.parse',
208+
'graphql.parse_and_verify',
209+
'graphql.parse_query',
210+
'graphql.parse_schema',
211+
'graphql.parse_schema_is_valid',
212+
// http
87213
'http.send',
88-
'time.now',
89-
'time.parse_rfc3339',
214+
// aws
215+
'providers.aws.sign_req',
216+
// net
90217
'net.cidr_contains',
218+
'net.cidr_contains_matches',
219+
'net.cidr_expand',
220+
'net.cidr_intersects',
221+
'net.cidr_is_valid',
222+
'net.cidr_merge',
223+
'net.lookup_ip_addr',
224+
// uuid
225+
'uuid.parse',
226+
'uuid.rfc4122',
227+
// semantic versions
228+
'semver.compare',
229+
'semver.is_valid',
230+
// rego
231+
'rego.metadata.chain',
232+
'rego.metadata.rule',
233+
'rego.metadata.parse_module',
91234
];
92235

93236
const keywords = wordRegexp(regoKeywords);

0 commit comments

Comments
 (0)