@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.
@@ -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
- return new trace_stream_adapter_1.TraceStreamAdapter(this.baseDir, streamName, this.streamAdapter);
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 rpc_communication import RpcCommunication
5
- from ipc_communication import IpcCommunication
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 type_definitions import HandlerResult
3
- from rpc import RpcSender
4
- from rpc_state_manager import RpcStateManager
5
- from logger import Logger
6
- from dot_dict import DotDict
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,6 +1,6 @@
1
1
  import time
2
2
  from typing import Any, Dict, Optional
3
- from rpc import RpcSender
3
+ from motia_rpc import RpcSender
4
4
 
5
5
  class Logger:
6
6
  def __init__(self, trace_id: str, flows: list[str], rpc: RpcSender):
@@ -1,6 +1,6 @@
1
1
  from typing import Any, Callable
2
2
  from functools import reduce
3
- from context import Context
3
+ from motia_context import Context
4
4
 
5
5
  def compose_middleware(*middlewares):
6
6
  """Compose multiple middleware functions into a single middleware"""
@@ -1,13 +1,7 @@
1
- import uuid
2
- import asyncio
3
- import json
4
- import sys
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"""
@@ -1,8 +1,8 @@
1
- from typing import Any
2
1
  import asyncio
3
- from rpc import RpcSender
4
2
  import functools
5
3
  import sys
4
+ from typing import Any
5
+ from motia_rpc import RpcSender
6
6
 
7
7
  class RpcStateManager:
8
8
  def __init__(self, rpc: RpcSender):
@@ -1,8 +1,8 @@
1
- from typing import Any
2
1
  import asyncio
3
- from rpc import RpcSender
4
2
  import functools
5
3
  import sys
4
+ from typing import Any
5
+ from motia_rpc import RpcSender
6
6
 
7
7
  class RpcStreamManager:
8
8
  def __init__(self, stream_name: str,rpc: RpcSender):
@@ -5,11 +5,11 @@ import os
5
5
  import asyncio
6
6
  import traceback
7
7
  from typing import Callable, List, Dict
8
- from rpc import RpcSender
9
- from context import Context
10
- from middleware import compose_middleware
11
- from rpc_stream_manager import RpcStreamManager
12
- from dot_dict import DotDict
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.2-beta.94",
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
- }