, AbstractMeta {
+
+ }
+
+ /** Represents the meta data for a database. */
+ interface DatabaseMeta extends AbstractMeta {
+ }
+
+ /** Represents the meta data for a collection. */
+ interface CollectionMeta extends AbstractMeta {
+ }
+
+ /** Represents the meta data for a stored procedure. */
+ interface ProcedureMeta extends AbstractMeta {
+ body: string;
+ }
+
+ /** An object that is used for authenticating requests and must contains one of the options. */
+ export interface AuthOptions {
+
+ /** The authorization master key to use to create the client. */
+ masterKey?: string;
+
+ /** An object that contains resources tokens. Keys for the object are resource Ids and values are the resource tokens.*/
+ resourceTokens?: any;
+
+ /** An array of {@link Permission} objects. */
+ permissionFeed?: any[];
+ }
+
+ /** Represents a DocumentDB stored procecedure. */
+ export interface Procedure extends UniqueId {
+
+ /** The function representing the stored procedure. */
+ body(...params: any[]): void;
+ }
+
+ /** Represents DocumentDB collection. */
+ export interface Collection extends UniqueId {
+
+ indexingPolicy?: IndexingPolicy;
+ }
+
+ /** The Indexing Path
+ * Indexing paths hints to optimize indexing.
+ * Indexing paths allow tradeoff between indexing storage and query performance
+ *
+ */
+ interface IndexingPath {
+
+ /** The indexing type(range or hash) {@link IndexType}.*/
+ IndexType: string;
+
+ /** Path to be indexed.*/
+ Path: string;
+
+ /** Precision for this particular Index type for numeric data. */
+ NumericPrecision: number;
+
+ /** Precision for this particular Index type for string data. */
+ StringPrecision: number;
+ }
+
+ /** The Indexing Policy represents the indexing policy configuration for a collection. */
+ interface IndexingPolicy {
+
+ /** Specifies whether automatic indexing is enabled for a collection.
+ In automatic indexing, documents can be explicitly excluded from indexing using {@link RequestOptions}.
+ In manual indexing, documents can be explicitly included.
*/
+ automatic: boolean;
+
+ /** The indexing mode (consistent or lazy) {@link IndexingMode}. */
+ indexingMode: string;
+
+ /** An array of {@link IndexingPath} represents The paths to be incuded for indexing. */
+ IncludedPath: IndexingPath[];
+
+ /** An array of strings representing the paths to be excluded from indexing. */
+ ExcludedPaths: string[];
+ }
+
+
+
+ /** Provides a client-side logical representation of the Azure DocumentDB database account. This client is used to configure and execute requests against the service.
+ */
+ export class DocumentClient {
+
+ /**
+ * Constructs a DocumentClient.
+ * @param urlConnection - The service endpoint to use to create the client.
+ * @param auth - An object that is used for authenticating requests and must contains one of the options.
+ * @param [connectionPolicy] - An instance of {@link ConnectionPolicy} class. This parameter is optional and the default connectionPolicy will be used if omitted.
+ * @param [consistencyLevel] - An optional parameter that represents the consistency level. It can take any value from {@link ConsistencyLevel}.
+ */
+ constructor(urlConnection: string, auth: AuthOptions, connectionPolicy?: any, consistencyLevel?: string);
+
+ /** Send a request for creating a database.
+ *
+ * A database manages users, permissions and a set of collections.
+ * Each Azure DocumentDB Database Account is able to support multiple independent named databases, with the database being the logical container for data.
+ * Each Database consists of one or more collections, each of which in turn contain one or more documents. Since databases are an an administrative resource, the Service Master Key will be required in order to access and successfully complete any action using the User APIs.
+ *
+ * @param body - A json object that represents The database to be created.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public createDatabase(body: UniqueId, options: RequestOptions, callback: RequestCallback): void;
+
+ /**
+ * Creates a collection.
+ *
+ * A collection is a named logical container for documents.
+ * A database may contain zero or more named collections and each collection consists of zero or more JSON documents.
+ * Being schema-free, the documents in a collection do not need to share the same structure or fields.
+ * Since collections are application resources, they can be authorized using either the master key or resource keys.
+ *
+ * @param databaseLink - The self-link of the database.
+ * @param body - Represents the body of the collection.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public createCollection(databaseLink: string, body: Collection, options: RequestOptions, callback: RequestCallback): void;
+
+ /**
+ * Create a StoredProcedure.
+ *
+ * DocumentDB allows stored procedures to be executed in the storage tier, directly against a document collection. The script
+ * gets executed under ACID transactions on the primary storage partition of the specified collection. For additional details,
+ * refer to the server-side JavaScript API documentation.
+ *
+ * @param collectionLink - The self-link of the collection.
+ * @param procedure - Represents the body of the stored procedure.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public createStoredProcedure(collectionLink: string, procedure: Procedure, options: RequestOptions, callback: RequestCallback): void;
+
+ /**
+ * Create a document.
+ *
+ * There is no set schema for JSON documents. They may contain any number of custom properties as well as an optional list of attachments.
+ * A Document is an application resource and can be authorized using the master key or resource keys
+ *
+ * @param collectionLink - The self-link of the collection.
+ * @param document - Represents the body of the document. Can contain any number of user defined properties.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public createDocument(collectionSelfLink: string, document: NewDocument, options: RequestOptions, callback: RequestCallback>): void;
+
+ /**
+ * Execute the StoredProcedure represented by the object.
+ * @param procedureLink - The self-link of the stored procedure.
+ * @param [params] - Represents the parameters of the stored procedure.
+ * @param callback - The callback for the request.
+ */
+ public executeStoredProcedure(procedureLink: string, params: any[], callback: RequestCallback): void;
+
+ /** Lists all databases that satisfy a query.
+ * @param query - A SQL query string.
+ * @param [options] - The feed options.
+ * @returns - An instance of QueryIterator to handle reading feed.
+ */
+ public queryDatabases(query: string): QueryIterator;
+
+ /**
+ * Query the collections for the database.
+ * @param databaseLink - The self-link of the database.
+ * @param query - A SQL query string.
+ * @param [options] - Represents the feed options.
+ * @returns - An instance of queryIterator to handle reading feed.
+ */
+ public queryCollections(databaseLink: string, query: string): QueryIterator;
+
+ /**
+ * Query the storedProcedures for the collection.
+ * @param collectionLink - The self-link of the collection.
+ * @param query - A SQL query string.
+ * @param [options] - Represents the feed options.
+ * @returns - An instance of queryIterator to handle reading feed.
+ */
+ public queryStoredProcedures(collectionLink: string, query: string): QueryIterator;
+
+ /**
+ * Query the documents for the collection.
+ * @param collectionLink - The self-link of the collection.
+ * @param query - A SQL query string.
+ * @param [options] - Represents the feed options.
+ * @returns - An instance of queryIterator to handle reading feed.
+ */
+ public queryDocuments(collectionLink: string, query: string, options?: FeedOptions): QueryIterator>;
+
+ /**
+ * Delete the document object.
+ * @param documentLink - The self-link of the document.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public deleteDocument(documentLink: string, options: RequestOptions, callback: RequestCallback): void;
+
+ /**
+ * Delete the database object.
+ * @param databaseLink - The self-link of the database.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public deleteDatabase(databaseLink: string, options: RequestOptions, callback: RequestCallback): void;
+
+ /**
+ * Delete the collection object.
+ * @param collectionLink - The self-link of the collection.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public deleteCollection(collectionLink: string, options: RequestOptions, callback: RequestCallback): void;
+
+ /**
+ * Delete the StoredProcedure object.
+ * @param procedureLink - The self-link of the stored procedure.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public deleteStoredProcedure(procedureLink: string, options: RequestOptions, callback: RequestCallback): void;
+
+ /**
+ * Replace the StoredProcedure object.
+ * @param procedureLink - The self-link of the stored procedure.
+ * @param procedure - Represent the new procedure body.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public replaceStoredProcedure(procedureLink: string, procedure: Procedure, options: RequestOptions, callback: RequestCallback): void;
+ }
+}
\ No newline at end of file
diff --git a/java-applet/java-applet-tests.ts b/java-applet/java-applet-tests.ts
index 670527999..cf652a443 100644
--- a/java-applet/java-applet-tests.ts
+++ b/java-applet/java-applet-tests.ts
@@ -1,22 +1,29 @@
///
/**
- * @summary Test for the applet status.
+ * @summary Test for the typage.
+ */
+function testTypage() {
+ var applet: HTMLAppletElement = document.getElementById('applet');
+ var javaApplet: JavaApplet = applet;
+}
+
+/**
+ * @summary Test for the java applet status.
*/
function testStatus() {
- var java: Java = {
- status: AppletStatus.Loading
- };
+ var applet: JavaApplet = document.getElementById('applet');
+ var status: number = applet.status;
}
/**
* @summary Test for the handlers.
*/
function testHandlers() {
+ var applet: JavaApplet = document.getElementById('applet');
+
var handler: Function = () => {};
- var java: Java = {
- onError: handler,
- onLoad: handler,
- onStop: handler
- };
-}
+ applet.onError = handler;
+ applet.onLoad = handler;
+ applet.onStop = handler;
+}
\ No newline at end of file
diff --git a/java-applet/java-applet.d.ts b/java-applet/java-applet.d.ts
index 0102b3b75..982e71a1c 100644
--- a/java-applet/java-applet.d.ts
+++ b/java-applet/java-applet.d.ts
@@ -4,10 +4,11 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/**
- * @summary Applet Status.
- * {@link http://docs.oracle.com/javase/8/docs/technotes/guides/deploy/applet_dev_guide.html#JSDPG719|Applet Status And Event Handlers}
+ * @summary Java applet Status. More details: {@link http://docs.oracle.com/javase/8/docs/technotes/guides/deploy/applet_dev_guide.html#JSDPG719|Applet Status And Event Handlers}
+ * @enum {number}
+ * @readonly
*/
-declare enum AppletStatus {
+declare enum JavaAppletStatus {
/**
* @summary Applet is loading.
*/
@@ -25,28 +26,32 @@ declare enum AppletStatus {
}
/**
- * @summary Interface for Java object.
+ * @summary Interface for Java applet object.
* @author Cyril Schumacher
* @version 1.0
*/
-interface Java {
+interface JavaApplet extends HTMLAppletElement {
/**
- * Handler if the applet status is ERROR. An error has occurred while loading the applet.
+ * @summary Handler if the applet status is {@link JavaAppletStatus#Error}. An error has occurred while loading the applet.
+ * @type {Function}
*/
onError?: Function;
/**
- * Handler if the applet status is READY. Applet has finished loading and is ready to receive JavaScript calls.
+ * @summary Handler if the applet status is {@link JavaAppletStatus#Ready}. Applet has finished loading and is ready to receive JavaScript calls.
+ * @type {Function}
*/
onLoad?: Function;
/**
- * Handler if the applet has stopped.
+ * @summary Handler if the applet has stopped.
+ * @type {Function}
*/
onStop?: Function;
/**
- * @summary Applet Status.
+ * @summary Java applet Status.
+ * @type {JavaAppletStatus}
*/
- status?: AppletStatus;
+ status?: JavaAppletStatus;
}
diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts
index 6f9ff2076..9e7015659 100644
--- a/knockout/knockout.d.ts
+++ b/knockout/knockout.d.ts
@@ -616,7 +616,7 @@ interface KnockoutComponentTemplate {
}
interface KnockoutComponentInfo {
- element: any;
+ element: Node;
}
/* end register overloads */
interface KnockoutComponentDefinition {
diff --git a/later/later-test.ts b/later/later-test.ts
new file mode 100644
index 000000000..2d336d1b3
--- /dev/null
+++ b/later/later-test.ts
@@ -0,0 +1,631 @@
+///
+
+
+module LaterTest_DefineSchedule {
+
+ // define a new schedule
+ var textSched = later.parse.text('at 10:15am every weekday');
+ var cronSched = later.parse.cron('0 0/5 14,18 * * ?');
+ var recurSched = later.parse.recur().last().dayOfMonth();
+ var manualSched = { schedules: [ { M: [ 3 ], D: [ 21 ] } ] };
+
+ // this schedule will fire on the closest weekday to the 15th
+ // every month at 2:00 am except in March
+ var complexSched = later.parse.recur()
+ .on(15).dayOfMonth().onWeekday().on(2).hour()
+ .and()
+ .on(14).dayOfMonth().on(6).dayOfWeek().on(2).hour()
+ .and()
+ .on(16).dayOfMonth().on(2).dayOfWeek().on(2).hour()
+ .except()
+ .on(3).month();
+}
+
+module LaterTest_ConfigureTimezone {
+
+ // set later to use UTC (the default)
+ later.date.UTC();
+
+ // set later to use local time
+ later.date.localTime();
+}
+
+module LaterTest_TimePeriods {
+ export function second() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.second.name;
+ // 'second'
+
+ later.second.range;
+ // 1
+
+ later.second.val(d);
+ // 5
+
+ later.second.isValid(d, 10);
+ // false
+
+ later.second.extent();
+ // [0, 59]
+
+ later.second.start(d);
+ // 'Fri, 22 Mar 2013 10:02:05 GMT'
+
+ later.second.end(d);
+ // 'Fri, 22 Mar 2013 10:02:05 GMT'
+
+ later.second.next(d, 27);
+ // 'Fri, 22 Mar 2013 10:02:27 GMT'
+
+ later.second.prev(d, 27);
+ // 'Fri, 22 Mar 2013 10:01:27 GMT'
+ }
+
+ export function minute() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.minute.name;
+ // 'minute'
+
+ later.minute.range;
+ // 60
+
+ later.minute.val(d);
+ // 2
+
+ later.minute.isValid(d, 2);
+ // true
+
+ later.minute.extent();
+ // [0, 59]
+
+ later.minute.start(d);
+ // 'Fri, 22 Mar 2013 10:02:00 GMT'
+
+ later.minute.end(d);
+ // 'Fri, 22 Mar 2013 10:02:59 GMT'
+
+ later.minute.next(d, 27);
+ // 'Fri, 22 Mar 2013 10:27:00 GMT'
+
+ later.minute.prev(d, 27);
+ // 'Fri, 22 Mar 2013 09:27:59 GMT'
+ }
+
+ export function hour() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.hour.name;
+ // 'hour'
+
+ later.hour.range;
+ // 3600
+
+ later.hour.val(d);
+ // 10
+
+ later.hour.isValid(d, 2);
+ // false
+
+ later.hour.extent();
+ // [0, 23]
+
+ later.hour.start(d);
+ // 'Fri, 22 Mar 2013 10:00:00 GMT'
+
+ later.hour.end(d);
+ // 'Fri, 22 Mar 2013 10:59:59 GMT'
+
+ later.hour.next(d, 5);
+ // 'Sat, 23 Mar 2013 05:00:00 GMT'
+
+ later.hour.prev(d, 21);
+ // 'Thu, 21 Mar 2013 21:59:59 GMT'
+ }
+
+ export function time() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.time.name;
+ // 'time'
+
+ later.time.range;
+ // 1
+
+ later.time.val(d);
+ // 36125
+
+ later.time.isValid(d, 36125);
+ // true
+
+ later.time.extent();
+ // [0, 86399]
+
+ later.time.start(d);
+ // 'Fri, 22 Mar 2013 00:00:00 GMT'
+
+ later.time.end(d);
+ // 'Fri, 22 Mar 2013 23:59:59 GMT'
+
+ later.time.next(d, 60);
+ // 'Sat, 23 Mar 2013 00:01:00 GMT'
+
+ later.time.prev(d, 60);
+ // 'Fri, 22 Mar 2013 00:01:00 GMT'
+ }
+
+ export function day() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.day.name;
+ // 'day'
+
+ later.day.range;
+ // 86400
+
+ later.day.val(d);
+ // 22
+
+ later.day.isValid(d, 3);
+ // false
+
+ later.day.extent(d);
+ // [1, 31]
+
+ later.day.start(d);
+ // 'Fri, 22 Mar 2013 00:00:00 GMT'
+
+ later.day.end(d);
+ // 'Fri, 22 Mar 2013 23:59:59 GMT'
+
+ later.day.next(d, 11);
+ // 'Thu, 11 Apr 2013 00:00:00 GMT'
+
+ later.day.prev(d, 2);
+ // 'Sat, 02 Mar 2013 23:59:59 GMT'
+ }
+
+ export function day_of_week() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.dayOfWeek.name;
+ // 'day of week'
+
+ later.dayOfWeek.range;
+ // 86400
+
+ later.dayOfWeek.val(d);
+ // 6
+
+ later.dayOfWeek.isValid(d, 3);
+ // false
+
+ later.dayOfWeek.extent();
+ // [1, 7]
+
+ later.dayOfWeek.start(d);
+ // 'Fri, 22 Mar 2013 00:00:00 GMT'
+
+ later.dayOfWeek.end(d);
+ // 'Fri, 22 Mar 2013 23:59:59 GMT'
+
+ later.dayOfWeek.next(d, 1);
+ // 'Sun, 24 Mar 2013 00:00:00 GMT'
+
+ later.dayOfWeek.prev(d, 5);
+ // 'Thu, 21 Mar 2013 23:59:59 GMT'
+ }
+
+ export function day_of_week_count() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.dayOfWeekCount.name;
+ // 'day of week count'
+
+ later.dayOfWeekCount.range;
+ // 604800
+
+ later.dayOfWeekCount.val(d);
+ // 4
+
+ later.dayOfWeekCount.isValid(d, 4);
+ // true
+
+ later.dayOfWeekCount.extent(d);
+ // [1, 5]
+
+ later.dayOfWeekCount.start(d);
+ // 'Fri, 22 Mar 2013 00:00:00 GMT'
+
+ later.dayOfWeekCount.end(d);
+ // 'Thu, 28 Mar 2013 23:59:59 GMT'
+
+ // zero is special cased and means the last instance of
+ // a day of the week in the month, instead of meaning the
+ // first day of the week with the highest instance count
+ // which would have been Mar 29 with value 5.
+ later.dayOfWeekCount.next(d, 0);
+ // 'Mon, 25 Mar 2013 00:00:00 GMT'
+
+ later.dayOfWeekCount.prev(d, 2);
+ // 'Thu, 14 Mar 2013 23:59:59 GMT'
+ }
+
+ export function day_of_year() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.dayOfYear.name;
+ // 'day of year'
+
+ later.dayOfYear.range;
+ // 86400
+
+ later.dayOfYear.val(d);
+ // 81
+
+ later.dayOfYear.isValid(d, 4);
+ // false
+
+ later.dayOfYear.extent(d);
+ // [1, 365]
+
+ later.dayOfYear.start(d);
+ // 'Fri, 22 Mar 2013 00:00:00 GMT'
+
+ later.dayOfYear.end(d);
+ // 'Fri, 22 Mar 2013 23:59:59 GMT'
+
+ later.dayOfYear.next(d, 256);
+ // 'Fri, 13 Sep 2013 00:00:00 GMT'
+
+ later.dayOfYear.prev(d, 44);
+ // 'Wed, 13 Feb 2013 23:59:59 GMT'
+ }
+
+ export function week_of_month() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.weekOfMonth.name;
+ // 'week of month'
+
+ later.weekOfMonth.range;
+ // 604800
+
+ later.weekOfMonth.val(d);
+ // 4
+
+ later.weekOfMonth.isValid(d, 4);
+ // true
+
+ later.weekOfMonth.extent(d);
+ // [1, 6]
+
+ later.weekOfMonth.start(d);
+ // 'Sun, 17 Mar 2013 00:00:00 GMT'
+
+ later.weekOfMonth.end(d);
+ // 'Sat, 23 Mar 2013 23:59:59 GMT'
+
+ later.weekOfMonth.next(d, 1);
+ // 'Mon, 01 Apr 2013 00:00:00 GMT'
+
+ later.weekOfMonth.prev(d, 2);
+ // 'Sat, 09 Mar 2013 23:59:59 GMT'
+ }
+
+ export function week_of_year() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.weekOfYear.name;
+ // 'week of year'
+
+ later.weekOfYear.range;
+ // 604800
+
+ later.weekOfYear.val(d);
+ // 12
+
+ later.weekOfYear.isValid(d, 21);
+ // false
+
+ later.weekOfYear.extent(d);
+ // [1, 52]
+
+ later.weekOfYear.start(d);
+ // 'Mon, 18 Mar 2013 00:00:00 GMT'
+
+ later.weekOfYear.end(d);
+ // 'Sun, 24 Mar 2013 23:59:59 GMT'
+
+ later.weekOfYear.next(d, 47);
+ // 'Mon, 18 Nov 2013 00:00:00 GMT'
+
+ later.weekOfYear.prev(d, 52);
+ // 'Sun, 30 Dec 2012 23:59:59 GMT'
+ }
+
+ export function month() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.month.name;
+ // 'month'
+
+ later.month.range;
+ // 2629740
+
+ later.month.val(d);
+ // 3
+
+ later.month.isValid(d, 3);
+ // true
+
+ later.month.extent();
+ // [1, 12]
+
+ later.month.start(d);
+ // 'Fri, 01 Mar 2013 00:00:00 GMT'
+
+ later.month.end(d);
+ // 'Sun, 31 Mar 2013 23:59:59 GMT'
+
+ later.month.next(d, 11);
+ // 'Fri, 01 Nov 2013 00:00:00 GMT'
+
+ later.month.prev(d, 2);
+ // 'Thu, 28 Feb 2013 23:59:59 GMT'
+ }
+
+ export function year() {
+ var d = new Date('2013-03-22T10:02:05Z');
+
+ later.year.name;
+ // 'year'
+
+ later.year.range;
+ // 31556900
+
+ later.year.val(d);
+ // 2013
+
+ later.year.isValid(d, 2013);
+ // true
+
+ later.year.extent();
+ // [1970, 2099]
+
+ later.year.start(d);
+ // 'Tue, 01 Jan 2013 00:00:00 GMT'
+
+ later.year.end(d);
+ // 'Tue, 31 Dec 2013 23:59:59 GMT'
+
+ later.year.next(d, 2014);
+ // 'Wed, 01 Jan 2014 00:00:00 GMT'
+
+ later.year.prev(d, 2012);
+ // 'Mon, 31 Dec 2012 23:59:59 GMT'
+ }
+
+ export interface IPartOfDayLater extends Later.IStatic {
+ partOfDay: Later.ITimePeriod;
+ }
+
+ export function custom() {
+
+ var customLater = later;
+
+ customLater.partOfDay = {
+
+ name: 'part of day',
+
+ range: later.hour.range * 6,
+
+ val: function(d: Date): number {
+ return later.hour.val(d) < 12
+ ? 0
+ : later.hour.val(d) < 18
+ ? 1
+ : 2;
+ },
+
+ isValid: function(d: Date, val: any) {
+ return customLater.partOfDay.val(d) === val;
+ },
+
+ extent: function(date?: Date) {
+ return [0, 2];
+ },
+
+ start: function(date: Date) {
+ var hour = customLater.partOfDay.val(date) === 0
+ ? 0
+ : customLater.partOfDay.val(date) === 1
+ ? 12
+ : 18;
+
+ return later.date.next(
+ later.year.val(date),
+ later.month.val(date),
+ later.day.val(date),
+ hour
+ );
+ },
+
+ end: function(date: Date) {
+ var hour = customLater.partOfDay.val(date) === 0
+ ? 11
+ : customLater.partOfDay.val(date) === 1
+ ? 5
+ : 23;
+
+ return later.date.prev(
+ later.year.val(date),
+ later.month.val(date),
+ later.day.val(date),
+ hour
+ );
+ },
+
+ next: function(date: Date, val: any) {
+ var hour = val === 0
+ ? 0
+ : val === 1
+ ? 12
+ : 18;
+
+ return later.date.next(
+ later.year.val(date),
+ later.month.val(date),
+ // increment the day if we already passed the desired time period
+ later.day.val(date) + (hour < later.hour.val(date) ? 1 : 0),
+ hour
+ );
+ },
+
+ prev: function(date: Date, val: any) {
+ var hour = val === 0
+ ? 11
+ : val === 1
+ ? 5
+ : 23;
+
+ return later.date.prev(
+ later.year.val(date),
+ later.month.val(date),
+ // decrement the day if we already passed the desired time period
+ later.day.val(date) + (hour > later.hour.val(date) ? -1 : 0),
+ hour
+ );
+ }
+ };
+ }
+}
+
+module LaterTest_GenerateRecurences {
+
+ export function on_method() {
+ // fires on the 2nd minute every hour
+ later.parse.recur().on(2).minute();
+
+ // fires every day at 8am and 8pm
+ later.parse.recur().on(8, 20).hour();
+
+ // fires every day at 8am
+ later.parse.recur().on('08:00:00').time();
+ }
+
+ export function first_method() {
+ // fires on the 0th minute of every hour
+ later.parse.recur().first().minute();
+ }
+
+ export function last_method() {
+ // fires on the last day of every month at 5am
+ later.parse.recur().on(5).hour().last().dayOfMonth();
+ }
+
+ export function onWeekend_method() {
+ // fires on the 5th minute of every hour during Sat and Sun
+ later.parse.recur().on(5).minute().onWeekend();
+ }
+
+ export function onWeekday_method() {
+ // fires on the 5th minute of every hour during Mon,Tues,Wed,Thur,Fri
+ later.parse.recur().on(5).minute().onWeekday();
+ }
+
+ export function every_method() {
+ // fires on the 0th, 10th, 20th, 30th, 40th, and 50th min of every hour
+ later.parse.recur().every(10).minute();
+
+ // fires on first second of Jan, Apr, July, Oct
+ later.parse.recur().every(3).month();
+ }
+
+ export function after_method() {
+ // fires on the 55th, 56th, 57th, 58th, and 59th minute
+ later.parse.recur().after(55).minute();
+
+ // fires at 12 noon and 6pm
+ later.parse.recur().every(6).hour().after('09:00').time();
+ }
+
+ export function before_method() {
+ // fires on the first second of January and February
+ later.parse.recur().before(3).month();
+
+ // fires at 6am every day
+ later.parse.recur().every(6).hour().before('09:00').time();
+
+ // fires between 9am and 6pm every day
+ later.parse.recur().after('09:00').time().before('18:00').time();
+ later.parse.recur().after(9).hour().before(18).hour();
+ }
+
+ export function startingOn_method() {
+ // fires on the 10th, 25th, 40th, and 55th minute of every hour
+ later.parse.recur().every(15).minute().startingOn(10);
+ }
+
+ export function between_method() {
+ // fires on the 10th, 25th, 40th minute of every hour
+ later.parse.recur().every(15).minute().between(10, 40);
+ }
+
+ export function and_method() {
+ // fires every 2 hours on the first day of every month
+ // and 8:00am and 8:00pm on the last day of every month
+ var sched = later.parse.recur()
+ .every(2).hour().first().dayOfMonth()
+ .and()
+ .on(8, 20).hour().last().dayOfMonth()
+ }
+
+ export function except_method() {
+ // fires every minute of every hour except on multiples of 2 and 3
+ var sched = later.parse.recur()
+ .every().minute()
+ .except()
+ .every(2).minute().between(2, 59)
+ .and()
+ .every(3).minute().between(3, 59);
+ }
+
+}
+
+module LaterTest_CalculateOccurences {
+
+ // Initialise next variable.
+ var next: Date[] = [];
+
+ // calculate the next 10 occurrences of a recur schedule
+ var recurSched = later.parse.recur().last().dayOfMonth();
+
+ next = later.schedule(recurSched).next(10);
+
+ // calculate the previous occurrence starting from March 21, 2013
+ var cronSched = later.parse.cron('0 0/5 14,18 * * ?');
+
+ next = later.schedule(cronSched).prev(1, new Date(2013, 2, 21));
+}
+
+module LaterTest_ExecuteCodeUsingSchedule {
+
+ // will fire every 5 minutes
+ var textSched = later.parse.text('every 5 min');
+
+ // execute logTime one time on the next occurrence of the text schedule
+ var timer = later.setTimeout(logTime, textSched);
+
+ // execute logTime for each successive occurrence of the text schedule
+ var timer2 = later.setInterval(logTime, textSched);
+
+ // function to execute
+ function logTime() {
+ console.log(new Date());
+ }
+
+ // clear the interval timer when you are done
+ timer2.clear();
+}
\ No newline at end of file
diff --git a/later/later.d.ts b/later/later.d.ts
new file mode 100644
index 000000000..780de6398
--- /dev/null
+++ b/later/later.d.ts
@@ -0,0 +1,673 @@
+// Type definitions for LaterJS
+// Project: http://bunkat.github.io/later/
+// Definitions by: Jason D Dryhurst-Smith
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module Later {
+
+ export interface IScheduleData {
+
+ /**
+ * A list of recurrence information as a composite schedule.
+ */
+ schedules: IRecurrence[];
+
+ /**
+ * A list of exceptions to the composite recurrence information.
+ */
+ exceptions: IRecurrence[];
+
+ /**
+ * A code to identify any errors in the composite schedule and exceptions.
+ * The number tells you the position of the error within the schedule.
+ */
+ error: number;
+ }
+
+ export interface IRecurrence {
+
+ /** Time in seconds from midnight.
+ */
+ t?: number[];
+ /** Seconds in minute.
+ */
+ s?: number[];
+ /** Minutes in hour.
+ */
+ m?: number[];
+ /** Hour in day.
+ */
+ h?: number[];
+ /** Day of the month.
+ */
+ D?: number[];
+ /** Day in week.
+ */
+ dw?: number[];
+ /** Nth day of the week in month.
+ */
+ dc?: number[];
+ /** Day in year.
+ */
+ dy?: number[];
+ /** Week in month.
+ */
+ wm?: number[];
+ /** ISO week in year.
+ */
+ wy?: number[];
+ /** Month in year.
+ */
+ M?: number[];
+ /** Year.
+ */
+ Y?: number[];
+
+ /** After modifiers.
+ */
+ t_a?: number[];
+ /** After modifiers.
+ */
+ s_a?: number[];
+ /** After modifiers.
+ */
+ m_a?: number[];
+ /** After modifiers.
+ */
+ h_a?: number[];
+ /** After modifiers.
+ */
+ D_a?: number[];
+ /** After modifiers.
+ */
+ dw_a?: number[];
+ /** After modifiers.
+ */
+ dc_a?: number[];
+ /** After modifiers.
+ */
+ dy_a?: number[];
+ /** After modifiers.
+ */
+ wm_a?: number[];
+ /** After modifiers.
+ */
+ wy_a?: number[];
+ /** After modifiers.
+ */
+ M_a?: number[];
+ /** After modifiers.
+ */
+ Y_a?: number[];
+
+ /** Before modifiers.
+ */
+ t_b?: number[];
+ /** Before modifiers.
+ */
+ s_b?: number[];
+ /** Before modifiers.
+ */
+ m_b?: number[];
+ /** Before modifiers.
+ */
+ h_b?: number[];
+ /** Before modifiers.
+ */
+ D_b?: number[];
+ /** Before modifiers.
+ */
+ dw_b?: number[];
+ /** Before modifiers.
+ */
+ dc_b?: number[];
+ /** Before modifiers.
+ */
+ dy_b?: number[];
+ /** Before modifiers.
+ */
+ wm_b?: number[];
+ /** Before modifiers.
+ */
+ wy_b?: number[];
+ /** Before modifiers.
+ */
+ M_b?: number[];
+ /** Before modifiers.
+ */
+ Y_b?: number[];
+
+ /*
+ * Custom Time Periods and Modifiers
+ * For acces to custom time periods created as extension to the later static type
+ * and modifiers created on the later modifier static type.
+ */
+ [ timeperiodAndModifierName: string ]: number[];
+ }
+
+ export interface IParseStatic {
+
+ /**
+ * Create a recurrence builder for building schedule data.
+ */
+ recur(): IRecurrenceBuilder;
+
+ /**
+ * Create schedule data by parsing a cron string
+ *
+ * @param {string} [input] - A string value to parse.
+ */
+ cron(input?: string): IScheduleData;
+
+ /**
+ * Create schedule data by paring a human readable string.
+ *
+ * @param {string} [input] - A string value to parse.
+ */
+ text(input?: string): IScheduleData;
+ }
+
+ export interface ITimer {
+
+ /**
+ * Clear the timer and end execution.
+ */
+ clear(): void;
+ }
+
+ export interface ISchedule {
+
+ /**
+ * Finds the next valid instance or instances of the current schedule,
+ * optionally between a specified start and end date. Start date is
+ * Date.now() by default, end date is unspecified. Start date must be
+ * smaller than end date.
+ *
+ * @param {number} numberOfInst: The number of instances to return
+ * @param {Date} dateFrom: The earliest a valid instance can occur
+ * @param {Date} dateTo: The latest a valid instance can occur
+ */
+ next(numberOfInst: number, dateFrom?: Date, dateTo?: Date): Date[];
+
+ /**
+ * Finds the next valid range or ranges of the current schedule,
+ * optionally between a specified start and end date. Start date is
+ * Date.now() by default, end date is unspecified. Start date must be
+ * greater than end date.
+ *
+ * @param {number} numberOfInst: The number of ranges to return
+ * @param {Date} dateFrom: The earliest a valid range can occur
+ * @param {Date} dateTo: The latest a valid range can occur
+ */
+ nextRange(numberOfInst: number, dateFrom?: Date, dateTo?: Date): Date[];
+
+ /**
+ * Finds the previous valid instance or instances of the current schedule,
+ * optionally between a specified start and end date. Start date is
+ * Date.now() by default, end date is unspecified. Start date must be
+ * greater than end date.
+ *
+ * @param {number} numberOfInst: The number of instances to return
+ * @param {Date} dateFrom: The earliest a valid instance can occur
+ * @param {Date} dateTo: The latest a valid instance can occur
+ */
+ prev(numberOfInst: number, dateFrom?: Date, dateTo?: Date): Date[];
+
+ /**
+ * Finds the previous valid range or ranges of the current schedule,
+ * optionally between a specified start and end date. Start date is
+ * Date.now() by default, end date is unspecified. Start date must be
+ * greater than end date.
+ *
+ * @param {number} numberOfInst: The number of ranges to return
+ * @param {Date} dateFrom: The earliest a valid range can occur
+ * @param {Date} dateTo: The latest a valid range can occur
+ */
+ prevRange(numberOfInst: number, dateFrom?: Date, dateTo?: Date): Date[];
+ }
+
+ export interface IRecurrenceBuilder extends IScheduleData {
+
+ /** a time period
+ */
+ second(): IRecurrenceBuilder;
+ /** a time period
+ */
+ minute(): IRecurrenceBuilder;
+ /** a time period
+ */
+ hour(): IRecurrenceBuilder;
+ /** a time period
+ */
+ time(): IRecurrenceBuilder;
+ /** a time period
+ */
+ dayOfWeek(): IRecurrenceBuilder;
+ /** a time period
+ */
+ dayOfWeekCount(): IRecurrenceBuilder;
+ /** a time period
+ */
+ dayOfMonth(): IRecurrenceBuilder;
+ /** a time period
+ */
+ dayOfYear(): IRecurrenceBuilder;
+ /** a time period
+ */
+ weekOfMonth(): IRecurrenceBuilder;
+ /** a time period
+ */
+ weekOfYear(): IRecurrenceBuilder;
+ /** a time period
+ */
+ month(): IRecurrenceBuilder;
+ /** a time period
+ */
+ year(): IRecurrenceBuilder;
+
+ /** a time period
+ */
+ fullDate(): IRecurrenceBuilder;
+
+ /**
+ * Specifies one or more specific vals of a time period information provider.
+ * When used to specify a time, a string indicating the 24-hour time may be used.
+ *
+ * @param {number[]} values - A list of values.
+ */
+ on(...values: number[]): IRecurrenceBuilder;
+ /**
+ * Specifies one or more specific vals of a time period information provider.
+ * When used to specify a time, a string indicating the 24-hour time may be used.
+ *
+ * @param {string} value - A string representing your value.
+ */
+ on(value: string): IRecurrenceBuilder;
+ /**
+ * Specifies one or more specific vals of a time period information provider.
+ * When used to specify a time, a string indicating the 24-hour time may be used.
+ *
+ * @param {Date} date - A Date representing your value.
+ */
+ on(date: Date): IRecurrenceBuilder;
+
+ /**
+ * Preceed a time period.
+ *
+ * @param {number} [value] - A number representing your value.
+ */
+ every(value?: number): IRecurrenceBuilder;
+ /**
+ * Preceed a time period.
+ *
+ * @param {string} [value] - A string representing your value.
+ */
+ every(value?: string): IRecurrenceBuilder;
+
+ /**
+ * Preceed a time period.
+ *
+ * @param {number} start - A number representing your start value.
+ * @param {number} end - A number representing your end value.
+ */
+ between(start: number, end: number): IRecurrenceBuilder;
+ /**
+ * Preceed a time period.
+ *
+ * @param {string} start - A string representing your start value.
+ * @param {string} end - A string representing your end value.
+ */
+ between(start: string, end: string): IRecurrenceBuilder;
+
+ /**
+ * After a time period.
+ *
+ * @param {number} value - A number representing your value.
+ */
+ after(value: number): IRecurrenceBuilder;
+ /**
+ * After a time period.
+ *
+ * @param {string} value - A string representing your value.
+ */
+ after(value: string): IRecurrenceBuilder;
+
+ /**
+ * After a time period.
+ *
+ * @param {number} value - A number representing your value.
+ */
+ before(value: number): IRecurrenceBuilder;
+ /**
+ * After a time period.
+ *
+ * @param {string} value - A string representing your value.
+ */
+ before(value: string): IRecurrenceBuilder;
+
+ /**
+ * After a time period.
+ *
+ * @param {number} value - A number representing your value.
+ */
+ startingOn(value: number): IRecurrenceBuilder;
+ /**
+ * After a time period.
+ *
+ * @param {string} value - A string representing your value.
+ */
+ startingOn(value: string): IRecurrenceBuilder;
+
+ /**
+ * Equivalent to .on(min)
+ */
+ first(): IRecurrenceBuilder;
+
+ /**
+ * Equivalent to .on(max)
+ */
+ last(): IRecurrenceBuilder;
+
+ /**
+ * Equivalent to .on(1,7).dayOfWeek()
+ */
+ onWeekend(): IRecurrenceBuilder;
+
+ /**
+ * Equivalent to .on(2,3,4,5,6).dayOfWeek()
+ */
+ onWeekday(): IRecurrenceBuilder;
+
+ /**
+ * Add a new schedule value to schedules, composite schedule.
+ */
+ and(): IRecurrenceBuilder;
+
+ /**
+ * Add exceptions.
+ */
+ except(): IRecurrenceBuilder;
+
+ /**
+ * Custom Timeperiod Recurrences.
+ * Using a key as defined by the custom period in any extension to Later.IStatic.
+ */
+ customPeriod(key: string): IRecurrenceBuilder;
+
+ /**
+ * Customise Recurrences.
+ * Using a key as defined by the custom modifier in any extension to Later.IModifierStatic.
+ */
+ customModifier(key: string, values: number): IRecurrenceBuilder;
+ }
+
+ export interface IDateProvider {
+
+ /**
+ * Set later to use UTC time.
+ */
+ UTC(): void;
+
+ /**
+ * Set later to use local time.
+ */
+ localTime(): void;
+
+ /**
+ * Builds and returns a new Date using the specified values. Date
+ * returned is either using Local time or UTC based on isLocal.
+ *
+ * @param {number} [Y]: Four digit year
+ * @param {number} [M]: Month between 1 and 12, defaults to 1
+ * @param {number} [D]: Date between 1 and 31, defaults to 1
+ * @param {number} [h]: Hour between 0 and 23, defaults to 0
+ * @param {number} [m]: Minute between 0 and 59, defaults to 0
+ * @param {number} [s]: Second between 0 and 59, defaults to 0
+ */
+ next(Y?: number, M?: number, D?: number, h?: number, m?: number, s?: number): Date;
+
+ /**
+ * Builds and returns a new Date using the specified values. Date
+ * returned is either using Local time or UTC based on isLocal.
+ *
+ * @param {number} [Y]: Four digit year
+ * @param {number} [M]: Month between 0 and 11, defaults to 11
+ * @param {number} [D]: Date between 1 and 31, defaults to last day of month
+ * @param {number} [h]: Hour between 0 and 23, defaults to 23
+ * @param {number} [m]: Minute between 0 and 59, defaults to 59
+ * @param {number} [s]: Second between 0 and 59, defaults to 59
+ */
+ prev(Y?: number, M?: number, D?: number, h?: number, m?: number, s?: number): Date;
+
+ /**
+ * Determines if a value will cause a particular constraint to rollover to the
+ * next largest time period. Used primarily when a constraint has a
+ * variable extent.
+ *
+ * @param {Date} d: Date
+ * @param {number} val: Value
+ * @param {IModifier} constraint: A modifier
+ * @param {ITimePeriod} period: A time period
+ */
+ nextRollover(d: Date, val: number, constraint: IModifier, period: ITimePeriod): Date;
+
+ /**
+ * Determines if a value will cause a particular constraint to rollover to the
+ * previous largest time period. Used primarily when a constraint has a
+ * variable extent.
+ *
+ * @param {Date} d: Date
+ * @param {number} val: Value
+ * @param {IModifier} constraint: A modifier
+ * @param {ITimePeriod} period: A time period
+ */
+ prevRollover(d: Date, val: number, constraint: IModifier, period: ITimePeriod): Date;
+ }
+
+ export interface ITimePeriod {
+
+ /**
+ * The name of the time period information provider.
+ */
+ name: string;
+
+ /**
+ * The rough number of seconds that are covered when moving from one instance of this time period to the next instance.
+ */
+ range: number;
+
+ /**
+ * The value of this time period for the date specified.
+ *
+ * @param {Date} date - The given date.
+ */
+ val(date: Date): number;
+
+ /**
+ * True if the specified value is valid for the specified date, false otherwise.
+ *
+ * @param {Date} date - The given date.
+ * @param {any} value - The value to test for the date.
+ */
+ isValid(date: Date, value: any): boolean;
+
+ /**
+ * The minimum and maximum valid values for the time period for the specified date.
+ * If the minimum value is not 0, 0 can be specified in schedules to indicate the maximum value.
+ * This makes working with non - constant extents(like days in a month) easier.
+ *
+ * @param {Date} [date] - The given date.
+ */
+ extent(date?: Date): number[];
+
+ /**
+ * The first second in which the value is the same as the value of the specified date.
+ * For example, the start of an hour would be the hour with 0 minutes and 0 seconds.
+ *
+ * @param {Date} date - The given date.
+ */
+ start(date: Date): Date;
+
+ /**
+ * The last second in which the value is the same as the value of the specified date.
+ * For example, the end of an hour would be the hour with 59 minutes and 59 seconds.
+ *
+ * @param {Date} date - The given date.
+ */
+ end(date: Date): Date;
+
+ /**
+ * Returns the next date where the value is the value specified.
+ * Sets the value to 1 if value specified is greater than the max allowed value.
+ *
+ * @param {Date} date - The given date.
+ * @param {any} value - The value to test for the date.
+ */
+ next(date: Date, value: any): Date;
+
+ /**
+ * Returns the previous date where the value is the value specified.
+ * Sets the value to the max allowed value if the value specified is greater than the max allowed value.
+ *
+ * @param {Date} date - The given date.
+ * @param {any} value - The value to test for the date.
+ */
+ prev(date: Date, value: any): Date;
+ }
+
+ export interface IModifier extends ITimePeriod {
+ /**
+ * Creates a new modified constraint.
+ *
+ * @param {ITimePeriod} constraint: The constraint to be modified
+ * @param {number} value: The starting value of the after constraint
+ */
+ (constraint: ITimePeriod, value: number): ITimePeriod;
+ }
+
+ export interface IModifierStatic {
+
+ /**
+ * After Modifier
+ */
+ after: IModifier;
+
+ /**
+ * Before Modifier
+ */
+ before: IModifier;
+ }
+
+ export interface IStatic {
+
+ /**
+ * Schedule
+ * Generates instances from schedule data.
+ */
+ schedule(input: any): ISchedule;
+
+ /**
+ * Parse
+ * For generating schedule data.
+ */
+ parse: IParseStatic;
+
+ /** Date Provider
+ */
+ date: IDateProvider;
+
+ /**
+ * Set timeout on window using given recurrence next.
+ *
+ * @param {function} callback - A callback called after first instance of recurrence pattern.
+ * @param {Later.IReccurence} - A recurrence instance.
+ */
+ setTimeout(callback: () => void, time: IScheduleData): ITimer;
+ /**
+ * Set interval on window using given recurrence
+ *
+ * @param {function} callback - A callback called after each instance of recurrence pattern.
+ * @param {Later.IReccurence} - A recurrence instance.
+ */
+ setInterval(callback: () => void, time: IScheduleData): ITimer;
+
+ /**
+ * time period information provider.
+ */
+ time: ITimePeriod;
+ /**
+ * Second time period information provider.
+ */
+ second: ITimePeriod;
+ /**
+ * Minute time period information provider.
+ */
+ minute: ITimePeriod;
+ /**
+ * Hour time period information provider.
+ */
+ hour: ITimePeriod;
+ /**
+ * Day time period information provider.
+ */
+ day: ITimePeriod;
+ /**
+ * Day of week time period information provider.
+ */
+ dayOfWeek: ITimePeriod;
+ /**
+ * Day of week in month time period information provider.
+ */
+ dayOfWeekCount: ITimePeriod;
+ /**
+ * Day in year time period information provider.
+ */
+ dayOfYear: ITimePeriod;
+ /**
+ * Week of mobth time period information provider.
+ */
+ weekOfMonth: ITimePeriod;
+ /**
+ * Week of yearfrom ISO 8601 time period information provider.
+ */
+ weekOfYear: ITimePeriod;
+ /**
+ * Month time period information provider.
+ */
+ month: ITimePeriod;
+ /**
+ * Year time period information provider.
+ */
+ year: ITimePeriod;
+
+ /**
+ * Later Modifiers:
+ *
+ * This type can be easily extended to include any custom IModifiers that you desire.
+ * These can then be used to create schedules of your own custom type.
+ *
+ * interface IGandalfsLaterModifier extends Later.IModifierStatic {
+ * duringTheThirdAge: IModifier
+ * }
+ *
+ * Be sure to use this interface when dealing with Later.modifier
+ */
+ modifier: IModifierStatic
+ }
+}
+
+/**
+ * Later Module:
+ *
+ * Easily define complex schedules then quickly calculate future or previous schedule occurrences.
+ *
+ * This type can be easily extended to include any custom ITimePeriods that you desire.
+ * These can then be used to create schedules of your own custom type.
+ *
+ * interface IGandalfsLater extends Later.IStatic {
+ * agesOfMiddleEarth: ITimePeriod
+ * }
+ *
+ * Be sure to use this interface when dealing with Later.
+ */
+declare var later: Later.IStatic;
\ No newline at end of file
diff --git a/lazy.js/lazy.js-tests.ts b/lazy.js/lazy.js-tests.ts
index f719a90a9..cab0787c3 100644
--- a/lazy.js/lazy.js-tests.ts
+++ b/lazy.js/lazy.js-tests.ts
@@ -156,7 +156,7 @@ obj = fooSequence.toObject();
// ArrayLikeSequence
-fooArraySeq = fooArraySeq.concat();
+fooArraySeq = fooArraySeq.concat(fooArr);
fooArraySeq = fooArraySeq.first();
fooArraySeq = fooArraySeq.first(num);
foo = fooArraySeq.get(num);
diff --git a/lazy.js/lazy.js.d.ts b/lazy.js/lazy.js.d.ts
index 7130a9d2d..d388ba6f7 100644
--- a/lazy.js/lazy.js.d.ts
+++ b/lazy.js/lazy.js.d.ts
@@ -176,7 +176,7 @@ declare module LazyJS {
interface ArrayLikeSequence extends Sequence {
// define()X;
- concat(): ArrayLikeSequence;
+ concat(var_args: T[]): ArrayLikeSequence;
first(count?: number): ArrayLikeSequence;
get(index: number): T;
length(): number;
diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts
index 2017252ff..6f24b75dc 100644
--- a/lodash/lodash-tests.ts
+++ b/lodash/lodash-tests.ts
@@ -1096,6 +1096,41 @@ result = _.unescape('Moe, Larry & Curly');
result = _.uniqueId('contact_');
result = _.uniqueId();
+/*********
+* String
+*********/
+
+result = _.camelCase('Foo Bar');
+result = _.capitalize('fred');
+result = _.deburr('déjà vu');
+result = _.endsWith('abc', 'c');
+result = _.escape('fred, barney, & pebbles');
+result = _.escapeRegExp('[lodash](https://lodash.com/)');
+result = _.kebabCase('Foo Bar');
+result = _.pad('abc', 8);
+result = _.pad('abc', 8, '_-');
+result = _.padLeft('abc', 6);
+result = _.padLeft('abc', 6, '_-');
+result = _.padRight('abc', 6);
+result = _.padRight('abc', 6, '_-');
+result = _.repeat('*', 3);
+result = _.snakeCase('Foo Bar');
+result = _.startCase('--foo-bar');
+result = _.startsWith('abc', 'a');
+result = _.trim(' abc ');
+result = _.trim('-_-abc-_-', '_-');
+result = _.trimLeft(' abc ');
+result = _.trimLeft('-_-abc-_-', '_-');
+result = _.trimRight(' abc ');
+result = _.trimRight('-_-abc-_-', '_-');
+result = _.trunc('hi-diddly-ho there, neighborino');
+result = _.trunc('hi-diddly-ho there, neighborino', 24);
+result = _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' });
+result = _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ });
+result = _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' […]' });
+result = _.words('fred, barney, & pebbles');
+result = _.words('fred, barney, & pebbles', /[^, ]+/g);
+
/**********
* Utilities *
***********/
diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts
index c8f7ad42d..c43f27c5c 100644
--- a/lodash/lodash.d.ts
+++ b/lodash/lodash.d.ts
@@ -6133,6 +6133,50 @@ declare module _ {
values(object: any): any[];
}
+ /**********
+ * String *
+ **********/
+
+ interface LoDashStatic {
+ camelCase(str?: string): string;
+ capitalize(str?: string): string;
+ deburr(str?: string): string;
+ endsWith(str?: string, target?: string, position?: number): boolean;
+ escape(str?: string): string;
+ escapeRegExp(str?: string): string;
+ kebabCase(str?: string): string;
+ pad(str?: string, length?: number, chars?: string): string;
+ padLeft(str?: string, length?: number, chars?: string): string;
+ padRight(str?: string, length?: number, chars?: string): string;
+ repeat(str?: string, n?: number): string;
+ snakeCase(str?: string): string;
+ startCase(str?: string): string;
+ startsWith(str?: string, target?: string, position?: number): boolean;
+ trim(str?: string, chars?: string): string;
+ trimLeft(str?: string, chars?: string): string;
+ trimRight(str?: string, chars?: string): string;
+ trunc(str?: string, len?: number): string;
+ trunc(str?: string, options?: { length?: number; omission?: string; separator?: string }): string;
+ trunc(str?: string, options?: { length?: number; omission?: string; separator?: RegExp }): string;
+ words(str?: string, pattern?: string): string[];
+ words(str?: string, pattern?: RegExp): string[];
+ }
+
+ //_.parseInt
+ interface LoDashStatic {
+ /**
+ * Converts the given value into an integer of the specified radix. If radix is undefined or 0 a
+ * radix of 10 is used unless the value is a hexadecimal, in which case a radix of 16 is used.
+ *
+ * Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See
+ * http://es5.github.io/#E.
+ * @param value The value to parse.
+ * @param radix The radix used to interpret the value to parse.
+ * @return The new integer value.
+ **/
+ parseInt(value: string, radix?: number): number;
+ }
+
/*************
* Utilities *
*************/
@@ -6174,22 +6218,6 @@ declare module _ {
noConflict(): typeof _;
}
- //_.parseInt
- interface LoDashStatic {
- /**
- * Converts the given value into an integer of the specified radix. If radix is undefined or 0 a
- * radix of 10 is used unless the value is a hexadecimal, in which case a radix of 16 is used.
- *
- * Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See
- * http://es5.github.io/#E.
- * @param value The value to parse.
- * @param radix The radix used to interpret the value to parse.
- * @return The new integer value.
- **/
- parseInt(value: string): number;
- }
-
-
//_.property
interface LoDashStatic {
/**
diff --git a/mkpath/mkpath-tests.ts b/mkpath/mkpath-tests.ts
new file mode 100644
index 000000000..d0be59244
--- /dev/null
+++ b/mkpath/mkpath-tests.ts
@@ -0,0 +1,9 @@
+///
+import mkpath = require('mkpath');
+
+mkpath('red/green/violet', function (err) {
+ if (err) throw err;
+ console.log('Directory structure red/green/violet created');
+});
+
+mkpath.sync('/tmp/blue/orange', 700);
diff --git a/mkpath/mkpath.d.ts b/mkpath/mkpath.d.ts
new file mode 100644
index 000000000..3be1a0229
--- /dev/null
+++ b/mkpath/mkpath.d.ts
@@ -0,0 +1,15 @@
+// Type definitions for mkpath v0.1.0
+// Project: https://www.npmjs.com/package/mkpath
+// Definitions by: Jared Klopper
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module 'mkpath' {
+ module mkpath {
+ function sync(path: string, mode?: number): void;
+ }
+
+ function mkpath(path: string, callback?: (err: any) => void): void;
+ function mkpath(path: string, mode?: number, callback?: (err?: any) => void): void;
+
+ export = mkpath;
+}
diff --git a/node-persist/node-persist-tests.ts b/node-persist/node-persist-tests.ts
new file mode 100644
index 000000000..a4e2af1ed
--- /dev/null
+++ b/node-persist/node-persist-tests.ts
@@ -0,0 +1,47 @@
+///
+// node-persist tests
+// compile with --module=common
+
+import nodePersist = require("node-persist");
+
+var opts = Node
+nodePersist.init({
+ dir: __dirname + "/test",
+ continuous: false
+});
+nodePersist.setItem("someArray", [1,2,3], (err)=> {
+ nodePersist.getItem("someArray", (err: any, value: any)=> {
+ nodePersist.removeItem("someArray", (err) => err);
+ });
+});
+nodePersist.setItem("someString", "foo")
+ .then(() => nodePersist.getItem("someString"))
+ .then(() => nodePersist.removeItem("someString"))
+ .then(() => nodePersist.clear())
+ .then(() => null);
+
+interface TestObject {
+ foo: string;
+ two: number;
+}
+nodePersist.clear((err) => {
+ var testObject: TestObject = {foo: "bar", two: 2};
+ nodePersist.setItemSync("someObject", testObject);
+ testObject = nodePersist.getItemSync("someObject");
+ nodePersist.removeItem("someObject");
+ nodePersist.clearSync();
+});
+
+var values: Array = nodePersist.values();
+var valuesWithKeyMatch: Array = nodePersist.valuesWithKeyMatch("some");
+var keys: Array = nodePersist.keys();
+var size: number = nodePersist.length();
+nodePersist.forEach((val) => {});
+try {
+ nodePersist.persist((err) => err);
+ nodePersist.persist().then(() => null);
+ nodePersist.persistSync;
+ nodePersist.persistKey("this", (err) => null);
+ nodePersist.persistKey("this").then(() => null);
+ nodePersist.persistKeySync("this");
+} catch(anyError){}
diff --git a/node-persist/node-persist.d.ts b/node-persist/node-persist.d.ts
new file mode 100644
index 000000000..23c86bd5c
--- /dev/null
+++ b/node-persist/node-persist.d.ts
@@ -0,0 +1,44 @@
+// Type definitions for node-persist
+// Project: https://github.com/simonlast/node-persist
+// Definitions by: Spencer Williams
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+///
+
+declare module "node-persist" {
+ type milliseconds = number;
+ module NodePersist {
+ export interface InitOptions {
+ dir?: string;
+ stringify?: (toSerialize: any)=>string;
+ parse?: (serialized: string)=>any;
+ encoding?: string;
+ logging?: boolean|Function;
+ continuous?: boolean;
+ interval?: milliseconds|boolean;
+ ttl?: milliseconds|boolean;
+ }
+ export function init(options?: InitOptions, callback?: Function): Q.Promise;
+ export function initSync(options?: InitOptions): void;
+ export function getItem(key: string, callback?: (err: any, value: any)=>any): Q.Promise;
+ export function getItemSync(key: string): any;
+ export function setItem(key: string, value: any, callback?: (err: any)=>any): Q.Promise;
+ export function setItemSync(key: string, value: any): void;
+ export function removeItem(key: string, callback?: (err: any)=>any): Q.Promise;
+ export function removeItemSync(key: string): void;
+ export function clear(callback?: (err: any)=>any): Q.Promise;
+ export function clearSync(): void;
+ export function values(): Array;
+ export function valuesWithKeyMatch(match: string): Array;
+ export function keys(): Array;
+ export function length(): number;
+ export function forEach(callback: (key: string, value: any)=>void): void;
+
+ export function persist(callback?: (err: any)=>any): Q.Promise;
+ export function persistSync(): void;
+ export function persistKey(key: string, callback?: (err: any)=>any): Q.Promise;
+ export function persistKeySync(key: string): void;
+ }
+ export = NodePersist;
+}
diff --git a/node/node-0.11-tests.ts b/node/node-0.11-tests.ts
index e9ef58dbb..5a0c294d4 100644
--- a/node/node-0.11-tests.ts
+++ b/node/node-0.11-tests.ts
@@ -10,6 +10,7 @@ import crypto = require("crypto");
import http = require("http");
import net = require("net");
import dgram = require("dgram");
+import querystring = require('querystring');
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
@@ -122,4 +123,14 @@ var ai: dgram.AddressInfo = ds.address();
ds.send(new Buffer("hello"), 0, 5, 5000, "127.0.0.1", (error: Error, bytes: number): void => {
});
+////////////////////////////////////////////////////
+///Querystring tests : https://gist.github.com/musubu/2202583
+////////////////////////////////////////////////////
+var original: string = 'http://example.com/product/abcde.html';
+var escaped: string = querystring.escape(original);
+console.log(escaped);
+// http%3A%2F%2Fexample.com%2Fproduct%2Fabcde.html
+var unescaped: string = querystring.unescape(escaped);
+console.log(unescaped);
+// http://example.com/product/abcde.html
diff --git a/node/node-0.11.d.ts b/node/node-0.11.d.ts
index a564ac85f..302ba12a9 100644
--- a/node/node-0.11.d.ts
+++ b/node/node-0.11.d.ts
@@ -250,8 +250,8 @@ declare module "buffer" {
declare module "querystring" {
export function stringify(obj: any, sep?: string, eq?: string): string;
export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any;
- export function escape(): any;
- export function unescape(): any;
+ export function escape(str: string): string;
+ export function unescape(str: string): string;
}
declare module "events" {
diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts
index f236faa89..274a580d8 100644
--- a/node/node-0.8.8.d.ts
+++ b/node/node-0.8.8.d.ts
@@ -203,8 +203,8 @@ interface Buffer {
declare module "querystring" {
export function stringify(obj: any, sep?: string, eq?: string): string;
export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any;
- export function escape(): any;
- export function unescape(): any;
+ export function escape(str: string): string;
+ export function unescape(str: string): string;
}
declare module "events" {
diff --git a/node/node-tests.ts b/node/node-tests.ts
index 7f59ab985..f2702ec4a 100644
--- a/node/node-tests.ts
+++ b/node/node-tests.ts
@@ -10,6 +10,7 @@ import crypto = require("crypto");
import http = require("http");
import net = require("net");
import dgram = require("dgram");
+import querystring = require('querystring');
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
@@ -165,4 +166,14 @@ var ai: dgram.AddressInfo = ds.address();
ds.send(new Buffer("hello"), 0, 5, 5000, "127.0.0.1", (error: Error, bytes: number): void => {
});
+////////////////////////////////////////////////////
+///Querystring tests : https://gist.github.com/musubu/2202583
+////////////////////////////////////////////////////
+var original: string = 'http://example.com/product/abcde.html';
+var escaped: string = querystring.escape(original);
+console.log(escaped);
+// http%3A%2F%2Fexample.com%2Fproduct%2Fabcde.html
+var unescaped: string = querystring.unescape(escaped);
+console.log(unescaped);
+// http://example.com/product/abcde.html
diff --git a/node/node.d.ts b/node/node.d.ts
index 6c09ee04f..b1e849535 100644
--- a/node/node.d.ts
+++ b/node/node.d.ts
@@ -250,8 +250,8 @@ declare module "buffer" {
declare module "querystring" {
export function stringify(obj: any, sep?: string, eq?: string): string;
export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any;
- export function escape(): any;
- export function unescape(): any;
+ export function escape(str: string): string;
+ export function unescape(str: string): string;
}
declare module "events" {
diff --git a/nopt/nopt-tests.ts b/nopt/nopt-tests.ts
new file mode 100644
index 000000000..1e2fb60a5
--- /dev/null
+++ b/nopt/nopt-tests.ts
@@ -0,0 +1,20 @@
+/**
+* Maintained by: jbondc
+*/
+
+///
+///
+
+import nopt = require("nopt");
+
+nopt({"--foo" : String})
+
+nopt({ "--foo": String }, { "-f": "--foo"})
+nopt({ "--foo": String }, { "-f": ["--foo", "-d"] })
+
+nopt({ "--foo": String }, { "-f": ["--foo", "-d"] }, ["test me --foo arg"])
+var cmd = nopt({ "--foo": String }, { "-f": ["--foo", "-d"] }, ["test me --foo arg"], 2)
+
+console.log(cmd.argv.cooked)
+console.log(cmd.argv.original)
+console.log(cmd.argv.remain)
diff --git a/nopt/nopt.d.ts b/nopt/nopt.d.ts
new file mode 100644
index 000000000..01e439821
--- /dev/null
+++ b/nopt/nopt.d.ts
@@ -0,0 +1,46 @@
+// Type definitions for nopt 3.0.1
+// Project: https://github.com/npm/nopt
+// Definitions by: jbondc
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module "nopt" {
+
+ interface CommandData {
+ [key: string]: string
+ }
+
+ interface TypeDefs {
+ [key: string]: TypeInfo
+ }
+
+ interface TypeInfo {
+ type: Object
+ validate: (data: CommandData, k: string, val: string) => boolean
+ }
+
+ module nopt {
+ export function clean(data: CommandData, types: FlagTypeMap, typeDefs?: TypeDefs): string
+ export var typeDefs: TypeDefs
+ }
+
+ interface FlagTypeMap {
+ [k: string]: Object
+ }
+
+ interface ShortFlags {
+ [k: string]: string[]|string
+ }
+
+ function nopt(types: FlagTypeMap, shorthands?: ShortFlags, args?: string[], slice?: number): OptionsParsed
+
+ interface OptionsParsed {
+ [k: string]: any
+ argv: {
+ remain: string[]
+ cooked: string[]
+ original: string[]
+ }
+ }
+
+ export = nopt
+}
\ No newline at end of file
diff --git a/raphael/raphael.d.ts b/raphael/raphael.d.ts
index 82dba5d4c..bef33d99c 100644
--- a/raphael/raphael.d.ts
+++ b/raphael/raphael.d.ts
@@ -28,9 +28,9 @@ interface RaphaelElement {
animateWith(el: RaphaelElement, anim: RaphaelAnimation, params: any, ms: number, easing?: string, callback?: Function): RaphaelElement;
animateWith(el: RaphaelElement, anim: RaphaelAnimation, animation: RaphaelAnimation): RaphaelElement;
attr(attrName: string, value: any): RaphaelElement;
- attr(params: any): RaphaelElement;
attr(attrName: string): any;
attr(attrNames: string[]): any[];
+ attr(params: any): RaphaelElement;
click(handler: Function): RaphaelElement;
clone(): RaphaelElement;
data(key: string): any;
diff --git a/react-router/react-router-test.ts b/react-router/react-router-test.ts
new file mode 100644
index 000000000..c220b3c24
--- /dev/null
+++ b/react-router/react-router-test.ts
@@ -0,0 +1,326 @@
+///
+"use strict";
+
+import React = require('react');
+import Router = require('react-router');
+
+// Mixin
+class NavigationTest {
+ v: T;
+
+ makePath() {
+ var v1: string = this.v.makePath('to');
+ var v2: string = this.v.makePath('to', {id: 1});
+ var v3: string = this.v.makePath('to', {id: 1}, {type: 'json'});
+ }
+ makeHref() {
+ var v1: string = this.v.makeHref('to');
+ var v2: string = this.v.makeHref('to', {id: 1});
+ var v3: string = this.v.makeHref('to', {id: 1}, {type: 'json'});
+ }
+ transitionTo() {
+ var v1: void = this.v.transitionTo('to');
+ var v2: void = this.v.transitionTo('to', {id: 1});
+ var v3: void = this.v.transitionTo('to', {id: 1}, {type: 'json'});
+ }
+ replaceWith() {
+ var v1: void = this.v.replaceWith('to');
+ var v2: void = this.v.replaceWith('to', {id: 1});
+ var v3: void = this.v.replaceWith('to', {id: 1}, {type: 'json'});
+ }
+ goBack() {
+ var v1: void = this.v.goBack();
+ }
+}
+
+class StateTest {
+ v: T;
+
+ getPath() {
+ var v1: string = this.v.getPath();
+ }
+
+ getRoutes() {
+ var v1: Router.Route[] = this.v.getRoutes();
+ }
+
+ getPathname() {
+ var v1: string = this.v.getPathname();
+ }
+
+ getParams() {
+ var v1: {} = this.v.getParams();
+ }
+
+ getQuery() {
+ var v1: {} = this.v.getQuery();
+ }
+
+ isActive() {
+ var v1: boolean = this.v.isActive('to');
+ var v2: boolean = this.v.isActive('to', {id: 1});
+ var v3: boolean = this.v.isActive('to', {id: 1}, {type: 'json'});
+ }
+}
+
+class RouteHandlerMixinTest {
+ v: T;
+
+ getRouteDepth() {
+ var v1: number = this.v.getRouteDepth();
+ }
+
+ createChildRouteHandler() {
+ var v1: Router.RouteHandler = this.v.createChildRouteHandler({ref: 'hoge'});
+ }
+}
+
+
+// Location
+class LocationTest {
+ v: T;
+
+ push() {
+ var v1: void = this.v.push('path/to/hoge');
+ }
+
+ replace() {
+ var v1: void = this.v.replace('path/to/hoge');
+ }
+
+ pop() {
+ var v1: void = this.v.pop();
+ }
+
+ getCurrentPath() {
+ var v1: void = this.v.getCurrentPath();
+ }
+}
+new LocationTest();
+new LocationTest();
+new LocationTest();
+
+class LocationListenerTest {
+ v: T;
+
+ addChangeListener() {
+ var v1: void = this.v.addChangeListener(() => console.log(1));
+ }
+
+ removeChangeListener() {
+ var v1: void = this.v.removeChangeListener(() => console.log(1));
+ }
+}
+new LocationListenerTest();
+new LocationListenerTest();
+
+
+// Behavior
+class ScrollBehaviorTest {
+ v: T;
+
+ updateScrollPosition() {
+ var v1: void = this.v.updateScrollPosition({x: 33, y: 102}, 'scrollTop');
+ }
+}
+new ScrollBehaviorTest();
+new ScrollBehaviorTest();
+
+
+// Component
+class DefaultRouteTest {
+ v: Router.DefaultRoute;
+
+ props() {
+ var name: string = this.v.props.name;
+ var handler: React.ComponentClass = this.v.props.handler;
+ }
+
+ createElement() {
+ var Handler: React.ComponentClass;
+ React.createElement(Router.DefaultRoute, null);
+ React.createElement(Router.DefaultRoute, {name: 'name', handler: Handler});
+ }
+}
+
+class LinkTest {
+ v: Router.Link;
+
+ constructor() {
+ new NavigationTest();
+ new StateTest();
+ }
+
+ props() {
+ var activeClassName: string = this.v.props.activeClassName;
+ var to: string = this.v.props.to;
+ var params: {} = this.v.props.params;
+ var query: {} = this.v.props.query;
+ var onClick: Function = this.v.props.onClick;
+ }
+
+ getHref() {
+ var v1: string = this.v.getHref();
+ }
+
+ getClassName() {
+ var v1: string = this.v.getClassName();
+ }
+
+ createElement() {
+ React.createElement(Router.Link, null);
+ React.createElement(Router.Link, {to: 'home'});
+ React.createElement(Router.Link, {
+ activeClassName: 'name',
+ to: 'home',
+ params: {},
+ query: {},
+ onClick: () => console.log(1)
+ });
+ }
+}
+
+class NotFoundRouteTest {
+ v: Router.NotFoundRoute;
+
+ props() {
+ var name: string = this.v.props.name;
+ var handler: React.ComponentClass = this.v.props.handler;
+ }
+
+ createElement() {
+ var Handler: React.ComponentClass;
+ React.createElement(Router.NotFoundRoute, null);
+ React.createElement(Router.NotFoundRoute, {handler: Handler});
+ React.createElement(Router.NotFoundRoute, {handler: Handler, name: "home"});
+ }
+}
+
+class RedirectTest {
+ v: Router.Redirect;
+
+ props() {
+ var path: string = this.v.props.path;
+ var from: string = this.v.props.from;
+ var to: string = this.v.props.to;
+ }
+
+ createElement() {
+ React.createElement(Router.Redirect, null);
+ React.createElement(Router.Redirect, {});
+ React.createElement(Router.Redirect, {path: 'a', from: 'a', to: 'b'});
+ }
+}
+
+class RouteTest {
+ v: Router.Route;
+
+ props() {
+ var name: string = this.v.props.name;
+ var path: string = this.v.props.path;
+ var handler: React.ComponentClass = this.v.props.handler;
+ var ignoreScrollBehavior: boolean = this.v.props.ignoreScrollBehavior;
+ }
+
+ createElement() {
+ var Handler: React.ComponentClass;
+ React.createElement(Router.Route, null);
+ React.createElement(Router.Route, {});
+ React.createElement(Router.Route, {name: "home", path: "/", handler: Handler, ignoreScrollBehavior: true});
+ }
+}
+
+class RouteHandlerTest {
+ v: Router.RouteHandler;
+
+ constructor() {
+ new RouteHandlerMixinTest();
+ }
+
+ createElement() {
+ React.createElement(Router.RouteHandler, null);
+ React.createElement(Router.RouteHandler, {});
+ }
+}
+
+
+// History
+class HistoryTest {
+ v: Router.History;
+
+ length() {
+ var v1: number = this.v.length;
+ }
+
+ back() {
+ var v1: void = this.v.back();
+ }
+}
+
+
+// Router
+class CreateTest {
+ v: Router.Router;
+
+ constructor() {
+ this.v = Router.create({
+ routes: React.createElement(Router.Route, null)
+ });
+ this.v = Router.create({
+ routes: React.createElement(Router.Route, null),
+ location: Router.HistoryLocation,
+ scrollBehavior: Router.ImitateBrowserBehavior
+ });
+ }
+
+ run() {
+ this.v.run((Handler) => console.log(Handler));
+ this.v.run((Handler, state) => console.log(Handler, state));
+ }
+}
+
+class RunTest {
+ constructor() {
+ var v1: Router.Router = Router.run(React.createElement(Router.Route, null), (Handler) => {
+ React.render(React.createElement(Handler, null), document.body);
+ });
+ var v2: Router.Router = Router.run(React.createElement(Router.Route, null), Router.HistoryLocation, (Handler, state) => {
+ React.render(React.createElement(Handler, null), document.body);
+ });
+ }
+}
+
+
+// Transition
+class TransitionTest {
+ constructor() {
+ var v1: Router.TransitionStaticLifecycle = {
+ willTransitionTo: (transition, params, query, callback) => {
+ transition.abort();
+ transition.redirect('to');
+ transition.redirect('to', {id: 1});
+ transition.redirect('to', {id: 1}, {type: 'json'});
+ transition.retry();
+ },
+ willTransitionFrom: (transition, component, callback) => {}
+ };
+ var v2: Router.TransitionStaticLifecycle = {
+ willTransitionTo: (transition, params, query) => {},
+ willTransitionFrom: (transition, component) => {}
+ };
+ var v3: Router.TransitionStaticLifecycle = {
+ willTransitionTo: (transition, params) => {},
+ willTransitionFrom: (transition) => {}
+ };
+ var v4: Router.TransitionStaticLifecycle = {
+ willTransitionTo: (transition) => {},
+ willTransitionFrom: () => {}
+ };
+ var v5: Router.TransitionStaticLifecycle = {
+ willTransitionTo: () => {}
+ };
+ var v6: Router.TransitionStaticLifecycle = {
+ willTransitionFrom: () => {}
+ };
+ }
+}
diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts
new file mode 100644
index 000000000..13c573b4b
--- /dev/null
+++ b/react-router/react-router.d.ts
@@ -0,0 +1,278 @@
+// Type definitions for React Router 0.12.0
+// Project: https://github.com/rackt/react-router
+// Definitions by: Yuichi Murata
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module ReactRouter {
+ //
+ // Mixin
+ // ----------------------------------------------------------------------
+ interface Navigation {
+ makePath(to: string, params?: {}, query?: {}): string;
+ makeHref(to: string, params?: {}, query?: {}): string;
+ transitionTo(to: string, params?: {}, query?: {}): void;
+ replaceWith(to: string, params?: {}, query?: {}): void;
+ goBack(): void;
+ }
+
+ interface RouteHandlerMixin {
+ getRouteDepth(): number;
+ createChildRouteHandler(props: {}): RouteHandler;
+ }
+
+ interface State {
+ getPath(): string;
+ getRoutes(): Route[];
+ getPathname(): string;
+ getParams(): {};
+ getQuery(): {};
+ isActive(to: string, params?: {}, query?: {}): boolean;
+ }
+
+ var Navigation: Navigation;
+ var State: State;
+ var RouteHandlerMixin: RouteHandlerMixin;
+
+
+ //
+ // Component
+ // ----------------------------------------------------------------------
+ // DefaultRoute
+ interface DefaultRouteProp {
+ name?: string;
+ handler: React.ComponentClass;
+ }
+ interface DefaultRoute extends React.ReactElement {
+ __react_router_default_route__: any; // dummy
+ }
+ interface DefaultRouteClass extends React.ComponentClass {
+ __react_router_default_route__: any; // dummy
+ }
+
+ // Link
+ interface LinkProp {
+ activeClassName?: string;
+ to: string;
+ params?: {};
+ query?: {};
+ onClick?: Function;
+ }
+ interface Link extends React.ReactElement, Navigation, State {
+ __react_router_link__: any; // dummy
+
+ getHref(): string;
+ getClassName(): string;
+ }
+ interface LinkClass extends React.ComponentClass {
+ __react_router_link__: any; // dummy
+ }
+
+ // NotFoundRoute
+ interface NotFoundRouteProp {
+ name?: string;
+ handler: React.ComponentClass;
+ }
+ interface NotFoundRoute extends React.ReactElement {
+ __react_router_not_found_route__: any; // dummy
+ }
+ interface NotFoundRouteClass extends React.ComponentClass {
+ __react_router_not_found_route__: any; // dummy
+ }
+
+ // Redirect
+ interface RedirectProp {
+ path?: string;
+ from?: string;
+ to?: string;
+ }
+ interface Redirect extends React.ReactElement {
+ __react_router_redirect__: any; // dummy
+ }
+ interface RedirectClass extends React.ComponentClass {
+ __react_router_redirect__: any; // dummy
+ }
+
+ // Route
+ interface RouteProp {
+ name?: string;
+ path?: string;
+ handler?: React.ComponentClass;
+ ignoreScrollBehavior?: boolean;
+ }
+ interface Route extends React.ReactElement {
+ __react_router_route__: any; // dummy
+ }
+ interface RouteClass extends React.ComponentClass {
+ __react_router_route__: any; // dummy
+ }
+
+ // RouteHandler
+ interface RouteHandlerProp {}
+ interface RouteHandler extends React.ReactElement, RouteHandlerMixin {
+ __react_router_route_handler__: any; // dummy
+ }
+ interface RouteHandlerClass extends React.ReactElement {
+ __react_router_route_handler__: any; // dummy
+ }
+
+ var DefaultRoute: DefaultRouteClass;
+ var Link: LinkClass;
+ var NotFoundRoute: NotFoundRouteClass;
+ var Redirect: RedirectClass;
+ var Route: RouteClass;
+ var RouteHandler: RouteHandlerClass;
+
+
+ //
+ // Location
+ // ----------------------------------------------------------------------
+ interface LocationBase {
+ push(path: string): void;
+ replace(path: string): void;
+ pop(): void;
+ getCurrentPath(): void;
+ }
+
+ interface LocationListener {
+ addChangeListener(listener: Function): void;
+ removeChangeListener(listener: Function): void;
+ }
+
+ interface HashLocation extends LocationBase, LocationListener {}
+ interface HistoryLocation extends LocationBase, LocationListener {}
+ interface RefreshLocation extends LocationBase {}
+
+ var HashLocation: HashLocation;
+ var HistoryLocation: HistoryLocation;
+ var RefreshLocation: RefreshLocation;
+
+
+ //
+ // Behavior
+ // ----------------------------------------------------------------------
+ interface ScrollBehaviorBase {
+ updateScrollPosition(position: {x: number; y: number;}, actionType: string): void;
+ }
+ interface ImitateBrowserBehavior extends ScrollBehaviorBase {}
+ interface ScrollToTopBehavior extends ScrollBehaviorBase {}
+
+ var ImitateBrowserBehavior: ImitateBrowserBehavior;
+ var ScrollToTopBehavior: ScrollToTopBehavior;
+
+
+ //
+ // Router
+ // ----------------------------------------------------------------------
+ interface Router extends React.ReactElement {
+ run(callback: RouterRunCallback): void;
+ }
+
+ interface RouterState {
+ path: string;
+ action: string;
+ pathname: string;
+ params: {};
+ query: {};
+ routes : Route[];
+ }
+
+ interface RouterCreateOption {
+ routes: Route;
+ location?: LocationBase;
+ scrollBehavior?: ScrollBehaviorBase;
+ }
+
+ type RouterRunCallback = (Handler: Router, state: RouterState) => void;
+
+ function create(options: RouterCreateOption): Router;
+ function run(routes: Route, callback: RouterRunCallback): Router;
+ function run(routes: Route, location: LocationBase, callback: RouterRunCallback): Router;
+
+
+ //
+ // History
+ // ----------------------------------------------------------------------
+ interface History {
+ back(): void;
+ length: number;
+ }
+ var History: History;
+
+
+ //
+ // Transition
+ // ----------------------------------------------------------------------
+ interface Transition {
+ abort(): void;
+ redirect(to: string, params?: {}, query?: {}): void;
+ retry(): void;
+ }
+
+ interface TransitionStaticLifecycle {
+ willTransitionTo?(
+ transition: Transition,
+ params: {},
+ query: {},
+ callback: Function
+ ): void;
+
+ willTransitionFrom?(
+ transition: Transition,
+ component: React.ReactElement,
+ callback: Function
+ ): void;
+ }
+}
+
+declare module 'react-router' {
+ import Export = ReactRouter;
+ export = Export;
+}
+
+declare module React {
+ interface TopLevelAPI {
+ // for DefaultRoute
+ createElement(
+ type: ReactRouter.DefaultRouteClass,
+ props: ReactRouter.DefaultRouteProp,
+ ...children: ReactNode[]
+ ): ReactRouter.DefaultRoute;
+
+ // for Link
+ createElement(
+ type: ReactRouter.LinkClass,
+ props: ReactRouter.LinkProp,
+ ...children: ReactNode[]
+ ): ReactRouter.Link;
+
+ // for NotFoundRoute
+ createElement(
+ type: ReactRouter.NotFoundRouteClass,
+ props: ReactRouter.NotFoundRouteProp,
+ ...children: ReactNode[]
+ ): ReactRouter.NotFoundRoute;
+
+ // for Redirect
+ createElement(
+ type: ReactRouter.RedirectClass,
+ props: ReactRouter.RedirectProp,
+ ...children: ReactNode[]
+ ): ReactRouter.Redirect;
+
+ // for Route
+ createElement(
+ type: ReactRouter.RouteClass,
+ props: ReactRouter.RouteProp,
+ ...children: ReactNode[]
+ ): ReactRouter.Route;
+
+ // for RouteHandler
+ createElement(
+ type: ReactRouter.RouteHandlerClass,
+ props: ReactRouter.RouteHandlerProp,
+ ...children: ReactNode[]
+ ): ReactRouter.RouteHandler;
+ }
+}
diff --git a/sanitize-html/sanitize-html-tests.ts b/sanitize-html/sanitize-html-tests.ts
new file mode 100644
index 000000000..22811faac
--- /dev/null
+++ b/sanitize-html/sanitize-html-tests.ts
@@ -0,0 +1,33 @@
+///
+
+import sanitizeHtml = require('sanitize-html');
+
+var s: string;
+var t: string;
+
+t = sanitizeHtml(s);
+t = sanitizeHtml(s, {
+});
+t = sanitizeHtml(s, {
+ allowedTags: ["a", "br"],
+ allowedSchemes: ["http"],
+ allowedAttributes: { "a": ["href"] },
+ allowedClasses: { "a": ["someclass"] },
+ transformTags: {
+ "a": "b",
+ "br": function(tagName: string, attributes: {[index: string]: string}): { tagName: string; attributes: {[index: string]: string};} {
+ return { tagName: tagName, attributes: attributes };
+ }
+ },
+ exclusiveFilter: {
+ "a": function(frame: {
+ tag: string;
+ attribs: { [index: string]: string };
+ text: string;
+ tagPosition: number;
+ }): boolean {
+ return false;
+ }
+ }
+});
+
diff --git a/sanitize-html/sanitize-html.d.ts b/sanitize-html/sanitize-html.d.ts
new file mode 100644
index 000000000..1875eedab
--- /dev/null
+++ b/sanitize-html/sanitize-html.d.ts
@@ -0,0 +1,27 @@
+// Type definitions for sanitize-html 1.6.0
+// Project: https://github.com/punkave/sanitize-html
+// Definitions by: Rogier Schouten
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+declare module "sanitize-html" {
+
+ function sanitizeHtml(s: string, opts?: {
+ allowedTags?: string[];
+ allowedSchemes?: string[];
+ allowedAttributes?: { [index: string]: string[] };
+ allowedClasses?: { [index: string]: string[] };
+ transformTags?: { [index: string]: any };
+ exclusiveFilter?: {
+ [index: string]: (frame: {
+ tag: string;
+ attribs: { [index: string]: string };
+ text: string;
+ tagPosition: number;
+ }) => boolean
+ };
+
+ }): string;
+
+ export = sanitizeHtml;
+}
diff --git a/sax/sax-tests.ts b/sax/sax-tests.ts
new file mode 100644
index 000000000..3eeecc4fc
--- /dev/null
+++ b/sax/sax-tests.ts
@@ -0,0 +1,43 @@
+///
+///
+import sax = require("sax");
+
+var opts: sax.SAXOptions = {
+ lowercase: true,
+ normalize: true,
+ xmlns: true,
+ position: true
+};
+
+var parser = sax.parser(/*strict=*/true, opts);
+
+parser.onerror = function(e: Error) {
+};
+
+parser.ontext = function(text: string) {
+};
+
+parser.onopentag = function(tag: sax.Tag) {
+};
+
+parser.onattribute = function(attr: { name: string; value: string; }) {
+};
+
+parser.onend = function() {
+};
+
+parser.write("Hello, world!").close();
+
+
+var saxStream = sax.createStream(/*strict=*/true, opts);
+
+saxStream.on("error", function(e: Error) {
+ this._parser.error = null;
+ this._parser.resume();
+});
+
+import fs = require("fs");
+fs.createReadStream("file.xml")
+ .pipe(saxStream)
+ .pipe(fs.createWriteStream("file-copy.xml"));
+
diff --git a/sax/sax.d.ts b/sax/sax.d.ts
new file mode 100644
index 000000000..fb3d7e785
--- /dev/null
+++ b/sax/sax.d.ts
@@ -0,0 +1,78 @@
+// Type definitions for sax js
+// Project: https://github.com/isaacs/sax-js
+// Definitions by: Asana
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+///
+
+declare module "sax" {
+ export var EVENTS: string[];
+
+ interface SAXOptions {
+ trim?: boolean;
+ normalize?: boolean;
+ lowercase?: boolean;
+ xmlns?: boolean;
+ noscript?: boolean;
+ position?: boolean;
+ }
+
+ export interface Tag {
+ name: string;
+ attributes: { [key: string]: string };
+
+ // Available if opt.xmlns
+ ns?: { [key: string]: string };
+ prefix?: string;
+ local?: string;
+ uri?: string;
+ }
+
+ export function parser(strict: boolean, opt: SAXOptions): SAXParser;
+ export class SAXParser {
+ constructor(strict: boolean, opt: SAXOptions);
+
+ // Methods
+ end(): void;
+ write(s: string): SAXParser;
+ resume(): SAXParser;
+ close(): SAXParser;
+ flush(): void;
+
+ // Members
+ line: number;
+ column: number;
+ error: Error;
+ position: number;
+ startTagPosition: number;
+ closed: boolean;
+ strict: boolean;
+ opt: SAXOptions;
+ tag: string;
+
+ // Events
+ onerror(e: Error): void;
+ ontext(t: string): void;
+ ondoctype(doctype: string): void;
+ onprocessinginstruction(node: { name: string; body: string }): void;
+ onopentag(tag: Tag): void;
+ onclosetag(tagName: string): void;
+ onattribute(attr: { name: string; value: string }): void;
+ oncomment(comment: string): void;
+ onopencdata(): void;
+ oncdata(cdata: string): void;
+ onclosecdata(): void;
+ onopennamespace(ns: { prefix: string; uri: string }): void;
+ onclosenamespace(ns: { prefix: string; uri: string }): void;
+ onend(): void;
+ onready(): void;
+ onscript(script: string): void;
+ }
+
+ import stream = require("stream");
+ export function createStream(strict: boolean, opt: SAXOptions): SAXStream;
+ export class SAXStream extends stream.Duplex {
+ constructor(strict: boolean, opt: SAXOptions);
+ private _parser: SAXParser;
+ }
+}
+
diff --git a/sequelize/sequelize-tests.ts b/sequelize/sequelize-tests.ts
new file mode 100644
index 000000000..0bbfe3f6d
--- /dev/null
+++ b/sequelize/sequelize-tests.ts
@@ -0,0 +1,214 @@
+///
+
+import Sequelize = require('sequelize');
+
+var opts: Sequelize.Options;
+var defOpts: Sequelize.DefineOptions = {
+ indexes: [{
+ fields: [""],
+ type: "",
+ method: ""
+ }]
+};
+var attrOpts: Sequelize.AttributeOptions;
+var defIndexOpts: Sequelize.DefineIndexOptions;
+var indexOpts: Sequelize.IndexOptions;
+var dropOpts: Sequelize.DropOptions;
+var transOpts: Sequelize.TransactionOptions;
+var syncOpts: Sequelize.SyncOptions;
+var assocOpts: Sequelize.AssociationOptions;
+var schemaOpts: Sequelize.SchemaOptions;
+var findOpts: Sequelize.FindOptions
+var findCrOpts: Sequelize.FindOrCreateOptions;
+var queryOpts: Sequelize.QueryOptions;
+var buildOpts: Sequelize.BuildOptions;
+var copyOpts: Sequelize.CopyOptions;
+var bulkCrOpts: Sequelize.BulkCreateOptions;
+var destroyOpts: Sequelize.DestroyOptions;
+var destroyInstOpts: Sequelize.DestroyInstanceOptions;
+var updateOpts: Sequelize.UpdateOptions;
+var saveOpts: Sequelize.SaveOptions;
+var valOpts: Sequelize.ValidateOptions;
+var incrOpts: Sequelize.IncrementOptions;
+
+var promiseMe: Sequelize.Promise;
+var emitMe: Sequelize.EventEmitter;
+
+var sequelize = new Sequelize("", "");
+sequelize = new Sequelize("", opts);
+sequelize = new Sequelize("", "", "");
+sequelize = new Sequelize("", "", opts);
+sequelize = new Sequelize("", "", "", opts);
+
+interface modelPojo {
+ name: string;
+}
+
+interface modelInst extends Sequelize.Instance, modelPojo {
+
+};
+
+var myModelInst: modelInst;
+var myModelPojo: modelPojo;
+
+sequelize.define("MyTable", attrOpts, defOpts);
+var model: Sequelize.Model = sequelize.model("MyTable");
+model = sequelize.import("");
+emitMe = sequelize.authenticate();
+sequelize.cast({}, "");
+sequelize.col("myCol");
+sequelize.models.MyTable;
+emitMe = sequelize.drop(dropOpts);
+emitMe = sequelize.createSchema("schema");
+emitMe = sequelize.dropAllSchemas();
+emitMe = sequelize.dropSchema("dbo");
+emitMe = sequelize.fn("upper", sequelize.col("username"));
+sequelize.literal("");
+sequelize.literal(1234);
+sequelize.and("", 1234);
+sequelize.or("", 123);
+sequelize.where("", "");
+sequelize.where("", sequelize.and("", ""));
+promiseMe= sequelize.transaction(transOpts);
+promiseMe = sequelize.transaction(transOpts, function (t:Sequelize.Transaction): boolean { return true; });
+emitMe = sequelize.query("", model).complete(function (err, result) { });
+emitMe = sequelize.query("");
+var dialect: string = sequelize.getDialect();
+emitMe = sequelize.showAllSchemas();
+emitMe = sequelize.sync(syncOpts);
+
+model.addHook("", "", function () { });
+model.addHook("", function () { });
+model.beforeValidate("", function () { });
+model.afterValidate("", function () { });
+model.beforeCreate("", function () { });
+model.afterCreate("", function () { });
+model.beforeDestroy("", function () { });
+model.afterDestroy("", function () { });
+model.beforeUpdate("", function () { });
+model.afterUpdate("", function () { });
+model.beforeBulkCreate("", function () { });
+model.afterBulkCreate("", function () { });
+model.beforeBulkDestroy("", function () { });
+model.afterBulkDestroy("", function () { });
+model.beforeBulkUpdate("", function () { });
+model.afterBulkUpdate("", function () { });
+
+
+model.hasOne(model);
+model.hasOne(model, assocOpts);
+model.belongsTo(model);
+model.belongsTo(model, assocOpts);
+model.hasMany(model);
+model.hasMany(model, assocOpts);
+
+promiseMe = model.sync();
+promiseMe = model.drop(dropOpts);
+model.schema("", schemaOpts);
+model.getTableName();
+model = model.scope({});
+model = model.scope("");
+model = model.scope([]);
+model = model.scope(null);
+
+model.find().then(function () { }, function () { });
+model.find().then(function () { });
+model.find().then(null, function () { });
+model.find().then(function (result: modelInst) { });
+model.find().then(function (result: modelInst): Sequelize.PromiseT { return model.find(1) });
+model.find().then(function (result: modelInst): Sequelize.PromiseT { return model.find(1) }, function (): Sequelize.PromiseT { return model.find(1) });
+
+model.find().catch(function () { });
+model.find().catch(function (result: modelInst) { });
+model.find().catch(function (result: modelInst): Sequelize.Promise { return model.find(1) });
+
+model.find().spread(function () { }, function () { });
+model.find().spread(function () { });
+model.find().spread(null, function () { });
+model.find().spread(function (result: modelInst) { });
+model.find().spread(function (result1: modelInst, result2: any) { });
+model.find().spread(null, function (result1: any, result2: boolean) { });
+model.find().spread(function (result: modelInst): Sequelize.Promise { return model.find(1) });
+model.find().spread(function (result: modelInst): Sequelize.PromiseT { return model.find(1) });
+model.find().spread(function (result: modelInst) { }, function (): Sequelize.PromiseT { return model.find(1) });
+model.find().spread(function (result: modelInst): Sequelize.PromiseT { return model.find(1) }, function (): Sequelize.PromiseT { return model.find(1) });
+
+promiseMe = model.findAll(findOpts, queryOpts);
+promiseMe = model.findAll(findOpts);
+promiseMe = model.findAll();
+promiseMe = model.find(findOpts, queryOpts);
+promiseMe = model.find(findOpts);
+promiseMe = model.find(1, queryOpts);
+promiseMe = model.find(1);
+promiseMe = model.find();
+promiseMe = model.aggregate("", "", findOpts);
+promiseMe = model.count();
+promiseMe = model.count(findOpts);
+promiseMe = model.findAndCountAll(findOpts, queryOpts);
+promiseMe = model.findAndCountAll(findOpts);
+promiseMe = model.findAndCountAll();
+promiseMe = model.max("", findOpts);
+promiseMe = model.max("");
+promiseMe = model.min("", findOpts);
+promiseMe = model.min("");
+promiseMe = model.sum("", findOpts);
+promiseMe = model.sum("");
+myModelInst = model.build(myModelPojo, buildOpts);
+myModelInst = model.build(myModelPojo);
+promiseMe = model.create(myModelPojo, copyOpts);
+promiseMe = model.create(myModelPojo);
+promiseMe = model.findOrInitialize({}, myModelPojo, queryOpts);
+promiseMe = model.findOrInitialize({}, myModelPojo);
+promiseMe = model.findOrInitialize({});
+promiseMe = model.findOrCreate({}, myModelPojo, findCrOpts);
+promiseMe = model.findOrCreate({}, myModelPojo);
+promiseMe = model.findOrCreate({});
+promiseMe = model.bulkCreate([myModelPojo], bulkCrOpts);
+promiseMe = model.bulkCreate([myModelPojo]);
+promiseMe = model.destroy({}, destroyOpts);
+promiseMe = model.destroy({});
+promiseMe = model.destroy();
+promiseMe = model.update(myModelPojo, {}, updateOpts);
+promiseMe = model.update(myModelPojo, {});
+promiseMe = model.describe();
+model.dataset;
+//var isDefined: boolean = sequelize.isDefined("");
+
+model.find().spread(function (arg1: string, arg2: number) {
+ return model.find();
+});
+
+var isBool: boolean;
+var strArr: Array;
+
+isBool = myModelInst.isNewRecord;
+model = myModelInst.Model;
+sequelize = myModelInst.sequelize;
+isBool = myModelInst.isDeleted;
+myModelPojo = myModelInst.values;
+isBool = myModelInst.isDirty;
+myModelPojo = myModelInst.primaryKeyValues;
+myModelInst.getDataValue("");
+myModelInst.setDataValue("", "");
+myModelInst.setDataValue("", 123);
+myModelInst.get("");
+myModelInst.set("", "");
+myModelInst.set("", 123);
+isBool = myModelInst.changed("");
+strArr = myModelInst.changed();
+myModelInst.previous("");
+promiseMe = myModelInst.save(["", ""], saveOpts);
+promiseMe = myModelInst.save(["", ""]);
+promiseMe = myModelInst.reload();
+promiseMe = myModelInst.reload(findOpts);
+promiseMe = myModelInst.validate(valOpts);
+promiseMe = myModelInst.validate();
+promiseMe = myModelInst.updateAttributes(myModelPojo, saveOpts);
+promiseMe = myModelInst.destroy(destroyInstOpts);
+promiseMe = myModelInst.destroy();
+promiseMe = myModelInst.increment({}, incrOpts);
+promiseMe = myModelInst.increment({});
+promiseMe = myModelInst.decrement({}, incrOpts);
+isBool = myModelInst.equal(myModelInst);
+isBool = myModelInst.equalsOneOf([myModelInst]);
+myModelPojo = myModelInst.toJSON();
\ No newline at end of file
diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts
new file mode 100644
index 000000000..08eb47272
--- /dev/null
+++ b/sequelize/sequelize.d.ts
@@ -0,0 +1,2780 @@
+// Type definitions for Sequelize 2.0.0 dev13
+// Project: http://sequelizejs.com
+// Definitions by: samuelneff , Peter Harris
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+// Based on original work by: samuelneff
+
+///
+///
+
+declare module "sequelize"
+{
+ module sequelize {
+ interface SequelizeStaticAndInstance {
+
+ /**
+ * A reference to sequelize utilities. Most users will not need to use these utils directly. However, you might want
+ * to use Sequelize.Utils._, which is a reference to the lodash library, if you don't already have it imported in
+ * your project.
+ */
+ Utils: Utils;
+
+ /**
+ * A modified version of bluebird promises, that allows listening for sql events.
+ *
+ * @see Promise
+ */
+ Promise: Promise;
+
+ /**
+ * Exposes the validator.js object, so you can extend it with custom validation functions. The validator is exposed
+ * both on the instance, and on the constructor.
+ *
+ * @see Validator
+ */
+ Validator: Validator;
+
+ QueryTypes: QueryTypes;
+
+ /**
+ * A general error class.
+ */
+ Error: Error;
+
+ /**
+ * Emitted when a validation fails.
+ *
+ * @see ValidationError
+ */
+ ValidationError: ValidationError;
+
+ /**
+ * Creates a object representing a database function. This can be used in search queries, both in where and order
+ * parts, and as default values in column definitions. If you want to refer to columns in your function, you should
+ * use sequelize.col, so that the columns are properly interpreted as columns and not a strings.
+ *
+ * @param fn The function you want to call.
+ * @param args All further arguments will be passed as arguments to the function.
+ */
+ fn(fn: string, ...args: Array): any;
+
+ /**
+ * Creates a object representing a column in the DB. This is often useful in conjunction with sequelize.fn, since
+ * raw string arguments to fn will be escaped.
+ *
+ * @param col The name of the column
+ */
+ col(col: string): Col;
+
+ /**
+ * Creates a object representing a call to the cast function.
+ *
+ * @param val The value to cast.
+ * @param type The type to cast it to.
+ */
+ cast(val: any, type: string): Cast;
+
+ /**
+ * Creates a object representing a literal, i.e. something that will not be escaped.
+ *
+ * @param val Value to convert to a literal.
+ */
+ literal(val: any): Literal;
+
+ /**
+ * An AND query.
+ *
+ * @param args Each argument (string or object) will be joined by AND.
+ */
+ and(...args: Array): And;
+
+ /**
+ * An OR query.
+ *
+ * @param args Each argument (string or object) will be joined by OR.
+ */
+ or(...args: Array): Or;
+
+ /**
+ * A way of specifying attr = condition. Mostly used internally.
+ *
+ * @param attr The attribute
+ * @param condition The condition. Can be both a simply type, or a further condition (.or, .and, .literal etc.)
+ */
+ where(attr: string, condition: any): Where;
+ }
+
+ interface SequelizeStatic extends SequelizeStaticAndInstance, DataTypes {
+ /**
+ * Instantiate sequelize with name of database and username
+ * @param database database name
+ * @param username user name
+ */
+ new (database: string, username: string): Sequelize;
+
+ /**
+ * Instantiate sequelize with name of database, username and password
+ * @param database database name
+ * @param username user name
+ * @param password password
+ */
+ new (database: string, username: string, password: string): Sequelize;
+
+ /**
+ * Instantiate sequelize with name of database, username, password, and options.
+ * @param database database name
+ * @param username user name
+ * @param password password
+ * @param options options. @see Options
+ */
+ new (database: string, username: string, password: string, options: Options): Sequelize;
+
+ /**
+ * Instantiate sequelize with name of database, username, and options.
+ *
+ * @param database database name
+ * @param username user name
+ * @param options options. @see Options
+ */
+ new (database: string, username: string, options: Options): Sequelize;
+
+ /**
+ * Instantiate sequlize with an URI
+ * @param connectionString A full database URI
+ * @param options Options for sequelize. @see Options
+ */
+ new (connectionString: string, options?: Options): Sequelize;
+ }
+
+ interface Sequelize extends SequelizeStaticAndInstance {
+ /**
+ * Sequelize configuration (undocumented).
+ */
+ config: Config;
+
+ /**
+ * Sequelize options (undocumented).
+ */
+ options: Options;
+
+ /**
+ * Models are stored here under the name given to sequelize.define
+ */
+ models: any;
+ modelManager: ModelManager;
+ daoFactoryManager: ModelManager;
+ transactionManager: TransactionManager;
+ importCache: any;
+
+ /**
+ * A reference to the sequelize transaction class. Use this to access isolationLevels when creating a transaction.
+ *
+ * @see Transaction
+ */
+ Transaction: TransactionStatic;
+
+ /**
+ * Returns the specified dialect.
+ */
+ getDialect(): string;
+
+ /**
+ * Returns the singleton instance of QueryInterface.
+ */
+ getQueryInterface(): QueryInterface;
+
+ /**
+ * Returns the singleton instance of Migrator.
+ * @param options Migration options
+ * @param force A flag that defines if the migrator should get instantiated or not.
+ */
+ getMigrator(options?: MigratorOptions, force?: boolean): Migrator;
+
+ /**
+ * Define a new model, representing a table in the DB.
+ *
+ * @param daoName The name of the entity (table). Typically specified in singular form.
+ * @param attributes A hash of attributes to define. Each attribute can be either a string name for the attribute
+ * or can be an object defining the attribute and its options. Note attributes is not fully
+ * typed since TypeScript does not support union types--it can be either a string or an
+ * options object. @see AttributeOptions.
+ * @param options Table options. @see DefineOptions.
+ */
+ define(daoName: string, attributes: any, options?: DefineOptions): Model;
+
+ /**
+ * Fetch a DAO factory which is already defined.
+ *
+ * @param daoName The name of a model defined with Sequelize.define.
+ */
+ model(daoName: string): Model;
+
+ /**
+ * Checks whether a model with the given name is defined.
+ *
+ * @param daoName The name of a model defined with Sequelize.define.
+ */
+ isDefined(daoName: string): boolean;
+
+ /**
+ * Imports a model defined in another file.
+ *
+ * @param path The path to the file that holds the model you want to import. If the part is relative, it will be
+ * resolved relatively to the calling file
+ */
+ import(path: string): Model;
+
+ /**
+ * Execute a query on the DB, with the possibility to bypass all the sequelize goodness.
+ *
+ * @param sql SQL statement to execute.
+ *
+ * @param callee If callee is provided, the selected data will be used to build an instance of the DAO represented
+ * by the factory. Equivalent to calling Model.build with the values provided by the query.
+ *
+ * @param options Query options.
+ *
+ * @param replacements Either an object of named parameter replacements in the format :param or an array of
+ * unnamed replacements to replace ? in your SQL.
+ */
+ query(sql: string, callee?: Model, options?: QueryOptions, replacements?: any): EventEmitter;
+
+ query(sql: string, callee?: Model, options?: QueryOptions): EventEmitterT>;
+
+ /**
+ * Create a new database schema.
+ *
+ * @param schema Name of the schema.
+ */
+ createSchema(schema: string): EventEmitter;
+
+ /**
+ * Show all defined schemas.
+ */
+ showAllSchemas(): EventEmitter;
+
+ /**
+ * Drop a single schema.
+ *
+ * @param schema Name of the schema.
+ */
+ dropSchema(schema: string): EventEmitter;
+
+ /**
+ * Drop all schemas.
+ */
+ dropAllSchemas(): EventEmitter;
+
+ /**
+ * Sync all defined DAOs to the DB.
+ *
+ * @param options Options.
+ */
+ sync(options?: SyncOptions): EventEmitter;
+
+ /**
+ * Drop all tables defined through this sequelize instance. This is done by calling Model.drop on each model.
+ *
+ * @param options The options passed to each call to Model.drop.
+ */
+ drop(options: DropOptions): EventEmitter;
+
+ /**
+ * Test the connection by trying to authenticate. Alias for 'validate'.
+ */
+ authenticate(): EventEmitter;
+
+ /**
+ * Alias for authenticate(). Test the connection by trying to authenticate. Alias for 'validate'.
+ */
+ validate(): EventEmitter;
+
+ /**
+ * !! DEPRECATED : When passing a callback to a transaction a promise chain is expected in return,
+ * the transaction will be committed or rejected based on the promise chain returned to the callback.
+ *
+ * Start a transaction. When using transactions, you should pass the transaction in the options argument in order
+ * for the query to happen under that transaction.
+ *
+ * @param callback Called when the transaction has been set up and is ready for use. Callback takes transaction
+ * argument (overload available for error and transaction arguments too).
+ */
+ transaction(callback: (transaction: Transaction) => boolean): Promise;
+
+ /**
+ * Start a transaction. When using transactions, you should pass the transaction in the options argument in order
+ * for the query to happen under that transaction.
+ *
+ * @param options Transaction options.
+ * @param callback Called when the transaction has been set up and is ready for use. Callback takes transaction
+ * argument (overload available for error and transaction arguments too).
+ */
+ transaction(options?: TransactionOptions, callback?: (transaction: Transaction) => void): PromiseT;
+
+ close(): void;
+ }
+
+ interface Config {
+ database?: string;
+ username?: string;
+ password?: string;
+ host?: string;
+ port?: number;
+ pool?: PoolOptions;
+ protocol?: string;
+ queue?: boolean;
+ native?: boolean;
+ ssl?: boolean;
+ replication?: ReplicationOptions;
+ dialectModulePath?: string;
+ maxConcurrentQueries?: number;
+ dialectOptions?: any;
+ }
+
+ interface Model extends Hooks, Associations {
+ /**
+ * A reference to the sequelize instance.
+ */
+ sequelize: Sequelize;
+
+ /**
+ * The name of the model, typically singular.
+ */
+ name: string;
+
+ /**
+ * The name of the underlying database table, typically plural.
+ */
+ tableName: string;
+
+ options: DefineOptions;
+ attributes: any;
+ rawAttributes: any;
+ modelManager: ModelManager;
+ daoFactoryManager: ModelManager;
+ associations: any;
+ scopeObj: any;
+
+ /**
+ * Sync this Model to the DB, that is create the table. Upon success, the callback will be called with the model
+ * instance (this).
+ */
+ sync(options?: SyncOptions): PromiseT>;
+
+ /**
+ * Drop the table represented by this Model.
+ *
+ * @param options
+ */
+ drop(options?: DropOptions): Promise;
+
+ /**
+ * Apply a schema to this model. For postgres, this will actually place the schema in front of the table name -
+ * "schema"."tableName", while the schema will be prepended to the table name for mysql and sqlite -
+ * 'schema.tablename'.
+ *
+ * @param schema The name of the schema.
+ * @param options Schema options.
+ */
+ schema(schema: string, options?: SchemaOptions): Model;
+
+ /**
+ * Get the tablename of the model, taking schema into account. The method will return The name as a string if the
+ * model has no schema, or an object with tableName, schema and delimiter properties.
+ */
+ getTableName(): any;
+
+ /**
+ * Apply a scope created in define to the model.
+ *
+ * @param options The scope(s) to apply. Scopes can either be passed as consecutive arguments, or as an array of
+ * arguments. To apply simple scopes, pass them as strings. For scope function, pass an object,
+ * with a method property. The value can either be a string, if the method does not take any
+ * arguments, or an array, where the first element is the name of the method, and consecutive
+ * elements are arguments to that method. Pass null to remove all scopes, including the default.
+ */
+ scope(options: any): Model;
+
+ /**
+ * Search for multiple instances..
+ *
+ * @param options A hash of options to describe the scope of the search.
+ * @param queryOptions Set the query options, e.g. raw, specifying that you want raw data instead of built
+ * Instances. See sequelize.query for options.
+ */
+ findAll(options?: FindOptions, queryOptions?: QueryOptions): PromiseT>;
+
+ /**
+ * Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single instance.
+ *
+ * @param options A hash of options to describe the scope of the search.
+ * @param queryOptions Set the query options, e.g. raw, specifying that you want raw data instead of built
+ * Instances. See sequelize.query for options
+ */
+ find(options?: FindOptions, queryOptions?: QueryOptions): PromiseT;
+
+ /**
+ * Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single instance.
+ *
+ * @param options A number to search by id.
+ * @param queryOptions Set the query options, e.g. raw, specifying that you want raw data instead of built
+ * Instances. See sequelize.query for options
+ */
+ find(id?: number, queryOptions?: QueryOptions): PromiseT;
+
+ /**
+ * Run an aggregation method on the specified field.
+ *
+ * @param field The field to aggregate over. Can be a field name or *.
+ * @param aggregateFunction The function to use for aggregation, e.g. sum, max etc.
+ * @param options Query options, particularly options.dataType.
+ */
+ aggregate(field: string, aggregateFunction: string, options: FindOptions): PromiseT;
+
+ /**
+ * Count the number of records matching the provided where clause.
+ *
+ * @param options Conditions and options for the query.
+ */
+ count(options?: FindOptions): PromiseT;
+
+ /**
+ * Find all the rows matching your query, within a specified offset / limit, and get the total number of rows
+ * matching your query. This is very usefull for paging.
+ *
+ * @param findOptions Filtering options
+ * @param queryOptions Query options
+ */
+ findAndCountAll(findOptions?: FindOptions, queryOptions?: QueryOptions): PromiseT>;
+
+ /**
+ * Find the maximum value of field.
+ *
+ * @param field
+ * @param options
+ */
+ max(field: string, options?: FindOptions): PromiseT;
+
+ /**
+ * Find the minimum value of field.
+ *
+ * @param field
+ * @param options
+ */
+ min(field: string, options?: FindOptions): PromiseT;
+
+ /**
+ * Find the sum of field.
+ *
+ * @param field
+ * @param options
+ */
+ sum(field: string, options?: FindOptions): PromiseT;
+
+ /**
+ * Builds a new model instance. Values is an object of key value pairs, must be defined but can be empty.
+ *
+ * @param values any from which to build entity instance.
+ * @param options any construction options.
+ */
+ build(values: TPojo, options?: BuildOptions): TInstance;
+
+ /**
+ * Builds a new model instance and calls save on it..
+ *
+ * @param values
+ * @param options
+ */
+ create(values: TPojo, options?: CopyOptions): PromiseT;
+
+ /**
+ * Find a row that matches the query, or build (but don't save) the row if none is found. The successfull result
+ * of the promise will be (instance, initialized) - Make sure to use .spread().
+ *
+ * @param where A hash of search attributes. Note that this method differs from finders, in that the syntax
+ * is { attr1: 42 } and NOT { where: { attr1: 42}}. This may be subject to change in 2.0
+ * @param defaults Default values to use if building a new instance
+ * @param options Options passed to the find call
+ */
+ findOrInitialize(where: any, defaults?: TPojo, options?: QueryOptions): PromiseT;
+
+ /**
+ * Find a row that matches the query, or build and save the row if none is found The successfull result of the
+ * promise will be (instance, created) - Make sure to use .spread().
+ *
+ * @param where A hash of search attributes. Note that this method differs from finders, in that the syntax is
+ * { attr1: 42 } and NOT { where: { attr1: 42}}. This is subject to change in 2.0
+ * @param defaults Default values to use if creating a new instance
+ * @param options Options passed to the find and create calls.
+ */
+ findOrCreate(where: any, defaults?: TPojo, options?: FindOrCreateOptions): PromiseT;
+
+ /**
+ * Create and insert multiple instances in bulk.
+ *
+ * @param records List of objects (key/value pairs) to create instances from.
+ * @param options
+ */
+ bulkCreate(records: Array, options?: BulkCreateOptions): PromiseT>;
+
+ /**
+ * Delete multiple instances.
+ */
+ destroy(where?: any, options?: DestroyOptions): Promise;
+
+ /**
+ * Update multiple instances that match the where options.
+ *
+ * @param attrValueHash A hash of fields to change and their new values
+ * @param where Options to describe the scope of the search. Note that these options are not wrapped in a
+ * { where: ... } is in find / findAll calls etc. This is probably due to change in 2.0.
+ */
+ update(attrValueHash: TPojo, where: any, options?: UpdateOptions): Promise;
+
+ /**
+ * Run a describe query on the table. The result will be return to the listener as a hash of attributes and their
+ * types.
+ */
+ describe(): PromiseT;
+
+ /**
+ * A proxy to the node-sql query builder, which allows you to build your query through a chain of method calls.
+ * The returned instance already has all the fields property populated with the field of the model.
+ */
+ dataset(): any;
+ }
+
+ interface Instance {
+ /**
+ * Returns true if this instance has not yet been persisted to the database.
+ */
+ isNewRecord: boolean;
+
+ /**
+ * Returns the Model the instance was created from.
+ */
+ Model: Model;
+
+ /**
+ * A reference to the sequelize instance.
+ */
+ sequelize: Sequelize;
+
+ /**
+ * If timestamps and paranoid are enabled, returns whether the deletedAt timestamp of this instance is set.
+ * Otherwise, always returns false.
+ */
+ isDeleted: boolean;
+
+ /**
+ * Get the values of this Instance. Proxies to this.get.
+ */
+ values: TPojo;
+
+ /**
+ * A getter for this.changed(). Returns true if any keys have changed.
+ */
+ isDirty: boolean;
+
+ /**
+ * Get the values of the primary keys of this instance.
+ */
+ primaryKeyValues: TPojo;
+
+ /**
+ * Get the value of the underlying data value.
+ *
+ * @param key Field to retrieve.
+ */
+ getDataValue(key: string): any;
+
+ /**
+ * Update the underlying data value.
+ *
+ * @param key Field to set.
+ * @param value Value to set.
+ */
+ setDataValue(key: string, value: any): void;
+
+ /**
+ * Retrieves the value for the key when specified. If no key is given, returns all values of the instance, also
+ * invoking virtual getters.
+ */
+ get(key?: string): any;
+
+ /**
+ * Set is used to update values on the instance (the sequelize representation of the instance that is, remember
+ * that nothing will be persisted before you actually call save).
+ */
+ set(key: string, value: any, options?: SetOptions): void;
+
+ /**
+ * If changed is called with a string it will return a boolean indicating whether the value of that key in
+ * dataValues is different from the value in _previousDataValues. If changed is called without an argument, it will
+ * return an array of keys that have changed.
+ */
+ changed(key: string): any;
+
+ /**
+ * If changed is called with a string it will return a boolean indicating whether the value of that key in
+ * dataValues is different from the value in _previousDataValues. If changed is called without an argument, it will
+ * return an array of keys that have changed.
+ */
+ changed(): Array;
+
+ /**
+ * Returns the previous value for key from _previousDataValues.
+ */
+ previous(key: string): any;
+
+ /**
+ * Validate this instance, and if the validation passes, persist it to the database.
+ */
+ save(fields?: Array, options?: SaveOptions): PromiseT;
+
+ /**
+ * Refresh the current instance in-place, i.e. update the object with current data from the DB and return the same
+ * object. This is different from doing a find(Instance.id), because that would create and return a new instance.
+ * With this method, all references to the Instance are updated with the new data and no new objects are created.
+ */
+ reload(options?: FindOptions): PromiseT;
+
+ /**
+ * Validate the attribute of this instance according to validation rules set in the model definition.
+ */
+ validate(options?: ValidateOptions): PromiseT;
+
+ /**
+ * This is the same as calling setAttributes, then calling save.
+ */
+ updateAttributes(updates: TPojo, options: SaveOptions): PromiseT;
+
+ /**
+ * Destroy the row corresponding to this instance. Depending on your setting for paranoid, the row will either be
+ * completely deleted, or have its deletedAt timestamp set to the current time.
+ *
+ * @param options Allows caller to specify if delete should be forced.
+ */
+ destroy(options?: DestroyInstanceOptions): Promise;
+
+ /**
+ * Increment the value of one or more columns. This is done in the database, which means it does not use the
+ * values currently stored on the Instance.
+ *
+ * @param fields If a string is provided, that column is incremented by the value of by given in options. If an
+ * array is provided, the same is true for each column. If and object is provided, each column is
+ * incremented by the value given.
+ * @param options Increment options.
+ */
+ increment(fields: any, options?: IncrementOptions): Promise;
+
+ /**
+ * Decrement the value of one or more columns. This is done in the database, which means it does not use the
+ * values currently stored on the Instance.
+ *
+ * @param fields If a string is provided, that column is decremented by the value of by given in options. If an
+ * array is provided, the same is true for each column. If and object is provided, each column is
+ * decremented by the value given.
+ * @param options Decrement options.
+ */
+ decrement(fields: any, options?: IncrementOptions): Promise;
+
+ /**
+ * Check whether all values of this and other Instance are the same.
+ */
+ equal(other: TInstance): boolean;
+
+ /**
+ * Check if this is eqaul to one of others by calling equals.
+ *
+ * @param others Other instances to compare to.
+ */
+ equalsOneOf(others: Array): boolean;
+
+ /**
+ * Convert the instance to a JSON representation. Proxies to calling get with no keys. This means get all values
+ * gotten from the DB, and apply all custom getters.
+ */
+ toJSON(): TPojo;
+ }
+
+ interface Transaction extends TransactionStatic {
+ /**
+ * Commit the transaction.
+ */
+ commit(): Transaction;
+
+ /**
+ * Rollback (abort) the transaction.
+ */
+ rollback(): Transaction;
+ }
+
+ interface TransactionStatic {
+ /**
+ * The possible isolation levels to use when starting a transaction
+ */
+ ISOLATION_LEVELS: TransactionIsolationLevels;
+
+ /**
+ * Possible options for row locking. Used in conjuction with find calls.
+ */
+ LOCK: TransactionLocks;
+ }
+
+ interface TransactionIsolationLevels {
+ READ_UNCOMMITTED: string;// "READ UNCOMMITTED"
+ READ_COMMITTED: string; // "READ COMMITTED"
+ REPEATABLE_READ: string; // "REPEATABLE READ"
+ SERIALIZABLE: string; // "SERIALIZABLE"
+ }
+
+ interface TransactionLocks {
+ UPDATE: string; // UPDATE
+ SHARE: string; // SHARE
+ }
+
+ interface Hooks {
+
+ /**
+ * Add a named hook to the model.
+ *
+ * @param hooktype
+ */
+ addHook(hooktype: string, name: string, fn: (...args: Array) => void): boolean;
+
+ /**
+ * Add a hook to the model.
+ *
+ * @param hooktype
+ */
+ addHook(hooktype: string, fn: (...args: Array) => void): boolean;
+
+ /**
+ * A named hook that is run before validation.
+ */
+ beforeValidate(name: string, validator: (dao: T, callback: (err?: Error) => void) => void): void;
+
+ /**
+ * A hook that is run before validation.
+ */
+ beforeValidate(validator: (dao: T, callback: (err?: Error) => void) => void): void;
+
+ /**
+ * A named hook that is run before validation.
+ */
+ afterValidate(name: string, validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run before validation.
+ */
+ afterValidate(validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run before creating a single instance.
+ */
+ beforeCreate(name: string, validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run before creating a single instance.
+ */
+ beforeCreate(validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run after creating a single instance.
+ */
+ afterCreate(name: string, validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run after creating a single instance.
+ */
+ afterCreate(validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run before destroying a single instance.
+ */
+ beforeDestroy(name: string, validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run before destroying a single instance.
+ */
+ beforeDestroy(validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run after destroying a single instance.
+ */
+ afterDestroy(name: string, validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run after destroying a single instance.
+ */
+ afterDestroy(validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run before updating a single instance.
+ */
+ beforeUpdate(name: string, validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run before updating a single instance.
+ */
+ beforeUpdate(validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run after updating a single instance.
+ */
+ afterUpdate(name: string, validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run after updating a single instance.
+ */
+ afterUpdate(validator: (dao: T, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run before creating instances in bulk.
+ */
+ beforeBulkCreate(name: string, validator: (daos: Array, fields: Array, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run before creating instances in bulk.
+ */
+ beforeBulkCreate(validator: (daos: Array, fields: Array, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run after creating instances in bulk.
+ */
+ afterBulkCreate(name: string, validator: (daos: Array, fields: Array, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A hook that is run after creating instances in bulk.
+ */
+ afterBulkCreate(validator: (daos: Array, fields: Array, callback: (err?: Error, dao?: T) => void) => void): void;
+
+ /**
+ * A named hook that is run before destroying instances in bulk.
+ */
+ beforeBulkDestroy(name: string, validator: (where: any, callback: (err?: Error, where?: any) => void) => void): void;
+
+ /**
+ * A hook that is run before destroying instances in bulk.
+ */
+ beforeBulkDestroy(validator: (where: any, callback: (err?: Error, where?: any) => void) => void): void;
+
+ /**
+ * A named hook that is run after destroying instances in bulk.
+ */
+ afterBulkDestroy(name: string, validator: (where: any, callback: (err?: Error, where?: any) => void) => void): void;
+
+ /**
+ * A hook that is run after destroying instances in bulk.
+ */
+ afterBulkDestroy(validator: (where: any, callback: (err?: Error, where?: any) => void) => void): void;
+
+ /**
+ * A named hook that is run before updating instances in bulk.
+ */
+ beforeBulkUpdate(name: string, validator: (instances: Array, where: any, callback: (err?: Error, instances?: Array, where?: any) => void) => void): void;
+
+ /**
+ * A hook that is run before updating instances in bulk.
+ */
+ beforeBulkUpdate(validator: (instances: Array, where: any, callback: (err?: Error, instances?: Array, where?: any) => void) => void): void;
+
+ /**
+ * A named hook that is run after updating instances in bulk.
+ */
+ afterBulkUpdate(name: string, validator: (instances: Array, where: any, callback: (err?: Error, instances?: Array, where?: any) => void) => void): void;
+
+ /**
+ * A hook that is run after updating instances in bulk.
+ */
+ afterBulkUpdate(validator: (instances: Array, where: any, callback: (err?: Error, instances?: Array, where?: any) => void) => void): void;
+ }
+
+ interface Associations {
+ /**
+ * Creates an association between this (the source) and the provided target. The foreign key is added on the target.
+ *
+ * @param target
+ * @param options
+ */
+ hasOne(target: Model, options?: AssociationOptions): void;
+
+ /**
+ * Creates an association between this (the source) and the provided target. The foreign key is added on the source.
+ *
+ * @param target
+ * @param options
+ */
+ belongsTo(target: Model, options?: AssociationOptions): void;
+
+ /**
+ * Create an association that is either 1:m or n:m.
+ *
+ * @param target
+ * @param options
+ */
+ hasMany