add: adding contracts package extracted contracts from existing code
This commit is contained in:
parent
28f693a681
commit
0e7971b928
27 changed files with 2762 additions and 0 deletions
71
packages/contracts/lib/contracts.dart
Normal file
71
packages/contracts/lib/contracts.dart
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/// Platform Contracts Library
|
||||||
|
///
|
||||||
|
/// This library provides the core contracts (interfaces) that define
|
||||||
|
/// the Platform framework's API. These contracts ensure consistency
|
||||||
|
/// and interoperability between components while enabling loose coupling
|
||||||
|
/// and dependency injection.
|
||||||
|
|
||||||
|
// Level 0: Core Foundation Contracts
|
||||||
|
|
||||||
|
// Container contracts (from packages/container)
|
||||||
|
export 'src/container/container.dart';
|
||||||
|
|
||||||
|
// Reflection contracts (from packages/container)
|
||||||
|
export 'src/reflection/reflection.dart';
|
||||||
|
|
||||||
|
// Pipeline contracts (from packages/pipeline)
|
||||||
|
export 'src/pipeline/pipeline.dart';
|
||||||
|
|
||||||
|
// Level 1: Infrastructure Contracts
|
||||||
|
|
||||||
|
// Events contracts (from packages/events)
|
||||||
|
export 'src/events/events.dart';
|
||||||
|
|
||||||
|
// Bus contracts (from packages/bus)
|
||||||
|
export 'src/bus/bus.dart';
|
||||||
|
|
||||||
|
// Model contracts (from packages/model)
|
||||||
|
export 'src/model/model.dart';
|
||||||
|
|
||||||
|
// Process contracts (from packages/process)
|
||||||
|
export 'src/process/process.dart';
|
||||||
|
|
||||||
|
// Support contracts (from packages/support)
|
||||||
|
export 'src/support/support.dart';
|
||||||
|
|
||||||
|
// Level 2: Core Services Contracts
|
||||||
|
|
||||||
|
// Queue contracts (from packages/queue)
|
||||||
|
export 'src/queue/queue.dart';
|
||||||
|
|
||||||
|
// Level 3: HTTP Layer Contracts
|
||||||
|
|
||||||
|
// Routing contracts (from packages/route)
|
||||||
|
export 'src/routing/routing.dart';
|
||||||
|
|
||||||
|
// HTTP contracts (from packages/core)
|
||||||
|
export 'src/http/http.dart';
|
||||||
|
|
||||||
|
// Testing Contracts
|
||||||
|
|
||||||
|
// Testing contracts (from packages/testing)
|
||||||
|
export 'src/testing/testing.dart';
|
||||||
|
|
||||||
|
// All contracts have been extracted from implemented packages:
|
||||||
|
// - Container & Reflection (Level 0)
|
||||||
|
// - Pipeline (Level 0)
|
||||||
|
// - Events (Level 1)
|
||||||
|
// - Bus (Level 1)
|
||||||
|
// - Model (Level 1)
|
||||||
|
// - Process (Level 1)
|
||||||
|
// - Support (Level 1)
|
||||||
|
// - Queue (Level 2)
|
||||||
|
// - Route (Level 3)
|
||||||
|
// - HTTP (Level 3)
|
||||||
|
// - Testing
|
||||||
|
|
||||||
|
// Next steps:
|
||||||
|
// 1. Update package dependencies to use these contracts
|
||||||
|
// 2. Implement contracts in each package
|
||||||
|
// 3. Add contract compliance tests
|
||||||
|
// 4. Document contract usage and patterns
|
2
packages/contracts/lib/src/bus/bus.dart
Normal file
2
packages/contracts/lib/src/bus/bus.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Bus package contracts
|
||||||
|
export 'bus_contract.dart';
|
196
packages/contracts/lib/src/bus/bus_contract.dart
Normal file
196
packages/contracts/lib/src/bus/bus_contract.dart
Normal file
|
@ -0,0 +1,196 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for commands.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Base interface for command objects that can be
|
||||||
|
/// dispatched through the command bus.
|
||||||
|
@sealed
|
||||||
|
abstract class CommandContract {}
|
||||||
|
|
||||||
|
/// Contract for queueable commands.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Marks commands that should be processed
|
||||||
|
/// through the queue system.
|
||||||
|
@sealed
|
||||||
|
abstract class ShouldQueueCommand implements CommandContract {}
|
||||||
|
|
||||||
|
/// Contract for command handlers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines how command handlers should process
|
||||||
|
/// their associated commands, with platform-specific typing.
|
||||||
|
@sealed
|
||||||
|
abstract class HandlerContract {
|
||||||
|
/// Handles a command.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core handler method with platform-specific
|
||||||
|
/// return type for more flexibility.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [command]: The command to handle.
|
||||||
|
Future<dynamic> handle(CommandContract command);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Type definition for command pipe functions.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines transformation functions that can modify
|
||||||
|
/// commands as they flow through the pipeline.
|
||||||
|
typedef CommandPipe = CommandContract Function(CommandContract);
|
||||||
|
|
||||||
|
/// Contract for command dispatching.
|
||||||
|
///
|
||||||
|
/// This contract defines the core interface for dispatching
|
||||||
|
/// and processing commands through the command bus.
|
||||||
|
@sealed
|
||||||
|
abstract class CommandDispatcherContract {
|
||||||
|
/// Dispatches a command.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core dispatch method.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [command]: The command to dispatch.
|
||||||
|
Future<dynamic> dispatch(CommandContract command);
|
||||||
|
|
||||||
|
/// Dispatches a command synchronously.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides explicit sync dispatch with optional handler.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [command]: The command to dispatch.
|
||||||
|
/// - [handler]: Optional specific handler.
|
||||||
|
Future<dynamic> dispatchSync(CommandContract command,
|
||||||
|
[HandlerContract? handler]);
|
||||||
|
|
||||||
|
/// Dispatches a command immediately.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Immediate dispatch without queueing.
|
||||||
|
/// Extended with optional handler parameter.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [command]: The command to dispatch.
|
||||||
|
/// - [handler]: Optional specific handler.
|
||||||
|
Future<dynamic> dispatchNow(CommandContract command,
|
||||||
|
[HandlerContract? handler]);
|
||||||
|
|
||||||
|
/// Dispatches a command to queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Queue-based dispatch.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [command]: The command to queue.
|
||||||
|
Future<dynamic> dispatchToQueue(CommandContract command);
|
||||||
|
|
||||||
|
/// Finds a command batch.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides batch lookup functionality.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [batchId]: The batch ID to find.
|
||||||
|
Future<CommandBatchContract?> findBatch(String batchId);
|
||||||
|
|
||||||
|
/// Creates a command batch.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Creates command batches.
|
||||||
|
/// Extended with platform-specific batch contract.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [commands]: Commands to include in batch.
|
||||||
|
PendingCommandBatchContract batch(List<CommandContract> commands);
|
||||||
|
|
||||||
|
/// Creates a command chain.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Creates command chains.
|
||||||
|
/// Extended with platform-specific chain contract.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [commands]: Commands to chain.
|
||||||
|
CommandChainContract chain(List<CommandContract> commands);
|
||||||
|
|
||||||
|
/// Maps command types to handlers.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides explicit handler mapping.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [handlers]: Map of command types to handler types.
|
||||||
|
CommandDispatcherContract map(Map<Type, Type> handlers);
|
||||||
|
|
||||||
|
/// Applies transformation pipes to commands.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Adds pipeline transformation support.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [pipes]: List of command transformation functions.
|
||||||
|
CommandDispatcherContract pipeThrough(List<CommandPipe> pipes);
|
||||||
|
|
||||||
|
/// Dispatches after current response.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Delayed dispatch after response.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [command]: Command to dispatch later.
|
||||||
|
void dispatchAfterResponse(CommandContract command);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for command batches.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines batch structure and operations.
|
||||||
|
/// Extended with additional status tracking.
|
||||||
|
@sealed
|
||||||
|
abstract class CommandBatchContract {
|
||||||
|
/// Gets the batch ID.
|
||||||
|
String get id;
|
||||||
|
|
||||||
|
/// Gets commands in the batch.
|
||||||
|
List<CommandContract> get commands;
|
||||||
|
|
||||||
|
/// Gets batch status.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides detailed status tracking.
|
||||||
|
String get status;
|
||||||
|
|
||||||
|
/// Whether batch allows failures.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Controls batch failure handling.
|
||||||
|
bool get allowsFailures;
|
||||||
|
|
||||||
|
/// Gets finished command count.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Tracks completion progress.
|
||||||
|
int get finished;
|
||||||
|
|
||||||
|
/// Gets failed command count.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Tracks failure count.
|
||||||
|
int get failed;
|
||||||
|
|
||||||
|
/// Gets pending command count.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Tracks remaining commands.
|
||||||
|
int get pending;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for pending command batches.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines batch configuration and dispatch.
|
||||||
|
@sealed
|
||||||
|
abstract class PendingCommandBatchContract {
|
||||||
|
/// Allows failures in batch.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Configures failure handling.
|
||||||
|
PendingCommandBatchContract allowFailures();
|
||||||
|
|
||||||
|
/// Dispatches the batch.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Executes the batch.
|
||||||
|
Future<void> dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for command chains.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines sequential command execution.
|
||||||
|
@sealed
|
||||||
|
abstract class CommandChainContract {
|
||||||
|
/// Dispatches the chain.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Executes commands in sequence.
|
||||||
|
Future<void> dispatch();
|
||||||
|
}
|
3
packages/contracts/lib/src/container/container.dart
Normal file
3
packages/contracts/lib/src/container/container.dart
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
/// Container package contracts
|
||||||
|
export 'container_contract.dart';
|
||||||
|
export 'contextual_binding_contract.dart';
|
134
packages/contracts/lib/src/container/container_contract.dart
Normal file
134
packages/contracts/lib/src/container/container_contract.dart
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import '../reflection/reflector_contract.dart';
|
||||||
|
|
||||||
|
/// Core container contract defining dependency injection functionality.
|
||||||
|
///
|
||||||
|
/// This contract defines the interface that all dependency injection containers
|
||||||
|
/// must implement. It provides methods for registering and resolving dependencies,
|
||||||
|
/// creating child containers, and managing named instances.
|
||||||
|
@sealed
|
||||||
|
abstract class ContainerContract {
|
||||||
|
/// Gets the reflector instance used by this container.
|
||||||
|
ReflectorContract get reflector;
|
||||||
|
|
||||||
|
/// Whether this is a root container (has no parent).
|
||||||
|
bool get isRoot;
|
||||||
|
|
||||||
|
/// Creates a child container that inherits from this container.
|
||||||
|
///
|
||||||
|
/// The child container can access all dependencies registered in its parent containers,
|
||||||
|
/// but can also define its own dependencies that override or extend the parent's.
|
||||||
|
/// This enables scoped dependency injection contexts.
|
||||||
|
ContainerContract createChild();
|
||||||
|
|
||||||
|
/// Checks if a type is registered in this container or its parents.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [T]: The type to check for. If [T] is dynamic, [t] must be provided.
|
||||||
|
/// - [t]: Optional type parameter that overrides [T] if provided.
|
||||||
|
///
|
||||||
|
/// Returns true if the type is registered, false otherwise.
|
||||||
|
bool has<T>([Type? t]);
|
||||||
|
|
||||||
|
/// Checks if a named instance exists in this container or its parents.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [name]: The name to check for.
|
||||||
|
///
|
||||||
|
/// Returns true if a named instance exists, false otherwise.
|
||||||
|
bool hasNamed(String name);
|
||||||
|
|
||||||
|
/// Makes an instance of type [T].
|
||||||
|
///
|
||||||
|
/// This will:
|
||||||
|
/// 1. Return a singleton if registered
|
||||||
|
/// 2. Create an instance via factory if registered
|
||||||
|
/// 3. Use reflection to create a new instance
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [type]: Optional type parameter that overrides [T] if provided.
|
||||||
|
///
|
||||||
|
/// Throws:
|
||||||
|
/// - ReflectionException if [T] is not a class or has no default constructor
|
||||||
|
T make<T>([Type? type]);
|
||||||
|
|
||||||
|
/// Makes an instance of type [T] asynchronously.
|
||||||
|
///
|
||||||
|
/// This will attempt to resolve a Future<T> in the following order:
|
||||||
|
/// 1. Wrap a synchronous [T] in Future
|
||||||
|
/// 2. Return a registered Future<T>
|
||||||
|
/// 3. Create a Future<T> via reflection
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [type]: Optional type parameter that overrides [T] if provided.
|
||||||
|
///
|
||||||
|
/// Throws:
|
||||||
|
/// - ReflectionException if no suitable injection is found
|
||||||
|
Future<T> makeAsync<T>([Type? type]);
|
||||||
|
|
||||||
|
/// Registers a singleton instance.
|
||||||
|
///
|
||||||
|
/// The instance will be shared across the container hierarchy.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [object]: The singleton instance to register.
|
||||||
|
/// - [as]: Optional type to register the singleton as.
|
||||||
|
///
|
||||||
|
/// Returns the registered instance.
|
||||||
|
///
|
||||||
|
/// Throws:
|
||||||
|
/// - StateError if a singleton is already registered for the type
|
||||||
|
T registerSingleton<T>(T object, {Type? as});
|
||||||
|
|
||||||
|
/// Registers a factory function.
|
||||||
|
///
|
||||||
|
/// The factory will be called each time an instance is needed.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [factory]: Function that creates instances.
|
||||||
|
/// - [as]: Optional type to register the factory as.
|
||||||
|
///
|
||||||
|
/// Returns the factory function.
|
||||||
|
///
|
||||||
|
/// Throws:
|
||||||
|
/// - StateError if a factory is already registered for the type
|
||||||
|
T Function(ContainerContract) registerFactory<T>(
|
||||||
|
T Function(ContainerContract) factory,
|
||||||
|
{Type? as});
|
||||||
|
|
||||||
|
/// Registers a lazy singleton.
|
||||||
|
///
|
||||||
|
/// The singleton will be created on first use.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [factory]: Function that creates the singleton.
|
||||||
|
/// - [as]: Optional type to register the singleton as.
|
||||||
|
///
|
||||||
|
/// Returns the factory function.
|
||||||
|
T Function(ContainerContract) registerLazySingleton<T>(
|
||||||
|
T Function(ContainerContract) factory,
|
||||||
|
{Type? as});
|
||||||
|
|
||||||
|
/// Gets a named singleton.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [name]: The name of the singleton to retrieve.
|
||||||
|
///
|
||||||
|
/// Returns the named singleton instance.
|
||||||
|
///
|
||||||
|
/// Throws:
|
||||||
|
/// - StateError if no singleton exists with the given name
|
||||||
|
T findByName<T>(String name);
|
||||||
|
|
||||||
|
/// Registers a named singleton.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [name]: The name to register the singleton under.
|
||||||
|
/// - [object]: The singleton instance.
|
||||||
|
///
|
||||||
|
/// Returns the registered instance.
|
||||||
|
///
|
||||||
|
/// Throws:
|
||||||
|
/// - StateError if a singleton already exists with the given name
|
||||||
|
T registerNamedSingleton<T>(String name, T object);
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for contextual binding in dependency injection.
|
||||||
|
///
|
||||||
|
/// This contract defines the interface for creating contextual bindings,
|
||||||
|
/// allowing dependencies to be resolved differently based on context.
|
||||||
|
@sealed
|
||||||
|
abstract class ContextualBindingContract {
|
||||||
|
/// Specifies the concrete type that triggers this contextual binding.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [concrete]: The concrete type that needs dependencies.
|
||||||
|
///
|
||||||
|
/// Returns a builder for specifying what type is needed.
|
||||||
|
ContextualNeedsContract when(Type concrete);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for specifying contextual needs.
|
||||||
|
///
|
||||||
|
/// This contract defines the interface for specifying what type
|
||||||
|
/// is needed in a particular context.
|
||||||
|
@sealed
|
||||||
|
abstract class ContextualNeedsContract {
|
||||||
|
/// Specifies the type needed in this context.
|
||||||
|
///
|
||||||
|
/// Returns a builder for specifying what to give.
|
||||||
|
ContextualGiveContract needs<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for specifying contextual implementations.
|
||||||
|
///
|
||||||
|
/// This contract defines the interface for specifying what
|
||||||
|
/// implementation to provide in a particular context.
|
||||||
|
@sealed
|
||||||
|
abstract class ContextualGiveContract {
|
||||||
|
/// Specifies what to give for this contextual binding.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [implementation]: The implementation to provide.
|
||||||
|
/// This can be an instance, a factory function, or a type.
|
||||||
|
void give(dynamic implementation);
|
||||||
|
}
|
199
packages/contracts/lib/src/events/event_dispatcher_contract.dart
Normal file
199
packages/contracts/lib/src/events/event_dispatcher_contract.dart
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for event dispatching functionality.
|
||||||
|
///
|
||||||
|
/// This contract defines the interface for dispatching events,
|
||||||
|
/// managing listeners, and handling event broadcasting.
|
||||||
|
///
|
||||||
|
/// The contract includes both Laravel-compatible methods and platform-specific
|
||||||
|
/// extensions for enhanced functionality.
|
||||||
|
@sealed
|
||||||
|
abstract class EventDispatcherContract {
|
||||||
|
/// Registers an event listener.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Registers event listeners, but with platform-specific
|
||||||
|
/// dynamic typing for more flexible event handling.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [events]: Event type or list of event types to listen for.
|
||||||
|
/// - [listener]: Function to handle the event.
|
||||||
|
void listen(dynamic events, dynamic listener);
|
||||||
|
|
||||||
|
/// Checks if event has listeners.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides listener existence checking.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [eventName]: Name of the event to check.
|
||||||
|
bool hasListeners(String eventName);
|
||||||
|
|
||||||
|
/// Pushes an event for delayed processing.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Supports delayed event processing.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [event]: Name of the event.
|
||||||
|
/// - [payload]: Optional event payload.
|
||||||
|
void push(String event, [dynamic payload]);
|
||||||
|
|
||||||
|
/// Flushes delayed events.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Processes delayed events immediately.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [event]: Name of the event to flush.
|
||||||
|
Future<void> flush(String event);
|
||||||
|
|
||||||
|
/// Subscribes an event subscriber.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Registers event subscribers, but with platform-specific
|
||||||
|
/// dynamic typing for more flexible subscription handling.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [subscriber]: The subscriber to register.
|
||||||
|
void subscribe(dynamic subscriber);
|
||||||
|
|
||||||
|
/// Waits for an event to occur.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides event waiting functionality.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [event]: Event to wait for.
|
||||||
|
/// - [payload]: Optional payload to dispatch.
|
||||||
|
Future<dynamic> until(dynamic event, [dynamic payload]);
|
||||||
|
|
||||||
|
/// Dispatches an event.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Dispatches events, with platform-specific
|
||||||
|
/// extensions for halting and payload handling.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [event]: Event to dispatch.
|
||||||
|
/// - [payload]: Optional event payload.
|
||||||
|
/// - [halt]: Whether to halt after first handler.
|
||||||
|
Future<dynamic> dispatch(dynamic event, [dynamic payload, bool? halt]);
|
||||||
|
|
||||||
|
/// Gets registered listeners.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Retrieves event listeners.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [eventName]: Name of the event.
|
||||||
|
List<Function> getListeners(String eventName);
|
||||||
|
|
||||||
|
/// Removes an event listener.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Removes event listeners.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [event]: Event to remove listener for.
|
||||||
|
void forget(String event);
|
||||||
|
|
||||||
|
/// Removes pushed event listeners.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Cleans up delayed event listeners.
|
||||||
|
void forgetPushed();
|
||||||
|
|
||||||
|
/// Sets queue resolver.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Configures queue integration.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [resolver]: Queue resolver function.
|
||||||
|
void setQueueResolver(Function resolver);
|
||||||
|
|
||||||
|
/// Sets transaction manager resolver.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Configures transaction integration.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [resolver]: Transaction manager resolver function.
|
||||||
|
void setTransactionManagerResolver(Function resolver);
|
||||||
|
|
||||||
|
/// Gets raw event listeners.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides access to raw listener data.
|
||||||
|
Map<String, List<Function>> getRawListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for event subscribers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines how event subscribers register
|
||||||
|
/// their event handling methods.
|
||||||
|
@sealed
|
||||||
|
abstract class EventSubscriberContract {
|
||||||
|
/// Subscribes to events.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Returns event handler mappings.
|
||||||
|
///
|
||||||
|
/// Returns a map of event types to handler functions.
|
||||||
|
Map<Type, Function> subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Marker interface for broadcastable events.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Events implementing this interface will be broadcast
|
||||||
|
/// across the application.
|
||||||
|
@sealed
|
||||||
|
abstract class ShouldBroadcast {
|
||||||
|
/// Gets channels to broadcast on.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines broadcast channels.
|
||||||
|
List<String> broadcastOn();
|
||||||
|
|
||||||
|
/// Gets event name for broadcasting.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines broadcast event name.
|
||||||
|
String broadcastAs() => runtimeType.toString();
|
||||||
|
|
||||||
|
/// Gets broadcast data.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines broadcast payload.
|
||||||
|
Map<String, dynamic> get broadcastWith => {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Marker interface for queueable events.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Events implementing this interface will be processed
|
||||||
|
/// through the queue system.
|
||||||
|
@sealed
|
||||||
|
abstract class ShouldQueue {
|
||||||
|
/// Gets the queue name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines target queue.
|
||||||
|
String get queue => 'default';
|
||||||
|
|
||||||
|
/// Gets the processing delay.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines queue delay.
|
||||||
|
Duration? get delay => null;
|
||||||
|
|
||||||
|
/// Gets maximum retry attempts.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines retry limit.
|
||||||
|
int get tries => 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Marker interface for encrypted events.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Events implementing this interface will be encrypted
|
||||||
|
/// before being stored or transmitted.
|
||||||
|
@sealed
|
||||||
|
abstract class ShouldBeEncrypted {
|
||||||
|
/// Whether the event should be encrypted.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Controls event encryption.
|
||||||
|
bool get shouldBeEncrypted => true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Marker interface for events that should dispatch after commit.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Events implementing this interface will only be dispatched
|
||||||
|
/// after the current database transaction commits.
|
||||||
|
@sealed
|
||||||
|
abstract class ShouldDispatchAfterCommit {
|
||||||
|
/// Whether to dispatch after commit.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Controls transaction-based dispatch.
|
||||||
|
bool get afterCommit => true;
|
||||||
|
}
|
2
packages/contracts/lib/src/events/events.dart
Normal file
2
packages/contracts/lib/src/events/events.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Events package contracts
|
||||||
|
export 'event_dispatcher_contract.dart';
|
2
packages/contracts/lib/src/http/http.dart
Normal file
2
packages/contracts/lib/src/http/http.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// HTTP package contracts
|
||||||
|
export 'http_contract.dart';
|
299
packages/contracts/lib/src/http/http_contract.dart
Normal file
299
packages/contracts/lib/src/http/http_contract.dart
Normal file
|
@ -0,0 +1,299 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for HTTP requests.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core request functionality matching Laravel's Request
|
||||||
|
/// interface, with platform-specific stream handling.
|
||||||
|
@sealed
|
||||||
|
abstract class RequestContract {
|
||||||
|
/// Gets the request method.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: HTTP method accessor.
|
||||||
|
String get method;
|
||||||
|
|
||||||
|
/// Gets the request URI.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Request URI using Dart's Uri class.
|
||||||
|
Uri get uri;
|
||||||
|
|
||||||
|
/// Gets request headers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Header access with platform-specific
|
||||||
|
/// multi-value support.
|
||||||
|
Map<String, List<String>> get headers;
|
||||||
|
|
||||||
|
/// Gets query parameters.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Query parameter access.
|
||||||
|
Map<String, String> get query;
|
||||||
|
|
||||||
|
/// Gets POST data.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: POST data access.
|
||||||
|
Map<String, dynamic> get post;
|
||||||
|
|
||||||
|
/// Gets cookies.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Cookie access.
|
||||||
|
Map<String, String> get cookies;
|
||||||
|
|
||||||
|
/// Gets uploaded files.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: File upload handling with
|
||||||
|
/// platform-specific contract.
|
||||||
|
Map<String, UploadedFileContract> get files;
|
||||||
|
|
||||||
|
/// Gets the request body.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Stream-based body access.
|
||||||
|
Stream<List<int>> get body;
|
||||||
|
|
||||||
|
/// Gets a request header.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Single header access.
|
||||||
|
String? header(String name, [String? defaultValue]);
|
||||||
|
|
||||||
|
/// Gets a query parameter.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Single query parameter access.
|
||||||
|
String? query_(String name, [String? defaultValue]);
|
||||||
|
|
||||||
|
/// Gets a POST value.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Single POST value access.
|
||||||
|
dynamic post_(String name, [dynamic defaultValue]);
|
||||||
|
|
||||||
|
/// Gets a cookie value.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Single cookie access.
|
||||||
|
String? cookie(String name, [String? defaultValue]);
|
||||||
|
|
||||||
|
/// Gets an uploaded file.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Single file access.
|
||||||
|
UploadedFileContract? file(String name);
|
||||||
|
|
||||||
|
/// Gets all input data (query + post).
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Combined input access.
|
||||||
|
Map<String, dynamic> all();
|
||||||
|
|
||||||
|
/// Gets input value from any source.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Universal input access.
|
||||||
|
dynamic input(String name, [dynamic defaultValue]);
|
||||||
|
|
||||||
|
/// Checks if input exists.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Input existence check.
|
||||||
|
bool has(String name);
|
||||||
|
|
||||||
|
/// Gets the raw request body as string.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Async text body access.
|
||||||
|
Future<String> text();
|
||||||
|
|
||||||
|
/// Gets the request body as JSON.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Async JSON body access.
|
||||||
|
Future<dynamic> json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for HTTP responses.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core response functionality matching Laravel's Response
|
||||||
|
/// interface, with platform-specific async features.
|
||||||
|
@sealed
|
||||||
|
abstract class ResponseContract {
|
||||||
|
/// Gets response headers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Header access with platform-specific
|
||||||
|
/// multi-value support.
|
||||||
|
Map<String, List<String>> get headers;
|
||||||
|
|
||||||
|
/// Gets the status code.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Status code accessor.
|
||||||
|
int get status;
|
||||||
|
|
||||||
|
/// Sets the status code.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Status code mutator.
|
||||||
|
set status(int value);
|
||||||
|
|
||||||
|
/// Sets a response header.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Single header setting.
|
||||||
|
void header(String name, String value);
|
||||||
|
|
||||||
|
/// Sets multiple headers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Bulk header setting.
|
||||||
|
void headers_(Map<String, String> headers);
|
||||||
|
|
||||||
|
/// Sets a cookie.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Cookie setting with platform-specific
|
||||||
|
/// security options.
|
||||||
|
void cookie(
|
||||||
|
String name,
|
||||||
|
String value, {
|
||||||
|
Duration? maxAge,
|
||||||
|
DateTime? expires,
|
||||||
|
String? domain,
|
||||||
|
String? path,
|
||||||
|
bool secure = false,
|
||||||
|
bool httpOnly = false,
|
||||||
|
String? sameSite,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Writes response body content.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Content writing.
|
||||||
|
void write(dynamic content);
|
||||||
|
|
||||||
|
/// Sends JSON response.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: JSON response.
|
||||||
|
void json(dynamic data);
|
||||||
|
|
||||||
|
/// Sends file download.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: File download with platform-specific
|
||||||
|
/// async handling.
|
||||||
|
Future<void> download(String path, [String? name]);
|
||||||
|
|
||||||
|
/// Redirects to another URL.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Redirect response.
|
||||||
|
void redirect(String url, [int status = 302]);
|
||||||
|
|
||||||
|
/// Sends the response.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Async response sending.
|
||||||
|
Future<void> send();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for uploaded files.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: File upload handling matching Laravel's UploadedFile
|
||||||
|
/// interface, with platform-specific async operations.
|
||||||
|
@sealed
|
||||||
|
abstract class UploadedFileContract {
|
||||||
|
/// Gets the original client filename.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Original filename.
|
||||||
|
String get filename;
|
||||||
|
|
||||||
|
/// Gets the file MIME type.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: MIME type.
|
||||||
|
String get mimeType;
|
||||||
|
|
||||||
|
/// Gets the file size in bytes.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: File size.
|
||||||
|
int get size;
|
||||||
|
|
||||||
|
/// Gets temporary file path.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Temporary storage.
|
||||||
|
String get path;
|
||||||
|
|
||||||
|
/// Moves file to new location.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: File movement with platform-specific
|
||||||
|
/// async handling.
|
||||||
|
Future<void> moveTo(String path);
|
||||||
|
|
||||||
|
/// Gets file contents as bytes.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Async binary content access.
|
||||||
|
Future<List<int>> bytes();
|
||||||
|
|
||||||
|
/// Gets file contents as string.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Async text content access.
|
||||||
|
Future<String> text();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for HTTP middleware.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Middleware functionality matching Laravel's Middleware
|
||||||
|
/// interface, with platform-specific async handling.
|
||||||
|
@sealed
|
||||||
|
abstract class MiddlewareContract {
|
||||||
|
/// Handles the request.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Middleware handling with platform-specific
|
||||||
|
/// async processing.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [request]: The incoming request.
|
||||||
|
/// - [next]: Function to pass to next middleware.
|
||||||
|
Future<ResponseContract> handle(RequestContract request,
|
||||||
|
Future<ResponseContract> Function(RequestContract) next);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for HTTP kernel.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: HTTP kernel functionality matching Laravel's HttpKernel
|
||||||
|
/// interface, with platform-specific async processing.
|
||||||
|
@sealed
|
||||||
|
abstract class HttpKernelContract {
|
||||||
|
/// Gets global middleware.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Global middleware list.
|
||||||
|
List<MiddlewareContract> get middleware;
|
||||||
|
|
||||||
|
/// Gets middleware groups.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Middleware grouping.
|
||||||
|
Map<String, List<MiddlewareContract>> get middlewareGroups;
|
||||||
|
|
||||||
|
/// Gets route middleware.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route middleware mapping.
|
||||||
|
Map<String, MiddlewareContract> get routeMiddleware;
|
||||||
|
|
||||||
|
/// Handles an HTTP request.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Request handling with platform-specific
|
||||||
|
/// async processing.
|
||||||
|
Future<ResponseContract> handle(RequestContract request);
|
||||||
|
|
||||||
|
/// Terminates the request/response cycle.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Request termination with platform-specific
|
||||||
|
/// async processing.
|
||||||
|
Future<ResponseContract> terminate(
|
||||||
|
RequestContract request, ResponseContract response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for HTTP context.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides request context beyond Laravel's
|
||||||
|
/// standard request handling.
|
||||||
|
@sealed
|
||||||
|
abstract class HttpContextContract {
|
||||||
|
/// Gets the current request.
|
||||||
|
RequestContract get request;
|
||||||
|
|
||||||
|
/// Gets the current response.
|
||||||
|
ResponseContract get response;
|
||||||
|
|
||||||
|
/// Gets context attributes.
|
||||||
|
Map<String, dynamic> get attributes;
|
||||||
|
|
||||||
|
/// Gets a context attribute.
|
||||||
|
T? getAttribute<T>(String key);
|
||||||
|
|
||||||
|
/// Sets a context attribute.
|
||||||
|
void setAttribute(String key, dynamic value);
|
||||||
|
|
||||||
|
/// Gets the route parameters.
|
||||||
|
Map<String, dynamic> get routeParams;
|
||||||
|
|
||||||
|
/// Gets a route parameter.
|
||||||
|
T? getRouteParam<T>(String name);
|
||||||
|
}
|
2
packages/contracts/lib/src/model/model.dart
Normal file
2
packages/contracts/lib/src/model/model.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Model package contracts
|
||||||
|
export 'model_contract.dart';
|
148
packages/contracts/lib/src/model/model_contract.dart
Normal file
148
packages/contracts/lib/src/model/model_contract.dart
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for base model functionality.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Provides core model functionality similar to Laravel's
|
||||||
|
/// Model class, adapted for Dart's type system and patterns.
|
||||||
|
@sealed
|
||||||
|
abstract class ModelContract {
|
||||||
|
/// Gets the model's unique identifier.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Primary key accessor.
|
||||||
|
/// Extended with nullable String type for flexibility.
|
||||||
|
String? get id;
|
||||||
|
|
||||||
|
/// Sets the model's unique identifier.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Primary key mutator.
|
||||||
|
/// Extended with nullable String type for flexibility.
|
||||||
|
set id(String? value);
|
||||||
|
|
||||||
|
/// Gets the creation timestamp.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Created at timestamp accessor.
|
||||||
|
/// Uses Dart's DateTime instead of Carbon.
|
||||||
|
DateTime? get createdAt;
|
||||||
|
|
||||||
|
/// Sets the creation timestamp.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Created at timestamp mutator.
|
||||||
|
/// Uses Dart's DateTime instead of Carbon.
|
||||||
|
set createdAt(DateTime? value);
|
||||||
|
|
||||||
|
/// Gets the last update timestamp.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Updated at timestamp accessor.
|
||||||
|
/// Uses Dart's DateTime instead of Carbon.
|
||||||
|
DateTime? get updatedAt;
|
||||||
|
|
||||||
|
/// Sets the last update timestamp.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Updated at timestamp mutator.
|
||||||
|
/// Uses Dart's DateTime instead of Carbon.
|
||||||
|
set updatedAt(DateTime? value);
|
||||||
|
|
||||||
|
/// Gets the ID as an integer.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides integer ID conversion.
|
||||||
|
/// Returns -1 if ID is null or not a valid integer.
|
||||||
|
int get idAsInt;
|
||||||
|
|
||||||
|
/// Gets the ID as a string.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides string ID conversion.
|
||||||
|
/// Returns empty string if ID is null.
|
||||||
|
String get idAsString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for auditable model functionality.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Similar to Laravel's auditable trait,
|
||||||
|
/// providing user tracking for model changes.
|
||||||
|
@sealed
|
||||||
|
abstract class AuditableModelContract extends ModelContract {
|
||||||
|
/// Gets the ID of user who created the record.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Created by user tracking.
|
||||||
|
/// Uses String ID instead of user model reference.
|
||||||
|
String? get createdBy;
|
||||||
|
|
||||||
|
/// Sets the ID of user who created the record.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Created by user tracking.
|
||||||
|
/// Uses String ID instead of user model reference.
|
||||||
|
set createdBy(String? value);
|
||||||
|
|
||||||
|
/// Gets the ID of user who last updated the record.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Updated by user tracking.
|
||||||
|
/// Uses String ID instead of user model reference.
|
||||||
|
String? get updatedBy;
|
||||||
|
|
||||||
|
/// Sets the ID of user who last updated the record.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Updated by user tracking.
|
||||||
|
/// Uses String ID instead of user model reference.
|
||||||
|
set updatedBy(String? value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Optional contract for model serialization.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Similar to Laravel's serialization features,
|
||||||
|
/// adapted for Dart's type system.
|
||||||
|
@sealed
|
||||||
|
abstract class SerializableModelContract {
|
||||||
|
/// Converts model to a map.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Similar to toArray() method.
|
||||||
|
Map<String, dynamic> toMap();
|
||||||
|
|
||||||
|
/// Creates model from a map.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Similar to fill() method.
|
||||||
|
void fromMap(Map<String, dynamic> map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Optional contract for model validation.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides built-in validation support,
|
||||||
|
/// inspired by Laravel's validation but adapted for Dart.
|
||||||
|
@sealed
|
||||||
|
abstract class ValidatableModelContract {
|
||||||
|
/// Validates the model.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Returns validation errors if invalid.
|
||||||
|
Map<String, List<String>>? validate();
|
||||||
|
|
||||||
|
/// Gets validation rules.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines validation rules.
|
||||||
|
Map<String, List<String>> get rules;
|
||||||
|
|
||||||
|
/// Gets custom error messages.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines custom validation messages.
|
||||||
|
Map<String, String> get messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Optional contract for model events.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Similar to Laravel's model events,
|
||||||
|
/// adapted for Dart's event system.
|
||||||
|
@sealed
|
||||||
|
abstract class ObservableModelContract {
|
||||||
|
/// Gets the event name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines event identifier.
|
||||||
|
String get eventName;
|
||||||
|
|
||||||
|
/// Gets the event timestamp.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Adds timestamp tracking to events.
|
||||||
|
DateTime get eventTimestamp;
|
||||||
|
|
||||||
|
/// Gets event data.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Provides event payload.
|
||||||
|
Map<String, dynamic> get eventData;
|
||||||
|
}
|
2
packages/contracts/lib/src/pipeline/pipeline.dart
Normal file
2
packages/contracts/lib/src/pipeline/pipeline.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Pipeline package contracts
|
||||||
|
export 'pipeline_contract.dart';
|
127
packages/contracts/lib/src/pipeline/pipeline_contract.dart
Normal file
127
packages/contracts/lib/src/pipeline/pipeline_contract.dart
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for a pipe that processes objects in a pipeline.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core pipe functionality matching Laravel's
|
||||||
|
/// pipe interface, with platform-specific async handling.
|
||||||
|
@sealed
|
||||||
|
abstract class PipeContract {
|
||||||
|
/// Handles the passable object.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core pipe handling with platform-specific
|
||||||
|
/// async processing.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [passable]: The object being passed through the pipeline.
|
||||||
|
/// - [next]: Function to pass the object to the next pipe.
|
||||||
|
///
|
||||||
|
/// Returns the processed object, possibly modified.
|
||||||
|
Future<dynamic> handle(
|
||||||
|
dynamic passable, Future<dynamic> Function(dynamic) next);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for a pipeline that processes objects through a series of pipes.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core pipeline functionality matching Laravel's
|
||||||
|
/// Pipeline class, with platform-specific fluent interface.
|
||||||
|
@sealed
|
||||||
|
abstract class PipelineContract {
|
||||||
|
/// Sets the object to be passed through the pipeline.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Pipeline input setting.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [passable]: The object to process.
|
||||||
|
///
|
||||||
|
/// Returns the pipeline instance for fluent chaining.
|
||||||
|
PipelineContract send(dynamic passable);
|
||||||
|
|
||||||
|
/// Sets the array of pipes to process the object through.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Pipe configuration with platform-specific
|
||||||
|
/// flexibility for pipe types.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [pipes]: The pipes to process the object through.
|
||||||
|
/// Can be a single pipe or an iterable of pipes.
|
||||||
|
///
|
||||||
|
/// Returns the pipeline instance for fluent chaining.
|
||||||
|
PipelineContract through(dynamic pipes);
|
||||||
|
|
||||||
|
/// Adds additional pipes to the pipeline.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Additional method for pipe configuration
|
||||||
|
/// following Laravel's fluent pattern.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [pipes]: The pipes to add.
|
||||||
|
/// Can be a single pipe or an iterable of pipes.
|
||||||
|
///
|
||||||
|
/// Returns the pipeline instance for fluent chaining.
|
||||||
|
PipelineContract pipe(dynamic pipes);
|
||||||
|
|
||||||
|
/// Sets the method to call on the pipes.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Method name configuration.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [method]: The name of the method to call.
|
||||||
|
///
|
||||||
|
/// Returns the pipeline instance for fluent chaining.
|
||||||
|
PipelineContract via(String method);
|
||||||
|
|
||||||
|
/// Runs the pipeline with a final destination callback.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Pipeline execution with platform-specific
|
||||||
|
/// async processing.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [destination]: Function to process the final result.
|
||||||
|
///
|
||||||
|
/// Returns the processed result.
|
||||||
|
Future<dynamic> then(dynamic Function(dynamic) destination);
|
||||||
|
|
||||||
|
/// Runs the pipeline and returns the result.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Direct result access following Laravel's
|
||||||
|
/// pipeline execution pattern.
|
||||||
|
///
|
||||||
|
/// Returns the processed object directly.
|
||||||
|
Future<dynamic> thenReturn();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for a pipeline hub that manages multiple pipelines.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Pipeline management functionality matching
|
||||||
|
/// Laravel's pipeline hub features.
|
||||||
|
@sealed
|
||||||
|
abstract class PipelineHubContract {
|
||||||
|
/// Gets or creates a pipeline with the given name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Named pipeline access.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [name]: The name of the pipeline.
|
||||||
|
///
|
||||||
|
/// Returns the pipeline instance.
|
||||||
|
PipelineContract pipeline(String name);
|
||||||
|
|
||||||
|
/// Sets the default pipes for a pipeline.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Default pipe configuration.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [name]: The name of the pipeline.
|
||||||
|
/// - [pipes]: The default pipes for the pipeline.
|
||||||
|
void defaults(String name, List<dynamic> pipes);
|
||||||
|
|
||||||
|
/// Registers a pipe type with a name.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Named pipe type registration following
|
||||||
|
/// Laravel's service registration pattern.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [name]: The name to register the pipe type under.
|
||||||
|
/// - [type]: The pipe type to register.
|
||||||
|
void registerPipeType(String name, Type type);
|
||||||
|
}
|
2
packages/contracts/lib/src/process/process.dart
Normal file
2
packages/contracts/lib/src/process/process.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Process package contracts
|
||||||
|
export 'process_contract.dart';
|
251
packages/contracts/lib/src/process/process_contract.dart
Normal file
251
packages/contracts/lib/src/process/process_contract.dart
Normal file
|
@ -0,0 +1,251 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for process management.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides system process management following Laravel's
|
||||||
|
/// architectural patterns for resource management and lifecycle control.
|
||||||
|
@sealed
|
||||||
|
abstract class ProcessManagerContract {
|
||||||
|
/// Starts a new process.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Creates and starts a new system process with
|
||||||
|
/// Laravel-style identifier and configuration options.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [id]: Unique identifier for the process.
|
||||||
|
/// - [command]: Command to execute.
|
||||||
|
/// - [arguments]: Command arguments.
|
||||||
|
/// - [workingDirectory]: Optional working directory.
|
||||||
|
/// - [environment]: Optional environment variables.
|
||||||
|
/// - [timeout]: Optional execution timeout.
|
||||||
|
/// - [tty]: Whether to run in a terminal.
|
||||||
|
/// - [enableReadError]: Whether to enable error stream reading.
|
||||||
|
Future<ProcessContract> start(
|
||||||
|
String id,
|
||||||
|
String command,
|
||||||
|
List<String> arguments, {
|
||||||
|
String? workingDirectory,
|
||||||
|
Map<String, String>? environment,
|
||||||
|
Duration? timeout,
|
||||||
|
bool tty = false,
|
||||||
|
bool enableReadError = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Gets a running process by ID.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Retrieves process by identifier,
|
||||||
|
/// following Laravel's repository pattern.
|
||||||
|
ProcessContract? get(String id);
|
||||||
|
|
||||||
|
/// Kills a process.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Terminates a process with optional signal,
|
||||||
|
/// following Laravel's resource cleanup patterns.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [id]: Process ID to kill.
|
||||||
|
/// - [signal]: Signal to send (default: SIGTERM).
|
||||||
|
Future<void> kill(String id, {ProcessSignal signal = ProcessSignal.sigterm});
|
||||||
|
|
||||||
|
/// Kills all managed processes.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Bulk process termination,
|
||||||
|
/// following Laravel's collection operation patterns.
|
||||||
|
Future<void> killAll({ProcessSignal signal = ProcessSignal.sigterm});
|
||||||
|
|
||||||
|
/// Gets process events stream.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Event streaming following Laravel's
|
||||||
|
/// event broadcasting patterns.
|
||||||
|
Stream<ProcessEventContract> get events;
|
||||||
|
|
||||||
|
/// Runs processes in a pool.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Concurrent process execution following
|
||||||
|
/// Laravel's job queue worker pool patterns.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [processes]: Processes to run.
|
||||||
|
/// - [concurrency]: Max concurrent processes.
|
||||||
|
Future<List<ProcessResultContract>> pool(
|
||||||
|
List<ProcessContract> processes, {
|
||||||
|
int concurrency = 5,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Runs processes in a pipeline.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Sequential process execution following
|
||||||
|
/// Laravel's pipeline pattern.
|
||||||
|
Future<ProcessResultContract> pipeline(List<ProcessContract> processes);
|
||||||
|
|
||||||
|
/// Disposes the manager and all processes.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Resource cleanup following Laravel's
|
||||||
|
/// service provider cleanup patterns.
|
||||||
|
void dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for process instances.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines individual process behavior following
|
||||||
|
/// Laravel's resource management patterns.
|
||||||
|
@sealed
|
||||||
|
abstract class ProcessContract {
|
||||||
|
/// Gets the process command.
|
||||||
|
String get command;
|
||||||
|
|
||||||
|
/// Gets the process ID.
|
||||||
|
int? get pid;
|
||||||
|
|
||||||
|
/// Gets process start time.
|
||||||
|
DateTime? get startTime;
|
||||||
|
|
||||||
|
/// Gets process end time.
|
||||||
|
DateTime? get endTime;
|
||||||
|
|
||||||
|
/// Gets process output stream.
|
||||||
|
Stream<List<int>> get output;
|
||||||
|
|
||||||
|
/// Gets process error stream.
|
||||||
|
Stream<List<int>> get errorOutput;
|
||||||
|
|
||||||
|
/// Gets process exit code.
|
||||||
|
Future<int> get exitCode;
|
||||||
|
|
||||||
|
/// Whether the process is running.
|
||||||
|
bool get isRunning;
|
||||||
|
|
||||||
|
/// Starts the process.
|
||||||
|
Future<ProcessContract> start();
|
||||||
|
|
||||||
|
/// Runs the process to completion.
|
||||||
|
Future<ProcessResultContract> run();
|
||||||
|
|
||||||
|
/// Runs the process with a timeout.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [timeout]: Maximum execution time.
|
||||||
|
///
|
||||||
|
/// Throws TimeoutException if process exceeds timeout.
|
||||||
|
Future<ProcessResultContract> runWithTimeout(Duration timeout);
|
||||||
|
|
||||||
|
/// Writes input to the process.
|
||||||
|
Future<void> write(String input);
|
||||||
|
|
||||||
|
/// Writes multiple lines to the process.
|
||||||
|
Future<void> writeLines(List<String> lines);
|
||||||
|
|
||||||
|
/// Kills the process.
|
||||||
|
Future<void> kill({ProcessSignal signal = ProcessSignal.sigterm});
|
||||||
|
|
||||||
|
/// Sends a signal to the process.
|
||||||
|
bool sendSignal(ProcessSignal signal);
|
||||||
|
|
||||||
|
/// Gets process output as string.
|
||||||
|
Future<String> get outputAsString;
|
||||||
|
|
||||||
|
/// Gets process error output as string.
|
||||||
|
Future<String> get errorOutputAsString;
|
||||||
|
|
||||||
|
/// Disposes the process.
|
||||||
|
Future<void> dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for process results.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines process execution results following
|
||||||
|
/// Laravel's response/result patterns.
|
||||||
|
@sealed
|
||||||
|
abstract class ProcessResultContract {
|
||||||
|
/// Gets the process ID.
|
||||||
|
int get pid;
|
||||||
|
|
||||||
|
/// Gets the exit code.
|
||||||
|
int get exitCode;
|
||||||
|
|
||||||
|
/// Gets the process output.
|
||||||
|
String get output;
|
||||||
|
|
||||||
|
/// Gets the process error output.
|
||||||
|
String get errorOutput;
|
||||||
|
|
||||||
|
/// Gets string representation.
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'ProcessResult(pid: $pid, exitCode: $exitCode, output: ${output.length} chars, errorOutput: ${errorOutput.length} chars)';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for process events.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines process lifecycle events following
|
||||||
|
/// Laravel's event system patterns.
|
||||||
|
@sealed
|
||||||
|
abstract class ProcessEventContract {
|
||||||
|
/// Gets the process ID.
|
||||||
|
String get id;
|
||||||
|
|
||||||
|
/// Gets the event timestamp.
|
||||||
|
DateTime get timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for process started events.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines process start event following
|
||||||
|
/// Laravel's event naming and structure patterns.
|
||||||
|
@sealed
|
||||||
|
abstract class ProcessStartedEventContract extends ProcessEventContract {
|
||||||
|
/// Gets the started process.
|
||||||
|
ProcessContract get process;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() =>
|
||||||
|
'ProcessStartedEvent(id: $id, command: ${process.command})';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for process exited events.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines process exit event following
|
||||||
|
/// Laravel's event naming and structure patterns.
|
||||||
|
@sealed
|
||||||
|
abstract class ProcessExitedEventContract extends ProcessEventContract {
|
||||||
|
/// Gets the exit code.
|
||||||
|
int get exitCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => 'ProcessExitedEvent(id: $id, exitCode: $exitCode)';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for process pools.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines concurrent process execution following
|
||||||
|
/// Laravel's worker pool patterns.
|
||||||
|
@sealed
|
||||||
|
abstract class ProcessPoolContract {
|
||||||
|
/// Gets maximum concurrent processes.
|
||||||
|
int get concurrency;
|
||||||
|
|
||||||
|
/// Gets active processes.
|
||||||
|
List<ProcessContract> get active;
|
||||||
|
|
||||||
|
/// Gets pending processes.
|
||||||
|
List<ProcessContract> get pending;
|
||||||
|
|
||||||
|
/// Runs processes in the pool.
|
||||||
|
Future<List<ProcessResultContract>> run(List<ProcessContract> processes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for process pipelines.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines sequential process execution following
|
||||||
|
/// Laravel's pipeline pattern.
|
||||||
|
@sealed
|
||||||
|
abstract class ProcessPipelineContract {
|
||||||
|
/// Gets pipeline processes.
|
||||||
|
List<ProcessContract> get processes;
|
||||||
|
|
||||||
|
/// Runs the pipeline.
|
||||||
|
Future<ProcessResultContract> run();
|
||||||
|
}
|
2
packages/contracts/lib/src/queue/queue.dart
Normal file
2
packages/contracts/lib/src/queue/queue.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Queue package contracts
|
||||||
|
export 'queue_contract.dart';
|
284
packages/contracts/lib/src/queue/queue_contract.dart
Normal file
284
packages/contracts/lib/src/queue/queue_contract.dart
Normal file
|
@ -0,0 +1,284 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for queue operations.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core queue functionality matching Laravel's Queue
|
||||||
|
/// interface, adapted for Dart's type system and async patterns.
|
||||||
|
@sealed
|
||||||
|
abstract class QueueContract {
|
||||||
|
/// Pushes a job onto the queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core push method.
|
||||||
|
/// Uses dynamic job type for flexibility.
|
||||||
|
Future<String> push(dynamic job, [String? queue]);
|
||||||
|
|
||||||
|
/// Pushes a job onto a specific queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Queue-specific push.
|
||||||
|
/// Uses dynamic job type for flexibility.
|
||||||
|
Future<String> pushOn(String queue, dynamic job);
|
||||||
|
|
||||||
|
/// Pushes a delayed job onto the queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Delayed job push.
|
||||||
|
/// Uses Duration instead of DateTime/Carbon.
|
||||||
|
Future<String> later(Duration delay, dynamic job, [String? queue]);
|
||||||
|
|
||||||
|
/// Pushes a delayed job onto a specific queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Queue-specific delayed push.
|
||||||
|
/// Uses Duration instead of DateTime/Carbon.
|
||||||
|
Future<String> laterOn(String queue, Duration delay, dynamic job);
|
||||||
|
|
||||||
|
/// Pushes multiple jobs onto the queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Bulk job push.
|
||||||
|
/// Uses dynamic job type for flexibility.
|
||||||
|
Future<void> bulk(List<dynamic> jobs, [String? queue]);
|
||||||
|
|
||||||
|
/// Gets the next job from the queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Job pop operation.
|
||||||
|
Future<JobContract?> pop([String? queue]);
|
||||||
|
|
||||||
|
/// Creates a job batch.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Batch creation.
|
||||||
|
BatchContract batch(List<JobContract> jobs);
|
||||||
|
|
||||||
|
/// Gets a queue connection.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Connection retrieval.
|
||||||
|
QueueConnectionContract connection([String? name]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for queue jobs.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core job interface matching Laravel's Job
|
||||||
|
/// contract, with platform-specific extensions.
|
||||||
|
@sealed
|
||||||
|
abstract class JobContract {
|
||||||
|
/// Gets the job ID.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Job identifier.
|
||||||
|
String get id;
|
||||||
|
|
||||||
|
/// Gets the job payload.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Job data.
|
||||||
|
Map<String, dynamic> get payload;
|
||||||
|
|
||||||
|
/// Gets the number of attempts.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Attempt tracking.
|
||||||
|
int get attempts;
|
||||||
|
|
||||||
|
/// Gets the maximum number of tries.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Retry limit.
|
||||||
|
int get tries;
|
||||||
|
|
||||||
|
/// Gets the job timeout in seconds.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Timeout configuration.
|
||||||
|
int get timeout;
|
||||||
|
|
||||||
|
/// Gets the queue name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Queue designation.
|
||||||
|
String? get queue;
|
||||||
|
|
||||||
|
/// Gets the job delay.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Delay configuration.
|
||||||
|
/// Uses Duration instead of DateTime/Carbon.
|
||||||
|
Duration? get delay;
|
||||||
|
|
||||||
|
/// Whether the job should be encrypted.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Adds encryption support.
|
||||||
|
bool get shouldBeEncrypted;
|
||||||
|
|
||||||
|
/// Whether to dispatch after commit.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Transaction support.
|
||||||
|
bool get afterCommit;
|
||||||
|
|
||||||
|
/// Executes the job.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core job execution.
|
||||||
|
Future<void> handle();
|
||||||
|
|
||||||
|
/// Handles job failure.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Failure handling.
|
||||||
|
Future<void> failed([Exception? exception]);
|
||||||
|
|
||||||
|
/// Releases the job back to the queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Job release.
|
||||||
|
/// Uses Duration instead of DateTime/Carbon.
|
||||||
|
Future<void> release([Duration? delay]);
|
||||||
|
|
||||||
|
/// Deletes the job.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Job deletion.
|
||||||
|
Future<void> delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for job batches.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Batch operations matching Laravel's batch
|
||||||
|
/// functionality, with platform-specific extensions.
|
||||||
|
@sealed
|
||||||
|
abstract class BatchContract {
|
||||||
|
/// Gets the batch ID.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Batch identifier.
|
||||||
|
String get id;
|
||||||
|
|
||||||
|
/// Gets the jobs in the batch.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Batch jobs.
|
||||||
|
List<JobContract> get jobs;
|
||||||
|
|
||||||
|
/// Adds jobs to the batch.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Job addition.
|
||||||
|
void add(List<JobContract> jobs);
|
||||||
|
|
||||||
|
/// Dispatches the batch.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Batch dispatch.
|
||||||
|
Future<void> dispatch();
|
||||||
|
|
||||||
|
/// Allows failures in the batch.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Failure configuration.
|
||||||
|
BatchContract allowFailures();
|
||||||
|
|
||||||
|
/// Sets the batch name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Batch naming.
|
||||||
|
BatchContract name(String name);
|
||||||
|
|
||||||
|
/// Adds a callback when all jobs finish.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Success callback.
|
||||||
|
BatchContract then(void Function(BatchContract) callback);
|
||||||
|
|
||||||
|
/// Adds a callback when the batch fails.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Error callback.
|
||||||
|
BatchContract onError(void Function(BatchContract, dynamic) callback);
|
||||||
|
|
||||||
|
/// Gets the batch progress.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Progress tracking.
|
||||||
|
double get progress;
|
||||||
|
|
||||||
|
/// Gets finished job count.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Completion tracking.
|
||||||
|
int get finished;
|
||||||
|
|
||||||
|
/// Gets failed job count.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Failure tracking.
|
||||||
|
int get failed;
|
||||||
|
|
||||||
|
/// Gets pending job count.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Pending tracking.
|
||||||
|
int get pending;
|
||||||
|
|
||||||
|
/// Gets total job count.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Size tracking.
|
||||||
|
int get total;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for queue connections.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Connection management matching Laravel's
|
||||||
|
/// queue connection functionality.
|
||||||
|
@sealed
|
||||||
|
abstract class QueueConnectionContract {
|
||||||
|
/// Gets the connection name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Connection identifier.
|
||||||
|
String get name;
|
||||||
|
|
||||||
|
/// Gets the connection driver.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Driver type.
|
||||||
|
String get driver;
|
||||||
|
|
||||||
|
/// Gets the connection config.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Configuration access.
|
||||||
|
Map<String, dynamic> get config;
|
||||||
|
|
||||||
|
/// Pushes a job onto the queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Job push.
|
||||||
|
Future<String> push(dynamic job, [String? queue]);
|
||||||
|
|
||||||
|
/// Gets the next job from the queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Job pop.
|
||||||
|
Future<JobContract?> pop([String? queue]);
|
||||||
|
|
||||||
|
/// Gets queue size.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Size check.
|
||||||
|
Future<int> size([String? queue]);
|
||||||
|
|
||||||
|
/// Clears the queue.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Queue clear.
|
||||||
|
Future<void> clear([String? queue]);
|
||||||
|
|
||||||
|
/// Pauses job processing.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Processing pause.
|
||||||
|
Future<void> pause([String? queue]);
|
||||||
|
|
||||||
|
/// Resumes job processing.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Processing resume.
|
||||||
|
Future<void> resume([String? queue]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for queue manager.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Manager functionality matching Laravel's
|
||||||
|
/// queue manager interface.
|
||||||
|
@sealed
|
||||||
|
abstract class QueueManagerContract {
|
||||||
|
/// Gets a queue connection.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Connection retrieval.
|
||||||
|
QueueConnectionContract connection([String? name]);
|
||||||
|
|
||||||
|
/// Gets the default connection name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Default connection.
|
||||||
|
String get defaultConnection;
|
||||||
|
|
||||||
|
/// Sets the default connection name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Default connection.
|
||||||
|
set defaultConnection(String name);
|
||||||
|
|
||||||
|
/// Gets connection configuration.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Config access.
|
||||||
|
Map<String, dynamic> getConfig(String name);
|
||||||
|
|
||||||
|
/// Extends available drivers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Driver extension.
|
||||||
|
void extend(String driver,
|
||||||
|
QueueConnectionContract Function(Map<String, dynamic>) callback);
|
||||||
|
}
|
2
packages/contracts/lib/src/reflection/reflection.dart
Normal file
2
packages/contracts/lib/src/reflection/reflection.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Reflection package contracts
|
||||||
|
export 'reflector_contract.dart';
|
148
packages/contracts/lib/src/reflection/reflector_contract.dart
Normal file
148
packages/contracts/lib/src/reflection/reflector_contract.dart
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for reflected type parameters
|
||||||
|
@sealed
|
||||||
|
abstract class ReflectedTypeParameterContract {
|
||||||
|
/// Gets the name of the type parameter
|
||||||
|
String get name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for reflected types
|
||||||
|
@sealed
|
||||||
|
abstract class ReflectedTypeContract {
|
||||||
|
/// Gets the name of the type
|
||||||
|
String get name;
|
||||||
|
|
||||||
|
/// Gets the type parameters if the type is generic
|
||||||
|
List<ReflectedTypeParameterContract> get typeParameters;
|
||||||
|
|
||||||
|
/// Gets the actual Dart type being reflected
|
||||||
|
Type get reflectedType;
|
||||||
|
|
||||||
|
/// Checks if this type is assignable to another type
|
||||||
|
bool isAssignableTo(ReflectedTypeContract? other);
|
||||||
|
|
||||||
|
/// Creates a new instance of this type
|
||||||
|
ReflectedInstanceContract newInstance(
|
||||||
|
String constructorName, List positionalArguments,
|
||||||
|
[Map<String, dynamic> namedArguments = const {},
|
||||||
|
List<Type> typeArguments = const []]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for reflected parameters
|
||||||
|
@sealed
|
||||||
|
abstract class ReflectedParameterContract {
|
||||||
|
/// Gets the parameter name
|
||||||
|
String get name;
|
||||||
|
|
||||||
|
/// Gets the parameter annotations
|
||||||
|
List<ReflectedInstanceContract> get annotations;
|
||||||
|
|
||||||
|
/// Gets the parameter type
|
||||||
|
ReflectedTypeContract get type;
|
||||||
|
|
||||||
|
/// Whether the parameter is required
|
||||||
|
bool get isRequired;
|
||||||
|
|
||||||
|
/// Whether the parameter is named
|
||||||
|
bool get isNamed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for reflected functions
|
||||||
|
@sealed
|
||||||
|
abstract class ReflectedFunctionContract {
|
||||||
|
/// Gets the function name
|
||||||
|
String get name;
|
||||||
|
|
||||||
|
/// Gets the function's type parameters
|
||||||
|
List<ReflectedTypeParameterContract> get typeParameters;
|
||||||
|
|
||||||
|
/// Gets the function's annotations
|
||||||
|
List<ReflectedInstanceContract> get annotations;
|
||||||
|
|
||||||
|
/// Gets the function's return type
|
||||||
|
ReflectedTypeContract? get returnType;
|
||||||
|
|
||||||
|
/// Gets the function's parameters
|
||||||
|
List<ReflectedParameterContract> get parameters;
|
||||||
|
|
||||||
|
/// Whether the function is a getter
|
||||||
|
bool get isGetter;
|
||||||
|
|
||||||
|
/// Whether the function is a setter
|
||||||
|
bool get isSetter;
|
||||||
|
|
||||||
|
/// Invokes the function
|
||||||
|
ReflectedInstanceContract invoke(Invocation invocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for reflected declarations
|
||||||
|
@sealed
|
||||||
|
abstract class ReflectedDeclarationContract {
|
||||||
|
/// Gets the declaration name
|
||||||
|
String get name;
|
||||||
|
|
||||||
|
/// Whether the declaration is static
|
||||||
|
bool get isStatic;
|
||||||
|
|
||||||
|
/// Gets the associated function if any
|
||||||
|
ReflectedFunctionContract? get function;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for reflected classes
|
||||||
|
@sealed
|
||||||
|
abstract class ReflectedClassContract extends ReflectedTypeContract {
|
||||||
|
/// Gets the class annotations
|
||||||
|
List<ReflectedInstanceContract> get annotations;
|
||||||
|
|
||||||
|
/// Gets the class constructors
|
||||||
|
List<ReflectedFunctionContract> get constructors;
|
||||||
|
|
||||||
|
/// Gets the class declarations
|
||||||
|
List<ReflectedDeclarationContract> get declarations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for reflected instances
|
||||||
|
@sealed
|
||||||
|
abstract class ReflectedInstanceContract {
|
||||||
|
/// Gets the instance type
|
||||||
|
ReflectedTypeContract get type;
|
||||||
|
|
||||||
|
/// Gets the instance class
|
||||||
|
ReflectedClassContract get clazz;
|
||||||
|
|
||||||
|
/// Gets the actual instance being reflected
|
||||||
|
Object? get reflectee;
|
||||||
|
|
||||||
|
/// Gets a field value
|
||||||
|
ReflectedInstanceContract getField(String name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Core reflector contract for type introspection.
|
||||||
|
///
|
||||||
|
/// This contract defines the interface for reflection capabilities,
|
||||||
|
/// allowing runtime inspection and manipulation of types, classes,
|
||||||
|
/// functions, and instances.
|
||||||
|
@sealed
|
||||||
|
abstract class ReflectorContract {
|
||||||
|
/// Gets the name from a symbol
|
||||||
|
String? getName(Symbol symbol);
|
||||||
|
|
||||||
|
/// Reflects a class type
|
||||||
|
ReflectedClassContract? reflectClass(Type clazz);
|
||||||
|
|
||||||
|
/// Reflects a function
|
||||||
|
ReflectedFunctionContract? reflectFunction(Function function);
|
||||||
|
|
||||||
|
/// Reflects a type
|
||||||
|
ReflectedTypeContract? reflectType(Type type);
|
||||||
|
|
||||||
|
/// Reflects an instance
|
||||||
|
ReflectedInstanceContract? reflectInstance(Object object);
|
||||||
|
|
||||||
|
/// Reflects the Future of a type
|
||||||
|
///
|
||||||
|
/// Throws:
|
||||||
|
/// - UnsupportedError if dart:mirrors is not available
|
||||||
|
ReflectedTypeContract reflectFutureOf(Type type);
|
||||||
|
}
|
2
packages/contracts/lib/src/routing/routing.dart
Normal file
2
packages/contracts/lib/src/routing/routing.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Routing package contracts
|
||||||
|
export 'routing_contract.dart';
|
260
packages/contracts/lib/src/routing/routing_contract.dart
Normal file
260
packages/contracts/lib/src/routing/routing_contract.dart
Normal file
|
@ -0,0 +1,260 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for router functionality.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core routing functionality matching Laravel's Router
|
||||||
|
/// interface, with platform-specific generic type support.
|
||||||
|
@sealed
|
||||||
|
abstract class RouterContract<T> {
|
||||||
|
/// Adds a route that responds to any HTTP method.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Any-method route registration.
|
||||||
|
RouteContract<T> any(String path, T handler,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Adds a route that responds to GET requests.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: GET route registration.
|
||||||
|
RouteContract<T> get(String path, T handler,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Adds a route that responds to POST requests.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: POST route registration.
|
||||||
|
RouteContract<T> post(String path, T handler,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Adds a route that responds to PUT requests.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: PUT route registration.
|
||||||
|
RouteContract<T> put(String path, T handler,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Adds a route that responds to DELETE requests.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: DELETE route registration.
|
||||||
|
RouteContract<T> delete(String path, T handler,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Adds a route that responds to PATCH requests.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: PATCH route registration.
|
||||||
|
RouteContract<T> patch(String path, T handler,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Adds a route that responds to OPTIONS requests.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: OPTIONS route registration.
|
||||||
|
RouteContract<T> options(String path, T handler,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Creates a route group with shared attributes.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route grouping with platform-specific
|
||||||
|
/// callback-based configuration.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [path]: The prefix path for the group.
|
||||||
|
/// - [callback]: Function to define routes within the group.
|
||||||
|
/// - [middleware]: Middleware to apply to all routes in the group.
|
||||||
|
void group(String path, void Function(RouterContract<T> router) callback,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Mounts another router at a path prefix.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides router composition functionality.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [path]: The path to mount at.
|
||||||
|
/// - [router]: The router to mount.
|
||||||
|
void mount(String path, RouterContract<T> router);
|
||||||
|
|
||||||
|
/// Resolves a route for a request.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route matching with platform-specific
|
||||||
|
/// match result contract.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [method]: The HTTP method.
|
||||||
|
/// - [path]: The request path.
|
||||||
|
RouteMatchContract<T>? resolve(String method, String path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for route definitions.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route definition interface matching Laravel's Route
|
||||||
|
/// class, with platform-specific enhancements.
|
||||||
|
@sealed
|
||||||
|
abstract class RouteContract<T> {
|
||||||
|
/// Gets the route path pattern.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route URI pattern.
|
||||||
|
String get path;
|
||||||
|
|
||||||
|
/// Gets the HTTP method this route responds to.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: HTTP method.
|
||||||
|
String get method;
|
||||||
|
|
||||||
|
/// Gets the route handler.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route action with generic typing.
|
||||||
|
T get handler;
|
||||||
|
|
||||||
|
/// Gets the route middleware.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route middleware.
|
||||||
|
Iterable<T> get middleware;
|
||||||
|
|
||||||
|
/// Gets the route name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route name accessor.
|
||||||
|
String? get name;
|
||||||
|
|
||||||
|
/// Sets the route name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route name mutator.
|
||||||
|
set name(String? value);
|
||||||
|
|
||||||
|
/// Gets the route parameters.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route parameters.
|
||||||
|
Map<String, dynamic> get parameters;
|
||||||
|
|
||||||
|
/// Makes a URI for this route.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: URL generation.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - [params]: The parameter values to use.
|
||||||
|
String makeUri(Map<String, dynamic> params);
|
||||||
|
|
||||||
|
/// Gets the route's regular expression pattern.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Direct access to route pattern.
|
||||||
|
RegExp get pattern;
|
||||||
|
|
||||||
|
/// Whether the route matches a path.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Direct path matching.
|
||||||
|
bool matches(String path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for route matching results.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Defines detailed match results beyond
|
||||||
|
/// Laravel's basic route matching.
|
||||||
|
@sealed
|
||||||
|
abstract class RouteMatchContract<T> {
|
||||||
|
/// Gets the matched route.
|
||||||
|
RouteContract<T> get route;
|
||||||
|
|
||||||
|
/// Gets the matched parameters.
|
||||||
|
Map<String, dynamic> get params;
|
||||||
|
|
||||||
|
/// Gets any remaining path after the match.
|
||||||
|
String get remaining;
|
||||||
|
|
||||||
|
/// Gets the full matched path.
|
||||||
|
String get matched;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for route parameters.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Parameter handling matching Laravel's
|
||||||
|
/// parameter constraints, with platform-specific validation.
|
||||||
|
@sealed
|
||||||
|
abstract class RouteParameterContract {
|
||||||
|
/// Gets the parameter name.
|
||||||
|
String get name;
|
||||||
|
|
||||||
|
/// Gets the parameter pattern.
|
||||||
|
String? get pattern;
|
||||||
|
|
||||||
|
/// Whether the parameter is optional.
|
||||||
|
bool get isOptional;
|
||||||
|
|
||||||
|
/// Gets the default value.
|
||||||
|
dynamic get defaultValue;
|
||||||
|
|
||||||
|
/// Validates a parameter value.
|
||||||
|
bool validate(String value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for route collection.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route collection functionality matching
|
||||||
|
/// Laravel's RouteCollection, with platform-specific enhancements.
|
||||||
|
@sealed
|
||||||
|
abstract class RouteCollectionContract<T> {
|
||||||
|
/// Gets all routes.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route listing.
|
||||||
|
Iterable<RouteContract<T>> get routes;
|
||||||
|
|
||||||
|
/// Gets routes by method.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Method filtering.
|
||||||
|
Iterable<RouteContract<T>> getByMethod(String method);
|
||||||
|
|
||||||
|
/// Gets a route by name.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Named route lookup.
|
||||||
|
RouteContract<T>? getByName(String name);
|
||||||
|
|
||||||
|
/// Adds a route to the collection.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route registration.
|
||||||
|
void add(RouteContract<T> route);
|
||||||
|
|
||||||
|
/// Removes a route from the collection.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route removal.
|
||||||
|
void remove(RouteContract<T> route);
|
||||||
|
|
||||||
|
/// Gets routes with a specific middleware.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Middleware filtering.
|
||||||
|
Iterable<RouteContract<T>> getByMiddleware(T middleware);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for route groups.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route grouping functionality matching
|
||||||
|
/// Laravel's route group features, with platform-specific additions.
|
||||||
|
@sealed
|
||||||
|
abstract class RouteGroupContract<T> {
|
||||||
|
/// Gets the group prefix.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Group prefix.
|
||||||
|
String get prefix;
|
||||||
|
|
||||||
|
/// Gets the group middleware.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Group middleware.
|
||||||
|
Iterable<T> get middleware;
|
||||||
|
|
||||||
|
/// Gets the group namespace.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Group namespace.
|
||||||
|
String? get namespace;
|
||||||
|
|
||||||
|
/// Gets routes in this group.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Group routes.
|
||||||
|
Iterable<RouteContract<T>> get routes;
|
||||||
|
|
||||||
|
/// Adds a route to the group.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route addition with platform-specific
|
||||||
|
/// middleware support.
|
||||||
|
RouteContract<T> addRoute(String method, String path, T handler,
|
||||||
|
{Iterable<T> middleware = const []});
|
||||||
|
|
||||||
|
/// Creates a sub-group.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Nested grouping with platform-specific
|
||||||
|
/// namespace support.
|
||||||
|
RouteGroupContract<T> group(String prefix,
|
||||||
|
{Iterable<T> middleware = const [], String? namespace});
|
||||||
|
}
|
2
packages/contracts/lib/src/support/support.dart
Normal file
2
packages/contracts/lib/src/support/support.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Support package contracts
|
||||||
|
export 'support_contract.dart';
|
263
packages/contracts/lib/src/support/support_contract.dart
Normal file
263
packages/contracts/lib/src/support/support_contract.dart
Normal file
|
@ -0,0 +1,263 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for service providers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core service provider functionality matching
|
||||||
|
/// Laravel's ServiceProvider class, adapted for Dart's type system.
|
||||||
|
@sealed
|
||||||
|
abstract class ServiceProviderContract {
|
||||||
|
/// Registers application services.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core registration method.
|
||||||
|
void register();
|
||||||
|
|
||||||
|
/// Bootstraps application services.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Core bootstrap method.
|
||||||
|
void boot();
|
||||||
|
|
||||||
|
/// Gets services provided by this provider.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Lists provided services.
|
||||||
|
List<String> provides();
|
||||||
|
|
||||||
|
/// Gets events that trigger registration.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Lists registration triggers.
|
||||||
|
List<String> when();
|
||||||
|
|
||||||
|
/// Whether provider is deferred.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Controls lazy loading.
|
||||||
|
bool isDeferred();
|
||||||
|
|
||||||
|
/// Gets the application instance.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Application access.
|
||||||
|
/// Uses dynamic type for flexibility.
|
||||||
|
dynamic get app;
|
||||||
|
|
||||||
|
/// Sets the application instance.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Application injection.
|
||||||
|
/// Uses dynamic type for flexibility.
|
||||||
|
set app(dynamic value);
|
||||||
|
|
||||||
|
/// Gets booting callbacks.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Boot phase callbacks.
|
||||||
|
List<Function> get bootingCallbacks;
|
||||||
|
|
||||||
|
/// Gets booted callbacks.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Post-boot callbacks.
|
||||||
|
List<Function> get bootedCallbacks;
|
||||||
|
|
||||||
|
/// Registers a booting callback.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Boot phase hook.
|
||||||
|
void booting(Function callback);
|
||||||
|
|
||||||
|
/// Registers a booted callback.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Post-boot hook.
|
||||||
|
void booted(Function callback);
|
||||||
|
|
||||||
|
/// Calls booting callbacks.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Executes boot phase hooks.
|
||||||
|
void callBootingCallbacks();
|
||||||
|
|
||||||
|
/// Calls booted callbacks.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Executes post-boot hooks.
|
||||||
|
void callBootedCallbacks();
|
||||||
|
|
||||||
|
/// Merges configuration.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Config merging.
|
||||||
|
void mergeConfigFrom(String path, String key);
|
||||||
|
|
||||||
|
/// Replaces configuration recursively.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Deep config replacement.
|
||||||
|
void replaceConfigRecursivelyFrom(String path, String key);
|
||||||
|
|
||||||
|
/// Loads routes from file.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Route loading.
|
||||||
|
void loadRoutesFrom(String path);
|
||||||
|
|
||||||
|
/// Loads views from directory.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: View loading.
|
||||||
|
void loadViewsFrom(String path, String namespace);
|
||||||
|
|
||||||
|
/// Loads view components.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Component loading.
|
||||||
|
void loadViewComponentsAs(String prefix, List<Type> components);
|
||||||
|
|
||||||
|
/// Loads translations from directory.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Translation loading.
|
||||||
|
void loadTranslationsFrom(String path, String namespace);
|
||||||
|
|
||||||
|
/// Loads JSON translations.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: JSON translation loading.
|
||||||
|
void loadJsonTranslationsFrom(String path);
|
||||||
|
|
||||||
|
/// Loads database migrations.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Migration loading.
|
||||||
|
void loadMigrationsFrom(dynamic paths);
|
||||||
|
|
||||||
|
/// Loads model factories.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Factory loading.
|
||||||
|
@Deprecated('Will be removed in a future version.')
|
||||||
|
void loadFactoriesFrom(dynamic paths);
|
||||||
|
|
||||||
|
/// Sets up after resolving listener.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Resolution hook.
|
||||||
|
void callAfterResolving(String name, Function callback);
|
||||||
|
|
||||||
|
/// Publishes migrations.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Migration publishing.
|
||||||
|
void publishesMigrations(List<String> paths, [dynamic groups]);
|
||||||
|
|
||||||
|
/// Registers publishable paths.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Asset publishing.
|
||||||
|
void registerPublishables(Map<String, String> paths, [dynamic groups]);
|
||||||
|
|
||||||
|
/// Legacy method for registering publishables.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Legacy publish method.
|
||||||
|
@Deprecated('Use registerPublishables instead')
|
||||||
|
void publishes(Map<String, String> paths, [dynamic groups]);
|
||||||
|
|
||||||
|
/// Initializes publish array.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Publish setup.
|
||||||
|
void ensurePublishArrayInitialized(String className);
|
||||||
|
|
||||||
|
/// Adds a publish group.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Group publishing.
|
||||||
|
void addPublishGroup(String group, Map<String, String> paths);
|
||||||
|
|
||||||
|
/// Gets paths to publish.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Publish path lookup.
|
||||||
|
Map<String, String> pathsToPublish([String? provider, String? group]);
|
||||||
|
|
||||||
|
/// Gets paths for provider or group.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Provider/group path lookup.
|
||||||
|
Map<String, String> pathsForProviderOrGroup(String? provider, String? group);
|
||||||
|
|
||||||
|
/// Gets paths for provider and group.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Combined path lookup.
|
||||||
|
Map<String, String> pathsForProviderAndGroup(String provider, String group);
|
||||||
|
|
||||||
|
/// Gets publishable providers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Provider listing.
|
||||||
|
List<String> publishableProviders();
|
||||||
|
|
||||||
|
/// Gets publishable migration paths.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Migration path listing.
|
||||||
|
List<String> publishableMigrationPaths();
|
||||||
|
|
||||||
|
/// Gets publishable groups.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Group listing.
|
||||||
|
List<String> publishableGroups();
|
||||||
|
|
||||||
|
/// Registers commands.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Command registration.
|
||||||
|
void commands(List<Type> commands);
|
||||||
|
|
||||||
|
/// Gets default providers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Default provider listing.
|
||||||
|
List<Type> defaultProviders();
|
||||||
|
|
||||||
|
/// Adds provider to bootstrap file.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Provider bootstrapping.
|
||||||
|
bool addProviderToBootstrapFile(String provider, [String? path]);
|
||||||
|
|
||||||
|
/// Registers a singleton.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Singleton binding with Dart typing.
|
||||||
|
void singleton<T>(T instance);
|
||||||
|
|
||||||
|
/// Registers a factory binding.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Factory binding with Dart typing.
|
||||||
|
void bind<T>(T Function(dynamic) factory);
|
||||||
|
|
||||||
|
/// Gets a service.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Service resolution with Dart typing.
|
||||||
|
T make<T>([Type? type]);
|
||||||
|
|
||||||
|
/// Checks if service exists.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Binding check with Dart typing.
|
||||||
|
bool has<T>();
|
||||||
|
|
||||||
|
/// Registers tagged bindings.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Tag binding with Dart typing.
|
||||||
|
void tag(List<Type> abstracts, List<Type> tags);
|
||||||
|
|
||||||
|
/// Registers an event listener.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Event listener registration.
|
||||||
|
void listen(String event, Function listener);
|
||||||
|
|
||||||
|
/// Registers middleware.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Middleware registration.
|
||||||
|
void middleware(String name, Function handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for deferrable providers.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Defines providers that can be loaded
|
||||||
|
/// on demand rather than at application startup.
|
||||||
|
@sealed
|
||||||
|
abstract class DeferrableProviderContract {
|
||||||
|
/// Gets services provided by this provider.
|
||||||
|
///
|
||||||
|
/// Laravel-compatible: Lists deferred services.
|
||||||
|
List<String> provides();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for provider static functionality.
|
||||||
|
///
|
||||||
|
/// Platform-specific: Provides static helper methods and properties
|
||||||
|
/// following Laravel's patterns for static configuration.
|
||||||
|
@sealed
|
||||||
|
abstract class ServiceProviderStaticContract {
|
||||||
|
/// Gets publishable migration paths.
|
||||||
|
static final List<String> publishableMigrationPaths = [];
|
||||||
|
|
||||||
|
/// Gets publishable paths.
|
||||||
|
static final Map<String, Map<String, String>> publishablePaths = {};
|
||||||
|
|
||||||
|
/// Gets publishable groups.
|
||||||
|
static final Map<String, Map<String, String>> publishableGroups = {};
|
||||||
|
|
||||||
|
/// Gets publishable provider paths.
|
||||||
|
static final Map<String, Map<String, String>> publishableProviderPaths = {};
|
||||||
|
}
|
2
packages/contracts/lib/src/testing/testing.dart
Normal file
2
packages/contracts/lib/src/testing/testing.dart
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/// Testing package contracts
|
||||||
|
export 'testing_contract.dart';
|
302
packages/contracts/lib/src/testing/testing_contract.dart
Normal file
302
packages/contracts/lib/src/testing/testing_contract.dart
Normal file
|
@ -0,0 +1,302 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// Contract for mock HTTP requests.
|
||||||
|
///
|
||||||
|
/// This contract defines how HTTP requests should be mocked
|
||||||
|
/// for testing purposes.
|
||||||
|
@sealed
|
||||||
|
abstract class MockHttpRequestContract
|
||||||
|
implements HttpRequest, StreamSink<List<int>>, StringSink {
|
||||||
|
/// Gets the request method.
|
||||||
|
@override
|
||||||
|
String get method;
|
||||||
|
|
||||||
|
/// Gets the request URI.
|
||||||
|
@override
|
||||||
|
Uri get uri;
|
||||||
|
|
||||||
|
/// Gets request headers.
|
||||||
|
@override
|
||||||
|
HttpHeaders get headers;
|
||||||
|
|
||||||
|
/// Gets request cookies.
|
||||||
|
@override
|
||||||
|
List<Cookie> get cookies;
|
||||||
|
|
||||||
|
/// Gets connection info.
|
||||||
|
@override
|
||||||
|
HttpConnectionInfo get connectionInfo;
|
||||||
|
|
||||||
|
/// Gets request session.
|
||||||
|
@override
|
||||||
|
HttpSession get session;
|
||||||
|
|
||||||
|
/// Gets request content length.
|
||||||
|
@override
|
||||||
|
int get contentLength;
|
||||||
|
|
||||||
|
/// Gets protocol version.
|
||||||
|
@override
|
||||||
|
String get protocolVersion;
|
||||||
|
|
||||||
|
/// Gets SSL/TLS certificate.
|
||||||
|
@override
|
||||||
|
X509Certificate? get certificate;
|
||||||
|
|
||||||
|
/// Gets whether connection is persistent.
|
||||||
|
@override
|
||||||
|
bool get persistentConnection;
|
||||||
|
|
||||||
|
/// Gets requested URI.
|
||||||
|
@override
|
||||||
|
Uri get requestedUri;
|
||||||
|
|
||||||
|
/// Sets requested URI.
|
||||||
|
set requestedUri(Uri value);
|
||||||
|
|
||||||
|
/// Gets response object.
|
||||||
|
@override
|
||||||
|
HttpResponse get response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for mock HTTP responses.
|
||||||
|
///
|
||||||
|
/// This contract defines how HTTP responses should be mocked
|
||||||
|
/// for testing purposes.
|
||||||
|
@sealed
|
||||||
|
abstract class MockHttpResponseContract
|
||||||
|
implements HttpResponse, Stream<List<int>> {
|
||||||
|
/// Gets/sets status code.
|
||||||
|
@override
|
||||||
|
int get statusCode;
|
||||||
|
@override
|
||||||
|
set statusCode(int value);
|
||||||
|
|
||||||
|
/// Gets/sets reason phrase.
|
||||||
|
@override
|
||||||
|
String get reasonPhrase;
|
||||||
|
@override
|
||||||
|
set reasonPhrase(String value);
|
||||||
|
|
||||||
|
/// Gets/sets content length.
|
||||||
|
@override
|
||||||
|
int get contentLength;
|
||||||
|
@override
|
||||||
|
set contentLength(int value);
|
||||||
|
|
||||||
|
/// Gets/sets deadline.
|
||||||
|
@override
|
||||||
|
Duration? get deadline;
|
||||||
|
@override
|
||||||
|
set deadline(Duration? value);
|
||||||
|
|
||||||
|
/// Gets/sets encoding.
|
||||||
|
@override
|
||||||
|
Encoding get encoding;
|
||||||
|
@override
|
||||||
|
set encoding(Encoding value);
|
||||||
|
|
||||||
|
/// Gets/sets persistent connection flag.
|
||||||
|
@override
|
||||||
|
bool get persistentConnection;
|
||||||
|
@override
|
||||||
|
set persistentConnection(bool value);
|
||||||
|
|
||||||
|
/// Gets/sets buffer output flag.
|
||||||
|
@override
|
||||||
|
bool get bufferOutput;
|
||||||
|
@override
|
||||||
|
set bufferOutput(bool value);
|
||||||
|
|
||||||
|
/// Gets response headers.
|
||||||
|
@override
|
||||||
|
HttpHeaders get headers;
|
||||||
|
|
||||||
|
/// Gets response cookies.
|
||||||
|
@override
|
||||||
|
List<Cookie> get cookies;
|
||||||
|
|
||||||
|
/// Gets connection info.
|
||||||
|
@override
|
||||||
|
HttpConnectionInfo get connectionInfo;
|
||||||
|
|
||||||
|
/// Gets done future.
|
||||||
|
@override
|
||||||
|
Future get done;
|
||||||
|
|
||||||
|
/// Detaches socket.
|
||||||
|
@override
|
||||||
|
Future<Socket> detachSocket({bool writeHeaders = true});
|
||||||
|
|
||||||
|
/// Redirects to location.
|
||||||
|
@override
|
||||||
|
Future redirect(Uri location, {int status = HttpStatus.movedTemporarily});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for mock HTTP sessions.
|
||||||
|
///
|
||||||
|
/// This contract defines how HTTP sessions should be mocked
|
||||||
|
/// for testing purposes.
|
||||||
|
@sealed
|
||||||
|
abstract class MockHttpSessionContract implements HttpSession {
|
||||||
|
/// Gets session ID.
|
||||||
|
@override
|
||||||
|
String get id;
|
||||||
|
|
||||||
|
/// Gets/sets whether session is new.
|
||||||
|
@override
|
||||||
|
bool get isNew;
|
||||||
|
@override
|
||||||
|
set isNew(bool value);
|
||||||
|
|
||||||
|
/// Gets session data.
|
||||||
|
Map<String, dynamic> get data;
|
||||||
|
|
||||||
|
/// Gets session value.
|
||||||
|
@override
|
||||||
|
dynamic operator [](Object? key);
|
||||||
|
|
||||||
|
/// Sets session value.
|
||||||
|
@override
|
||||||
|
void operator []=(dynamic key, dynamic value);
|
||||||
|
|
||||||
|
/// Removes session value.
|
||||||
|
@override
|
||||||
|
dynamic remove(Object? key);
|
||||||
|
|
||||||
|
/// Clears all session data.
|
||||||
|
@override
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/// Destroys the session.
|
||||||
|
@override
|
||||||
|
Future<void> destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for mock HTTP headers.
|
||||||
|
///
|
||||||
|
/// This contract defines how HTTP headers should be mocked
|
||||||
|
/// for testing purposes.
|
||||||
|
@sealed
|
||||||
|
abstract class MockHttpHeadersContract implements HttpHeaders {
|
||||||
|
/// Gets header value.
|
||||||
|
@override
|
||||||
|
String? value(String name);
|
||||||
|
|
||||||
|
/// Adds header value.
|
||||||
|
@override
|
||||||
|
void add(String name, Object value, {bool preserveHeaderCase = false});
|
||||||
|
|
||||||
|
/// Removes header.
|
||||||
|
@override
|
||||||
|
void remove(String name, Object value);
|
||||||
|
|
||||||
|
/// Removes all headers.
|
||||||
|
@override
|
||||||
|
void removeAll(String name);
|
||||||
|
|
||||||
|
/// Sets header value.
|
||||||
|
@override
|
||||||
|
void set(String name, Object value, {bool preserveHeaderCase = false});
|
||||||
|
|
||||||
|
/// Gets header values.
|
||||||
|
@override
|
||||||
|
List<String>? operator [](String name);
|
||||||
|
|
||||||
|
/// Gets all header names.
|
||||||
|
@override
|
||||||
|
List<String> get names;
|
||||||
|
|
||||||
|
/// Gets header values.
|
||||||
|
@override
|
||||||
|
Iterable<String>? getAll(String name);
|
||||||
|
|
||||||
|
/// Clears all headers.
|
||||||
|
@override
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/// Gets whether headers are mutable.
|
||||||
|
@override
|
||||||
|
bool get mutable;
|
||||||
|
|
||||||
|
/// Gets content type.
|
||||||
|
@override
|
||||||
|
ContentType? get contentType;
|
||||||
|
|
||||||
|
/// Sets content type.
|
||||||
|
@override
|
||||||
|
set contentType(ContentType? value);
|
||||||
|
|
||||||
|
/// Gets date.
|
||||||
|
@override
|
||||||
|
DateTime? get date;
|
||||||
|
|
||||||
|
/// Sets date.
|
||||||
|
@override
|
||||||
|
set date(DateTime? value);
|
||||||
|
|
||||||
|
/// Gets expires date.
|
||||||
|
@override
|
||||||
|
DateTime? get expires;
|
||||||
|
|
||||||
|
/// Sets expires date.
|
||||||
|
@override
|
||||||
|
set expires(DateTime? value);
|
||||||
|
|
||||||
|
/// Gets if-modified-since date.
|
||||||
|
@override
|
||||||
|
DateTime? get ifModifiedSince;
|
||||||
|
|
||||||
|
/// Sets if-modified-since date.
|
||||||
|
@override
|
||||||
|
set ifModifiedSince(DateTime? value);
|
||||||
|
|
||||||
|
/// Gets host.
|
||||||
|
@override
|
||||||
|
String? get host;
|
||||||
|
|
||||||
|
/// Sets host.
|
||||||
|
@override
|
||||||
|
set host(String? value);
|
||||||
|
|
||||||
|
/// Gets port.
|
||||||
|
@override
|
||||||
|
int? get port;
|
||||||
|
|
||||||
|
/// Sets port.
|
||||||
|
@override
|
||||||
|
set port(int? value);
|
||||||
|
|
||||||
|
/// Locks headers from modification.
|
||||||
|
void lock();
|
||||||
|
|
||||||
|
/// Gets whether headers are locked.
|
||||||
|
bool get locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contract for mock connection info.
|
||||||
|
///
|
||||||
|
/// This contract defines how connection info should be mocked
|
||||||
|
/// for testing purposes.
|
||||||
|
@sealed
|
||||||
|
abstract class MockConnectionInfoContract implements HttpConnectionInfo {
|
||||||
|
/// Gets local address.
|
||||||
|
@override
|
||||||
|
InternetAddress get localAddress;
|
||||||
|
|
||||||
|
/// Gets local port.
|
||||||
|
@override
|
||||||
|
int get localPort;
|
||||||
|
|
||||||
|
/// Gets remote address.
|
||||||
|
@override
|
||||||
|
InternetAddress get remoteAddress;
|
||||||
|
|
||||||
|
/// Gets remote port.
|
||||||
|
@override
|
||||||
|
int get remotePort;
|
||||||
|
}
|
13
packages/contracts/pubspec.yaml
Normal file
13
packages/contracts/pubspec.yaml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
name: platform_contracts
|
||||||
|
description: Core contracts for the Platform framework
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: '>=3.0.0 <4.0.0'
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
meta: ^1.9.0
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
lints: ^2.0.0
|
||||||
|
test: ^1.21.0
|
Loading…
Reference in a new issue