Skip to content

Commit e4000fb

Browse files
MEPalmagregfurman
authored andcommitted
Add Step Functions support for Variables and JSONata features (#11906)
Co-authored-by: Greg Furman <31275503+gregfurman@users.noreply.github.com>
1 parent bdcb1dc commit e4000fb

File tree

303 files changed

+44180
-4571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

303 files changed

+44180
-4571
lines changed

localstack-core/localstack/aws/api/stepfunctions/__init__.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import datetime
22
from enum import StrEnum
3-
from typing import List, Optional, TypedDict
3+
from typing import Dict, List, Optional, TypedDict
44

55
from localstack.aws.api import RequestContext, ServiceException, ServiceRequest, handler
66

@@ -12,6 +12,7 @@
1212
Definition = str
1313
Enabled = bool
1414
ErrorMessage = str
15+
EvaluationFailureLocation = str
1516
HTTPBody = str
1617
HTTPHeaders = str
1718
HTTPMethod = str
@@ -52,6 +53,8 @@
5253
ValidateStateMachineDefinitionMaxResult = int
5354
ValidateStateMachineDefinitionMessage = str
5455
ValidateStateMachineDefinitionTruncated = bool
56+
VariableName = str
57+
VariableValue = str
5558
VersionDescription = str
5659
VersionWeight = int
5760
includedDetails = bool
@@ -145,6 +148,7 @@ class HistoryEventType(StrEnum):
145148
MapRunSucceeded = "MapRunSucceeded"
146149
ExecutionRedriven = "ExecutionRedriven"
147150
MapRunRedriven = "MapRunRedriven"
151+
EvaluationFailed = "EvaluationFailed"
148152

149153

150154
class IncludedData(StrEnum):
@@ -473,6 +477,13 @@ class ActivityTimedOutEventDetails(TypedDict, total=False):
473477
cause: Optional[SensitiveCause]
474478

475479

480+
AssignedVariables = Dict[VariableName, VariableValue]
481+
482+
483+
class AssignedVariablesDetails(TypedDict, total=False):
484+
truncated: Optional[truncated]
485+
486+
476487
BilledDuration = int
477488
BilledMemoryUsed = int
478489

@@ -721,6 +732,10 @@ class DescribeStateMachineForExecutionInput(ServiceRequest):
721732
includedData: Optional[IncludedData]
722733

723734

735+
VariableNameList = List[VariableName]
736+
VariableReferences = Dict[StateName, VariableNameList]
737+
738+
724739
class DescribeStateMachineForExecutionOutput(TypedDict, total=False):
725740
stateMachineArn: Arn
726741
name: Name
@@ -733,6 +748,7 @@ class DescribeStateMachineForExecutionOutput(TypedDict, total=False):
733748
label: Optional[MapRunLabel]
734749
revisionId: Optional[RevisionId]
735750
encryptionConfiguration: Optional[EncryptionConfiguration]
751+
variableReferences: Optional[VariableReferences]
736752

737753

738754
class DescribeStateMachineInput(ServiceRequest):
@@ -756,9 +772,19 @@ class DescribeStateMachineInput(ServiceRequest):
756772
"revisionId": Optional[RevisionId],
757773
"description": Optional[VersionDescription],
758774
"encryptionConfiguration": Optional[EncryptionConfiguration],
775+
"variableReferences": Optional[VariableReferences],
759776
},
760777
total=False,
761778
)
779+
780+
781+
class EvaluationFailedEventDetails(TypedDict, total=False):
782+
error: Optional[SensitiveError]
783+
cause: Optional[SensitiveCause]
784+
location: Optional[EvaluationFailureLocation]
785+
state: StateName
786+
787+
762788
EventId = int
763789

764790

@@ -848,6 +874,8 @@ class StateExitedEventDetails(TypedDict, total=False):
848874
name: Name
849875
output: Optional[SensitiveData]
850876
outputDetails: Optional[HistoryEventExecutionDataDetails]
877+
assignedVariables: Optional[AssignedVariables]
878+
assignedVariablesDetails: Optional[AssignedVariablesDetails]
851879

852880

853881
class StateEnteredEventDetails(TypedDict, total=False):
@@ -1004,6 +1032,7 @@ class TaskFailedEventDetails(TypedDict, total=False):
10041032
"mapRunStartedEventDetails": Optional[MapRunStartedEventDetails],
10051033
"mapRunFailedEventDetails": Optional[MapRunFailedEventDetails],
10061034
"mapRunRedrivenEventDetails": Optional[MapRunRedrivenEventDetails],
1035+
"evaluationFailedEventDetails": Optional[EvaluationFailedEventDetails],
10071036
},
10081037
total=False,
10091038
)
@@ -1033,13 +1062,15 @@ class InspectionDataRequest(TypedDict, total=False):
10331062

10341063
class InspectionData(TypedDict, total=False):
10351064
input: Optional[SensitiveData]
1065+
afterArguments: Optional[SensitiveData]
10361066
afterInputPath: Optional[SensitiveData]
10371067
afterParameters: Optional[SensitiveData]
10381068
result: Optional[SensitiveData]
10391069
afterResultSelector: Optional[SensitiveData]
10401070
afterResultPath: Optional[SensitiveData]
10411071
request: Optional[InspectionDataRequest]
10421072
response: Optional[InspectionDataResponse]
1073+
variables: Optional[SensitiveData]
10431074

10441075

10451076
class ListActivitiesInput(ServiceRequest):
@@ -1265,10 +1296,11 @@ class TagResourceOutput(TypedDict, total=False):
12651296

12661297
class TestStateInput(ServiceRequest):
12671298
definition: Definition
1268-
roleArn: Arn
1299+
roleArn: Optional[Arn]
12691300
input: Optional[SensitiveData]
12701301
inspectionLevel: Optional[InspectionLevel]
12711302
revealSecrets: Optional[RevealSecrets]
1303+
variables: Optional[SensitiveData]
12721304

12731305

12741306
class TestStateOutput(TypedDict, total=False):
@@ -1640,10 +1672,11 @@ def test_state(
16401672
self,
16411673
context: RequestContext,
16421674
definition: Definition,
1643-
role_arn: Arn,
1675+
role_arn: Arn = None,
16441676
input: SensitiveData = None,
16451677
inspection_level: InspectionLevel = None,
16461678
reveal_secrets: RevealSecrets = None,
1679+
variables: SensitiveData = None,
16471680
**kwargs,
16481681
) -> TestStateOutput:
16491682
raise NotImplementedError

localstack-core/localstack/dns/server.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
from socket import AddressFamily
1313
from typing import Iterable, Literal, Tuple
1414

15+
import dns.flags
16+
import dns.message
17+
import dns.query
1518
import psutil
1619
from cachetools import TTLCache, cached
20+
from dns.exception import Timeout
1721
from dnslib import (
1822
AAAA,
1923
CNAME,
@@ -35,11 +39,6 @@
3539
from dnslib.server import DNSHandler, DNSServer
3640
from psutil._common import snicaddr
3741

38-
import dns.flags
39-
import dns.message
40-
import dns.query
41-
from dns.exception import Timeout
42-
4342
# Note: avoid adding additional imports here, to avoid import issues when running the CLI
4443
from localstack import config
4544
from localstack.constants import LOCALHOST_HOSTNAME, LOCALHOST_IP

localstack-core/localstack/services/stepfunctions/asl/antlr/ASLIntrinsicLexer.g4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ CONTEXT_PATH_STRING: DOLLAR DOLLAR JSON_PATH_BODY;
88

99
JSON_PATH_STRING: DOLLAR JSON_PATH_BODY;
1010

11+
STRING_VARIABLE: DOLLAR IDENTIFIER JSON_PATH_BODY;
12+
13+
// TODO: JSONPath body composition may need strenghening to support features such as filtering conditions.
1114
fragment JSON_PATH_BODY: JSON_PATH_BRACK? (DOT IDENTIFIER? JSON_PATH_BRACK?)*;
1215

1316
fragment JSON_PATH_BRACK: '[' (JSON_PATH_BRACK | ~[\]])* ']';

localstack-core/localstack/services/stepfunctions/asl/antlr/ASLIntrinsicParser.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ func_arg:
4242
| (TRUE | FALSE) # func_arg_bool
4343
| CONTEXT_PATH_STRING # func_arg_context_path
4444
| JSON_PATH_STRING # func_arg_json_path
45+
| STRING_VARIABLE # func_arg_var
4546
| states_func_decl # func_arg_func_decl
4647
;

localstack-core/localstack/services/stepfunctions/asl/antlr/ASLLexer.g4

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ MAP: '"Map"';
5555

5656
CHOICES: '"Choices"';
5757

58+
CONDITION: '"Condition"';
59+
5860
VARIABLE: '"Variable"';
5961

6062
DEFAULT: '"Default"';
@@ -189,6 +191,8 @@ INPUTPATH: '"InputPath"';
189191

190192
OUTPUTPATH: '"OutputPath"';
191193

194+
ITEMS: '"Items"';
195+
192196
ITEMSPATH: '"ItemsPath"';
193197

194198
RESULTPATH: '"ResultPath"';
@@ -197,6 +201,8 @@ RESULT: '"Result"';
197201

198202
PARAMETERS: '"Parameters"';
199203

204+
CREDENTIALS: '"Credentials"';
205+
200206
RESULTSELECTOR: '"ResultSelector"';
201207

202208
ITEMREADER: '"ItemReader"';
@@ -259,6 +265,22 @@ NONE: '"NONE"';
259265
// Catch.
260266
CATCH: '"Catch"';
261267

268+
// Query Language.
269+
QUERYLANGUAGE: '"QueryLanguage"';
270+
271+
JSONPATH: '"JSONPath"';
272+
273+
JSONATA: '"JSONata"';
274+
275+
// Assign.
276+
ASSIGN: '"Assign"';
277+
278+
// Output.
279+
OUTPUT: '"Output"';
280+
281+
// Arguments.
282+
ARGUMENTS: '"Arguments"';
283+
262284
// ErrorNames
263285
ERRORNAMEStatesALL: '"States.ALL"';
264286

@@ -288,6 +310,8 @@ ERRORNAMEStatesItemReaderFailed: '"States.ItemReaderFailed"';
288310

289311
ERRORNAMEStatesResultWriterFailed: '"States.ResultWriterFailed"';
290312

313+
ERRORNAMEStatesQueryEvaluationError: '"States.QueryEvaluationError"';
314+
291315
// Read-only:
292316
ERRORNAMEStatesRuntime: '"States.Runtime"';
293317

@@ -296,7 +320,13 @@ STRINGDOLLAR: '"' (ESC | SAFECODEPOINT)* '.$"';
296320

297321
STRINGPATHCONTEXTOBJ: '"$$' (ESC | SAFECODEPOINT)* '"';
298322

299-
STRINGPATH: '"$' (ESC | SAFECODEPOINT)* '"';
323+
STRINGPATH: '"$"' | '"$' ('.' | '[') (ESC | SAFECODEPOINT)* '"';
324+
325+
STRINGVAR: '"$' [a-zA-Z_] (ESC | SAFECODEPOINT)* '"';
326+
327+
STRINGINTRINSICFUNC: '"States.' (ESC | SAFECODEPOINT)+ '(' (ESC | SAFECODEPOINT)* ')"';
328+
329+
STRINGJSONATA: LJSONATA (ESC | SAFECODEPOINT)* RJSONATA;
300330

301331
STRING: '"' (ESC | SAFECODEPOINT)* '"';
302332

@@ -308,6 +338,10 @@ fragment HEX: [0-9a-fA-F];
308338
309339
fragment SAFECODEPOINT: ~ ["\\\u0000-\u001F];
310340

341+
fragment LJSONATA: '"{%';
342+
343+
fragment RJSONATA: '%}"';
344+
311345
// Numbers.
312346
INT: '0' | [1-9] [0-9]*;
313347

0 commit comments

Comments
 (0)