aura-lang 0.4.0

Aura configuration language: deterministic, capability-secured, schema-validated configs — embeddable library + the `aura` CLI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# Aura stdlib surface — the single source of truth for editor completion/hover.
#
# The language server EVALUATES this file with aura-lang at startup (dogfooding:
# Aura configuring its own tooling) to build its completion database. A test
# checks these method names against the real method registry so the two cannot
# drift. Grouped by receiver type; `builtins` are global functions.

String:
  upper:
    params:  []
    returns: "String"
    doc:     "Uppercase every character."
  end
  lower:
    params:  []
    returns: "String"
    doc:     "Lowercase every character."
  end
  len:
    params:  []
    returns: "Int"
    doc:     "Number of characters."
  end
  trim:
    params:  []
    returns: "String"
    doc:     "Remove leading and trailing whitespace."
  end
  split:
    params:  ["sep"]
    returns: "List"
    doc:     "Split on a non-empty separator into a list of strings."
  end
  replace:
    params:  ["from", "to"]
    returns: "String"
    doc:     "Replace every occurrence of a substring."
  end
  starts_with:
    params:  ["prefix"]
    returns: "Bool"
    doc:     "True if the string begins with the prefix."
  end
  ends_with:
    params:  ["suffix"]
    returns: "Bool"
    doc:     "True if the string ends with the suffix."
  end
  contains:
    params:  ["substr"]
    returns: "Bool"
    doc:     "True if the substring occurs anywhere."
  end
  slice:
    params:  ["start", "end"]
    returns: "String"
    doc:     "Substring by character index; end exclusive, indices clamped."
  end
  to_int:
    params:  []
    returns: "Int"
    doc:     "Parse an integer (E0314 on failure)."
  end
  to_float:
    params:  []
    returns: "Float"
    doc:     "Parse a float (E0314 on failure)."
  end
  to_str:
    params:  []
    returns: "String"
    doc:     "The string itself (universal to_str)."
  end
  parse_json:
    params:  []
    returns: "Object"
    doc:     "Parse a JSON document into a value."
  end
  parse_yaml:
    params:  []
    returns: "Object"
    doc:     "Parse a YAML document into a value."
  end
  parse_toml:
    params:  []
    returns: "Object"
    doc:     "Parse a TOML document into a value."
  end
  parse_duration:
    params:  []
    returns: "Int"
    doc:     "Duration string (d/h/m/s) to seconds; E0319 on error."
  end
  parse_datetime:
    params:  []
    returns: "Int"
    doc:     "RFC3339 timestamp to epoch seconds UTC; E0320 on error."
  end
  sha256:
    params:  []
    returns: "String"
    doc:     "SHA-256 digest as lowercase hex (config checksums)."
  end
  base64:
    params:  []
    returns: "String"
    doc:     "Standard base64 with padding (e.g. Kubernetes Secret data)."
  end
  base64_decode:
    params:  []
    returns: "String"
    doc:     "Decode standard base64 to a String; E0321 if invalid."
  end
end

Int:
  abs:
    params:  []
    returns: "Int"
    doc:     "Absolute value."
  end
  to_str:
    params:  []
    returns: "String"
    doc:     "Decimal string form."
  end
  to_float:
    params:  []
    returns: "Float"
    doc:     "Widen to Float. There is no Float -> Int: narrowing would have to round."
  end
  format_duration:
    params:  []
    returns: "String"
    doc:     "Seconds to a duration string (d/h/m/s)."
  end
  format_datetime:
    params:  []
    returns: "String"
    doc:     "Epoch seconds to an RFC3339 UTC timestamp."
  end
end

Float:
  abs:
    params:  []
    returns: "Float"
    doc:     "Absolute value."
  end
  round:
    params:  ["digits"]
    returns: "Float"
    doc:     "Nearest Float with that many decimal places (0 to 15); exact ties go to even."
  end
  to_str:
    params:  []
    returns: "String"
    doc:     "Decimal string form."
  end
end

Bool:
  to_str:
    params:  []
    returns: "String"
    doc:     "\"true\" or \"false\"."
  end
end

List:
  len:
    params:  []
    returns: "Int"
    doc:     "Number of elements."
  end
  to_object:
    params:  []
    returns: "Object"
    doc:     "Build an Object from { key, value } pairs; a duplicate key is E0323."
  end
  reduce:
    params:  ["init", "fn"]
    returns: "Any"
    doc:     "Left fold: reduce(init) (acc, elem) -> ... end. The init is required."
  end
  any:
    params:  ["fn"]
    returns: "Bool"
    doc:     "True if the predicate holds for some element; false for an empty list."
  end
  all:
    params:  ["fn"]
    returns: "Bool"
    doc:     "True if the predicate holds for every element; true for an empty list."
  end
  find:
    params:  ["default", "fn"]
    returns: "Any"
    doc:     "First element matching the predicate, or the default."
  end
  index_of:
    params:  ["value", "default"]
    returns: "Int"
    doc:     "Index of the first equal element, or the default (which must be an Int)."
  end
  first:
    params:  []
    returns: "Any"
    doc:     "First element (E0317 if empty)."
  end
  last:
    params:  []
    returns: "Any"
    doc:     "Last element (E0317 if empty)."
  end
  get:
    params:  ["index"]
    returns: "Any"
    doc:     "Element at an Int index, or a default via .get(i, default)."
  end
  contains:
    params:  ["item"]
    returns: "Bool"
    doc:     "True if the element is present."
  end
  compact:
    params:  []
    returns: "List"
    doc:     "Drop null elements."
  end
  uniq:
    params:  []
    returns: "List"
    doc:     "Remove duplicates, keeping first occurrence."
  end
  map:
    params:  ["fn"]
    returns: "List"
    doc:     "Apply (element, index) -> value to each element."
  end
  filter:
    params:  ["fn"]
    returns: "List"
    doc:     "Keep elements where (element, index) -> Bool is true."
  end
  join:
    params:  ["sep"]
    returns: "String"
    doc:     "Join scalar elements with a separator."
  end
  sort:
    params:  []
    returns: "List"
    doc:     "Ascending sort of mutually-comparable scalars."
  end
  reverse:
    params:  []
    returns: "List"
    doc:     "Elements in reverse order."
  end
  sum:
    params:  []
    returns: "Int"
    doc:     "Sum of numbers (Float if any Float)."
  end
  min:
    params:  []
    returns: "Any"
    doc:     "Smallest element (E0317 if empty)."
  end
  max:
    params:  []
    returns: "Any"
    doc:     "Largest element (E0317 if empty)."
  end
  flatten:
    params:  []
    returns: "List"
    doc:     "Spread one level of nested lists."
  end
  slice:
    params:  ["start", "end"]
    returns: "List"
    doc:     "Half-open sub-list; indices are clamped."
  end
  to_json:
    params:  []
    returns: "String"
    doc:     "Serialize to a compact JSON string, for embedding."
  end
  to_json_pretty:
    params:  []
    returns: "String"
    doc:     "Serialize to indented JSON, for a file a person reads."
  end
  to_yaml:
    params:  []
    returns: "String"
    doc:     "Serialize to a compact YAML string (flow style), for embedding."
  end
  to_yaml_pretty:
    params:  []
    returns: "String"
    doc:     "Serialize to block-style YAML, for a file a person reads."
  end
  to_toml:
    params:  []
    returns: "String"
    doc:     "Serialize to TOML with arrays on one line, for embedding."
  end
  to_toml_pretty:
    params:  []
    returns: "String"
    doc:     "Serialize to TOML with one array element per line."
  end
end

Object:
  len:
    params:  []
    returns: "Int"
    doc:     "Number of keys."
  end
  keys:
    params:  []
    returns: "List"
    doc:     "Keys in declaration order."
  end
  values:
    params:  []
    returns: "List"
    doc:     "Values in declaration order."
  end
  contains:
    params:  ["key"]
    returns: "Bool"
    doc:     "True if the key is present."
  end
  get:
    params:  ["key", "default"]
    returns: "Any"
    doc:     "Value for a key, or a default if absent."
  end
  entries:
    params:  []
    returns: "List"
    doc:     "Key/value pairs as { key, value } objects, in declaration order."
  end
  merge:
    params:  ["other"]
    returns: "Object"
    doc:     "Shallow merge; the argument wins on key conflicts."
  end
  to_json:
    params:  []
    returns: "String"
    doc:     "Serialize to a compact JSON string, for embedding."
  end
  to_json_pretty:
    params:  []
    returns: "String"
    doc:     "Serialize to indented JSON, for a file a person reads."
  end
  to_yaml:
    params:  []
    returns: "String"
    doc:     "Serialize to a compact YAML string (flow style), for embedding."
  end
  to_yaml_pretty:
    params:  []
    returns: "String"
    doc:     "Serialize to block-style YAML, for a file a person reads."
  end
  to_toml:
    params:  []
    returns: "String"
    doc:     "Serialize to TOML with arrays on one line, for embedding."
  end
  to_toml_pretty:
    params:  []
    returns: "String"
    doc:     "Serialize to TOML with one array element per line."
  end
end

builtins:
  range:
    params:  ["n"]
    returns: "List"
    doc:     "The list [0, 1, ..., n-1]."
  end
  env:
    params:  ["name", "default"]
    returns: "String"
    doc:     "Environment variable value or a default (needs --allow-env)."
  end
  read_file:
    params:  ["path"]
    returns: "String"
    doc:     "File contents as a string (needs --allow-read)."
  end
  fail:
    params:  ["message"]
    returns: "Any"
    doc:     "Abort evaluation with a message (E0530)."
  end
end