update: updating files with ported code
This commit is contained in:
parent
1ba4afc563
commit
9705b49bea
53 changed files with 1151 additions and 0 deletions
|
@ -0,0 +1,7 @@
|
|||
abstract class ClearableQueue {
|
||||
/// Delete all of the jobs from the queue.
|
||||
///
|
||||
/// @param String queue
|
||||
/// @return int
|
||||
int clear(String queue);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import 'dart:core';
|
||||
|
||||
class EntityNotFoundException implements Exception {
|
||||
final String message;
|
||||
|
||||
EntityNotFoundException(String type, dynamic id)
|
||||
: message = "Queueable entity [$type] not found for ID [${id.toString()}].";
|
||||
|
||||
@override
|
||||
String toString() => 'EntityNotFoundException: $message';
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
abstract class EntityResolver {
|
||||
/// Resolve the entity for the given ID.
|
||||
///
|
||||
/// @param String type
|
||||
/// @param dynamic id
|
||||
/// @return dynamic
|
||||
dynamic resolve(String type, dynamic id);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
import 'queue.dart';
|
||||
|
||||
// TODO: Fix Imports
|
||||
|
||||
abstract class Factory {
|
||||
/// Resolve a queue connection instance.
|
||||
///
|
||||
/// @param String? name
|
||||
/// @return Queue
|
||||
Queue connection([String? name]);
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
abstract class Job {
|
||||
/// Get the UUID of the job.
|
||||
String? uuid();
|
||||
|
||||
/// Get the job identifier.
|
||||
String getJobId();
|
||||
|
||||
/// Get the decoded body of the job.
|
||||
Map<String, dynamic> payload();
|
||||
|
||||
/// Fire the job.
|
||||
void fire();
|
||||
|
||||
/// Release the job back into the queue after [delay] seconds.
|
||||
void release(int delay);
|
||||
|
||||
/// Determine if the job was released back into the queue.
|
||||
bool isReleased();
|
||||
|
||||
/// Delete the job from the queue.
|
||||
void delete();
|
||||
|
||||
/// Determine if the job has been deleted.
|
||||
bool isDeleted();
|
||||
|
||||
/// Determine if the job has been deleted or released.
|
||||
bool isDeletedOrReleased();
|
||||
|
||||
/// Get the number of times the job has been attempted.
|
||||
int attempts();
|
||||
|
||||
/// Determine if the job has been marked as a failure.
|
||||
bool hasFailed();
|
||||
|
||||
/// Mark the job as "failed".
|
||||
void markAsFailed();
|
||||
|
||||
/// Delete the job, call the "failed" method, and raise the failed job event.
|
||||
void fail([Exception? e]);
|
||||
|
||||
/// Get the number of times to attempt a job.
|
||||
int? maxTries();
|
||||
|
||||
/// Get the maximum number of exceptions allowed, regardless of attempts.
|
||||
int? maxExceptions();
|
||||
|
||||
/// Get the number of seconds the job can run.
|
||||
int? timeout();
|
||||
|
||||
/// Get the timestamp indicating when the job should timeout.
|
||||
int? retryUntil();
|
||||
|
||||
/// Get the name of the queued job class.
|
||||
String getName();
|
||||
|
||||
/// Get the resolved name of the queued job class.
|
||||
String resolveName();
|
||||
|
||||
/// Get the name of the connection the job belongs to.
|
||||
String getConnectionName();
|
||||
|
||||
/// Get the name of the queue the job belongs to.
|
||||
String getQueue();
|
||||
|
||||
/// Get the raw body string for the job.
|
||||
String getRawBody();
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
abstract class Monitor {
|
||||
/// Register a callback to be executed on every iteration through the queue loop.
|
||||
///
|
||||
/// @param Function callback
|
||||
/// @return void
|
||||
void looping(Function callback);
|
||||
|
||||
/// Register a callback to be executed when a job fails after the maximum number of retries.
|
||||
///
|
||||
/// @param Function callback
|
||||
/// @return void
|
||||
void failing(Function callback);
|
||||
|
||||
/// Register a callback to be executed when a daemon queue is stopping.
|
||||
///
|
||||
/// @param Function callback
|
||||
/// @return void
|
||||
void stopping(Function callback);
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
import "job.dart";
|
||||
abstract class Queue {
|
||||
/// Get the size of the queue.
|
||||
///
|
||||
/// @param String? queue
|
||||
/// @return int
|
||||
int size(String? queue);
|
||||
|
||||
/// Push a new job onto the queue.
|
||||
///
|
||||
/// @param String job
|
||||
/// @param dynamic data
|
||||
/// @param String? queue
|
||||
/// @return dynamic
|
||||
dynamic push(dynamic job, {dynamic data = '', String? queue});
|
||||
|
||||
/// Push a new job onto the queue.
|
||||
///
|
||||
/// @param String queue
|
||||
/// @param String job
|
||||
/// @param dynamic data
|
||||
/// @return dynamic
|
||||
dynamic pushOn(String queue, dynamic job, {dynamic data = ''});
|
||||
|
||||
/// Push a raw payload onto the queue.
|
||||
///
|
||||
/// @param String payload
|
||||
/// @param String? queue
|
||||
/// @param Map<String, dynamic> options
|
||||
/// @return dynamic
|
||||
dynamic pushRaw(String payload, {String? queue, Map<String, dynamic> options = const {}});
|
||||
|
||||
/// Push a new job onto the queue after (n) seconds.
|
||||
///
|
||||
/// @param dynamic delay
|
||||
/// @param dynamic job
|
||||
/// @param dynamic data
|
||||
/// @param String? queue
|
||||
/// @return dynamic
|
||||
dynamic later(dynamic delay, dynamic job, {dynamic data = '', String? queue});
|
||||
|
||||
/// Push a new job onto a specific queue after (n) seconds.
|
||||
///
|
||||
/// @param String queue
|
||||
/// @param dynamic delay
|
||||
/// @param dynamic job
|
||||
/// @param dynamic data
|
||||
/// @return dynamic
|
||||
dynamic laterOn(String queue, dynamic delay, dynamic job, {dynamic data = ''});
|
||||
|
||||
/// Push an array of jobs onto the queue.
|
||||
///
|
||||
/// @param List<dynamic> jobs
|
||||
/// @param dynamic data
|
||||
/// @param String? queue
|
||||
/// @return dynamic
|
||||
dynamic bulk(List<dynamic> jobs, {dynamic data = '', String? queue});
|
||||
|
||||
/// Pop the next job off of the queue.
|
||||
///
|
||||
/// @param String? queue
|
||||
/// @return Job?
|
||||
Job? pop(String? queue);
|
||||
|
||||
/// Get the connection name for the queue.
|
||||
///
|
||||
/// @return String
|
||||
String getConnectionName();
|
||||
|
||||
/// Set the connection name for the queue.
|
||||
///
|
||||
/// @param String name
|
||||
/// @return this
|
||||
Queue setConnectionName(String name);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
abstract class QueueableCollection {
|
||||
/// Get the type of the entities being queued.
|
||||
///
|
||||
/// @return String|null
|
||||
String? getQueueableClass();
|
||||
|
||||
/// Get the identifiers for all of the entities.
|
||||
///
|
||||
/// @return List<int, dynamic>
|
||||
List<dynamic> getQueueableIds();
|
||||
|
||||
/// Get the relationships of the entities being queued.
|
||||
///
|
||||
/// @return List<int, String>
|
||||
List<String> getQueueableRelations();
|
||||
|
||||
/// Get the connection of the entities being queued.
|
||||
///
|
||||
/// @return String|null
|
||||
String? getQueueableConnection();
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
abstract class QueueableEntity {
|
||||
/// Get the queueable identity for the entity.
|
||||
///
|
||||
/// @return dynamic
|
||||
dynamic getQueueableId();
|
||||
|
||||
/// Get the relationships for the entity.
|
||||
///
|
||||
/// @return List
|
||||
List<dynamic> getQueueableRelations();
|
||||
|
||||
/// Get the connection of the entity.
|
||||
///
|
||||
/// @return String?
|
||||
String? getQueueableConnection();
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
abstract class ShouldBeEncrypted {
|
||||
// Add any necessary methods or properties here
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
abstract class ShouldBeUnique {
|
||||
// This is an abstract class that serves as a marker interface.
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// File: illuminate/contracts/queue/should_be_unique_until_processing.dart
|
||||
|
||||
import 'should_be_unique.dart';
|
||||
|
||||
abstract class ShouldBeUniqueUntilProcessing implements ShouldBeUnique {
|
||||
// This interface can include any additional methods or properties if needed
|
||||
// Currently, it's just extending ShouldBeUnique
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
abstract class ShouldQueue {
|
||||
// Interface with no methods defined
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import 'should_queue.dart';
|
||||
abstract class ShouldQueueAfterCommit implements ShouldQueue {
|
||||
// Additional functionalities can be added here if needed
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import 'dart:async';
|
||||
|
||||
abstract class Connection {
|
||||
/// Subscribe to a set of given channels for messages.
|
||||
///
|
||||
/// @param List<String> channels
|
||||
/// @param void Function(dynamic) callback
|
||||
/// @return void
|
||||
void subscribe(List<String> channels, void Function(dynamic) callback);
|
||||
|
||||
/// Subscribe to a set of given channels with wildcards.
|
||||
///
|
||||
/// @param List<String> channels
|
||||
/// @param void Function(dynamic) callback
|
||||
/// @return void
|
||||
void psubscribe(List<String> channels, void Function(dynamic) callback);
|
||||
|
||||
/// Run a command against the Redis database.
|
||||
///
|
||||
/// @param String method
|
||||
/// @param List<dynamic> parameters
|
||||
/// @return Future<dynamic>
|
||||
Future<dynamic> command(String method, [List<dynamic> parameters = const []]);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
import 'connection.dart';
|
||||
|
||||
abstract class Connector {
|
||||
/// Create a connection to a Redis cluster.
|
||||
///
|
||||
/// @param config
|
||||
/// @param options
|
||||
/// @return Connection
|
||||
Connection connect(Map<String, dynamic> config, Map<String, dynamic> options);
|
||||
|
||||
/// Create a connection to a Redis instance.
|
||||
///
|
||||
/// @param config
|
||||
/// @param clusterOptions
|
||||
/// @param options
|
||||
/// @return Connection
|
||||
Connection connectToCluster(Map<String, dynamic> config, Map<String, dynamic> clusterOptions, Map<String, dynamic> options);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// file: lib/src/contracts/redis/factory.dart
|
||||
|
||||
import 'connection.dart';
|
||||
|
||||
abstract class Factory {
|
||||
/// Get a Redis connection by name.
|
||||
///
|
||||
/// @param [String] name
|
||||
/// @return [Connection]
|
||||
Connection connection([String? name]);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
//import 'package:redis/redis.dart';
|
||||
|
||||
class LimiterTimeoutException implements Exception {
|
||||
final String message;
|
||||
|
||||
LimiterTimeoutException([this.message = '']);
|
||||
|
||||
@override
|
||||
String toString() => message.isEmpty ? 'LimiterTimeoutException' : 'LimiterTimeoutException: $message';
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
abstract class BindingRegistrar {
|
||||
/// Add a new route parameter binder.
|
||||
///
|
||||
/// @param String key
|
||||
/// @param String or Function binder
|
||||
/// @return void
|
||||
void bind(String key, dynamic binder);
|
||||
|
||||
/// Get the binding callback for a given binding.
|
||||
///
|
||||
/// @param String key
|
||||
/// @return Function
|
||||
Function getBindingCallback(String key);
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
import 'route.dart';
|
||||
|
||||
// TODO: Fix Imports.
|
||||
|
||||
abstract class Registrar {
|
||||
/// Register a new GET route with the router.
|
||||
///
|
||||
/// @param string $uri
|
||||
/// @param array|string|callable $action
|
||||
/// @return \Illuminate\Routing\Route
|
||||
Route get(String uri, dynamic action);
|
||||
|
||||
/// Register a new POST route with the router.
|
||||
///
|
||||
/// @param string $uri
|
||||
/// @param array|string|callable $action
|
||||
/// @return \Illuminate\Routing\Route
|
||||
Route post(String uri, dynamic action);
|
||||
|
||||
/// Register a new PUT route with the router.
|
||||
///
|
||||
/// @param string $uri
|
||||
/// @param array|string|callable $action
|
||||
/// @return \Illuminate\Routing\Route
|
||||
Route put(String uri, dynamic action);
|
||||
|
||||
/// Register a new DELETE route with the router.
|
||||
///
|
||||
/// @param string $uri
|
||||
/// @param array|string|callable $action
|
||||
/// @return \Illuminate\Routing\Route
|
||||
Route delete(String uri, dynamic action);
|
||||
|
||||
/// Register a new PATCH route with the router.
|
||||
///
|
||||
/// @param string $uri
|
||||
/// @param array|string|callable $action
|
||||
/// @return \Illuminate\Routing\Route
|
||||
Route patch(String uri, dynamic action);
|
||||
|
||||
/// Register a new OPTIONS route with the router.
|
||||
///
|
||||
/// @param string $uri
|
||||
/// @param array|string|callable $action
|
||||
/// @return \Illuminate\Routing\Route
|
||||
Route options(String uri, dynamic action);
|
||||
|
||||
/// Register a new route with the given verbs.
|
||||
///
|
||||
/// @param array|string $methods
|
||||
/// @param string $uri
|
||||
/// @param array|string|callable $action
|
||||
/// @return \Illuminate\Routing\Route
|
||||
Route match(dynamic methods, String uri, dynamic action);
|
||||
|
||||
/// Route a resource to a controller.
|
||||
///
|
||||
/// @param string $name
|
||||
/// @param string $controller
|
||||
/// @param array $options
|
||||
/// @return \Illuminate\Routing\PendingResourceRegistration
|
||||
PendingResourceRegistration resource(String name, String controller, [Map<String, dynamic>? options]);
|
||||
|
||||
/// Create a route group with shared attributes.
|
||||
///
|
||||
/// @param array $attributes
|
||||
/// @param \Closure|string $routes
|
||||
/// @return void
|
||||
void group(Map<String, dynamic> attributes, dynamic routes);
|
||||
|
||||
/// Substitute the route bindings onto the route.
|
||||
///
|
||||
/// @param \Illuminate\Routing\Route $route
|
||||
/// @return \Illuminate\Routing\Route
|
||||
Route substituteBindings(Route route);
|
||||
|
||||
/// Substitute the implicit Eloquent model bindings for the route.
|
||||
///
|
||||
/// @param \Illuminate\Routing\Route $route
|
||||
/// @return void
|
||||
void substituteImplicitBindings(Route route);
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
import 'dart:io';
|
||||
|
||||
abstract class ResponseFactory {
|
||||
/// Create a new response instance.
|
||||
///
|
||||
/// [content] can be an array or a string.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// Returns a Response object.
|
||||
HttpResponse make(dynamic content, {int status = 200, Map<String, String> headers = const {}});
|
||||
|
||||
/// Create a new "no content" response.
|
||||
///
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// Returns a Response object.
|
||||
HttpResponse noContent({int status = 204, Map<String, String> headers = const {}});
|
||||
|
||||
/// Create a new response for a given view.
|
||||
///
|
||||
/// [view] can be a string or an array.
|
||||
/// [data] is the data to be passed to the view.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// Returns a Response object.
|
||||
HttpResponse view(dynamic view, {Map<String, dynamic> data = const {}, int status = 200, Map<String, String> headers = const {}});
|
||||
|
||||
/// Create a new JSON response instance.
|
||||
///
|
||||
/// [data] is the data to be returned as JSON.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// [options] are the JSON options.
|
||||
/// Returns a JsonResponse object.
|
||||
HttpResponse json(dynamic data, {int status = 200, Map<String, String> headers = const {}, int options = 0});
|
||||
|
||||
/// Create a new JSONP response instance.
|
||||
///
|
||||
/// [callback] is the JSONP callback name.
|
||||
/// [data] is the data to be returned as JSONP.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// [options] are the JSON options.
|
||||
/// Returns a JsonResponse object.
|
||||
HttpResponse jsonp(String callback, dynamic data, {int status = 200, Map<String, String> headers = const {}, int options = 0});
|
||||
|
||||
/// Create a new streamed response instance.
|
||||
///
|
||||
/// [callback] is the callback function for streaming.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// Returns a StreamedResponse object.
|
||||
HttpResponse stream(Function callback, {int status = 200, Map<String, String> headers = const {}});
|
||||
|
||||
/// Create a new streamed response instance as a file download.
|
||||
///
|
||||
/// [callback] is the callback function for streaming.
|
||||
/// [name] is the name of the file.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// [disposition] is the content disposition.
|
||||
/// Returns a StreamedResponse object.
|
||||
HttpResponse streamDownload(Function callback, {String? name, Map<String, String> headers = const {}, String disposition = 'attachment'});
|
||||
|
||||
/// Create a new file download response.
|
||||
///
|
||||
/// [file] is the file to be downloaded.
|
||||
/// [name] is the name of the file.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// [disposition] is the content disposition.
|
||||
/// Returns a BinaryFileResponse object.
|
||||
HttpResponse download(dynamic file, {String? name, Map<String, String> headers = const {}, String disposition = 'attachment'});
|
||||
|
||||
/// Return the raw contents of a binary file.
|
||||
///
|
||||
/// [file] is the file to be returned.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// Returns a BinaryFileResponse object.
|
||||
HttpResponse file(dynamic file, {Map<String, String> headers = const {}});
|
||||
|
||||
/// Create a new redirect response to the given path.
|
||||
///
|
||||
/// [path] is the path to redirect to.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// [secure] indicates if the redirection should be secure.
|
||||
/// Returns a RedirectResponse object.
|
||||
HttpResponse redirectTo(String path, {int status = 302, Map<String, String> headers = const {}, bool? secure});
|
||||
|
||||
/// Create a new redirect response to a named route.
|
||||
///
|
||||
/// [route] is the name of the route.
|
||||
/// [parameters] are the parameters for the route.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// Returns a RedirectResponse object.
|
||||
HttpResponse redirectToRoute(String route, {dynamic parameters = const {}, int status = 302, Map<String, String> headers = const {}});
|
||||
|
||||
/// Create a new redirect response to a controller action.
|
||||
///
|
||||
/// [action] is the action name.
|
||||
/// [parameters] are the parameters for the action.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// Returns a RedirectResponse object.
|
||||
HttpResponse redirectToAction(dynamic action, {dynamic parameters = const {}, int status = 302, Map<String, String> headers = const {}});
|
||||
|
||||
/// Create a new redirect response, while putting the current URL in the session.
|
||||
///
|
||||
/// [path] is the path to redirect to.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// [secure] indicates if the redirection should be secure.
|
||||
/// Returns a RedirectResponse object.
|
||||
HttpResponse redirectGuest(String path, {int status = 302, Map<String, String> headers = const {}, bool? secure});
|
||||
|
||||
/// Create a new redirect response to the previously intended location.
|
||||
///
|
||||
/// [defaultPath] is the default path if no intended location is found.
|
||||
/// [status] is the HTTP status code.
|
||||
/// [headers] are the HTTP headers.
|
||||
/// [secure] indicates if the redirection should be secure.
|
||||
/// Returns a RedirectResponse object.
|
||||
HttpResponse redirectToIntended({String defaultPath = '/', int status = 302, Map<String, String> headers = const {}, bool? secure});
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
abstract class UrlGenerator {
|
||||
/// Get the current URL for the request.
|
||||
String current();
|
||||
|
||||
/// Get the URL for the previous request.
|
||||
String previous([dynamic fallback = false]);
|
||||
|
||||
/// Generate an absolute URL to the given path.
|
||||
String to(String path, [dynamic extra = const [], bool? secure]);
|
||||
|
||||
/// Generate a secure, absolute URL to the given path.
|
||||
String secure(String path, [Map<String, dynamic> parameters = const {}]);
|
||||
|
||||
/// Generate the URL to an application asset.
|
||||
String asset(String path, [bool? secure]);
|
||||
|
||||
/// Get the URL to a named route.
|
||||
///
|
||||
/// Throws [ArgumentError] if an invalid argument is provided.
|
||||
String route(String name, [dynamic parameters = const [], bool absolute = true]);
|
||||
|
||||
/// Create a signed route URL for a named route.
|
||||
///
|
||||
/// Throws [ArgumentError] if an invalid argument is provided.
|
||||
String signedRoute(String name, [dynamic parameters = const [], dynamic expiration, bool absolute = true]);
|
||||
|
||||
/// Create a temporary signed route URL for a named route.
|
||||
String temporarySignedRoute(String name, dynamic expiration, [Map<String, dynamic> parameters = const {}, bool absolute = true]);
|
||||
|
||||
/// Get the URL to a controller action.
|
||||
String action(dynamic action, [dynamic parameters = const [], bool absolute = true]);
|
||||
|
||||
/// Get the root controller namespace.
|
||||
String getRootControllerNamespace();
|
||||
|
||||
/// Set the root controller namespace.
|
||||
UrlGenerator setRootControllerNamespace(String rootNamespace);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
abstract class UrlRoutable {
|
||||
/// Get the value of the model's route key.
|
||||
///
|
||||
/// @return dynamic
|
||||
dynamic getRouteKey();
|
||||
|
||||
/// Get the route key for the model.
|
||||
///
|
||||
/// @return String
|
||||
String getRouteKeyName();
|
||||
|
||||
/// Retrieve the model for a bound value.
|
||||
///
|
||||
/// @param dynamic value
|
||||
/// @param String? field
|
||||
/// @return Model?
|
||||
Model? resolveRouteBinding(dynamic value, [String? field]);
|
||||
|
||||
/// Retrieve the child model for a bound value.
|
||||
///
|
||||
/// @param String childType
|
||||
/// @param dynamic value
|
||||
/// @param String? field
|
||||
/// @return Model?
|
||||
Model? resolveChildRouteBinding(String childType, dynamic value, [String? field]);
|
||||
}
|
||||
|
||||
// TODO: Fix Imports
|
||||
class Model {
|
||||
// This class is a placeholder for the actual Eloquent model implementation.
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
abstract class AuthenticatesSessions {
|
||||
// Add any methods or properties that are needed here
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
abstract class Session {
|
||||
/// Get the name of the session.
|
||||
String getName();
|
||||
|
||||
/// Set the name of the session.
|
||||
void setName(String name);
|
||||
|
||||
/// Get the current session ID.
|
||||
String getId();
|
||||
|
||||
/// Set the session ID.
|
||||
void setId(String id);
|
||||
|
||||
/// Start the session, reading the data from a handler.
|
||||
bool start();
|
||||
|
||||
/// Save the session data to storage.
|
||||
void save();
|
||||
|
||||
/// Get all of the session data.
|
||||
Map<String, dynamic> all();
|
||||
|
||||
/// Checks if a key exists.
|
||||
bool exists(dynamic key);
|
||||
|
||||
/// Checks if a key is present and not null.
|
||||
bool has(dynamic key);
|
||||
|
||||
/// Get an item from the session.
|
||||
dynamic get(String key, [dynamic defaultValue]);
|
||||
|
||||
/// Get the value of a given key and then forget it.
|
||||
dynamic pull(String key, [dynamic defaultValue]);
|
||||
|
||||
/// Put a key / value pair or array of key / value pairs in the session.
|
||||
void put(dynamic key, [dynamic value]);
|
||||
|
||||
/// Get the CSRF token value.
|
||||
String token();
|
||||
|
||||
/// Regenerate the CSRF token value.
|
||||
void regenerateToken();
|
||||
|
||||
/// Remove an item from the session, returning its value.
|
||||
dynamic remove(String key);
|
||||
|
||||
/// Remove one or many items from the session.
|
||||
void forget(dynamic keys);
|
||||
|
||||
/// Remove all of the items from the session.
|
||||
void flush();
|
||||
|
||||
/// Flush the session data and regenerate the ID.
|
||||
bool invalidate();
|
||||
|
||||
/// Generate a new session identifier.
|
||||
bool regenerate([bool destroy = false]);
|
||||
|
||||
/// Generate a new session ID for the session.
|
||||
bool migrate([bool destroy = false]);
|
||||
|
||||
/// Determine if the session has been started.
|
||||
bool isStarted();
|
||||
|
||||
/// Get the previous URL from the session.
|
||||
String? previousUrl();
|
||||
|
||||
/// Set the "previous" URL in the session.
|
||||
void setPreviousUrl(String url);
|
||||
|
||||
/// Get the session handler instance.
|
||||
SessionHandlerInterface getHandler();
|
||||
|
||||
/// Determine if the session handler needs a request.
|
||||
bool handlerNeedsRequest();
|
||||
|
||||
/// Set the request on the handler instance.
|
||||
void setRequestOnHandler(Request request);
|
||||
}
|
||||
|
||||
// TODO: Fix Imports
|
||||
abstract class SessionHandlerInterface {
|
||||
// Define the necessary methods for SessionHandlerInterface
|
||||
}
|
||||
|
||||
class Request {
|
||||
// Define the necessary methods and properties for Request
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
abstract class Arrayable<TKey, TValue> {
|
||||
/// Get the instance as an array.
|
||||
///
|
||||
/// @return Map<TKey, TValue>
|
||||
Map<TKey, TValue> toArray();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
abstract class CanBeEscapedWhenCastToString {
|
||||
/// Indicate that the object's string representation should be escaped when toString is invoked.
|
||||
///
|
||||
/// @param bool escape
|
||||
/// @return this
|
||||
CanBeEscapedWhenCastToString escapeWhenCastingToString(bool escape);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
abstract class DeferrableProvider {
|
||||
/// Get the services provided by the provider.
|
||||
///
|
||||
/// @return List<String>
|
||||
List<String> provides();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
//import 'package:your_package_name/htmlable.dart';
|
||||
|
||||
abstract class DeferringDisplayableValue {
|
||||
/// Resolve the displayable value that the class is deferring.
|
||||
///
|
||||
/// @return Htmlable or String
|
||||
dynamic resolveDisplayableValue(); // Return type is dynamic to allow Htmlable or String
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
abstract class Htmlable {
|
||||
/// Get content as a string of HTML.
|
||||
///
|
||||
/// @return String
|
||||
String toHtml();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
abstract class Jsonable {
|
||||
/// Convert the object to its JSON representation.
|
||||
///
|
||||
/// [options] Optional argument for JSON encoding options.
|
||||
/// Returns the JSON representation of the object as a String.
|
||||
String toJson({int options = 0});
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
import 'arrayable.dart';
|
||||
import 'countable.dart';
|
||||
|
||||
// TODO: Fix Imports.
|
||||
|
||||
abstract class MessageBag implements Arrayable, Countable {
|
||||
/// Get the keys present in the message bag.
|
||||
List<String> keys();
|
||||
|
||||
/// Add a message to the bag.
|
||||
///
|
||||
/// Returns this instance for chaining.
|
||||
MessageBag add(String key, String message);
|
||||
|
||||
/// Merge a new array of messages into the bag.
|
||||
///
|
||||
/// Returns this instance for chaining.
|
||||
MessageBag merge(dynamic messages);
|
||||
|
||||
/// Determine if messages exist for a given key.
|
||||
bool has(dynamic key);
|
||||
|
||||
/// Get the first message from the bag for a given key.
|
||||
String first([String? key, String? format]);
|
||||
|
||||
/// Get all of the messages from the bag for a given key.
|
||||
List<String> get(String key, [String? format]);
|
||||
|
||||
/// Get all of the messages for every key in the bag.
|
||||
List<String> all([String? format]);
|
||||
|
||||
/// Remove a message from the bag.
|
||||
///
|
||||
/// Returns this instance for chaining.
|
||||
MessageBag forget(String key);
|
||||
|
||||
/// Get the raw messages in the container.
|
||||
List<dynamic> getMessages();
|
||||
|
||||
/// Get the default message format.
|
||||
String getFormat();
|
||||
|
||||
/// Set the default message format.
|
||||
///
|
||||
/// Returns this instance for chaining.
|
||||
MessageBag setFormat([String format = ':message']);
|
||||
|
||||
/// Determine if the message bag has any messages.
|
||||
bool isEmpty();
|
||||
|
||||
/// Determine if the message bag has any messages.
|
||||
bool isNotEmpty();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import 'message_bag.dart';
|
||||
|
||||
abstract class MessageProvider {
|
||||
/// Get the messages for the instance.
|
||||
///
|
||||
/// @return MessageBag
|
||||
MessageBag getMessageBag();
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
abstract class Renderable {
|
||||
/// Get the evaluated contents of the object.
|
||||
///
|
||||
/// Returns a string representation of the contents.
|
||||
String render();
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import 'package:symfony_http_foundation/response.dart';
|
||||
import 'request.dart';
|
||||
|
||||
// TODO: Fix Imports.
|
||||
abstract class Responsable {
|
||||
/// Create an HTTP response that represents the object.
|
||||
///
|
||||
/// @param Request request
|
||||
/// @return Response
|
||||
Response toResponse(Request request);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
//import 'dart:collection';
|
||||
import 'arrayable.dart';
|
||||
|
||||
abstract class ValidatedData implements Arrayable, Map<String, dynamic> {
|
||||
@override
|
||||
Iterator<MapEntry<String, dynamic>> get iterator => entries.iterator;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
abstract class HasLocalePreference {
|
||||
/// Get the preferred locale of the entity.
|
||||
///
|
||||
/// Returns a [String] representing the preferred locale or null if none is set.
|
||||
String? preferredLocale();
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
abstract class Loader {
|
||||
/// Load the messages for the given locale.
|
||||
///
|
||||
/// [locale] is the locale to load messages for.
|
||||
/// [group] is the message group to load.
|
||||
/// [namespace] is the optional namespace to load messages from.
|
||||
/// Returns a list of messages.
|
||||
List<dynamic> load(String locale, String group, [String? namespace]);
|
||||
|
||||
/// Add a new namespace to the loader.
|
||||
///
|
||||
/// [namespace] is the name of the namespace.
|
||||
/// [hint] is the path hint for the namespace.
|
||||
void addNamespace(String namespace, String hint);
|
||||
|
||||
/// Add a new JSON path to the loader.
|
||||
///
|
||||
/// [path] is the path to the JSON file.
|
||||
void addJsonPath(String path);
|
||||
|
||||
/// Get an array of all the registered namespaces.
|
||||
///
|
||||
/// Returns a map of all registered namespaces and their hints.
|
||||
Map<String, String> namespaces();
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
abstract class Translator {
|
||||
/// Get the translation for a given key.
|
||||
///
|
||||
/// @param String key
|
||||
/// @param Map<String, dynamic> replace
|
||||
/// @param String? locale
|
||||
/// @return dynamic
|
||||
dynamic get(String key, {Map<String, dynamic> replace = const {}, String? locale});
|
||||
|
||||
/// Get a translation according to an integer value.
|
||||
///
|
||||
/// @param String key
|
||||
/// @param dynamic number (Countable, int, double, or List)
|
||||
/// @param Map<String, dynamic> replace
|
||||
/// @param String? locale
|
||||
/// @return String
|
||||
String choice(String key, dynamic number, {Map<String, dynamic> replace = const {}, String? locale});
|
||||
|
||||
/// Get the default locale being used.
|
||||
///
|
||||
/// @return String
|
||||
String getLocale();
|
||||
|
||||
/// Set the default locale.
|
||||
///
|
||||
/// @param String locale
|
||||
/// @return void
|
||||
void setLocale(String locale);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
abstract class DataAwareRule {
|
||||
/// Sets the data under validation.
|
||||
///
|
||||
/// @param Map<String, dynamic> data - The data to be validated.
|
||||
/// @return DataAwareRule - The instance of the implementing class.
|
||||
DataAwareRule setData(Map<String, dynamic> data);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import 'validator.dart';
|
||||
abstract class Factory {
|
||||
/// Create a new Validator instance.
|
||||
///
|
||||
/// @param Map<String, dynamic> data
|
||||
/// @param Map<String, dynamic> rules
|
||||
/// @param Map<String, String> messages
|
||||
/// @param Map<String, String> attributes
|
||||
/// @return Validator
|
||||
Validator make(
|
||||
Map<String, dynamic> data,
|
||||
Map<String, dynamic> rules,
|
||||
[Map<String, String> messages = const {},
|
||||
Map<String, String> attributes = const {}]);
|
||||
|
||||
/// Register a custom validator extension.
|
||||
///
|
||||
/// @param String rule
|
||||
/// @param Function|string extension
|
||||
/// @param String|null message
|
||||
/// @return void
|
||||
void extend(String rule, dynamic extension, [String? message]);
|
||||
|
||||
/// Register a custom implicit validator extension.
|
||||
///
|
||||
/// @param String rule
|
||||
/// @param Function|string extension
|
||||
/// @param String|null message
|
||||
/// @return void
|
||||
void extendImplicit(String rule, dynamic extension, [String? message]);
|
||||
|
||||
/// Register a custom implicit validator message replacer.
|
||||
///
|
||||
/// @param String rule
|
||||
/// @param Function|string replacer
|
||||
/// @return void
|
||||
void replacer(String rule, dynamic replacer);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// Import the necessary file where the Rule interface is defined
|
||||
import 'rule.dart';
|
||||
|
||||
/// @deprecated see ValidationRule
|
||||
abstract class ImplicitRule implements Rule {
|
||||
// Empty abstract class to follow the structure of the original interface
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
// Import necessary libraries
|
||||
import 'dart:core';
|
||||
|
||||
// Define a type alias for the fail function closure
|
||||
typedef FailFunction = void Function(String);
|
||||
|
||||
// Define the InvokableRule interface
|
||||
///@deprecated see ValidateRule
|
||||
abstract class InvokableRule {
|
||||
/// Run the validation rule.
|
||||
///
|
||||
/// @param attribute The attribute being validated.
|
||||
/// @param value The value of the attribute.
|
||||
/// @param fail A function that will be called if the validation fails.
|
||||
void call(String attribute, dynamic value, FailFunction fail);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
/// @deprecated see ValidationRule
|
||||
abstract class Rule {
|
||||
/// Determine if the validation rule passes.
|
||||
///
|
||||
/// @param attribute The name of the attribute.
|
||||
/// @param value The value of the attribute.
|
||||
/// @return True if the validation rule passes, false otherwise.
|
||||
bool passes(String attribute, dynamic value);
|
||||
|
||||
/// Get the validation error message.
|
||||
///
|
||||
/// @return The validation error message as a string or list of strings.
|
||||
dynamic message();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import 'package:meta/meta.dart';
|
||||
|
||||
abstract class UncompromisedVerifier {
|
||||
/// Verify that the given data has not been compromised in data leaks.
|
||||
///
|
||||
/// @param List<String> data
|
||||
/// @return bool
|
||||
bool verify(List<String> data);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
abstract class ValidatesWhenResolved {
|
||||
/// Validate the given class instance.
|
||||
///
|
||||
/// This method should be overridden to implement the validation logic.
|
||||
void validateResolved();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
import 'package:meta/meta.dart';
|
||||
|
||||
typedef FailCallback = void Function(String message);
|
||||
|
||||
abstract class ValidationRule {
|
||||
/// Run the validation rule.
|
||||
///
|
||||
/// @param attribute The name of the attribute being validated.
|
||||
/// @param value The value of the attribute.
|
||||
/// @param fail A callback function that accepts a failure message.
|
||||
void validate(String attribute, dynamic value, FailCallback fail);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import 'message_provider.dart';
|
||||
import 'validation_exception.dart';
|
||||
import 'message_bag.dart';
|
||||
|
||||
// TODO: Fix Imports.
|
||||
|
||||
abstract class Validator implements MessageProvider {
|
||||
/// Run the validator's rules against its data.
|
||||
///
|
||||
/// Throws a [ValidationException] if validation fails.
|
||||
///
|
||||
/// Returns a map of validated data.
|
||||
Map<String, dynamic> validate();
|
||||
|
||||
/// Get the attributes and values that were validated.
|
||||
///
|
||||
/// Throws a [ValidationException] if validation fails.
|
||||
///
|
||||
/// Returns a map of validated data.
|
||||
Map<String, dynamic> validated();
|
||||
|
||||
/// Determine if the data fails the validation rules.
|
||||
///
|
||||
/// Returns true if validation fails, false otherwise.
|
||||
bool fails();
|
||||
|
||||
/// Get the failed validation rules.
|
||||
///
|
||||
/// Returns a map of failed validation rules.
|
||||
Map<String, dynamic> failed();
|
||||
|
||||
/// Add conditions to a given field based on a callback.
|
||||
///
|
||||
/// Takes an [attribute], [rules], and a [callback] function.
|
||||
///
|
||||
/// Returns the current instance of [Validator].
|
||||
Validator sometimes(dynamic attribute, dynamic rules, Function callback);
|
||||
|
||||
/// Add an after validation callback.
|
||||
///
|
||||
/// Takes a [callback] function.
|
||||
///
|
||||
/// Returns the current instance of [Validator].
|
||||
Validator after(Function callback);
|
||||
|
||||
/// Get all of the validation error messages.
|
||||
///
|
||||
/// Returns a [MessageBag] containing the error messages.
|
||||
MessageBag errors();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import 'validator.dart'; // Assume this is the correct import for the Validator class
|
||||
|
||||
abstract class ValidatorAwareRule {
|
||||
/// Set the current validator.
|
||||
///
|
||||
/// @param Validator validator
|
||||
/// @return ValidatorAwareRule
|
||||
ValidatorAwareRule setValidator(Validator validator);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
abstract class Engine {
|
||||
/// Get the evaluated contents of the view.
|
||||
///
|
||||
/// @param String path
|
||||
/// @param Map<String, dynamic> data
|
||||
/// @return String
|
||||
String get(String path, {Map<String, dynamic> data = const {}});
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
import 'view.dart';
|
||||
|
||||
abstract class Factory {
|
||||
/// Determine if a given view exists.
|
||||
///
|
||||
/// @param String view
|
||||
/// @return bool
|
||||
bool exists(String view);
|
||||
|
||||
/// Get the evaluated view contents for the given path.
|
||||
///
|
||||
/// @param String path
|
||||
/// @param Map<String, dynamic> data
|
||||
/// @param Map<String, dynamic> mergeData
|
||||
/// @return View
|
||||
View file(String path, {Map<String, dynamic>? data, Map<String, dynamic>? mergeData});
|
||||
|
||||
/// Get the evaluated view contents for the given view.
|
||||
///
|
||||
/// @param String view
|
||||
/// @param Map<String, dynamic> data
|
||||
/// @param Map<String, dynamic> mergeData
|
||||
/// @return View
|
||||
View make(String view, {Map<String, dynamic>? data, Map<String, dynamic>? mergeData});
|
||||
|
||||
/// Add a piece of shared data to the environment.
|
||||
///
|
||||
/// @param dynamic key
|
||||
/// @param dynamic value
|
||||
/// @return dynamic
|
||||
dynamic share(dynamic key, {dynamic value});
|
||||
|
||||
/// Register a view composer event.
|
||||
///
|
||||
/// @param dynamic views
|
||||
/// @param dynamic callback
|
||||
/// @return List
|
||||
List composer(dynamic views, dynamic callback);
|
||||
|
||||
/// Register a view creator event.
|
||||
///
|
||||
/// @param dynamic views
|
||||
/// @param dynamic callback
|
||||
/// @return List
|
||||
List creator(dynamic views, dynamic callback);
|
||||
|
||||
/// Add a new namespace to the loader.
|
||||
///
|
||||
/// @param String namespace
|
||||
/// @param dynamic hints
|
||||
/// @return Factory
|
||||
Factory addNamespace(String namespace, dynamic hints);
|
||||
|
||||
/// Replace the namespace hints for the given namespace.
|
||||
///
|
||||
/// @param String namespace
|
||||
/// @param dynamic hints
|
||||
/// @return Factory
|
||||
Factory replaceNamespace(String namespace, dynamic hints);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
import "package:fabric_contracts/support.dart";
|
||||
|
||||
abstract class View extends Renderable {
|
||||
/// Get the name of the view.
|
||||
String name();
|
||||
|
||||
/// Add a piece of data to the view.
|
||||
///
|
||||
/// @param String|Map key
|
||||
/// @param dynamic value
|
||||
/// @return View
|
||||
View with(dynamic key, [dynamic value]);
|
||||
|
||||
/// Get the array of view data.
|
||||
Map<String, dynamic> getData();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
import 'package:meta/meta.dart';
|
||||
|
||||
class ViewCompilationException implements Exception {
|
||||
final String? message;
|
||||
|
||||
ViewCompilationException([this.message]);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return message ?? 'ViewCompilationException';
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue