From 8c524c4d844151319b81beece0f96bade19d55c0 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Mon, 23 Mar 2015 17:11:48 +0900 Subject: [PATCH 01/38] add `jsonpath` type definition file --- jsonpath/jsonpath-tests.ts | 55 ++++++++++++++++++++++++++++++++++++++ jsonpath/jsonpath.d.ts | 21 +++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 jsonpath/jsonpath-tests.ts create mode 100644 jsonpath/jsonpath.d.ts diff --git a/jsonpath/jsonpath-tests.ts b/jsonpath/jsonpath-tests.ts new file mode 100644 index 000000000..d7fd50868 --- /dev/null +++ b/jsonpath/jsonpath-tests.ts @@ -0,0 +1,55 @@ +/// + +import jp = require('jsonpath'); + +var data: any; + +/** + * jp.query(obj, pathExpression) + * Find elements in obj matching pathExpression. Returns an array of elements that satisfy the provided JSONPath expression, or an empty array if none were matched. + */ +var authors = jp.query(data, '$..author'); + +/** + * jp.paths(obj, pathExpression) + * Find elements in obj matching pathExpression. Returns an array of element paths that satisfy the provided JSONPath expression. Each path is itself an array of keys representing the location within obj of the matching element. + */ +var paths = jp.paths(data, '$..author'); + +/** + * jp.nodes(obj, pathExpression) + * Find elements and their corresponding paths in obj matching pathExpression. Returns an array of node objects where each node has a path containing an array of keys representing the location within obj, and a value pointing to the matched element. + */ +var nodes = jp.nodes(data, '$..author'); + +/** + * jp.value(obj, pathExpression, [newValue]) + * Returns the value of the first element matching pathExpression. If newValue is provided, sets the value of the first matching element and returns the new value. + */ +var value = jp.value(data, '$.store..price'); +jp.value(data, '$.store..price', 12.5); + +/** + * jp.parent(obj, pathExpression) + * Returns the parent of the first matching element. + */ +var parent = jp.parent(data, '$.store..price'); + +/** + * jp.apply(obj, pathExpression, fn) + * Runs the supplied function fn on each matching element, and replaces each matching element with the return value from the function. The function accepts the value of the matching element as its only parameter. Returns matching nodes with their updated values. + */ +var nodes = jp.apply(data, '$..author', (value: string) => { return value.toUpperCase() }); + +/** + * jp.parse(pathExpression) + * Parse the provided JSONPath expression into path components and their associated operations. + */ +var path = jp.parse('$..author'); + +/** + * jp.stringify(path) + * Returns a path expression in string form, given a path. The supplied path may either be a flat array of keys, as returned by jp.nodes for example, or may alternatively be a fully parsed path expression in the form of an array of path components as returned by jp.parse. + */ +var pathExpression = jp.stringify(['$', 'store', 'book', 0, 'author']); + diff --git a/jsonpath/jsonpath.d.ts b/jsonpath/jsonpath.d.ts new file mode 100644 index 000000000..a976ecd5c --- /dev/null +++ b/jsonpath/jsonpath.d.ts @@ -0,0 +1,21 @@ +// Type definitions for jsonpath 0.1.3 +// Project: https://www.npmjs.org/package/jsonpath +// Definitions by: Hiroki Horiuchi +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "jsonpath" { + + type PathComponent = string|number; + + export function query(obj: any, pathExpression: string): any[]; + export function paths(obj: any, pathExpression: string): PathComponent[][]; + export function nodes(obj: any, pathExpression: string): { path: PathComponent[]; value: any; }[]; + export function value(obj: any, pathExpression: string): any; + export function value(obj: any, pathExpression: string, newValue: any): any; + export function parent(obj: any, pathExpression: string): any; + export function apply(obj: any, pathExpression: string, fn: (x: any) => any): { path: PathComponent[]; value: any; }[]; + export function parse(pathExpression: string): any[]; + export function stringify(path: PathComponent[]): string; + +} + From abdd933682ed9efc19b0b27fbe726f410e9083fa Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Mon, 23 Mar 2015 17:18:33 +0900 Subject: [PATCH 02/38] modify Auther header --- jsonpath/jsonpath.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsonpath/jsonpath.d.ts b/jsonpath/jsonpath.d.ts index a976ecd5c..db5322017 100644 --- a/jsonpath/jsonpath.d.ts +++ b/jsonpath/jsonpath.d.ts @@ -1,6 +1,6 @@ // Type definitions for jsonpath 0.1.3 // Project: https://www.npmjs.org/package/jsonpath -// Definitions by: Hiroki Horiuchi +// Definitions by: Hiroki Horiuchi // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module "jsonpath" { From 828ab6bf767edfc96b89059ecf24999c4556bc44 Mon Sep 17 00:00:00 2001 From: Will Johnston Date: Tue, 24 Mar 2015 21:19:33 -0500 Subject: [PATCH 03/38] adding typings for stripe-node --- stripe-node/stripe-node-tests.ts | 310 +++ stripe-node/stripe-node.d.ts | 3107 ++++++++++++++++++++++++++++++ 2 files changed, 3417 insertions(+) create mode 100644 stripe-node/stripe-node-tests.ts create mode 100644 stripe-node/stripe-node.d.ts diff --git a/stripe-node/stripe-node-tests.ts b/stripe-node/stripe-node-tests.ts new file mode 100644 index 000000000..48c675055 --- /dev/null +++ b/stripe-node/stripe-node-tests.ts @@ -0,0 +1,310 @@ +/// + +import Stripe = require('stripe'); + +var stripe = new Stripe("sk_test_BF573NobVn98OiIsPAv7A04K"); + +stripe.setApiVersion('2015-02-18'); +stripe.customers.list({ limit: 3 }, function (err, customers) { + // asynchronously called +}); + +stripe.charges.create({ + amount: 400, + currency: "usd", + source: "tok_15V2YhEe31JkLCeQy9iUgsJX", // obtained with Stripe.js + description: "Charge for test@example.com" +}, function (err, charge) { + // asynchronously called +}); + +stripe.charges.retrieve( + "ch_15fvyXEe31JkLCeQOo0SwFk9", + function (err, charge) { + // asynchronously called + } + ); + +stripe.charges.update( + "ch_15fvyXEe31JkLCeQOo0SwFk9", + { + description: "Charge for test@example.com" + }, + function (err, charge) { + // asynchronously called + } + ); + +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", function (err, charge) { + // asynchronously called +}); + +stripe.charges.list({ limit: 3 }, function (err, charges) { + // asynchronously called +}); + +stripe.charges.createRefund( + "ch_15fvyXEe31JkLCeQOo0SwFk9", + {}, + function (err, refund) { + // asynchronously called + } + ); + +stripe.charges.retrieveRefund( + "ch_15fvyXEe31JkLCeQOo0SwFk9", + "re_15jzA4Ee31JkLCeQcxbTbjaL", + function (err, refund) { + // asynchronously called + } + ); + +stripe.charges.updateRefund( + "ch_15fvyXEe31JkLCeQOo0SwFk9", + "re_15jzA4Ee31JkLCeQcxbTbjaL", + { metadata: { key: "value" } }, + function (err, refund) { + // asynchronously called + } + ); + +stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9', null, function (err, refunds) { + // asynchronously called +}); + +stripe.customers.create({ + description: 'Customer for test@example.com', + source: "tok_15V2YhEe31JkLCeQy9iUgsJX" // obtained with Stripe.js +}, function (err, customer) { + // asynchronously called + }); + +stripe.customers.retrieve( + "cus_5rfJKDJkuxzh5Q", + function (err, customer) { + // asynchronously called + } + ); + +stripe.customers.update("cus_5rfJKDJkuxzh5Q", { + description: "Customer for test@example.com" +}, function (err, customer) { + // asynchronously called + }); + +stripe.customers.del( + "cus_5rfJKDJkuxzh5Q", + function (err, confirmation) { + // asynchronously called + } + ); + +stripe.customers.list({ limit: 3 }, function (err, customers) { + // asynchronously called +}); + +stripe.customers.createCard( + "cus_5rfJKDJkuxzh5Q", + { card: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, + function (err, card) { + // asynchronously called + } + ); + +stripe.customers.retrieveCard( + "cus_5rfJKDJkuxzh5Q", + "card_15fvyXEe31JkLCeQ9KMktP5S", + function (err, card) { + // asynchronously called + } + ); + +stripe.customers.retrieveCard( + "cus_5rfJKDJkuxzh5Q", + "card_15fvyXEe31JkLCeQ9KMktP5S", + function (err, card) { + // asynchronously called + } + ); + +stripe.customers.updateCard( + "cus_5rfJKDJkuxzh5Q", + "card_15fvyXEe31JkLCeQ9KMktP5S", + { name: "Jane Austen" }, + function (err, card) { + // asynchronously called + } + ); + +stripe.customers.updateCard( + "cus_5rfJKDJkuxzh5Q", + "card_15fvyXEe31JkLCeQ9KMktP5S", + { name: "Jane Austen" }, + function (err, card) { + // asynchronously called + } + ); + +stripe.customers.deleteCard( + "cus_5rfJKDJkuxzh5Q", + "card_15fvyXEe31JkLCeQ9KMktP5S", + function (err, confirmation) { + // asynchronously called + } + ); + +stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc', null, function (err, cards) { + // asynchronously called +}); + +stripe.customers.retrieveSubscription( + "cus_5rfJKDJkuxzh5Q", + "sub_5rfJxnBLGSwsYp", + function (err, subscription) { + // asynchronously called + } + ); + +stripe.customers.updateSubscription( + "cus_5rfJKDJkuxzh5Q", + "sub_5rfJxnBLGSwsYp", + { plan: "platypi-dev" }, + function (err, subscription) { + // asynchronously called + } + ); + +stripe.customers.cancelSubscription( + "cus_5rfJKDJkuxzh5Q", + "sub_5rfJxnBLGSwsYp", + null, + function (err, confirmation) { + // asynchronously called + } + ); + +stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc', null, function (err, subscriptions) { + // asynchronously called +}); + +stripe.plans.create({ + amount: 2000, + interval: "month", + name: "Amazing Gold Plan", + currency: "usd", + id: "gold" +}, function (err, plan) { + // asynchronously called + }); + +stripe.plans.retrieve( + "platypi-dev", + function (err, plan) { + // asynchronously called + } + ); + +stripe.plans.update("platypi-dev", { + name: "New plan name" +}, function (err, plan) { + // asynchronously called + }); + +stripe.plans.del( + "platypi-dev", + function (err, confirmation) { + // asynchronously called + } + ); + +stripe.plans.list(null, function (err, plans) { + // asynchronously called +}); + +stripe.coupons.create({ + percent_off: 25, + duration: 'repeating', + duration_in_months: 3, + id: '25OFF' +}, function (err, coupon) { + // asynchronously called + }); + +stripe.coupons.retrieve( + "25OFF", + function (err, coupon) { + // asynchronously called + } + ); + +stripe.coupons.update("25OFF", { + metadata: { key: "value" } +}, function (err, coupon) { + // asynchronously called + }); + +stripe.coupons.del("25OFF", function (err, confirmation) { + +}); + +stripe.coupons.list({ limit: 3 }, function (err, coupons) { + // asynchronously called +}); + +stripe.customers.deleteDiscount("cus_5rfJKDJkuxzh5Q", function (err, confirmation) { + // asynchronously called +}); + +stripe.customers.deleteSubscriptionDiscount("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", function (err, confirmation) { + // asynchronously called +}); + +stripe.invoices.create({ + customer: "cus_5rfJKDJkuxzh5Q" +}, function (err, invoice) { + // asynchronously called + }); + +stripe.invoices.retrieve( + "in_15fvyXEe31JkLCeQH7QbgZZb", + function (err, invoice) { + // asynchronously called + } + ); + +stripe.invoices.retrieveLines( + "in_15fvyXEe31JkLCeQH7QbgZZb", + { limit: 5 }, + function (err, lines) { + // asynchronously called + } + ); + +stripe.invoices.retrieveUpcoming( + "cus_5rfJKDJkuxzh5Q", + null, + function (err, upcoming) { + // asynchronously called + } + ); + +stripe.invoices.update( + "in_15fvyXEe31JkLCeQH7QbgZZb", + { + closed: true + }, + function (err, invoice) { + // asynchronously called + } + ); + +stripe.invoices.pay("in_15fvyXEe31JkLCeQH7QbgZZb", function (err, invoice) { + // asynchronously called +}); + +stripe.invoices.list( + { customer: "cus_5rfJKDJkuxzh5Q", limit: 3 }, + function (err, invoices) { + // asynchronously called + } + ); diff --git a/stripe-node/stripe-node.d.ts b/stripe-node/stripe-node.d.ts new file mode 100644 index 000000000..8d9bd05c8 --- /dev/null +++ b/stripe-node/stripe-node.d.ts @@ -0,0 +1,3107 @@ +// Type definitions for stripe-node +// Project: https://github.com/stripe/stripe-node/ +// Definitions by: William Johnston +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'stripe' { + var out: typeof Stripe.Stripe; + export = out; +} + +declare module Stripe { + class Stripe { + static DEFAULT_HOST: string; + static DEFAULT_PORT: string; + static DEFAULT_BASE_PATH: string; + static DEFAULT_API_VERSION: string; + static DEFAULT_TIMEOUT: number; + static PACKAGE_VERSION: string; + static USER_AGENT: { + bindings_version: string; + lang: string; + lang_version: string; + platform: string; + publisher: string; + uname: string; + }; + static USER_AGENT_SERIALIZED: string; + + static resources: typeof resources; + static StripeResource: typeof StripeResource; + + account: resources.Account; + balance: resources.Balance; + charges: resources.Charges; + coupons: resources.Coupons; + customers: resources.Customers; + events: resources.Events; + invoices: resources.Invoices; + invoiceItems: resources.InvoiceItems; + plans: resources.Plans; + recipientCards: resources.RecipientCards; + recipients: resources.Recipients; + tokens: resources.Tokens; + yransfers: resources.Transfers; + applicationFees: resources.ApplicationFees; + fileUploads: resources.FileUploads; + bitcoinReceivers: resources.BitcoinReceivers; + customerCards: resources.CustomerCards; + customerSubscriptions: resources.CustomerSubscriptions; + chargeRefunds: resources.ChargeRefunds; + applicationFeeRefunds: resources.ApplicationFeeRefunds; + transferReversals: resources.TransferReversals; + + constructor(apiKey: string, version?: string); + + setHost(host: string): void; + setHost(host: string, port: string|number): void; + setHost(host: string, port: string|number, protocol: string): void; + + setProtocol(protocol: string): void; + setPort(port: string|number): void; + setApiVersion(version?: string): void; + setApiKey(key?: string): void; + setTimeout(timeout?: number): void; + setHttpAgent(agent: string): void; + getConstant(c: string): any; + getClientUserAgent(response: (userAgent: string) => void): void; + } + + module account { } + + module balance { + interface IBalanceTransaction { + id: string; + + /** + * Value is 'balance_transaction' + */ + object: string; + + /** + * Gross amount of the transaction, in cents. + */ + amount: number; + + /** + * The date the transaction’s net funds will become available in the Stripe balance. + */ + available_on: number; + created: number; + + /** + * Three-letter ISO currency code representing the currency. + */ + currency: string; + + /** + * Fee (in cents) paid for this transaction + */ + fee: number; + + /** + * Detailed breakdown of fees (in cents) paid for this transaction + */ + fee_details: Array<{ + amount: number; + + /** + * Three-letter ISO currency code representing the currency of the amount that was disputed. + */ + currency: string; + + /** + * Type of the fee, one of: application_fee, stripe_fee or tax. + */ + type: string; + application: string; + description: string; + }>; + + /** + * Net amount of the transaction, in cents. + */ + net: number; + + /** + * If the transaction’s net funds are available in the Stripe balance yet. Either available or pending. + */ + status: string; + + /** + * Type of the transaction, one of: charge, refund, adjustment, application_fee, + * application_fee_refund, transfer, transfer_cancel or transfer_failure. + */ + type: string; + description?: string; + + /** + * The Stripe object this transaction is related to. + */ + source?: IPaymentToken | ICard; + source_transfers: IList; + } + } + + module charges { + + /** + * To charge a credit or a debit card, you create a charge object. You can retrieve and refund individual + * charges as well as list all charges. Charges are identified by a unique random ID. + */ + interface ICharge { + id: string; + + /** + * Value is 'charge' + */ + object: string; + + livemode: boolean; + + /** + * Amount charged in cents, positive integer or zero. + */ + amount: number; + + /** + * If the charge was created without capturing, this boolean represents whether or not it is + * still uncaptured or has since been captured. + */ + captured: boolean; + + created: number; + + /** + * Three-letter ISO currency code representing the currency in which the charge was made. + */ + currency: string; + + paid: boolean; + + /** + * Whether or not the charge has been fully refunded. If the charge is only partially refunded, + * this attribute will still be false. + */ + refunded: boolean; + + /** + * A list of refunds that have been applied to the charge. + */ + refunds: IList; + + /** + * For most Stripe users, the source of every charge is a credit or debit card. + * This hash is then the card object describing that card. + */ + source: ICard; + + /** + * The status of the payment is either succeeded or failed. + */ + status: string; + + /** + * Amount in cents refunded (can be less than the amount attribute on the charge if a partial refund was issued). + */ + amount_refunded: number; + + /** + * ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes). + */ + balance_transaction: string; + + /** + * ID of the customer this charge is for if one exists. + */ + customer: string; + description?: string; + + /** + * Details about the dispute if the charge has been disputed. + */ + dispute?: IDispute; + + /** + * Error code explaining reason for charge failure if available (see the errors section for a list of + * codes: https://stripe.com/docs/api#errors). + */ + failure_code: string; + + /** + * Message to user further explaining reason for charge failure if available. + */ + failure_message: string; + + /** + * ID of the invoice this charge is for if one exists. + */ + invoice: string; + metadata: IMetadata; + + /** + * This is the email address that the receipt for this charge was sent to. + */ + receipt_email: string; + + /** + * This is the transaction number that appears on email receipts sent for this charge. + */ + receipt_number: string; + application_fee?: string; + + /** + * Hash with information on fraud assessments for the charge. + */ + fraud_details: { + /** + * Assessments reported by you have the key user_report and, if set, possible values of safe and fraudulent. + */ + user_report?: string; + + /** + * Assessments from Stripe have the key stripe_report and, if set, the value fraudulent. + */ + stripe_report?: string; + }; + + /** + * Shipping information for the charge. + */ + shipping?: IShippingInformation; + } + } + + module coupons { + /** + * A discount represents the actual application of a coupon to a particular customer. It contains information + * about when the discount began and when it will end. + */ + interface IDiscount { + /** + * Value is 'discount' + */ + object: string; + + /** + * Hash describing the coupon applied to create this discount + */ + coupon: ICoupon; + customer: string; + + /** + * Date that the coupon was applied + */ + start: number; + + /** + * If the coupon has a duration of once or repeating, the date that this discount will end. If the coupon + * used has a forever duration, this attribute will be null. + */ + end: number; + + /** + * The subscription that this coupon is applied to, if it is applied to a particular subscription + */ + subscription: string; + } + + /** + * A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer. + * Coupons only apply to invoices; they do not apply to one-off charges. + */ + interface ICoupon { + id: string; + + /** + * Value is 'coupon' + */ + object: string; + livemode: boolean; + created: number; + + /** + * One of forever, once, and repeating. Describes how long a customer who applies this coupon will get the discount. + */ + duration: string; + + /** + * Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer. + */ + amount_off: number; + + /** + * If amount_off has been set, the currency of the amount to take off. + */ + currency: string; + + /** + * If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once. + */ + duration_in_months: number; + + /** + * Maximum number of times this coupon can be redeemed, in total, before it is no longer valid. + */ + max_redemptions: number; + + /** + * A set of key/value pairs that you can attach to a coupon object. It can be useful for storing + * additional information about the coupon in a structured format. + */ + metadata: IMetadata; + + /** + * Percent that will be taken off the subtotal of any invoices for this customer for the duration + * of the coupon. For example, a coupon with percent_off of 50 will make a $100 invoice $50 instead. + */ + percent_off: number; + + /** + * Date after which the coupon can no longer be redeemed + */ + redeem_by: number; + + /** + * Number of times this coupon has been applied to a customer. + */ + times_redeemed: number; + + /** + * Taking account of the above properties, whether this coupon can still be applied to a customer + */ + valid: boolean; + } + } + module customers { + /** + * Customer objects allow you to perform recurring charges and track multiple charges that are associated + * with the same customer. The API allows you to create, delete, and update your customers. You can + * retrieve individual customers as well as a list of all your customers. + */ + interface ICustomer { + id: string; + + /** + * Value is 'customer' + */ + object: string; + livemode: boolean; + created: number; + + /** + * Current balance, if any, being stored on the customer’s account. If negative, the customer has credit to apply to + * the next invoice. If positive, the customer has an amount owed that will be added to the next invoice. The balance + * does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied + * to any invoice. This balance is only taken into account for recurring charges. + */ + account_balance?: number; + + /** + * The currency the customer can be charged in for recurring billing purposes (subscriptions, invoices, invoice items). + */ + currency: string; + + /** + * ID of the default source attached to this customer. + */ + default_source: string; + + /** + * Whether or not the latest charge for the customer’s latest invoice has failed + */ + delinquent: boolean; + + /** + * Describes the current discount active on the customer, if there is one. + */ + discount: coupons.IDiscount; + description?: string; + email?: string; + + /** + * A set of key/value pairs that you can attach to a customer object. It can be useful for storing + * additional information about the customer in a structured format. + */ + metadata?: IMetadata; + + sources?: IList; + + /** + * The customer’s current subscriptions, if any + */ + subscriptions: IList; + } + } + module events { } + module invoices { + /** + * Invoices are statements of what a customer owes for a particular billing period, including subscriptions, + * invoice items, and any automatic proration adjustments if necessary. Once an invoice is created, payment + * is automatically attempted. Note that the payment, while automatic, does not happen exactly at the time of + * invoice creation. If you have configured webhooks, the invoice will wait until one hour after the last + * webhook is successfully sent (or the last webhook times out after failing). Any customer credit on the + * account is applied before determining how much is due for that invoice (the amount that will be actually + * charged). If the amount due for the invoice is less than 50 cents (the minimum for a charge), we add the + * amount to the customer's running account balance to be added to the next invoice. If this amount is + * negative, it will act as a credit to offset the next invoice. Note that the customer account balance does + * not include unpaid invoices; it only includes balances that need to be taken into account when calculating + * the amount due for the next invoice. + */ + interface IInvoice { + id: string; + + /** + * Value is 'invoice' + */ + object: string; + livemode: boolean; + + /** + * Final amount due at this time for this invoice. If the invoice’s total is smaller than the minimum charge + * amount, for example, or if there is account credit that can be applied to the invoice, the amount_due may + * be 0. If there is a positive starting_balance for the invoice (the customer owes money), the amount_due + * will also take that into account. The charge that gets generated for the invoice will be for the amount + * specified in amount_due. + */ + amount_due: number; + + /** + * Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any + * payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt + * count. In other words, manual payment attempts after the first attempt do not affect the retry schedule. + */ + attempt_count: number; + + /** + * Whether or not an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after + * the invoice.created webhook, for example, so you might not want to display that invoice as unpaid to your + * users. + */ + attempted: boolean; + + /** + * Whether or not the invoice is still trying to collect payment. An invoice is closed if it’s either paid or + * it has been marked closed. A closed invoice will no longer attempt to collect payment. + */ + closed: boolean; + currency: string; + customer: string; + date: number; + + /** + * Whether or not the invoice has been forgiven. Forgiving an invoice instructs us to update the subscription + * status as if the invoice were succcessfully paid. Once an invoice has been forgiven, it cannot be unforgiven + * or reopened + */ + forgiven: boolean; + + /** + * The individual line items that make up the invoice + */ + lines: IList; + + /** + * Whether or not payment was successfully collected for this invoice. An invoice can be paid (most commonly) + * with a charge or with credit from the customer’s account balance. + */ + paid: boolean; + + /** + * End of the usage period during which invoice items were added to this invoice + */ + period_end: number; + + /** + * Start of the usage period during which invoice items were added to this invoice + */ + period_start: number; + + /** + * Starting customer balance before attempting to pay invoice. If the invoice has not been attempted yet, + * this will be the current customer balance. + */ + starting_balance: number; + + /** + * Total of all subscriptions, invoice items, and prorations on the invoice before any discount is applied + */ + subtotal: number; + + /** + * Total after discount + */ + total: number; + + /** + * The fee in cents that will be applied to the invoice and transferred to the application owner’s + * Stripe account when the invoice is paid. + */ + application_fee: number; + + /** + * ID of the latest charge generated for this invoice, if any. + */ + charge: string; + description: string; + discount: coupons.IDiscount; + + /** + * Ending customer balance after attempting to pay invoice. If the invoice has not been attempted yet, + * this will be null. + */ + ending_balance: number; + + /** + * The time at which payment will next be attempted. + */ + next_payment_attempt: number; + + /** + * This is the transaction number that appears on email receipts sent for this invoice. + */ + receipt_number: string; + + /** + * Extra information about an invoice for the customer’s credit card statement. + */ + statement_descriptor: string; + + /** + * The subscription that this invoice was prepared for, if any. + */ + subscription: string; + + /** + * The time at which webhooks for this invoice were successfully delivered (if the invoice had no webhooks to + * deliver, this will match date). Invoice payment is delayed until webhooks are delivered, or until all webhook + * delivery attempts have been exhausted. + */ + webhooks_delivered_at: number; + + /** + * A set of key/value pairs that you can attach to an invoice object. It can be useful for storing additional + * information about the invoice in a structured format. + */ + metadata: IMetadata; + + /** + * The amount of tax included in the total, calculated from tax_percent and the subtotal. If no tax_percent + * is defined, this value will be null. + */ + tax: number; + + /** + * This percentage of the subtotal has been added to the total amount of the invoice, including invoice line + * items and discounts. This field is inherited from the subscription’s tax_percent field, but can be changed + * before the invoice is paid. This field defaults to null. + */ + tax_percent: number; + } + } + module invoiceItems { + interface InvoiceLineItem { + /** + * The ID of the source of this line item, either an invoice item or a subscription + */ + id: string; + + /** + * Value is 'line_item' + */ + object: string; + + /** + * Whether or not this is a test line item + */ + livemode: boolean; + + /** + * The amount, in cents + */ + amount: number; + currency: string; + + /** + * If true, discounts will apply to this line item. Always false for prorations. + */ + discountable: boolean; + + /** + * The period this line_item covers + */ + period: { + /** + * The period start date + */ + start: number; + /** + * The period end date + */ + end: number; + }; + + /** + * Whether or not this is a proration + */ + proration: boolean; + + /** + * A string identifying the type of the source of this line item, either an invoiceitem or a subscription + */ + type: string; + + /** + * A text description of the line item, if the line item is an invoice item + */ + description: string; + + /** + * Key-value pairs attached to the line item, if the line item is an invoice item + */ + metadata: IMetadata; + + /** + * The plan of the subscription, if the line item is a subscription or a proration + */ + plan: plans.IPlan; + + /** + * The quantity of the subscription, if the line item is a subscription or a proration + */ + quantity: number; + + /** + * When type is invoiceitem, the subscription that the invoice item pertains to, if any. Left blank when + * type is already subscription, as it’d be redundant with id. + */ + subscription: string; + } + } + module plans { + /** + * A subscription plan contains the pricing information for different products and feature levels on your site. + * For example, you might have a $10/month plan for basic features and a different $20/month plan for premium features. + */ + interface IPlan { + id: string; + + /** + * Value is 'plan' + */ + object: string; + livemode: boolean; + + /** + * The amount in cents to be charged on the interval specified + */ + amount: number; + created: number; + + /** + * Currency in which subscription will be charged + */ + currency: string; + + /** + * One of day, week, month or year. The frequency with which a subscription should be billed. + */ + interval: string; + + /** + * The number of intervals (specified in the interval property) between each subscription billing. For example, + * interval=month and interval_count=3 bills every 3 months. + */ + interval_count: number; + + /** + * Display name of the plan + */ + name: string; + + /** + * A set of key/value pairs that you can attach to a plan object. It can be useful for storing additional information + * about the plan in a structured format. + */ + metadata: IMetadata; + + /** + * Number of trial period days granted when subscribing a customer to this plan. Null if the plan has no trial period. + */ + trial_period_days: number; + + /** + * Extra information about a charge for the customer’s credit card statement. + */ + statement_descriptor: string; + } + } + module recipientCards { } + module recipients { } + module tokens { } + module transfers { + interface ITransfer { + id: string; + object: string; + livemode: boolean; + + /** + * Amount (in cents) to be transferred to your bank account + */ + amount: number; + + /** + * Time that this record of the transfer was first created. + */ + created: number; + + /** + * Three-letter ISO currency code representing the currency. + */ + currency: string; + + /** + * Date the transfer is scheduled to arrive in the bank. This doesn’t factor in delays like weekends or bank holidays. + */ + date: number; + + /** + * A list of reversals that have been applied to the transfer. + */ + reversals: IList; + + /** + * Whether or not the transfer has been fully reversed. If the transfer is only partially reversed, this attribute + * will still be false. + */ + reversed: boolean; + + /** + * Current status of the transfer (paid, pending, canceled or failed). A transfer will be pending until it is submitted, at which + * point it becomes paid. If it does not go through successfully, its status will change to failed or canceled. + */ + status: string; + + /** + * The type of this type of this transfer. Can be card or bank_account. + */ + type: string; + + /** + * Amount in cents reversed (can be less than the amount attribute on the transfer if a partial reversal was issued). + */ + amount_reversed: number; + + /** + * Balance transaction that describes the impact of this transfer on your account balance. + */ + balance_transaction: string; + + /** + * Internal-only description of the transfer + */ + description: string; + + /** + * Error code explaining reason for transfer failure if available. See Types of transfer failures for a + * list of failure codes: https://stripe.com/docs/api#transfer_failures + */ + failure_code: string; + + /** + * Message to user further explaining reason for transfer failure if available. + */ + failure_message: string; + metadata: IMetadata; + application_fee: string; + + /** + * Hash describing the bank account this transfer was sent to + */ + bank_account: IBankAccount; + + /** + * Hash describing the debit card this transfer was sent to + */ + card: ICard; + + /** + * ID of the recipient this transfer is for if one exists. Transfers to your bank account do not have a recipient. + */ + recipient: string; + source_transaction: string; + + /** + * Extra information about a transfer to be displayed on the user’s bank statement. + */ + statement_descriptor: string; + } + } + module applicationFees { } + module fileUploads { } + module bitcoinReceivers { + /** + * A Bitcoin receiver wraps a Bitcoin address so that a customer can push a payment to you. This guide describes how to use + * receivers to create Bitcoin payments. + */ + interface IBitcoinReceiver { + id: string; + + /** + * Value is 'bitcoin_receiver' + */ + object: string; + livemode: boolean; + + /** + * True when this bitcoin receiver has received a non-zero amount of bitcoin. + */ + active: boolean; + + /** + * The amount of currency that you are collecting as payment. + */ + amount: number; + + /** + * The amount of currency to which bitcoin_amount_received has been converted. + */ + amount_received: number; + + /** + * The amount of bitcoin that the customer should send to fill the receiver. The bitcoin_amount is denominated in Satoshi: + * there are 10^8 Satoshi in one bitcoin. + */ + bitcoin_amount: number; + + /** + * The amount of bitcoin that has been sent by the customer to this receiver. + */ + bitcoin_amount_received: number; + + /** + * This URI can be displayed to the customer as a clickable link (to activate their bitcoin client) or as a QR code (for mobile wallets). + */ + bitcoin_uri: number; + created: number; + + /** + * Three-letter ISO currency code representing the currency to which the bitcoin will be converted. + */ + currency: string; + + /** + * This flag is initially false and updates to true when the customer sends the bitcoin_amount to this receiver. + */ + filled: boolean; + + /** + * A bitcoin address that is specific to this receiver. The customer can send bitcoin to this address to fill the receiver. + */ + inbound_address: string; + + /** + * A list with one entry for each time that the customer sent bitcoin to the receiver. Hidden when viewing the + * receiver with a publishable key. + */ + transactions: IList; + + /** + * This receiver contains uncaptured funds that can be used for a payment or refunded. + */ + uncaptured_funds: boolean; + description: string; + + /** + * The customer’s email address, set by the API call that creates the receiver. + */ + email: string; + + /** + * A set of key/value pairs that you can attach to a customer object. It can be useful for storing additional information + * about the customer in a structured format. + */ + metadata: IMetadata; + + /** + * The ID of the payment created from the receiver, if any. Hidden when viewing the receiver with a publishable key. + */ + payment: string; + + /** + * The refund address for these bitcoin, if communicated by the customer. + */ + refund_address: string; + customer: string; + } + + interface IBitcoinTransaction { + id: string; + + /** + * Value is 'list' + */ + object: string; + + /** + * The amount of currency that the transaction was converted to in real-time. + */ + amount: number; + + /** + * The amount of bitcoin contained in the transaction. + */ + bitcoin_amount: number; + created: number; + + /** + * The currency to which this transaction was converted. + */ + currency: string; + + /** + * The receiver to which this transaction was sent. + */ + receiver: string; + } + } + module customerCards { } + + module customerSubscriptions { + /** + * Subscriptions allow you to charge a customer's card on a recurring basis. A subscription ties a customer to + * a particular plan you've created: https://stripe.com/docs/api#create_plan + */ + interface ISubscription { + id: string; + + /** + * Value is 'subscription' + */ + object: string; + + /** + * If the subscription has been canceled with the at_period_end flag set to true, cancel_at_period_end on the + * subscription will be true. You can use this attribute to determine whether a subscription that has a status + * of active is scheduled to be canceled at the end of the current period. + */ + cancel_at_period_end: boolean; + customer: string; + + /** + * Hash describing the plan the customer is subscribed to + */ + plan: plans.IPlan; + + /** + * The number of subscriptions for the associated plan + */ + quantity: number; + + /** + * Date the subscription started + */ + start: number; + + /** + * Possible values are trialing, active, past_due, canceled, or unpaid. A subscription still in its trial period is trialing + * and moves to active when the trial period is over. When payment to renew the subscription fails, the subscription becomes + * past_due. After Stripe has exhausted all payment retry attempts, the subscription ends up with a status of either canceled + * or unpaid depending on your retry settings. Note that when a subscription has a status of unpaid, no subsequent invoices + * will be attempted (invoices will be created, but then immediately automatically closed. Additionally, updating customer + * card details will not lead to Stripe retrying the latest invoice.). After receiving updated card details from a customer, + * you may choose to reopen and pay their closed invoices. + */ + status: string; + + /** + * A positive decimal that represents the fee percentage of the subscription invoice amount that will be transferred to + * the application owner’s Stripe account each billing period. + */ + application_fee_percent: number; + + /** + * If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with + * cancel_at_period_end, canceled_at will still reflect the date of the initial cancellation request, not the end of the + * subscription period when the subscription is automatically moved to a canceled state. + */ + canceled_at: number; + + /** + * End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created. + */ + current_period_end: number; + + /** + * Start of the current period that the subscription has been invoiced for + */ + current_period_start: number; + + /** + * Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a + * subscription overrides a discount applied on a customer-wide basis. + */ + discount: coupons.IDiscount; + + /** + * If the subscription has ended (either because it was canceled or because the customer was switched to a subscription + * to a new plan), the date the subscription ended + */ + ended_at: number; + + /** + * A set of key/value pairs that you can attach to a subscription object. It can be useful for storing additional + * information about the subscription in a structured format. + */ + metadata: IMetadata; + + /** + * If the subscription has a trial, the end of that trial. + */ + trial_end: number; + + /** + * If the subscription has a trial, the beginning of that trial. + */ + trial_start: number; + + /** + * If provided, each invoice created by this subscription will apply the tax rate, increasing the amount billed to the customer. + */ + tax_percent: number; + } + } + + module chargeRefunds { + interface IRefund { + id: string; + + /** + * Value is 'list' + */ + object: string; + + /** + * Amount reversed in cents. + */ + amount: number; + + created: number; + + /** + * Three-letter ISO currency code representing the currency in which the charge was made. + */ + currency: string; + + /** + * Balance transaction that describes the impact of this reversal on your account balance. + */ + balance_transaction: string; + + /** + * ID of the charge that was refunded. + */ + charge: string; + + metadata: IMetadata; + + /** + * Reason for the refund. If set, possible values are duplicate, fraudulent, and requested_by_customer. + */ + reason: string; + + /** + * This is the transaction number that appears on email receipts sent for this refund. + */ + receipt_number: string; + + description: string; + } + } + + module applicationFeeRefunds { } + module transferReversals { } + + class StripeResource { + constructor(stripe: Stripe, urlData: any); + } + + module resources { + class Account extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + } + + class ApplicationFeeRefunds extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + } + + class ApplicationFees extends StripeResource { + list(): void; + retrieve(id: string): void; + } + + class Balance extends StripeResource { + retrieve(id: string): void; + } + + class BitcoinReceivers extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + } + + class ChargeRefunds extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + } + + class Charges extends StripeResource { + /** + * To charge a credit card, you create a charge object. If your API key is in test mode, the supplied card won't actually be charged, though + * everything else will occur as if in live mode. (Stripe assumes that the charge would have completed successfully). + * + * @returns Returns a charge object if the charge succeeded. Throws an error if something goes wrong. A common source of error is an invalid or + * expired card, or a valid card with insufficient available balance. If the cvc parameter is provided, Stripe will attempt to check the CVC's + * correctness, and the check's result will be returned. Similarly, If address_line1 or address_zip are provided, Stripe will similarly try to + * check the validity of those parameters. Some banks do not support checking one or more of these parameters, in which case Stripe will return + * an 'unavailable' result. Also note that, depending on the bank, charges can succeed even when passed incorrect CVC and address information. + * + * @param options Options for creating a charge. + * @param response A callback to receive the response and newly created charge, or errors if they exist. + */ + create(options: { + /** + * A positive integer in the smallest currency unit (e.g 100 cents to charge $1.00, or 1 to charge ¥1, a 0-decimal currency) + * representing how much to charge the card. The minimum amount is $0.50 (or equivalent in charge currency). + */ + amount: number; + + /** + * 3-letter ISO code for currency. + */ + currency: string; + + /** + * The ID of an existing customer that will be charged in this request. + */ + customer?: string; + + /** + * A payment source to be charged, such as a credit card. If you also pass a customer ID, the source must be the ID of + * a source belonging to the customer. Otherwise, if you do not pass a customer ID, the source you provide must either + * be a token, like the ones returned by Stripe.js, or a object containing a user's credit card details, with the options + * described below. Although not all information is required, the extra info helps prevent fraud. + */ + source?: string | IPaymentToken | ICard; + + /** + * An arbitrary string which you can attach to a charge object. It is displayed when in the web interface alongside the + * charge. Note that if you use Stripe to send automatic email receipts to your customers, your receipt emails will include + * the description of the charge(s) that they are describing. + */ + description?: string; + metadata?: IMetadata; + + /** + * Whether or not to immediately capture the charge. When false, the charge issues an authorization (or pre-authorization), + * and will need to be captured later. Uncaptured charges expire in 7 days. For more information, see authorizing charges + * and settling later: https://support.stripe.com/questions/can-i-authorize-a-charge-and-then-wait-to-settle-it-later + */ + capture?: boolean; + + /** + * An arbitrary string to be displayed on your customer's credit card statement. This may be up to 22 characters. + * As an example, if your website is RunClub and the item you're charging for is a race ticket, you may want to + * specify a statement_descriptor of RunClub 5K race ticket. The statement description may not include <>"' characters, + * and will appear on your customer's statement in capital letters. Non-ASCII characters are automatically stripped. + * While most banks display this information consistently, some may display it incorrectly or not at all. + */ + statement_descriptor?: string; + + /** + * The email address to send this charge's receipt to. The receipt will not be sent until the charge is paid. + * If this charge is for a customer, the email address specified here will override the customer's email address. + * Receipts will not be sent for test mode charges. If receipt_email is specified for a charge in live mode, a receipt + * will be sent regardless of your email settings. + */ + receipt_email?: string; + + /** + * A fee in cents that will be applied to the charge and transferred to the application owner's Stripe account. + * The request must be made with an OAuth key in order to take an application fee. For more information, + * see the application fees documentation: https://stripe.com/docs/connect/collecting-fees + */ + application_fee?: string; + + /** + * Shipping information for the charge. Helps prevent fraud on charges for physical goods. + */ + shipping?: IShippingInformation; + }, response: IResponseFn): void; + + /** + * Retrieves the details of a charge that has previously been created. Supply the unique charge ID that was returned + * from your previous request, and Stripe will return the corresponding charge information. The same information is + * returned when creating or refunding the charge. + * + * @param id The identifier of the charge to be retrieved + * @param response A callback that takes in a potential error and a charge object. + */ + retrieve(id: string, response: IResponseFn): void; + + /** + * Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + * This request accepts only the description, metadata, receipt_emailand fraud_details as arguments. + * + * @param id The identifier of the charge to be updated + * @param update An object containing the updated properties. + */ + update(id: string, update: { + /** + * An arbitrary string which you can attach to a charge object. It is displayed when in the web interface alongside the charge. + * Note that if you use Stripe to send automatic email receipts to your customers, your receipt emails will include the description + * of the charge(s) that they are describing. This can be unset by updating the value to null and then saving. + */ + description?: string; + + /** + * You can unset an individual key by setting its value to null and then saving. To clear all keys, set metadata to null, then save. + */ + metadata?: IMetadata; + + /** + * This is the email address that the receipt for this charge will be sent to. + * If this field is updated, then a new email receipt will be sent to the updated address. + */ + receipt_email?: string; + + /** + * A set of key/value pairs you can attach to a charge giving information about its riskiness. + */ + fraud_details?: { + /** + * If you believe a charge is fraudulent, include a user_report key with a value of fraudulent. If you believe a + * charge is safe, include a user_report key with a value of safe. Note that you must refund a charge before setting + * the user_report to fraudulent. Stripe will use the information you send to improve our fraud detection algorithm + */ + user_report?: string; + } + }, response: IResponseFn): void; + + /** + * Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first + * you created a charge with the capture option set to false. Uncaptured payments expire exactly seven days after they are + * created. If they are not captured by that point in time, they will be marked as refunded and will no longer be capturable. + */ + capture(id: string, response: IResponseFn): void; + + /** + * Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges + * appearing first. + * + * @returns An object with a data property that contains an array of up to limit charges, starting after charge starting_after. + * Each entry in the array is a separate charge object. If no more charges are available, the resulting array will be empty. + * If you provide a non-existent customer ID, this call throws an error. You can optionally request that the response include + * the total count of all charges that match your filters. To do so, specify include[]=total_count in your request. + * + * @param options Filtering options for the returned items. + */ + list(options: IListOptions, response: IResponseFn>): void; + + /** + * When you get a dispute, contacting your customer is always the best first step. If that doesn't work, you can submit evidence in + * order to help us resolve the dispute in your favor. You can do this in your dashboard, but if you prefer, you can use the API to + * submit evidence programmatically. Depending on your dispute type, different evidence fields will give you a better chance of winning + * your dispute. You may want to consult our guide to dispute types to help you figure out which evidence fields to provide: + * https://stripe.com/help/dispute-types + * + * @param chargeId The ID for the disputed charge + * @param options The fields to update + */ + updateDispute(chargeId: string, options: { + /** + * Evidence to upload to respond to a dispute. Updating any field in the hash will submit all fields in the hash for review. + */ + evidence?: IDisputeEvidence; + /** + * A set of key/value pairs that you can attach to a dispute object. It can be useful for storing additional information about the + * dispute in a structured format. This can be unset by updating the value to null and then saving. + */ + metadata?: IMetadata; + }, response: IResponseFn): void; + + + /** + * Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially 'dismissing' the dispute, + * acknowledging it as lost. The status of the dispute will change from under_review to lost. + * + * IMPORTANT: Closing a dispute is irreversible. + * + * @param chargeId The ID of the disputed charge + */ + closeDispute(chargeId: string): void; + + /** + * When you create a new refund, you must specify a charge to create it on. Creating a new refund will refund a charge that has previously + * been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged. The fees you were + * originally charged are also refunded. You can optionally refund only part of a charge. You can do so as many times as you wish until + * the entire charge has been refunded. Once entirely refunded, a charge can't be refunded again. This method will throw an error when + * called on an already-refunded charge, or when trying to refund more money than is left on a charge. + * + * @returns Returns the refund object if the refund succeeded. Throws an error if the charge has already been refunded or an invalid + * charge identifier was provided. + * + * @param id The identifier of the charge to be refunded. + * @param options Options for specifying reasons and refund amount + * @param response The refund. + */ + createRefund(id: string, options: { + /** + * A positive integer in cents representing how much of this charge to refund. Can only refund up to the unrefunded amount remaining + * of the charge. + */ + amount?: number; + + /** + * Boolean indicating whether the application fee should be refunded when refunding this charge. If a full charge refund is given, the + * full application fee will be refunded. Else, the application fee will be refunded with an amount proportional to the amount of the + * charge refunded. An application fee can only be refunded by the application that created the charge. + */ + refund_applcation_fee?: boolean; + + /** + * String indicating the reason for the refund. If set, possible values are duplicate, fraudulent, and requested_by_customer. Specifying + * fraudulent as the reason when you believe the charge to be fraudulent will help us improve our fraud detection algorithms. + */ + reason?: string; + + /** + * A set of key/value pairs that you can attach to a refund object. It can be useful for storing additional information about the refund + * in a structured format. You can unset an individual key by setting its value to null and then saving. To clear all keys, set metadata + * to null, then save. + */ + metadata?: IMetadata; + }, response: IResponseFn): void; + + /** + * By default, you can see the 10 most recent refunds stored directly on the charge object, but you can also retrieve details about a specific + * refund stored on the charge. + * + * @param chargeId The ID of the charge refunded + * @param refundId The ID of the refund to retrieve + */ + retrieveRefund(chargeId: string, refundId: string, response: IResponseFn): void; + + /** + * Updates the specified refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + * This request only accepts metadata as an argument. + * + * @param chargeId The ID of the charge refunded + * @param refundId The ID of the refund to update + */ + updateRefund(chargeId: string, refundId: string, options: { + /** + * A set of key/value pairs that you can attach to a refund object. It can be useful for storing additional information about the refund + * in a structured format. You can unset an individual key by setting its value to null and then saving. To clear all keys, set metadata + * to null, then save. + */ + metadata: IMetadata; + }, response: IResponseFn): void; + + /** + * You can see a list of the refunds belonging to a specific charge. Note that the 10 most recent refunds are always available by default on + * the charge object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through + * additional refunds. + * + * @returns A object with a data property that contains an array of up to limit refunds, starting after refund starting_after. + * Each entry in the array is a separate refund object. If no more refunds are available, the resulting array will be empty. If you provide + * a non-existent customer ID or charge ID, this call throws an error. You can optionally request that the response include the total count + * of all refunds that match your filters. To do so, specify include[]=total_count in your request. + * + * @param chargeId The ID of the charge refunded + * @param options Used to filter the refunds returned + */ + listRefunds(chargeId: string, options: IListOptions, response: IResponseFn>): void; + } + + class Coupons extends StripeResource { + /** + * You can create coupons easily via the coupon management page of the Stripe dashboard. Coupon creation is also accessible via the API if + * you need to create coupons on the fly. A coupon has either a percent_off or an amount_off and currency. If you set an amount_off, that + * amount will be subtracted from any invoice's subtotal. For example, an invoice with a subtotal of $10 will have a final total of $0 if + * a coupon with an amount_off of 2000 is applied to it and an invoice with a subtotal of $30 will have a final total of $10 if a coupon + * with an amount_off of 2000 is applied to it. + * + * @returns Returns the coupon object. + * + * @param options Options for creating the coupon. + */ + create(options: { + /** + * Unique string of your choice that will be used to identify this coupon when applying it a customer. This is often a specific code + * you’ll give to your customer to use when signing up (e.g. FALL25OFF). If you don’t want to specify a particular code, you can leave + * the ID blank and we’ll generate a random code for you. + */ + id?: string; + + /** + * Specifies how long the discount will be in effect. Can be forever, once, or repeating. + */ + duration: string; + + /** + * A positive integer representing the amount to subtract from an invoice total (required if percent_off is not passed) + */ + amount_off?: number; + + /** + * Currency of the amount_off parameter (required if amount_off is passed) + */ + currency?: string; + + /** + * required only if duration is repeating If duration is repeating, a positive integer that specifies the number of months the + * discount will be in effect + */ + duration_in_months?: number; + + /** + * A positive integer specifying the number of times the coupon can be redeemed before it’s no longer valid. For example, you might + * have a 50% off coupon that the first 20 readers of your blog can use. + */ + max_redemptions?: number; + + /** + * A set of key/value pairs that you can attach to a coupon object. It can be useful for storing additional information about the + * coupon in a structured format. This can be unset by updating the value to null and then saving. + */ + metadata?: IMetadata; + + /** + * A positive integer between 1 and 100 that represents the discount the coupon will apply (required if amount_off is not passed) + */ + percent_off?: number; + + /** + * Unix timestamp specifying the last time at which the coupon can be redeemed. After the redeem_by date, the coupon can no longer + * be applied to new customers. + */ + redeem_by?: number; + }, response: IResponseFn): void; + + /** + * Retrieves the coupon with the given ID. + * + * @returns Returns a coupon if a valid coupon ID was provided. Throws an error otherwise. + * + * @param id The ID of the desired coupon + */ + retrieve(id: string, response: IResponseFn): void; + + /** + * Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable. + * + * @returns The newly updated coupon object if the call succeeded. Otherwise, this call throws an error, such as if the coupon has + * been deleted. + * + * @param id The ID of the coupon to be updated + * @param options Metadata to update + */ + update(id: string, options: { + /** + * A set of key/value pairs that you can attach to a coupon object. It can be useful for storing additional information about the + * coupon in a structured format. + */ + metadata?: IMetadata; + }, response: IResponseFn): void; + + /** + * You can delete coupons via the coupon management page of the Stripe dashboard. However, deleting a coupon does not affect any + * customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons + * via the API. + * + * @returns An object with the deleted coupon's ID and a deleted flag upon success. Otherwise, this call throws an error, such as + * if the coupon has already been deleted. + * + * @param id The ID of the coupon to be deleted. + */ + del(id: string, response: IResponseFn): void; + + /** + * Returns a list of your coupons. + * + * @returns A object with a data property that contains an array of up to limit coupons, starting after coupon starting_after. Each + * entry in the array is a separate coupon object. If no more coupons are available, the resulting array will be empty. This request + * should never throw an error. You can optionally request that the response include the total count of all coupons. To do so, specify + * include[]=total_count in your request. + * + * @param options Filtering options for the list. + */ + list(options: IListOptions, response: IResponseFn): void; + } + + class CustomerCards extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + del(id: string): void; + } + + class Customers extends StripeResource { + /** + * Creates a new customer object. + * + * @returns Returns a customer object if the call succeeded. The returned object will have information about subscriptions, discount, + * and payment sources, if that information has been provided. If a non-free plan is specified and a source is not provided (unless + * the plan has a trial period), the call will throw an error. If a non-existent plan or a non-existent or expired coupon is provided, + * the call will throw an error. If a source has been attached to the customer, the returned customer object will have a default_source + * attribute, which is an ID that can be expanded into the full source details when retrieving the customer. + * + * @param options The options for the new customer + */ + create(options: { + /** + * An integer amount in cents that is the starting account balance for your customer. A negative amount represents a credit that + * will be used before attempting any charges to the customer’s card; a positive amount will be added to the next invoice. + */ + account_balance?: number; + + /** + * If you provide a coupon code, the customer will have a discount applied on all recurring charges. Charges you create through the + * API will not have the discount. + */ + coupon?: string; + + /** + * An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard. This can + * be unset by updating the value to null and then saving. + */ + description?: string; + + /** + * Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. + * This can be unset by updating the value to null and then saving. + */ + email?: string; + + /** + * A set of key/value pairs that you can attach to a customer object. It can be useful for storing additional information about the + * customer in a structured format. This can be unset by updating the value to null and then saving. + */ + metadata?: IMetadata; + + /** + * The identifier of the plan to subscribe the customer to. If provided, the returned customer object will have a list of subscriptions + * that the customer is currently subscribed to. If you subscribe a customer to a plan without a free trial, the customer must have a + * valid card as well. + */ + plan?: string; + + /** + * The quantity you’d like to apply to the subscription you’re creating (if you pass in a plan). For example, if your plan is + * 10 cents/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged 50 cents + * (5 x 10 cents) monthly. Defaults to 1 if not set. Only applies when the plan parameter is also provided. + */ + quantity?: number; + source?: string | ICard; + + /** + * Unix timestamp representing the end of the trial period the customer will get before being charged. If set, trial_end will + * override the default trial period of the plan the customer is being subscribed to. The special value now can be provided to + * end the customer’s trial immediately. Only applies when the plan parameter is also provided. + */ + trial_end?: number; + }, response: IResponseFn): void; + + /** + * Returns a list of your customers. The customers are returned sorted by creation date, with the most recently created customers + * appearing first. + * + * @returns A object with a data property that contains an array of up to limit customers, starting after customer starting_after. + * Each entry in the array is a separate customer object. If no more customers are available, the resulting array will be empty. + * This request should never throw an error. You can optionally request that the response include the total count of all customers + * that match your filters. To do so, specify include[]=total_count in your request. + * + * @param options Allows you to filter the customers you want. + */ + list(options: IListOptions, response: IResponseFn>): void; + + /** + * Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + * For example, if you pass the card parameter, that becomes the customer's active card to be used for all charges in the future. + * When you update a customer to a new valid card: for each of the customer's current subscriptions, if the subscription is in the + * past_due state, then the latest unpaid, unclosed invoice for the subscription will be retried (note that this retry will not count + * as an automatic retry, and will not affect the next regularly scheduled payment for the invoice). (Note also that no invoices + * pertaining to subscriptions in the unpaid state, or invoices pertaining to canceled subscriptions, will be retried as a result + * of updating the customer's card.) This request accepts mostly the same arguments as the customer creation call. + * + * @returns Returns the customer object if the update succeeded. Throws an error if update parameters are invalid (e.g. specifying + * an invalid coupon or an invalid card). + */ + update(id: string, options: { + /** + * An integer amount in cents that is the starting account balance for your customer. A negative amount represents a credit that + * will be used before attempting any charges to the customer’s card; a positive amount will be added to the next invoice. + */ + account_balance?: number; + + /** + * If you provide a coupon code, the customer will have a discount applied on all recurring charges. Charges you create through the + * API will not have the discount. + */ + coupon?: string; + + /** + * An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard. This can + * be unset by updating the value to null and then saving. + */ + description?: string; + + /** + * Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. + * This can be unset by updating the value to null and then saving. + */ + email?: string; + + /** + * A set of key/value pairs that you can attach to a customer object. It can be useful for storing additional information about the + * customer in a structured format. This can be unset by updating the value to null and then saving. + */ + metadata?: IMetadata; + + /** + * The identifier of the plan to subscribe the customer to. If provided, the returned customer object will have a list of subscriptions + * that the customer is currently subscribed to. If you subscribe a customer to a plan without a free trial, the customer must have a + * valid card as well. + */ + plan?: string; + + /** + * The quantity you’d like to apply to the subscription you’re creating (if you pass in a plan). For example, if your plan is + * 10 cents/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged 50 cents + * (5 x 10 cents) monthly. Defaults to 1 if not set. Only applies when the plan parameter is also provided. + */ + quantity?: number; + source?: ICard; + + /** + * Unix timestamp representing the end of the trial period the customer will get before being charged. If set, trial_end will + * override the default trial period of the plan the customer is being subscribed to. The special value now can be provided to + * end the customer’s trial immediately. Only applies when the plan parameter is also provided. + */ + trial_end?: number; + }, response: IResponseFn): void; + + /** + * Retrieves the details of an existing customer. You need only supply the unique customer identifier that was returned upon customer + * creation. + * + * @returns Returns a customer object if a valid identifier was provided. When requesting the ID of a customer that has been deleted, + * a subset of the customer's information will be returned, including a "deleted" property, which will be true. + * + * @param id The identifier of the customer to be retrieved. + */ + retrieve(id: string, response: IResponseFn): void; + + /** + * Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. + * + * @returns Returns an object with a deleted parameter on success. If the customer ID does not exist, this call throws an error. Unlike + * other objects, deleted customers can still be retrieved through the API, in order to be able to track the history of customers while + * still removing their credit card details and preventing any further operations to be performed (such as adding a new subscription). + * + * @param id The identifier of the customer to be deleted. + */ + del(id: string, response: IResponseFn): void; + + /** + * When you create a new credit card, you must specify a customer or recipient to create it on. If the card's owner has no default card, + * then the new card will become the default. However, if the owner already has a default then it will not change. To change the default, + * you should either update the customer to have a new default_source or update the recipient to have a new default_card. + * + * @returns Returns the card object. + * + * @param customerId The customer ID to which to add the card. + */ + createCard(customerId: string, options: { + /** + * The source can either be a token, like the ones returned by our Stripe.js, or a dictionary containing a user’s credit card details + * (with the options shown below). Whenever you create a new card for a customer, Stripe will automatically validate the card. + */ + source?: string | ICard; + card?: string | IPaymentToken; + }, response: IResponseFn): void; + + /** + * By default, you can see the 10 most recent cards stored on a customer or recipient directly on the customer or recipient object, but + * you can also retrieve details about a specific card stored on the customer or recipient. + * + * @returns Returns the card object. + * + * @param customerId The ID of the customer whose card needs to be retrieved. + * @param cardId The ID of the card to be retrieved. + */ + retrieveCard(customerId: string, cardId: string, response: IResponseFn): void; + + /** + * If you need to update only some card details, like the billing address or expiration date, you can do so without having to re-enter the + * full card details. Stripe also works directly with card networks so that your customers can continue using your service without + * interruption. When you update a card, Stripe will automatically validate the card. + * + * @returns Returns the card object. + * + * @param customerId The ID of the customer whose card needs to be retrieved. + * @param cardId The ID of the card to be retrieved. + */ + updateCard(customerId: string, cardId: string, options: { + /** + * The card number + */ + 'number'?: number; + exp_month?: number; + exp_year?: number; + address_city?: string; + + /** + * Billing address country, if provided when creating card + */ + address_country?: string; + address_line1?: string; + address_line2?: string; + address_state?: string; + address_zip?: string; + + /** + * Two-letter ISO code representing the country of the card. You could use this + * attribute to get a sense of the international breakdown of cards you’ve collected. + */ + country?: string; + + /** + * Cardholder name + */ + name?: string; + }, response: IResponseFn): void; + + /** + * You can delete cards from a customer or recipient. If you delete a card that is currently the + * default source on a customer, then the most recently added source will become the new default. + * If you delete a card that is the last remaining source on the customer then the default_source + * attribute will become null. Similarly, if you delete the default card on a recipient, then the + * most recently added card will become the new default. If you delete the last remaining card on + * a recipient, then the default_card attribute will become null. Note that for cards belonging to + * customers, you may want to prevent customers on paid subscriptions from deleting all cards on + * file so that there is at least one default card for the next invoice payment attempt. + * + * @returns Returns the deleted card object. + * + * @param customerId The ID of the customer whose card needs to be retrieved. + * @param cardId The ID of the card to be retrieved. + */ + deleteCard(customerId: string, cardId: string, response: IResponseFn): void; + + /** + * You can see a list of the cards belonging to a customer or recipient. Note that the 10 most recent + * cards are always available by default on the customer or recipient object. If you need more than + * those 10, you can use this API method and the limit and starting_after parameters to page through + * additional cards. + * + * @returns Returns a list of the cards stored on the customer or recipient. You can optionally request + * that the response include the total count of all cards for the customer or recipient. To do so, + * specify include[]=total_count in your request. + * + * @param customerId The ID of the customer whose cards will be retrieved + * @param options Filtering options + */ + listCards(customerId: string, options: IListOptions, response: IResponseFn>): void; + + /** + * Creates a new subscription on an existing customer. + * + * @returns The newly created subscription object if the call succeeded. If the customer has no card or the + * attempted charge fails, this call throws an error (unless the specified plan is free or has a trial + * period). + * + * @param customerId The customer to which the add the subscription. + * @param options The options for the new subscription + */ + createSubscription(customerId: string, options: { + /** + * The identifier of the plan to subscribe the customer to. + */ + plan: string; + + /** + * The code of the coupon to apply to this subscription. A coupon applied to a subscription will only + * affect invoices created for that particular subscription. + */ + coupon?: string; + + /** + * Unix timestamp representing the end of the trial period the customer will get before being charged + * for the first time. If set, trial_end will override the default trial period of the plan the customer + * is being subscribed to. The special value now can be provided to end the customer's trial immediately. + */ + trial_end?: number; + + /** + * The source can either be a token, like the ones returned by our Stripe.js, or a object containing a + * user's credit card details (with the options shown below). You must provide a source if the customer + * does not already have a valid source attached, and you are subscribing the customer for a plan that + * is not free. Passing source will create a new source object, make it the customer default source, and + * delete the old customer default if one exists. If you want to add an additional source to use with + * subscriptions, instead use the card creation API to add the card and then the customer update API to + * set it as the default. Whenever you attach a card to a customer, Stripe will automatically validate + * the card. + */ + source?: IPaymentToken | ICard; + + /** + * The quantity you'd like to apply to the subscription you're creating. For example, if your plan is + * $10/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer + * charged $50 (5 x $10) monthly. If you update a subscription but don't change the plan ID (e.g. + * changing only the trial_end), the subscription will inherit the old subscription's quantity attribute + * unless you pass a new quantity parameter. If you update a subscription and change the plan ID, the new + * subscription will not inherit the quantity attribute and will default to 1 unless you pass a quantity + * parameter. + */ + quantity?: number; + + /** + * A positive decimal (with at most two decimal places) between 1 and 100. This represents the percentage + * of the subscription invoice subtotal that will be transferred to the application owner’s Stripe account. + * The request must be made with an OAuth key in order to set an application fee percentage. For more + * information, see the application fees documentation: https://stripe.com/docs/connect/collecting-fees#subscriptions + */ + application_fee_percent?: number; + + /** + * A positive decimal (with at most two decimal places) between 1 and 100. This represents the percentage + * of the subscription invoice subtotal that will be calculated and added as tax to the final amount each + * billing period. For example, a plan which charges $10/month with a tax_percent of 20.0 will charge + * $12 per invoice. + */ + tax_percent?: number; + + /** + * A set of key/value pairs that you can attach to a subscription object. It can be useful for + * storing additional information about the subscription in a structured format. + */ + metadata?: IMetadata; + }, response: IResponseFn): void; + + /** + * By default, you can see the 10 most recent active subscriptions stored on a customer directly on the customer + * object, but you can also retrieve details about a specific active subscription for a customer. + * + * @returns Returns the subscription object. + * + * @param customerId The customer ID for the subscription + * @param subscriptionId The ID of the subscription to retrieve + */ + retrieveSubscription(customerId: string, subscriptionId: string, response: IResponseFn): void; + + /** + * Updates an existing subscription on a customer to match the specified parameters. When changing plans or quantities, + * we will optionally prorate the price we charge next month to make up for any price changes. + * + * By default, we prorate subscription changes. For example, if a customer signs up on May 1 for a $10 plan, she'll be billed + * $10 immediately. If she then switches to a $20 plan on May 15, on June 1 she'll be billed $25 ($20 for a renewal of her + * subscription and a $5 prorating adjustment for the previous month). Similarly, a downgrade will generate a credit to be + * applied to the next invoice. We also prorate when you make quantity changes. Switching plans does not change the billing + * date or generate an immediate charge unless you're switching between different intervals (e.g. monthly to yearly), in which + * case we apply a credit for the time unused on the old plan and charge for the new plan starting right away, resetting the + * billing date. (Note that if we charge for the new plan, and that payment fails, the plan change will not go into effect). If + * you'd like to charge for an upgrade immediately, just pass prorate as true as usual, and then invoice the customer as soon + * as you make the subscription change. That'll collect the proration adjustments into a new invoice, and Stripe will automatically + * attempt to pay the invoice. If you don't want to prorate at all, set the prorate option to false and the customer would be billed + * $10 on May 1 and $20 on June 1. Similarly, if you set prorate to false when switching between different billing intervals + * (monthly to yearly, for example), we won't generate any credits for the old subscription's unused time, although we will still + * reset the billing date and bill immediately for the new subscription. + * + * @returns The newly updated subscription object if the call succeeded. If a charge is required for the update, and + * the charge fails, this call raises throws an error, and the subscription update does not go into effect. + * + * @param customerId The ID of the customer whose subscription needs to be updated. + * @param subscriptionId The ID of the subscription to update. + * @param options The fields to update + */ + updateSubscription(customerId: string, subscriptionId: string, options: { + /** + * The identifier of the plan to update the subscription to. If omitted, the subscription will not change plans. + */ + plan?: string; + + /** + * The code of the coupon to apply to the customer if you would like to apply it at the same time as updating the subscription. + */ + coupon?: string; + + /** + * Flag telling us whether to prorate switching plans during a billing cycle. + */ + prorate?: boolean; + + /** + * Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. If set, + * trial_end will override the default trial period of the plan the customer is being subscribed to. The special value now can be + * provided to end the customer's trial immediately. + */ + trial_end?: number; + + /** + * The source can either be a token, like the ones returned by our Stripe.js, or a object containing a user's credit card details + * (with the options shown below). You must provide a source if the customer does not already have a valid source attached, and + * you are subscribing the customer for a plan that is not free. Passing source will create a new source object, make it the + * customer default source, and delete the old customer default if one exists. If you want to add an additional source to use + * with subscriptions, instead use the card creation API to add the card and then the customer update API to set it as the default. + * Whenever you attach a card to a customer, Stripe will automatically validate the card. + */ + source?: IPaymentToken | ICard; + + /** + * The quantity you'd like to apply to the subscription you're updating. For example, if your plan is $10/user/month, and your + * customer has 5 users, you could pass 5 as the quantity to have the customer charged $50 (5 x $10) monthly. If you update a + * subscription but don't change the plan ID (e.g. changing only the trial_end), the subscription will inherit the old subscription's + * quantity attribute unless you pass a new quantity parameter. If you update a subscription and change the plan ID, the new + * subscription will not inherit the quantity attribute and will default to 1 unless you pass a quantity parameter. + */ + quantity?: number; + + /** + * A positive decimal (with at most two decimal places) between 1 and 100 that represents the percentage of the subscription + * invoice amount due each billing period (including any bundled invoice items) that will be transferred to the application + * owner’s Stripe account. The request must be made with an OAuth key in order to set an application fee percentage . For more + * information, see the application fees documentation: https://stripe.com/docs/connect/collecting-fees#subscriptions + */ + application_fee_percent?: number; + + /** + * Update the amount of tax applied to this subscription. Changing the tax_percent of a subscription will only affect future + * invoices. + */ + tax_percent?: number; + + /** + * A set of key/value pairs that you can attach to a subscription object. It can be useful for storing additional information + * about the subscription in a structured format. + */ + metadata?: IMetadata; + }, response: IResponseFn): void; + + /** + * Cancels a customer's subscription. If you set the at_period_end parameter to true, the subscription will remain active until + * the end of the period, at which point it will be canceled and not renewed. By default, the subscription is terminated + * immediately. In either case, the customer will not be charged again for the subscription. Note, however, that any pending + * invoice items that you've created will still be charged for at the end of the period unless manually deleted. If you've set + * the subscription to cancel at period end, any pending prorations will also be left in place and collected at the end of the + * period, but if the subscription is set to cancel immediately, pending prorations will be removed. By default, all unpaid + * invoices for the customer will be closed upon subscription cancellation. We do this in order to prevent unexpected payment + * retries once the customer has canceled a subscription. However, you can reopen the invoices manually after subscription + * cancellation to have us proceed with automatic retries, or you could even re-attempt payment yourself on all unpaid invoices + * before allowing the customer to cancel the subscription at all. + * + * @returns The canceled subscription object. Its subscription status will be set to "canceled" unless you've set at_period_end + * to true when canceling, in which case the status will remain "active" but the cancel_at_period_end attribute will change to true. + * + * @param customerId The ID of the customer whose subscription needs to be cancelled. + * @param subscriptionId The ID of the subscription to cancel. + * @param options Specify when to cancel the subscription + */ + cancelSubscription(customerId: string, subscriptionId: string, options: { + /** + * A flag that if set to true will delay the cancellation of the subscription until the end of the current period. + */ + at_period_end?: boolean; + }, response: IResponseFn): void; + + /** + * You can see a list of the customer's active subscriptions. Note that the 10 most recent active subscriptions are always available + * by default on the customer object. If you need more than those 10, you can use the limit and starting_after parameters to page + * through additional subscriptions. + * + * @returns Returns a list of the customer's active subscriptions. You can optionally request that the response include the total + * count of all subscriptions for the customer. To do so, specify include[]=total_count in your request. + * + * @param customerId The ID of the customer whose subscriptions will be retrieved + * @param options Filtering options + */ + listSubscriptions(customerId: string, options: IListOptions, response: IResponseFn>): void; + + /** + * Removes the currently applied discount on a customer. + * + * @returns An object with a deleted flag set to true upon success. This call throws an error otherwise, such as if no + * discount exists on this customer. + * + * @param customerId The ID of the customer. + */ + deleteDiscount(customerId: string, response: IResponseFn): void; + + /** + * Removes the currently applied discount on a subscription. + * + * @returns An object with a deleted flag set to true upon success. This call throws an error otherwise, such as if no + * discount exists on this subscription. + * + * @param customerId The ID of the customer. + * @param subscriptionId The ID of the subscription. + */ + deleteSubscriptionDiscount(customerId: string, subscriptionId: string, response: IResponseFn): void; + } + + class CustomerSubscriptions extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + del(id: string): void; + } + + class Events extends StripeResource { + list(): void; + retrieve(id: string): void; + } + + class FileUploads extends StripeResource { + list(): void; + retrieve(id: string): void; + } + + class InvoiceItems extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + del(id: string): void; + } + + class Invoices extends StripeResource { + /** + * If you need to invoice your customer outside the regular billing cycle, you can create an invoice that + * pulls in all pending invoice items, including prorations. The customer's billing cycle and regular subscription + * won't be affected. Once you create the invoice, it'll be picked up and paid automatically, though you can + * choose to pay it right away: https://stripe.com/docs/api#pay_invoice + * + * @returns Returns the invoice object if there are pending invoice items to invoice. Throws an error if there + * are no pending invoice items or if the customer ID provided is invalid. + * + * @param options Options used to create the invoice. + */ + create(options: { + customer: string; + + /** + * A fee in cents that will be applied to the invoice and transferred to the application owner’s Stripe account. + * The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. + * For more information, see the application fees documentation. + */ + application_fee?: number; + description?: string; + metadata?: IMetadata; + + /** + * Extra information about a charge for the customer’s credit card statement. + */ + statement_descriptor?: string; + + /** + * The ID of the subscription to invoice. If not set, the created invoice will include all pending invoice items + * for the customer. If set, the created invoice will exclude pending invoice items that pertain to other + * subscriptions. + */ + subscription?: string; + + /** + * The percent tax rate applied to the invoice, represented as a decimal number. + */ + tax_percent?: number; + }, response: IResponseFn): void; + + /** + * Retrieves the invoice with the given ID. The invoice object contains a + * lines hash that contains information about the subscriptions and invoice items that have been applied to the + * invoice, as well as any prorations that Stripe has automatically calculated. Each line on the invoice has an + * amount attribute that represents the amount actually contributed to the invoice's total. For invoice items and + * prorations, the amount attribute is the same as for the invoice item or proration respectively. For + * subscriptions, the amount may be different from the plan's regular price depending on whether the invoice + * covers a trial period or the invoice period differs from the plan's usual interval. The invoice object has + * both a subtotal and a total. The subtotal represents the total before any discounts, while the total is the final + * amount to be charged to the customer after all coupons have been applied. The invoice also has a + * next_payment_attempt attribute that tells you the next time (as a Unix timestamp) payment for the invoice will be + * automatically attempted. For invoices that have been closed or that have reached the maximum number of retries + * (specified in your retry settings), the next_payment_attempt will be null. + * + * @returns Returns an invoice object if a valid invoice ID was provided. Throws an error otherwise. + * + * @param id The ID of the desired invoice. + */ + retrieve(id: string, response: IResponseFn): void; + + /** + * When retrieving an invoice, you'll get a lines property containing the total count of line items and the first + * handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + * + * @returns Returns a list of line_item objects. + * + * @param id The id of the invoice containing the lines to be retrieved + * @param options Filtering options + */ + retrieveLines(id: string, options: { + /** + * In the case of upcoming invoices, the customer of the upcoming invoice is required. In other cases it is ignored. + */ + customer?: string; + + /** + * A cursor for use in pagination. ending_before is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, starting with obj_bar, your subsequent + * call can include ending_before=obj_bar in order to fetch the previous page of the list. + */ + ending_before?: string; + + /** + * A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + */ + limit?: number; + + /** + * A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, + * if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include + * starting_after=obj_foo in order to fetch the next page of the list. + */ + starting_after?: string; + + /** + * In the case of upcoming invoices, the subscription of the upcoming invoice is optional. In other cases it is ignored. + */ + subscription?: string; + }, response: IResponseFn>): void; + + /** + * At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, + * including subscription renewal charges, invoice item charges, etc. It will also show you any discount that is applicable + * to the customer. Note that when you are viewing an upcoming invoice, you are simply viewing a preview -- the invoice has + * not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API + * to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or + * update pending invoice items, or update the customer's discount. + * + * @returns Returns an invoice if a valid customer ID was provided. Throws an error otherwise. + * + * @param id The identifier of the customer whose upcoming invoice you'd like to retrieve. + */ + retrieveUpcoming(id: string, options: { + /** + * The identifier of the subscription for which you'd like to retrieve the upcoming invoice. If not provided, you will + * retrieve the next upcoming invoice from among the customer's subscriptions. + */ + subscription?: string; + }, response: IResponseFn): void; + + /** + * Until an invoice is paid, it is marked as open (closed=false). If you'd like to stop Stripe from automatically attempting + * payment on an invoice or would simply like to close the invoice out as no longer owed by the customer, you can update the + * closed parameter. + * + * @returns Returns the invoice object. + * + * @param id The ID of the invoice to update + * @param options Fields to update + */ + update(id: string, options: { + /** + * A fee in cents that will be applied to the invoice and transferred to the application owner’s Stripe account. The request + * must be made with an OAuth key or the Stripe-Account header in order to take an application fee. For more information, + * see the application fees documentation: https://stripe.com/docs/connect/collecting-fees#subscriptions + */ + application_fee?: number; + + /** + * Boolean representing whether an invoice is closed or not. To close an invoice, pass true. + */ + closed?: boolean; + description?: string; + + /** + * Boolean representing whether an invoice is forgiven or not. To forgive an invoice, pass true. Forgiving an invoice instructs + * us to update the subscription status as if the invoice were succcessfully paid. Once an invoice has been forgiven, it + * cannot be unforgiven or reopened. + */ + forgiven?: string; + metadata?: IMetadata; + + /** + * Extra information about a charge for the customer’s credit card statement. + */ + statement_descriptor?: string; + + /** + * The percent tax rate applied to the invoice, represented as a decimal number. The tax rate of a paid or forgiven invoice + * cannot be changed. + */ + tax_percent?: number; + }, response: IResponseFn): void; + + /** + * Stripe automatically creates and then attempts to pay invoices for customers on subscriptions. We'll also retry unpaid + * invoices according to your retry settings. However, if you'd like to attempt to collect payment on an invoice out of the + * normal retry schedule or for some other reason, you can do so. + * + * @returns Returns the invoice object. + * + * @param id The ID of the invoice to pay. + */ + pay(id: string, response: IResponseFn): void; + + /** + * You can list all invoices, or list the invoices for a specific customer. The invoices are returned + * sorted by creation date, with the most recently created invoices appearing first. + * + * @returns A object with a data property that contains an array of invoice objects. Throws an error if the + * customer ID is invalid. + * + * @param options Filtering options + */ + list(options: IListOptions, response: IResponseFn>): void; + } + + class Plans extends StripeResource { + /** + * You can create plans easily via the plan management page of the Stripe dashboard. Plan creation is also + * accessible via the API if you need to create plans on the fly. + * + * @returns The newly created plan + * + * @param options Options for the new plan. + */ + create(options: { + /** + * Unique string of your choice that will be used to identify this plan when subscribing a customer. + * This could be an identifier like "gold" or a primary key from your own database. + */ + id: string; + + /** + * A positive integer in cents (or 0 for a free plan) representing how much to charge (on a recurring basis). + */ + amount: number; + + /** + * 3-letter ISO code for currency. + */ + currency: string; + + /** + * Specifies billing frequency. Either day, week, month or year. + */ + interval: string; + + /** + * The number of intervals between each subscription billing. For example, interval=month and + * interval_count=3 bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, + * or 52 weeks). + */ + interval_count?: number; + + /** + * Name of the plan, to be displayed on invoices and in the web interface. + */ + name: string; + + /** + * Specifies a trial period in (an integer number of) days. If you include a trial period, the customer + * won't be billed for the first time until the trial period ends. If the customer cancels before the + * trial period is over, she'll never be billed at all. + */ + trial_period_days?: number; + + /** + * A set of key/value pairs that you can attach to a plan object. It can be useful for storing additional + * information about the plan in a structured format. + */ + metadata?: IMetadata; + + /** + * An arbitrary string to be displayed on your customer's credit card statement. This may be up to 22 characters. + * As an example, if your website is RunClub and the item you're charging for is your Silver Plan, you may want + * to specify a statement_descriptor of RunClub Silver Plan. The statement description may not include <>"' + * characters, and will appear on your customer's statement in capital letters. Non-ASCII characters are + * automatically stripped. While most banks display this information consistently, some may display it incorrectly + * or not at all. + */ + statement_descriptor?: string; + }, response: IResponseFn): void; + + /** + * Retrieves the plan with the given ID. + * + * @returns Returns a plan if a valid plan ID was provided. Throws an error otherwise. + * + * @param id The ID of the desired plan. + */ + retrieve(id: string, response: IResponseFn): void; + + /** + * Updates the name of a plan. Other plan details (price, interval, etc.) are, by design, not editable. + * + * @returns The updated plan object is returned upon success. Otherwise, this call throws an error. + * + * @param id The plan ID to update + * @param options The fields to update + */ + update(id: string, options: { + /** + * Name of the plan, to be displayed on invoices and in the web interface. + */ + name?: string; + + /** + * A set of key/value pairs that you can attach to a plan object. It can be useful for storing additional information + * about the plan in a structured format. You can unset an individual key by setting its value to null and then saving. + * To clear all keys, set metadata to null, then save. + */ + metadata?: IMetadata; + + /** + * An arbitrary string to be displayed on your customer's credit card statement. This may be up to 22 characters. + * As an example, if your website is RunClub and the item you're charging for is your Silver Plan, you may want + * to specify a statement_descriptor of RunClub Silver Plan. The statement description may not include <>"' + * characters, and will appear on your customer's statement in capital letters. Non-ASCII characters are + * automatically stripped. While most banks display this information consistently, some may display it incorrectly + * or not at all. + */ + statement_descriptor?: string; + }, response: IResponseFn): void; + + /** + * You can delete plans via the plan management page of the Stripe dashboard. However, deleting a plan does not affect + * any current subscribers to the plan; it merely means that new subscribers can't be added to that plan. You can also + * delete plans via the API. + * + * @returns An object with the deleted plan's ID and a deleted flag upon success. Otherwise, this call throws an error, such as if the plan has already been deleted. + * + * @param id The identifier of the plan to be deleted. + */ + del(id: string, response: IResponseFn): void; + + /** + * Returns a list of your plans. + * + * @returns An object with a data property that contains an array of up to limit plans, starting after plan starting_after. + * Each entry in the array is a separate plan object. If no more plans are available, the resulting array will be empty. This + * request should never throw an error. You can optionally request that the response include the total count of all plans. To + * do so, specify include[]=total_count in your request. + */ + list(options: IListOptions, response: IResponseFn>): void; + } + + class RecipientCards extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + del(id: string): void; + } + + class Recipients extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + del(id: string): void; + } + + class Tokens extends StripeResource { + create(): void; + retrieve(id: string): void; + } + + class TransferReversals extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + } + + class Transfers extends StripeResource { + create(): void; + list(): void; + update(id: string): void; + retrieve(id: string): void; + } + } + + interface IResponseFn { + (err: IStripeError, value: R): void; + } + + interface IDeleteConfirmation { id: string; deleted: boolean; } + + /** + * Options for filtering a list by created period. + */ + interface IDateFilter { + /** + * Return values where the created field is after this timestamp. + */ + gt?: string; + + /** + * Return values where the created field is after or equal to this timestamp. + */ + gte?: string; + + /** + * Return values where the created field is before this timestamp. + */ + lt?: string; + + /** + * Return values where the created field is before or equal to this timestamp. + */ + lte?: string; + } + + /** + * A dispute occurs when a customer questions your charge with their bank or credit card company. + * When a customer disputes your charge, you're given the opportunity to respond to the dispute with + * evidence that shows the charge is legitimate. You can find more information about the dispute process + * in our disputes FAQ: https://stripe.com/help/disputes + */ + interface IDispute { + /** + * Valud is 'dispute' + */ + object: string; + livemode: boolean; + + /** + * Disputed amount. Usually the amount of the charge, but can differ (usually because of currency + * fluctuation or because only part of the order is disputed). + */ + amount: number; + + /** + * ID of the charge that was disputed + */ + charge: string; + + /** + * Date dispute was opened + */ + created: number; + + /** + * Three-letter ISO currency code representing the currency of the amount that was disputed. + */ + currency: string; + + /** + * Reason given by cardholder for dispute. Possible values are duplicate, fraudulent, subscription_canceled, + * product_unacceptable, product_not_received, unrecognized, credit_not_processed, general. + * Read more about dispute reasons: https://stripe.com/help/disputes#reasons + */ + reason: string; + + /** + * Current status of dispute. Possible values are warning_needs_response, warning_under_review, warning_closed, + * needs_response, response_disabled, under_review, charge_refunded, won, lost. + */ + status: string; + + /** + * List of zero, one, or two balance transactions that show funds withdrawn and reinstated to your + * Stripe account as a result of this dispute. + */ + balance_transactions: Array; + + /** + * Evidence provided to respond to a dispute. Updating any field in the hash will submit all fields in the hash for review. + */ + evidence: IDisputeEvidence; + + /** + * Information about the evidence submission. + */ + evidence_details?: { + /** + * Whether or not evidence has been saved for this dispute. + */ + has_evidence: boolean; + + /** + * The number of times the evidence has been submitted. You may submit evidence a maximum of 5 times + */ + submission_count: number; + + /** + * Date by which evidence must be submitted in order to successfully challenge dispute. Will be null + * if the customer’s bank or credit card company doesn’t allow a response for this particular dispute. + */ + due_by: number; + + /** + * Whether or not the last evidence submission was submitted past the due date. Defaults to false + * if no evidence submissions have occurred. If true, then delivery of the latest evidence is not guaranteed. + */ + past_due: boolean; + }; + + /** + * If true, it is still possible to refund the disputed payment. Once the payment has been fully + * refunded, no further funds will be withdrawn from your Stripe account as a result of this dispute. + */ + is_charge_refundable: boolean; + metadata: IMetadata; + } + + interface IBankAccount { + id: string; + object: string; + + /** + * Two-letter ISO code representing the country the bank account is located in. + */ + country: string; + + /** + * Three-letter ISO currency code representing the currency paid out to the bank account. + */ + currency: string; + default_for_currency: boolean; + last4: string; + + /** + * Possible values are new, validated, verified, or errored. A bank account that hasn’t had any activity or validation performed + * is new. If Stripe can determine that the bank account exists, its status will be validated. Note that there often isn’t enough + * information to know (e.g. for smaller credit unions), and the validation is not always run. If the recipient or customer proves + * that they own the bank account (via microdeposit or login), the status will be verified. If a transfer sent to this bank account + * fails, we’ll set the status to errored and will not continue to send transfers until the bank details are updated. + */ + status: string; + + /** + * Name of the bank associated with the routing number, e.g. WELLS FARGO. + */ + bank_name: string; + + /** + * Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same. + */ + fingerprint: string; + + /** + * The routing transit number for the bank account. + */ + routing_number: string; + } + + interface IReversal { + id: string; + + /** + * Value is 'list' + */ + object: string; + + /** + * Amount reversed, in cents. + */ + amount: number; + created: number; + + /** + * Three-letter ISO currency code representing the currency. + */ + currency: string; + + /** + * Balance transaction that describes the impact of this reversal on your account balance. + */ + balance_transaction: string; + metadata: IMetadata; + + /** + * ID of the transfer that was reversed. + */ + transfer: string; + } + + interface IDisputeEvidence { + /** + * Any server or activity logs showing proof that the customer accessed or downloaded the purchased + * digital product. This information should include IP addresses, corresponding timestamps, and any + * detailed recorded activity. + */ + access_activity_log?: string; + + /** + * The billing addess provided by the customer. + */ + billing_address?: string; + + /** + * (ID of a file upload) Your subscription cancellation policy, as shown to the customer. + */ + cancellation_policy?: string; + + /** + * An explanation of how and when the customer was shown your refund policy prior to purchase. + */ + cancellation_policy_disclosure?: string; + + /** + * A justification for why the customer’s subscription was not canceled. + */ + cancellation_rebuttal?: string; + + /** + * (ID of a file upload) Any communication with the customer that you feel is relevant to your case (for + * example emails proving that they received the product or service, or demonstrating their use of or + * satisfaction with the product or service). + */ + customer_communication?: string; + + /** + * The email address of the customer. + */ + customer_email_address?: string; + + /** + * The name of the customer. + */ + customer_name?: string; + + /** + * The IP address that the customer used when making the purchase. + */ + customer_purchase_ip?: string; + + /** + * (ID of a file upload) A relevant document or contract showing the customer’s signature. + */ + customer_signature?: string; + + /** + * (ID of a file upload) Documentation for the prior charge that can uniquely identify the charge, + * such as a receipt, shipping label, work order, etc. This document should be paired with a similar + * document from the disputed payment that proves the two payments are separate. + */ + duplicate_charge_documentation?: string; + + /** + * An explanation of the difference between the disputed charge and the prior charge that appears to be a duplicate. + */ + duplicate_charge_explanation?: string; + + /** + * The Stripe ID for the prior charge which appears to be a duplicate of the disputed charge. + */ + duplicate_charge_id?: string; + + /** + * A description of the product or service which was sold. + */ + product_description?: string; + + /** + * (ID of a file upload) Any receipt or message sent to the customer notifying them of the charge. + */ + receipt?: string; + + /** + * (ID of a file upload) Your refund policy, as shown to the customer. + */ + refund_policy?: string; + + /** + * Documentation demonstrating that the customer was shown your refund policy prior to purchase. + */ + refund_policy_disclosure?: string; + + /** + * A justification for why the customer is not entitled to a refund. + */ + refund_refusal_explanation?: string; + + /** + * The date on which the customer received or began receiving the purchased service, in a clear human-readable format. + */ + service_date?: string; + + /** + * (ID of a file upload) Documentation showing proof that a service was provided to the customer. This could + * include a copy of a signed contract, work order, or other form of written agreement. + */ + service_documentation?: string; + + /** + * The address to which a physical product was shipped. You should try to include as much complete address information as possible. + */ + shipping_address?: string; + + /** + * The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc. If multiple carriers were used + * for this purchase, please separate them with commas. + */ + shipping_carrier?: string; + + /** + * The date on which a physical product began its route to the shipping address, in a clear human-readable format. + */ + shipping_date?: string; + + /** + * (ID of a file upload) Documentation showing proof that a product was shipped to the customer at the same address + * the customer provided to you. This could include a copy of the shipment receipt, shipping label, etc, and should + * show the full shipping address of the customer, if possible. + */ + shipping_documentation?: string; + + /** + * The tracking number for a physical product, obtained from the delivery service. If multiple tracking numbers + * were generated for this purchase, please separate them with commas. + */ + shipping_tracking_number?: string; + + /** + * (ID of a file upload) Any additional evidence or statements. + */ + uncategorized_file?: string; + + /** + * Any additional evidence or statements. + */ + uncategorized_text?: string; + } + + /** + * To safely retry an API request without accidentally performing the same operation twice, + * you can attach a unique key to any POST request made to the Stripe API via the Idempotency-Key: header. + * For example, if a request to create a charge fails due to a network connection error, you can make + * a second request with the same key to guarantee that only a single charge is created. + * The creation of the key is completely up to you — we suggest using random strings or UUIDs. + * We'll always send back the same response for requests made with the same key, even if you make the request + * with different request parameters. The keys expire after 24 hours. + */ + interface IIdempotentOptions { + idempotency_key: string; + } + + /** + * A set of key/value pairs that you can attach to a reversal. It can be useful for storing + * additional information about the reversal in a structured format. + */ + interface IMetadata extends Object { } + + interface IShippingInformation { + /** + * Shipping address. + */ + address: { + /** + * Address line 1 (Street address/PO Box/Company name) + */ + line1: string; + + /** + * Address line 2 (Apartment/Suite/Unit/Building) + */ + line2: string; + + /** + * City/Suburb/Town/Village + */ + city: string; + + /** + * State/Province/County + */ + state: string; + + /** + * Zip/Postal Code + */ + postal_code: string; + + /** + * 2-letter country code + */ + country: string; + }; + + /** + * Recipient name. + */ + name: string; + + /** + * The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc. + */ + carrier: string; + + /** + * Recipient phone (including extension). + */ + phone: string; + + /** + * The tracking number for a physical product, obtained from the delivery service. If multiple + * tracking numbers were generated for this purchase, please separate them with commas. + */ + tracking_number: string; + } + + + interface IList { + /** + * Value is 'list' + */ + object: string; + + data: Array; + + has_more: boolean; + + /** + * The URL where this list can be accessed. + */ + url: string; + + /** + * The total number of items available. This value is not included by default, + * but you can request it by specifying ?include[]=total_count + */ + total_count: number; + } + + interface IPaymentToken { + id: string; + card: { + name: string; + address_line1: string; + address_line2: string; + address_city: string; + address_state: string; + address_zip: string; + address_country: string; + country: string; + exp_month: number; + exp_year: number; + last4: string; + object: string; + brand: string; + funding: string; + }; + created: number; + livemode: boolean; + type: string; + object: string; + used: boolean; + } + + /** + * You can store multiple cards on a customer in order to charge the customer later. You + * can also store multiple debit cards on a recipient in order to transfer to those cards later. + */ + interface ICard { + /** + * ID of card (used in conjunction with a customer or recipient ID) + */ + id: string; + + /** + * Value is 'card' + */ + object: string; + + /** + * The card number + */ + 'number': number; + + /** + * Card brand. Can be Visa, American Express, MasterCard, Discover, JCB, Diners Club, or Unknown. + */ + brand: string; + exp_month: number; + exp_year: number; + + /** + * Card funding type. Can be credit, debit, prepaid, or unknown + */ + funding: string; + last4: string; + address_city: string; + + /** + * Billing address country, if provided when creating card + */ + address_country: string; + address_line1: string; + + /** + * If address_line1 was provided, results of the check: pass, fail, unavailable, or unchecked. + */ + address_line1_check: string; + address_line2: string; + address_state: string; + address_zip: string; + + /** + * If address_zip was provided, results of the check: pass, fail, unavailable, or unchecked. + */ + address_zip_check: string; + + /** + * Two-letter ISO code representing the country of the card. You could use this + * attribute to get a sense of the international breakdown of cards you’ve collected. + */ + country: string; + + /** + * The customer that this card belongs to. This attribute will not be in the card object + * if the card belongs to a recipient instead. + */ + customer: string; + + /** + * If a CVC was provided, results of the check: pass, fail, unavailable, or unchecked + */ + cvc_check: string; + + /** + * (For Apple Pay integrations only.) The last four digits of the device account number. + */ + dynamic_last4: string; + + /** + * Cardholder name + */ + name: string; + + /** + * The recipient that this card belongs to. This attribute will not be in the card object if + * the card belongs to a customer instead. + */ + recipient: string; + + /** + * Uniquely identifies this particular card number. You can use this attribute to check + * whether two customers who’ve signed up with you are using the same card number, for example. + */ + fingerprint: string; + } + + interface IListOptions { + /** + * A filter on the list based on the object created field. The value can be a string with an integer Unix timestamp, or it can + * be a dictionary. + */ + created?: string | IDateFilter; + + /** + * A filter on the list based on the object date field. The value can be a string with an integer Unix timestamp, + * or it can be a dictionary. + */ + date?: string | IDateFilter; + + /** + * Only return charges for the customer specified by this customer ID. + */ + customer?: string; + + /** + * A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make + * a list request and receive 100 objects, starting with obj_bar, your subsequent call can include ending_before=obj_bar in + * order to fetch the previous page of the list. + */ + ending_before?: string; + + /** + * A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + */ + limit?: number; + + /** + * A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make + * a list request and receive 100 objects, ending with obj_foo, your subsequent call can include starting_after=obj_foo in order + * to fetch the next page of the list. + */ + starting_after?: string; + } + + /** + * Stripe uses conventional HTTP response codes to indicate success or failure of an API request. + * In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that + * resulted from the provided information (e.g. a required parameter was missing, a charge failed, etc.), + * and codes in the 5xx range indicate an error with Stripe's servers. Not all errors map cleanly onto HTTP + * response codes, however. When a request is valid but does not complete successfully (e.g. a card is + * declined), we return a 402 error code. + * + * 200 - OK Everything worked as expected. + * 400 - Bad Request Often missing a required parameter. + * 401 - Unauthorized No valid API key provided. + * 402 - Request Failed Parameters were valid but request failed. + * 404 - Not Found The requested item doesn't exist. + * 500, 502, 503, 504 - Server Errors Something went wrong on Stripe's end. + */ + interface IStripeError { + /** + * The type of error returned. Can be invalid_request_error, api_error, or card_error. + * + * + * invalid_request_error Invalid request errors arise when your request has invalid parameters. + * + * api_error API errors cover any other type of problem (e.g. a temporary problem with Stripe's + * servers) and should turn up only very infrequently. + * + * card_error Card errors are the most common type of error you should expect to handle. They result + * when the user enters a card that can't be charged for some reason. + */ + type: string; + + /** + * A human-readable message giving more details about the error. For card errors, these messages can + * be shown to your users. + */ + message?: string; + + /** + * For card errors, a short string from amongst those listed on the right describing the kind of card + * error that occurred. + * + * incorrect_number The card number is incorrect. + * invalid_number The card number is not a valid credit card number. + * invalid_expiry_month The card's expiration month is invalid. + * invalid_expiry_year The card's expiration year is invalid. + * invalid_cvc The card's security code is invalid. + * expired_card The card has expired. + * incorrect_cvc The card's security code is incorrect. + * incorrect_zip The card's zip code failed validation. + * card_declined The card was declined. + * missing There is no card on a customer that is being charged. + * processing_error An error occurred while processing the card. + * rate_limit An error occurred due to requests hitting the API too + * quickly. Please let us know if you're consistently running + * into this error. + */ + code?: string; + + /** + * The parameter the error relates to if the error is parameter-specific. You can use this to display a + * message near the correct form field, for example. + */ + param?: string; + } +} From 32d8918a4e0d93753f4dc6ee469c1a7191cde4b7 Mon Sep 17 00:00:00 2001 From: Eirik Hoem Date: Wed, 8 Apr 2015 08:52:19 +0200 Subject: [PATCH 04/38] Added support for Calq --- calq/calq-test.ts | 28 ++++++++++++++++++++++++++++ calq/calq.d.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 calq/calq-test.ts create mode 100644 calq/calq.d.ts diff --git a/calq/calq-test.ts b/calq/calq-test.ts new file mode 100644 index 000000000..6f8019261 --- /dev/null +++ b/calq/calq-test.ts @@ -0,0 +1,28 @@ +/// +function calq_base() +{ + calq.init("bfff14a4e0225789be3d9d22c4bb42a1"); + + calq.init("bfff14a4e0225789be3d9d22c4bb42a1", { your: "config" }); + + calq.action.track("Product Review", {"Rating": 9.0}); + + calq.action.trackSale("Product Sale", { "Product Id": 149, "Product Name": "Dinosaur T-Shirt XL" }, "USD",10); + + calq.action.trackHTMLLink('Link', { 'Target': 'Calq'}); + + calq.action.trackPageView(); + + calq.action.trackPageView("Custom Action"); + + calq.action.setGlobalProperty("Referral Source", "Google Campaign"); +} + +function calq_people() +{ + calq.user.identify("1001"); + + calq.user.clear(); + + calq.user.profile( { "Company": "MegaCorp", "$email": "super_customer1@notarealemail.com" }); +} diff --git a/calq/calq.d.ts b/calq/calq.d.ts new file mode 100644 index 000000000..c574df58f --- /dev/null +++ b/calq/calq.d.ts @@ -0,0 +1,34 @@ +// Type definitions for calq +// Project: https://calq.io/docs/client/javascript/reference +// Definitions by: Eirik Hoem +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Calq +{ + action:Calq.Action; + user:Calq.User; + + init(writeKey:string, options?:{[index:string]:any}):void; +} + +declare module Calq +{ + interface Action + { + track(action:string, params?:{[index:string]:any}):void; + trackSale(action:string, params:{[index:string]:any}, currency:string, amount:number):void; + trackHTMLLink(action:string, params?:{[index:string]:any}):void; + trackPageView(action?:string):void; + setGlobalProperty(name:string,value:any):void; + } + + interface User + { + identify(userId:string):void; + clear():void; + profile(params:{[index:string]:any}):void; + + } +} + +declare var calq:Calq; \ No newline at end of file From a38e4d5cd28e1535d181ef951f471dbd68e10c33 Mon Sep 17 00:00:00 2001 From: Rob Hux Date: Wed, 8 Apr 2015 10:37:06 -0400 Subject: [PATCH 05/38] Update chosen.jquery.d.ts updated the options for chosen to be based on the chosen's latest release (1.4.2) --- chosen/chosen.jquery.d.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/chosen/chosen.jquery.d.ts b/chosen/chosen.jquery.d.ts index 890b4221e..1c9507339 100644 --- a/chosen/chosen.jquery.d.ts +++ b/chosen/chosen.jquery.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Chosen.JQuery 0.9 +// Type definitions for Chosen.JQuery 1.4.2 // Project: http://harvesthq.github.com/chosen/ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -8,18 +8,23 @@ interface ChosenOptions { allow_single_deselect?: boolean; - disable_search_threshold?: number; disable_search?: boolean; + disable_search_threshold?: number; + enable_split_word_search?: boolean; + inherit_select_classes?: boolean; + max_selected_options?: number; + no_results_text?: string; + placeholder_text_multiple?: string; + placeholder_text_single?: string; search_contains?: boolean; single_backstroke_delete?: boolean; - max_selected_options?: number; - placeholder_text_multiple?: string; - placeholder_text?: string; - placeholder_text_single?: string; - no_results_text?: string; + width?: number; + display_disabled_options?: boolean; + display_selected_options?: boolean; + include_group_label_in_selected?: boolean; } interface JQuery { chosen(): JQuery; chosen(options: ChosenOptions): JQuery; -} \ No newline at end of file +} From 4b2767c2871412c4e3c7c8c48e28fa362ee3ab32 Mon Sep 17 00:00:00 2001 From: a3chic9 Date: Wed, 8 Apr 2015 11:25:31 -0400 Subject: [PATCH 06/38] Update ng-grid.d.ts angular references from ng --- ng-grid/ng-grid.d.ts | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/ng-grid/ng-grid.d.ts b/ng-grid/ng-grid.d.ts index 3bb3b2daa..e35472865 100644 --- a/ng-grid/ng-grid.d.ts +++ b/ng-grid/ng-grid.d.ts @@ -30,9 +30,9 @@ declare module ngGrid { export interface IDomAccessProvider { previousColumn:IColumn; grid:IGridInstance; - changeUserSelect(elm:ng.IAugmentedJQuery, value:string):void; + changeUserSelect(elm:angular.IAugmentedJQuery, value:string):void; focusCellElement($scope:IGridScope, index:number):void; - selectionHandlers($scope:IGridScope, elm:ng.IAugmentedJQuery):void; + selectionHandlers($scope:IGridScope, elm:angular.IAugmentedJQuery):void; } export interface IStyleProviderStatic { @@ -43,7 +43,7 @@ declare module ngGrid { } export interface ISearchProviderStatic { - new($scope:IGridScope, grid:IGridInstance, $filter:ng.IFilterService):ISearchProvider; + new($scope:IGridScope, grid:IGridInstance, $filter:angular.IFilterService):ISearchProvider; } export interface ISearchProvider { @@ -53,7 +53,7 @@ declare module ngGrid { } export interface ISelectionProviderStatic { - new(grid:IGridInstance, $scope:IGridScope, $parse:ng.IParseService):ISelectionProvider; + new(grid:IGridInstance, $scope:IGridScope, $parse:angular.IParseService):ISelectionProvider; } export interface ISelectionProvider { @@ -62,7 +62,7 @@ declare module ngGrid { selectedIndex:number; lastClickedRow:any; ignoreSelectedItemChanges:boolean; - pKeyParser:ng.ICompiledExpression; + pKeyParser:angular.ICompiledExpression; ChangeSelection(rowItem:any, event:any):void; getSelection(entity:any):number; getSelectionIndex(entity:any):number; @@ -71,7 +71,7 @@ declare module ngGrid { } export interface IEventProviderStatic { - new(grid:IGridInstance, $scope:IGridScope, domUtilityService:service.IDomUtilityService, $timeout:ng.ITimeoutService):IEventProvider; + new(grid:IGridInstance, $scope:IGridScope, domUtilityService:service.IDomUtilityService, $timeout:angular.ITimeoutService):IEventProvider; } export interface IEventProvider { @@ -203,7 +203,7 @@ declare module ngGrid { } export interface IColumnStatic { - new(config:IGridOptions, $scope:IGridScope, grid:IGridInstance, domUtilityService:service.IDomUtilityService, $templateCache:ng.ITemplateCacheService, $utils:any):IColumn; + new(config:IGridOptions, $scope:IGridScope, grid:IGridInstance, domUtilityService:service.IDomUtilityService, $templateCache:angular.ITemplateCacheService, $utils:any):IColumn; } export interface IColumn { @@ -251,7 +251,7 @@ declare module ngGrid { setVars(fromCol:IColumn):void; } - export interface IGridScope extends ng.IScope { + export interface IGridScope extends angular.IScope { elementsNeedMeasuring:boolean; columns:any[]; renderedRows:any[]; @@ -292,15 +292,15 @@ declare module ngGrid { } export interface IGridInstance { - $canvas:ng.IAugmentedJQuery; - $viewport:ng.IAugmentedJQuery; - $groupPanel:ng.IAugmentedJQuery; - $footerPanel:ng.IAugmentedJQuery; - $headerScroller:ng.IAugmentedJQuery; - $headerContainer:ng.IAugmentedJQuery; - $headers:ng.IAugmentedJQuery; - $topPanel:ng.IAugmentedJQuery; - $root:ng.IAugmentedJQuery; + $canvas:angular.IAugmentedJQuery; + $viewport:angular.IAugmentedJQuery; + $groupPanel:angular.IAugmentedJQuery; + $footerPanel:angular.IAugmentedJQuery; + $headerScroller:angular.IAugmentedJQuery; + $headerContainer:angular.IAugmentedJQuery; + $headers:angular.IAugmentedJQuery; + $topPanel:angular.IAugmentedJQuery; + $root:angular.IAugmentedJQuery; config:IGridOptions; data:any; elementDims:IElementDimension; @@ -327,9 +327,9 @@ declare module ngGrid { configureColumnWidths():void; fixColumnIndexes():void; fixGroupIndexes():void; - getTemplate(key:string):ng.IPromise; - init():ng.IPromise; - initTemplates():ng.IPromise; + getTemplate(key:string):angular.IPromise; + init():angular.IPromise; + initTemplates():angular.IPromise; minRowsToRender():void; refreshDomSizes():void; resizeOnData(col:IColumn):void; @@ -379,7 +379,7 @@ declare module ngGrid { /** Data updated callback, fires every time the data is modified from outside the grid. */ dataUpdated?: Function; - /** Enables cell editing. */ + /** Enables cell editiangular. */ enableCellEdit?: boolean; /** Enables cell selection. */ @@ -400,7 +400,7 @@ declare module ngGrid { /** Enable column pinning */ enablePinning?: boolean; - /** Enable drag and drop row reordering. Only works in HTML5 compliant browsers. */ + /** Enable drag and drop row reorderiangular. Only works in HTML5 compliant browsers. */ enableRowReordering?: boolean; /** To be able to have selectable rows in grid. */ @@ -440,7 +440,7 @@ declare module ngGrid { /** Prevent unselections when in single selection mode. */ keepLastSelected?: boolean; - /** Maintains the column widths while resizing. + /** Maintains the column widths while resiziangular. Defaults to true when using *'s or undefined widths. Can be ovverriden by setting to false. */ maintainColumnRatios?: boolean; @@ -496,7 +496,7 @@ declare module ngGrid { /** Set the tab index of the Vieport. */ tabIndex?: number; - /** Prevents the internal sorting from executing. + /** Prevents the internal sorting from executiangular. The sortInfo object will be updated with the sorting information so you can handle sorting (see sortInfo)*/ useExternalSorting?: boolean; @@ -602,7 +602,7 @@ declare module ngGrid { eventStorage:any; numberOfGrids:number; immediate:number; - AssignGridContainers($scope:IGridScope, rootel:ng.IAugmentedJQuery, grid:IGridInstance):void; + AssignGridContainers($scope:IGridScope, rootel:angular.IAugmentedJQuery, grid:IGridInstance):void; getRealWidth(obj:IDimension):number; UpdateGridLayout($scope:IGridScope, grid:IGridInstance):void; setStyleText(grid:IGridInstance, css:string):void; From a1fe2dd7267d1a2183f48bd4c62e2533131af3d7 Mon Sep 17 00:00:00 2001 From: a3chic9 Date: Wed, 8 Apr 2015 11:32:25 -0400 Subject: [PATCH 07/38] Fixed errors in find ng. ang replace angular.. --- ng-grid/ng-grid.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ng-grid/ng-grid.d.ts b/ng-grid/ng-grid.d.ts index e35472865..0fb267faa 100644 --- a/ng-grid/ng-grid.d.ts +++ b/ng-grid/ng-grid.d.ts @@ -379,7 +379,7 @@ declare module ngGrid { /** Data updated callback, fires every time the data is modified from outside the grid. */ dataUpdated?: Function; - /** Enables cell editiangular. */ + /** Enables cell editing. */ enableCellEdit?: boolean; /** Enables cell selection. */ @@ -400,7 +400,7 @@ declare module ngGrid { /** Enable column pinning */ enablePinning?: boolean; - /** Enable drag and drop row reorderiangular. Only works in HTML5 compliant browsers. */ + /** Enable drag and drop row reordering. Only works in HTML5 compliant browsers. */ enableRowReordering?: boolean; /** To be able to have selectable rows in grid. */ @@ -440,7 +440,7 @@ declare module ngGrid { /** Prevent unselections when in single selection mode. */ keepLastSelected?: boolean; - /** Maintains the column widths while resiziangular. + /** Maintains the column widths while resizing. Defaults to true when using *'s or undefined widths. Can be ovverriden by setting to false. */ maintainColumnRatios?: boolean; @@ -496,7 +496,7 @@ declare module ngGrid { /** Set the tab index of the Vieport. */ tabIndex?: number; - /** Prevents the internal sorting from executiangular. + /** Prevents the internal sorting from executing. The sortInfo object will be updated with the sorting information so you can handle sorting (see sortInfo)*/ useExternalSorting?: boolean; From d203b4a67c6d8be4c8ecaf7a9c84f9e8c8b6e38c Mon Sep 17 00:00:00 2001 From: a3chic9 Date: Wed, 8 Apr 2015 11:47:42 -0400 Subject: [PATCH 08/38] Update ng-grid-tests.ts angular module Changed references from depreciated `ng` module to `angular` module --- ng-grid/ng-grid-tests.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ng-grid/ng-grid-tests.ts b/ng-grid/ng-grid-tests.ts index 82105ea5b..d8d153f28 100644 --- a/ng-grid/ng-grid-tests.ts +++ b/ng-grid/ng-grid-tests.ts @@ -63,7 +63,7 @@ selectionProvider.selectedItems = []; selectionProvider.selectedIndex = 1; selectionProvider.lastClickedRow = {}; selectionProvider.ignoreSelectedItemChanges = false; -selectionProvider.pKeyParser = {}; +selectionProvider.pKeyParser = {}; selectionProvider.ChangeSelection({}, {}); nr = selectionProvider.getSelection({}); nr = selectionProvider.getSelectionIndex({}); @@ -256,15 +256,15 @@ nr = gridScope.totalRowWidth(); a = gridScope.headerScrollerDim(); var gridInstance: ngGrid.IGridInstance = {}; -gridInstance.$canvas = {}; -gridInstance.$viewport = {}; -gridInstance.$groupPanel = {}; -gridInstance.$footerPanel = {}; -gridInstance.$headerScroller = {}; -gridInstance.$headerContainer = {}; -gridInstance.$headers = {}; -gridInstance.$topPanel = {}; -gridInstance.$root = {}; +gridInstance.$canvas = {}; +gridInstance.$viewport = {}; +gridInstance.$groupPanel = {}; +gridInstance.$footerPanel = {}; +gridInstance.$headerScroller = {}; +gridInstance.$headerContainer = {}; +gridInstance.$headers = {}; +gridInstance.$topPanel = {}; +gridInstance.$root = {}; gridInstance.config = {}; gridInstance.data = {}; gridInstance.elementDims = {}; @@ -290,7 +290,7 @@ gridInstance.clearSortingData(); gridInstance.configureColumnWidths(); gridInstance.fixColumnIndexes(); gridInstance.fixGroupIndexes(); -var p:ng.IPromise = gridInstance.getTemplate(''); +var p:angular.IPromise = gridInstance.getTemplate(''); p = gridInstance.init(); p = gridInstance.initTemplates(); gridInstance.minRowsToRender(); @@ -302,12 +302,12 @@ gridInstance.sortColumnsInit(); gridInstance.sortData({}, {}); var test_styleProvider:ngGrid.IStyleProvider = new ngStyleProvider({}, {}); -var test_searchProvider:ngGrid.ISearchProvider = new ngSearchProvider({}, {}, {}); -var test_selectionProvider:ngGrid.ISelectionProvider = new ngSelectionProvider({}, {}, {}); -var test_eventProvider:ngGrid.IEventProvider = new ngEventProvider({}, {}, {}, {}); +var test_searchProvider:ngGrid.ISearchProvider = new ngSearchProvider({}, {}, {}); +var test_selectionProvider:ngGrid.ISelectionProvider = new ngSelectionProvider({}, {}, {}); +var test_eventProvider:ngGrid.IEventProvider = new ngEventProvider({}, {}, {}, {}); var test_aggregate:ngGrid.IAggregate = new ngAggregate({}, {}, 10, true); var test_renderedRange:ngGrid.IRenderedRange = new ngRenderedRange(1, 2); var test_dimension:ngGrid.IDimension = new ngDimension({}); var test_row:ngGrid.IRow = new ngRow({}, {}, {}, 0, {}); -var test_column:ngGrid.IColumn = new ngColumn({}, {}, {}, {}, {}, {}); +var test_column:ngGrid.IColumn = new ngColumn({}, {}, {}, {}, {}, {}); var test_footer:ngGrid.IFooter = new ngFooter({}, {}); From 6baac1dca4751d5e0ba3dee0c0a9f43266fd74ae Mon Sep 17 00:00:00 2001 From: Jon Nyman Date: Wed, 8 Apr 2015 10:55:15 -0700 Subject: [PATCH 09/38] add isError property https://lodash.com/docs#isError --- lodash/lodash.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 426162e2e..55d35707f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5745,6 +5745,18 @@ declare module _ { **/ isEmpty(value: any): boolean; } + + //_.isError + interface LoDashStatic { + /** + * Checks if value is an Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, + * or URIError object. + * @param value The value to check. + * @return True if value is an error object, else false. + */ + isError(value: any): boolean; + } + //_.isEqual interface LoDashStatic { From a88024c770cc2692b1674b96be169b49b6068570 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 8 Apr 2015 11:35:43 -0700 Subject: [PATCH 10/38] Update breaking change from parsing class declaration in strict mode (as specified in ES6) --- backbone/backbone.d.ts | 2 +- ember/ember.d.ts | 18 +++++++++--------- marionette/marionette.d.ts | 4 ++-- node-azure/azure.d.ts | 4 ++-- winrt/winrt.d.ts | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 834ebc831..7de8eb807 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -238,7 +238,7 @@ declare module Backbone { initial(n: number): TModel[]; inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; isEmpty(object: any): boolean; - invoke(methodName: string, arguments?: any[]): any; + invoke(methodName: string, args?: any[]): any; last(): TModel; last(n: number): TModel[]; lastIndexOf(element: TModel, fromIndex?: number): number; diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 22cbb8ab5..636a7af68 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -444,7 +444,7 @@ declare module Ember { static metaForProperty(key: string): {}; static isClass: boolean; static isMethod: boolean; - static initializer(arguments?: ApplicationInitializerArguments): void; + static initializer(args?: ApplicationInitializerArguments): void; /** Call advanceReadiness after any asynchronous setup logic has completed. Each call to deferReadiness must be matched by a call to advanceReadiness @@ -1318,9 +1318,9 @@ declare module Ember { Creates an instance of the class. @param arguments A hash containing values with which to initialize the newly instantiated object. **/ - static create(arguments?: {}): T; + static create(args: {}): T; detect(obj: any): boolean; - reopen(arguments?: {}): T; + reopen(args?: {}): T; } class MutableArray implements Array, MutableEnumberable { addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; @@ -1581,17 +1581,17 @@ declare module Ember { /** Creates a subclass of the Object class. **/ - static extend(arguments?: CoreObjectArguments): T; - static extend(mixins? : Mixin, arguments?: CoreObjectArguments): T; + static extend(args?: CoreObjectArguments): T; + static extend(mixins? : Mixin, args?: CoreObjectArguments): T; /** Creates an instance of the class. @param arguments A hash containing values with which to initialize the newly instantiated object. **/ - static create(arguments?: {}): T; + static create(args?: {}): T; /** Equivalent to doing extend(arguments).create(). If possible use the normal create method instead. **/ - static createWithMixins(arguments?: {}): T; + static createWithMixins(args?: {}): T; static detect(obj: any): boolean; static detectInstance(obj: any): boolean; /** @@ -1608,13 +1608,13 @@ declare module Ember { Augments a constructor's prototype with additional properties and functions. To add functions and properties to the constructor itself, see reopenClass. **/ - static reopen(arguments?: {}): T; + static reopen(args?: {}): T; /** Augments a constructor's own properties and functions. To add functions and properties to instances of a constructor by extending the constructor's prototype see reopen. **/ - static reopenClass(arguments?: {}): T; + static reopenClass(args?: {}): T; static isClass: boolean; static isMethod: boolean; addObserver: ModifyObserver; diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index ee528b666..2b9b25635 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -38,7 +38,7 @@ declare module Backbone { include(value: any): boolean; initial(): View; initial(n: number): View[]; - invoke(methodName: string, arguments?: any[]): any; + invoke(methodName: string, args?: any[]): any; isEmpty(object: any): boolean; last(): View; last(n: number): View[]; @@ -533,7 +533,7 @@ declare module Marionette { * Calls the method named by methodName on each value in the collection. Any extra * arguments passed to invoke will be forwarded on to the method invocation. */ - invoke(methodName: string, arguments?: any[]): any; + invoke(methodName: string, args?: any[]): any; /** * Returns true if the RegionManager contains no regions. diff --git a/node-azure/azure.d.ts b/node-azure/azure.d.ts index 91c5c0bf0..7e52a8be3 100644 --- a/node-azure/azure.d.ts +++ b/node-azure/azure.d.ts @@ -832,8 +832,8 @@ declare module "azure" { whereKeys(partitionKey: string, rowKey: string): TableQuery; whereNextKeys(partitionKey: string, rowKey: string): TableQuery; where(condition: string, ...values: string[]): TableQuery; - and(condition: string, ...arguments: string[]): TableQuery; - or(condition: string, ...arguments: string[]): TableQuery; + and(condition: string, ...args: string[]): TableQuery; + or(condition: string, ...args: string[]): TableQuery; top(integer: number): TableQuery; toQueryObject(): any; toPath(): string; diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index 91c0a2801..883860b00 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -12203,8 +12203,8 @@ declare module Windows { createWithId(tileId: string): Windows.UI.StartScreen.SecondaryTile; } export class SecondaryTile implements Windows.UI.StartScreen.ISecondaryTile { - constructor(tileId: string, shortName: string, displayName: string, arguments: string, tileOptions: Windows.UI.StartScreen.TileOptions, logoReference: Windows.Foundation.Uri); - constructor(tileId: string, shortName: string, displayName: string, arguments: string, tileOptions: Windows.UI.StartScreen.TileOptions, logoReference: Windows.Foundation.Uri, wideLogoReference: Windows.Foundation.Uri); + constructor(tileId: string, shortName: string, displayName: string, args: string, tileOptions: Windows.UI.StartScreen.TileOptions, logoReference: Windows.Foundation.Uri); + constructor(tileId: string, shortName: string, displayName: string, args: string, tileOptions: Windows.UI.StartScreen.TileOptions, logoReference: Windows.Foundation.Uri, wideLogoReference: Windows.Foundation.Uri); constructor(tileId: string); constructor(); arguments: string; From 8c675ecf28c6625797711b9db5207c04182e1224 Mon Sep 17 00:00:00 2001 From: Markus Peloso Date: Wed, 8 Apr 2015 21:47:29 +0200 Subject: [PATCH 11/38] Add type definitions for sweetalert. The type definitons is based on the docs and code. --- sweetalert/sweetalert-tests.ts | 93 +++++++++++++++++ sweetalert/sweetalert.d.ts | 181 +++++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+) create mode 100644 sweetalert/sweetalert-tests.ts create mode 100644 sweetalert/sweetalert.d.ts diff --git a/sweetalert/sweetalert-tests.ts b/sweetalert/sweetalert-tests.ts new file mode 100644 index 000000000..1ccb93ba3 --- /dev/null +++ b/sweetalert/sweetalert-tests.ts @@ -0,0 +1,93 @@ +/// + +// A basic message +swal("Here's a message!"); + +// A title with a text under +swal("Here's a message!", "It's pretty, isn't it?"); + +// A success message! +swal("Good job!", "You clicked the button!", "success"); + +// A warning message, with a function attached to the "Confirm"-button... +swal({ + title: "Are you sure?", + text: "You will not be able to recover this imaginary file!", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "Yes, delete it!", + closeOnConfirm: false +}, + function () { + swal("Deleted!", "Your imaginary file has been deleted.", "success"); + }); + +// ... and by passing a parameter, you can execute something else for "Cancel". +swal({ + title: "Are you sure?", + text: "You will not be able to recover this imaginary file!", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "Yes, delete it!", + cancelButtonText: "No, cancel plx!", + closeOnConfirm: false, + closeOnCancel: false +}, + function (isConfirm) { + if (isConfirm) { + swal("Deleted!", "Your imaginary file has been deleted.", "success"); + } else { + swal("Cancelled", "Your imaginary file is safe :)", "error"); + } + }); + +// A message with a custom icon +swal({ + title: "Sweet!", + text: "Here's a custom image.", + imageUrl: "images/thumbs-up.jpg" +}); + +// An HTML message +swal({ + title: "HTML Title!", + text: "A custom html message.", + html: true +}); + +// A message with auto close timer +swal({ + title: "Auto close alert!", + text: "I will close in 2 seconds.", + timer: 2000, + showConfirmButton: false +}); + +// A replacement for the "prompt" function +swal({ + title: "An input!", + text: "Write something interesting:", + type: "input", + showCancelButton: true, + closeOnConfirm: false, + animation: "slide-from-top" +}, + function (inputValue) { + if (inputValue === false) return false; + + if (inputValue === "") { + swal.showInputError("You need to write something!"); + return false; + } + + swal("Nice!", "You wrote: " + inputValue, "success"); + } + ); + +swal.setDefaults({ confirmButtonColor: "#000000" }); + +swal.close(); + +swal.showInputError("Invalid email!"); \ No newline at end of file diff --git a/sweetalert/sweetalert.d.ts b/sweetalert/sweetalert.d.ts new file mode 100644 index 000000000..d5b4cd607 --- /dev/null +++ b/sweetalert/sweetalert.d.ts @@ -0,0 +1,181 @@ +// Type definitions for SweetAlert 0.5.0 +// Project: https://github.com/t4t5/sweetalert/ +// Definitions by: Markus Peloso +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var sweetAlert: SweetAlert.SweetAlertStatic; +declare var swal: SweetAlert.SweetAlertStatic; + +declare module "sweetalert" { + export = swal; +} + +declare module SweetAlert { + interface SettingsBase { + /** + * A description for the modal. + * Default: null + */ + text?: string; + + /** + * The type of the modal. SweetAlert comes with 4 built-in types which will show a corresponding icon animation: "warning", "error", "success" and "info". You can also set it as "input" to get a prompt modal. + * Default: null + */ + type?: string; + + /** + * If set to true, the user can dismiss the modal by pressing the Escape key. + * Default: true + */ + allowEsxcapeKey?: boolean; + + /** + * A custom CSS class for the modal. + * Default: null + */ + customClass?: string; + + /** + * If set to true, the user can dismiss the modal by clicking outside it. + * Default: false + */ + allowOutsideClick?: boolean; + + /** + * If set to true, a "Cancel"-button will be shown, which the user can click on to dismiss the modal. + * Default: false + */ + showCancelButton?: boolean; + + /** + * If set to false, the "OK/Confirm"-button will be hidden. Make sure you set a timer or set allowOutsideClick to true when using this, in order not to annoy the user. + * Default: true + */ + showConfirmButton?: boolean; + + /** + * Use this to change the text on the "Confirm"-button. If showCancelButton is set as true, the confirm button will automatically show "Confirm" instead of "OK". + * Default: "OK" + */ + confirmButtonText?: string; + + /** + * Use this to change the background color of the "Confirm"-button (must be a HEX value). + * Default: "#AEDEF4" + */ + confirmButtonColor?: string; + + /** + * Use this to change the text on the "Cancel"-button. + * Default: "Cancel" + */ + cancelButtonText?: string; + + /** + * Set to false if you want the modal to stay open even if the user presses the "Confirm"-button. This is especially useful if the function attached to the "Confirm"-button is another SweetAlert. + * Default: true + */ + closeOnConfirm?: boolean; + + /** + * Add a customized icon for the modal.Should contain a string with the path to the image. + * Default: null + */ + imageUrl?: string; + + /** + * If imageUrl is set, you can specify imageSize to describes how big you want the icon to be in px. Pass in a string with two values separated by an "x". The first value is the width, the second is the height. + * Default: "80x80" + */ + imageSize?: string; + + /** + * Auto close timer of the modal.Set in ms (milliseconds). + * Default: null + */ + timer?: number; + + /** + * If set to true, will not escape title and text parameters. (Set to false if you're worried about XSS attacks.) + * Default: false + */ + html?: boolean; + + /** + * If set to false, the modal's animation will be disabled. Possible animations: "slide-from-top", "slide-from-bottom", "pop" (use true instead) and "none" (use false instead). + * Default: true, "pop" + */ + animation?: boolean | string; + + /** + * Change the type of the input field when using type: "input" (this can be useful if you want users to type in their password for example). + * Default: "text" + */ + inputType?: string; + } + + interface Settings extends SettingsBase { + /** + * The title of the modal. + */ + title: string; + } + + interface SetDefaultsSettings extends SettingsBase { + /** + * The title of the modal. + * Default: null + */ + title?: string; + } + + /** + * Is true or false if the user confirms or cancels the alert. Except for the type "input", then when the user confirms the alert, this variable contains the value of the input element. + */ + type CallbackArgument = boolean | string; + + interface SweetAlertStatic { + /** + * SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. An awesome replacement for JavaScript's alert. + * @param title The title of the modal. + */ + (title: string): void; + + /** + * SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. An awesome replacement for JavaScript's alert. + * @param title The title of the modal. + * @param text A description for the modal. + */ + (title: string, text: string): void; + + /** + * SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. An awesome replacement for JavaScript's alert. + * @param title The title of the modal. + * @param text A description for the modal. + * @param type The type of the modal. SweetAlert comes with 4 built-in types which will show a corresponding icon animation: "warning", "error", "success" and "info". You can also set it as "input" to get a prompt modal. + */ + (title: string, text: string, type: string): void; + + /** + * SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. An awesome replacement for JavaScript's alert. + * @param callback The callback from the users action. The value is true or false if the user confirms or cancels the alert. Except for the type "input", then when the user confirms the alert, the argument contains the value of the input element. + */ + (settings: Settings, callback?: (isConfirmOrInputValue: CallbackArgument) => any): void; + + /** + * If you end up using a lot of the same settings when calling SweetAlert, you can use setDefaults at the start of your program to set them once and for all! + */ + setDefaults(settings: SetDefaultsSettings): void; + + /** + * Close the currently open SweetAlert programmatically. + */ + close(): void; + + /** + * Show an error message after validating the input field, if the user's data is bad. + */ + showInputError(errorMessage: string): void; + } +} \ No newline at end of file From 74c2024d34e0e0ec791df6880dd38e20367c8a00 Mon Sep 17 00:00:00 2001 From: Tom Hasner Date: Wed, 8 Apr 2015 16:44:23 -0400 Subject: [PATCH 12/38] replacing old less.d.ts definitions to match new APIs --- less/less-tests.ts | 33 +-- less/less.d.ts | 591 +++++---------------------------------------- 2 files changed, 61 insertions(+), 563 deletions(-) diff --git a/less/less-tests.ts b/less/less-tests.ts index a984306ee..71dfbae76 100644 --- a/less/less-tests.ts +++ b/less/less-tests.ts @@ -2,33 +2,12 @@ import less = require("less"); -declare var __dirname: string; - -less.render('.class { width: (1 + 1) }', (e, css) => console.log(css)); - -var parser: less.Parser = new less.Parser; - -parser.parse('.class { width: (1 + 1) }', function (err, tree) { - if (err) return console.error(err); - tree.toCSS(); +less.render(".class { width: (1 + 1) }").then((output) => { + console.log(output.css); }); -var parser2 = new less.Parser({ - paths: ['.', './lib'], - filename: 'style.less' +less.render("fail").then((output) => { + throw new Error("promise should have been rejected"); +}, () => { + console.log("rejected as expected"); }); - -parser2.parse('.class { width: (1 + 1) }', (e, tree) => tree.toCSS({ compress: true })); - -var lessParser = new less.Parser({ - paths: [__dirname], - filename: "out.less" -}); - -lessParser.parse('.class { width: (1 + 1) }', function (err, tree) { - tree.rules.forEach(function (rule) { - if (rule.path) { - console.log(rule.path); - } - }); -}); \ No newline at end of file diff --git a/less/less.d.ts b/less/less.d.ts index 4c096525d..2c10ce50e 100644 --- a/less/less.d.ts +++ b/less/less.d.ts @@ -1,556 +1,75 @@ // Type definitions for LESS // Project: http://lesscss.org/ -// Definitions by: AndrewGaspar +// Definitions by: Tom Hasner // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module less { - class LessError { - constructor(e: Error, env); +declare module Less { + // Promise definitions from ../es6-promise/es6-promise.d.ts + interface Thenable { + then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; + } - type: any; - message: string; + class Promise implements Thenable { + constructor(callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void); + + then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; + + catch(onRejected?: (error: any) => U | Thenable): Promise; + + finally(finallyCallback: () => any): Promise; + } + + interface RootFileInfo { filename: string; - index; - line: number; - callLine: number; - callExtract; - stack; - column; - extract: any[]; + relativeUrls: boolean; + rootpath: string; + currentDirectory: string; + entryPath: string; + rootFilename: string; + } + + class PluginManager { + constructor(less: LessStatic); + } + + interface Plugin { + install: (less: LessStatic, pluginManager: PluginManager) => void; + } + + interface SourceMapOption { + sourceMapURL: string; + sourceMapBasepath: string; + sourceMapRootpath: string; + outputSourceFiles: boolean; + sourceMapFileInline: boolean; } interface Options { - contents?; - rootpath?: string; - files?; - paths?: string[]; - mime?: string; + sourceMap?: SourceMapOption; filename?: string; - optimization?: number; - dumpLineNumbers?: boolean; - strictImports?; - entryPath?: string; - relativeUrls?; - errback? (path: string, paths: string[], callback: Function, env: Options); - frames?; - compress?: boolean; + plugins: Plugin[]; + rootFileInfo?: RootFileInfo; } - export module tree { - export module mixin { // TODO - export class Call { - - } - - export class Definition extends Ruleset { - - } - } - - export module functions { - export function rgb(r: number, g: number, b: number): Color; - export function rgba(r: number, g: number, b: number, a: number): Color; - export function hsl(h: number, s?: number, l?: number): Color; - export function hsla(h: number, s?: number, l?: number, a?: number): Color; - export function hsv(h: number, s: number, v: number): Color; - export function hsva(h: number, s: number, v: number, a: number): Color; - export function hue(color: Color): Dimension; - export function saturation(color: Color): Dimension; - export function lightness(color: Color): Dimension; - export function red(color: Color): Dimension; - export function green(color: Color): Dimension; - export function blue(color: Color): Dimension; - export function alpha(color: Color): Dimension; - export function luma(color: Color): Dimension; - export function saturate(color: Color, amount: IValuableNumber): Color; - export function desaturate(color: Color, amount: IValuableNumber): Color; - export function lighten(color: Color, amount: IValuableNumber): Color; - export function darken(color: Color, amount: IValuableNumber): Color; - export function fadein(color: Color, amount: IValuableNumber): Color; - export function fadeout(color: Color, amount: IValuableNumber): Color; - export function fade(color: Color, amount: IValuableNumber): Color; - export function spin(color: Color, amount: IValuableNumber): Color; - export function mix(color1: Color, color2: Color, weight: Dimension): Color; - export function greyscale(color: Color): Color; - export function contrast(color: Color, dark?: Color, light?: Color, threshold?: IValuableNumber): Color; - export function contrast(color: Color, dark?: Color, light?: Color, threshold?: number): Color; - export function e(str: string): Anonymous; - export function e(str: JavaScript): Anonymous; - export function escape(str: IValuableString): Anonymous; - export function unit(val: IValuableNumber, unit?: ICSSable): Dimension; - export function round(n: Dimension, f?: IValuableNumber): Dimension; - export function round(n: number, f?: IValuableNumber): number; - export function ceil(n: number): number; - export function ceil(n: Dimension): Dimension; - export function floor(n: number): number; - export function floor(n: Dimension): Dimension; - export function argb(color: Color): Anonymous; - export function percentage(n: IValuableNumber): Dimension; - export function color(n: Quoted): Color; - export function iscolor(n): Keyword; - export function isnumber(n): Keyword; - export function isstring(n): Keyword; - export function iskeyword(n): Keyword; - export function isurl(n): Keyword; - export function ispixel(n): Keyword; - export function ispercentage(n): Keyword; - export function isem(n): Keyword; - export function multiply(color1: Color, color2: Color): Color; - export function screen(color1: Color, color2: Color): Color; - export function overlay(color1: Color, color2: Color): Color; - export function softlight(color1: Color, color2: Color): Color; - export function hardlight(color1: Color, color2: Color): Color; - export function difference(color1: Color, color2: Color): Color; - export function exclusion(color1: Color, color2: Color): Color; - export function average(color1: Color, color2: Color): Color; - export function negation(color1: Color, color2: Color): Color; - export function tint(color: Color, amount: Dimension): Color; - export function shade(color: Color, amount: Dimension): Color; - } - - export var colors: any; // Could be module - got lazy - - interface HasDebugInfo { - debugInfo: DebugInfo; - } - - interface DebugInfo { - lineNumber; - fileName: string; - } - - interface HSL { - h: number; - s: number; - l: number; - a: number; - } - - interface DebugInfoFunction { - (env: Options, ctx: HasDebugInfo): string; - asComment(ctx: HasDebugInfo): string; - asMediaQuery(ctx: HasDebugInfo): string; - } - - interface RuleContainer { - [name: string]: Rule; - } - - interface ICSSable { - toCSS(ctx?, env?: Options): string; - } - - interface IEvalable { - eval(env: Options): IEvalable; - } - - interface IInjectable extends ICSSable, IEvalable {} - - interface IOperable { - operate(op: Operation, other: IOperable): IOperable; - } - - interface IComparable { - compare(x: IComparable): number; - } - - interface IColorable { - toColor(): Color; - } - - interface IValuableNumber { - value: number; - } - - interface IValuableString { - value: string; - } - - export class Color implements IOperable, IInjectable, IComparable { - constructor(rgb: string, a: number); - constructor(rgb: number[], a: number); - - rgb: number[]; - alpha: number; - eval(): Color; - toCSS(): string; - operate(op: Operation, other: Color): Color; - operate(op: Operation, other: IColorable): Color; - toHSL(): HSL; - toARGB(): string; - compare(x: Color): number; - } - - export class Directive implements IInjectable { - constructor(name, value); - - name; - value: ICSSable; - ruleset: Ruleset; - - toCSS(ctx?, env?: Options): string; - eval(env: Options): Directive; - - variable(name); - find(); - rulesets(); - } - - export class Operation implements IEvalable { - constructor(op, operands); - - op: string; - operands: IEvalable; - - eval(env: Options): IEvalable; - - operate(op: string, a: number, b: number): number; - } - - export class Dimension implements IColorable, IInjectable, IOperable, IComparable { - constructor(value: number, unit: string); - - value: number; - unit: string; - - eval(): Dimension; - toColor(): Color; - toCSS(): string; - operate(op: Operation, other: Dimension): Dimension; - compare(other: IComparable): number; - } - - export class Keyword implements IInjectable, IComparable { - constructor(value: string); - - value: string; - - eval(): Keyword; - toCSS(): string; - compare(other: IComparable): number; - - static True: Keyword; - static False: Keyword; - } - - export class Variable implements IEvalable { - constructor(name: string, index, file: string); - - name: string; - index; - file: string; - - eval(env: Options): IEvalable; - } - - export class AbstractRuleset implements IEvalable { - selectors: Selector[]; - rules: any[]; - strictImports; - - eval(env: Options): Ruleset; - evalImports(env: Options): void; - makeImportant(): Ruleset; - matchArgs(args: any): boolean; - resetCache(): void; - variables(): RuleContainer; - variable(): Rule; - rulesets(): Ruleset[]; - find(selector: Selector, self: Rule): Rule[]; - joinSelectors(paths: string[], context: any[][], selectors: Selector[]): void; - joinSelector(paths: string[], context: any[][], selector: Selector): void; - mergeElementsOnToSelectors(elements: Element[], selectors: Selector[]): void; - } - - export class Ruleset extends AbstractRuleset { - constructor(selectors: Selector[], rules: Rule[], strictImports); - - toCSS(context?: any[][], env?: Options): string; - } - - export class Element implements IInjectable { - constructor(combinator: Combinator, value, index); - - combinator: Combinator; - value; - index; - - eval(env: Options): Element; - toCSS(env?: Options): string; - } - - export class Combinator implements ICSSable { - constructor(value: string); - - value: string; - - toCSS(env?: Options): string; - } - - export class Selector implements IInjectable { - constructor(elements: Element[]); - - match(other: Selector): boolean; - eval(env: Options): Selector; - toCSS(env?: Options): string; - } - - export class Quoted implements IInjectable, IComparable { - constructor(str: string, content: string, escaped: boolean, i); - - escaped: boolean; - value: string; - quote: string; - index; - - toCSS(): string; - eval(env: Options): Quoted; - compare(x: IComparable): number; - } - - export class Expression implements IInjectable { - constructor(value: IEvalable[]); - - value: IEvalable[]; - - eval(env: Options): IEvalable; - toCSS(env?: Options): string; - } - - export class Rule implements IInjectable { - constructor(name: string, value?: Value, important?: string, index?, inline?: boolean); - - name: string; - value: Value; - important: string; - index; - inline: boolean; - - toCSS(env?: Options): string; - eval(context): Rule; - - makeImportant(): Rule; - } - - export class Shorthand implements IInjectable { - constructor(a: ICSSable, b: ICSSable); - - a: ICSSable; - b: ICSSable; - - toCSS(env?: Options): string; - eval(): Shorthand; - } - - export class Call implements IInjectable { - constructor(name: string, args: IEvalable[], index, filename: string); - - name: string; - args: IEvalable[]; - index; - filename: string; - - eval(env: Options): IEvalable; - toCSS(env?: Options): string; - } - - export class URL implements IInjectable { - constructor(val, rootpath: string); - - value; - rootpath: string; - - toCSS(): string; - eval(ctx): URL; - } - - export class Alpha implements IInjectable { - constructor(val); - - value; - - toCSS(): string; - eval(env: Options): Alpha; - } - - export class Import implements IInjectable { - constructor(path, imports, features: ICSSable, once: boolean, index, rootpath); - - once: boolean; - index; - features: ICSSable; - rootpath; - path: string; - css: boolean; - - toCSS(env?: Options): string; - eval(env: Options): IEvalable; - } - - export class Comment implements IInjectable { - constructor(value: string, silent); - - value: string; - silent: boolean; - - toCSS(env?: Options): string; - eval(): Comment; - } - - export class Anonymous implements IInjectable, IComparable { - constructor(value: string); - - value: string; - - toCSS(): string; - eval(): Anonymous; - compare(x): number; - } - - export class Value implements IInjectable { - constructor(value: IEvalable[]); - - value: IEvalable[]; - is: string; - - eval(env: Options): IEvalable; - toCSS(env?: Options): string; - } - - export class JavaScript implements IEvalable { - constructor(expression: string, index, escaped: boolean); - - escaped: boolean; - expression: string; - index; - - eval(env: Options): IEvalable; - } - - export class Assignment implements IInjectable { - constructor(key: string, val); - constructor(key: string, val: ICSSable); - constructor(key: string, val: IEvalable); - - key: string; - value; - - toCSS(): string; - eval(env: Options): Assignment; - } - - export class Condition { - constructor(op: string, l, r, i, negate: boolean); - - op: string; - lvalue; - rvalue; - index; - negate: boolean; - - eval(env: Options): boolean; - } - - export class Paren implements IInjectable { - constructor(node: IInjectable); - value: IInjectable; - - toCSS(env?: Options): string; - eval(env: Options): Paren; - } - - export class Media implements IInjectable { - constructor(value, features); - - selectors: Selector[]; - features: Value; - ruleset: Ruleset; - - toCSS(ctx?, env?: Options): string; - eval(env: Options): IEvalable; - - variable(name): Rule; - rulesets(): Ruleset[]; - find(selector: Selector, self: Rule): Rule[]; - - emptySelectors(): Selector[]; - evalTop(env: Options): IEvalable; - evalNested(env: Options): Ruleset; - permute(arr: any[]): any[]; - bubbleSelectors(selectors: Selector[]): void; - } - - export class Ratio implements IInjectable { - constructor(value: string); - - value: string; - - toCSS(env?: Options): string; - eval(): Ratio; - } - - export class UnicodeDescriptor implements IInjectable { - constructor(value: string); - - value: string; - - toCSS(env?: Options): string; - eval(): UnicodeDescriptor; - } - - export class Attribute implements IInjectable { - constructor(value: string); - - value: string; - - toCSS(env?: Options): string; - genCSS(env: Options, output): string; - eval(): Attribute; - } - - export var debugInfo: DebugInfoFunction; - export function find(obj: any[], fun: Function): any; - export function jsify(obj: any): string; - export function operate(op: string, a: number, b: number): number; - - export var True: Keyword; - export var False: Keyword; + interface RenderOutput { + css: string; + map: string; + imports: string[]; } +} - class ParserNode extends tree.AbstractRuleset { - toCSS(): string; - toCSS(options: { compress: boolean; }, variables?): string; - } +interface LessStatic { + render(input: string, callback: (output: Less.RenderOutput) => void): void; + render(input: string, options: Less.Options, callback: (output: Less.RenderOutput) => void): void; - export class Parser { - constructor(env?: Options); + render(input: string): Less.Promise; + render(input: string, options: Less.Options): Less.Promise; - imports: { - paths: string[]; - queue: string[]; - files; - contents; - mime: string; - error; - push(path: string, callback: (e, root, imported) => void); - }; // TODO - - parse: (str: string, callback: (error: LessError, root: ParserNode) => void ) => void; - - parsers: { // Major TODO - }; - } - - export function render(input: string, callback: (e, css: string) => void): void; - export function render(input: string, options: Options, - callback: (e, css: string) => void): void; - - export function formatError(ctx, options: { color: boolean; }): string; - export function writeError(ctx, options: { color: boolean; }): void; - - export var version: number[]; + version: number[]; } declare module "less" { - export = less; + export = less; } + +declare var less: LessStatic; From 9e0dc3d3625cfc9d9186101f76f1d944d8b3a44f Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 9 Apr 2015 01:30:48 -0300 Subject: [PATCH 13/38] Add type definitions for less-middleware --- less-middleware/less-middleware-tests.ts | 28 ++++++ less-middleware/less-middleware.d.ts | 108 +++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 less-middleware/less-middleware-tests.ts create mode 100644 less-middleware/less-middleware.d.ts diff --git a/less-middleware/less-middleware-tests.ts b/less-middleware/less-middleware-tests.ts new file mode 100644 index 000000000..0a84203b6 --- /dev/null +++ b/less-middleware/less-middleware-tests.ts @@ -0,0 +1,28 @@ +/// + +import express = require('express'); +import lessMiddleware = require('less-middleware'); +var app = express(); + +app.use(lessMiddleware('public', { + cacheFile: null, + debug: false, + dest: 'dest', + force: false, + once: false, + pathRoot: 'root', + postprocess: { + css: function(css, req) { return css; }, + }, + preprocess: { + less: function(src, req) { return src; }, + path: function(pathname, req) { return pathname; }, + importPaths: function(paths, req) { return paths; } + }, + render: { + compress: 'auto', + yuicompress: false, + paths: ['foo', 'bar'] + }, + storeCss: function(css, req, next) {}, +})); diff --git a/less-middleware/less-middleware.d.ts b/less-middleware/less-middleware.d.ts new file mode 100644 index 000000000..ee0e0069d --- /dev/null +++ b/less-middleware/less-middleware.d.ts @@ -0,0 +1,108 @@ +// Type definitions for less-middleware 2.0.1 +// Project: https://github.com/emberfeather/less.js-middleware +// Definitions by: Federico Bond +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* =================== USAGE =================== + + import lessMiddleware = require('less-middleware'); + app.use(lessMiddleware(source, options)); + + =============================================== */ + +/// + +declare module "less-middleware" { + import express = require('express'); + + /** + * Middleware created to allow processing of Less files for Connect JS framework + * and by extension the Express JS framework + */ + function lessMiddleware(source: string, options?: { + /** + * Show more verbose logging? + */ + debug?: boolean; + + /** + * Destination directory to output the compiled .css files. + */ + dest?: string; + + /** + * Always re-compile less files on each request. + */ + force?: boolean; + + /** + * Only recompile once after each server restart. + * Useful for reducing disk i/o on production. + */ + once?: boolean; + + /** + * Common root of the source and destination. + * It is prepended to both the source and destination before being used. + */ + pathRoot?: string; + + /** + * Object containing functions relevant to preprocessing data. + */ + postprocess?: { + + /** + * Function that modifies the compiled css output before being stored. + */ + css?(css: string, req: express.Request): string; + }; + + /** + * Object containing functions relevant to preprocessing data. + */ + preprocess?: { + + /** + * Function that modifies the raw less output before being parsed and compiled. + */ + less?(css: string, req: express.Request): string; + + /** + * Function that modifies the less pathname before being loaded from the filesystem. + */ + path?(pathname: string, req: express.Request): string; + + /** + * Function that modifies the import paths used by the less parser per request. + */ + importPaths?(paths: string[], req: express.Request): string[]; + }; + + /** + * Options for the less render. + */ + render?: { + + compress?: string; + yuicompress?: boolean; + paths?: string[]; + }; + + /** + * Function that is in charge of storing the css in the filesystem. + */ + storeCss?(pathname: string, css: string, req: express.Request, next: Function): void; + + /** + * Path to a JSON file that will be used to cache less data across server restarts. + * This can greatly speed up initial load time after a server restart - if the less + * files haven't changed and the css files still exist, specifying this option will + * mean that the less files don't need to be recompiled after a server restart. + */ + cacheFile?: string; + + }): express.RequestHandler; + + export = lessMiddleware; +} From 3143ec8f581b29a7ada1b331003ceabb5f3cc48a Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 9 Apr 2015 02:53:01 -0300 Subject: [PATCH 14/38] Add type definitions for express-debug --- express-debug/express-debug-tests.ts | 21 +++++++ express-debug/express-debug.d.ts | 83 ++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 express-debug/express-debug-tests.ts create mode 100644 express-debug/express-debug.d.ts diff --git a/express-debug/express-debug-tests.ts b/express-debug/express-debug-tests.ts new file mode 100644 index 000000000..6f702856e --- /dev/null +++ b/express-debug/express-debug-tests.ts @@ -0,0 +1,21 @@ +/// + +import express = require('express'); +import debug = require('express-debug'); +var app = express(); + +debug(app, { + depth: 4, + theme: 'public/css/debug.css', + extra_panels: [{ + name: 'mypanel', + template: '/absolute/path/to/mypanel.jade', + process: function(locals) { + return { locals: { mypanel: true, }}; + } + }], + panels: ['locals', 'request', 'session'], + path: '/express-debug', + extra_attrs: '', + sort: false, +}); diff --git a/express-debug/express-debug.d.ts b/express-debug/express-debug.d.ts new file mode 100644 index 000000000..d185f5c69 --- /dev/null +++ b/express-debug/express-debug.d.ts @@ -0,0 +1,83 @@ +// Type definitions for express-debug 1.1.1 +// Project: https://github.com/devoidfury/express-debug +// Definitions by: Federico Bond +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* =================== USAGE =================== + + import debug = require('express-debug'); + debug(app, options); + + =============================================== */ + +/// + +declare module "express-debug" { + import express = require('express'); + + interface CustomPanel { + name: string; + + template: string; + + process(locals: any): any; + + standalone?: boolean; + + initialize?(req: express.Request): void; + + finalize?(req: express.Request): void; + + pre_render?(req: express.Request): void; + + post_render?(req: express.Request): void; + + options?: any; + } + + /** + * Node.js middleware for serving a favicon. + */ + function debug(app: express.Application, settings?: { + /** + * How deep to recurse through printed objects. This is the default unless the + * print_obj function is passed an options object with a 'depth' property. + */ + depth?: number; + + /** + * Absolute path to a css file to include and override EDT's default css. + */ + theme?: string; + + /** + * Additional panels to show. + */ + extra_panels?: CustomPanel[]; + + /** + * Allows changing the default panel. + */ + panels?: string[]; + + /** + * Path to render standalone express-debug. + */ + path?: string; + + /** + * If you need to add arbitrary attributes to the containing element of EDT, + * this allows you to. + */ + extra_attrs?: string; + + /** + * Global option to determine sort order of printed object values. false for + * default order, true for basic default sort, or a function to use for sort. + */ + sort?: boolean | ((a: number, b: number) => number); + + }): void; + + export = debug; +} From f3205f05f43a584933559743cf98902e4246f165 Mon Sep 17 00:00:00 2001 From: Adam Carr Date: Thu, 9 Apr 2015 11:57:46 -0400 Subject: [PATCH 15/38] making IRouteAdditionalConfigurationOptions validate properties optional --- hapi/hapi.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts index 2cd06cd6e..de8dba6b8 100644 --- a/hapi/hapi.d.ts +++ b/hapi/hapi.d.ts @@ -568,7 +568,7 @@ declare module "hapi" { optionsthe server validation options. next(err, value)the callback function called when validation is completed. */ - headers: boolean | IJoi | IValidationFunction; + headers?: boolean | IJoi | IValidationFunction; /** validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params.Values allowed: @@ -579,7 +579,7 @@ declare module "hapi" { valuethe object containing the path parameters. optionsthe server validation options. next(err, value)the callback function called when validation is completed. */ - params: boolean | IJoi | IValidationFunction; + params?: boolean | IJoi | IValidationFunction; /** validation rules for an incoming request URI query component (the key- value part of the URI between '?' and '#').The query is parsed into its individual key- value pairs (using the qs module) and stored in request.query prior to validation.Values allowed: trueany query parameters allowed (no validation performed).This is the default. falseno query parameters allowed. @@ -588,7 +588,7 @@ declare module "hapi" { valuethe object containing the query parameters. optionsthe server validation options. next(err, value)the callback function called when validation is completed. */ - query: boolean | IJoi | IValidationFunction; + query?: boolean | IJoi | IValidationFunction; /** validation rules for an incoming request payload (request body).Values allowed: trueany payload allowed (no validation performed).This is the default. falseno payload allowed. @@ -597,9 +597,9 @@ declare module "hapi" { valuethe object containing the payload object. optionsthe server validation options. next(err, value)the callback function called when validation is completed. */ - payload: boolean | IJoi | IValidationFunction; + payload?: boolean | IJoi | IValidationFunction; /** an optional object with error fields copied into every validation error response. */ - errorFields: any; + errorFields?: any; /** determines how to handle invalid requests.Allowed values are: 'error'return a Bad Request (400) error response.This is the default value. 'log'log the error but continue processing the request. @@ -609,9 +609,9 @@ declare module "hapi" { replythe continuation reply interface. sourcethe source of the invalid field (e.g. 'path', 'query', 'payload'). errorthe error object prepared for the client response (including the validation function error under error.data). */ - failAction: string | IRouteFailFunction; + failAction?: string | IRouteFailFunction; /** options to pass to Joi.Useful to set global options such as stripUnknown or abortEarly (the complete list is available here: https://github.com/hapijs/joi#validatevalue-schema-options-callback ).Defaults to no options. */ - options: any; + options?: any; }; /** define timeouts for processing durations: */ timeout?: { From 1a364df8db0fc63f81dad2edee189a46a07457a1 Mon Sep 17 00:00:00 2001 From: Adam Carr Date: Thu, 9 Apr 2015 12:01:48 -0400 Subject: [PATCH 16/38] Adding test for optional hapi config.validate parameters --- hapi/hapi-tests.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hapi/hapi-tests.ts b/hapi/hapi-tests.ts index c0f8d9f6e..11ad81d2d 100644 --- a/hapi/hapi-tests.ts +++ b/hapi/hapi-tests.ts @@ -82,5 +82,18 @@ server.route([{ } }]); +// config.validate parameters should be optional +server.route([{ + method: 'GET', + path: '/hello2', + handler: function(request: Hapi.Request, reply: Function) { + reply('hello world2'); + }, + config: { + validate: { + } + } +}]); + // Start the server server.start(); From 229a641cc87828460bbcf7572503bab543a8666e Mon Sep 17 00:00:00 2001 From: davetayls Date: Fri, 10 Apr 2015 11:08:40 +0100 Subject: [PATCH 17/38] added yahoo xss-filters --- xss-filters/xss-filters-tests.ts | 37 +++++++++++++++++++++++++++ xss-filters/xss-filters.d.ts | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 xss-filters/xss-filters-tests.ts create mode 100644 xss-filters/xss-filters.d.ts diff --git a/xss-filters/xss-filters-tests.ts b/xss-filters/xss-filters-tests.ts new file mode 100644 index 000000000..49a566efc --- /dev/null +++ b/xss-filters/xss-filters-tests.ts @@ -0,0 +1,37 @@ +/// + +import xssFilters = require('xss-filters'); + +var s = ''; + +xssFilters.inHTMLComment(s); +xssFilters.inHTMLData(s); +xssFilters.inDoubleQuotedAttr(s); +xssFilters.inSingleQuotedAttr(s); +xssFilters.inUnQuotedAttr(s); +xssFilters.uriInHTMLComment(s); +xssFilters.uriInHTMLData(s); +xssFilters.uriInDoubleQuotedAttr(s); +xssFilters.uriInSingleQuotedAttr(s); +xssFilters.uriInUnQuotedAttr(s); +xssFilters.uriPathInHTMLComment(s); +xssFilters.uriPathInHTMLData(s); +xssFilters.uriPathInDoubleQuotedAttr(s); +xssFilters.uriPathInSingleQuotedAttr(s); +xssFilters.uriPathInUnQuotedAttr(s); +xssFilters.uriQueryInHTMLComment(s); +xssFilters.uriQueryInHTMLData(s); +xssFilters.uriQueryInDoubleQuotedAttr(s); +xssFilters.uriQueryInSingleQuotedAttr(s); +xssFilters.uriQueryInUnQuotedAttr(s); +xssFilters.uriComponentInHTMLComment(s); +xssFilters.uriComponentInHTMLData(s); +xssFilters.uriComponentInDoubleQuotedAttr(s); +xssFilters.uriComponentInSingleQuotedAttr(s); +xssFilters.uriComponentInUnQuotedAttr(s); +xssFilters.uriFragmentInHTMLComment(s); +xssFilters.uriFragmentInHTMLData(s); +xssFilters.uriFragmentInDoubleQuotedAttr(s); +xssFilters.uriFragmentInSingleQuotedAttr(s); +xssFilters.uriFragmentInUnQuotedAttr(s); + diff --git a/xss-filters/xss-filters.d.ts b/xss-filters/xss-filters.d.ts new file mode 100644 index 000000000..3ac33d4f3 --- /dev/null +++ b/xss-filters/xss-filters.d.ts @@ -0,0 +1,43 @@ +// Type definitions for Yahoo XSS Filters +// Project: https://github.com/yahoo/xss-filters +// Definitions by: Dave Taylor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface XSSFilters { + inHTMLComment(s:string):string; + inHTMLData(s:string):string; + inDoubleQuotedAttr(s:string):string; + inSingleQuotedAttr(s:string):string; + inUnQuotedAttr(s:string):string; + uriInHTMLComment(s:string):string; + uriInHTMLData(s:string):string; + uriInDoubleQuotedAttr(s:string):string; + uriInSingleQuotedAttr(s:string):string; + uriInUnQuotedAttr(s:string):string; + uriPathInHTMLComment(s:string):string; + uriPathInHTMLData(s:string):string; + uriPathInDoubleQuotedAttr(s:string):string; + uriPathInSingleQuotedAttr(s:string):string; + uriPathInUnQuotedAttr(s:string):string; + uriQueryInHTMLComment(s:string):string; + uriQueryInHTMLData(s:string):string; + uriQueryInDoubleQuotedAttr(s:string):string; + uriQueryInSingleQuotedAttr(s:string):string; + uriQueryInUnQuotedAttr(s:string):string; + uriComponentInHTMLComment(s:string):string; + uriComponentInHTMLData(s:string):string; + uriComponentInDoubleQuotedAttr(s:string):string; + uriComponentInSingleQuotedAttr(s:string):string; + uriComponentInUnQuotedAttr(s:string):string; + uriFragmentInHTMLComment(s:string):string; + uriFragmentInHTMLData(s:string):string; + uriFragmentInDoubleQuotedAttr(s:string):string; + uriFragmentInSingleQuotedAttr(s:string):string; + uriFragmentInUnQuotedAttr(s:string):string; +} + +declare var xssFilters:XSSFilters; + +declare module 'xss-filters' { + export = xssFilters; +} From aa84861d4141a7896101420a1aeb59a109109bb7 Mon Sep 17 00:00:00 2001 From: davetayls Date: Fri, 10 Apr 2015 11:39:53 +0100 Subject: [PATCH 18/38] added DOMPurify from https://github.com/cure53/DOMPurify --- dompurify/dompurify-tests.ts | 8 ++++++++ dompurify/dompurify.d.ts | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 dompurify/dompurify-tests.ts create mode 100644 dompurify/dompurify.d.ts diff --git a/dompurify/dompurify-tests.ts b/dompurify/dompurify-tests.ts new file mode 100644 index 000000000..d9d6e0bd6 --- /dev/null +++ b/dompurify/dompurify-tests.ts @@ -0,0 +1,8 @@ +/// + +import dompurify = require('dompurify'); + +dompurify.sanitize(''); +dompurify.addHook('beforeSanitizeElements', (el, data, config) => { + return el; +}); diff --git a/dompurify/dompurify.d.ts b/dompurify/dompurify.d.ts new file mode 100644 index 000000000..b1f24b00e --- /dev/null +++ b/dompurify/dompurify.d.ts @@ -0,0 +1,15 @@ +// Type definitions for DOM Purify +// Project: https://github.com/cure53/DOMPurify +// Definitions by: Dave Taylor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface IDOMPurify { + sanitize(s:string):string; + addHook(hook:string, cb:(currentNode:Element, data:any, config:any) => Element):void; +} + +declare var DOMPurify:IDOMPurify; + +declare module 'dompurify' { + export = DOMPurify; +} From a688d7bf1f9eeb5187843d4fdc393c81adda57e6 Mon Sep 17 00:00:00 2001 From: davetayls Date: Fri, 10 Apr 2015 12:12:41 +0100 Subject: [PATCH 19/38] added sanitiser https://github.com/theSmaw/Caja-HTML-Sanitizer --- sanitizer/sanitizer-tests.ts | 53 ++++++++++++++++++++++++++++++++++++ sanitizer/sanitizer.d.ts | 27 ++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 sanitizer/sanitizer-tests.ts create mode 100644 sanitizer/sanitizer.d.ts diff --git a/sanitizer/sanitizer-tests.ts b/sanitizer/sanitizer-tests.ts new file mode 100644 index 000000000..6a4c8982d --- /dev/null +++ b/sanitizer/sanitizer-tests.ts @@ -0,0 +1,53 @@ +/// + +import sanitizer = require('sanitizer'); + +// example copied from the tests https://github.com/theSmaw/Caja-HTML-Sanitizer/blob/master/test/test-sanitizer.js#L346 +var events:any[] = []; +var addTextEvent = function(type:string, text:string, param:any) { + var n = events.length; + + if (events[n - 3] === type && events[n - 1] === param) { + events[n - 2] += text; + } else { + events.push(type, text, param); + } +}; + +sanitizer.makeSaxParser({ + startTag: function(name, attribs, param) { + events.push('startTag', name + '[' + attribs.join(';') + ']', param); + }, + + endTag: function(name, param) { + events.push('endTag', name, param); + }, + + pcdata: function(text, param) { + addTextEvent('pcdata', text, param); + }, + + cdata: function(text, param) { + addTextEvent('cdata', text, param); + }, + + rcdata: function(text, param) { + addTextEvent('rcdata', text, param); + }, + + comment: function(text, param) { + events.push('comment', text, param); + }, + + startDoc: function(param) { + events.push('startDoc', '', param); + }, + + endDoc: function(param) { + events.push('endDoc', '', param); + } +}); +sanitizer.escape(''); +sanitizer.sanitize(''); +sanitizer.normalizeRCData(''); +sanitizer.unescapeEntities(''); diff --git a/sanitizer/sanitizer.d.ts b/sanitizer/sanitizer.d.ts new file mode 100644 index 000000000..16d9448c9 --- /dev/null +++ b/sanitizer/sanitizer.d.ts @@ -0,0 +1,27 @@ +// Type definitions for Sanitizer +// Project: https://github.com/theSmaw/Caja-HTML-Sanitizer +// Definitions by: Dave Taylor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'sanitizer' { + export interface ISaxHandler { + startTag(name:string, attribs:string[], param:any):void; + endTag(name:string, param:any):void; + pcdata(text:string, param:any):void; + cdata(text:string, param:any):void; + rcdata(text:string, param:any):void; + comment(text:string, param:any):void; + startDoc(param:any):void; + endDoc(param:any):void; + } + + export function escape(s:string):string; + + export function makeSaxParser(yourHandler:ISaxHandler):(...any:any[])=>any; + + export function normalizeRCData(s:string):string; + + export function sanitize(s:string):string; + + export function unescapeEntities(s:string):string; +} From 2df64a97328bf1d6e15aa97616bdbb47c0adec73 Mon Sep 17 00:00:00 2001 From: kubosho Date: Fri, 10 Apr 2015 20:55:10 +0900 Subject: [PATCH 20/38] Add lory definition file --- lory/lory.d.ts | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 lory/lory.d.ts diff --git a/lory/lory.d.ts b/lory/lory.d.ts new file mode 100644 index 000000000..deee77f46 --- /dev/null +++ b/lory/lory.d.ts @@ -0,0 +1,68 @@ +// Type definitions for lory 0.4.3 +// Project: https://github.com/meandmax/lory/ +// Definitions by: kubosho +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var lory: LoryStatic; + +interface LoryStatic { + (element: Element, options?: LoryOptions): LoryStatic; + + /** + * slides to the previous slide. + */ + prev(): void; + + /** + * slides to the next slide. + */ + next(): void; + + /** + * slides to the index given as an argument + * @param {number} index + */ + slideTo(index: number): void; + + /** + * binds eventlisteners, merging default and user options, setup the slides based on DOM (called once during initialisation). Call setup if DOM or user options have changed or eventlisteners needs to be rebinded. + */ + setup(): void; + + /** + * sets the slider back to the starting position and resets the current index (called on resize event) + */ + reset(): void; +} + +interface LoryOptions { + /** + * slides scrolled at once (default: 1) + */ + slidesToScroll?: number; + + /** + * time in milliseconds for the animation of a valid slide attempt (default: 300) + */ + slideSpeed?: number; + + /** + * time in milliseconds for the animation of the rewind after the last slide (default: 600) + */ + rewindSpeed?: number; + + /** + * time for the snapBack of the slider if the slide attempt was not valid (default: 200) + */ + snapBackSpeed?: number; + + /** + * cubic bezier easing functions: http://easings.net/de (default: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)') + */ + ease?: string; + + /** + * if slider reached the last slide, with next click the slider goes back to the startindex (default: false) + */ + rewind?: boolean; +} From 43fe8614dabbe649512f8f508bc8f17ad77cf319 Mon Sep 17 00:00:00 2001 From: Slimfit Date: Fri, 10 Apr 2015 17:39:42 -0400 Subject: [PATCH 21/38] Add segments array to CircularInstance This is needed because a circular instance are set by updating CircularIntance.segments[0].value. See update() example in the following documentation: http://www.chartjs.org/docs/#doughnut-pie-chart-prototype-methods. --- chartjs/chart.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/chartjs/chart.d.ts b/chartjs/chart.d.ts index a73ecc94e..d85f9b476 100644 --- a/chartjs/chart.d.ts +++ b/chartjs/chart.d.ts @@ -115,6 +115,7 @@ interface CircularInstance extends ChartInstance { update: () => void; addData: (valuesArray: CircularChartData[], index: number) => void; removeData: (index: number) => void; + segments: Array; } interface LineChartOptions extends ChartOptions { From c17bd6dfc59517627bfada803c84504623ede4bb Mon Sep 17 00:00:00 2001 From: Michael Nahkies Date: Sat, 11 Apr 2015 14:47:47 +1200 Subject: [PATCH 22/38] - Added missing tz overloads for constructing a moment at now in a specific timezone and constructing a moment from a string using strict parsing and specific timezone. - Added missing getter tz for getting the current timezone of a moment instance. --- moment-timezone/moment-timezone-tests.ts | 5 +++++ moment-timezone/moment-timezone.d.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/moment-timezone/moment-timezone-tests.ts b/moment-timezone/moment-timezone-tests.ts index f6a754c6e..6e818c742 100644 --- a/moment-timezone/moment-timezone-tests.ts +++ b/moment-timezone/moment-timezone-tests.ts @@ -8,11 +8,16 @@ june.tz('America/Los_Angeles').format('ha z'); var a = moment.tz("2013-11-18 11:55", "America/Toronto"); var b = moment.tz("May 12th 2014 8PM", "MMM Do YYYY hA", "America/Toronto"); var c = moment.tz(1403454068850, "America/Toronto"); +var d = moment.tz("May 12th 2014 8PM", "MMM Do YYYY hA", true, "America/Toronto"); + +a.tz(); var arr = [2013, 5, 1], str = "2013-12-01", obj = { year : 2013, month : 5, day : 1 }; +moment.tz("America/Los_Angeles"); + moment.tz(arr, "America/Los_Angeles"); moment.tz(str, "America/Los_Angeles"); moment.tz(obj, "America/Los_Angeles"); diff --git a/moment-timezone/moment-timezone.d.ts b/moment-timezone/moment-timezone.d.ts index 1e908ace1..02d72ac2e 100644 --- a/moment-timezone/moment-timezone.d.ts +++ b/moment-timezone/moment-timezone.d.ts @@ -7,6 +7,7 @@ declare module moment { interface Moment { + tz(): string; tz(timezone: string): Moment; } @@ -27,9 +28,11 @@ interface MomentZone { } interface MomentTimezone { + (timezone: string): moment.Moment; (date: number, timezone: string): moment.Moment; (date: number[], timezone: string): moment.Moment; (date: string, format: string, timezone: string): moment.Moment; + (date: string, format: string, useStrict: boolean, timezone: string): moment.Moment; (date: Date, timezone: string): moment.Moment; (date: moment.Moment, timezone: string): moment.Moment; (date: Object, timezone: string): moment.Moment; From 1a3e3a11f40ab42a17474cfd84f77f1eb50664ab Mon Sep 17 00:00:00 2001 From: Adrien Kohlbecker Date: Sat, 11 Apr 2015 15:38:52 +0200 Subject: [PATCH 23/38] Add google places AutocompleteService --- googlemaps/google.maps.d.ts | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index eb85899c4..3ba451c8a 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -1345,6 +1345,55 @@ declare module google.maps { } export module places { + + export class AutocompleteService extends MVCObject { + constructor(); + getPlacePredictions(request: AutocompletionRequest, callback: (result: AutocompletePrediction[], status: PlacesServiceStatus) => void): void; + getQueryPredictions(request: QueryAutocompletionRequest, callback: (result: QueryAutocompletePrediction[], status: PlacesServiceStatus) => void): void; + } + + export interface AutocompletionRequest { + input: string; + bounds?: LatLngBounds; + componentRestrictions?: ComponentRestrictions; + location?: LatLng; + offset?: number; + radius?: number; + types?: string[]; + } + + export interface QueryAutocompletionRequest { + input: string; + bounds?: LatLngBounds; + location?: LatLng; + offset?: number; + radius?: number; + } + + export interface AutocompletePrediction { + description: string; + matched_substrings: PredictionSubstring[]; + place_id: string; + terms: PredictionTerm[]; + types: string[] + } + + export interface PredictionTerm { + offset: number; + value: string; + } + + export interface PredictionSubstring { + length: number; + offset: number; + } + + export interface QueryAutocompletePrediction { + description: string; + matched_substrings: PredictionSubstring[]; + place_id: string; + terms: PredictionTerm[]; + } export class Autocomplete extends MVCObject { constructor (inputField: HTMLInputElement, opts?: AutocompleteOptions); From 262cd5c3fc12d424b3c5a409b986e7eeb3f8cd4d Mon Sep 17 00:00:00 2001 From: Slimfit Date: Sat, 11 Apr 2015 11:13:27 -0400 Subject: [PATCH 24/38] CircularInstance.addData was incorrect addData takes a single object of type CircularChartData, not an array. Also the index is optional. See addData example in the documentation http://www.chartjs.org/docs/#doughnut-pie-chart-prototype-methods --- chartjs/chart.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chartjs/chart.d.ts b/chartjs/chart.d.ts index a73ecc94e..44d571803 100644 --- a/chartjs/chart.d.ts +++ b/chartjs/chart.d.ts @@ -113,7 +113,7 @@ interface LinearInstance extends ChartInstance { interface CircularInstance extends ChartInstance { getSegmentsAtEvent: (event: Event) => {}[]; update: () => void; - addData: (valuesArray: CircularChartData[], index: number) => void; + addData: (valuesArray: CircularChartData, index?: number) => void; removeData: (index: number) => void; } From 8fa20fff1e3ef282f39a4148edeb3e3ffe0a70fd Mon Sep 17 00:00:00 2001 From: Slimfit Date: Sat, 11 Apr 2015 11:27:24 -0400 Subject: [PATCH 25/38] Updated test file CircularInstance to match new addData signature --- chartjs/chart-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chartjs/chart-tests.ts b/chartjs/chart-tests.ts index 2374b6228..d63a6b504 100644 --- a/chartjs/chart-tests.ts +++ b/chartjs/chart-tests.ts @@ -301,12 +301,12 @@ var myPieChart = new Chart(ctx).Pie(pieData, { var myPieChartLegend: string = myPieChart.generateLegend(); var myPieChartImage: string = myPieChart.toBase64Image(); -myPieChart.addData([{ +myPieChart.addData({ value: 120, color: "#4D5360", highlight: "#616774", label: "Dark Grey" -}], 0); +}, 0); myPieChart.clear(); myPieChart.removeData(0); myPieChart.resize(); From 32aae2c650b465b14b263e1995bd5cd5c26ef895 Mon Sep 17 00:00:00 2001 From: Slimfit Date: Sat, 11 Apr 2015 11:36:06 -0400 Subject: [PATCH 26/38] Missed a couple addData() calls in the test file --- chartjs/chart-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chartjs/chart-tests.ts b/chartjs/chart-tests.ts index d63a6b504..4bd8820c6 100644 --- a/chartjs/chart-tests.ts +++ b/chartjs/chart-tests.ts @@ -252,12 +252,12 @@ var myPolarAreaChart = new Chart(ctx).PolarArea(polarAreaData, { var myPolarAreaChartLegend: string = myPolarAreaChart.generateLegend(); var myPolarAreaChartImage: string = myPolarAreaChart.toBase64Image(); -myPolarAreaChart.addData([{ +myPolarAreaChart.addData({ value: 120, color: "#4D5360", highlight: "#616774", label: "Dark Grey" -}], 0); +}, 0); myPolarAreaChart.clear(); myPolarAreaChart.removeData(0); myPolarAreaChart.resize(); @@ -329,12 +329,12 @@ var myDoughnutChart = new Chart(ctx).Doughnut(pieData, { var myDoughnutChartLegend: string = myDoughnutChart.generateLegend(); var myDoughnutChartImage: string = myDoughnutChart.toBase64Image(); -myPieChart.addData([{ +myPieChart.addData({ value: 120, color: "#4D5360", highlight: "#616774", label: "Dark Grey" -}], 0); +}, 0); myDoughnutChart.clear(); myDoughnutChart.removeData(0); myDoughnutChart.resize(); From fb7832af29088554efd2414ad83fb776c4d8eabd Mon Sep 17 00:00:00 2001 From: Albin Sunnanbo Date: Mon, 6 Apr 2015 22:59:23 +0200 Subject: [PATCH 27/38] Add TypeScript definitions and tests for Bootstrap TouchSpin (http://www.virtuosoft.eu/code/bootstrap-touchspin/) --- .../jquery.bootstrap-touchspin-tests.ts | 68 +++++++++ .../jquery.bootstrap-touchspin.d.ts | 130 ++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts create mode 100644 jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts diff --git a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts b/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts new file mode 100644 index 000000000..436b98416 --- /dev/null +++ b/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts @@ -0,0 +1,68 @@ +/// +/// + +$(function () { + // Example 1 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo1']").TouchSpin({ + min: 0, + max: 100, + step: 0.1, + decimals: 2, + boostat: 5, + maxboostedstep: 10, + postfix: '%' + }); + + // Example 2 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo2']").TouchSpin({ + min: -1000000000, + max: 1000000000, + stepinterval: 50, + maxboostedstep: 10000000, + prefix: '$' + }); + + // Example 3 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo_vertical']").TouchSpin({ + verticalbuttons: true + }); + + // Example 4 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo_vertical2']").TouchSpin({ + verticalbuttons: true, + verticalupclass: 'glyphicon glyphicon-plus', + verticaldownclass: 'glyphicon glyphicon-minus' + }); + + // Example 5 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo3']").TouchSpin(); + + // Example 6 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo3_21']").TouchSpin({ + initval: 40 + }); + + // Example 7 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo4']").TouchSpin({ + postfix: "a button", + postfix_extraclass: "btn btn-default" + }); + + // Example 8 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo4_2']").TouchSpin({ + postfix: "a button", + postfix_extraclass: "btn btn-default" + }); + + // Example 9 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo5']").TouchSpin({ + prefix: "pre", + postfix: "post" + }); + + // Example 10 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo6']").TouchSpin({ + buttondown_class: "btn btn-link", + buttonup_class: "btn btn-link" + }); +}); \ No newline at end of file diff --git a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts b/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts new file mode 100644 index 000000000..2dcf62884 --- /dev/null +++ b/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts @@ -0,0 +1,130 @@ +// Type definitions for Bootstrap TouchSpin +// Project: http://www.virtuosoft.eu/code/bootstrap-touchspin/ +// Definitions by: Albin Sunnanbo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** + * TouchSpinOptions. All options are optional + */ +interface TouchSpinOptions { + /** + * Applied when no explicit value is set on the input with the value attribute. + * Empty string means that the value remains empty on initialization. + */ + initval?: number | string; + + /** + * Minimum value. + */ + min?: number; + + /** + * Maximum value. + */ + max?: number; + + /** + * Incremental/decremental step on up/down change. + */ + step?: number; + + /** + * How to force the value to be divisible by step value: 'none' | 'round' | 'floor' | 'ceil' + */ + forcestepdivisibility?: string; + + /** + * Number of decimal points. + */ + decimals?: number; + + /** + * Refresh rate of the spinner in milliseconds. + */ + stepinterval?: number; + + /** + * Time in milliseconds before the spinner starts to spin. + */ + stepintervaldelay?: number; + + /** + * Enables the traditional up/down buttons. + */ + verticalbuttons?: boolean; + + /** + * Class of the up button with vertical buttons mode enabled. + */ + verticalupclass?: string; + + /** + * Class of the down button with vertical buttons mode enabled. + */ + verticaldownclass?: string; + + /** + * Text before the input. + */ + prefix?: string; + + /** + * Text after the input. + */ + postfix?: string; + + /** + * Extra class(es) for prefix. + */ + prefix_extraclass?: string; + + /** + * Extra class(es) for postfix. + */ + postfix_extraclass?: string; + + /** + * If enabled, the the spinner is continually becoming faster as holding the button. + */ + booster?: boolean; + + /** + * Boost at every nth step. + */ + boostat?: number; + + /** + * Maximum step when boosted. + */ + maxboostedstep?: number | boolean; + + /** + * Enables the mouse wheel to change the value of the input. + */ + mousewheel?: boolean; + + /** + * Class(es) of down button. + */ + buttondown_class?: string; + + /** + * Class(es) of up button. + */ + buttonup_class?: string; +} + +interface JQuery { + /** + * Initialize TouchSpin + */ + TouchSpin(): JQuery; + + /** + * Inialize TouchSpin with options + * @param options a TouchSpinOptions object with one or more options + */ + TouchSpin(options: TouchSpinOptions): JQuery; +} From c156c4545fa7aeca27bb25455b6d34d0497f2d57 Mon Sep 17 00:00:00 2001 From: Albin Sunnanbo Date: Sun, 12 Apr 2015 08:05:52 +0200 Subject: [PATCH 28/38] Add TypeScript definitions and tests for Bootstrap TouchSpin (http://www.virtuosoft.eu/code/bootstrap-touchspin/) - Rename to bootstrap-touchspin as suggested in https://github.com/borisyankov/DefinitelyTyped/pull/4054#issuecomment-90607707 --- .../bootstrap-touchspin-tests.ts | 2 +- .../bootstrap-touchspin.d.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts => bootstrap-touchspin/bootstrap-touchspin-tests.ts (97%) rename jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts => bootstrap-touchspin/bootstrap-touchspin.d.ts (100%) diff --git a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts b/bootstrap-touchspin/bootstrap-touchspin-tests.ts similarity index 97% rename from jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts rename to bootstrap-touchspin/bootstrap-touchspin-tests.ts index 436b98416..552c26f52 100644 --- a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts +++ b/bootstrap-touchspin/bootstrap-touchspin-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// $(function () { // Example 1 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ diff --git a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts b/bootstrap-touchspin/bootstrap-touchspin.d.ts similarity index 100% rename from jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts rename to bootstrap-touchspin/bootstrap-touchspin.d.ts From 096407dd0cd3b14f5a28b662033570174e0f1cdf Mon Sep 17 00:00:00 2001 From: Eirik Hoem Date: Sun, 12 Apr 2015 14:04:47 +0200 Subject: [PATCH 29/38] Rename --- calq/{calq-test.ts => calq-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename calq/{calq-test.ts => calq-tests.ts} (100%) diff --git a/calq/calq-test.ts b/calq/calq-tests.ts similarity index 100% rename from calq/calq-test.ts rename to calq/calq-tests.ts From 4cbff38fab64847b13f6329ac5927dc4d1a87e0d Mon Sep 17 00:00:00 2001 From: kubosho Date: Mon, 13 Apr 2015 12:39:03 +0900 Subject: [PATCH 30/38] Add callbacks in definition file & Add tests --- lory/lory-tests.ts | 62 ++++++++++++++++++++++++++++++++++++++++++++++ lory/lory.d.ts | 60 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 lory/lory-tests.ts diff --git a/lory/lory-tests.ts b/lory/lory-tests.ts new file mode 100644 index 000000000..cb3495a62 --- /dev/null +++ b/lory/lory-tests.ts @@ -0,0 +1,62 @@ +/// + +(function() { + var elm = document.querySelector('.js-foo'); + var elm2 = document.querySelector('.js-bar'); + var elm3 = document.querySelector('.js-baz'); + var elm4 = document.querySelector('.js-foobar'); + + ////////////////////////////////////////////////// + // Init + ////////////////////////////////////////////////// + + lory(elm); + + // with options + lory(elm2, { + slidesToScroll: 1, + slideSpeed: 300, + rewindSpeed: 600, + snapBackSpeed: 200, + ease: 'ease', + rewind: true, + infinite: false + }); + + // with callbacks + lory(elm3, { + beforeInit: () => { }, + afterInit: () => { }, + beforePrev: () => { return 1; }, + beforeNext: () => { return false; }, + beforeTouch: () => { return ''; }, + beforeResize: () => { } + }); + + // with options & callbacks + lory(elm4, { + slidesToScroll: 1, + slideSpeed: 300, + rewindSpeed: 600, + snapBackSpeed: 200, + ease: 'ease', + rewind: true, + infinite: 4, + beforeInit: () => { return function() { console.log('foo') }; }, + afterInit: () => { return [0, 1]; }, + beforePrev: () => { }, + beforeNext: () => { }, + beforeTouch: () => { }, + beforeResize: () => { return {}; } + }); + + ////////////////////////////////////////////////// + // Public API + ////////////////////////////////////////////////// + + lory.setup(); + lory.prev(); + lory.next(); + lory.reset(); + lory.slideTo(1); +}()); diff --git a/lory/lory.d.ts b/lory/lory.d.ts index deee77f46..4dc7860d8 100644 --- a/lory/lory.d.ts +++ b/lory/lory.d.ts @@ -19,8 +19,7 @@ interface LoryStatic { next(): void; /** - * slides to the index given as an argument - * @param {number} index + * slides to the index given as an argument. */ slideTo(index: number): void; @@ -30,39 +29,82 @@ interface LoryStatic { setup(): void; /** - * sets the slider back to the starting position and resets the current index (called on resize event) + * sets the slider back to the starting position and resets the current index (called on resize event). */ reset(): void; } interface LoryOptions { + ////////////////////////////////////////////////// + // Options + ////////////////////////////////////////////////// + /** - * slides scrolled at once (default: 1) + * slides scrolled at once (default: 1). */ slidesToScroll?: number; /** - * time in milliseconds for the animation of a valid slide attempt (default: 300) + * time in milliseconds for the animation of a valid slide attempt (default: 300). */ slideSpeed?: number; /** - * time in milliseconds for the animation of the rewind after the last slide (default: 600) + * time in milliseconds for the animation of the rewind after the last slide (default: 600). */ rewindSpeed?: number; /** - * time for the snapBack of the slider if the slide attempt was not valid (default: 200) + * time for the snapBack of the slider if the slide attempt was not valid (default: 200). */ snapBackSpeed?: number; /** - * cubic bezier easing functions: http://easings.net/de (default: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)') + * cubic bezier easing functions: http://easings.net/de (default: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)'). */ ease?: string; /** - * if slider reached the last slide, with next click the slider goes back to the startindex (default: false) + * if slider reached the last slide, with next click the slider goes back to the startindex (default: false). */ rewind?: boolean; + + /** + * like carousel, works with multiple slides (default: false). (do not combine with rewind) + */ + infinite?: boolean | number; + + ////////////////////////////////////////////////// + // Callbacks + ////////////////////////////////////////////////// + + /** + * executed before initialisation (first in setup function) + */ + beforeInit?: () => T; + + /** + * executed after initialisation (end of setup function) + */ + afterInit?: () => T; + + /** + * executed on click of prev controls (prev function) + */ + beforePrev?: () => T; + + /** + * executed on click of next controls (next function) + */ + beforeNext?: () => T; + + /** + * executed on touch attempt (touchstart) + */ + beforeTouch?: () => T; + + /** + * executed on every resize event + */ + beforeResize?: () => T; } From dc17c1cf2fdb0cdd32a96962e9fbf3981e9ca07a Mon Sep 17 00:00:00 2001 From: Matt Podsiadlo Date: Mon, 13 Apr 2015 10:52:41 +0200 Subject: [PATCH 31/38] Added a definition for IBrowserService.defer --- angularjs/angular.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 191aa7692..31f59d9fa 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -665,6 +665,7 @@ declare module angular { // TODO undocumented, so we need to get it from the source code /////////////////////////////////////////////////////////////////////////// interface IBrowserService { + defer: ng.ITimeoutService; [key: string]: any; } From bfb1ef58546e5687c4560bc115b6c3a6eb7445c2 Mon Sep 17 00:00:00 2001 From: Kristof Mattei Date: Mon, 13 Apr 2015 15:35:24 +0200 Subject: [PATCH 32/38] Added TSD for ReCaptchaV2 --- grecaptcha/grecaptcha-tests.ts | 21 +++++++++++ grecaptcha/grecaptcha.d.ts | 67 ++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 grecaptcha/grecaptcha-tests.ts create mode 100644 grecaptcha/grecaptcha.d.ts diff --git a/grecaptcha/grecaptcha-tests.ts b/grecaptcha/grecaptcha-tests.ts new file mode 100644 index 000000000..cfc86e71b --- /dev/null +++ b/grecaptcha/grecaptcha-tests.ts @@ -0,0 +1,21 @@ +/// + +var params: ReCaptchaV2.Parameters = { + "sitekey": "mySuperSecretKey", + "theme": "black", // no type-checking here. + "type": "image", + "tabindex": 5, + "callback": (response: string) => { }, + "expired-callback": () => { }, +} + +var id1: number = grecaptcha.render("foo"); +var id2: number = grecaptcha.render("foo", params); +var id3: number = grecaptcha.render(document.getElementById("foo")); +var id4: number = grecaptcha.render(document.getElementById("foo"), params); + +// response takes a number and returns a string +var response1: string = grecaptcha.getResponse(id1); + +// reset takes a number +grecaptcha.reset(id1); diff --git a/grecaptcha/grecaptcha.d.ts b/grecaptcha/grecaptcha.d.ts new file mode 100644 index 000000000..e246aaf17 --- /dev/null +++ b/grecaptcha/grecaptcha.d.ts @@ -0,0 +1,67 @@ +// Type definitions for Google Recaptcha v2 +// Project: https://www.google.com/recaptcha +// Definitions by: Kristof Mattei +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var grecaptcha: ReCaptchaV2.ReCaptcha; + +declare module ReCaptchaV2 +{ + class ReCaptcha + { + /** + * Renders the container as a reCAPTCHA widget and returns the ID of the newly created widget. + * @param container The HTML element to render the reCAPTCHA widget. Specify either the ID of the container (string) or the DOM element itself. + * @param parameters An object containing parameters as key=value pairs, for example, {"sitekey": "your_site_key", "theme": "light"}. See @see render parameters. + * @return the ID of the newly created widget. + **/ + render(container: (string | HTMLElement), parameters?: Parameters): number; + /** + * Resets the reCAPTCHA widget. + * @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified. + **/ + reset(opt_widget_id?: number): void; + /** + * Gets the response for the reCAPTCHA widget. + * @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified. + * @return the response of the reCAPTCHA widget. + **/ + getResponse(opt_widget_id?: number): string; + } + + interface Parameters + { + /** + * Your sitekey. + **/ + sitekey: string; + /** + * Optional. The color theme of the widget. + * Accepted values: "light", "dark" + * @default "light" + **/ + theme?: string; + /** + * Optional. The type of CAPTCHA to serve. + * Accepted values: "audio ", "image" + * @default "image" + **/ + type?: string; + /** + * Optional. The tabindex of the widget and challenge. + * If other elements in your page use tabindex, it should be set to make user navigation easier. + **/ + tabindex?: number; + /** + * Optional. Your callback function that's executed when the user submits a successful CAPTCHA response. + * The user's response, g-recaptcha-response, will be the input for your callback function. + **/ + callback?: (response: string) => void; + /** + * Optional. Your callback function that's executed when the recaptcha response expires and the user needs to solve a new CAPTCHA. + **/ + // Notice to the reader + // I need to surround this object with quotes, this will however break intellisense in VS 2013. + "expired-callback"?: () => void; + } +} From 4f63dbf41c37c0dda8366012e223330b9696fd8d Mon Sep 17 00:00:00 2001 From: Will Johnston Date: Mon, 13 Apr 2015 11:13:38 -0500 Subject: [PATCH 33/38] renamed stripe-node/stripe-node -> stripe/stripe-node --- {stripe-node => stripe}/stripe-node-tests.ts | 0 {stripe-node => stripe}/stripe-node.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {stripe-node => stripe}/stripe-node-tests.ts (100%) rename {stripe-node => stripe}/stripe-node.d.ts (100%) diff --git a/stripe-node/stripe-node-tests.ts b/stripe/stripe-node-tests.ts similarity index 100% rename from stripe-node/stripe-node-tests.ts rename to stripe/stripe-node-tests.ts diff --git a/stripe-node/stripe-node.d.ts b/stripe/stripe-node.d.ts similarity index 100% rename from stripe-node/stripe-node.d.ts rename to stripe/stripe-node.d.ts From 17119412908a8805d6c687ad7ebded8080693992 Mon Sep 17 00:00:00 2001 From: Will Johnston Date: Mon, 13 Apr 2015 11:19:08 -0500 Subject: [PATCH 34/38] fixing implicit any in stripe.d.ts, elminating duplicate variables between stripe and stripe-node --- stripe/stripe-node-tests.ts | 4 ++-- stripe/stripe-node.d.ts | 4 ++-- stripe/stripe.d.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/stripe/stripe-node-tests.ts b/stripe/stripe-node-tests.ts index 48c675055..3217b78fb 100644 --- a/stripe/stripe-node-tests.ts +++ b/stripe/stripe-node-tests.ts @@ -1,8 +1,8 @@ /// -import Stripe = require('stripe'); +import StripeNode = require('stripe'); -var stripe = new Stripe("sk_test_BF573NobVn98OiIsPAv7A04K"); +var stripe = new StripeNode("sk_test_BF573NobVn98OiIsPAv7A04K"); stripe.setApiVersion('2015-02-18'); stripe.customers.list({ limit: 3 }, function (err, customers) { diff --git a/stripe/stripe-node.d.ts b/stripe/stripe-node.d.ts index 8d9bd05c8..cb5932086 100644 --- a/stripe/stripe-node.d.ts +++ b/stripe/stripe-node.d.ts @@ -4,11 +4,11 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module 'stripe' { - var out: typeof Stripe.Stripe; + var out: typeof StripeNode.Stripe; export = out; } -declare module Stripe { +declare module StripeNode { class Stripe { static DEFAULT_HOST: string; static DEFAULT_PORT: string; diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 2d5005618..ca589e133 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -4,12 +4,12 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped interface StripeStatic { - setPublishableKey(key: string); + setPublishableKey(key: string): void; validateCardNumber(cardNumber: string): boolean; validateExpiry(month: string, year: string): boolean; validateCVC(cardCVC: string): boolean; cardType(cardNumber: string): string; - getToken(token: string, responseHandler: (status: number, response: StripeTokenResponse) => void); + getToken(token: string, responseHandler: (status: number, response: StripeTokenResponse) => void): void; card: StripeCardData; } @@ -58,7 +58,7 @@ interface StripeCardData { address_zip?: string; address_country?: string; - createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void); + createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; } declare var Stripe: StripeStatic; From ccbabf73c767b086db8f4e416b128c922ba140ee Mon Sep 17 00:00:00 2001 From: Jason Plante Date: Mon, 13 Apr 2015 13:34:15 -0400 Subject: [PATCH 35/38] Added cardinal properties to L.LatLngBounds Added the following property methods to the L.LatLngBounds class: getWest() getEast() getNorth() getSouth() --- leaflet/leaflet.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 1708a9d10..a1e92ef71 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -1573,6 +1573,26 @@ declare module L { */ getSouthEast(): LatLng; + /** + * Returns the west longitude in degrees of the bounds. + */ + getWest(): number; + + /** + * Returns the east longitude in degrees of the bounds. + */ + getEast(): number; + + /** + * Returns the north latitude in degrees of the bounds. + */ + getNorth(): number; + + /** + * Returns the south latitude in degrees of the bounds. + */ + getSouth(): number; + /** * Returns the center point of the bounds. */ From f0182837ce59520f051049f6f4b6bd5d335cf346 Mon Sep 17 00:00:00 2001 From: kubosho Date: Tue, 14 Apr 2015 10:07:45 +0900 Subject: [PATCH 36/38] Rename files (lory -> lory.js) --- lory/{lory-tests.ts => lory.js-tests.ts} | 0 lory/{lory.d.ts => lory.js.d.ts} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename lory/{lory-tests.ts => lory.js-tests.ts} (100%) rename lory/{lory.d.ts => lory.js.d.ts} (100%) diff --git a/lory/lory-tests.ts b/lory/lory.js-tests.ts similarity index 100% rename from lory/lory-tests.ts rename to lory/lory.js-tests.ts diff --git a/lory/lory.d.ts b/lory/lory.js.d.ts similarity index 100% rename from lory/lory.d.ts rename to lory/lory.js.d.ts From dcbe740826b2a969190ce621bf9a3ad5ece68efc Mon Sep 17 00:00:00 2001 From: kubosho Date: Tue, 14 Apr 2015 10:12:26 +0900 Subject: [PATCH 37/38] Fix correct file path --- lory/lory.js-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lory/lory.js-tests.ts b/lory/lory.js-tests.ts index cb3495a62..4247dceca 100644 --- a/lory/lory.js-tests.ts +++ b/lory/lory.js-tests.ts @@ -1,4 +1,4 @@ -/// +/// (function() { var elm = document.querySelector('.js-foo'); From 926c4e288034005ff810cf8bbc3eda76ab5646d7 Mon Sep 17 00:00:00 2001 From: kubosho Date: Tue, 14 Apr 2015 10:25:43 +0900 Subject: [PATCH 38/38] Change directory name (lory -> lory.js) --- {lory => lory.js}/lory.js-tests.ts | 0 {lory => lory.js}/lory.js.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {lory => lory.js}/lory.js-tests.ts (100%) rename {lory => lory.js}/lory.js.d.ts (100%) diff --git a/lory/lory.js-tests.ts b/lory.js/lory.js-tests.ts similarity index 100% rename from lory/lory.js-tests.ts rename to lory.js/lory.js-tests.ts diff --git a/lory/lory.js.d.ts b/lory.js/lory.js.d.ts similarity index 100% rename from lory/lory.js.d.ts rename to lory.js/lory.js.d.ts