@motiadev/core 0.4.2-beta.94 → 0.4.3-beta.96
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.
- package/dist/src/locked-data.js +6 -2
- package/dist/src/python/{communication_factory.py → motia_communication_factory.py} +2 -2
- package/dist/src/python/{context.py → motia_context.py} +5 -5
- package/dist/src/python/{logger.py → motia_logger.py} +1 -1
- package/dist/src/python/{middleware.py → motia_middleware.py} +1 -1
- package/dist/src/python/{rpc.py → motia_rpc.py} +4 -10
- package/dist/src/python/{rpc_state_manager.py → motia_rpc_state_manager.py} +2 -2
- package/dist/src/python/{rpc_stream_manager.py → motia_rpc_stream_manager.py} +2 -2
- package/dist/src/python/python-runner.py +5 -5
- package/package.json +1 -1
- package/dist/src/python/validation.py +0 -56
- /package/dist/src/python/{dot_dict.py → motia_dot_dict.py} +0 -0
- /package/dist/src/python/{ipc_communication.py → motia_ipc_communication.py} +0 -0
- /package/dist/src/python/{rpc_communication.py → motia_rpc_communication.py} +0 -0
- /package/dist/src/python/{type_definitions.py → motia_type_definitions.py} +0 -0
package/dist/src/locked-data.js
CHANGED
|
@@ -8,8 +8,9 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const guards_1 = require("./guards");
|
|
10
10
|
const step_validator_1 = require("./step-validator");
|
|
11
|
+
const file_stream_adapter_1 = require("./streams/adapters/file-stream-adapter");
|
|
12
|
+
const memory_stream_adapter_1 = require("./streams/adapters/memory-stream-adapter");
|
|
11
13
|
const generate_types_1 = require("./types/generate-types");
|
|
12
|
-
const trace_stream_adapter_1 = require("./observability/trace-stream-adapter");
|
|
13
14
|
class LockedData {
|
|
14
15
|
constructor(baseDir, streamAdapter = 'file', printer) {
|
|
15
16
|
this.baseDir = baseDir;
|
|
@@ -264,7 +265,10 @@ class LockedData {
|
|
|
264
265
|
return validationResult.success;
|
|
265
266
|
}
|
|
266
267
|
createStreamAdapter(streamName) {
|
|
267
|
-
|
|
268
|
+
if (this.streamAdapter === 'file') {
|
|
269
|
+
return new file_stream_adapter_1.FileStreamAdapter(this.baseDir, streamName);
|
|
270
|
+
}
|
|
271
|
+
return new memory_stream_adapter_1.MemoryStreamAdapter();
|
|
268
272
|
}
|
|
269
273
|
}
|
|
270
274
|
exports.LockedData = LockedData;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import platform
|
|
3
3
|
from typing import Union
|
|
4
|
-
from
|
|
5
|
-
from
|
|
4
|
+
from motia_rpc_communication import RpcCommunication
|
|
5
|
+
from motia_ipc_communication import IpcCommunication
|
|
6
6
|
|
|
7
7
|
def create_communication() -> Union[RpcCommunication, IpcCommunication]:
|
|
8
8
|
"""
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from typing import Any, List, Optional
|
|
2
|
-
from
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
2
|
+
from motia_type_definitions import HandlerResult
|
|
3
|
+
from motia_rpc import RpcSender
|
|
4
|
+
from motia_rpc_state_manager import RpcStateManager
|
|
5
|
+
from motia_logger import Logger
|
|
6
|
+
from motia_dot_dict import DotDict
|
|
7
7
|
|
|
8
8
|
class Context:
|
|
9
9
|
def __init__(
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import os
|
|
6
|
-
import platform
|
|
7
|
-
from typing import Any, Dict, Optional, Callable, Union
|
|
8
|
-
from communication_factory import create_communication
|
|
9
|
-
from rpc_communication import RpcCommunication
|
|
10
|
-
from ipc_communication import IpcCommunication
|
|
1
|
+
from typing import Any, Union
|
|
2
|
+
from motia_communication_factory import create_communication
|
|
3
|
+
from motia_rpc_communication import RpcCommunication
|
|
4
|
+
from motia_ipc_communication import IpcCommunication
|
|
11
5
|
|
|
12
6
|
def serialize_for_json(obj: Any) -> Any:
|
|
13
7
|
"""Convert Python objects to JSON-serializable types"""
|
|
@@ -5,11 +5,11 @@ import os
|
|
|
5
5
|
import asyncio
|
|
6
6
|
import traceback
|
|
7
7
|
from typing import Callable, List, Dict
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
8
|
+
from motia_rpc import RpcSender
|
|
9
|
+
from motia_context import Context
|
|
10
|
+
from motia_middleware import compose_middleware
|
|
11
|
+
from motia_rpc_stream_manager import RpcStreamManager
|
|
12
|
+
from motia_dot_dict import DotDict
|
|
13
13
|
|
|
14
14
|
def parse_args(arg: str) -> Dict:
|
|
15
15
|
"""Parse command line arguments into HandlerArgs"""
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@motiadev/core",
|
|
3
3
|
"description": "Core functionality for the Motia framework, providing the foundation for building event-driven workflows.",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"version": "0.4.
|
|
5
|
+
"version": "0.4.3-beta.96",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"body-parser": "^1.20.3",
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
from typing import TypeVar, Dict, Any
|
|
2
|
-
from jsonschema import validate as json_validate
|
|
3
|
-
from jsonschema.exceptions import ValidationError
|
|
4
|
-
from type_definitions import ValidationResult, JsonSchema
|
|
5
|
-
|
|
6
|
-
T = TypeVar('T')
|
|
7
|
-
|
|
8
|
-
def namespace_to_dict(obj: Any) -> Dict:
|
|
9
|
-
"""Convert SimpleNamespace to dict recursively"""
|
|
10
|
-
if isinstance(obj, list):
|
|
11
|
-
return [namespace_to_dict(item) for item in obj]
|
|
12
|
-
elif hasattr(obj, '__dict__'):
|
|
13
|
-
return {k: namespace_to_dict(v) for k, v in obj.__dict__.items()}
|
|
14
|
-
return obj
|
|
15
|
-
|
|
16
|
-
def create_validation_error(error: ValidationError) -> ValidationResult:
|
|
17
|
-
"""Create a user-friendly validation error message"""
|
|
18
|
-
property_name = error.path[-1] if error.path else error.schema_path[-1]
|
|
19
|
-
|
|
20
|
-
if error.validator == 'required':
|
|
21
|
-
missing_field = error.schema['required'][0]
|
|
22
|
-
error_msg = f"Missing required field: '{missing_field}'"
|
|
23
|
-
elif error.validator == 'type':
|
|
24
|
-
expected_type = error.validator_value
|
|
25
|
-
error_msg = f"Invalid type for '{property_name}'. Expected {expected_type}"
|
|
26
|
-
elif error.validator == 'properties':
|
|
27
|
-
error_msg = f"Invalid property: '{property_name}'"
|
|
28
|
-
elif error.validator == 'items':
|
|
29
|
-
error_msg = f"Invalid item in array: '{property_name}'"
|
|
30
|
-
else:
|
|
31
|
-
error_msg = f"Validation error for '{property_name}': {error.message}"
|
|
32
|
-
|
|
33
|
-
details = f"\nReceived: {str(error.instance)}" if hasattr(error, 'instance') else ""
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
'success': False,
|
|
37
|
-
'error': error_msg,
|
|
38
|
-
'details': details,
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
def validate_with_jsonschema(data: T, schema: JsonSchema) -> ValidationResult:
|
|
42
|
-
"""Validate data against a JSON schema"""
|
|
43
|
-
try:
|
|
44
|
-
dict_data = namespace_to_dict(data)
|
|
45
|
-
json_validate(instance=dict_data, schema=schema)
|
|
46
|
-
return {
|
|
47
|
-
'success': True,
|
|
48
|
-
'data': dict_data
|
|
49
|
-
}
|
|
50
|
-
except ValidationError as e:
|
|
51
|
-
return create_validation_error(e)
|
|
52
|
-
except Exception as e:
|
|
53
|
-
return {
|
|
54
|
-
'success': False,
|
|
55
|
-
'error': f"Validation Error: {str(e)}"
|
|
56
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|