localstack-core 4.10.1.dev42__py3-none-any.whl → 4.11.2.dev14__py3-none-any.whl
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.
- localstack/aws/api/apigateway/__init__.py +42 -0
- localstack/aws/api/cloudformation/__init__.py +161 -0
- localstack/aws/api/ec2/__init__.py +1165 -12
- localstack/aws/api/iam/__init__.py +227 -0
- localstack/aws/api/kms/__init__.py +1 -0
- localstack/aws/api/lambda_/__init__.py +418 -66
- localstack/aws/api/logs/__init__.py +312 -0
- localstack/aws/api/opensearch/__init__.py +89 -0
- localstack/aws/api/redshift/__init__.py +69 -0
- localstack/aws/api/resourcegroupstaggingapi/__init__.py +36 -0
- localstack/aws/api/route53/__init__.py +42 -0
- localstack/aws/api/route53resolver/__init__.py +1 -0
- localstack/aws/api/s3/__init__.py +62 -0
- localstack/aws/api/secretsmanager/__init__.py +28 -23
- localstack/aws/api/stepfunctions/__init__.py +52 -10
- localstack/aws/api/sts/__init__.py +52 -0
- localstack/aws/handlers/logging.py +8 -4
- localstack/aws/handlers/service.py +11 -2
- localstack/aws/protocol/serializer.py +1 -1
- localstack/deprecations.py +0 -6
- localstack/services/acm/provider.py +4 -0
- localstack/services/apigateway/legacy/provider.py +28 -15
- localstack/services/cloudformation/engine/template_preparer.py +6 -2
- localstack/services/cloudformation/engine/v2/change_set_model_preproc.py +12 -0
- localstack/services/cloudwatch/provider.py +10 -3
- localstack/services/cloudwatch/provider_v2.py +6 -3
- localstack/services/configservice/provider.py +5 -1
- localstack/services/dynamodb/provider.py +1 -0
- localstack/services/dynamodb/v2/provider.py +1 -0
- localstack/services/dynamodbstreams/provider.py +6 -0
- localstack/services/dynamodbstreams/v2/provider.py +6 -0
- localstack/services/ec2/provider.py +6 -0
- localstack/services/es/provider.py +6 -0
- localstack/services/events/provider.py +4 -0
- localstack/services/events/v1/provider.py +9 -0
- localstack/services/firehose/provider.py +5 -0
- localstack/services/iam/provider.py +4 -0
- localstack/services/kms/models.py +10 -20
- localstack/services/kms/provider.py +4 -0
- localstack/services/lambda_/api_utils.py +37 -20
- localstack/services/lambda_/event_source_mapping/pollers/stream_poller.py +1 -1
- localstack/services/lambda_/invocation/assignment.py +4 -1
- localstack/services/lambda_/invocation/execution_environment.py +21 -2
- localstack/services/lambda_/invocation/lambda_models.py +27 -2
- localstack/services/lambda_/invocation/lambda_service.py +51 -3
- localstack/services/lambda_/invocation/models.py +9 -1
- localstack/services/lambda_/invocation/version_manager.py +18 -3
- localstack/services/lambda_/provider.py +239 -95
- localstack/services/lambda_/resource_providers/aws_lambda_function.py +33 -1
- localstack/services/lambda_/runtimes.py +3 -1
- localstack/services/logs/provider.py +9 -0
- localstack/services/opensearch/provider.py +53 -3
- localstack/services/resource_groups/provider.py +5 -1
- localstack/services/resourcegroupstaggingapi/provider.py +6 -1
- localstack/services/s3/provider.py +28 -15
- localstack/services/s3/utils.py +35 -14
- localstack/services/s3control/provider.py +101 -2
- localstack/services/s3control/validation.py +50 -0
- localstack/services/sns/constants.py +3 -1
- localstack/services/sns/publisher.py +15 -6
- localstack/services/sns/v2/models.py +6 -0
- localstack/services/sns/v2/provider.py +650 -19
- localstack/services/sns/v2/utils.py +12 -0
- localstack/services/stepfunctions/asl/component/common/path/result_path.py +1 -1
- localstack/services/stepfunctions/asl/component/state/state_execution/execute_state.py +0 -1
- localstack/services/stepfunctions/asl/component/state/state_execution/state_map/state_map.py +0 -1
- localstack/services/stepfunctions/asl/component/state/state_execution/state_task/lambda_eval_utils.py +8 -8
- localstack/services/stepfunctions/asl/component/state/state_execution/state_task/{mock_eval_utils.py → local_mock_eval_utils.py} +13 -9
- localstack/services/stepfunctions/asl/component/state/state_execution/state_task/service/state_task_service.py +6 -6
- localstack/services/stepfunctions/asl/component/state/state_execution/state_task/service/state_task_service_callback.py +1 -1
- localstack/services/stepfunctions/asl/component/state/state_fail/state_fail.py +4 -0
- localstack/services/stepfunctions/asl/component/test_state/state/base_mock.py +118 -0
- localstack/services/stepfunctions/asl/component/test_state/state/common.py +82 -0
- localstack/services/stepfunctions/asl/component/test_state/state/execution.py +139 -0
- localstack/services/stepfunctions/asl/component/test_state/state/map.py +77 -0
- localstack/services/stepfunctions/asl/component/test_state/state/task.py +44 -0
- localstack/services/stepfunctions/asl/eval/environment.py +30 -22
- localstack/services/stepfunctions/asl/eval/states.py +1 -1
- localstack/services/stepfunctions/asl/eval/test_state/environment.py +49 -9
- localstack/services/stepfunctions/asl/eval/test_state/program_state.py +22 -0
- localstack/services/stepfunctions/asl/jsonata/jsonata.py +5 -1
- localstack/services/stepfunctions/asl/parse/preprocessor.py +67 -24
- localstack/services/stepfunctions/asl/parse/test_state/asl_parser.py +5 -4
- localstack/services/stepfunctions/asl/parse/test_state/preprocessor.py +222 -31
- localstack/services/stepfunctions/asl/static_analyser/test_state/test_state_analyser.py +170 -22
- localstack/services/stepfunctions/backend/execution.py +6 -6
- localstack/services/stepfunctions/backend/execution_worker.py +5 -5
- localstack/services/stepfunctions/backend/test_state/execution.py +36 -0
- localstack/services/stepfunctions/backend/test_state/execution_worker.py +33 -1
- localstack/services/stepfunctions/backend/test_state/test_state_mock.py +127 -0
- localstack/services/stepfunctions/local_mocking/__init__.py +9 -0
- localstack/services/stepfunctions/{mocking → local_mocking}/mock_config.py +24 -17
- localstack/services/stepfunctions/provider.py +78 -27
- localstack/services/stepfunctions/test_state/mock_config.py +47 -0
- localstack/testing/pytest/fixtures.py +28 -0
- localstack/testing/snapshots/transformer_utility.py +5 -0
- localstack/utils/analytics/publisher.py +37 -155
- localstack/utils/analytics/service_request_aggregator.py +6 -4
- localstack/utils/aws/arns.py +7 -0
- localstack/utils/batching.py +258 -0
- localstack/utils/collections.py +23 -11
- localstack/version.py +2 -2
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.11.2.dev14.dist-info}/METADATA +5 -5
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.11.2.dev14.dist-info}/RECORD +113 -105
- localstack_core-4.11.2.dev14.dist-info/plux.json +1 -0
- localstack/services/stepfunctions/mocking/__init__.py +0 -0
- localstack/utils/batch_policy.py +0 -124
- localstack_core-4.10.1.dev42.dist-info/plux.json +0 -1
- /localstack/services/stepfunctions/{mocking → local_mocking}/mock_config_file.py +0 -0
- {localstack_core-4.10.1.dev42.data → localstack_core-4.11.2.dev14.data}/scripts/localstack +0 -0
- {localstack_core-4.10.1.dev42.data → localstack_core-4.11.2.dev14.data}/scripts/localstack-supervisor +0 -0
- {localstack_core-4.10.1.dev42.data → localstack_core-4.11.2.dev14.data}/scripts/localstack.bat +0 -0
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.11.2.dev14.dist-info}/WHEEL +0 -0
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.11.2.dev14.dist-info}/entry_points.txt +0 -0
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.11.2.dev14.dist-info}/licenses/LICENSE.txt +0 -0
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.11.2.dev14.dist-info}/top_level.txt +0 -0
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import copy
|
|
4
4
|
import logging
|
|
5
5
|
import threading
|
|
6
|
-
from typing import Any, Final, Optional
|
|
6
|
+
from typing import Any, Final, Optional, Self
|
|
7
7
|
|
|
8
8
|
from localstack.aws.api.stepfunctions import (
|
|
9
9
|
Arn,
|
|
@@ -34,7 +34,10 @@ from localstack.services.stepfunctions.asl.eval.program_state import (
|
|
|
34
34
|
from localstack.services.stepfunctions.asl.eval.states import ContextObjectData, States
|
|
35
35
|
from localstack.services.stepfunctions.asl.eval.variable_store import VariableStore
|
|
36
36
|
from localstack.services.stepfunctions.backend.activity import Activity
|
|
37
|
-
from localstack.services.stepfunctions.
|
|
37
|
+
from localstack.services.stepfunctions.local_mocking.mock_config import (
|
|
38
|
+
LocalMockedResponse,
|
|
39
|
+
LocalMockTestCase,
|
|
40
|
+
)
|
|
38
41
|
|
|
39
42
|
LOG = logging.getLogger(__name__)
|
|
40
43
|
|
|
@@ -52,7 +55,7 @@ class Environment:
|
|
|
52
55
|
callback_pool_manager: CallbackPoolManager
|
|
53
56
|
map_run_record_pool_manager: MapRunRecordPoolManager
|
|
54
57
|
activity_store: Final[dict[Arn, Activity]]
|
|
55
|
-
|
|
58
|
+
local_mock_test_case: LocalMockTestCase | None = None
|
|
56
59
|
|
|
57
60
|
_frames: Final[list[Environment]]
|
|
58
61
|
_is_frame: bool = False
|
|
@@ -71,7 +74,7 @@ class Environment:
|
|
|
71
74
|
cloud_watch_logging_session: CloudWatchLoggingSession | None,
|
|
72
75
|
activity_store: dict[Arn, Activity],
|
|
73
76
|
variable_store: VariableStore | None = None,
|
|
74
|
-
|
|
77
|
+
local_mock_test_case: LocalMockTestCase | None = None,
|
|
75
78
|
):
|
|
76
79
|
super().__init__()
|
|
77
80
|
self._state_mutex = threading.RLock()
|
|
@@ -89,7 +92,7 @@ class Environment:
|
|
|
89
92
|
|
|
90
93
|
self.activity_store = activity_store
|
|
91
94
|
|
|
92
|
-
self.
|
|
95
|
+
self.local_mock_test_case = local_mock_test_case
|
|
93
96
|
|
|
94
97
|
self._frames = []
|
|
95
98
|
self._is_frame = False
|
|
@@ -101,9 +104,9 @@ class Environment:
|
|
|
101
104
|
|
|
102
105
|
@classmethod
|
|
103
106
|
def as_frame_of(
|
|
104
|
-
cls, env:
|
|
105
|
-
) ->
|
|
106
|
-
return
|
|
107
|
+
cls, env: Self, event_history_frame_cache: EventHistoryContext | None = None
|
|
108
|
+
) -> Self:
|
|
109
|
+
return cls.as_inner_frame_of(
|
|
107
110
|
env=env,
|
|
108
111
|
variable_store=env.variable_store,
|
|
109
112
|
event_history_frame_cache=event_history_frame_cache,
|
|
@@ -112,10 +115,10 @@ class Environment:
|
|
|
112
115
|
@classmethod
|
|
113
116
|
def as_inner_frame_of(
|
|
114
117
|
cls,
|
|
115
|
-
env:
|
|
118
|
+
env: Self,
|
|
116
119
|
variable_store: VariableStore,
|
|
117
120
|
event_history_frame_cache: EventHistoryContext | None = None,
|
|
118
|
-
) ->
|
|
121
|
+
) -> Self:
|
|
119
122
|
# Construct the frame's context object data.
|
|
120
123
|
context = ContextObjectData(
|
|
121
124
|
Execution=env.states.context_object.context_object_data["Execution"],
|
|
@@ -138,8 +141,8 @@ class Environment:
|
|
|
138
141
|
cloud_watch_logging_session=env.cloud_watch_logging_session,
|
|
139
142
|
activity_store=env.activity_store,
|
|
140
143
|
variable_store=variable_store,
|
|
141
|
-
mock_test_case=env.mock_test_case,
|
|
142
144
|
)
|
|
145
|
+
frame.local_mock_test_case = env.local_mock_test_case
|
|
143
146
|
frame._is_frame = True
|
|
144
147
|
frame.event_manager = env.event_manager
|
|
145
148
|
if "State" in env.states.context_object.context_object_data:
|
|
@@ -267,32 +270,37 @@ class Environment:
|
|
|
267
270
|
def is_standard_workflow(self) -> bool:
|
|
268
271
|
return self.execution_type == StateMachineType.STANDARD
|
|
269
272
|
|
|
270
|
-
def
|
|
273
|
+
def is_test_state_mocked_mode(self) -> bool:
|
|
274
|
+
return False
|
|
275
|
+
|
|
276
|
+
def is_local_mocked_mode(self) -> bool:
|
|
271
277
|
"""
|
|
272
|
-
Returns True if
|
|
273
|
-
|
|
274
|
-
|
|
278
|
+
Returns True if:
|
|
279
|
+
- the state machine is running in Step Functions Local mode
|
|
280
|
+
- the current state has a defined Local mock configuration in the target environment or frame
|
|
281
|
+
|
|
282
|
+
Otherwise, returns False.
|
|
275
283
|
"""
|
|
276
284
|
return (
|
|
277
|
-
self.
|
|
278
|
-
and self.next_state_name in self.
|
|
285
|
+
self.local_mock_test_case is not None
|
|
286
|
+
and self.next_state_name in self.local_mock_test_case.state_mocked_responses
|
|
279
287
|
)
|
|
280
288
|
|
|
281
|
-
def
|
|
282
|
-
if not self.
|
|
289
|
+
def get_current_local_mocked_response(self) -> LocalMockedResponse:
|
|
290
|
+
if not self.is_local_mocked_mode():
|
|
283
291
|
raise RuntimeError(
|
|
284
292
|
"Cannot retrieve mocked response: execution is not operating in mocked mode"
|
|
285
293
|
)
|
|
286
294
|
state_name = self.next_state_name
|
|
287
|
-
state_mocked_responses: Optional = self.
|
|
295
|
+
state_mocked_responses: Optional = self.local_mock_test_case.state_mocked_responses.get(
|
|
288
296
|
state_name
|
|
289
297
|
)
|
|
290
298
|
if state_mocked_responses is None:
|
|
291
|
-
raise RuntimeError(f"No mocked response definition for state '{state_name}'")
|
|
299
|
+
raise RuntimeError(f"No Local mocked response definition for state '{state_name}'")
|
|
292
300
|
retry_count = self.states.context_object.context_object_data["State"]["RetryCount"]
|
|
293
301
|
if len(state_mocked_responses.mocked_responses) <= retry_count:
|
|
294
302
|
raise RuntimeError(
|
|
295
|
-
f"No mocked response definition for state '{state_name}' "
|
|
303
|
+
f"No Local mocked response definition for state '{state_name}' "
|
|
296
304
|
f"and retry number '{retry_count}'"
|
|
297
305
|
)
|
|
298
306
|
return state_mocked_responses.mocked_responses[retry_count]
|
|
@@ -82,7 +82,7 @@ class States:
|
|
|
82
82
|
context_object: Final[ContextObject]
|
|
83
83
|
|
|
84
84
|
def __init__(self, context: ContextObjectData):
|
|
85
|
-
input_value = context
|
|
85
|
+
input_value = context.get("Execution", {}).get("Input", {})
|
|
86
86
|
self._states_data = StatesData(input=input_value, context=context)
|
|
87
87
|
self.context_object = ContextObject(context_object=context)
|
|
88
88
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Self
|
|
4
|
+
|
|
3
5
|
from localstack.aws.api.stepfunctions import Arn, InspectionData, StateMachineType
|
|
4
6
|
from localstack.services.stepfunctions.asl.eval.environment import Environment
|
|
5
7
|
from localstack.services.stepfunctions.asl.eval.evaluation_details import AWSExecutionDetails
|
|
@@ -14,14 +16,18 @@ from localstack.services.stepfunctions.asl.eval.program_state import (
|
|
|
14
16
|
)
|
|
15
17
|
from localstack.services.stepfunctions.asl.eval.states import ContextObjectData
|
|
16
18
|
from localstack.services.stepfunctions.asl.eval.test_state.program_state import (
|
|
19
|
+
ProgramCaughtError,
|
|
17
20
|
ProgramChoiceSelected,
|
|
21
|
+
ProgramRetriable,
|
|
18
22
|
)
|
|
19
23
|
from localstack.services.stepfunctions.asl.eval.variable_store import VariableStore
|
|
20
24
|
from localstack.services.stepfunctions.backend.activity import Activity
|
|
25
|
+
from localstack.services.stepfunctions.backend.test_state.test_state_mock import TestStateMock
|
|
21
26
|
|
|
22
27
|
|
|
23
28
|
class TestStateEnvironment(Environment):
|
|
24
29
|
inspection_data: InspectionData
|
|
30
|
+
mock: TestStateMock
|
|
25
31
|
|
|
26
32
|
def __init__(
|
|
27
33
|
self,
|
|
@@ -31,6 +37,8 @@ class TestStateEnvironment(Environment):
|
|
|
31
37
|
event_history_context: EventHistoryContext,
|
|
32
38
|
activity_store: dict[Arn, Activity],
|
|
33
39
|
cloud_watch_logging_session: CloudWatchLoggingSession | None = None,
|
|
40
|
+
variable_store: VariableStore | None = None,
|
|
41
|
+
mock: TestStateMock | None = None,
|
|
34
42
|
):
|
|
35
43
|
super().__init__(
|
|
36
44
|
aws_execution_details=aws_execution_details,
|
|
@@ -39,30 +47,43 @@ class TestStateEnvironment(Environment):
|
|
|
39
47
|
event_history_context=event_history_context,
|
|
40
48
|
cloud_watch_logging_session=cloud_watch_logging_session,
|
|
41
49
|
activity_store=activity_store,
|
|
50
|
+
variable_store=variable_store,
|
|
42
51
|
)
|
|
43
52
|
self.inspection_data = InspectionData()
|
|
53
|
+
self.mock = mock
|
|
54
|
+
|
|
55
|
+
def is_test_state_mocked_mode(self) -> bool:
|
|
56
|
+
return self.mock.is_mocked()
|
|
44
57
|
|
|
58
|
+
@classmethod
|
|
45
59
|
def as_frame_of(
|
|
46
60
|
cls,
|
|
47
|
-
env:
|
|
61
|
+
env: Self,
|
|
48
62
|
event_history_frame_cache: EventHistoryContext | None = None,
|
|
49
|
-
) ->
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return frame
|
|
63
|
+
) -> Self:
|
|
64
|
+
if (mocked_context := env.mock.get_context()) is not None:
|
|
65
|
+
env.states.context_object.context_object_data = mocked_context
|
|
53
66
|
|
|
67
|
+
return cls.as_inner_frame_of(
|
|
68
|
+
env=env,
|
|
69
|
+
variable_store=env.variable_store,
|
|
70
|
+
event_history_frame_cache=event_history_frame_cache,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
54
74
|
def as_inner_frame_of(
|
|
55
75
|
cls,
|
|
56
|
-
env:
|
|
76
|
+
env: Self,
|
|
57
77
|
variable_store: VariableStore,
|
|
58
78
|
event_history_frame_cache: EventHistoryContext | None = None,
|
|
59
|
-
) ->
|
|
79
|
+
) -> Self:
|
|
60
80
|
frame = super().as_inner_frame_of(
|
|
61
81
|
env=env,
|
|
62
82
|
event_history_frame_cache=event_history_frame_cache,
|
|
63
83
|
variable_store=variable_store,
|
|
64
84
|
)
|
|
65
85
|
frame.inspection_data = env.inspection_data
|
|
86
|
+
frame.mock = env.mock
|
|
66
87
|
return frame
|
|
67
88
|
|
|
68
89
|
def set_choice_selected(self, next_state_name: str) -> None:
|
|
@@ -71,5 +92,24 @@ class TestStateEnvironment(Environment):
|
|
|
71
92
|
self._program_state = ProgramChoiceSelected(next_state_name=next_state_name)
|
|
72
93
|
self.program_state_event.set()
|
|
73
94
|
self.program_state_event.clear()
|
|
74
|
-
|
|
75
|
-
|
|
95
|
+
|
|
96
|
+
def set_caught_error(self, next_state_name: str, error: str, cause: str) -> None:
|
|
97
|
+
with self._state_mutex:
|
|
98
|
+
if isinstance(self._program_state, ProgramRunning):
|
|
99
|
+
self._program_state = ProgramCaughtError(
|
|
100
|
+
next_state_name=next_state_name,
|
|
101
|
+
error=error,
|
|
102
|
+
cause=cause,
|
|
103
|
+
)
|
|
104
|
+
self.program_state_event.set()
|
|
105
|
+
self.program_state_event.clear()
|
|
106
|
+
|
|
107
|
+
def set_retriable_error(self, error: str, cause: str) -> None:
|
|
108
|
+
with self._state_mutex:
|
|
109
|
+
if isinstance(self._program_state, ProgramRunning):
|
|
110
|
+
self._program_state = ProgramRetriable(
|
|
111
|
+
error=error,
|
|
112
|
+
cause=cause,
|
|
113
|
+
)
|
|
114
|
+
self.program_state_event.set()
|
|
115
|
+
self.program_state_event.clear()
|
|
@@ -9,3 +9,25 @@ class ProgramChoiceSelected(ProgramState):
|
|
|
9
9
|
def __init__(self, next_state_name: str):
|
|
10
10
|
super().__init__()
|
|
11
11
|
self.next_state_name = next_state_name
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ProgramCaughtError(ProgramState):
|
|
15
|
+
next_state_name: Final[str]
|
|
16
|
+
error: Final[str]
|
|
17
|
+
cause: Final[str]
|
|
18
|
+
|
|
19
|
+
def __init__(self, next_state_name: str, error: str, cause: str):
|
|
20
|
+
super().__init__()
|
|
21
|
+
self.next_state_name = next_state_name
|
|
22
|
+
self.error = error
|
|
23
|
+
self.cause = cause
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ProgramRetriable(ProgramState):
|
|
27
|
+
error: Final[str]
|
|
28
|
+
cause: Final[str]
|
|
29
|
+
|
|
30
|
+
def __init__(self, error: str, cause: str):
|
|
31
|
+
super().__init__()
|
|
32
|
+
self.error = error
|
|
33
|
+
self.cause = cause
|
|
@@ -33,7 +33,11 @@ _PATTERN_VARIABLE_REFERENCE = re.compile(
|
|
|
33
33
|
# allowing escapes
|
|
34
34
|
r"(?:\"(?:\\.|[^\"\\])*\"|\'(?:\\.|[^\'\\])*\')"
|
|
35
35
|
r"|"
|
|
36
|
-
# 3)
|
|
36
|
+
# 3) Non-capturing branch for bracket expressions [...]
|
|
37
|
+
# Consume these to avoid capturing $ inside them
|
|
38
|
+
r"(?:\[[^\[\]]*\])"
|
|
39
|
+
r"|"
|
|
40
|
+
# 4) Capturing branch for $$, $identifier[.prop…], or lone $
|
|
37
41
|
r"(\$\$|\$[A-Za-z0-9_$]+(?:\.[A-Za-z0-9_][A-Za-z0-9_$]*)*|\$)"
|
|
38
42
|
)
|
|
39
43
|
|
|
@@ -7,13 +7,17 @@ from antlr4.tree.Tree import ParseTree, TerminalNodeImpl
|
|
|
7
7
|
|
|
8
8
|
from localstack.services.stepfunctions.asl.antlr.runtime.ASLLexer import ASLLexer
|
|
9
9
|
from localstack.services.stepfunctions.asl.antlr.runtime.ASLParser import ASLParser
|
|
10
|
-
from localstack.services.stepfunctions.asl.antlr.runtime.ASLParserVisitor import
|
|
10
|
+
from localstack.services.stepfunctions.asl.antlr.runtime.ASLParserVisitor import (
|
|
11
|
+
ASLParserVisitor,
|
|
12
|
+
)
|
|
11
13
|
from localstack.services.stepfunctions.asl.antlt4utils.antlr4utils import (
|
|
12
14
|
from_string_literal,
|
|
13
15
|
is_production,
|
|
14
16
|
is_terminal,
|
|
15
17
|
)
|
|
16
|
-
from localstack.services.stepfunctions.asl.component.common.assign.assign_decl import
|
|
18
|
+
from localstack.services.stepfunctions.asl.component.common.assign.assign_decl import (
|
|
19
|
+
AssignDecl,
|
|
20
|
+
)
|
|
17
21
|
from localstack.services.stepfunctions.asl.component.common.assign.assign_decl_binding import (
|
|
18
22
|
AssignDeclBinding,
|
|
19
23
|
)
|
|
@@ -36,9 +40,15 @@ from localstack.services.stepfunctions.asl.component.common.assign.assign_templa
|
|
|
36
40
|
AssignTemplateValueTerminalLit,
|
|
37
41
|
AssignTemplateValueTerminalStringJSONata,
|
|
38
42
|
)
|
|
39
|
-
from localstack.services.stepfunctions.asl.component.common.catch.catch_decl import
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
from localstack.services.stepfunctions.asl.component.common.catch.catch_decl import (
|
|
44
|
+
CatchDecl,
|
|
45
|
+
)
|
|
46
|
+
from localstack.services.stepfunctions.asl.component.common.catch.catcher_decl import (
|
|
47
|
+
CatcherDecl,
|
|
48
|
+
)
|
|
49
|
+
from localstack.services.stepfunctions.asl.component.common.catch.catcher_props import (
|
|
50
|
+
CatcherProps,
|
|
51
|
+
)
|
|
42
52
|
from localstack.services.stepfunctions.asl.component.common.comment import Comment
|
|
43
53
|
from localstack.services.stepfunctions.asl.component.common.error_name.custom_error_name import (
|
|
44
54
|
CustomErrorName,
|
|
@@ -46,7 +56,9 @@ from localstack.services.stepfunctions.asl.component.common.error_name.custom_er
|
|
|
46
56
|
from localstack.services.stepfunctions.asl.component.common.error_name.error_equals_decl import (
|
|
47
57
|
ErrorEqualsDecl,
|
|
48
58
|
)
|
|
49
|
-
from localstack.services.stepfunctions.asl.component.common.error_name.error_name import
|
|
59
|
+
from localstack.services.stepfunctions.asl.component.common.error_name.error_name import (
|
|
60
|
+
ErrorName,
|
|
61
|
+
)
|
|
50
62
|
from localstack.services.stepfunctions.asl.component.common.error_name.states_error_name import (
|
|
51
63
|
StatesErrorName,
|
|
52
64
|
)
|
|
@@ -79,10 +91,18 @@ from localstack.services.stepfunctions.asl.component.common.parargs import (
|
|
|
79
91
|
Parameters,
|
|
80
92
|
Parargs,
|
|
81
93
|
)
|
|
82
|
-
from localstack.services.stepfunctions.asl.component.common.path.input_path import
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
from localstack.services.stepfunctions.asl.component.common.path.
|
|
94
|
+
from localstack.services.stepfunctions.asl.component.common.path.input_path import (
|
|
95
|
+
InputPath,
|
|
96
|
+
)
|
|
97
|
+
from localstack.services.stepfunctions.asl.component.common.path.items_path import (
|
|
98
|
+
ItemsPath,
|
|
99
|
+
)
|
|
100
|
+
from localstack.services.stepfunctions.asl.component.common.path.output_path import (
|
|
101
|
+
OutputPath,
|
|
102
|
+
)
|
|
103
|
+
from localstack.services.stepfunctions.asl.component.common.path.result_path import (
|
|
104
|
+
ResultPath,
|
|
105
|
+
)
|
|
86
106
|
from localstack.services.stepfunctions.asl.component.common.payload.payloadvalue.payload_value import (
|
|
87
107
|
PayloadValue,
|
|
88
108
|
)
|
|
@@ -116,7 +136,9 @@ from localstack.services.stepfunctions.asl.component.common.query_language impor
|
|
|
116
136
|
QueryLanguage,
|
|
117
137
|
QueryLanguageMode,
|
|
118
138
|
)
|
|
119
|
-
from localstack.services.stepfunctions.asl.component.common.result_selector import
|
|
139
|
+
from localstack.services.stepfunctions.asl.component.common.result_selector import (
|
|
140
|
+
ResultSelector,
|
|
141
|
+
)
|
|
120
142
|
from localstack.services.stepfunctions.asl.component.common.retry.backoff_rate_decl import (
|
|
121
143
|
BackoffRateDecl,
|
|
122
144
|
)
|
|
@@ -133,9 +155,15 @@ from localstack.services.stepfunctions.asl.component.common.retry.max_attempts_d
|
|
|
133
155
|
from localstack.services.stepfunctions.asl.component.common.retry.max_delay_seconds_decl import (
|
|
134
156
|
MaxDelaySecondsDecl,
|
|
135
157
|
)
|
|
136
|
-
from localstack.services.stepfunctions.asl.component.common.retry.retrier_decl import
|
|
137
|
-
|
|
138
|
-
|
|
158
|
+
from localstack.services.stepfunctions.asl.component.common.retry.retrier_decl import (
|
|
159
|
+
RetrierDecl,
|
|
160
|
+
)
|
|
161
|
+
from localstack.services.stepfunctions.asl.component.common.retry.retrier_props import (
|
|
162
|
+
RetrierProps,
|
|
163
|
+
)
|
|
164
|
+
from localstack.services.stepfunctions.asl.component.common.retry.retry_decl import (
|
|
165
|
+
RetryDecl,
|
|
166
|
+
)
|
|
139
167
|
from localstack.services.stepfunctions.asl.component.common.string.string_expression import (
|
|
140
168
|
StringContextPath,
|
|
141
169
|
StringExpression,
|
|
@@ -291,15 +319,23 @@ from localstack.services.stepfunctions.asl.component.state.state_fail.error_decl
|
|
|
291
319
|
Error,
|
|
292
320
|
ErrorPath,
|
|
293
321
|
)
|
|
294
|
-
from localstack.services.stepfunctions.asl.component.state.state_fail.state_fail import
|
|
295
|
-
|
|
296
|
-
|
|
322
|
+
from localstack.services.stepfunctions.asl.component.state.state_fail.state_fail import (
|
|
323
|
+
StateFail,
|
|
324
|
+
)
|
|
325
|
+
from localstack.services.stepfunctions.asl.component.state.state_pass.result import (
|
|
326
|
+
Result,
|
|
327
|
+
)
|
|
328
|
+
from localstack.services.stepfunctions.asl.component.state.state_pass.state_pass import (
|
|
329
|
+
StatePass,
|
|
330
|
+
)
|
|
297
331
|
from localstack.services.stepfunctions.asl.component.state.state_props import StateProps
|
|
298
332
|
from localstack.services.stepfunctions.asl.component.state.state_succeed.state_succeed import (
|
|
299
333
|
StateSucceed,
|
|
300
334
|
)
|
|
301
335
|
from localstack.services.stepfunctions.asl.component.state.state_type import StateType
|
|
302
|
-
from localstack.services.stepfunctions.asl.component.state.state_wait.state_wait import
|
|
336
|
+
from localstack.services.stepfunctions.asl.component.state.state_wait.state_wait import (
|
|
337
|
+
StateWait,
|
|
338
|
+
)
|
|
303
339
|
from localstack.services.stepfunctions.asl.component.state.state_wait.wait_function.seconds import (
|
|
304
340
|
Seconds,
|
|
305
341
|
SecondsJSONata,
|
|
@@ -311,18 +347,24 @@ from localstack.services.stepfunctions.asl.component.state.state_wait.wait_funct
|
|
|
311
347
|
Timestamp,
|
|
312
348
|
TimestampPath,
|
|
313
349
|
)
|
|
314
|
-
from localstack.services.stepfunctions.asl.parse.intrinsic.intrinsic_parser import
|
|
350
|
+
from localstack.services.stepfunctions.asl.parse.intrinsic.intrinsic_parser import (
|
|
351
|
+
IntrinsicParser,
|
|
352
|
+
)
|
|
315
353
|
from localstack.services.stepfunctions.asl.parse.typed_props import TypedProps
|
|
316
354
|
|
|
317
355
|
LOG = logging.getLogger(__name__)
|
|
318
356
|
|
|
319
357
|
|
|
320
358
|
class Preprocessor(ASLParserVisitor):
|
|
321
|
-
|
|
359
|
+
def __init__(self):
|
|
360
|
+
self._query_language_per_scope: list[QueryLanguage] = []
|
|
322
361
|
|
|
323
362
|
def _get_current_query_language(self) -> QueryLanguage:
|
|
324
363
|
return self._query_language_per_scope[-1]
|
|
325
364
|
|
|
365
|
+
def _get_top_level_query_language(self) -> QueryLanguage:
|
|
366
|
+
return self._query_language_per_scope[0]
|
|
367
|
+
|
|
326
368
|
def _open_query_language_scope(self, parse_tree: ParseTree) -> None:
|
|
327
369
|
production = is_production(parse_tree)
|
|
328
370
|
if production is None:
|
|
@@ -347,11 +389,11 @@ class Preprocessor(ASLParserVisitor):
|
|
|
347
389
|
query_language = QueryLanguage()
|
|
348
390
|
# Otherwise, check for logical conflicts and add the latest or inherited value to as the next scope.
|
|
349
391
|
else:
|
|
350
|
-
|
|
392
|
+
top_query_language = self._get_top_level_query_language()
|
|
351
393
|
if query_language is None:
|
|
352
|
-
query_language =
|
|
394
|
+
query_language = top_query_language
|
|
353
395
|
if (
|
|
354
|
-
|
|
396
|
+
top_query_language.query_language_mode == QueryLanguageMode.JSONata
|
|
355
397
|
and query_language.query_language_mode == QueryLanguageMode.JSONPath
|
|
356
398
|
):
|
|
357
399
|
raise ValueError(
|
|
@@ -1507,5 +1549,6 @@ class Preprocessor(ASLParserVisitor):
|
|
|
1507
1549
|
intrinsic_function_derivation = ctx.STRINGINTRINSICFUNC().getText()[1:-1]
|
|
1508
1550
|
function, _ = IntrinsicParser.parse(intrinsic_function_derivation)
|
|
1509
1551
|
return StringIntrinsicFunction(
|
|
1510
|
-
intrinsic_function_derivation=intrinsic_function_derivation,
|
|
1552
|
+
intrinsic_function_derivation=intrinsic_function_derivation,
|
|
1553
|
+
function=function,
|
|
1511
1554
|
)
|
|
@@ -15,7 +15,9 @@ from localstack.services.stepfunctions.asl.parse.test_state.preprocessor import
|
|
|
15
15
|
|
|
16
16
|
class TestStateAmazonStateLanguageParser(AmazonStateLanguageParser):
|
|
17
17
|
@staticmethod
|
|
18
|
-
def parse(
|
|
18
|
+
def parse(
|
|
19
|
+
definition: str, state_name: str | None = None
|
|
20
|
+
) -> tuple[EvalComponent, ParserRuleContext]:
|
|
19
21
|
# Attempt to build the AST and look out for syntax errors.
|
|
20
22
|
syntax_error_listener = SyntaxErrorListener()
|
|
21
23
|
|
|
@@ -25,15 +27,14 @@ class TestStateAmazonStateLanguageParser(AmazonStateLanguageParser):
|
|
|
25
27
|
parser = ASLParser(stream)
|
|
26
28
|
parser.removeErrorListeners()
|
|
27
29
|
parser.addErrorListener(syntax_error_listener)
|
|
28
|
-
# Unlike the main Program parser, TestState parsing occurs at a state declaration level.
|
|
29
|
-
tree = parser.state_decl_body()
|
|
30
30
|
|
|
31
|
+
tree = parser.state_machine() if state_name else parser.state_decl_body()
|
|
31
32
|
errors = syntax_error_listener.errors
|
|
32
33
|
if errors:
|
|
33
34
|
raise ASLParserException(errors=errors)
|
|
34
35
|
|
|
35
36
|
# Attempt to preprocess the AST into evaluation components.
|
|
36
37
|
preprocessor = TestStatePreprocessor()
|
|
37
|
-
test_state_program = preprocessor.
|
|
38
|
+
test_state_program = preprocessor.to_test_state_program(tree, state_name)
|
|
38
39
|
|
|
39
40
|
return test_state_program, tree
|