forked from ehmicky/Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpowertools_lambda_jmespath.node.txt
More file actions
74 lines (56 loc) · 4.22 KB
/
powertools_lambda_jmespath.node.txt
File metadata and controls
74 lines (56 loc) · 4.22 KB
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
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ POWERTOOLS_LAMBDA_JMESPATH ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
VERSION ==> #See AWS Lambda docs
#Package '@aws-lambda-powertools/jmespath'
┌───────────┐
│ QUERY │
└───────────┘
'QUERY' #In JMESPath (see its doc)
SERVICE-SPECIFIC QUERY ==> #Multiple AWS SERVICE-specific QUERYs are exported
#Documented in their respective docs
#Requires new PowertoolsFunctions() (i.e. extractDataFromEnvelope())
#Note: apart for this, the rest of this package is not AWS-specific
#I.e. it is just a normal JMESPath client
┌────────────┐
│ SEARCH │
└────────────┘
search(VAL, 'QUERY'[, OPTS])->VAL2#Performs JMESPath
#'QUERY' parsing is memoized
# - cache max size 128
# - randomly purged when reaching max size
extractDataFromEnvelope(...) #Same except for OPTS.customFunctions (see below)
#Imported from @aws-lambda-powertools/jmespath/envelopes
┌───────────────────────┐
│ BUILTIN FUNCTIONS │
└───────────────────────┘
OPTS.customFunctions #CUSTOM_FUNCS. List of available JMESPath FUNCs
new Functions() #CUSTOM_FUNCS with all JMESPath builtin FUNCs
#Def value of OPTS.customFunctions with search()
┌──────────────────────────┐
│ ADDITIONAL FUNCTIONS │
└──────────────────────────┘
new PowertoolsFunctions() #CUSTOM_FUNCS. Like new Functions() but adds following additional JMESPath FUNCs
#Def value of OPTS.customFunctions with extractDataFromEnvelope()
#Imported from @aws-lambda-powertools/jmespath/functions
powertools_json('JSON')->VAL #JSON.parse()
powertools_base64('BASE64')->VAL #Base64 decode
powertools_base64_gzip
('BASE64_GZIPPED')->VAL #Base64 decode then gzip decompress
┌──────────────────────┐
│ CUSTOM FUNCTIONS │
└──────────────────────┘
class CLASS #CUSTOM_FUNCS. Add custom JMESPath FUNCs
extends [Powertools]Functions { #FUNC name must be camelCase, which is converted to snake_case
public funcFUNC(...)->VAL #ARG can be &EXPR
... # - an EXPRESSION is passed as argument
} # - with EXPRESSION.visit(VAL)->VAL2 applying it
class ... {
@Functions.signature(SPEC)
public funcFUNC(...)->VAL
...
} #Declares ARG types, to throw ERROR on invalid ARG
SPEC.argumentsSpecs #['TYPE',...]_ARR of ARGs
#['TYPE',...] is each possible TYPE of each ARG
#'TYPE' can be: 'any', 'string', 'number', 'object', 'array[-TYPE]', 'expression'
SPEC.variadic #BOOL (def: false). Whether ARGs are variadic