update: updating files with ported code
This commit is contained in:
parent
b09546501f
commit
1ba4afc563
14 changed files with 505 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
import 'package:your_project/attachment.dart';
|
||||
|
||||
// TODO: Check imports
|
||||
|
||||
abstract class Attachable {
|
||||
/// Get an attachment instance for this entity.
|
||||
///
|
||||
/// @return Attachment
|
||||
Attachment toMailAttachment();
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// import statements for required packages
|
||||
import 'mailer.dart';
|
||||
|
||||
abstract class Factory {
|
||||
/// Get a mailer instance by name.
|
||||
///
|
||||
/// @param [name] The name of the mailer instance.
|
||||
/// @return An instance of [Mailer].
|
||||
Mailer mailer([String? name]);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// Import necessary libraries
|
||||
import 'dart:async';
|
||||
|
||||
/// Represents the MailQueue interface.
|
||||
abstract class MailQueue {
|
||||
/// Queues a new e-mail message for sending.
|
||||
///
|
||||
/// [view] can be a Mailable, String, or List.
|
||||
/// [queue] is the optional queue name.
|
||||
/// Returns a Future representing the queued result.
|
||||
Future<dynamic> queue(dynamic view, {String? queue});
|
||||
|
||||
/// Queues a new e-mail message for sending after [delay].
|
||||
///
|
||||
/// [delay] can be a Duration, int (in seconds), or DateTime.
|
||||
/// [view] can be a Mailable, String, or List.
|
||||
/// [queue] is the optional queue name.
|
||||
/// Returns a Future representing the queued result.
|
||||
Future<dynamic> later(dynamic delay, dynamic view, {String? queue});
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
import 'package:some_package/queue.dart'; // Replace with actual queue package
|
||||
import 'package:some_package/mail.dart'; // Replace with actual mail package
|
||||
|
||||
// TODO: Check Imports.
|
||||
|
||||
abstract class Mailable {
|
||||
/// Send the message using the given mailer.
|
||||
///
|
||||
/// @param Factory|Mailer $mailer
|
||||
/// @return SentMessage|null
|
||||
Future<SentMessage?> send(Mailer mailer);
|
||||
|
||||
/// Queue the given message.
|
||||
///
|
||||
/// @param Queue $queue
|
||||
/// @return dynamic
|
||||
Future<dynamic> queue(Queue queue);
|
||||
|
||||
/// Deliver the queued message after (n) seconds.
|
||||
///
|
||||
/// @param DateTimeInterface|Duration|int $delay
|
||||
/// @param Queue $queue
|
||||
/// @return dynamic
|
||||
Future<dynamic> later(dynamic delay, Queue queue);
|
||||
|
||||
/// Set the recipients of the message.
|
||||
///
|
||||
/// @param dynamic $address
|
||||
/// @param String? $name
|
||||
/// @return self
|
||||
Mailable cc(dynamic address, [String? name]);
|
||||
|
||||
/// Set the recipients of the message.
|
||||
///
|
||||
/// @param dynamic $address
|
||||
/// @param String? $name
|
||||
/// @return $this
|
||||
Mailable bcc(dynamic address, [String? name]);
|
||||
|
||||
/// Set the recipients of the message.
|
||||
///
|
||||
/// @param dynamic $address
|
||||
/// @param String? $name
|
||||
/// @return $this
|
||||
Mailable to(dynamic address, [String? name]);
|
||||
|
||||
/// Set the locale of the message.
|
||||
///
|
||||
/// @param String $locale
|
||||
/// @return $this
|
||||
Mailable locale(String locale);
|
||||
|
||||
/// Set the name of the mailer that should be used to send the message.
|
||||
///
|
||||
/// @param String $mailer
|
||||
/// @return $this
|
||||
Mailable mailer(String mailer);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
abstract class Mailer {
|
||||
/// Begin the process of mailing a mailable class instance.
|
||||
///
|
||||
/// [users] can be of any type.
|
||||
/// Returns a PendingMail instance.
|
||||
PendingMail to(dynamic users);
|
||||
|
||||
/// Begin the process of mailing a mailable class instance.
|
||||
///
|
||||
/// [users] can be of any type.
|
||||
/// Returns a PendingMail instance.
|
||||
PendingMail bcc(dynamic users);
|
||||
|
||||
/// Send a new message with only a raw text part.
|
||||
///
|
||||
/// [text] is the raw text message.
|
||||
/// [callback] can be of any type.
|
||||
/// Returns a SentMessage instance or null.
|
||||
SentMessage? raw(String text, dynamic callback);
|
||||
|
||||
/// Send a new message using a view.
|
||||
///
|
||||
/// [view] can be of type Mailable, String, or List.
|
||||
/// [data] is a map of data to pass to the view.
|
||||
/// [callback] is a function or null.
|
||||
/// Returns a SentMessage instance or null.
|
||||
SentMessage? send(dynamic view, {Map<String, dynamic> data = const {}, dynamic callback});
|
||||
|
||||
/// Send a new message synchronously using a view.
|
||||
///
|
||||
/// [mailable] can be of type Mailable, String, or List.
|
||||
/// [data] is a map of data to pass to the view.
|
||||
/// [callback] is a function or null.
|
||||
/// Returns a SentMessage instance or null.
|
||||
SentMessage? sendNow(dynamic mailable, {Map<String, dynamic> data = const {}, dynamic callback});
|
||||
}
|
||||
|
||||
class PendingMail {
|
||||
// Implementation of PendingMail class
|
||||
}
|
||||
|
||||
class SentMessage {
|
||||
// Implementation of SentMessage class
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
abstract class Dispatcher {
|
||||
/// Send the given notification to the given notifiable entities.
|
||||
///
|
||||
/// @param List<dynamic>|dynamic notifiables
|
||||
/// @param dynamic notification
|
||||
/// @return void
|
||||
void send(dynamic notifiables, dynamic notification);
|
||||
|
||||
/// Send the given notification immediately.
|
||||
///
|
||||
/// @param List<dynamic>|dynamic notifiables
|
||||
/// @param dynamic notification
|
||||
/// @param List<String>? channels
|
||||
/// @return void
|
||||
void sendNow(dynamic notifiables, dynamic notification, List<String>? channels);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
// Define the namespace (this would be part of the file structure in Dart)
|
||||
//library illuminate.contracts.notifications;
|
||||
|
||||
// TODO: Check imports - Check for way to do namespaces
|
||||
|
||||
// Import necessary Dart packages
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
// Define the Factory interface
|
||||
abstract class Factory {
|
||||
/// Get a channel instance by name.
|
||||
///
|
||||
/// @param String? name
|
||||
/// @return dynamic
|
||||
dynamic channel(String? name);
|
||||
|
||||
/// Send the given notification to the given notifiable entities.
|
||||
///
|
||||
/// @param dynamic notifiables
|
||||
/// @param dynamic notification
|
||||
/// @return void
|
||||
void send(dynamic notifiables, dynamic notification);
|
||||
|
||||
/// Send the given notification immediately.
|
||||
///
|
||||
/// @param dynamic notifiables
|
||||
/// @param dynamic notification
|
||||
/// @return void
|
||||
void sendNow(dynamic notifiables, dynamic notification);
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
abstract class CursorPaginator<T> {
|
||||
/// Get the URL for a given cursor.
|
||||
///
|
||||
/// @param Cursor? cursor
|
||||
/// @return String
|
||||
String url(Cursor? cursor);
|
||||
|
||||
/// Add a set of query string values to the paginator.
|
||||
///
|
||||
/// @param List<Object>? key
|
||||
/// @param String? value
|
||||
/// @return $this
|
||||
CursorPaginator<T> appends(dynamic key, [String? value]);
|
||||
|
||||
/// Get / set the URL fragment to be appended to URLs.
|
||||
///
|
||||
/// @param String? fragment
|
||||
/// @return $this|String?
|
||||
dynamic fragment([String? fragment]);
|
||||
|
||||
/// Add all current query string values to the paginator.
|
||||
///
|
||||
/// @return $this
|
||||
CursorPaginator<T> withQueryString();
|
||||
|
||||
/// Get the URL for the previous page, or null.
|
||||
///
|
||||
/// @return String?
|
||||
String? previousPageUrl();
|
||||
|
||||
/// The URL for the next page, or null.
|
||||
///
|
||||
/// @return String?
|
||||
String? nextPageUrl();
|
||||
|
||||
/// Get all of the items being paginated.
|
||||
///
|
||||
/// @return List<T>
|
||||
List<T> items();
|
||||
|
||||
/// Get the "cursor" of the previous set of items.
|
||||
///
|
||||
/// @return Cursor?
|
||||
Cursor? previousCursor();
|
||||
|
||||
/// Get the "cursor" of the next set of items.
|
||||
///
|
||||
/// @return Cursor?
|
||||
Cursor? nextCursor();
|
||||
|
||||
/// Determine how many items are being shown per page.
|
||||
///
|
||||
/// @return int
|
||||
int perPage();
|
||||
|
||||
/// Get the current cursor being paginated.
|
||||
///
|
||||
/// @return Cursor?
|
||||
Cursor? cursor();
|
||||
|
||||
/// Determine if there are enough items to split into multiple pages.
|
||||
///
|
||||
/// @return bool
|
||||
bool hasPages();
|
||||
|
||||
/// Get the base path for paginator generated URLs.
|
||||
///
|
||||
/// @return String?
|
||||
String? path();
|
||||
|
||||
/// Determine if the list of items is empty or not.
|
||||
///
|
||||
/// @return bool
|
||||
bool isEmpty();
|
||||
|
||||
/// Determine if the list of items is not empty.
|
||||
///
|
||||
/// @return bool
|
||||
bool isNotEmpty();
|
||||
|
||||
/// Render the paginator using a given view.
|
||||
///
|
||||
/// @param String? view
|
||||
/// @param Map<String, dynamic> data
|
||||
/// @return String
|
||||
String render([String? view, Map<String, dynamic> data = const {}]);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import 'paginator.dart';
|
||||
|
||||
abstract class LengthAwarePaginator extends Paginator {
|
||||
/// Create a range of pagination URLs.
|
||||
///
|
||||
/// @param int start
|
||||
/// @param int end
|
||||
/// @return List<String>
|
||||
List<String> getUrlRange(int start, int end);
|
||||
|
||||
/// Determine the total number of items in the data store.
|
||||
///
|
||||
/// @return int
|
||||
int total();
|
||||
|
||||
/// Get the page number of the last available page.
|
||||
///
|
||||
/// @return int
|
||||
int lastPage();
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
abstract class Paginator {
|
||||
/// Get the URL for a given page.
|
||||
///
|
||||
/// @param int $page
|
||||
/// @return string
|
||||
String url(int page);
|
||||
|
||||
/// Add a set of query string values to the paginator.
|
||||
///
|
||||
/// @param array|string|null $key
|
||||
/// @param string|null $value
|
||||
/// @return $this
|
||||
Paginator appends(dynamic key, [String? value]);
|
||||
|
||||
/// Get / set the URL fragment to be appended to URLs.
|
||||
///
|
||||
/// @param string|null $fragment
|
||||
/// @return $this|string|null
|
||||
dynamic fragment([String? fragment]);
|
||||
|
||||
/// The URL for the next page, or null.
|
||||
///
|
||||
/// @return string|null
|
||||
String? nextPageUrl();
|
||||
|
||||
/// Get the URL for the previous page, or null.
|
||||
///
|
||||
/// @return string|null
|
||||
String? previousPageUrl();
|
||||
|
||||
/// Get all of the items being paginated.
|
||||
///
|
||||
/// @return array
|
||||
List<dynamic> items();
|
||||
|
||||
/// Get the "index" of the first item being paginated.
|
||||
///
|
||||
/// @return int|null
|
||||
int? firstItem();
|
||||
|
||||
/// Get the "index" of the last item being paginated.
|
||||
///
|
||||
/// @return int|null
|
||||
int? lastItem();
|
||||
|
||||
/// Determine how many items are being shown per page.
|
||||
///
|
||||
/// @return int
|
||||
int perPage();
|
||||
|
||||
/// Determine the current page being paginated.
|
||||
///
|
||||
/// @return int
|
||||
int currentPage();
|
||||
|
||||
/// Determine if there are enough items to split into multiple pages.
|
||||
///
|
||||
/// @return bool
|
||||
bool hasPages();
|
||||
|
||||
/// Determine if there are more items in the data store.
|
||||
///
|
||||
/// @return bool
|
||||
bool hasMorePages();
|
||||
|
||||
/// Get the base path for paginator generated URLs.
|
||||
///
|
||||
/// @return string|null
|
||||
String? path();
|
||||
|
||||
/// Determine if the list of items is empty or not.
|
||||
///
|
||||
/// @return bool
|
||||
bool isEmpty();
|
||||
|
||||
/// Determine if the list of items is not empty.
|
||||
///
|
||||
/// @return bool
|
||||
bool isNotEmpty();
|
||||
|
||||
/// Render the paginator using a given view.
|
||||
///
|
||||
/// @param string|null $view
|
||||
/// @param array $data
|
||||
/// @return string
|
||||
String render([String? view, Map<String, dynamic> data = const {}]);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// Define a Dart interface for Hub
|
||||
|
||||
abstract class Hub {
|
||||
/// Send an object through one of the available pipelines.
|
||||
///
|
||||
/// @param object The object to be piped.
|
||||
/// @param pipeline The name of the pipeline, or null to use the default.
|
||||
/// @return The processed object.
|
||||
dynamic pipe(dynamic object, [String? pipeline]);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import 'dart:async';
|
||||
|
||||
abstract class Pipeline {
|
||||
/// Set the traveler object being sent on the pipeline.
|
||||
Pipeline send(dynamic traveler);
|
||||
|
||||
/// Set the stops of the pipeline.
|
||||
Pipeline through(dynamic stops);
|
||||
|
||||
/// Set the method to call on the stops.
|
||||
Pipeline via(String method);
|
||||
|
||||
/// Run the pipeline with a final destination callback.
|
||||
FutureOr<dynamic> then(FutureOr<dynamic> Function() destination);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
import 'process_result.dart';
|
||||
abstract class InvokedProcess {
|
||||
/// Get the process ID if the process is still running.
|
||||
///
|
||||
/// Returns an integer or null.
|
||||
int? id();
|
||||
|
||||
/// Send a signal to the process.
|
||||
///
|
||||
/// Takes an integer [signal] and returns the current instance.
|
||||
InvokedProcess signal(int signal);
|
||||
|
||||
/// Determine if the process is still running.
|
||||
///
|
||||
/// Returns a boolean.
|
||||
bool running();
|
||||
|
||||
/// Get the standard output for the process.
|
||||
///
|
||||
/// Returns a string.
|
||||
String output();
|
||||
|
||||
/// Get the error output for the process.
|
||||
///
|
||||
/// Returns a string.
|
||||
String errorOutput();
|
||||
|
||||
/// Get the latest standard output for the process.
|
||||
///
|
||||
/// Returns a string.
|
||||
String latestOutput();
|
||||
|
||||
/// Get the latest error output for the process.
|
||||
///
|
||||
/// Returns a string.
|
||||
String latestErrorOutput();
|
||||
|
||||
/// Wait for the process to finish.
|
||||
///
|
||||
/// Takes an optional [output] callback and returns a ProcessResult instance.
|
||||
Future<ProcessResult> wait([Future<void> Function()? output]);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
abstract class ProcessResult {
|
||||
/// Get the original command executed by the process.
|
||||
///
|
||||
/// @return String
|
||||
String command();
|
||||
|
||||
/// Determine if the process was successful.
|
||||
///
|
||||
/// @return bool
|
||||
bool successful();
|
||||
|
||||
/// Determine if the process failed.
|
||||
///
|
||||
/// @return bool
|
||||
bool failed();
|
||||
|
||||
/// Get the exit code of the process.
|
||||
///
|
||||
/// @return int|null
|
||||
int? exitCode();
|
||||
|
||||
/// Get the standard output of the process.
|
||||
///
|
||||
/// @return String
|
||||
String output();
|
||||
|
||||
/// Determine if the output contains the given string.
|
||||
///
|
||||
/// @param String output
|
||||
/// @return bool
|
||||
bool seeInOutput(String output);
|
||||
|
||||
/// Get the error output of the process.
|
||||
///
|
||||
/// @return String
|
||||
String errorOutput();
|
||||
|
||||
/// Determine if the error output contains the given string.
|
||||
///
|
||||
/// @param String output
|
||||
/// @return bool
|
||||
bool seeInErrorOutput(String output);
|
||||
|
||||
/// Throw an exception if the process failed.
|
||||
///
|
||||
/// @param Function? callback
|
||||
/// @return ProcessResult
|
||||
ProcessResult throwException([Function? callback]);
|
||||
|
||||
/// Throw an exception if the process failed and the given condition is true.
|
||||
///
|
||||
/// @param bool condition
|
||||
/// @param Function? callback
|
||||
/// @return ProcessResult
|
||||
ProcessResult throwIf(bool condition, [Function? callback]);
|
||||
}
|
Loading…
Reference in a new issue