• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Duit-Foundation / duit_kernel / 20897307069

11 Jan 2026 03:13PM UTC coverage: 75.211% (-1.5%) from 76.681%
20897307069

push

github

web-flow
feat: Migration to capability-based API pt3 (#52)

* feat: Add scripting and transport capabilities

* Introduced ScriptingCapabilityDelegate with methods for script evaluation and execution.
* Added TransportCapabilityDelegate for server communication and resource management.
* Updated index.dart to export new capabilities.
* Enhanced UIDriver to include new capability delegates.

* wip

* wip

* wip

* refactor: Update logging methods for consistency

* Replaced instances of `driver.error` with `driver.logError` for improved logging consistency.
* Updated logging method names in `LoggingManager` and `LoggingCapabilityDelegate` to include the `log` prefix.
* Adjusted logging calls in `DuitRegistry` to reflect the new method names.

* wip

3 of 66 new or added lines in 9 files covered. (4.55%)

2 existing lines in 2 files now uncovered.

1781 of 2368 relevant lines covered (75.21%)

4.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/src/action_api/action_executor.dart
1
import "package:duit_kernel/duit_kernel.dart";
2

3
/// The [ActionExecutor] is an abstract class responsible for executing actions.
4
///
5
/// It relies on a [UIDriver] to perform actions and an DebugLogger to log messages.
6
/// This class serves as a base for concrete implementations that define how actions
7
/// should be executed.
8
///
9
/// Subclasses must implement the [executeAction] method to handle different types
10
/// of [ServerAction]s.
11
abstract class ActionExecutor {
12
  final UIDriver driver;
13
  @Deprecated("Use [LoggingCapabilityDelegate] instead")
14
  final DebugLogger? logger;
15

16
  ActionExecutor({
×
17
    required this.driver,
18
    this.logger,
19
  });
20

21
  Future<ServerEvent?> executeAction(
22
    ServerAction action,
23
  );
24
}
25

26
/// Executes a given [ServerAction].
27
///
28
/// The [executeAction] method takes a [ServerAction] as a parameter and
29
/// performs the necessary operations to execute it. This is an abstract
30
/// method that must be implemented by subclasses. It relies on the [UIDriver]
31
/// to resolve the event associated with the action and perform the execution.
32
///
33
/// Implementations should handle different types of actions, such as
34
/// [TransportAction], by using switch cases or other control flow mechanisms.
35
///
36
/// This method is asynchronous and returns a [Future] that completes when
37
/// the action execution is finished.
38
final class DefaultActionExecutor extends ActionExecutor {
39
  DefaultActionExecutor({
×
40
    required super.driver,
41
    super.logger,
42
  });
43

44
  @override
×
45
  Future<ServerEvent?> executeAction(
46
    ServerAction action,
47
  ) async {
48
    switch (action) {
49
      //transport
50
      case TransportAction():
×
51
        try {
52
          final payload = driver.preparePayload(action.dependsOn);
×
53

54
          final res = await driver.transport?.execute(action, payload);
×
55

56
          if (res != null) {
57
            return ServerEvent.parseEvent(res);
×
58
          }
59

60
          return null;
61
        } catch (e, s) {
NEW
62
          driver.logError(
×
63
            "[Error while executing transport action]",
64
            e,
65
            s,
66
          );
67
        }
68

69
        break;
70
      //local execution
71
      case LocalAction():
×
72
        try {
73
          return action.event;
×
74
        } catch (e, s) {
NEW
75
          driver.logError(
×
76
            "[Error while executing local action]",
77
            e,
78
            s,
79
          );
80
        }
81
        break;
82
      //script
83
      case ScriptAction():
×
84
        try {
85
          final body = driver.preparePayload(action.dependsOn);
×
86
          final script = action.script;
×
87

88
          final scriptInvocationResult = await driver.scriptRunner?.runScript(
×
89
            script.functionName,
×
90
            url: action.eventName,
×
91
            meta: action.script.meta,
×
92
            body: body,
93
          );
94

95
          if (scriptInvocationResult != null) {
96
            return ServerEvent.parseEvent(scriptInvocationResult);
×
97
          }
98

99
          return null;
100
        } catch (e, s) {
NEW
101
          driver.logError(
×
102
            "[Error while executing script action]",
103
            e,
104
            s,
105
          );
106
        }
107
        break;
108
    }
109

110
    return null;
111
  }
112
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc