mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add definition for "node-schedule".
Update definition for "maildev".
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
/// <reference path="maildev.d.ts"/>
|
||||
|
||||
import MailDev = require("maildev")
|
||||
|
||||
var options: MailDevOptions = {smtp: 1025};
|
||||
var maildev = new MailDev(options);
|
||||
|
||||
var errorCallback = (error: Error) => {};
|
||||
maildev.listen(errorCallback);
|
||||
|
||||
var eventName = 'new';
|
||||
maildev.on(eventName, errorCallback)
|
||||
Vendored
+111
-84
@@ -5,105 +5,132 @@
|
||||
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
import fs = require("fs");
|
||||
|
||||
/**
|
||||
* Interface for {@link MailDev} options.
|
||||
*/
|
||||
interface MailDevOptions {
|
||||
/**
|
||||
* SMTP host for outgoing emails
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
outgoingHost: string;
|
||||
/**
|
||||
* SMTP host for outgoing emails
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
outgoingHost?: string;
|
||||
|
||||
/**
|
||||
* SMTP password for outgoing emails
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
outgoingPass: string;
|
||||
/**
|
||||
* SMTP password for outgoing emails
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
outgoingPass?: string;
|
||||
|
||||
/**
|
||||
* SMTP port for outgoing emails.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
outgoingPort: number;
|
||||
/**
|
||||
* SMTP port for outgoing emails.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
outgoingPort?: number;
|
||||
|
||||
/**
|
||||
* SMTP user for outgoing emails
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
outgoingUser: string;
|
||||
/**
|
||||
* SMTP user for outgoing emails
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
outgoingUser?: string;
|
||||
|
||||
/**
|
||||
* SMTP port to catch emails.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
smtp: number;
|
||||
/**
|
||||
* SMTP port to catch emails.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
smtp?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for {@link MailDev}.
|
||||
* Interface for mail.
|
||||
*/
|
||||
interface MailDev {
|
||||
interface Mail {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @public
|
||||
* @param options The options.
|
||||
* Identifier.
|
||||
*/
|
||||
new(options: MailDevOptions): MailDev;
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* Stops the SMTP server.
|
||||
*
|
||||
* @public
|
||||
* @param callback The error callback.
|
||||
* Client.
|
||||
*/
|
||||
end(callback?: (error: Error) => void): void;
|
||||
|
||||
/**
|
||||
* Accepts e-mail identifier, returns email object.
|
||||
*
|
||||
* @public
|
||||
* @param id The e-mail identifier.
|
||||
*/
|
||||
getEmail(id: string, callback?: (error: Error) => void): void;
|
||||
|
||||
/**
|
||||
* Returns a readable stream of the raw e-mail.
|
||||
*
|
||||
* @public
|
||||
* @param id The e-mail identifier.
|
||||
*/
|
||||
getRawEmail(id: string, callback?: (error: Error, readStream: fs.ReadStream) => void): void;
|
||||
|
||||
/**
|
||||
* Returns array of all e-mail.
|
||||
|
||||
* @public
|
||||
*/
|
||||
getAllEmail(): void;
|
||||
|
||||
/**
|
||||
* Starts the SMTP server.
|
||||
*
|
||||
* @public
|
||||
* @param callback The error callback.
|
||||
*/
|
||||
listen(callback?: (error: Error) => void): void;
|
||||
|
||||
/**
|
||||
* Event called when a new e-mail is received. Callback receives single mail object.
|
||||
*
|
||||
* @public
|
||||
* @param eventName The event name.
|
||||
* @param callback The callback for obtains the received email.
|
||||
*/
|
||||
on(eventName: string, callback: (email: string) => void): void;
|
||||
envelope?: Object;
|
||||
}
|
||||
|
||||
declare module "maildev" {
|
||||
import fs = require("fs");
|
||||
|
||||
/**
|
||||
* Interface for {@link MailDev}.
|
||||
*/
|
||||
class MailDev {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @public
|
||||
* @param {MailDevOptions} options The options.
|
||||
*/
|
||||
constructor(options: MailDevOptions);
|
||||
|
||||
/**
|
||||
* Stops the SMTP server.
|
||||
*
|
||||
* @public
|
||||
* @param callback The error callback.
|
||||
*/
|
||||
end(callback?: (error: Error) => void): void;
|
||||
|
||||
/**
|
||||
* Accepts e-mail identifier, returns email object.
|
||||
*
|
||||
* @public
|
||||
* @param {string} id The e-mail identifier.
|
||||
*/
|
||||
getEmail(id: string, callback?: (error: Error) => void): void;
|
||||
|
||||
/**
|
||||
* Returns a readable stream of the raw e-mail.
|
||||
*
|
||||
* @public
|
||||
* @param {string} id The e-mail identifier.
|
||||
*/
|
||||
getRawEmail(id: string, callback?: (error: Error, readStream: fs.ReadStream) => void): void;
|
||||
|
||||
/**
|
||||
* Returns array of all e-mail.
|
||||
|
||||
* @public
|
||||
*/
|
||||
getAllEmail(done: (error: Error, emails: Array<Object>) => void): void;
|
||||
|
||||
/**
|
||||
* Starts the SMTP server.
|
||||
*
|
||||
* @public
|
||||
* @param callback The error callback.
|
||||
*/
|
||||
listen(callback?: (error: Error) => void): void;
|
||||
|
||||
/**
|
||||
* Event called when a new e-mail is received. Callback receives single mail object.
|
||||
*
|
||||
* @public
|
||||
* @param {string} eventName The event name.
|
||||
* @param callback The callback for obtains the received email.
|
||||
*/
|
||||
on(eventName: string, callback: (email: string) => void): void;
|
||||
|
||||
/**
|
||||
* Relay the e-mail.
|
||||
*
|
||||
* @param {string} idOrMailObject The identifier or mail object.
|
||||
*/
|
||||
relayMail(idOrMailObject: string, done: (error: Error) => void): void;
|
||||
}
|
||||
|
||||
var out: typeof MailDev;
|
||||
export = out;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/// <reference path="node-schedule.d.ts"/>
|
||||
|
||||
import nodeSchedule = require("node-schedule");
|
||||
|
||||
/**
|
||||
* Test for {@link Job} class.
|
||||
*/
|
||||
function testJob() {
|
||||
var name: string = '';
|
||||
var job: Function = null;
|
||||
var callback: Function = null;
|
||||
|
||||
new nodeSchedule.Job(job, callback);
|
||||
new nodeSchedule.Job(name, job, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link Range} class.
|
||||
*/
|
||||
function testRange() {
|
||||
var range = new nodeSchedule.Range(0);
|
||||
var twoParametersRange = new nodeSchedule.Range(0, 0);
|
||||
var threeParametersRange = new nodeSchedule.Range(0, 0, 0);
|
||||
|
||||
var contained: boolean = range.contains(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link RecurrenceRule} class.
|
||||
*/
|
||||
function testRecurrenceRule() {
|
||||
var range = new nodeSchedule.Range(0, 0, 0);
|
||||
var rule: nodeSchedule.RecurrenceRule = {
|
||||
date: 0,
|
||||
dayOfWeek: [0, range],
|
||||
hour: 0,
|
||||
minute: 0,
|
||||
month: 0,
|
||||
second: 0,
|
||||
year: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link Invocation} class.
|
||||
*/
|
||||
function testInvocation() {
|
||||
var job = new nodeSchedule.Job();
|
||||
var fireDate = new Date();
|
||||
var rule: nodeSchedule.RecurrenceRule = {};
|
||||
|
||||
var invocation = new nodeSchedule.Invocation(job, fireDate, rule);
|
||||
invocation.timerID = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link ScheduleJob} class.
|
||||
*/
|
||||
function testScheduleJob() {
|
||||
var callback: Function = null;
|
||||
new nodeSchedule.ScheduleJob('', callback);
|
||||
|
||||
var rule: nodeSchedule.RecurrenceRule = {};
|
||||
new nodeSchedule.ScheduleJob(rule, callback);
|
||||
|
||||
var date: Date = new Date();
|
||||
new nodeSchedule.ScheduleJob(date, callback);
|
||||
|
||||
var date: Date = new Date();
|
||||
new nodeSchedule.ScheduleJob(date, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link cancelJob} function.
|
||||
*/
|
||||
function testCancelJob() {
|
||||
var job = new nodeSchedule.Job();
|
||||
nodeSchedule.cancelJob(job);
|
||||
}
|
||||
Vendored
+207
@@ -0,0 +1,207 @@
|
||||
// Type definitions for node-schedule
|
||||
// Project: https://github.com/tejasmanohar/node-schedule/
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "node-schedule" {
|
||||
import nodeSchedule = require('node-schedule');
|
||||
|
||||
/**
|
||||
* Recurrence rules.
|
||||
*/
|
||||
export interface RecurrenceRule {
|
||||
/**
|
||||
* Day of the month.
|
||||
*
|
||||
* @public
|
||||
* @type {number}
|
||||
*/
|
||||
date?: number;
|
||||
|
||||
/**
|
||||
* Day of the week.
|
||||
*
|
||||
* @public
|
||||
* @type {number|Array<number|Range>}
|
||||
*/
|
||||
dayOfWeek?: number|Array<number|Range>;
|
||||
|
||||
/**
|
||||
* Hour.
|
||||
*
|
||||
* @public
|
||||
* @type {number}
|
||||
*/
|
||||
hour?: number;
|
||||
|
||||
/**
|
||||
* Minute.
|
||||
*
|
||||
* @public
|
||||
* @type {number}
|
||||
*/
|
||||
minute?: number;
|
||||
|
||||
/**
|
||||
* Month.
|
||||
*
|
||||
* @public
|
||||
* @type {number}
|
||||
*/
|
||||
month?: number;
|
||||
|
||||
/**
|
||||
* Second.
|
||||
*
|
||||
* @public
|
||||
* @type {number}
|
||||
*/
|
||||
second?: number;
|
||||
|
||||
/**
|
||||
* Year.
|
||||
*
|
||||
* @public
|
||||
* @type {number}
|
||||
*/
|
||||
year?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Range.
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
export class Range {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {number} start The start.
|
||||
* @param {end} end The end.
|
||||
* @param {step} step The step.
|
||||
*/
|
||||
constructor(start?: number, end?: number, step?: number);
|
||||
|
||||
/**
|
||||
* Return a {boolean} if the class contains the specified value.
|
||||
*
|
||||
* @param {number} value The value.
|
||||
* @returns {boolean} {true} if the class contains the specified value, otherwise, {false}.
|
||||
*/
|
||||
contains(value: number): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scheduler job.
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
export class ScheduleJob {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {RecurrenceRule} rule The rule.
|
||||
* @param
|
||||
*/
|
||||
constructor(rule: RecurrenceRule|Date|string, callback: Function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scheduler jobs.
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
export class Job {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {RecurrenceRule} rule The rule.
|
||||
* @param
|
||||
*/
|
||||
constructor(name?: string, job?: Function, callback?: Function);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {RecurrenceRule} rule The rule.
|
||||
* @param
|
||||
*/
|
||||
constructor(job?: Function, callback?: Function);
|
||||
|
||||
/**
|
||||
* Attach an event handler function.
|
||||
*
|
||||
* @public
|
||||
* @param {string} eventName The event name.
|
||||
* @param {Function} handler The function to execute when the event is triggered.
|
||||
*/
|
||||
on(eventName: string, handler: Function): void;
|
||||
|
||||
/**
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
schedule(date: Date): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invocation.
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
export class Invocation {
|
||||
/**
|
||||
* Fire date.
|
||||
*
|
||||
* @public
|
||||
* @type {Date}
|
||||
*/
|
||||
public fireDate: Date;
|
||||
|
||||
/**
|
||||
* Job.
|
||||
*
|
||||
* @public
|
||||
* @type {Job}
|
||||
*/
|
||||
public job: Job;
|
||||
|
||||
/**
|
||||
* Recurrence rule.
|
||||
*
|
||||
* @public
|
||||
* @type {RecurrenceRule}
|
||||
*/
|
||||
public recurrenceRule: RecurrenceRule;
|
||||
|
||||
/**
|
||||
* Timer identifier.
|
||||
*
|
||||
* @public
|
||||
* @type {number}
|
||||
*/
|
||||
public timerID: number;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param job The job.
|
||||
* @param fireDate The fire date.
|
||||
* @param recurrenceRule The recurrence rule.
|
||||
*/
|
||||
constructor(job: Job, fireDate: Date, recurrenceRule: RecurrenceRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the job.
|
||||
*
|
||||
* @param job The job.
|
||||
* @returns {boolean} {true} if the job has been cancelled with success, otherwise, {false}.
|
||||
*/
|
||||
export function cancelJob(job: Job): boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user