diff --git a/notNeededPackages.json b/notNeededPackages.json index f630c4e59e..a51dce496f 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1536,6 +1536,12 @@ "sourceRepoURL": "https://github.com/samchon/tstl", "asOfVersion": "1.5.7" }, + { + "libraryName": "typed.js", + "typingsPackageName": "typed.js", + "sourceRepoURL": "https://github.com/mattboldt/typed.js", + "asOfVersion": "2.0.9" + }, { "libraryName": "TypeScript", "typingsPackageName": "typescript", diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index 618e4d562e..4b5c60e716 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -90,6 +90,7 @@ const themeOptions : Auth0LockConstructorOptions = { icon: 'http://baz.com/icon.png' } }, + hideMainScreenTitle: false, labeledSubmitButton: false, logo: "https://example.com/assets/logo.png", primaryColor: "green" diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index da1820352f..622ac3d36c 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Brian Caruso // Dan Caddigan // Larry Faudree +// Will Caulfield // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -75,6 +76,7 @@ interface Auth0LockThemeButtonOptions { interface Auth0LockThemeOptions { authButtons?: Auth0LockThemeButtonOptions; + hideMainScreenTitle?: boolean; labeledSubmitButton?: boolean; logo?: string; primaryColor?: string; diff --git a/types/better-queue/better-queue-tests.ts b/types/better-queue/better-queue-tests.ts new file mode 100644 index 0000000000..4a1aa4771e --- /dev/null +++ b/types/better-queue/better-queue-tests.ts @@ -0,0 +1,131 @@ +import Queue = require('better-queue'); + +interface TestTask { + taskId: string; + taskPayload: any; +} + +interface TestResult { + some: string; +} + +new Queue((task) => { + const test = task.anything; + console.log(task); +}); + +new Queue((task: TestTask[]) => { + const test = task[0].taskId; + console.log(task); +}); + +new Queue((task: TestTask, cb) => { + const id = task.taskId; + cb(null, 'result'); + cb(); +}, {}); + +new Queue({ + process(task: TestTask, cb) { + const id = task.taskId; + cb(null, { some: 'prop' }); + }, + filter(task, cb) { + const id = task.taskId; + cb(null, task); + }, + merge(oldTask, newTask, cb) { + const oldId = oldTask.taskId; + const newId = newTask.taskId; + cb(null, newTask); + }, + priority(task, cb) { + const id = task.taskId; + cb(null, 10); + }, + precondition(cb) { + cb(null, true); + }, + afterProcessDelay: 1000, + autoResume: true, + batchDelay: 123, + batchDelayTimeout: 123, + batchSize: 123, + cancelIfRunning: true, + concurrent: 123, + failTaskOnProcessException: true, + filo: true, + id: 'taskId', + maxRetries: 1, + maxTimeout: 1, + retryDelay: 1, + storeMaxRetries: 1, + storeRetryTimeout: 1, + preconditionRetryTimeout: 1, + store: 'test' +}); + +new Queue({ + process(task: TestTask[], cb) { + const firstId = task[0].taskId; + cb(null, { some: 'prop' }); + } +}); + +new Queue(() => { }, { + id(task, cb) { + const id = task.taskId; + cb(null, 'taskId'); + } +}); + +new Queue(() => { }, { + store: { + type: 'test' + } +}); + +const q = new Queue(() => {}); + +const testTask = {taskId: '', taskPayload: ''}; + +q.push(testTask); +q.push(testTask, (error, result) => {}); + +q.cancel('id', () => {}); + +class TestStore implements Queue.Store { + connect(cb: (error: any, length: number) => void) { + cb(null, 1); + } + + getTask(taskId: any, cb: (error: any, task: TestTask) => void) { + cb(null, { taskId: '', taskPayload: '' }); + } + + deleteTask(taskId: any, cb: () => void) { + cb(); + } + + putTask(taskId: any, task: TestTask, priority: number, cb: (error: any) => void) { + cb(null); + } + + takeFirstN(n: number, cb: (error: any, lockId: string) => void) { + cb(null, ''); + } + + takeLastN(n: number, cb: (error: any, lockId: string) => void) { + cb(null, ''); + } + + getLock(lockId: string, cb: (error: any, tasks: { [taskId: string]: TestTask }) => void) { + cb(null, { + id: { taskId: 'id', taskPayload: 'payload' } + }); + } + + releaseLock(lockId: string, cb: (error: any) => void) { + cb(null); + } +} diff --git a/types/better-queue/index.d.ts b/types/better-queue/index.d.ts new file mode 100644 index 0000000000..69861c5132 --- /dev/null +++ b/types/better-queue/index.d.ts @@ -0,0 +1,136 @@ +// Type definitions for better-queue 3.8 +// Project: https://github.com/diamondio/better-queue +// Definitions by: Ostap Nagovitsyn +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/* =================== USAGE =================== + import * as Queue from "better-queue"; + var queue = new Queue(...); + =============================================== */ + +/// + +declare class BetterQueue extends NodeJS.EventEmitter { + constructor(options: BetterQueue.QueueOptions); + constructor(process: BetterQueue.ProcessFunction, options?: Partial>); + + push(task: T, cb?: (err: any, result: K) => void): BetterQueue.Ticket; + + cancel(taskId: any, cb?: () => void): void; + + pause(): void; + + resume(): void; + + destroy(cb: () => void): void; + + use(store: BetterQueue.Store): void; + + getStats(): BetterQueue.QueueStats; + + resetStats(): void; + + on(event: 'task_finish', listener: (taskId: any, result: K) => void): this; + on(event: 'task_failed', listener: (taskId: any, errorMessage: string) => void): this; + on(event: 'task_progress', listener: (taskId: any, completed: number, total: number) => void): this; + on(event: BetterQueue.QueueEvent, listener: (...args: any[]) => void): this; +} + +declare namespace BetterQueue { + interface QueueOptions { + process: ProcessFunction; + filter?(task: T, cb: (error: any, task: T) => void): void; + merge?(oldTask: T, newTask: T, cb: (error: any, mergedTask: T) => void): void; + priority?(task: T, cb: (error: any, priority: number) => void): void; + precondition?(cb: (error: any, passOrFail: boolean) => void): void; + id?: keyof T | ((task: T, cb: (error: any, id: keyof T) => void) => void); + cancelIfRunning?: boolean; + autoResume?: boolean; + failTaskOnProcessException?: boolean; + filo?: boolean; + batchSize?: number; + batchDelay?: number; + batchDelayTimeout?: number; + concurrent?: number; + maxTimeout?: number; + afterProcessDelay?: number; + maxRetries?: number; + retryDelay?: number; + storeMaxRetries?: number; + storeRetryTimeout?: number; + preconditionRetryTimeout?: number; + store?: string | StoreOptions | Store; + } + + // TODO reflect task types somehow (task: T | T[]) + type ProcessFunction = (task: any, cb: ProcessFunctionCb) => void; + + type ProcessFunctionCb = (error?: any, result?: K) => void; + + type QueueEvent = + 'task_queued' + | 'task_accepted' + | 'task_started' + | 'task_finish' + | 'task_failed' + | 'task_progress' + | 'batch_finish' + | 'batch_failed' + | 'batch_progress' + | 'error'; + + type TicketEvent = + 'accept' + | 'queued' + | 'started' + | 'progress' + | 'finish' + | 'failed' + | 'error'; + + interface Store { + connect(cb: (error: any, length: number) => void): void; + + getTask(taskId: any, cb: (error: any, task: T) => void): void; + + deleteTask(taskId: any, cb: () => void): void; + + putTask(taskId: any, task: T, priority: number, cb: (error: any) => void): void; + + takeFirstN(n: number, cb: (error: any, lockId: string) => void): void; + + takeLastN(n: number, cb: (error: any, lockId: string) => void): void; + + getLock(lockId: string, cb: (error: any, tasks: { [taskId: string]: T }) => void): void; + + releaseLock(lockId: string, cb: (error: any) => void): void; + } + + interface StoreOptions { + type: string; + // store-specific options + [key: string]: any; + } + + class Ticket extends NodeJS.EventEmitter { + on(event: TicketEvent, listener: (...args: any[]) => void): this; + } + + interface TickerProgress { + eta: string; + pct: number; + complete: number; + total: number; + message: string; + } + + interface QueueStats { + total: number; + average: number; + successRate: number; + peak: number; + } +} + +export = BetterQueue; diff --git a/types/better-queue/tsconfig.json b/types/better-queue/tsconfig.json new file mode 100644 index 0000000000..4677f6a711 --- /dev/null +++ b/types/better-queue/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "better-queue-tests.ts" + ] +} diff --git a/types/better-queue/tslint.json b/types/better-queue/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/better-queue/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 09230f6702..4e82fb9ff5 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -14,6 +14,7 @@ // Slavik Nychkalo // Francesco Benedetto // Alexandros Dorodoulis +// Manuel Heidrich // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -31,7 +32,7 @@ declare class Chart { stop: () => {}; resize: () => {}; clear: () => {}; - toBase64: () => string; + toBase64Image: () => string; generateLegend: () => {}; getElementAtEvent: (e: any) => {}; getElementsAtEvent: (e: any) => Array<{}>; diff --git a/types/chartmogul-node/chartmogul-node-tests.ts b/types/chartmogul-node/chartmogul-node-tests.ts new file mode 100644 index 0000000000..3a09a7597c --- /dev/null +++ b/types/chartmogul-node/chartmogul-node-tests.ts @@ -0,0 +1,277 @@ +import * as ChartMogul from 'chartmogul-node'; + +const config = new ChartMogul.Config("token", "secret", "baseURL"); +config.retries = 10; +config.getAccountToken(); // $ExpectType string +config.getSecretKey(); // $ExpectType string +config.VERSION; // $ExpectType string + +ChartMogul.Ping.ping(config); // $ExpectType Promise + +// $ExpectType Promise +ChartMogul.DataSource.create(config, { + name: "" +}); + +// $ExpectType Promise +ChartMogul.DataSource.retrieve(config, ""); + +// $ExpectType Promise<{}> +ChartMogul.DataSource.destroy(config, ""); + +// $ExpectType Promise +ChartMogul.DataSource.all(config, { + name: "" +}); + +ChartMogul.DataSource.all(config).then(data => { + data.data_sources[0]; // $ExpectType DataSource + data.data_sources[0].name; // $ExpectType string +}); + +// $ExpectType Promise +ChartMogul.Customer.create(config, { + data_source_uuid: "", + name: "", + external_id: "", + attributes: { + tags: ["important", "Prio1"], + custom: [ + {type: "String", key: "channel", value: "Facebook", source: "integration"}, + {type: "Integer", key: "age", value: 18} + ] + } +}); + +// $ExpectType Promise +ChartMogul.Customer.retrieve(config, ""); + +// $ExpectType Promise +ChartMogul.Customer.modify(config, "", {}); + +// $ExpectType Promise<{}> +ChartMogul.Customer.destroy(config, ""); + +// $ExpectType Promise> +ChartMogul.Customer.all(config, { + data_source_uuid: "" +}); + +ChartMogul.Customer.all(config).then(data => { + data.entries[0]; // $ExpectType Customer + data.entries[0].attributes!.stripe!['something']; // $ExpectType any + data.page!; // $ExpectType number +}); + +// $ExpectType Promise> +ChartMogul.Customer.search(config, { + email: "" +}); +// $ExpectType Promise<{}> +ChartMogul.Customer.merge(config, { + from: {customer_uuid: ""}, + into: {customer_uuid: ""} +}); +// $ExpectType Promise +ChartMogul.Customer.attributes(config, ""); + +// $ExpectType Promise +ChartMogul.Plan.create(config, { + data_source_uuid: "", + name: "", + interval_count: 1, + interval_unit: "", + external_id: "" +}); + +// $ExpectType Promise +ChartMogul.Plan.retrieve(config, ""); + +// $ExpectType Promise +ChartMogul.Plan.modify(config, "", { + name: "" +}); + +// $ExpectType Promise<{}> +ChartMogul.Plan.destroy(config, ""); + +ChartMogul.Plan.all(config, { + page: 1 +}).then(data => { + data.plans[0]; // $ExpectType Plan + data.plans[0].name!; // $ExpectType string + data.page!; // $ExpectType number +}); + +// $ExpectType Promise +ChartMogul.Invoice.retrieve(config, ""); + +// $ExpectType Promise +ChartMogul.Invoice.create(config, "", { + invoices: [ + { + external_id: "" + } + ] +}); + +// $ExpectType Promise<{}> +ChartMogul.Invoice.destroy(config, ""); +ChartMogul.Invoice.all(config, { + external_id: "" +}).then(data => { + data.invoices[0]; // $ExpectType Invoice + data.invoices[0].uuid!; // $ExpectType string + data.page!; // $ExpectType number +}); + +ChartMogul.Invoice.all(config, "", { + page: 1 +}).then(data => { + data.customer_uuid!; // $ExpectType string + data.invoices[0]; // $ExpectType Invoice + data.invoices[0].uuid!; // $ExpectType string + data.page!; // $ExpectType number +}); + +// $ExpectType Promise +ChartMogul.Transaction.create(config, "", { + type: "", + date: "", + result: "" +}); + +ChartMogul.Subscription.all(config, "", { + page: 1 +}).then(data => { + data.customer_uuid!; // $ExpectType string + data.subscriptions[0]; // $ExpectType Subscription + data.subscriptions[0].uuid; // $ExpectType string + data.current_page!; // $ExpectType number +}); + +ChartMogul.Subscription.cancel(config, "", { + cancelled_at: "" +}).then(data => { + data.customer_uuid; // $ExpectType string +}); + +// $ExpectType Promise> +ChartMogul.Tag.add(config, "", { + email: "", + tags: [""] +}); + +// $ExpectType Promise +ChartMogul.Tag.add(config, "", { + tags: [""] +}); + +// $ExpectType Promise +ChartMogul.Tag.remove(config, "", { + tags: [""] +}); + +// $ExpectType Promise +ChartMogul.CustomAttribute.add(config, "", { + custom: [ + {type: "", key: "", value: 0} + ] +}); +// $ExpectType Promise> +ChartMogul.CustomAttribute.add(config, "", { + email: "", + custom: [ + {type: "", key: "", value: 0} + ] +}); + +// $ExpectType Promise +ChartMogul.CustomAttribute.update(config, "", { + custom: { + pro: true, + channel: "" + } +}); + +ChartMogul.CustomAttribute.remove(config, "", { + custom: [""] +}).then(data => { + data.custom["key"]; // $ExpectType any +}); + +// $ExpectType Promise +ChartMogul.Metrics.all(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-24', + interval: '', + geo: '', + plans: '' +}); + +// $ExpectType Promise> +ChartMogul.Metrics.mrr(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-01' +}); + +// $ExpectType Promise> +ChartMogul.Metrics.arr(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-01' +}); + +// $ExpectType Promise> +ChartMogul.Metrics.arpa(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-01' +}); + +// $ExpectType Promise> +ChartMogul.Metrics.asp(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-01' +}); + +// $ExpectType Promise> +ChartMogul.Metrics.customerCount(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-01' +}); + +// $ExpectType Promise> +ChartMogul.Metrics.customerChurnRate(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-01', + geo: '', + plans: '' +}); + +// $ExpectType Promise> +ChartMogul.Metrics.mrrChurnRate(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-01' +}); + +ChartMogul.Metrics.ltv(config, { + 'start-date': '2015-01-01', + 'end-date': '2015-11-01' +}).then(data => { + data.entries[0].ltv; // $ExpectType number + data.summary; // $ExpectType Summary + data.summary.current; // $ExpectType number +}); + +// $ExpectType Promise> +ChartMogul.Metrics.Customer.subscriptions(config, "", { + page: 1 +}); + +ChartMogul.Metrics.Customer.activities(config, "", { + page: 1 +}).then(data => { + data.entries; // $ExpectType MetricsActivity[] + data.entries[0]; // $ExpectType MetricsActivity + data.entries[0]['activity-mrr']; // $ExpectType number + data.page!; // $ExpectType number +}); diff --git a/types/chartmogul-node/common.d.ts b/types/chartmogul-node/common.d.ts new file mode 100644 index 0000000000..ced10f98d7 --- /dev/null +++ b/types/chartmogul-node/common.d.ts @@ -0,0 +1,28 @@ +export interface Map { + [key: string]: any +} +export interface CursorParams { + page?: number; + per_page?: number; +} +export type Strings = string[]; + +export interface Cursor { + page?: number; + per_page?: number; + has_more?: boolean; + current_page?: number; + total_pages?: number; +} +export interface Entries extends Cursor { + entries: T[] +} +interface Summary { + current: number; + previous: number; + ['percentage-change']: number; +} +export interface EntriesSummary { + entries: T[]; + summary: Summary; +} \ No newline at end of file diff --git a/types/chartmogul-node/index.d.ts b/types/chartmogul-node/index.d.ts new file mode 100644 index 0000000000..c4bdce5aca --- /dev/null +++ b/types/chartmogul-node/index.d.ts @@ -0,0 +1,410 @@ +// Type definitions for chartmogul-node 1.0 +// Project: https://github.com/chartmogul/chartmogul-node +// Definitions by: ChartMogul +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Map, Cursor, CursorParams, Strings, Entries, EntriesSummary } from './common'; + +export class Config { + VERSION: string; + API_BASE: string; + retries: number; + + constructor(token: string, secret: string, base?: string); + getAccountToken(): string; + getSecretKey(): string; +} + +export namespace Ping { + function ping(config: Config): Promise; +} + +export namespace DataSource { + interface DataSource { + uuid?: string; + name: string; + created_at?: string; + status?: string; + system?: string; + } + interface DataSources { + data_sources: DataSource[]; + } + interface ListDataSourcesParams { + name?: string; + system?: string; + } + + function create(config: Config, data: DataSource): Promise; + function retrieve(config: Config, uuid: string): Promise; + function destroy(config: Config, uuid: string): Promise<{}>; + function all(config: Config, params?: ListDataSourcesParams): Promise; +} + +export namespace Customer { + interface Customer { + id?: number; + data_source_uuid?: string; + data_source_uuids?: Strings; + uuid?: string; + external_id?: string; + external_ids?: Strings; + name?: string; + email?: string; + status?: string; + ['customer-since']?: string; + attributes?: Attributes; + address?: { + address_zip?: string; + city?: string; + state?: string; + country?: string; + }; + mrr?: number; + arr?: number; + ['billing-system-url']?: string; + ['chartmogul-url']?: string; + ['billing-system-type']?: string; + currency?: string; + ['currency-sign']?: string; + company?: string; + country?: string; + state?: string; + city?: string; + zip?: string; + lead_created_at?: string; + free_trial_started_at?: string; + } + interface NewCustomer { + data_source_uuid: string; + external_id: string; + name: string; + email?: string; + company?: string; + country?: string; + state?: string; + city?: string; + zip?: string; + lead_created_at?: string; + free_trial_started_at?: string; + attributes?: NewAttributes; + } + interface UpdateCustomer { + name?: string; + email?: string; + company?: string; + country?: string; + state?: string; + city?: string; + zip?: string; + lead_created_at?: string; + free_trial_started_at?: string; + attributes?: NewAttributes; + } + interface NewAttributes { + tags?: Strings; + custom?: NewCustomAttributes[]; + } + interface NewCustomAttributes { + type?: string; + key: string; + value: any; + source?: string; + } + interface Attributes { + tags?: Strings; + stripe?: Map; + clearbit?: Map; + custom?: Map; + } + interface ListCustomersParams extends CursorParams { + data_source_uuid?: string; + status?: string; + system?: string; + external_id?: string; + } + interface SearchCustomersParams extends CursorParams { + email: string; + } + interface MergeID { + customer_uuid?: string; + external_id?: string; + } + interface MergeCustomersParams { + from: MergeID; + into: MergeID; + } + + function create(config: Config, data: NewCustomer): Promise; + function retrieve(config: Config, uuid: string): Promise; + function modify(config: Config, uuid: string, data: UpdateCustomer): Promise; + function destroy(config: Config, uuid: string): Promise<{}>; + function all(config: Config, params?: ListCustomersParams): Promise>; + function search(config: Config, params?: SearchCustomersParams): Promise>; + function merge(config: Config, params?: MergeCustomersParams): Promise<{}>; + function attributes(config: Config, uuid: string): Promise; +} + +export namespace Plan { + interface Plan { + uuid?: string; + data_source_uuid?: string; + external_id?: string; + name?: string; + interval_count?: number; + interval_unit?: string; + } + interface ListPlansParams extends CursorParams { + data_source_uuid?: string; + system?: string; + external_id?: string; + } + interface Plans extends Cursor { + plans: Plan[]; + } + + function create(config: Config, data: Plan): Promise; + function retrieve(config: Config, uuid: string): Promise; + function modify(config: Config, uuid: string, data: Plan): Promise; + function destroy(config: Config, uuid: string): Promise<{}>; + function all(config: Config, params?: ListPlansParams): Promise; +} + +export namespace Invoice { + interface Invoice { + uuid?: string; + customer_uuid?: string; + currency?: string; + data_source_uuid?: string; + date?: string; + due_date?: string; + external_id?: string; + line_items?: LineItem[]; + transactions?: Transaction[]; + } + interface LineItem { + uuid?: string; + account_code?: string; + amount_in_cents?: number; + cancelled_at?: string; + description?: string; + discount_amount_in_cents?: number; + discount_code?: string; + external_id?: string; + plan_uuid?: string; + prorated?: boolean; + quantity?: number; + service_period_end?: string; + service_period_start?: string; + subscription_external_id?: string; + subscription_uuid?: string; + tax_amount_in_cents?: number; + transaction_fees_in_cents?: number; + type?: string; + } + interface Transaction { + uuid?: string; + date?: string; + external_id?: string; + result?: string; + type?: string; + } + interface ListInvoicesParams extends CursorParams { + data_source_uuid?: string; + customer_uuid?: string; + external_id?: string; + } + interface Invoices extends Cursor { + customer_uuid?: string; + invoices: Invoice[]; + } + + function create(config: Config, uuid: string, data: { + invoices: Invoice[] + }): Promise; + function retrieve(config: Config, uuid: string): Promise; + function destroy(config: Config, uuid: string): Promise<{}>; + function all(config: Config, uuid: string, params?: ListInvoicesParams): Promise; + function all(config: Config, params?: ListInvoicesParams): Promise; +} + +export namespace Transaction { + interface Transaction { + uuid?: string; + date: string; + external_id?: string; + result: string; + type: string; + } + + function create(config: Config, uuid: string, data: Transaction): Promise; +} + +export namespace Subscription { + interface Subscription { + uuid: string; + external_id: string; + customer_uuid: string; + plan_uuid: string; + cancellation_dates: Strings; + data_source_uuid: string; + } + interface CancelSubscriptionParams { + cancelled_at?: string; + cancellation_dates?: Strings; + } + interface Subscriptions extends Cursor { + customer_uuid?: string; + subscriptions: Subscription[]; + } + + function all(config: Config, uuid: string, data: CursorParams): Promise; + function cancel(config: Config, uuid: string, data: CancelSubscriptionParams): Promise; +} + +export namespace Tag { + interface Tags { + tags: Strings; + } + interface TagsWithEmail { + email: string; + tags: Strings; + } + function add(config: Config, uuid: string, data: TagsWithEmail): Promise>; + function add(config: Config, uuid: string, data: Tags): Promise; + function remove(config: Config, uuid: string, data: Tags): Promise; +} + +export namespace CustomAttribute { + import NewCustomAttributes = Customer.NewCustomAttributes; + + interface CustomAttributes { + custom: Map; + } + function add(config: Config, uuid: string, data: { + email: string; + custom: NewCustomAttributes[]; + }): Promise>; + function add(config: Config, uuid: string, data: { + custom: NewCustomAttributes[]; + }): Promise; + function update(config: Config, uuid: string, data: CustomAttributes): Promise; + function remove(config: Config, uuid: string, data: { + custom: Strings; + }): Promise; +} + +export namespace Metrics { + interface Params extends ParamsNoInterval { + interval?: string; + } + interface ParamsNoInterval { + ['start-date']: string; + ['end-date']: string; + geo?: string; + plans?: string; + } + interface All { + entries: { + date: string; + ['customer-churn-rate']: number; + ['mrr-churn-rate']: number; + ltv: number; + customers: number; + asp: number; + arpa: number; + arr: number; + mrr: number; + }; + } + + interface MRR { + date: string; + mrr: number; + ['mrr-new-business']: number; + ['mrr-expansion']: number; + ['mrr-contraction']: number; + ['mrr-churn']: number; + ['mrr-reactivation']: number; + } + interface ARR { + date: string; + arr: number; + } + interface ARPA { + date: string; + arpa: number; + } + interface ASP { + date: string; + asp: number; + } + interface CustomerCount { + date: string; + customers: number; + } + interface CustomerChurnRate { + date: string; + ['customer-churn-rate']: number; + } + interface MRRChurnRate { + date: string; + ['mrr-churn-rate']: number; + } + interface LTV { + date: string; + ltv: number; + } + + function all(config: Config, params: Params): Promise; + function mrr(config: Config, params: Params): Promise>; + function arr(config: Config, params: Params): Promise>; + function asp(config: Config, params: Params): Promise>; + function arpa(config: Config, params: Params): Promise>; + function customerCount(config: Config, params: Params): Promise>; + function customerChurnRate(config: Config, params: ParamsNoInterval): Promise>; + function mrrChurnRate(config: Config, params: ParamsNoInterval): Promise>; + function ltv(config: Config, params: ParamsNoInterval): Promise>; + + namespace Customer { + interface MetricsSubscription { + id: number; + external_id: string; + plan: string; + quantity: number; + mrr: number; + arr: number; + status: string; + ['billing-cycle']: string; + ['billing-cycle-count']: number; + ['start-date']: string; + ['end-date']: string; + currency: string; + ['currency-sign']: string; + } + interface MetricsActivity { + id: number; + date: string; + ['activity-arr']: number; + ['activity-mrr']: number; + ['activity-mrr-movement']: number; + currency: string; + ['currency-sign']: string; + description: string; + type: string; + } + + function subscriptions(config: Config, uuid: string, params?: CursorParams): Promise>; + function activities(config: Config, uuid: string, params?: CursorParams): Promise>; + } +} + +export class ChartMogulError extends Error { + response: any; + httpStatus: number; +} +export class ConfigurationError extends ChartMogulError {} +export class ForbiddenError extends ChartMogulError {} +export class NotFoundError extends ChartMogulError {} +export class ResourceInvalidError extends ChartMogulError {} +export class SchemaInvalidError extends ChartMogulError {} diff --git a/types/chartmogul-node/tsconfig.json b/types/chartmogul-node/tsconfig.json new file mode 100644 index 0000000000..3b24d48da8 --- /dev/null +++ b/types/chartmogul-node/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chartmogul-node-tests.ts" + ] +} diff --git a/types/chartmogul-node/tslint.json b/types/chartmogul-node/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/chartmogul-node/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/dav/dav-tests.ts b/types/dav/dav-tests.ts new file mode 100644 index 0000000000..6a31df698d --- /dev/null +++ b/types/dav/dav-tests.ts @@ -0,0 +1,250 @@ +import * as dav from "dav"; + +(() => { + const xhr = new dav.transport.Basic( + new dav.Credentials({ + username: 'xxx', + password: 'xxx' + }) + ); + + dav.createAccount({ server: 'http://dav.example.com', xhr }) + .then((account) => { + account.calendars.forEach(() => { + }); + }); + const client = new dav.Client(xhr); + + client.createAccount({ + server: 'http://dav.example.com', + accountType: 'carddav' + }).then((account) => { + account.addressBooks.forEach(() => { + }); + }); +})(); + +(() => { + const client = new dav.Client( + new dav.transport.Basic( + new dav.Credentials({ + username: 'xxx', + password: 'xxx' + }) + ), + { + baseUrl: 'https://mail.mozilla.com' + } + ); + + const req = dav.request.basic({ + method: 'PUT', + data: 'BEGIN:VCALENDAR\nEND:VCALENDAR', + etag: '12345' + }); + + client.send(req, '/calendars/123.ics') + .then(() => { }); +})(); + +(() => { + const xhr = new dav.transport.Basic( + new dav.Credentials({ + username: 'xxx', + password: 'xxx' + }) + ); + + const req = dav.request.basic({ + method: 'PUT', + data: 'BEGIN:VCALENDAR\nEND:VCALENDAR', + etag: '12345' + }); + + xhr.send(req, 'https://mail.mozilla.com/calendars/123.ics') + .then(() => { + }); +})(); + +dav.debug.enabled = true; + +(() => { + const xhr = new dav.transport.Basic( + new dav.Credentials({ + username: 'Killer BOB', + password: 'blacklodge' + }) + ); + + const client = new dav.Client(xhr, { baseUrl: 'https://mail.mozilla.com' }); + + const url = 'https://mail.mozilla.com/'; + const req = dav.request.basic({ + method: 'PUT', + data: 'BEGIN:VCALENDAR\nEND:VCALENDAR', + etag: 'abc123' + }); + + const sandbox = dav.createSandbox(); + client.send(req, url, { sandbox }); + xhr.send(req, url, { sandbox }); + + client.createAccount({ sandbox: {}, server: 'http://dav.example.com' }); + dav.createAccount({ + sandbox: {}, + server: 'http://dav.example.com', + xhr + }); + + let calendar = new dav.Calendar(); + client.createCalendarObject(calendar, { + data: 'BEGIN:VCALENDAR\nEND:VCALENDAR', + filename: 'test.ics' + }); + dav.createCalendarObject( + calendar, + { + data: 'BEGIN:VCALENDAR\nEND:VCALENDAR', + filename: 'test.ics', + xhr + }); + + let object = new dav.CalendarObject(); + client.updateCalendarObject(object); + dav.updateCalendarObject( + object, + { + xhr + } + ); + + object = new dav.CalendarObject(); + client.deleteCalendarObject(object); + dav.deleteCalendarObject( + object, + { + xhr + } + ); + + calendar = new dav.Calendar(); + client.syncCalendar(calendar, { syncMethod: 'webdav' }); + dav.syncCalendar( + calendar, + { + syncMethod: 'webdav', + xhr + } + ); + + let account = new dav.Account(); + client.syncCaldavAccount(account, { syncMethod: 'webdav' }); + dav.syncCaldavAccount( + account, + { + syncMethod: 'webdav', + xhr + } + ); + + let addressBook = new dav.AddressBook(); + client.createCard(addressBook, { + data: 'BEGIN:VCARD\nEND:VCARD', + filename: 'test.vcf' + }); + dav.createCard(addressBook, + { + data: 'BEGIN:VCARD\nEND:VCARD', + filename: 'test.vcf', + xhr + }); + + let vcard = new dav.VCard(); + client.updateCard(vcard); + dav.updateCard( + vcard, + { + xhr + } + ); + vcard = new dav.VCard(); + client.deleteCard(vcard); + dav.deleteCard( + vcard, + { + xhr + }); + + addressBook = new dav.AddressBook(); + client.syncAddressBook(addressBook, { + syncMethod: 'basic' + }); + + dav.syncAddressBook( + addressBook, + { + syncMethod: 'basic', + xhr + }); + + account = new dav.Account(); + client.syncCarddavAccount(account, { syncMethod: 'basic' }); + + dav.syncCarddavAccount( + account, + { + syncMethod: 'basic', + xhr + }); +})(); + +(() => { + const xhr = new dav.transport.Basic( + new dav.Credentials({ username: 'admin', password: 'admin' }) + ); + + const req: dav.Request = { + method: 'GET', + transformRequest: (xhr: any) => xhr + }; + + const sandbox = dav.createSandbox(); + xhr.send(req, 'http://127.0.0.1:1337', { sandbox }); + sandbox.requestList; + + xhr.send(req, 'http://127.0.0.1:1337'); +})(); + +(() => { + const credentials = new dav.Credentials({ + clientId: '605300196874-1ki833poa7uqabmh3hq' + + '6u1onlqlsi54h.apps.googleusercontent.com', + clientSecret: 'jQTKlOhF-RclGaGJot3HIcVf', + redirectUrl: 'https://oauth.gaiamobile.org/authenticated', + tokenUrl: 'https://accounts.google.com/o/oauth2/token', + authorizationCode: 'gareth' + }); + + const xhr = new dav.transport.OAuth2(credentials); + + const req = { method: 'GET' }; + + credentials.accessToken = 'EXPIRED'; + credentials.refreshToken = '1/oPHTPFgECWFPrs7KgHdis24u6Xl4E4EnRrkkiwLfzdk'; + credentials.expiration = Date.now() - 1; + + xhr.send(req, 'http://127.0.0.1:1337', { + retry: false + }); + + credentials.accessToken = 'Little Bear'; + credentials.refreshToken = 'spicy tamales'; + const expiration = credentials.expiration = Date.now() + 60 * 60 * 1000; + + credentials.accessToken = 'EXPIRED'; + credentials.refreshToken = 'raspberry pie'; + credentials.expiration = Date.now() + 60 * 60 * 1000; + + credentials.accessToken = 'EXPIRED'; + credentials.refreshToken = 'soda'; +})(); diff --git a/types/dav/index.d.ts b/types/dav/index.d.ts new file mode 100644 index 0000000000..6b1b09e326 --- /dev/null +++ b/types/dav/index.d.ts @@ -0,0 +1,804 @@ +// Type definitions for dav 1.7 +// Project: https://github.com/lambdabaa/dav/ +// Definitions by: ToastHawaii +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export let version: string; + +/** + * Perform an initial download of a caldav or carddav account's data. + * @param options + * @returns a Promise which will be fulfilled with a dav.Account object. + */ +export function createAccount(options: CreateAccountOptions): Promise; + +export interface CreateAccountOptions { + /** + * one of 'caldav' or 'carddav'. Defaults to 'caldav'. + */ + accountType?: "caldav" | "carddav"; + + /** + * list of caldav filters to send with request. + */ + filters?: object[]; + + /** + * whether or not to load dav collections. + */ + loadCollections?: boolean; + + /** + * whether or not to load dav objects. + */ + loadObjects?: boolean; + + /** + * request sandox. + */ + sandbox?: Sandbox | {}; + + /** + * some url for server (needn't be base url). + */ + server: string; + + /** + * VTIMEZONE calendar object. + */ + timezone?: string; + + /** + * request sender. + */ + + xhr?: transport.Transport; +} + +/** + * Create a calendar object on the parameter calendar. + * @param calendar the calendar to put the object on. + * @param options + * @returns a Promise which will be fulfilled when the calendar has been created. + */ +export function createCalendarObject(calendar: Calendar, options: CreateCalendarObjectOptions): Promise; + +export interface CreateCalendarObjectOptions { + /** + * rfc 5545 VCALENDAR object. + */ + data: string; + + /** + * name for the calendar ics file. + */ + filename: string; + + /** + * request sandbox. + */ + sandbox?: Sandbox; + + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Persist updates to the parameter calendar object to the server. + * @param calendarObject updated calendar object. + * @param options + * @returns a Promise which will be fulfilled when the calendar has been updated. + */ +export function updateCalendarObject(calendarObject: CalendarObject, options: UpdateCalendarObjectOptions): Promise; + +export interface UpdateCalendarObjectOptions { + /** + * request sandbox. + */ + sandbox?: Sandbox; + + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Delete the parameter calendar object on the server. + * @param calendarObject target calendar object. + * @param options + * @returns a Promise which will be fulfilled when the calendar has been deleted. + */ +export function deleteCalendarObject(calendarObject: CalendarObject, options: DeleteCalendarObjectOptions): Promise; + +export interface DeleteCalendarObjectOptions { + /** + * request sandbox. + */ + sandbox?: Sandbox; + + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Fetch changes from the remote server to the parameter calendar. + * @param calendar the calendar to fetch changes for. + * @param options + * @returns a Promise which will be fulfilled with an updated dav.Calendar object once sync is complete. + */ +export function syncCalendar(calendar: Calendar, options: SyncCalendarOptions): Promise; + +export interface SyncCalendarOptions { + /** + * list of caldav filters to send with request. + */ + filters?: object[]; + + /** + * request sandbox. + */ + sandbox?: Sandbox; + + /** + * either 'basic' or 'webdav'. If unspecified, will try to do webdav sync + * and failover to basic sync if rfc 6578 is not supported by the server. + */ + syncMethod?: "basic" | "webdav"; + + /** + * VTIMEZONE calendar object. + */ + timezone?: string; + + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Fetch changes from the remote server to the account's calendars. + * @param account the calendar account to sync. + * @param options + * @returns a Promise which will be fulfilled with an updated dav.Account object once sync is complete. + */ +export function syncCaldavAccount(account: Account, options: SyncCaldavAccountOptions): Promise; + +export interface SyncCaldavAccountOptions { + /** + * list of caldav filters to send with request. + */ + filters?: object[]; + + /** + * request sandbox. + */ + sandbox?: Sandbox; + + /** + * either 'basic' or 'webdav'. If unspecified, will try to do webdav sync + * and failover to basic sync if rfc 6578 is not supported by the server. + */ + syncMethod?: "basic" | "webdav"; + + /** + * VTIMEZONE calendar object. + */ + timezone?: string; + + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Create a vcard object on the parameter address book. + * @param addressBook the address book to put the object on. + * @param options + * @returns a Promise which will be fulfilled when the vcard has been created. + */ +export function createCard(addressBook: AddressBook, options: CreateCardOptions): Promise; + +export interface CreateCardOptions { + /** + * VCARD object. + */ + data: string; + /** + * name for the vcard vcf file. + */ + filename: string; + + /** + * request sandbox. + */ + sandbox?: Sandbox; + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Persist updates to the parameter vcard object to the server. + * @param card updated vcard object. + * @param options + * @returns a Promise which will be fulfilled when the vcard has been updated. + */ +export function updateCard(card: VCard, options: UpdateCardOptions): Promise; + +export interface UpdateCardOptions { + /** + * request sandbox. + */ + sandbox?: Sandbox; + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Delete the parameter vcard object on the server. + * @param card target vcard object. + * @param options + * @returns a Promise which will be fulfilled when the vcard has been deleted. + */ +export function deleteCard(card: VCard, options: DeleteCardOptions): Promise; + +export interface DeleteCardOptions { + /** + * request sandbox. + */ + sandbox?: Sandbox; + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Fetch changes from the remote server to the parameter address books. + * @param addressBook the address book to fetch changes for. + * @param options + * @returns a Promise which will be fulfilled with an updated AddressBook object once sync is complete. + */ +export function syncAddressBook(addressBook: AddressBook, options: SyncAddressBookOptions): Promise; + +export interface SyncAddressBookOptions { + /** + * request sandbox. + */ + sandbox?: Sandbox; + /** + * either 'basic' or 'webdav'.If unspecified, will try to do webdav sync + * and failover to basic sync if rfc 6578 is not supported by the server. + */ + syncMethod?: "basic" | "webdav"; + + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Fetch changes from the remote server to the account's address books. + * @param account the address book account to sync. + * @param options + * @returns a Promise which will be fulfilled with an updated Account object once sync is complete. + */ +export function syncCarddavAccount(account: Account, options: SyncCarddavAccountOptions): Promise; + +export interface SyncCarddavAccountOptions { + /** + * list of caldav filters to send with request. + */ + filters?: object[]; + + /** + * request sandbox. + */ + sandbox?: Sandbox; + + /** + * either 'basic' or 'webdav'. If unspecified, will try to do webdav sync + * and failover to basic sync if rfc 6578 is not supported by the server. + */ + syncMethod?: "basic" | "webdav"; + + /** + * VTIMEZONE calendar object. + */ + timezone?: string; + + /** + * request sender. + */ + xhr?: transport.Transport; +} + +/** + * Create a request sandbox. + */ +export class Sandbox { + constructor(); + + requestList: any[]; + + add(request: any): void; + + /** + * abort sandboxed requests as a group. + */ + abort(): void; +} + +/** + * @deprecated + */ +export function createSandbox(): Sandbox; + +export namespace transport { + class Transport { + /** + * @param credentials user authorization. + */ + constructor(credentials: Credentials); + + send(request: Request, url: string, options?: TransportOptions): Promise; + } + + interface TransportOptions { + /** + * request sandbox. + */ + sandbox?: Sandbox; + + retry?: boolean; + } + + class Basic extends Transport { + /** + * Create a new Basic object. This sends dav requests using http basic authentication. + * @param credentials user authorization. + */ + constructor(credentials: Credentials); + + /** + * + * @param request object with request info. + * @param url + * @param options + * @return a promise that will be resolved with an xhr request after + * its readyState is 4 or the result of applying an optional request + * `transformResponse` function to the xhr object after its readyState + * is 4. + */ + send(request: Request, url: string, options?: TransportOptions): Promise; + } + + /** + * Create a new OAuth2 object.This sends dav requests authorized via rfc 6749 oauth2. + * @param credentials user authorization. + */ + class OAuth2 extends Transport { + constructor(credentials: Credentials); + + /** + * + * @param request object with request info. + * @param url + * @param options + * @return a promise that will be resolved with an xhr request after + * its readyState is 4 or the result of applying an optional request + * `transformResponse` function to the xhr object after its readyState + * is 4. + */ + send(request: Request, url: string, options?: TransportOptions): Promise; + } +} + +export namespace request { + /** + * + * @param options + * @returns + */ + function addressBookQuery(options: AddressBookQueryOptions): string; + + interface AddressBookQueryOptions { + /** + * value for Depth header. + */ + depth?: string; + + /** + * list of props to request. + */ + props: object[]; + } + + /** + * + * @param options + * @returns + */ + function basic(options: BasicOptions): Request; + + interface BasicOptions { + /** + * put request body. + */ + data: string; + + /** + * http method. + */ + method: string; + + /** + * cached calendar object etag. + */ + etag: string; + } + + /** + * + * @param options + * @returns + */ + function calendarQuery(options: CalendarQueryOptions): string; + + interface CalendarQueryOptions { + /** + * value for Depth header. + */ + depth?: string; + + /** + * list of filters to send with request. + */ + filters: object[]; + + /** + * list of props to request. + */ + props: object[]; + + /** + * VTIMEZONE calendar object. + */ + timezone: string; + } + + /** + * + * @param options + * @returns + */ + function propfind(options: PropfindOptions): string; + + interface PropfindOptions { + /** + * value for Depth header. + */ + depth?: string; + + /** + * list of props to request. + */ + props: object[]; + } + + /** + * + * @param options + * @returns + */ + function syncCollection(options: SyncCollectionOptions): string; + + interface SyncCollectionOptions { + /** + * option value for Depth header. + */ + depth?: string; + + /** + * list of props to request. + */ + props: object[]; + + /** + * indicates scope of the sync report request. + */ + syncLevel: number; + + /** + * synchronization token provided by the server. + */ + syncToken: string; + } +} + +export class Client { + /** + * Create a new Client object. The client interface allows consumers to set + * their credentials and transport once and then make authorized requests + * without passing them to each request. Each of the other, public API + * methods should be available on Client objects. + * @param xhr request sender. + * @param options + */ + constructor(xhr: transport.Transport, options?: ClientOptions); + + /** + * Send a request using this client's transport (and perhaps baseUrl). + * @param req dav request. + * @param options + * @return a promise that will be resolved with an xhr request after + * its readyState is 4 or the result of applying an optional request + * `transformResponse` function to the xhr object after its readyState + * is 4. + */ + send(req: Request, uri: string, options?: ClientSendOptions): Promise; + + /** + * Perform an initial download of a caldav or carddav account's data. + * @param options + * @returns a Promise which will be fulfilled with a dav.Account object. + */ + createAccount(options?: CreateAccountOptions): Promise; + + /** + * Create a calendar object on the parameter calendar. + * @param calendar the calendar to put the object on. + * @param options + * @returns a Promise which will be fulfilled when the calendar has been created. + */ + createCalendarObject(calendar: Calendar, options?: CreateCalendarObjectOptions): Promise; + + /** + * Persist updates to the parameter calendar object to the server. + * @param calendarObject updated calendar object. + * @param options + * @returns a Promise which will be fulfilled when the calendar has been updated. + */ + updateCalendarObject(calendarObject: CalendarObject, options?: UpdateCalendarObjectOptions): Promise; + + /** + * Delete the parameter calendar object on the server. + * @param calendarObject target calendar object. + * @param options + * @returns a Promise which will be fulfilled when the calendar has been deleted. + */ + deleteCalendarObject(calendarObject: CalendarObject, options?: DeleteCalendarObjectOptions): Promise; + + /** + * Fetch changes from the remote server to the parameter calendar. + * @param calendar the calendar to fetch changes for. + * @param options + * @returns a Promise which will be fulfilled with an updated dav.Calendar object once sync is complete. + */ + syncCalendar(calendar: Calendar, options?: SyncCalendarOptions): Promise; + + /** + * Fetch changes from the remote server to the account's calendars. + * @param account the calendar account to sync. + * @param options + * @returns a Promise which will be fulfilled with an updated dav.Account object once sync is complete. + */ + syncCaldavAccount(account: Account, options?: SyncCaldavAccountOptions): Promise; + + /** + * Create a vcard object on the parameter address book. + * @param addressBook the address book to put the object on. + * @param options + * @returns a Promise which will be fulfilled when the vcard has been created. + */ + createCard(addressBook: AddressBook, options?: CreateCardOptions): Promise; + + /** + * Persist updates to the parameter vcard object to the server. + * @param card updated vcard object. + * @param options + * @returns a Promise which will be fulfilled when the vcard has been updated. + */ + updateCard(card: VCard, options?: UpdateCardOptions): Promise; + + /** + * + * Delete the parameter vcard object on the server. + * @param card target vcard object. + * @param options + * @returns a Promise which will be fulfilled when the vcard has been deleted. + */ + deleteCard(card: VCard, options?: DeleteCardOptions): Promise; + + /** + * Fetch changes from the remote server to the parameter address books. + * @param addressBook the address book to fetch changes for. + * @param options + * @returns a Promise which will be fulfilled with an updated AddressBook object once sync is complete. + */ + syncAddressBook(addressBook: AddressBook, options?: SyncAddressBookOptions): Promise; + + /** + * Fetch changes from the remote server to the account's address books. + * @param account the address book account to sync. + * @param options + * @returns a Promise which will be fulfilled with an updated Account object once sync is complete. + */ + syncCarddavAccount(account: Account, options?: SyncCarddavAccountOptions): Promise; +} + +export interface ClientOptions { + /** + * root url to resolve relative request urls with. + */ + baseUrl: string; +} + +export interface ClientSendOptions { + /** + * request sandbox. + */ + sandbox?: Sandbox; + /** + * relative url for request. + */ + url?: string; +} + +export type Partial = { + [P in keyof T]?: T[P]; +}; + +export class Account { + constructor(options?: AccountOptions); + server: string; + credentials: Credentials; + rootUrl: string; + principalUrl: string; + homeUrl: string; + calendars: Calendar[]; + addressBooks: AddressBook[]; +} + +export type AccountOptions = Partial; + +export class Credentials { + constructor(options?: CredentialsOptions); + + /** + * username (perhaps email) for calendar user. + */ + username: string; + + /** + * plaintext password for calendar user. + */ + password: string; + + /** + * oauth client id. + */ + clientId: string; + + /** + * oauth client secret. + */ + clientSecret: string; + + /** + * oauth code. + */ + authorizationCode: string; + + /** + * oauth redirect url. + */ + redirectUrl: string; + + /** + * oauth token url. + */ + tokenUrl: string; + + /** + * oauth access token. + */ + accessToken: string; + + /** + * oauth refresh token. + */ + refreshToken: string; + + /** + * unix time for access token expiration. + */ + expiration: number; +} +export type CredentialsOptions = Partial; + +export class DAVCollection { + constructor(options: DAVCollectionOptions); + data: string; + objects: T[]; + account: Account; + ctag: string; + description: string; + displayName: string; + reports: string[]; + resourcetype: string; + syncToken: string; + url: string; +} +export type DAVCollectionOptions = Partial>; + +export class AddressBook extends DAVCollection { + constructor(options?: AddressBookOptions); +} +export type AddressBookOptions = Partial; + +export class Calendar extends DAVCollection { + constructor(options?: CalendarOptions); + + components: string[]; + timezone: string; +} +export type CalendarOptions = Partial; + +export class DAVObject { + constructor(options: DAVObjectOptions); + data: string; + etag: string; + url: string; +} +export type DAVObjectOptions = Partial; + +export class CalendarObject extends DAVObject { + constructor(options?: CalendarObjectOptions); + calendar: Calendar; + calendarData: string; +} +export type CalendarObjectOptions = Partial; + +export class VCard extends DAVObject { + constructor(options?: VCardOptions); + addressBook: AddressBook; + addressData: string; +} + +export type VCardOptions = Partial; + +export class Request { + constructor(options?: RequestOptions); + method: string; + requestData?: string; + transformRequest?: (xhr: any) => any; + transformResponse?: (xhr: any) => any; + onerror?: (error: Error) => any; +} + +export type RequestOptions = Partial; + +export namespace debug { + let enabled: boolean; +} + +export namespace ns { + const CALENDAR_SERVER = 'http://calendarserver.org/ns/'; + const CALDAV_APPLE = 'http://apple.com/ns/ical/'; + const CALDAV = 'urn:ietf:params:xml:ns:caldav'; + const CARDDAV = 'urn:ietf:params:xml:ns:carddav'; + const DAV = 'DAV:'; +} diff --git a/types/dav/tsconfig.json b/types/dav/tsconfig.json new file mode 100644 index 0000000000..5de3437644 --- /dev/null +++ b/types/dav/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dav-tests.ts" + ] +} \ No newline at end of file diff --git a/types/dav/tslint.json b/types/dav/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/dav/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file diff --git a/types/dialogflow/dialogflow-tests.ts b/types/dialogflow/dialogflow-tests.ts new file mode 100644 index 0000000000..42d905839e --- /dev/null +++ b/types/dialogflow/dialogflow-tests.ts @@ -0,0 +1,10 @@ +import * as dialogflow from "dialogflow"; + +const agentsClient = new dialogflow.AgentsClient(); +const contextsClient = new dialogflow.ContextsClient(); +const entityTypesClient = new dialogflow.EntityTypesClient(); +const intentsClient = new dialogflow.IntentsClient(); +const sessionEntityTypesClient = new dialogflow.SessionEntityTypesClient(); +const sessionsClient = new dialogflow.SessionsClient(); + +// TODO: Add real significant tests diff --git a/types/dialogflow/index.d.ts b/types/dialogflow/index.d.ts new file mode 100644 index 0000000000..c847b662c2 --- /dev/null +++ b/types/dialogflow/index.d.ts @@ -0,0 +1,927 @@ +// Type definitions for dialogflow 0.6 +// Project: https://github.com/dialogflow/dialogflow-nodejs-client-v2#readme +// Definitions by: Daniel Dyla +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export namespace v2 { + class AgentsClient { + constructor(options?: ClientOptions); + + servicePath: string; + port: number; + scopes: string[]; + + getProjectId(): Promise; + getProjectId(callback?: (error: Error, id: string) => string): void; + + getAgent( + request: GetAgentRequest, + options?: gax.CallOptions, + cb?: (err: Error, agent: Agent) => void + ): Promise<[Agent]>; + searchAgents( + request: SearchAgentRequest, + options?: gax.CallOptions, + cb?: ( + err: Error, + agents: Agent[], + arg3: any, + response: any + ) => void + ): Promise; + searchAgentsStream( + request: SearchAgentRequest, + options?: gax.CallOptions + ): any; + trainAgent( + request: TrainAgentRequest, + options?: gax.CallOptions, + cb?: (err: Error, operation: gax.Operation) => void + ): Promise<[gax.Operation]>; + exportAgent( + request: ExportAgentRequest, + options?: gax.CallOptions, + cb?: (err: Error, operation: gax.Operation) => void + ): Promise<[gax.Operation]>; + importAgent( + request: ImportAgentRequest, + options?: gax.CallOptions, + cb?: (err: Error, operation: gax.Operation) => void + ): Promise<[gax.Operation]>; + restoreAgent( + request: RestoreAgentRequest, + options?: gax.CallOptions, + cb?: (err: Error, operation: gax.Operation) => void + ): Promise<[gax.Operation]>; + } + + class ContextsClient { + constructor(options?: ClientOptions); + + servicePath: string; + port: number; + scopes: string[]; + + getProjectId(): Promise; + getProjectId(callback?: (error: Error, id: string) => string): void; + + listContexts( + request: ListContextsRequest, + options?: gax.CallOptions + ): Promise<[Context[]]>; + listContextsStream( + request: ListContextsRequest, + options?: gax.CallOptions + ): any; + getContext( + request: GetContextRequest, + options?: gax.CallOptions + ): Promise<[Context]>; + createContext( + request: CreateContextReqeust, + options?: gax.CallOptions + ): Promise<[Context]>; + updateContext( + request: UpdateContextRequest, + options?: gax.CallOptions + ): Promise<[Context]>; + deleteContext( + request: DeleteContextRequest, + options?: gax.CallOptions + ): Promise; + deleteAllContexts( + request: DeleteAllContextsRequest, + options?: gax.CallOptions + ): Promise; + + sessionPath(project: string, session: string): string; + contextPath(project: string, session: string, context: string): string; + + matchProjectFromContextName(name: string): string; + matchSessionFromContextName(name: string): string; + matchContextFromContextName(name: string): string; + + matchProjectFromSessionName(name: string): string; + matchSessionFromSessionName(name: string): string; + } + + class EntityTypesClient { + constructor(options?: ClientOptions); + + servicePath: string; + port: number; + scopes: string[]; + + getProjectId(): Promise; + getProjectId(callback?: (error: Error, id: string) => string): void; + + listEntityTypes( + request: ListEntityTypesRequest, + options?: gax.CallOptions + ): Promise<[EntityType[]]>; + + listEntityTypesStream( + request: ListEntityTypesRequest, + options?: gax.CallOptions + ): any; + + getEntityType( + request: GetEntityTypeRequest, + options?: gax.CallOptions + ): Promise<[EntityType]>; + createEntityType( + request: CreateEntityTypeRequest, + options?: gax.CallOptions + ): Promise<[EntityType]>; + updateEntityType( + request: UpdateEntityTypeRequest, + options?: gax.CallOptions + ): Promise<[EntityType]>; + deleteEntityType( + request: DeleteEntityTypeRequest, + options?: gax.CallOptions + ): Promise; + + // TODO: add batch style calls + // batchUpdateEntityTypes + // batchDeleteEntityTypes + // batchCreateEntities + // batchUpdateEntities + // batchDeleteEntities + + projectAgentPath(project: string): string; + entityTypePath(project: string, entityType: string): string; + matchProjectFromProjectAgentName(entityTypeName: string): string; + matchProjectFromEntityTypeName(entityTypeName: string): string; + matchEntityTypeFromEntityTypeName(entityTypeName: string): string; + } + + class IntentsClient { + constructor(options?: ClientOptions); + + servicePath: string; + port: number; + scopes: string[]; + + getProjectId(): Promise; + getProjectId(callback?: (error: Error, id: string) => string): void; + + listIntents( + request: ListIntentsRequest, + options?: gax.CallOptions + ): Promise<[Intent[]]>; + getIntent( + request: GetIntentRequest, + options?: gax.CallOptions + ): Promise<[Intent]>; + createIntent( + request: CreateIntentRequest, + options?: gax.CallOptions + ): Promise<[Intent]>; + updateIntent( + request: UpdateIntentRequest, + options?: gax.CallOptions + ): Promise<[Intent]>; + deleteIntent( + request: DeleteIntentRequest, + options?: gax.CallOptions + ): Promise; + + // TODO: add batch style calls + // batchUpdateIntents(request: BatchUpdateIntentsRequest): void; + // batchDeleteIntents(request: BatchDeleteIntentsRequest): void; + + projectAgentPath(project: string): string; + intentPath(project: string, intent: string): string; + agentPath(project: string, agent: string): string; + + matchProjectFromProjectAgentName(projectAgentName: string): string; + matchProjectFromIntentName(intentName: string): string; + matchIntentFromIntentName(intentName: string): string; + matchProjectFromAgentName(agentName: string): string; + matchAgentFromAgentName(agentName: string): string; + } + + class SessionEntityTypesClient { + constructor(options?: ClientOptions); + + servicePath: string; + port: number; + scopes: string[]; + + getProjectId(): Promise; + getProjectId(callback?: (error: Error, id: string) => string): void; + + // TODO: add Session Entity Types service methods + } + + class SessionsClient { + constructor(options?: ClientOptions); + + servicePath: string; + port: number; + scopes: string[]; + + getProjectId(): Promise; + getProjectId(callback?: (error: Error, id: string) => string): void; + + detectIntent( + request: DetectIntentRequest, + options?: gax.CallOptions + ): Promise; + streamingDetectIntent(options?: gax.CallOptions): Promise; + + sessionPath(projectId: string, sessionId: string): string; + } +} + +export namespace v2beta1 { + class AgentsClient extends v2.AgentsClient {} + class ContextsClient extends v2.ContextsClient { + environmentSessionPath( + project: string, + environment: string, + user: string, + session: string + ): string; + + environmentContextPath( + project: string, + environment: string, + user: string, + session: string, + context: string + ): string; + + matchProjectFromEnvironmentSessionName( + environmentSessionName: string + ): string; + matchEnvironmentFromEnvironmentSessionName( + environmentSessionName: string + ): string; + matchUserFromEnvironmentSessionName( + environmentSessionName: string + ): string; + matchSessionFromEnvironmentSessionName( + environmentSessionName: string + ): string; + + matchProjectFromEnvironmentContextName( + environmentContextName: string + ): string; + matchEnvironmentFromEnvironmentContextName( + environmentContextName: string + ): string; + matchUserFromEnvironmentContextName( + environmentContextName: string + ): string; + matchSessionFromEnvironmentContextName( + environmentContextName: string + ): string; + matchContextFromEnvironmentContextName( + environmentContextName: string + ): string; + } + class EntityTypesClient extends v2.EntityTypesClient {} + class IntentsClient extends v2.IntentsClient {} + class SessionEntityTypesClient extends v2.SessionEntityTypesClient {} + class SessionsClient extends v2.SessionsClient { + environmentSessionPath( + project: string, + environment: string, + user: string, + session: string + ): string; + + matchProjectFromEnvironmentSessionName( + environmentSessionName: string + ): string; + matchEnvironmentFromEnvironmentSessionName( + environmentSessionName: string + ): string; + matchUserFromEnvironmentSessionName( + environmentSessionName: string + ): string; + matchSessionFromEnvironmentSessionName( + environmentSessionName: string + ): string; + } +} + +export class AgentsClient extends v2.AgentsClient {} +export class ContextsClient extends v2.ContextsClient {} +export class EntityTypesClient extends v2.EntityTypesClient {} +export class IntentsClient extends v2.IntentsClient {} +export class SessionEntityTypesClient extends v2.SessionEntityTypesClient {} +export class SessionsClient extends v2.SessionsClient {} + +export namespace entities { + namespace DateTimeVariants { + interface DateTime { + date_time: string; + } + + interface DateTimePeriod { + startDateTime: DateTime; + endDateTime: DateTime; + } + + interface DatePeriod { + startDate: Date; + endDate: Date; + } + interface TimePeriod { + startTime: string; + endTime: string; + } + } + + type DateTime = + | string + | DateTimeVariants.DatePeriod + | DateTimeVariants.TimePeriod + | DateTimeVariants.DateTime + | DateTimeVariants.DateTimePeriod; + + interface Duration { + unit: string; + amount: number; + } + + type Date = string; + + type Time = string; +} + +export namespace gax { + interface BackoffSettings { + initialRetryDelayMillis: number; + retryDelayMultiplier: number; + maxRetryDelayMillis: number; + initialRpcTimeoutMillis: number; + maxRpcTimeoutMillis: number; + totalTimeoutMillis: number; + } + + interface RetryOptions { + retryCodes: string[]; + backoffSettings: BackoffSettings; + } + + interface CallOptions { + timeout?: number; + retry?: RetryOptions; + autoPaginate?: boolean; + pageToken?: any; + isBundling?: boolean; + longrunning?: BackoffSettings; + promise?: PromiseConstructor; + } + + interface Operation { + grpcOp: longrunning.Operation; + longrunningDescriptor: any; + backoffSettings: BackoffSettings; + callOptions?: CallOptions; + } +} + +export namespace longrunning { + type Operation = + | UnfinishedOperation + | FailedOperation + | SuccessfulOperation; + + interface BaseOperation { + name: string; + metadata: any; + done: boolean; + } + + interface UnfinishedOperation extends BaseOperation { + done: false; + } + + interface FailedOperation extends BaseOperation { + done: true; + error: Status; + } + + interface SuccessfulOperation extends BaseOperation { + done: true; + response: any; + } + + interface Status { + code: number; + message: string; + details: any[]; + } +} + +export interface GetAgentRequest { + parent: string; +} + +export interface SearchAgentRequest { + parent: string; + pageSize?: number; +} + +export interface TrainAgentRequest { + parent: string; +} + +export interface ExportAgentRequest { + parent: string; + agentUri?: string; +} + +export interface ImportAgentRequest { + parent: string; + agentUri?: string; + agentContent?: string; +} + +export interface RestoreAgentRequest { + parent: string; + agentUri?: string; + agentContent?: string; +} + +export interface ListContextsRequest { + parent: string; + pageSize?: number; +} + +export interface GetContextRequest { + name: string; +} + +export interface CreateContextReqeust { + parent: string; + context: Context; +} + +export interface UpdateContextRequest { + context: Context; + updatemask?: any; +} + +export interface DeleteContextRequest { + name: string; +} + +export interface DeleteAllContextsRequest { + parent: string; +} + +export interface ListEntityTypesRequest { + parent: string; + languageCode?: string; + pageSize?: number; +} + +export interface GetEntityTypeRequest { + name: string; + languageCode?: string; +} + +export interface CreateEntityTypeRequest { + parent: string; + entityType: EntityType; +} + +export interface UpdateEntityTypeRequest { + entityType: EntityType; + languageCode?: string; + /** @link https://github.com/google/protobuf/blob/master/src/google/protobuf/field_mask.proto */ + updateMask?: any; +} + +export interface DeleteEntityTypeRequest { + name: string; +} + +export interface ListIntentsRequest { + parent: string; + languageCode?: string; + intentView?: IntentView; + pageSize?: number; +} + +export interface GetIntentRequest { + name: string; + languageCode?: string; + intentView?: IntentView; +} + +export interface CreateIntentRequest { + parent: string; + intent: Intent; + languageCode?: string; + intentView?: IntentView; +} + +export interface UpdateIntentRequest { + intent: Intent; + languageCode?: string; + updateMask?: any; + intentView?: IntentView; +} + +export interface DeleteIntentRequest { + name: string; +} + +export interface DetectIntentRequest { + session: string; + queryInput: QueryInput; + queryParams?: QueryParams; + inputAudio?: any; +} + +export interface DetectIntentResponse { + responseId: string; + queryResult: QueryResult; + webhookStatus: Status; +} + +export interface QueryResult { + queryText: string; + laugnageCode: string; + speechRecognitionConfidence: number; + action: string; + parameters: any; + allRequiredParamsSent: boolean; + fulfillmentText: string; + fulfillmentMessages: Message[]; + webhookSource: string; + webhookPayload: any; + outputContexts: Context[]; + intent: Intent; + intentDetectionConfidence: number; + diagnosticInfo: any; +} + +export interface Status { + code: StatusCode; + message: string; + details: any[]; +} + +export enum StatusCode { + // Not an error; returned on success + // + // HTTP Mapping: 200 OK + OK = 0, + + // The operation was cancelled, typically by the caller. + // + // HTTP Mapping: 499 Client Closed Request + CANCELLED = 1, + + // Unknown error. For example, this error may be returned when + // a `Status` value received from another address space belongs to + // an error space that is not known in this address space. Also + // errors raised by APIs that do not return enough error information + // may be converted to this error. + // + // HTTP Mapping: 500 Internal Server Error + UNKNOWN = 2, + + // The client specified an invalid argument. Note that this differs + // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments + // that are problematic regardless of the state of the system + // (e.g., a malformed file name). + // + // HTTP Mapping: 400 Bad Request + INVALID_ARGUMENT = 3, + + // The deadline expired before the operation could complete. For operations + // that change the state of the system, this error may be returned + // even if the operation has completed successfully. For example, a + // successful response from a server could have been delayed long + // enough for the deadline to expire. + // + // HTTP Mapping: 504 Gateway Timeout + DEADLINE_EXCEEDED = 4, + + // Some requested entity (e.g., file or directory) was not found. + // + // Note to server developers: if a request is denied for an entire class + // of users, such as gradual feature rollout or undocumented whitelist, + // `NOT_FOUND` may be used. If a request is denied for some users within + // a class of users, such as user-based access control, `PERMISSION_DENIED` + // must be used. + // + // HTTP Mapping: 404 Not Found + NOT_FOUND = 5, + + // The entity that a client attempted to create (e.g., file or directory) + // already exists. + // + // HTTP Mapping: 409 Conflict + ALREADY_EXISTS = 6, + + // The caller does not have permission to execute the specified + // operation. `PERMISSION_DENIED` must not be used for rejections + // caused by exhausting some resource (use `RESOURCE_EXHAUSTED` + // instead for those errors). `PERMISSION_DENIED` must not be + // used if the caller can not be identified (use `UNAUTHENTICATED` + // instead for those errors). This error code does not imply the + // request is valid or the requested entity exists or satisfies + // other pre-conditions. + // + // HTTP Mapping: 403 Forbidden + PERMISSION_DENIED = 7, + + // The request does not have valid authentication credentials for the + // operation. + // + // HTTP Mapping: 401 Unauthorized + UNAUTHENTICATED = 16, + + // Some resource has been exhausted, perhaps a per-user quota, or + // perhaps the entire file system is out of space. + // + // HTTP Mapping: 429 Too Many Requests + RESOURCE_EXHAUSTED = 8, + + // The operation was rejected because the system is not in a state + // required for the operation's execution. For example, the directory + // to be deleted is non-empty, an rmdir operation is applied to + // a non-directory, etc. + // + // Service implementors can use the following guidelines to decide + // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: + // (a) Use `UNAVAILABLE` if the client can retry just the failing call. + // (b) Use `ABORTED` if the client should retry at a higher level + // (e.g., when a client-specified test-and-set fails, indicating the + // client should restart a read-modify-write sequence). + // (c) Use `FAILED_PRECONDITION` if the client should not retry until + // the system state has been explicitly fixed. E.g., if an "rmdir" + // fails because the directory is non-empty, `FAILED_PRECONDITION` + // should be returned since the client should not retry unless + // the files are deleted from the directory. + // + // HTTP Mapping: 400 Bad Request + FAILED_PRECONDITION = 9, + + // The operation was aborted, typically due to a concurrency issue such as + // a sequencer check failure or transaction abort. + // + // See the guidelines above for deciding between `FAILED_PRECONDITION`, + // `ABORTED`, and `UNAVAILABLE`. + // + // HTTP Mapping: 409 Conflict + ABORTED = 10, + + // The operation was attempted past the valid range. E.g., seeking or + // reading past end-of-file. + // + // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may + // be fixed if the system state changes. For example, a 32-bit file + // system will generate `INVALID_ARGUMENT` if asked to read at an + // offset that is not in the range [0,2^32-1], but it will generate + // `OUT_OF_RANGE` if asked to read from an offset past the current + // file size. + // + // There is a fair bit of overlap between `FAILED_PRECONDITION` and + // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific + // error) when it applies so that callers who are iterating through + // a space can easily look for an `OUT_OF_RANGE` error to detect when + // they are done. + // + // HTTP Mapping: 400 Bad Request + OUT_OF_RANGE = 11, + + // The operation is not implemented or is not supported/enabled in this + // service. + // + // HTTP Mapping: 501 Not Implemented + UNIMPLEMENTED = 12, + + // Internal errors. This means that some invariants expected by the + // underlying system have been broken. This error code is reserved + // for serious errors. + // + // HTTP Mapping: 500 Internal Server Error + INTERNAL = 13, + + // The service is currently unavailable. This is most likely a + // transient condition, which can be corrected by retrying with + // a backoff. + // + // See the guidelines above for deciding between `FAILED_PRECONDITION`, + // `ABORTED`, and `UNAVAILABLE`. + // + // HTTP Mapping: 503 Service Unavailable + UNAVAILABLE = 14, + + // Unrecoverable data loss or corruption. + // + // HTTP Mapping: 500 Internal Server Error + DATA_LOSS = 15 +} + +export interface Agent { + parent: string; + displayName: string; + defaultLanguageCode: string; + supportedLanguageCodes?: string[]; + timeZone: string; + description?: string; + avatarUri?: string; + enableLogging?: boolean; + matchMode?: MatchMode; + classificationThreshold?: number; +} + +export interface Context { + name: string; + lifespanCount?: number; + parameters?: any; +} + +export interface EntityType { + name: string; + entities: EntitySynonyms[]; + displayName: string; + kind: EntityKind; + autoExpansionMode: EntityAutoExpansionMode; +} + +export enum MatchMode { + MATCH_MODE_UNSPECIFIED = "MATCH_MODE_UNSPECIFIED", + MATCH_MODE_HYBRID = "MATCH_MODE_HYBRID", + MATCH_MODE_ML_ONLY = "MATCH_MODE_ML_ONLY" +} + +export interface Credentials { + clientEmail?: string; + privateKey?: string; +} + +export interface ClientOptions { + credentials?: Credentials; + email?: string; + keyFilename?: string; + port?: number; + projectId?: string; + promise?: PromiseConstructor; + servicePath?: string; +} + +export interface EntitySynonyms { + synonyms: string[]; + value: string; +} + +export enum EntityKind { + KIND_MAP = "KIND_MAP", + KIND_LIST = "KIND_LIST" +} + +export enum EntityAutoExpansionMode { + AUTO_EXPANSION_MODE_DEFAULT = "AUTO_EXPANSION_MODE_DEFAULT", + AUTO_EXPANSION_MODE_UNSPECIFIED = "AUTO_EXPANSION_MODE_UNSPECIFIED" +} + +export enum IntentView { + INTENT_VIEW_UNSPECIFIED = "INTENT_VIEW_UNSPECIFIED", + INTENT_VIEW_FULL = "INTENT_VIEW_FULL" +} + +export interface Intent { + name: string; + displayName: string; + webhookState: string; + priority?: number; + isFallback?: boolean; + mlEnabled?: boolean; + inputContextNames?: string[]; + events?: string[]; + trainingPhrases?: TrainingPhrase[]; + action?: string; + outputContexts?: Context[]; + resetContexts?: boolean; + parameters?: Parameter[]; + messages?: Message[]; + defaultResponsePlatforms?: string[]; + rootFollowupIntentName: string; + parentFollowupIntentName: string; + followupIntentInfo?: FollowupIntentInfo[]; +} + +export interface TrainingPhrase { + name: string; + type: string; + parts: Part[]; + timesAddedCount?: number; +} + +export interface Part { + text: string; + entityType?: string; + alias?: string; + userDefined?: boolean; +} + +export interface Parameter { + name: string; + displayName: string; + value?: string; + defaultValue?: string; + entityTypeDisplayName?: string; + mandatory?: boolean; + prompts?: string[]; + isList?: boolean; +} + +export interface FollowupIntentInfo { + followupIntentName: string; + parentFollowupIntentName: string; +} + +export interface Message { + platform?: string; + text?: Text; + card?: Card; + payload?: any; +} + +export interface Text { + text: string[]; +} + +export interface Card { + title?: string; + subtitle?: string; + imageUri?: string; + buttons?: Button[]; +} + +export interface Button { + text?: string; + postback?: string; +} + +export interface EventInput { + name: string; + languageCode: string; + parameters?: any; +} + +export interface TextInput { + text: string; + languageCode: string; +} + +export interface QueryInput { + text?: TextInput; + event?: EventInput; +} + +export interface QueryParams { + timeZone?: string; + geoLocation?: LatLong; + contexts?: Context[]; + resetContexts?: boolean; + sessionEntityTypes?: SessionEntityType[]; + payload?: any; +} + +export interface LatLong { + latitude: number; + longitude: number; +} + +export interface SessionEntityType { + name: string; + entityOverrideMode: string; + entities: Entity[]; +} + +export interface Entity { + value: string; + synonyms: string[]; +} + +export interface WebhookRequest { + session: string; + responseId: string; + + queryResult: QueryResult; + originalDetectIntentRequest?: any; +} + +export interface WebhookResponse { + fulfillmentText?: string; + fulfillmentMessages?: Message[]; + source?: string; + payload?: any; + outputContexts?: Context[]; + followupEventInput?: EventInput; +} diff --git a/types/dialogflow/tsconfig.json b/types/dialogflow/tsconfig.json new file mode 100644 index 0000000000..366cf28866 --- /dev/null +++ b/types/dialogflow/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dialogflow-tests.ts" + ] +} diff --git a/types/dialogflow/tslint.json b/types/dialogflow/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/dialogflow/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/dom-clipboard-api/dom-clipboard-api-tests.ts b/types/dom-clipboard-api/dom-clipboard-api-tests.ts new file mode 100644 index 0000000000..9b0731d8f4 --- /dev/null +++ b/types/dom-clipboard-api/dom-clipboard-api-tests.ts @@ -0,0 +1,16 @@ +const clipboard = navigator.clipboard; + +let text: string; + +clipboard.writeText('foo'); +clipboard.readText().then((val) => { + text = val; +}); + +const transfer = new DataTransfer(); +transfer.setData('text/plain', 'foo'); + +clipboard.write(transfer); +clipboard.read().then((tf) => { + text = tf.getData('text/plain'); +}); diff --git a/types/dom-clipboard-api/index.d.ts b/types/dom-clipboard-api/index.d.ts new file mode 100644 index 0000000000..1af5f2c60a --- /dev/null +++ b/types/dom-clipboard-api/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for w3c Clipboard API 1.0 +// Project: https://w3c.github.io/clipboard-apis/ +// Definitions by: James Garbutt +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Clipboard extends EventTarget { + read(): Promise; + readText(): Promise; + write(data: DataTransfer): Promise; + writeText(data: string): Promise; +} + +interface Navigator { + readonly clipboard: Clipboard; +} diff --git a/types/dom-clipboard-api/tsconfig.json b/types/dom-clipboard-api/tsconfig.json new file mode 100644 index 0000000000..230c5f16f6 --- /dev/null +++ b/types/dom-clipboard-api/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dom-clipboard-api-tests.ts" + ] +} diff --git a/types/dom-clipboard-api/tslint.json b/types/dom-clipboard-api/tslint.json new file mode 100644 index 0000000000..495d29983d --- /dev/null +++ b/types/dom-clipboard-api/tslint.json @@ -0,0 +1,5 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + } +} diff --git a/types/esri-leaflet/index.d.ts b/types/esri-leaflet/index.d.ts index 3dbd351cb5..df1a9c3752 100644 --- a/types/esri-leaflet/index.d.ts +++ b/types/esri-leaflet/index.d.ts @@ -44,6 +44,7 @@ declare module 'leaflet' { | 'GrayLabels' | 'DarkGrayLabels' | 'ImageryLabels' + | 'ImageryClarity' | 'ImageryTransportation' | 'ShadedReliefLabels' | 'TerrainLabels'; diff --git a/types/ffi-napi/ffi-napi-tests.ts b/types/ffi-napi/ffi-napi-tests.ts new file mode 100644 index 0000000000..5965e23e12 --- /dev/null +++ b/types/ffi-napi/ffi-napi-tests.ts @@ -0,0 +1,106 @@ +import ffi = require('ffi-napi'); +import ref = require('ref-napi'); +import Struct = require('ref-struct-di'); +import Union = require('ref-union-di'); +import TArray = require('ref-array-di'); + +{ + const sqlite3 = ref.types.void; + const sqlite3Ptr = ref.refType(sqlite3); + const sqlite3PtrPtr = ref.refType(sqlite3Ptr); + const stringPtr = ref.refType(ref.types.CString); + + const libsqlite3 = ffi.Library('libsqlite3', { + sqlite3_open: [ 'int', [ 'string', sqlite3PtrPtr ] ], + sqlite3_close: [ 'int', [ sqlite3PtrPtr ] ], + sqlite3_exec: [ 'int', [ sqlite3PtrPtr, 'string', 'pointer', 'pointer', stringPtr ] ], + sqlite3_changes: [ 'int', [ sqlite3PtrPtr ]] + }); + + const dbPtrPtr = ref.alloc(sqlite3PtrPtr); + libsqlite3.sqlite3_open("test.sqlite3", dbPtrPtr); +} +{ + const func = ffi.ForeignFunction(new Buffer(10), 'int', [ 'int' ]); + func(-5); + func.async(-5, (err: any, res: any) => {}); +} +{ + const funcPtr = ffi.Callback('int', [ 'int' ], Math.abs); + const func = ffi.ForeignFunction(funcPtr, 'int', [ 'int' ]); +} +{ + const printfPointer = ffi.DynamicLibrary().get('printf'); + const printfGen = ffi.VariadicForeignFunction(printfPointer, 'void', [ 'string' ]); + printfGen()('Hello World!\n'); + printfGen('int')('This is an int: %d\n', 10); + printfGen('string')('This is a string: %s\n', 'hello'); +} +{ + ref.address(new Buffer(1)); + const intBuf = ref.alloc(ref.types.int); + const intWith4 = ref.alloc(ref.types.int, 4); + const buf0 = ref.allocCString('hello world'); + const type = ref.coerceType('int **'); + const val = ref.deref(intBuf); +} +{ + ref.isNull(new Buffer(1)); +} +{ + const str = ref.readCString(new Buffer('hello\0world\0'), 0); + const buf = ref.alloc('int64'); + ref.writeInt64BE(buf, 0, '9223372036854775807'); + const val = ref.readInt64BE(buf, 0); +} +{ + const voidPtrType = ref.refType(ref.types.void); + const buf = ref.alloc('int64'); + ref.writeInt64LE(buf, 0, '9223372036854775807'); +} +{ + const S1 = Struct({ a: ref.types.int }); + const S2 = new Struct({ a: 'int' }); +} +{ + const P = new Struct(); + P.defineProperty('a', ref.types.int); + P.defineProperty('d', 'long'); +} +{ + const SimpleStruct = Struct({ + first : ref.types.byte, + last : ref.types.byte + }); + + const ss = new SimpleStruct({ first: 50, last: 100 }); + ss.first += 200; +} +{ + const ST = Struct(); + const test: ref.Type = ST.fields['t'].type; +} +{ + const CharArray = TArray('char'); + const b = new Buffer('hello', 'ascii'); + const a = new CharArray(b); +} +{ + const Int32Array = TArray(ref.types.int32); + const input = [1, 4, 91, 123123, 5123512, 0, -1]; + const a = new Int32Array(input); +} +{ + const int = ref.types.int; + const IntArray = TArray(int); + + const buf = new Buffer(int.size * 3); + int.set(buf, int.size * 0, 5); + int.set(buf, int.size * 1, 8); + int.set(buf, int.size * 2, 0); + + const array = IntArray.untilZeros(buf); +} +{ + const refCharArr = TArray('char')([1, 3, 5], 2).ref(); +} diff --git a/types/ffi-napi/index.d.ts b/types/ffi-napi/index.d.ts new file mode 100644 index 0000000000..6cfd439e13 --- /dev/null +++ b/types/ffi-napi/index.d.ts @@ -0,0 +1,186 @@ +// Type definitions for node-ffi-napi 2.4 +// Project: https://github.com/node-ffi/node-ffi +// Definitions by: Keerthi Niranjan , Kiran Niranjan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + + +import ref = require('ref-napi'); +import StructType = require('ref-struct-di'); + +/** Provides a friendly API on-top of `DynamicLibrary` and `ForeignFunction`. */ +export interface Library { + /** The extension to use on libraries. */ + EXT: string; + + /** + * @param libFile name of library + * @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}] + * @param lib hash that will be extended + */ + new (libFile: string, funcs?: {[key: string]: any[]}, lib?: object): any; + + /** + * @param libFile name of library + * @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}] + * @param lib hash that will be extended + */ + (libFile: string, funcs?: {[key: string]: any[]}, lib?: object): any; +} +export const Library: Library; + +/** Get value of errno. */ +export function errno(): number; + +export interface Function extends ref.Type { + /** The type of return value. */ + retType: ref.Type; + /** The type of arguments. */ + argTypes: ref.Type[]; + /** Is set for node-ffi functions. */ + ffi_type: Buffer; + abi: number; + + /** Get a `Callback` pointer of this function type. */ + toPointer(fn: (...args: any[]) => any): Buffer; + /** Get a `ForeignFunction` of this function type. */ + toFunction(buf: Buffer): ForeignFunction; +} + +/** Creates and returns a type for a C function pointer. */ +export const Function: { + new (retType: ref.Type | string, argTypes: any[], abi?: number): Function; + (retType: ref.Type | string, argTypes: any[], abi?: number): Function; +}; + +export interface ForeignFunction { + (...args: any[]): any; + async(...args: any[]): void; +} + +/** + * Represents a foreign function in another library. Manages all of the aspects + * of function execution, including marshalling the data parameters for the + * function into native types and also unmarshalling the return from function + * execution. + */ +export const ForeignFunction: { + new (ptr: Buffer, retType: ref.Type | string, argTypes: any[], abi?: number): ForeignFunction; + (ptr: Buffer, retType: ref.Type | string, argTypes: any[], abi?: number): ForeignFunction; +}; + +export interface VariadicForeignFunction { + /** + * What gets returned is another function that needs to be invoked with the rest + * of the variadic types that are being invoked from the function. + */ + (...args: any[]): ForeignFunction; + + /** + * Return type as a property of the function generator to + * allow for monkey patching the return value in the very rare case where the + * return type is variadic as well + */ + returnType: any; +} + +/** + * For when you want to call to a C function with variable amount of arguments. + * i.e. `printf`. + * + * This function takes care of caching and reusing `ForeignFunction` instances that + * contain the same ffi_type argument signature. + */ +export const VariadicForeignFunction: { + new (ptr: Buffer, ret: ref.Type | string, fixedArgs: any[], abi?: number): VariadicForeignFunction; + (ptr: Buffer, ret: ref.Type | string, fixedArgs: any[], abi?: number): VariadicForeignFunction; +}; + +export interface DynamicLibrary { + /** Close library, returns the result of the `dlclose` system function. */ + close(): number; + /** Get a symbol from this library. */ + get(symbol: string): Buffer; + /** Get the result of the `dlerror` system function. */ + error(): string; +} + +/** + * This class loads and fetches function pointers for dynamic libraries + * (.so, .dylib, etc). After the libray's function pointer is acquired, then you + * call `get(symbol)` to retreive a pointer to an exported symbol. You need to + * call `get___` on the pointer to dereference it into its actual value, or + * turn the pointer into a callable function with `ForeignFunction`. + */ +export const DynamicLibrary: { + FLAGS: { + RTLD_LAZY: number; + RTLD_NOW: number; + RTLD_LOCAL: number; + RTLD_GLOBAL: number; + RTLD_NOLOAD: number; + RTLD_NODELETE: number; + RTLD_NEXT: Buffer; + RTLD_DEFAUL: Buffer; + } + + new (path?: string, mode?: number): DynamicLibrary; + (path?: string, mode?: number): DynamicLibrary; +}; + +/** + * Turns a JavaScript function into a C function pointer. + * The function pointer may be used in other C functions that + * accept C callback functions. + */ +export interface Callback { + new (retType: any, argTypes: any[], abi: number, fn: any): Buffer; + new (retType: any, argTypes: any[], fn: any): Buffer; + (retType: any, argTypes: any[], abi: number, fn: any): Buffer; + (retType: any, argTypes: any[], fn: any): Buffer; +} +export const Callback: Callback; + +export const ffiType: { + /** Get a `ffi_type *` Buffer appropriate for the given type. */ + (type: ref.Type | string): Buffer + FFI_TYPE: StructType; +}; + +export function CIF(retType: any, types: any[], abi?: any): Buffer; +export function CIF_var(retType: any, types: any[], numFixedArgs: number, abi?: any): Buffer; +export const HAS_OBJC: boolean; +export const FFI_TYPES: {[key: string]: Buffer}; +export const FFI_OK: number; +export const FFI_BAD_TYPEDEF: number; +export const FFI_BAD_ABI: number; +export const FFI_DEFAULT_ABI: number; +export const FFI_FIRST_ABI: number; +export const FFI_LAST_ABI: number; +export const FFI_SYSV: number; +export const FFI_UNIX64: number; +export const RTLD_LAZY: number; +export const RTLD_NOW: number; +export const RTLD_LOCAL: number; +export const RTLD_GLOBAL: number; +export const RTLD_NOLOAD: number; +export const RTLD_NODELETE: number; +export const RTLD_NEXT: Buffer; +export const RTLD_DEFAULT: Buffer; +export const LIB_EXT: string; +export const FFI_TYPE: StructType; + +/** Default types. */ +export const types: { + void: ref.Type; int64: ref.Type; ushort: ref.Type; + int: ref.Type; uint64: ref.Type; float: ref.Type; + uint: ref.Type; long: ref.Type; double: ref.Type; + int8: ref.Type; ulong: ref.Type; Object: ref.Type; + uint8: ref.Type; longlong: ref.Type; CString: ref.Type; + int16: ref.Type; ulonglong: ref.Type; bool: ref.Type; + uint16: ref.Type; char: ref.Type; byte: ref.Type; + int32: ref.Type; uchar: ref.Type; size_t: ref.Type; + uint32: ref.Type; short: ref.Type; +}; diff --git a/types/ffi-napi/node-ffi-napi-buffer.d.ts b/types/ffi-napi/node-ffi-napi-buffer.d.ts new file mode 100644 index 0000000000..fa817e1662 --- /dev/null +++ b/types/ffi-napi/node-ffi-napi-buffer.d.ts @@ -0,0 +1,50 @@ +// DefinitelyTyped: partial + +interface Buffer { + /** Shorthand for `ref.address`. */ + address(): number; + /** Shorthand for `ref.deref`. */ + deref(): any; + /** Shorthand for `ref.isNull`. */ + isNull(): boolean; + /** Shorthand for `ref.readCString`. */ + readCString(offset?: number): string; + /** Shorthand for `ref.readInt64BE`. */ + readInt64BE(offset?: number): string; + /** Shorthand for `ref.readInt64LE`. */ + readInt64LE(offset?: number): string; + /** Shorthand for `ref.readObject`. */ + readObject(offset?: number): string; + /** Shorthand for `ref.readPointer`. */ + readPointer(offset?: number): string; + /** Shorthand for `ref.readUInt64BE`. */ + readUInt64BE(offset?: number): string; + /** Shorthand for `ref.readUInt64LE`. */ + readUInt64LE(offset?: number): string; + /** Shorthand for `ref.ref`. */ + ref(): Buffer; + /** Shorthand for `ref.reinterpret`. */ + reinterpret(size: number, offset?: number): Buffer; + /** Shorthand for `ref.reinterpretUntilZeros`. */ + reinterpretUntilZeros(size: number, offset?: number): Buffer; + /** Shorthand for `ref.writeCString`. */ + writeCString(offset: number, input: string, encoding?: string): void; + /** Shorthand for `ref.writeInt64BE`. */ + writeInt64BE(offset: number, input: number | string): any; + /** Shorthand for `ref.writeInt64LE`. */ + writeInt64LE(offset: number, input: number | string): any; + /** Shorthand for `ref.writeObject`. */ + writeObject(offset: number, object: object): void; + /** Shorthand for `ref.writePointer`. */ + writePointer(offset: number, pointer: Buffer): void; + /** Shorthand for `ref.writeUInt64BE`. */ + writeUInt64BE(offset: number, input: number | string): any; + /** Shorthand for `ref.writeUInt64LE`. */ + writeUInt64LE(offset: number, input: number | string): any; + + /** + * Generate string for inspecting. + * String includes the hex-encoded memory address of the Buffer instance. + */ + inspect(): string; +} diff --git a/types/ffi-napi/tsconfig.json b/types/ffi-napi/tsconfig.json new file mode 100644 index 0000000000..c914c55679 --- /dev/null +++ b/types/ffi-napi/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-ffi-napi-buffer.d.ts", + "ffi-napi-tests.ts" + ] +} diff --git a/types/ffi-napi/tslint.json b/types/ffi-napi/tslint.json new file mode 100644 index 0000000000..c5fa24ca82 --- /dev/null +++ b/types/ffi-napi/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "dtslint/dt.json", + + "rules": { + "no-consecutive-blank-lines": [true, 3], + "ban-types": [false] + } +} diff --git a/types/get-port/get-port-tests.ts b/types/get-port/get-port-tests.ts index b6e59890d6..53a9e8e69b 100644 --- a/types/get-port/get-port-tests.ts +++ b/types/get-port/get-port-tests.ts @@ -7,3 +7,7 @@ getPort().then(port => { getPort({ port: 3000 }).then(port => { console.log(port); }); + +getPort({ port: [3000, 3001] }).then(port => { + console.log(port); +}); diff --git a/types/get-port/index.d.ts b/types/get-port/index.d.ts index 3f62b90c86..f8adb4851e 100644 --- a/types/get-port/index.d.ts +++ b/types/get-port/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for get-port 3.2 +// Type definitions for get-port 4.0 // Project: https://github.com/sindresorhus/get-port // Definitions by: York Yao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "get-port" { - var getPort: (options?: { port?: number, host?: string }) => PromiseLike + var getPort: (options?: { port?: number | ReadonlyArray, host?: string }) => PromiseLike export = getPort; } diff --git a/types/gulp-jsonmin/gulp-jsonmin-tests.ts b/types/gulp-jsonmin/gulp-jsonmin-tests.ts new file mode 100644 index 0000000000..5c0cf66cc3 --- /dev/null +++ b/types/gulp-jsonmin/gulp-jsonmin-tests.ts @@ -0,0 +1,5 @@ +import * as GulpJsonmin from 'gulp-jsonmin'; + +GulpJsonmin(); +GulpJsonmin({}); +GulpJsonmin({ verbose: true }); diff --git a/types/gulp-jsonmin/index.d.ts b/types/gulp-jsonmin/index.d.ts new file mode 100644 index 0000000000..16a4347dd2 --- /dev/null +++ b/types/gulp-jsonmin/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for gulp-jsonmin 1.1 +// Project: https://github.com/englercj/gulp-jsonmin +// Definitions by: Romain Faust +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Transform } from 'stream'; + +declare function jsonmin(options?: jsonmin.Options): Transform; + +declare namespace jsonmin { + interface Options { + verbose?: boolean; + } +} + +export = jsonmin; diff --git a/types/gulp-jsonmin/tsconfig.json b/types/gulp-jsonmin/tsconfig.json new file mode 100644 index 0000000000..7f1244285f --- /dev/null +++ b/types/gulp-jsonmin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gulp-jsonmin-tests.ts" + ] +} diff --git a/types/gulp-jsonmin/tslint.json b/types/gulp-jsonmin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/gulp-jsonmin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index f24004fadb..a71e07c925 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -474,6 +474,26 @@ declare namespace Highcharts { skipNullPoints?: boolean; } + interface AnimationOptions { + /** + * The animation duration in milliseconds. + */ + duration: number; + /** + * The name of an easing function as defined on the Math object. + */ + easing?: string; + /** + * A callback function to exectute when the animation finishes. + */ + complete?: () => void; + /** + * A callback function to execute on each step of each attribute or CSS property that's being animated. + * The first argument contains information about the animation and progress. + */ + step?: () => void; + } + interface AxisTitle { /** * Alignment of the title relative to the axis values. Possible values are 'low', 'middle' or 'high'. @@ -5692,6 +5712,46 @@ declare namespace Highcharts { y?: number | null; } + interface TimeOptions { + /** + * A custom Date class for advanced date handling. For example, JDate can be hooked in to handle Jalali dates. + * @default undefined + * @since 4.0.4 + */ + Date?: Date; + /** + * A callback to return the time zone offset for a given datetime. It takes the timestamp in terms of milliseconds since + * January 1 1970, and returns the timezone offset in minutes. This provides a hook for drawing time based charts in + * specific time zones using their local DST crossover dates, with the help of external libraries. + * @default undefined + * @since 4.1.0 + */ + getTimezoneOffset?: (timestamp: Date) => number; + /** + * Requires moment.js. If the timezone option is specified, it creates a default getTimezoneOffset function that looks + * up the specified timezone in moment.js. If moment.js is not included, this throws a Highcharts error in the console, + * but does not crash the chart. + * @default undefined + * @since 5.0.7 + */ + timezone?: string; + /** + * The timezone offset in minutes. Positive values are west, negative values are east of UTC, as in the ECMAScript + * getTimezoneOffset method. Use this to display UTC based data in a predefined time zone. + * @default 0 + * @since 3.0.8 + */ + timezoneOffset?: number; + /** + * Whether to use UTC time for axis scaling, tickmark placement and time display in Highcharts.dateFormat. + * Advantages of using UTC is that the time displays equally regardless of the user agent's time zone settings. + * Local time can be used when the data is loaded in real time or when correct Daylight Saving Time transitions are required. + * @default undefined + * @since 6.0.5 + */ + useUTC?: boolean; + } + interface TitleOptions { /** * The horizontal alignment of the title. Can be one of 'left', 'center' and 'right'. @@ -6118,6 +6178,10 @@ declare namespace Highcharts { * The chart's subtitle */ subtitle?: SubtitleOptions; + /** + * The chart's time options + */ + time?: TimeOptions; /** * The chart's main title. */ @@ -6487,9 +6551,10 @@ declare namespace Highcharts { * @param [boolean] redraw Whether to redraw the chart. Defaults to true. * @param [boolean] oneToOne When true, the series, xAxis and yAxis collections will be updated one to one, and * items will be either added or removed to match the new updated options. Defaults to false. + * @param [(boolean | AnimationOptions)] animation Whether to apply animation, and optionally animation configuration. * @since 5.0.0 */ - update(options: Options, redraw?: boolean, oneToOne?: boolean): void; + update(options: Options, redraw?: boolean, oneToOne?: boolean, animation?: boolean | AnimationOptions): void; /** * This method is deprecated as of 2.0.1. Updating the chart position after a move operation is no longer necessary. * @since 1.2.5 diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index 1d6e921461..bafb4a7516 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -2457,6 +2457,10 @@ function test_ChartObject() { chart.update( {}); chart.update( {}, true); chart.update( {}, true, true); + chart.update( {}, true, true, true); + chart.update( {}, true, true, { + duration: 3000, + }); } function test_ElementObject() { diff --git a/types/iltorb/iltorb-tests.ts b/types/iltorb/iltorb-tests.ts index 66bda251d4..202b9ebbd0 100644 --- a/types/iltorb/iltorb-tests.ts +++ b/types/iltorb/iltorb-tests.ts @@ -20,6 +20,14 @@ br.compress(Buffer.from('foo', 'utf8'), onCompress); br.compress(Buffer.from('foo', 'utf8'), opts, onCompress); +br + .compress(Buffer.from('foobar')) + .then(compressedData => { + br.decompress(compressedData).then(data => { + console.log(data.equals(Buffer.from('foobar'))); + }); + }); + const stream = br.compressStream(); stream.flush(); diff --git a/types/iltorb/index.d.ts b/types/iltorb/index.d.ts index 5ac707a51b..a1cf04844c 100644 --- a/types/iltorb/index.d.ts +++ b/types/iltorb/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for iltorb 2.0 +// Type definitions for iltorb 2.3 // Project: https://github.com/MayhemYDG/iltorb // Definitions by: Arturas Molcanovas +// Francis Gulotta // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -25,8 +26,10 @@ export type IltorbCallback = (err: Error | null | undefined, output: Buffer) => export function compress(buffer: Buffer, options: BrotliEncodeParams, callback: IltorbCallback): void; export function compress(buffer: Buffer, callback: IltorbCallback): void; +export function compress(buffer: Buffer, options?: BrotliEncodeParams): Promise; export function decompress(buffer: Buffer, callback: IltorbCallback): void; +export function decompress(buffer: Buffer): Promise; export function compressSync(buffer: Buffer, options?: BrotliEncodeParams): Buffer; export function decompressSync(buffer: Buffer): Buffer; diff --git a/types/intrinsic-scale/index.d.ts b/types/intrinsic-scale/index.d.ts new file mode 100644 index 0000000000..56100aeb25 --- /dev/null +++ b/types/intrinsic-scale/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for intrinsic-scale 3.0 +// Project: https://github.com/bfred-it/intrinsic-scale#readme +// Definitions by: shalomdotnet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function contain(parentWidth: number, parentHeight: number, childWidth: number, childHeight: number): IntrinsicScale; +export function cover(parentWidth: number, parentHeight: number, childWidth: number, childHeight: number): IntrinsicScale; + +export interface IntrinsicScale { + width: number; + height: number; + x: number; + y: number; +} diff --git a/types/intrinsic-scale/intrinsic-scale-tests.ts b/types/intrinsic-scale/intrinsic-scale-tests.ts new file mode 100644 index 0000000000..23c450572b --- /dev/null +++ b/types/intrinsic-scale/intrinsic-scale-tests.ts @@ -0,0 +1,4 @@ +import { cover, contain } from "intrinsic-scale"; + +const intrinsicScale = cover(100, 100, 50, 50); +const { x, y, width, height } = contain(1, 2, 3, 4); diff --git a/types/intrinsic-scale/tsconfig.json b/types/intrinsic-scale/tsconfig.json new file mode 100644 index 0000000000..8fcff6913d --- /dev/null +++ b/types/intrinsic-scale/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "intrinsic-scale-tests.ts" + ] +} \ No newline at end of file diff --git a/types/intrinsic-scale/tslint.json b/types/intrinsic-scale/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/intrinsic-scale/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jws/index.d.ts b/types/jws/index.d.ts index f384fadefc..fdbf1851c4 100644 --- a/types/jws/index.d.ts +++ b/types/jws/index.d.ts @@ -149,4 +149,5 @@ export type Algorithm = 'HS256' | 'HS384' | 'HS512' | 'RS256' | export interface Header { alg: Algorithm; + [name: string]: string; } diff --git a/types/jws/jws-tests.ts b/types/jws/jws-tests.ts index d5271b24ca..c6e62378f8 100644 --- a/types/jws/jws-tests.ts +++ b/types/jws/jws-tests.ts @@ -20,6 +20,13 @@ const signature = jws.sign({ secret: 'has a van', }); +// jws.sign with extra header values +const signatureWithHeaderParams = jws.sign({ + header: { alg: 'HS256', foo: 'bar' }, + payload: 'h. jon benjamin', + secret: 'has a van', +}); + // jws.decode const message = jws.decode('djfakdid'); diff --git a/types/kendo-ui/index.d.ts b/types/kendo-ui/index.d.ts index d9df1942c3..c1d114aaee 100644 --- a/types/kendo-ui/index.d.ts +++ b/types/kendo-ui/index.d.ts @@ -20300,16 +20300,19 @@ interface JQueryPromise { interface JQuery { + data(key: any): any; + kendoDraggable(): JQuery; kendoDraggable(options: kendo.ui.DraggableOptions): JQuery; + data(key: "kendoDraggable"): kendo.ui.Draggable; kendoDropTarget(): JQuery; kendoDropTarget(options: kendo.ui.DropTargetOptions): JQuery; + data(key: "kendoDropTarget"): kendo.ui.DropTarget; kendoDropTargetArea(): JQuery; kendoDropTargetArea(options: kendo.ui.DropTargetAreaOptions): JQuery; - - data(key: any): any; + data(key: "kendoDropTargetArea"): kendo.ui.DropTargetArea; kendoAlert(): JQuery; kendoAlert(options: kendo.ui.AlertOptions): JQuery; diff --git a/types/koa-redis-cache/index.d.ts b/types/koa-redis-cache/index.d.ts new file mode 100644 index 0000000000..58f7f120ca --- /dev/null +++ b/types/koa-redis-cache/index.d.ts @@ -0,0 +1,94 @@ +// Type definitions for koa-redis-cache 3.0 +// Project: https://github.com/coderhaoxin/koa-redis-cache +// Definitions by: Dima Mukhin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as Koa from "koa"; +import * as Redis from "redis"; + +type onErrorCallback = (error: Error) => void; + +type getPrefixCallback = (ctx: Koa.Context) => string; + +declare namespace cache { + interface CacheOptions { + /** + * redis key prefix, default is koa-redis-cache: + * If a function is supplied, its signature should be function(ctx) {} and it should return a string to use as the redis key prefix + */ + prefix?: string | getPrefixCallback; + + /** + * redis expire time (second), default is 30 * 60 (30 min) + */ + expire?: number; + + /** + * if the passParam exists in the query string, skip the cache + */ + passParam?: string; + + /** + * max length of body size (in bytes) to cache. + * if the size of the body exceeds maxLength, the body will not be cached. + * default is: Infinity + */ + maxLength?: number; + + /** + * the routes to cache, default is ['(.*)']. + * can be set to an array of routes (string), or an array of RouteOptions + */ + routes?: RouteOptions[] | string[]; + + /** + * the routes to exclude, default is []. + * example: ['/api/(.*)', '/view/:id'] + */ + exclude?: string[]; + + /** + * callback function for error, default is function() {} + */ + onerror?: onErrorCallback; + + /** + * redis options + */ + redis?: RedisOptions; + } + + interface RouteOptions { + /** + * the route to cache, example: '/api/(.*)' + */ + route: string; + + /** + * expiration time in seconds for cached responses for the route + */ + expire?: number; + } + + interface RedisOptions { + /** + * host name of the redis server, default: 'localhost' + */ + host?: string; + + /** + * port number of the redis server, default: 6379 + */ + port?: number; + + /** + * node_redis options + */ + options?: Redis.ClientOpts; + } +} + +declare function cache(opts?: cache.CacheOptions): Koa.Middleware; + +export = cache; diff --git a/types/koa-redis-cache/koa-redis-cache-tests.ts b/types/koa-redis-cache/koa-redis-cache-tests.ts new file mode 100644 index 0000000000..b83d0b3aea --- /dev/null +++ b/types/koa-redis-cache/koa-redis-cache-tests.ts @@ -0,0 +1,34 @@ +import * as Koa from "koa"; +import * as cache from 'koa-redis-cache'; + +const app = new Koa(); + +const routeOptions: cache.RouteOptions[] = [ + { + route: '/api/test', + expire: 60 + }, + { + route: '/api/users' + } +]; + +const redisOptions: cache.RedisOptions = { + port: 6379, + host: 'localhost' +}; + +const options: cache.CacheOptions = { + prefix: (ctx: Koa.Context) => 'koa-redis-cache:', + expire: 30 * 30, + passParam: 'skip', + maxLength: 1024, + routes: routeOptions, + exclude: ['/api/(.*)', '/view/:id'], + onerror: (error: Error) => console.log(error), + redis: redisOptions +}; + +app.use(cache(options)); + +app.listen(80); diff --git a/types/koa-redis-cache/tsconfig.json b/types/koa-redis-cache/tsconfig.json new file mode 100644 index 0000000000..897679810e --- /dev/null +++ b/types/koa-redis-cache/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-redis-cache-tests.ts" + ] +} \ No newline at end of file diff --git a/types/koa-redis-cache/tslint.json b/types/koa-redis-cache/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/koa-redis-cache/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index d85af4fd5a..78ce94cb56 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -6,6 +6,9 @@ /// +export = mapboxgl; +export as namespace mapboxgl; + declare namespace mapboxgl { let accessToken: string; let version: string; @@ -1286,11 +1289,3 @@ declare namespace mapboxgl { 'hillshade-accent-color-transition'?: Transition; } } - -declare module 'mapbox-gl' { - export = mapboxgl; -} - -declare module 'mapbox-gl/dist/mapbox-gl' { - export = mapboxgl; -} diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 5eea1625b5..90bb04747f 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mongoose 5.2.1 +// Type definitions for Mongoose 5.2.2 // Project: http://mongoosejs.com/ // Definitions by: horiuchi // sindrenm @@ -10,6 +10,7 @@ // jussikinnula // ondratra // alfirin +// Idan Dardikman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -769,8 +770,8 @@ declare module "mongoose" { * @param key option name * @param value if not passed, the current option value is returned */ - set(key: string): any; - set(key: string, value: any): this; + set(key: T): SchemaOptions[T]; + set(key: T, value: SchemaOptions[T]): this; /** * Adds static "class" methods to Models compiled from this schema. diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 2fe1e1b12e..02227c681d 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -429,7 +429,7 @@ schema.queue('m1', [1, 2, 3]).queue('m2', [[]]); schema.remove('path'); schema.remove(['path1', 'path2', 'path3']); schema.requiredPaths(true)[0].toLowerCase(); -schema.set('key', 999).set('key'); +schema.set('id', true).set('id'); schema.static('static', cb).static({ s1: cb, s2: cb diff --git a/types/mosca/index.d.ts b/types/mosca/index.d.ts index 178f150d05..aee3625d10 100644 --- a/types/mosca/index.d.ts +++ b/types/mosca/index.d.ts @@ -1,9 +1,11 @@ // Type definitions for mosca 2.8 // Project: https://github.com/mcollina/mosca // Definitions by: Joao Gabriel Gouveia +// Jerray Fu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export class Server { + id: string; opts: any; modernOpts: any; clients: any; @@ -83,3 +85,15 @@ export interface Message { qos: number; retain: boolean; } + +export namespace persistence { + interface Persistence { + wire(server: Server): void; + } + type FactoryFunc = (options: { [key: string]: any }) => Persistence; + + const Redis: FactoryFunc; + const Mongo: FactoryFunc; + const LevelUp: FactoryFunc; + const Memory: FactoryFunc; +} diff --git a/types/nanoevents/index.d.ts b/types/nanoevents/index.d.ts new file mode 100644 index 0000000000..0da2f0add3 --- /dev/null +++ b/types/nanoevents/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for nanoevents 1.0 +// Project: https://github.com/ai/nanoevents#readme +// Definitions by: nju33 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +declare function unbind(): void; + +declare class NanoEvents { + on(name: U, callBack: (arg: T[U]) => any): typeof unbind; + emit(name: U, value: T[U]): void; +} + +export = NanoEvents; diff --git a/types/nanoevents/nanoevents-tests.ts b/types/nanoevents/nanoevents-tests.ts new file mode 100644 index 0000000000..7e6eaa8cd8 --- /dev/null +++ b/types/nanoevents/nanoevents-tests.ts @@ -0,0 +1,8 @@ +import NanoEvents = require('nanoevents'); +import unbindAll = require('nanoevents/unbind-all'); + +const emitter = new NanoEvents<{foo: {foo: string}, bar: {bar: string}}>(); +const unbind = emitter.on('foo', action => action.foo); +emitter.emit('bar', {bar: 'test'}); +unbind(); +unbindAll(emitter); diff --git a/types/nanoevents/tsconfig.json b/types/nanoevents/tsconfig.json new file mode 100644 index 0000000000..d3291ed1d9 --- /dev/null +++ b/types/nanoevents/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "nanoevents-tests.ts", + "unbind-all.d.ts" + ] +} diff --git a/types/nanoevents/tslint.json b/types/nanoevents/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/nanoevents/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/nanoevents/unbind-all.d.ts b/types/nanoevents/unbind-all.d.ts new file mode 100644 index 0000000000..1f5662e493 --- /dev/null +++ b/types/nanoevents/unbind-all.d.ts @@ -0,0 +1,5 @@ +import NanoEmitter = require('.'); + +declare function unbindAll(emitter: NanoEmitter): void; + +export = unbindAll; diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index d307bd27d5..13869f0d60 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for nunjucks 3.0 +// Type definitions for nunjucks 3.1 // Project: http://mozilla.github.io/nunjucks/ // Definitions by: Ruben Slabbert // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -95,6 +95,7 @@ export function installJinjaCompat(): void; export interface ILoader { async?: boolean; getSource(name: string): LoaderSource; + getSource(name: string, callback: (err?: any, result?: LoaderSource) => void): void; extend?(extender: ILoader): ILoader; } @@ -128,7 +129,7 @@ export class FileSystemLoader extends Loader implements ILoader { constructor(searchPaths?: string | string[], opts?: FileSystemLoaderOptions); } -export class WebLoader implements ILoader { +export class WebLoader extends Loader implements ILoader { constructor(baseUrl: string, opts?: any); getSource(name: string): LoaderSource; } @@ -137,3 +138,13 @@ export class PrecompiledLoader extends Loader implements ILoader { init(searchPaths: string[], opts: any): void; getSource(name: string): LoaderSource; } + +export namespace runtime { + class SafeString { + constructor(val: string); + val: string; + length: number; + valueOf(): string; + toString(): string; + } +} diff --git a/types/nunjucks/nunjucks-tests.ts b/types/nunjucks/nunjucks-tests.ts index 9f3afcddfe..6dd4d8fed7 100644 --- a/types/nunjucks/nunjucks-tests.ts +++ b/types/nunjucks/nunjucks-tests.ts @@ -52,3 +52,5 @@ class MyLoader extends nunjucks.Loader implements nunjucks.ILoader { } env = new nunjucks.Environment(new MyLoader()); + +new nunjucks.runtime.SafeString("an unsafe string"); diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index 2c7c1bed53..65fb79195f 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "interface-name": false + "interface-name": false, + "no-unnecessary-class": false // to allow SafeString class } } diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index fa6513df90..bde7558531 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -13728,7 +13728,7 @@ declare namespace Office { * asyncContext: Any state data that is passed to the asynchronous method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of type AsyncResult. The token is provided as a string in the asyncResult.value property. */ - getCallbackTokenAsync(options: Office.AsyncContextOptions, callback: (result: AsyncResult) => void): void; + getCallbackTokenAsync(options: Office.AsyncContextOptions & { isRest?: boolean }, callback: (result: AsyncResult) => void): void; /** * Gets a string that contains a token used to get an attachment or item from an Exchange Server. * @@ -60632,4 +60632,4 @@ declare namespace Visio { //////////////////////////////////////////////////////////////// ////////////////////// End PowerPoint APIs ///////////////////// -//////////////////////////////////////////////////////////////// \ No newline at end of file +//////////////////////////////////////////////////////////////// diff --git a/types/page/index.d.ts b/types/page/index.d.ts index 0f9317c6a4..ef56afdc9b 100644 --- a/types/page/index.d.ts +++ b/types/page/index.d.ts @@ -1,7 +1,9 @@ // Type definitions for page v1.5.0 // Project: http://visionmedia.github.io/page.js/ // Definitions by: Alan Norbauer +// James Garbutt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare namespace PageJS { interface Static { @@ -64,7 +66,7 @@ declare namespace PageJS { * * If you wish to load serve initial content from the server you likely will want to set dispatch to false. */ - (options: Options): void; + (options: Partial): void; /** * Register page's popstate / click bindings. If you're doing selective binding you'll like want to pass { click: false } to specify this yourself. The following options are available: * @@ -125,7 +127,7 @@ declare namespace PageJS { * * Identical to page([options]). */ - start(options: Options): void; + start(options: Partial): void; /** * Register page's popstate / click bindings. If you're doing selective binding you'll like want to pass { click: false } to specify this yourself. The following options are available: * @@ -205,19 +207,23 @@ declare namespace PageJS { /** * bind to click events (default = true) */ - click?: boolean; + click: boolean; /** * bind to popstate (default = true) */ - popstate?: boolean; + popstate: boolean; /** * perform initial dispatch (default = true) */ - dispatch?: boolean; + dispatch: boolean; /** * add #!before urls (default = false) */ - hashbang?: boolean; + hashbang: boolean; + /** + * remove URL encoding frfrom path components + */ + decodeURLComponents: boolean; } interface Callback { diff --git a/types/page/page-tests.ts b/types/page/page-tests.ts index 9d78998672..5d5b421d7e 100644 --- a/types/page/page-tests.ts +++ b/types/page/page-tests.ts @@ -13,6 +13,16 @@ page('/contact', contact); page('/contact/:contactName', contact); page('/contact/inline/:contactName', ctx => { }); page(); +page({ + click: false, + popstate: true, + dispatch: false, + hashbang: true, + decodeURLComponents: false +}); +page({ + hashbang: true +}); var index: PageJS.Callback = function() { document.querySelector('p') @@ -82,4 +92,4 @@ var show: PageJS.Callback = function (ctx) { function notfound() { document.querySelector('p') .textContent = 'not found'; -} \ No newline at end of file +} diff --git a/types/phonegap/index.d.ts b/types/phonegap/index.d.ts index 60ad5d2fd9..926140c3f9 100644 --- a/types/phonegap/index.d.ts +++ b/types/phonegap/index.d.ts @@ -526,7 +526,7 @@ declare var Media: { new(src: string, onSuccess: (arg: any) => any, onError: (error: any) => any): Media; } -interface Notification { +interface PhonegapNotification { alert(message: string, alertCallback: Function, title?: string, buttonName?: string): void; confirm(message: string, confirmCallback: Function, title?: string, buttonLabels?: string): void; confirm(message: string, confirmCallback: Function, title?: string, buttonLabels?: string[]): void; @@ -614,7 +614,7 @@ interface /*PhoneGapNavigator extends*/ Navigator { contacts: Contacts; device: Device; globalization: Globalization; - notification: Notification; + notification: PhonegapNotification; splashscreen: Splashscreen; } diff --git a/types/polymer-ts/index.d.ts b/types/polymer-ts/index.d.ts index bf7daf936f..7ab10afa47 100644 --- a/types/polymer-ts/index.d.ts +++ b/types/polymer-ts/index.d.ts @@ -58,7 +58,7 @@ declare namespace polymer { setScrollDirection(direction: string, node: HTMLElement): void; shift(path: string, value: any): any; splice(path: string, start: number, deleteCount: number, ...items: any[]): any; - toggleAttribute(name: string, bool: boolean, node?: HTMLElement): void; + toggleAttribute(name: string, force?: boolean, node?: HTMLElement): boolean; toggleClass(name: string, bool: boolean, node?: HTMLElement): void; transform(transform: string, node?: HTMLElement): void; translate3d(x: any, y: any, z: any, node?: HTMLElement): void; diff --git a/types/puppeteer/v0/puppeteer-tests.ts b/types/puppeteer/v0/puppeteer-tests.ts index 913d46a789..963fb1c8c1 100644 --- a/types/puppeteer/v0/puppeteer-tests.ts +++ b/types/puppeteer/v0/puppeteer-tests.ts @@ -27,8 +27,8 @@ import * as puppeteer from "puppeteer"; // Get the "viewport" of the page, as reported by the page. const dimensions = await page.evaluate(() => { return { - width: document.documentElement.clientWidth, - height: document.documentElement.clientHeight, + width: document.documentElement!.clientWidth, + height: document.documentElement!.clientHeight, deviceScaleFactor: window.devicePixelRatio }; }); diff --git a/types/qiniu-js/index.d.ts b/types/qiniu-js/index.d.ts new file mode 100644 index 0000000000..b47bc0528e --- /dev/null +++ b/types/qiniu-js/index.d.ts @@ -0,0 +1,371 @@ +// Type definitions for qiniu-js 2.4 +// Project: https://github.com/qiniu/js-sdk#readme +// Definitions by: taoqf +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export as namespace qiniu; + +export interface Next { + total: { + loaded: number; // 已上传大小,单位为字节。 + total: number; // 本次上传的总量控制信息,单位为字节,注意这里的 total 跟文件大小并不一致。 + percent: number; // 当前上传进度,范围:0~100。 + }; +} + +export interface Error { + code: number; // 请求错误状态码,只有在 err.isRequestError 为 true 的时候才有效。可查阅码值对应说明。 + message: string; // 错误信息,包含错误码,当后端返回提示信息时也会有相应的错误信息。 + isRequestError: true | undefined; // 用于区分是否 xhr 请求错误;当 xhr 请求出现错误并且后端通过 HTTP 状态码返回了错误信息时,该参数为 true;否则为 undefined 。 + reqId: string; // xhr请求错误的 X-Reqid。 +} + +export interface AudioInfo { + bit_rate: string; + channels: number; + codec_name: string; + codec_type: string; + duration: string; + index: number; + nb_frames: string; + r_frame_rate: string; + sample_fmt: string; + sample_rate: string; + start_time: string; + tags: { + creation_time: string; + [key: string]: string; + }; +} + +export interface AvFormat { + bit_rate: string; + duration: string; + format_long_name: string; + format_name: string; + nb_streams: number; + size: string; + start_time: string; + tags: { + creation_time: string; + [key: string]: string; + }; +} + +export interface VideoInfo { + bit_rate: string; + codec_name: string; + codec_type: string; + display_aspect_ratio: string; + duration: string; + height: number; + index: number; + nb_frames: string; + pix_fmt: string; + r_frame_rate: string; + sample_aspect_ratio: string; + start_time: string; + tags: { + creation_time: string; + [key: string]: string; + }; + width: number; +} + +export interface AvAudioInfo { + audio: AudioInfo; + format: AvFormat; + video: VideoInfo; +} + +export interface AvImageInfo { + format: string; + width: number; + height: number; + colorModel: string; +} + +export interface CompletedResult { + avinfo?: AvAudioInfo; + imageInfo?: AvImageInfo; + key: string; + name: string; + size: number; + persistentid: string; + sec: string; + ext: string; + bucket: string; +} + +export interface Observer { + next(res: Next): void; + error(err: Error | string): void; + complete(res: CompletedResult): void; +} + +export interface Subscription { + unsubscribe(): void; +} + +export interface Observable { + subscribe(options: Observer): Subscription; + /** + * 订阅 + * + * @param next 接收上传进度信息 + * @param error 上传错误后触发;自动重试本身并不会触发该错误,而当重试次数到达上限后则可以触发。当不是 xhr 请求错误时,会把当前错误产生原因直接抛出,诸如 JSON 解析异常等;当产生 xhr 请求错误时,参数 err 为一个包含 code、message、isRequestError 三个属性的 object + * @param complete 接收上传完成后的后端返回信息,具体返回结构取决于后端sdk的配置,可参考[上传策略](https://developer.qiniu.com/kodo/manual/1206/put-policy)。 + * @returns + */ + subscribe(next: (obj: Next) => void, error?: (err: Error | string) => void, complete?: (obj: CompletedResult) => void): Subscription; +} + +export interface Extra { + fname: string; // 文件原文件名 + params: any; // 用来放置自定义变量 + mimeType: string[] | null; // 用来限制上传文件类型,为 null 时表示不对文件类型限制;限制类型放到数组里: ["image/png", "image/jpeg", "image/gif"] +} + +export interface Config { + useCdnDomain: boolean; + region: Region | string; +} + +/** + * 上传文件 + * @param file Blob 对象,上传的文件 + * @param key 文件资源名 + * @param token 上传验证信息,前端通过接口请求后端获得 + * @param putExtra + * @param config + */ +export function upload(file: Blob, key: string | null | undefined, token: string, putExtra: Partial, config: Partial): Observable; + +/** + * 返回创建文件的 url;当分片上传时,我们需要把分片返回的 ctx 信息拼接后通过该 url 上传给七牛以创建文件。 + * + * @param url 上传域名,可以通过qiniu.getUploadUrl()获得 + * @param size 文件大小 + * @param key 文件资源名 + * @param putExtra + * @returns + */ +export function createMkFileUrl(url: string, size: number, key: string, putExtra: Partial): string; + +export enum Region { + z0, // 代表华东区域 + z1, // 代表华北区域 + z2, // 代表华南区域 + na0, // 代表北美区域 + as0 // 代表新加坡区域 +} + +export namespace region { + const z0: Region; + const z1: Region; + const z2: Region; + const na0: Region; + const as0: Region; +} + +/** + * 接收参数为 config 对象,返回根据 config 里所配置信息的上传域名 + * + * @param config + * @param token + * @returns + */ +export function getUploadUrl(config: Partial, token: string): Promise; + +export interface Headers { + [key: string]: string; +} + +/** + * 返回 object,包含用来获得分片上传设置的头信息,参数为 token 字符串;当分片上传时,请求需要带该函数返回的头信息 + * + * @param token + * @returns + */ +export function getHeadersForChunkUpload(token: string): Headers; + +/** + * 返回 object,包含用来获得文件创建的头信息,参数为 token 字符串;当分片上传完需要把 ctx 信息传给七牛用来创建文件时,请求需要带该函数返回的头信息 + * + * @param token + * @returns + */ +export function getHeadersForMkFile(token: string): Headers; + +/** + * 返回[[k, v],...]格式的数组,k 为自定义变量 key 名,v 为自定义变量值,用来提取 putExtra.params 包含的自定义变量 + * + * @param params + * @returns + */ +export function filterParams(params: any): Array<[string, any]>; + +export interface CompressOptions { + quality: number; // 图片压缩质量,在图片格式为 image/jpeg 或 image/webp 的情况下生效,其他格式不会生效,可以从 0 到 1 的区间内选择图片的质量。默认值 0.92 + maxWidh: number; // 压缩图片的最大宽度值 + maxHeight: number; // 压缩图片的最大高度值 (注意:当 maxWidth 和 maxHeight 都不设置时,则采用原图尺寸大小) + noCompressIfLarger: boolean; // 为 true 时如果发现压缩后图片大小比原来还大,则返回源图片(即输出的 dist 直接返回了输入的 file);默认 false,即保证图片尺寸符合要求,但不保证压缩后的图片体积一定变小 +} + +/** + * 上传前图片压缩 + * + * @param file 要压缩的源图片,为 blob 对象,支持 image/png、image/jpeg、image/bmp、image/webp 这几种图片类型 + * @param options + * @returns + */ +export function compressImage(file: Blob, options: Partial): Promise<{ + dist: Blob; // 压缩后输出的 blob 对象,或原始的 file,具体看下面的 options 配置 + width: number; // 压缩后的图片宽度 + height: number; // 压缩后的图片高度 +}>; + +export interface WaterMarkOptions1 { + mode: 1; // 图片水印 + image: string; // 图片水印的Url,mode = 1 时 **必需** + dissolve: number; // 透明度,取值范围1-100,非必需,下同 + gravity: 'NorthWest' | 'North' | 'NorthEast' | 'West' | 'Center' | 'East' | 'SouthWest' | 'South' | 'SouthEast'; // 水印位置 + dx: number; // 横轴边距,单位:像素(px) + dy: number; // 纵轴边距,单位:像素(px) +} + +export interface WaterMarkOptions2 { + mode: 2; // 文字水印 + text: string; // 水印文字,mode = 2 时 **必需** + dissolve: number; // 透明度,取值范围1-100,非必需,下同 + gravity: 'NorthWest' | 'North' | 'NorthEast' | 'West' | 'Center' | 'East' | 'SouthWest' | 'South' | 'SouthEast'; // 水印位置 + fontsize: number; // 字体大小,单位: 缇 + font: string; // 水印文字字体 + dx: number; // 横轴边距,单位:像素(px) + dy: number; // 纵轴边距,单位:像素(px) + fill: string; // 水印文字颜色,RGB格式,可以是颜色名称 +} + +/** + * 水印 + * + * @param options 包含的具体水印参数解释见水印([watermark](https://developer.qiniu.com/dora/manual/1316/image-watermarking-processing-watermark)) + * @param key 文件资源名 + * @param domain 为七牛空间(bucket)对应的域名,选择某个空间后,可通过"空间设置->基本设置->域名设置"查看获取,前端可以通过接口请求后端得到 + * @returns 返回添加水印后的图片地址,可以赋值给 html 的 img 元素的 src 属性, 若未指定key,可以通过以下方式获得完整的 imgLink + * `imgLink = '/?' + imgLink` + * 为七牛空间(bucket)对应的域名,选择某个空间后,可通过"空间设置->基本设置->域名设置"查看获取 + */ +export function watermark(options: WaterMarkOptions1 | WaterMarkOptions2, key?: string, domain?: string): string; + +export interface ImageView2Options { + mode: 0 | 1 | 2 | 3 | 4 | 5; // 缩略模式,共6种[0-5] + w: number; // 具体含义由缩略模式决定 + h: number; // 具体含义由缩略模式决定 + q: number; // 新图的图像质量,取值范围:1-100 + format: 'jpg' | 'gif' | 'png' | 'webp' | string; // 新图的输出格式,取值范围:jpg,gif,png,webp等 +} + +/** + * 缩略 + * + * @param options 具体缩略参数解释见[图片基本处理(imageView2)](https://developer.qiniu.com/dora/manual/1279/basic-processing-images-imageview2) + * @param key + * @param domain + * @returns 返回处理后的图片url + */ +export function imageView2(options: Partial, key: string, domain: string): string; + +export interface ImageMogr2Options { + 'auto-orient': boolean; // 布尔值,是否根据原图EXIF信息自动旋正,便于后续处理,建议放在首位。 + strip: boolean; // 布尔值,是否去除图片中的元信息 + thumbnail: string; // 缩放操作参数 + crop: string; // 裁剪操作参数 + gravity: string; // 裁剪锚点参数 + quality: number; // 图片质量,取值范围1-100 + rotate: number; // 旋转角度,取值范围1-360,缺省为不旋转。 + format: string; // 新图的输出格式,取值范围:jpg,gif,png,webp等 + blur: string; // 高斯模糊参数 +} + +/** + * 返回处理后的图片url + * + * @param optoins 具体高级图像处理参数解释见[图像高级处理(imageMogr2)](https://developer.qiniu.com/dora/manual/1270/the-advanced-treatment-of-images-imagemogr2) + * @param key + * @param domain + * @returns 返回处理后的图片url + */ +export function imageMogr2(optoins: Partial, key: string, domain: string): string; + +export interface ImageInfo { + size: number; // 文件大小,单位:Bytes + format: 'png' | 'jpeg' | 'gif' | 'bmp'; // 图片类型,如png、jpeg、gif、bmp等。 + width: number; // 图片宽度,单位:像素(px) 。 + height: number; // 图片高度,单位:像素(px) 。 + colorModel: string; // 彩色空间,如palette16、ycbcr等。 + frameNumber: number; // 帧数,gif 图片会返回此项。 +} + +/** + * + * 图片基本信息 + * 具体 imageInfo 解释见[图片基本信息(imageInfo)](https://developer.qiniu.com/dora/manual/1269/pictures-basic-information-imageinfo) + * + * @param key + * @param domain + * @returns + */ +export function imageInfo(key: string, domain: string): Promise; + +export interface ExtendedInfo { + code: number; + error: string; + [key: string]: { + type: number; + val: string; + } | number | string; +} + +export interface ExtentInfoValue { + type: number; + val: string; +} + +export interface ExtentInfo { + [key: string]: ExtentInfoValue; + DateTime: ExtentInfoValue; + ExposureBiasValue: ExtentInfoValue; + ExposureTime: ExtentInfoValue; + Model: ExtentInfoValue; + ISOSpeedRatings: ExtentInfoValue; + ResolutionUnit: ExtentInfoValue; +} + +/** + * EXIF 信息 + * 具体 exif 解释见[图片 EXIF 信息(exif)](https://developer.qiniu.com/dora/manual/1260/photo-exif-information-exif) + * @param key + * @param domain + * @returns + */ +export function exif(key: string, domain: string): Promise; + +export interface WaterMarkFopOptions1 extends WaterMarkOptions1 { + fop: 'watermark'; +} + +export interface WaterMarkFopOptions2 extends WaterMarkOptions2 { + fop: 'watermark'; +} + +export interface ImageView2FopOptions extends ImageView2Options { + fop: 'imageView2'; +} + +export interface ImageMogr2FopOptions extends ImageMogr2Options { + fop: 'imageMogr2'; +} + +export function pipeline(fos: Array<(WaterMarkFopOptions1 | WaterMarkFopOptions2 | ImageView2FopOptions | ImageMogr2FopOptions)>, key: string, domain: string): string; diff --git a/types/qiniu-js/qiniu-js-tests.ts b/types/qiniu-js/qiniu-js-tests.ts new file mode 100644 index 0000000000..344f38b195 --- /dev/null +++ b/types/qiniu-js/qiniu-js-tests.ts @@ -0,0 +1,50 @@ +import { compressImage, region, upload } from 'qiniu-js'; + +const file: Blob = null as any; + +const config = { + useCdnDomain: true, + region: region.z2 +}; + +const key = 'key'; +const token = 'token'; + +const putExtra = { + fname: "", + params: {}, + mimeType: [] || null +}; + +(() => { + const observable = upload(file, key, token, putExtra, config); + + const subscription = observable.subscribe({ + next(res) { }, + complete(res) { }, + error(err) { } + }); // 上传开始 + subscription.unsubscribe(); // 上传取消 +})(); + +(() => { + const observable = upload(file, key, token, putExtra, config); + const subscription = observable.subscribe((res) => { }, (err) => { }, (res) => { }); // 这样传参形式也可以 +})(); + +(async () => { + // 图片上传前压缩: + const options = { + quality: 0.92, + noCompressIfLarger: true + // maxWidth: 1000, + // maxHeight: 618 + }; + const data = await compressImage(file, options); + const observable = upload(data.dist, key, token, putExtra, config); + const subscription = observable.subscribe({ + next(res) { }, + complete(res) { }, + error(err) { } + }); // 上传开始 +})(); diff --git a/types/qiniu-js/test/qiniu-js-global-tests.ts b/types/qiniu-js/test/qiniu-js-global-tests.ts new file mode 100644 index 0000000000..e3820d1438 --- /dev/null +++ b/types/qiniu-js/test/qiniu-js-global-tests.ts @@ -0,0 +1,48 @@ +const file: Blob = null as any; + +const config = { + useCdnDomain: true, + region: qiniu.region.z2 +}; + +const key = 'key'; +const token = 'token'; + +const putExtra = { + fname: "", + params: {}, + mimeType: [] || null +}; + +(() => { + const observable = qiniu.upload(file, key, token, putExtra, config); + + const subscription = observable.subscribe({ + next(res) { }, + complete(res) { }, + error(err) { } + }); // 上传开始 + subscription.unsubscribe(); // 上传取消 +})(); + +(() => { + const observable = qiniu.upload(file, key, token, putExtra, config); + const subscription = observable.subscribe((res) => { }, (err) => { }, (res) => { }); // 这样传参形式也可以 +})(); + +(async () => { + // 图片上传前压缩: + const options = { + quality: 0.92, + noCompressIfLarger: true + // maxWidth: 1000, + // maxHeight: 618 + }; + const data = await qiniu.compressImage(file, options); + const observable = qiniu.upload(data.dist, key, token, putExtra, config); + const subscription = observable.subscribe({ + next(res) { }, + complete(res) { }, + error(err) { } + }); // 上传开始 +})(); diff --git a/types/qiniu-js/tsconfig.json b/types/qiniu-js/tsconfig.json new file mode 100644 index 0000000000..15efaa0a4c --- /dev/null +++ b/types/qiniu-js/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "strictFunctionTypes": true, + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "qiniu-js-tests.ts", + "test/qiniu-js-global-tests.ts" + ] +} \ No newline at end of file diff --git a/types/qiniu-js/tslint.json b/types/qiniu-js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/qiniu-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-input-mask/index.d.ts b/types/react-input-mask/index.d.ts index c09719f871..ff618e8749 100644 --- a/types/react-input-mask/index.d.ts +++ b/types/react-input-mask/index.d.ts @@ -1,49 +1,73 @@ -// Type definitions for react-input-mask 1.2 +// Type definitions for react-input-mask 2.0 // Project: https://github.com/sanniassin/react-input-mask // Definitions by: Alexandre Paré +// Dima Danylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.9 -import * as React from "react"; +import * as React from 'react'; -declare namespace ReactInputMask { - interface Props extends React.InputHTMLAttributes { - /** - * Mask string. Format characters are: - * * `9`: `0-9` - * * `a`: `A-Z, a-z` - * * `\*`: `A-Z, a-z, 0-9` - * - * Any character can be escaped with backslash, which usually will appear as double backslash in JS strings. - * For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}` - */ - mask: string; - /** - * Character to cover unfilled editable parts of mask. Default character is "_". If set to null, unfilled parts will be empty, like in ordinary input. - */ - maskChar?: string | null; - /** - * Defines format characters with characters as keys and corresponding RegExp string as values. Default ones: - * ``` - * { - * "9": "[0-9]", - * "a": "[A-Za-z]", - * "*": "[A-Za-z0-9]" - * }``` - */ - formatChars?: { [key: string]: string }; - /** - * Show mask even in empty input without focus. - */ - alwaysShowMask?: boolean; - /** - * Use inputRef instead of ref if you need input node to manage focus, selection, etc. - */ - inputRef?: React.Ref; - } +export interface InputState { + value: string; + selection: Selection; } -declare class ReactInputMask extends React.Component { +export interface MaskOptions { + mask: string; + maskChar: string; + alwaysShowMask: boolean; + formatChars: Record; + permanents: number[]; +} + +interface Props extends React.InputHTMLAttributes { + /** + * Mask string. Format characters are: + * * `9`: `0-9` + * * `a`: `A-Z, a-z` + * * `\*`: `A-Z, a-z, 0-9` + * + * Any character can be escaped with backslash, which usually will appear as double backslash in JS strings. + * For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}` + */ + mask: string; + /** + * Character to cover unfilled editable parts of mask. Default character is "_". If set to null, unfilled parts will be empty, like in ordinary input. + */ + maskChar?: string | null; + /** + * Defines format characters with characters as keys and corresponding RegExp string as values. Default ones: + * ``` + * { + * "9": "[0-9]", + * "a": "[A-Za-z]", + * "*": "[A-Za-z0-9]" + * }``` + */ + formatChars?: { [key: string]: string }; + /** + * Show mask even in empty input without focus. + */ + alwaysShowMask?: boolean; + /** + * Use inputRef instead of ref if you need input node to manage focus, selection, etc. + */ + inputRef?: React.Ref; + + /** + * In case you need to implement more complex masking behavior, you can provide + * beforeMaskedValueChange function to change masked value and cursor position + * before it will be applied to the input. + */ + beforeMaskedValueChange?( + newState: InputState, + oldState: InputState, + userInput: string, + maskOptions: MaskOptions, + ): InputState; +} + +export class ReactInputMask extends React.Component { } export default ReactInputMask; diff --git a/types/react-input-mask/react-input-mask-tests.tsx b/types/react-input-mask/react-input-mask-tests.tsx index a34b15ac99..93c6b1f638 100644 --- a/types/react-input-mask/react-input-mask-tests.tsx +++ b/types/react-input-mask/react-input-mask-tests.tsx @@ -4,10 +4,10 @@ import * as React from 'react'; let ref: HTMLInputElement | null = null;
- - - - - - ref = node} /> + + + + + + ref = node} />
; diff --git a/types/react-input-mask/tslint.json b/types/react-input-mask/tslint.json index 3db14f85ea..f93cf8562a 100644 --- a/types/react-input-mask/tslint.json +++ b/types/react-input-mask/tslint.json @@ -1 +1,3 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json" +} diff --git a/types/react-input-mask/v1/index.d.ts b/types/react-input-mask/v1/index.d.ts new file mode 100644 index 0000000000..c09719f871 --- /dev/null +++ b/types/react-input-mask/v1/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for react-input-mask 1.2 +// Project: https://github.com/sanniassin/react-input-mask +// Definitions by: Alexandre Paré +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from "react"; + +declare namespace ReactInputMask { + interface Props extends React.InputHTMLAttributes { + /** + * Mask string. Format characters are: + * * `9`: `0-9` + * * `a`: `A-Z, a-z` + * * `\*`: `A-Z, a-z, 0-9` + * + * Any character can be escaped with backslash, which usually will appear as double backslash in JS strings. + * For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}` + */ + mask: string; + /** + * Character to cover unfilled editable parts of mask. Default character is "_". If set to null, unfilled parts will be empty, like in ordinary input. + */ + maskChar?: string | null; + /** + * Defines format characters with characters as keys and corresponding RegExp string as values. Default ones: + * ``` + * { + * "9": "[0-9]", + * "a": "[A-Za-z]", + * "*": "[A-Za-z0-9]" + * }``` + */ + formatChars?: { [key: string]: string }; + /** + * Show mask even in empty input without focus. + */ + alwaysShowMask?: boolean; + /** + * Use inputRef instead of ref if you need input node to manage focus, selection, etc. + */ + inputRef?: React.Ref; + } +} + +declare class ReactInputMask extends React.Component { +} + +export default ReactInputMask; diff --git a/types/react-input-mask/v1/react-input-mask-tests.tsx b/types/react-input-mask/v1/react-input-mask-tests.tsx new file mode 100644 index 0000000000..a34b15ac99 --- /dev/null +++ b/types/react-input-mask/v1/react-input-mask-tests.tsx @@ -0,0 +1,13 @@ +import ReactInputMask from 'react-input-mask'; +import * as React from 'react'; + +let ref: HTMLInputElement | null = null; + +
+ + + + + + ref = node} /> +
; diff --git a/types/react-input-mask/v1/tsconfig.json b/types/react-input-mask/v1/tsconfig.json new file mode 100644 index 0000000000..fddba7dc87 --- /dev/null +++ b/types/react-input-mask/v1/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "react-input-mask": ["react-input-mask/v1"] + } + }, + "files": [ + "index.d.ts", + "react-input-mask-tests.tsx" + ] +} \ No newline at end of file diff --git a/types/react-input-mask/v1/tslint.json b/types/react-input-mask/v1/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-input-mask/v1/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-native-calendars/index.d.ts b/types/react-native-calendars/index.d.ts index 3784c1f628..b7a1736d2a 100644 --- a/types/react-native-calendars/index.d.ts +++ b/types/react-native-calendars/index.d.ts @@ -1,170 +1,92 @@ // Type definitions for react-native-calendars 1.20 // Project: https://github.com/wix/react-native-calendars#readme // Definitions by: Tyler Zhang +// David Noreña // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from 'react'; -import { ViewProps, StyleProp } from 'react-native'; +import { StyleProp, TextStyle, ViewStyle } from 'react-native'; +export import LocaleConfig = require('xdate'); export interface DateObject { - year: number; - month: number; day: number; - timestamp: number; dateString: string; + month: number; + timestamp: number; + year: number; } -export interface CalendarTheme { - backgroundColor?: string; - calendarBackground?: string; - textSectionTitleColor?: string; - selectedDayBackgroundColor?: string; - selectedDayTextColor?: string; - todayTextColor?: string; - dayTextColor?: string; - textDisabledColor?: string; - dotColor?: string; - selectedDotColor?: string; - arrowColor?: string; - monthTextColor?: string; - textDayFontFamily?: string; - textMonthFontFamily?: string; - textDayHeaderFontFamily?: string; - textMonthFontWeight?: string; - textDayFontSize?: number; - textMonthFontSize?: number; - textDayHeaderFontSize?: number; -} - -export interface DayComponentProps { - state: '' | 'selected' | 'disabled' | 'today'; - theme: CalendarTheme; - onPress: () => any; - onLongPress: () => any; - date: DateObject; - marking: false | Marking[]; -} - -export interface CalendarBaseProps { - /** - * Styles for the view - */ - style?: StyleProp; - - /** - * Specify theme properties to override specific styles for calendar parts. Default = {} - */ - theme?: CalendarTheme; - - /** - * Initially visible month. Default = Date() - */ - current?: Date | string; - - /** - * Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined - */ - minDate?: Date | string; - - /** - * Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined - */ - maxDate?: Date | string; - - /** - * Handler which gets executed on day press. Default = undefined - */ - onDayPress?: (day: number) => void; - - /** - * Handler which gets executed on day long press. Default = undefined - */ - onDayLongPress?: (day: number) => void; - - /** - * Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting - */ - monthFormat?: string; - - /** - * Handler which gets executed when visible month changes in calendar. Default = undefined - */ - onMonthChange?: (month: number) => void; - - /** - * Hide month navigation arrows. Default = false - */ - hideArrows?: boolean; - - /** - * Replace default arrows with custom ones (direction can be 'left' or 'right') - */ - renderArrow?: (direction: 'left' | 'right') => React.ReactNode; - - /** - * Do not show days of other months in month page. Default = false - */ - hideExtraDays?: boolean; - - /** - * If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out - * day from another month that is visible in calendar page. Default = false - */ - disableMonthChange?: boolean; - - /** - * If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday. - */ - firstDay?: number; - - /** - * Hide day names. Default = false - */ - hideDayNames?: boolean; - - /** - * Show week numbers to the left. Default = false - */ - showWeekNumbers?: boolean; - - /** - * Handler which gets executed when press arrow icon left. It receive a callback can go back month - */ - onPressArrowLeft?: (month: number) => void; - - /** - * Handler which gets executed when press arrow icon left. It receive a callback can go next month - */ - onPressArrowRight?: (month: number) => void; - - /** - * Custom day renderer - */ - dayComponent?: React.Component | React.SFC; -} - -export interface DotForMultiDot { +export interface CalendarDot { key: string; color: string; selectedDotColor?: string; } -export interface MultiDotMarking { - dots: DotForMultiDot[]; - selected?: boolean; - selectedColor?: string; - disabled?: boolean; +export interface CalendarTheme { + arrowColor?: string; + backgroundColor?: string; + calendarBackground?: string; + dayTextColor?: string; + dotColor?: string; + monthTextColor?: string; + selectedDayBackgroundColor?: string; + selectedDayTextColor?: string; + selectedDotColor?: string; + textDayFontFamily?: string; + textDayFontSize?: number; + textDayHeaderFontFamily?: string; + textDayHeaderFontSize?: number; + textDisabledColor?: string; + textMonthFontFamily?: string; + textMonthFontWeight?: string; + textMonthFontSize?: number; + textSectionTitleColor?: string; + todayTextColor?: string; +} + +export type DateCallbackHandler = (date: DateObject) => void; + +export type TCalendarDate = Date | DateObject | number | string | XDate; + +export interface MarkedDateCustomStyles { + container: StyleProp; + text: StyleProp; +} + +export interface CalendarDot { + key: string; + color: string; + selectedDotColor?: string; +} + +export interface CustomMarking { + customStyles: MarkedDateCustomStyles; } export interface DotMarking { - selected?: boolean; - marked?: boolean; - selectedColor?: string; - dotColor?: string; activeOpacity?: number; disabled?: boolean; disableTouchEvent?: boolean; + dotColor?: string; + marked?: boolean; + selected?: boolean; + selectedColor?: string; +} + +export interface MultiDotMarking { + disabled?: boolean; + dots: CalendarDot[]; + selected?: boolean; + selectedColor?: string; +} + +export interface MultiPeriodMarking { + periods: Array<{ + startingDay?: boolean; + endingDay?: boolean; + color?: string; + }>; } export interface PeriodMarking { @@ -176,29 +98,15 @@ export interface PeriodMarking { disabled?: boolean; } -export interface MultiPeriodMarking { - periods: Array<{ - startingDay?: boolean; - endingDay?: boolean; - color?: string; - }>; -} - -export interface CustomMarking { - customStyles: any; -} - export type Marking = - MultiDotMarking | - DotMarking | - PeriodMarking | - MultiPeriodMarking | - CustomMarking; + CustomMarking | DotMarking | + MultiDotMarking | MultiPeriodMarking | + PeriodMarking; -export interface MultiDotMarkingProps { - markingType: 'multi-dot'; +export interface CustomMarkingProps { + markingType: 'custom'; markedDates: { - [date: string]: MultiDotMarking; + [date: string]: CustomMarking; }; } @@ -209,17 +117,10 @@ export interface DotMarkingProps { }; } -export interface PeriodMarkingProps { - markingType: 'period'; +export interface MultiDotMarkingProps { + markingType: 'multi-dot'; markedDates: { - [date: string]: PeriodMarking; - }; -} - -export interface CustomMarkingProps { - markingType: 'custom'; - markedDates: { - [date: string]: CustomMarking; + [date: string]: MultiDotMarking; }; } @@ -234,6 +135,13 @@ export interface MultiPeriodMarkingProps { }; } +export interface PeriodMarkingProps { + markingType: 'period'; + markedDates: { + [date: string]: PeriodMarking; + }; +} + export type CalendarMarkingProps = MultiDotMarkingProps | DotMarkingProps | @@ -242,61 +150,217 @@ export type CalendarMarkingProps = CustomMarkingProps | {}; -export class Calendar extends React.Component {} +export interface DayComponentProps { + date: DateObject; + marking: false | Marking[]; + onPress: () => any; + onLongPress: () => any; + state: '' | 'selected' | 'disabled' | 'today'; + theme: CalendarTheme; +} + +export interface CalendarBaseProps { + /** + * Initially visible month. Default = Date() + */ + current?: TCalendarDate; + + /** + * Provide custom day rendering component. + */ + dayComponent?: React.Component | React.SFC; + + /** + * Disable days by default. Default = false + */ + disabledByDefault?: boolean; + + /** + * If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out + * day from another month that is visible in calendar page. Default = false + */ + disableMonthChange?: boolean; + + /** + * Display loading indicator. Default = false + */ + displayLoadingIndicator?: boolean; + + /** + * If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday. + */ + firstDay?: number; + + /** + * Hide month navigation arrows. Default = false + */ + hideArrows?: boolean; + + /** + * Hide day names. Default = false + */ + hideDayNames?: boolean; + + /** + * Do not show days of other months in month page. Default = false + */ + hideExtraDays?: boolean; + + /** + * Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined + */ + maxDate?: TCalendarDate; + + /** + * Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined + */ + minDate?: TCalendarDate; + + /** + * Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting + */ + monthFormat?: string; + + /** + * Handler which gets executed on day press. Default = undefined + */ + onDayPress?: DateCallbackHandler; + + /** + * Handler which gets executed on day long press. Default = undefined + */ + onDayLongPress?: DateCallbackHandler; + + /** + * Handler which gets executed when press arrow icon left. It receive a callback can go back month + */ + onPressArrowLeft?: (substractMonth: () => void) => void; + + /** + * Handler which gets executed when press arrow icon left. It receive a callback can go next month + */ + onPressArrowRight?: (addMonth: () => void) => void; + + /** + * Handler which gets executed when visible month changes in calendar. Default = undefined + */ + onMonthChange?: DateCallbackHandler; -export interface CalendarListBaseProps extends CalendarBaseProps { /** * Callback which gets executed when visible months change in scroll view. Default = undefined */ - onVisibleMonthsChange?: (months: number) => void; + onVisibleMonthsChange?: (months: DateObject[]) => void; /** - * Max amount of months allowed to scroll to the past. Default = 50 + * Replace default arrows with custom ones (direction can be 'left' or 'right') */ - pastScrollRange?: number; + renderArrow?: (direction: 'left' | 'right') => React.ReactNode; + + /** + * Show week numbers to the left. Default = false + */ + showWeekNumbers?: boolean; + + /** + * Calendar container style. + */ + style?: StyleProp; + + /** + * Specify theme properties to override specific styles for calendar parts. Default = {} + */ + theme?: CalendarTheme; +} + +export class Calendar extends React.Component { } + +export interface CalendarListBaseProps extends CalendarBaseProps { + /** + * Set custom calendar heigth. + */ + calendarHeight?: number; + + /** + * Set custom calendar width. + */ + calendarWidth?: number; /** * Max amount of months allowed to scroll to the future. Default = 50 */ futureScrollRange?: number; + /** + * Enable horizontal scrolling, default = false + */ + horizontal?: boolean; + + /** + * Enable paging on horizontal, default = false + */ + pagingEnabled?: boolean; + + /** + * Max amount of months allowed to scroll to the past. Default = 50 + */ + pastScrollRange?: number; + /** * Enable or disable scrolling of calendar list */ scrollEnabled?: boolean; + /** + * When true, the calendar list scrolls to top when the status bar is tapped. Default = true + */ + scrollsToTop?: boolean; + /** * Enable or disable vertical scroll indicator. Default = false */ showScrollIndicator?: boolean; - - /** - * Enable horizontal scrolling, default = false - */ - horizontal?: boolean; - - /** - * Enable paging on horizontal, default = false - */ - pagingEnabled?: boolean; - - /** - * Set custom calendarWidth. - */ - calendarWidth?: boolean; } -export class CalendarList extends React.Component {} +export class CalendarList extends React.Component { } -export interface AgendaProps { +export interface AgendaThemeStyle extends CalendarTheme { + agendaDayNumColor?: string; + agendaDayTextColor?: string; + agendaKnobColor?: string; + agendaTodayColor?: string; +} + +export interface AgendaItemsMap { + [date: string]: TItem[]; +} + +export interface AgendaProps { /** - * the list of items that have to be displayed in agenda. If you want to render item as empty date - * the value of date key kas to be an empty array []. If there exists no value for date key it is - * considered that the date in question is not yet loaded + * Display loading indicator. Default = false */ - items: { - [key: string]: T[]; - }; + displayLoadingIndicator?: boolean; + + /** + * If firstDay = 1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday. + */ + firstDay?: number; + + /** + * Max amount of months allowed to scroll to the future. Default = 50 + */ + futureScrollRange?: number; + + /** + * Hide knob button. Default = false + */ + hideKnob?: boolean; + + /** + * The list of items that have to be displayed in agenda. If you want to render item as empty date + * the value of date key kas to be an empty array []. If there exists no value for date key it is + * considered that the date in question is not yet loaded + */ + items?: AgendaItemsMap; /** * callback that gets called when items for a certain month should be loaded (month became visible) @@ -304,115 +368,100 @@ export interface AgendaProps { loadItemsForMonth?: (date: DateObject) => void; /** - * callback that fires when the calendar is opened or closed + * Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined */ - onCalendarToggled?: (calendarOpened: boolean) => void; - - /** - * callback that gets called on day press - */ - onDayPress?: (day: number) => void; - - /** - * callback that gets called when day changes while scrolling agenda list - */ - onDayChange?: (day: number) => void; - - /** - * initially selected day - */ - selected?: Date | string; + maxDate?: TCalendarDate; /** * Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined */ - minDate?: Date | string; + minDate?: TCalendarDate; /** - * Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined + * Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting */ - maxDate?: Date | string; + monthFormat?: string; /** - * Max amount of months allowed to scroll to the past. Default = 50 + * Handler which gets executed on day press. Default = undefined + */ + onDayPress?: DateCallbackHandler; + + /** + * Handler which gets executed when the calendar is opened or closed. Default = undefined + */ + onCalendarToggled?: (calendarOpened: boolean) => void; + + /** + * Handler that gets called when day changes while scrolling agenda list. Default = undefined + */ + onDayChange?: DateCallbackHandler; + + /** + * If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. + * Make sure to also set the refreshing prop correctly. Default = undefined + */ + onRefresh?: () => void; + + /** + * Max amount of months allowed to scroll to the past. Default = 50 */ pastScrollRange?: number; /** - * Max amount of months allowed to scroll to the future. Default = 50 - */ - futureScrollRange?: number; - - /** - * specify how each item should be rendered in agenda - */ - renderItem: (item: T, firstItemInDay?: T) => React.ReactNode; - - /** - * specify how each date should be rendered. day can be undefined if the item is not first in that day. - */ - renderDay?: (day: DateObject | undefined, item: T) => React.ReactNode; - - /** - * specify how empty date content with no items should be rendered - */ - renderEmptyDate?: () => React.ReactNode; - - /** - * specify how agenda knob should look like - */ - renderKnob?: () => React.ReactNode; - - /** - * specify what should be rendered instead of ActivityIndicator - */ - renderEmptyData?: () => React.ReactNode; - - /** - * specify your item comparison function for increased performance - */ - rowHasChanged?: (r1: any, r2: any) => boolean; - - /** - * Hide knob button. Default = false - */ - hideKnob?: boolean; - - /** - * A RefreshControl component, used to provide pull-to-refresh funtionality for the ScrollView + * A RefreshControl component, used to provide pull-to-refresh funtionality for the ScrollView. */ refreshControl?: React.ReactNode; /** - * If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. - * Make sure to also set the refreshing prop correctly. - */ - onRefresh?: () => any; - - /** - * Set this true while waiting for new data from a refresh + * Set this true while waiting for new data from a refresh. */ refreshing?: boolean; /** - * Display loading indicator. Default = false + * Specify how each day should be rendered. + * Date can be undefined if the item has not property date. */ - displayLoadingIndicator?: boolean; + renderDay?: (date: DateObject | undefined, item: TItem) => React.ReactNode; /** - * agenda theme + * Specify what should be rendered instead of ActivityIndicator */ - theme?: { - agendaDayTextColor?: string; - agendaDayNumColor?: string; - agendaTodayColor?: string; - agendaKnobColor?: string; - } & CalendarTheme; + renderEmptyData?: () => React.ReactNode; /** - * agenda container style + * Specify how empty date content with no items should be rendered. */ - style?: StyleProp; + renderEmptyDate: () => React.ReactNode; + + /** + * Specify how each item should be rendered in agenda. + */ + renderItem: (item: TItem, firstDayInDay: boolean) => React.ReactNode; + + /** + * Specify how agenda knob should look like. + */ + renderKnob?: () => React.ReactNode; + + /** + * specify your item comparison function for increased performance + */ + rowHasChanged: (r1: TItem, r2: TItem) => boolean; + + /** + * Initially visible month. Default = Date() + */ + selected?: TCalendarDate; + + /** + * Agenda container style. + */ + style?: StyleProp; + + /** + * Specify theme properties to override specific styles for agenda parts. Default = {} + */ + theme?: AgendaThemeStyle; } - -export class Agenda extends React.Component & CalendarMarkingProps> {} +export class Agenda extends React.Component & CalendarMarkingProps> { } diff --git a/types/react-native-calendars/react-native-calendars-tests.tsx b/types/react-native-calendars/react-native-calendars-tests.tsx index 5b438937e1..3a095a597e 100644 --- a/types/react-native-calendars/react-native-calendars-tests.tsx +++ b/types/react-native-calendars/react-native-calendars-tests.tsx @@ -10,23 +10,23 @@ import { Calendar, CalendarList, Agenda } from "react-native-calendars"; // Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined maxDate={"2012-05-30"} // Handler which gets executed on day press. Default = undefined - onDayPress={day => { - console.log("selected day", day); + onDayPress={date => { + console.log("selected day", date.day); }} // Handler which gets executed on day long press. Default = undefined - onDayLongPress={day => { - console.log("selected day", day); + onDayLongPress={date => { + console.log("selected day", date.day); }} // Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting monthFormat={"yyyy MM"} // Handler which gets executed when visible month changes in calendar. Default = undefined - onMonthChange={month => { - console.log("month changed", month); + onMonthChange={date => { + console.log("month changed", date.month); }} // Hide month navigation arrows. Default = false hideArrows={true} // Replace default arrows with custom ones (direction can be 'left' or 'right') - renderArrow={direction =>
} + renderArrow={direction => } // Do not show days of other months in month page. Default = false hideExtraDays={true} // If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out @@ -42,6 +42,7 @@ import { Calendar, CalendarList, Agenda } from "react-native-calendars"; onPressArrowLeft={substractMonth => console.log(substractMonth)} // Handler which gets executed when press arrow icon left. It receive a callback can go next month onPressArrowRight={addMonth => console.log(addMonth)} + disabledByDefault={true} />; { - console.log("selected day", day); + onDayPress={date => { + console.log("selected day", date.day); }} // Handler which gets executed on day long press. Default = undefined - onDayLongPress={day => { - console.log("selected day", day); + onDayLongPress={date => { + console.log("selected day", date.day); }} // Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting monthFormat={"yyyy MM"} // Handler which gets executed when visible month changes in calendar. Default = undefined - onMonthChange={month => { - console.log("month changed", month); + onMonthChange={date => { + console.log("month changed", date.month); }} // Hide month navigation arrows. Default = false hideArrows={true} // Replace default arrows with custom ones (direction can be 'left' or 'right') - renderArrow={direction =>
} + renderArrow={direction => } // Do not show days of other months in month page. Default = false hideExtraDays={true} // If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out @@ -267,7 +268,7 @@ const workout = { key: "workout", color: "green" }; // Hide month navigation arrows. Default = false hideArrows={true} // Replace default arrows with custom ones (direction can be 'left' or 'right') - renderArrow={direction =>
} + renderArrow={direction => } // Do not show days of other months in month page. Default = false hideExtraDays={true} // If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out @@ -283,6 +284,29 @@ const workout = { key: "workout", color: "green" }; onPressArrowLeft={substractMonth => console.log(substractMonth)} // Handler which gets executed when press arrow icon left. It receive a callback can go next month onPressArrowRight={addMonth => console.log(addMonth)} + // Disable days by default. Default = false + disabledByDefault={true} + // Display loading indicator. Default = false + displayLoadingIndicator={true} + // When true, the calendar list scrolls to top when the status bar is tapped. Default = true + scrollsToTop={true} + // Enable paging on horizontal, default = false + pagingEnabled={true} + // Provide custom day rendering component. + dayComponent={({ date, state }) => { + return ( + + + {date.day} + + + ); + }} />; { - return ; + return firstItemInDay ? : ; }} // specify how each date should be rendered. day can be undefined if the item is not first in that day. renderDay={(day, item) => { @@ -371,4 +395,10 @@ const workout = { key: "workout", color: "green" }; }} // agenda container style style={{}} + // Display loading indicator. Default = false + displayLoadingIndicator={true} + // If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday. + firstDay={1} + // Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting + monthFormat={"yyyy MM"} />; diff --git a/types/react-native-calendars/tslint.json b/types/react-native-calendars/tslint.json index 3db14f85ea..82403bc9ec 100644 --- a/types/react-native-calendars/tslint.json +++ b/types/react-native-calendars/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "file-name-casing": [true, "kebab-case"] + } +} diff --git a/types/react-onsenui/index.d.ts b/types/react-onsenui/index.d.ts index 39722faa7c..1b90fb1c50 100644 --- a/types/react-onsenui/index.d.ts +++ b/types/react-onsenui/index.d.ts @@ -281,6 +281,7 @@ export class Ripple extends Component<{ color?: string, background?: string, disabled?: boolean, + modifier?: string, }, any> {} /*** Forms ***/ diff --git a/types/react-paginate/index.d.ts b/types/react-paginate/index.d.ts index 83d8c476c9..83a03ac838 100644 --- a/types/react-paginate/index.d.ts +++ b/types/react-paginate/index.d.ts @@ -1,9 +1,10 @@ -// Type definitions for react-paginate 4.3 +// Type definitions for react-paginate 5.2 // Project: https://github.com/AdeleD/react-paginate // Definitions by: Simon Hartcher // Wouter Hardeman // pegel03 // Simon Archer +// Yasunori Ohoka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -48,7 +49,7 @@ interface ReactPaginateProps { /** * The method to call when a page is clicked. Exposes the current page object as an argument. */ - onPageChange?(selectedItem: {selected: number}): void; + onPageChange?(selectedItem: { selected: number }): void; /** * The initial page selected. @@ -122,4 +123,4 @@ interface ReactPaginateProps { } declare const ReactPaginate: React.ComponentClass; -export = ReactPaginate; +export default ReactPaginate; diff --git a/types/react-paginate/react-paginate-tests.tsx b/types/react-paginate/react-paginate-tests.tsx index 92d8659c0c..a98e8702a4 100644 --- a/types/react-paginate/react-paginate-tests.tsx +++ b/types/react-paginate/react-paginate-tests.tsx @@ -1,5 +1,5 @@ -import * as React from "react"; -import ReactPaginate = require("react-paginate"); +import * as React from 'react'; +import ReactPaginate from 'react-paginate'; class Test extends React.Component { render() { diff --git a/types/react-paginate/tsconfig.json b/types/react-paginate/tsconfig.json index 5653cee275..5c49c56d9e 100644 --- a/types/react-paginate/tsconfig.json +++ b/types/react-paginate/tsconfig.json @@ -1,8 +1,4 @@ { - "files": [ - "index.d.ts", - "react-paginate-tests.tsx" - ], "compilerOptions": { "module": "commonjs", "lib": [ @@ -21,5 +17,9 @@ "noEmit": true, "forceConsistentCasingInFileNames": true, "jsx": "react" - } -} \ No newline at end of file + }, + "files": [ + "index.d.ts", + "react-paginate-tests.tsx" + ] + } diff --git a/types/react-paginate/v4/index.d.ts b/types/react-paginate/v4/index.d.ts new file mode 100644 index 0000000000..736455f60f --- /dev/null +++ b/types/react-paginate/v4/index.d.ts @@ -0,0 +1,125 @@ +// Type definitions for react-paginate 4.3 +// Project: https://github.com/AdeleD/react-paginate +// Definitions by: Simon Hartcher +// Wouter Hardeman +// pegel03 +// Simon Archer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +interface ReactPaginateProps { + /** + * The total number of pages. + */ + pageCount: number; + + /** + * The range of pages displayed. + */ + pageRangeDisplayed: number; + + /** + * The number of pages to display for margins. + */ + marginPagesDisplayed: number; + + /** + * Label for the `previous` button. + */ + previousLabel?: string | JSX.Element; + + /** + * Label for the `next` button. + */ + nextLabel?: string | JSX.Element; + + /** + * Label for ellipsis. + */ + breakLabel?: string | JSX.Element; + + /** + * The classname on tag `li` of the ellipsis element. + */ + breakClassName?: string | JSX.Element; + + /** + * The method to call when a page is clicked. Exposes the current page object as an argument. + */ + onPageChange?(selectedItem: { selected: number }): void; + + /** + * The initial page selected. + */ + initialPage?: number; + + /** + * To override selected page with parent prop. + */ + forcePage?: number; + + /** + * Disable onPageChange callback with initial page. Default: false + */ + disableInitialCallback?: boolean; + + /** + * The classname of the pagination container. + */ + containerClassName?: string; + + /** + * The classname on tag `li` of each page element. + */ + pageClassName?: string; + + /** + * The classname on tag `a` of each page element. + */ + pageLinkClassName?: string; + + /** + * The classname for the active page. + */ + activeClassName?: string; + + /** + * The classname on tag `li` of the `previous` button. + */ + previousClassName?: string; + + /** + * The classname on tag `li` of the `next` button. + */ + nextClassName?: string; + + /** + * The classname on tag `a` of the `previous` button. + */ + previousLinkClassName?: string; + + /** + * The classname on tag `a` of the `next` button. + */ + nextLinkClassName?: string; + + /** + * The classname for disabled `previous` and `next` buttons. + */ + disabledClassName?: string; + + /** + * The method is called to generate the href attribute value on tag a of each page element. + */ + hrefBuilder?(pageIndex: number): void; + + /** + * Extra context to add to the aria-label HTML attribute. + */ + extraAriaContext?: string; +} + +declare const ReactPaginate: React.ComponentClass; +export = ReactPaginate; diff --git a/types/react-paginate/v4/react-paginate-tests.tsx b/types/react-paginate/v4/react-paginate-tests.tsx new file mode 100644 index 0000000000..130db0248c --- /dev/null +++ b/types/react-paginate/v4/react-paginate-tests.tsx @@ -0,0 +1,33 @@ +import * as React from 'react'; +import ReactPaginate = require('react-paginate'); + +class Test extends React.Component { + render() { + return ( + null} + initialPage={2} + forcePage={3} + disableInitialCallback={false} + containerClassName={'container'} + pageClassName={'page-li'} + pageLinkClassName={'page-a'} + activeClassName={'active'} + previousClassName={'previous-li'} + nextClassName={'next-li'} + previousLinkClassName={'previous-a'} + nextLinkClassName={'next-a'} + disabledClassName={'disabled'} + hrefBuilder={(pageIndex: number) => null} + extraAriaContext={'aria'} + /> + ); + } +} diff --git a/types/react-paginate/v4/tsconfig.json b/types/react-paginate/v4/tsconfig.json new file mode 100644 index 0000000000..d6ee7a0357 --- /dev/null +++ b/types/react-paginate/v4/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "react-paginate": [ + "react-paginate/v4" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-paginate-tests.tsx" + ] +} diff --git a/types/react-paginate/v4/tslint.json b/types/react-paginate/v4/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-paginate/v4/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-sortable-tree/index.d.ts b/types/react-sortable-tree/index.d.ts index 0415db0414..257e3aedf9 100644 --- a/types/react-sortable-tree/index.d.ts +++ b/types/react-sortable-tree/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Wouter Hardeman // Jovica Zoric // Kevin Perrine +// Alex Maclean // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -70,6 +71,12 @@ export interface OnDragPreviousAndNextLocation extends PreviousAndNextLocation { nextParent: TreeItem | null; } +export interface ShouldCopyData { + node: TreeNode; + prevPath: NumberArrayOrStringArray; + prevTreeIndex: number; +} + export interface OnMovePreviousAndNextLocation extends PreviousAndNextLocation { nextParentNode: TreeItem | null; } @@ -186,6 +193,7 @@ export interface ReactSortableTreeProps { dndType?: string; placeholderRenderer?: PlaceholderRenderer; theme?: ThemeProps; + shouldCopyOnOutsideDrop?: boolean | ((data: ShouldCopyData) => boolean); } declare const SortableTree: React.ComponentClass; diff --git a/types/react-sortable-tree/react-sortable-tree-tests.tsx b/types/react-sortable-tree/react-sortable-tree-tests.tsx index 6ed4b3e74b..695614caca 100644 --- a/types/react-sortable-tree/react-sortable-tree-tests.tsx +++ b/types/react-sortable-tree/react-sortable-tree-tests.tsx @@ -69,11 +69,13 @@ class Test extends React.Component { dndType="testNodeType" placeholderRenderer={PlaceholderRenderer} theme={theme} + shouldCopyOnOutsideDrop={true} /> {}} style={{width: "100px"}} + shouldCopyOnOutsideDrop={() => false} />
); diff --git a/types/ref-array-di/index.d.ts b/types/ref-array-di/index.d.ts new file mode 100644 index 0000000000..04a69fd1ef --- /dev/null +++ b/types/ref-array-di/index.d.ts @@ -0,0 +1,62 @@ +// Type definitions for ref-array-di 1.2 +// Project: https://github.com/node-ffi-napi/ref-array-di +// Definitions by: Keerthi Niranjan , Kiran Niranjan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import ref = require('ref-napi'); + +interface ArrayType extends ref.Type { + BYTES_PER_ELEMENT: number; + fixedLength: number; + /** The reference to the base type. */ + type: ref.Type; + + /** + * Accepts a Buffer instance that should be an already-populated with data + * for the ArrayType. The "length" of the Array is determined by searching + * through the buffer's contents until an aligned NULL pointer is encountered. + */ + untilZeros(buffer: Buffer): { + [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; + }; + + new (length?: number): { + [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; + }; + new (data: number[], length?: number): { + [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; + }; + new (data: Buffer, length?: number): { + [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; + }; + (length?: number): { + [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; + }; + (data: number[], length?: number): { + [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; + }; + (data: Buffer, length?: number): { + [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; + }; +} + +/** + * The array type meta-constructor. + * The returned constructor's API is highly influenced by the WebGL + * TypedArray API. + */ +declare var ArrayType: { + new (type: ref.Type, length?: number): ArrayType; + new (type: string, length?: number): ArrayType; + (type: ref.Type, length?: number): ArrayType; + (type: string, length?: number): ArrayType; +}; + +export = ArrayType; diff --git a/types/ref-array-di/tsconfig.json b/types/ref-array-di/tsconfig.json new file mode 100644 index 0000000000..02963e3afd --- /dev/null +++ b/types/ref-array-di/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} \ No newline at end of file diff --git a/types/ref-array-di/tslint.json b/types/ref-array-di/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/ref-array-di/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} diff --git a/types/ref-napi/index.d.ts b/types/ref-napi/index.d.ts new file mode 100644 index 0000000000..ab3b38d953 --- /dev/null +++ b/types/ref-napi/index.d.ts @@ -0,0 +1,188 @@ +// Type definitions for ref-napi 1.4 +// Project: https://github.com/node-ffi-napi/ref-napi +// Definitions by: Keerthi Niranjan , Kiran Niranjan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export interface Type { + /** The size in bytes required to hold this datatype. */ + size: number; + /** The current level of indirection of the buffer. */ + indirection: number; + /** To invoke when `ref.get` is invoked on a buffer of this type. */ + get(buffer: Buffer, offset: number): any; + /** To invoke when `ref.set` is invoked on a buffer of this type. */ + set(buffer: Buffer, offset: number, value: any): void; + /** The name to use during debugging for this datatype. */ + name?: string; + /** The alignment of this datatype when placed inside a struct. */ + alignment?: number; +} + +/** A Buffer that references the C NULL pointer. */ +export declare var NULL: Buffer; +/** A pointer-sized buffer pointing to NULL. */ +export declare var NULL_POINTER: Buffer; +/** Get the memory address of buffer. */ +export declare function address(buffer: Buffer): number; +/** Allocate the memory with the given value written to it. */ +export declare function alloc(type: Type, value?: any): Buffer; +/** Allocate the memory with the given value written to it. */ +export declare function alloc(type: string, value?: any): Buffer; + +/** + * Allocate the memory with the given string written to it with the given + * encoding (defaults to utf8). The buffer is 1 byte longer than the + * string itself, and is NULL terminated. + */ +export declare function allocCString(string: string, encoding?: string): Buffer; + +/** Coerce a type.*/ +export declare function coerceType(type: Type): Type; +/** Coerce a type. String are looked up from the ref.types object. */ +export declare function coerceType(type: string): Type; + +/** + * Get value after dereferencing buffer. + * That is, first it checks the indirection count of buffer's type, and + * if it's greater than 1 then it merely returns another Buffer, but with + * one level less indirection. + */ +export declare function deref(buffer: Buffer): any; + +/** Create clone of the type, with decremented indirection level by 1. */ +export declare function derefType(type: Type): Type; +/** Create clone of the type, with decremented indirection level by 1. */ +export declare function derefType(type: string): Type; +/** Represents the native endianness of the processor ("LE" or "BE"). */ +export declare var endianness: string; +/** Check the indirection level and return a dereferenced when necessary. */ +export declare function get(buffer: Buffer, offset?: number, type?: Type): any; +/** Check the indirection level and return a dereferenced when necessary. */ +export declare function get(buffer: Buffer, offset?: number, type?: string): any; +/** Get type of the buffer. Create a default type when none exists. */ +export declare function getType(buffer: Buffer): Type; +/** Check the NULL. */ +export declare function isNull(buffer: Buffer): boolean; +/** Read C string until the first NULL. */ +export declare function readCString(buffer: Buffer, offset?: number): string; + +/** + * Read a big-endian signed 64-bit int. + * If there is losing precision, then return a string, otherwise a number. + * @return {number|string} + */ +export declare function readInt64BE(buffer: Buffer, offset?: number): any; + +/** + * Read a little-endian signed 64-bit int. + * If there is losing precision, then return a string, otherwise a number. + * @return {number|string} + */ +export declare function readInt64LE(buffer: Buffer, offset?: number): any; + +/** Read a JS Object that has previously been written. */ +export declare function readObject(buffer: Buffer, offset?: number): Object; +/** Read data from the pointer. */ +export declare function readPointer(buffer: Buffer, offset?: number, + length?: number): Buffer; +/** + * Read a big-endian unsigned 64-bit int. + * If there is losing precision, then return a string, otherwise a number. + * @return {number|string} + */ +export declare function readUInt64BE(buffer: Buffer, offset?: number): any; + +/** + * Read a little-endian unsigned 64-bit int. + * If there is losing precision, then return a string, otherwise a number. + * @return {number|string} + */ +export declare function readUInt64LE(buffer: Buffer, offset?: number): any; + +/** Create pointer to buffer. */ +export declare function ref(buffer: Buffer): Buffer; +/** Create clone of the type, with incremented indirection level by 1. */ +export declare function refType(type: Type): Type; +/** Create clone of the type, with incremented indirection level by 1. */ +export declare function refType(type: string): Type; + +/** + * Create buffer with the specified size, with the same address as source. + * This function "attaches" source to the returned buffer to prevent it from + * being garbage collected. + */ +export declare function reinterpret(buffer: Buffer, size: number, + offset?: number): Buffer; +/** + * Scan past the boundary of the buffer's length until it finds size number + * of aligned NULL bytes. + */ +export declare function reinterpretUntilZeros(buffer: Buffer, size: number, + offset?: number): Buffer; + +/** Write pointer if the indirection is 1, otherwise write value. */ +export declare function set(buffer: Buffer, offset: number, value: any, type?: Type): void; +/** Write pointer if the indirection is 1, otherwise write value. */ +export declare function set(buffer: Buffer, offset: number, value: any, type?: string): void; +/** Write the string as a NULL terminated. Default encoding is utf8. */ +export declare function writeCString(buffer: Buffer, offset: number, + string: string, encoding?: string): void; +/** Write a big-endian signed 64-bit int. */ +export declare function writeInt64BE(buffer: Buffer, offset: number, input: number): void; +/** Write a big-endian signed 64-bit int. */ +export declare function writeInt64BE(buffer: Buffer, offset: number, input: string): void; +/** Write a little-endian signed 64-bit int. */ +export declare function writeInt64LE(buffer: Buffer, offset: number, input: number): void; +/** Write a little-endian signed 64-bit int. */ +export declare function writeInt64LE(buffer: Buffer, offset: number, input: string): void; + +/** + * Write the JS Object. This function "attaches" object to buffer to prevent + * it from being garbage collected. + */ +export declare function writeObject(buffer: Buffer, offset: number, object: Object): void; + +/** + * Write the memory address of pointer to buffer at the specified offset. This + * function "attaches" object to buffer to prevent it from being garbage collected. + */ +export declare function writePointer(buffer: Buffer, offset: number, + pointer: Buffer): void; + +/** Write a little-endian unsigned 64-bit int. */ +export declare function writeUInt64BE(buffer: Buffer, offset: number, input: number): void; +/** Write a little-endian unsigned 64-bit int. */ +export declare function writeUInt64BE(buffer: Buffer, offset: number, input: string): void; + +/** + * Attach object to buffer such. + * It prevents object from being garbage collected until buffer does. + */ +export declare function _attach(buffer: Buffer, object: Object): void; + +/** Same as ref.reinterpret, except that this version does not attach buffer. */ +export declare function _reinterpret(buffer: Buffer, size: number, + offset?: number): Buffer; +/** Same as ref.reinterpretUntilZeros, except that this version does not attach buffer. */ +export declare function _reinterpretUntilZeros(buffer: Buffer, size: number, + offset?: number): Buffer; +/** Same as ref.writePointer, except that this version does not attach pointer. */ +export declare function _writePointer(buffer: Buffer, offset: number, + pointer: Buffer): void; +/** Same as ref.writeObject, except that this version does not attach object. */ +export declare function _writeObject(buffer: Buffer, offset: number, object: Object): void; + +/** Default types. */ +export declare var types: { + void: Type; int64: Type; ushort: Type; + int: Type; uint64: Type; float: Type; + uint: Type; long: Type; double: Type; + int8: Type; ulong: Type; Object: Type; + uint8: Type; longlong: Type; CString: Type; + int16: Type; ulonglong: Type; bool: Type; + uint16: Type; char: Type; byte: Type; + int32: Type; uchar: Type; size_t: Type; + uint32: Type; short: Type; +}; diff --git a/types/ref-napi/tsconfig.json b/types/ref-napi/tsconfig.json new file mode 100644 index 0000000000..02963e3afd --- /dev/null +++ b/types/ref-napi/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} \ No newline at end of file diff --git a/types/ref-napi/tslint.json b/types/ref-napi/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/ref-napi/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} diff --git a/types/ref-struct-di/index.d.ts b/types/ref-struct-di/index.d.ts new file mode 100644 index 0000000000..dd3d878fc1 --- /dev/null +++ b/types/ref-struct-di/index.d.ts @@ -0,0 +1,60 @@ +// Type definitions for ref-struct-di 1.1 +// Project: https://github.com/node-ffi-napi/ref-struct-di +// Definitions by: Keerthi Niranjan , Kiran Niranjan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import ref = require('ref-napi'); + +/** + * This is the `constructor` of the Struct type that gets returned. + * + * Invoke it with `new` to create a new Buffer instance backing the struct. + * Pass it an existing Buffer instance to use that as the backing buffer. + * Pass in an Object containing the struct fields to auto-populate the + * struct with the data. + * + * @constructor + */ +interface StructType extends ref.Type { + /** Pass it an existing Buffer instance to use that as the backing buffer. */ + new (arg: Buffer, data?: {}): any; + new (data?: {}): any; + /** Pass it an existing Buffer instance to use that as the backing buffer. */ + (arg: Buffer, data?: {}): any; + (data?: {}): any; + + fields: { [key: string]: { type: ref.Type } }; + + /** + * Adds a new field to the struct instance with the given name and type. + * Note that this function will throw an Error if any instances of the struct + * type have already been created, therefore this function must be called at the + * beginning, before any instances are created. + */ + defineProperty(name: string, type: ref.Type): void; + + /** + * Adds a new field to the struct instance with the given name and type. + * Note that this function will throw an Error if any instances of the struct + * type have already been created, therefore this function must be called at the + * beginning, before any instances are created. + */ + defineProperty(name: string, type: string): void; + + /** + * Custom for struct type instances. + * @override + */ + toString(): string; +} + +/** The struct type meta-constructor. */ +declare var StructType: { + new (fields?: object, opt?: object): StructType; + new (fields?: any[]): StructType; + (fields?: object, opt?: object): StructType; + (fields?: any[]): StructType; +} + +export = StructType; diff --git a/types/ref-struct-di/ref-struct-di-tests.ts b/types/ref-struct-di/ref-struct-di-tests.ts new file mode 100644 index 0000000000..60b03e0cd5 --- /dev/null +++ b/types/ref-struct-di/ref-struct-di-tests.ts @@ -0,0 +1,12 @@ +import ref = require("ref-napi"); +import StructType = require("ref-struct-di"); + +const normalStruct = StructType({ + t: ref.types.uint8, + v: ref.types.long, +}); + +const packedStruct = StructType({ + t: ref.types.uint8, + v: ref.types.long, +}, {packed: true}); diff --git a/types/ref-struct-di/tsconfig.json b/types/ref-struct-di/tsconfig.json new file mode 100644 index 0000000000..fef426ba7a --- /dev/null +++ b/types/ref-struct-di/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ref-struct-di-tests.ts" + ] +} diff --git a/types/ref-struct-di/tslint.json b/types/ref-struct-di/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/ref-struct-di/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} diff --git a/types/ref-union-di/index.d.ts b/types/ref-union-di/index.d.ts new file mode 100644 index 0000000000..29c7401df9 --- /dev/null +++ b/types/ref-union-di/index.d.ts @@ -0,0 +1,59 @@ +// Type definitions for ref-union-di 1.0 +// Project: https://github.com/node-ffi-napi/ref-union-di +// Definitions by: Keerthi Niranjan , Kiran Niranjan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import ref = require('ref-napi'); + +/** + * This is the `constructor` of the Struct type that gets returned. + * + * Invoke it with `new` to create a new Buffer instance backing the union. + * Pass it an existing Buffer instance to use that as the backing buffer. + * Pass in an Object containing the union fields to auto-populate the + * union with the data. + * + * @constructor + */ +interface UnionType extends ref.Type { + /** Pass it an existing Buffer instance to use that as the backing buffer. */ + new (arg: Buffer, data?: {}): any; + new (data?: {}): any; + /** Pass it an existing Buffer instance to use that as the backing buffer. */ + (arg: Buffer, data?: {}): any; + (data?: {}): any; + + fields: { [key: string]: { type: ref.Type } }; + + /** + * Adds a new field to the union instance with the given name and type. + * Note that this function will throw an Error if any instances of the union + * type have already been created, therefore this function must be called at the + * beginning, before any instances are created. + */ + defineProperty(name: string, type: ref.Type): void; + + /** + * Adds a new field to the union instance with the given name and type. + * Note that this function will throw an Error if any instances of the union + * type have already been created, therefore this function must be called at the + * beginning, before any instances are created. + */ + defineProperty(name: string, type: string): void; + + /** + * Custom for union type instances. + * @override + */ + toString(): string; +} + +/** The union type meta-constructor. */ +declare var UnionType: { + new (fields?: {}): UnionType; + new (fields?: any[]): UnionType; + (fields?: {}): UnionType; + (fields?: any[]): UnionType; +} + +export = UnionType; diff --git a/types/ref-union-di/tsconfig.json b/types/ref-union-di/tsconfig.json new file mode 100644 index 0000000000..02963e3afd --- /dev/null +++ b/types/ref-union-di/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} \ No newline at end of file diff --git a/types/ref-union-di/tslint.json b/types/ref-union-di/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/ref-union-di/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} diff --git a/types/round-to/index.d.ts b/types/round-to/index.d.ts new file mode 100644 index 0000000000..73622c5012 --- /dev/null +++ b/types/round-to/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for round-to 3.0 +// Project: https://github.com/sindresorhus/round-to#readme +// Definitions by: Sean Marvi Oliver Genabe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace roundTo { + /** + * Round the decimals with `Math.ceil`. + * @param input Number to adjust. + * @param precision (Integer) number of decimal places. + */ + function up(input: number, precision: number): number; + /** + * Round the decimals with `Math.floor`. + * @param input Number to adjust. + * @param precision (Integer) number of decimal places. + */ + function down(input: number, precision: number): number; +} + +/** + * Round the decimals with `Math.round`. + * @param input Number to adjust. + * @param precision (integer) Number of decimal places. + */ +declare function roundTo(input: number, precision: number): number; + +export = roundTo; diff --git a/types/round-to/round-to-tests.ts b/types/round-to/round-to-tests.ts new file mode 100644 index 0000000000..60d4c21538 --- /dev/null +++ b/types/round-to/round-to-tests.ts @@ -0,0 +1,10 @@ +import roundTo = require('round-to'); + +// $ExpectType number +roundTo(1.234, 2); + +// $ExpectType number +roundTo.up(1.234, 2); + +// $ExpectType number +roundTo.down(1.234, 2); diff --git a/types/typed.js/tsconfig.json b/types/round-to/tsconfig.json similarity index 81% rename from types/typed.js/tsconfig.json rename to types/round-to/tsconfig.json index b018ca64fe..633ed48869 100644 --- a/types/typed.js/tsconfig.json +++ b/types/round-to/tsconfig.json @@ -7,7 +7,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" @@ -15,10 +14,10 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, - "esModuleInterop": true + "strictFunctionTypes": true }, "files": [ "index.d.ts", - "typed.js-tests.ts" + "round-to-tests.ts" ] } diff --git a/types/round-to/tslint.json b/types/round-to/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/round-to/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/socket.io/index.d.ts b/types/socket.io/index.d.ts index 2b5100abb2..6c12e444b0 100644 --- a/types/socket.io/index.d.ts +++ b/types/socket.io/index.d.ts @@ -696,6 +696,23 @@ declare namespace SocketIO { query: any; } + /** + * The interface describing a room + */ + interface Room { + sockets: {[id: string]: boolean }; + length: number; + } + + /** + * The interface describing a dictionary of rooms + * Where room is the name of the room + */ + + interface Rooms { + [room: string]: Room; + } + /** * The interface used when dealing with rooms etc */ @@ -708,9 +725,8 @@ declare namespace SocketIO { /** * A dictionary of all the rooms that we have in this namespace - * The rooms are made of a `sockets` key which is the dictionary of sockets per ID */ - rooms: {[room: string]: {sockets: {[id: string]: boolean }, length: number }}; + rooms: Rooms; /** * A dictionary of all the socket ids that we're dealing with, and all diff --git a/types/typed.js/index.d.ts b/types/typed.js/index.d.ts deleted file mode 100644 index 45064e9c03..0000000000 --- a/types/typed.js/index.d.ts +++ /dev/null @@ -1,185 +0,0 @@ -// Type definitions for typed.js 2.0 -// Project: https://github.com/mattboldt/typed.js -// Definitions by: Davide Donadello -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export default Typed; - -export class Typed { - constructor(elementId: string, options: TypedJsOptions); - - /** - * Toggle start() and stop() of the Typed instance - */ - toggle(): void; - - /** - * Stop typing / backspacing and enable cursor blinking - */ - stop(): void; - - /** - * Start typing / backspacing after being stopped - */ - start(): void; - - /** - * Destroy this instance of Typed - */ - destroy(): void; - - /** - * Reset Typed and optionally restarts - */ - reset(restart: boolean): void; -} - -export type TypedJsContentType = "html" | "null"; - -export interface TypedJsOptions { - /** - * Strings to be typed - */ - strings?: string[]; - - /** - * ID of element containing string children - */ - stringsElement?: string; - - /** - * Type speed in milliseconds - */ - typeSpeed?: number; - - /** - * Time before typing starts in milliseconds - */ - startDelay?: number; - - /** - * Backspacing speed in milliseconds - */ - backSpeed?: number; - - /** - * Only backspace what doesn't match the previous string - */ - smartBackspace?: boolean; - - /** - * Shuffle the strings - */ - shuffle?: boolean; - - /** - * Time before backspacing in milliseconds - */ - backDelay?: number; - - /** - * Fade out instead of backspace - */ - fadeOut?: boolean; - - /** - * Css class for fade animation - */ - fadeOutClass?: string; - - /** - * Fade out delay in milliseconds - */ - fadeOutDelay?: number; - - /** - * Loop strings - */ - loop?: boolean; - - /** - * Amount of loops - */ - loopCount?: number; - - /** - * Show cursor - */ - showCursor?: boolean; - - /** - * Character for cursor - */ - cursorChar?: string; - - /** - * Insert CSS for cursor and fadeOut into HTML - */ - autoInsertCss?: boolean; - - /** - * Attribute for typing - * Ex: input placeholder, value, or just HTML text - */ - attr?: string; - - /** - * Bind to focus and blur if el is text input - */ - bindInputFocusEvents?: boolean; - - /** - * 'html' or 'null' for plaintext - */ - contentType?: TypedJsContentType; - - /** - * All typing is complete - */ - onComplete?: (self: Typed) => void; - - /** - * Before each string is typed - */ - preStringTyped?: (arrayPos: number, self: Typed) => void; - - /** - * After each string is typed - */ - onStringTyped?: (arrayPos: number, self: Typed) => void; - - /** - * During looping, after last string is typed - */ - onLastStringBackspaced?: (self: Typed) => void; - - /** - * Typing has been stopped - */ - onTypingPaused?: (arrayPos: number, self: Typed) => void; - - /** - * Typing has been started after being stopped - */ - onTypingResumed?: (arrayPos: number, self: Typed) => void; - - /** - * After reset - */ - onReset?: (self: Typed) => void; - - /** - * After stop - */ - onStop?: (arrayPos: number, self: Typed) => void; - - /** - * After start - */ - onStart?: (arrayPos: number, self: Typed) => void; - - /** - * After destroy - */ - onDestroy?: (self: Typed) => void; -} diff --git a/types/typed.js/tslint.json b/types/typed.js/tslint.json deleted file mode 100644 index e60c15844f..0000000000 --- a/types/typed.js/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "dtslint/dt.json" -} \ No newline at end of file diff --git a/types/typed.js/typed.js-tests.ts b/types/typed.js/typed.js-tests.ts deleted file mode 100644 index 3e4bd0a137..0000000000 --- a/types/typed.js/typed.js-tests.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Typed, TypedJsOptions } from 'typed.js'; - -// Create instance -const typed = new Typed(".element", { - strings: ["First sentence.", "& a second sentence."], - typeSpeed: 100, - startDelay: 0, - backSpeed: 50, - smartBackspace: true, - shuffle: true, - backDelay: 150, - loop: true, - showCursor: true, - autoInsertCss: true, - contentType: "html", - onComplete: (self: Typed) => { - // Complete!! - }, - onDestroy: (self: Typed) => { - // End!! - }, -}); - -// Methods -typed.reset(false); -typed.destroy(); -typed.start(); -typed.stop(); -typed.toggle(); diff --git a/types/ui-router-extras/index.d.ts b/types/ui-router-extras/index.d.ts index b36f030689..42f4926e87 100644 --- a/types/ui-router-extras/index.d.ts +++ b/types/ui-router-extras/index.d.ts @@ -131,6 +131,12 @@ declare module 'angular' { */ interface IStickyStateService { getInactiveStates(): IStickyState[]; + /* + * If there is an inactive state named inactiveStateName, this method exits that state. + * If stateParams is provided, then the state is only exited if the params match the inactive params. + * If inactiveStateName === '*', then all inactive states are exited + */ + reset(inactiveStateName: string, stateParams?: { [key: string]: string | string[] }): void; } /** diff --git a/types/ui-router-extras/ui-router-extras-tests.ts b/types/ui-router-extras/ui-router-extras-tests.ts index 5cc3ed122a..ef3f52ad79 100644 --- a/types/ui-router-extras/ui-router-extras-tests.ts +++ b/types/ui-router-extras/ui-router-extras-tests.ts @@ -16,7 +16,7 @@ myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: a onReactivate: ($state: angular.ui.IState) => { const iAmInjectedByInjector = $state; }, - controller: ($previousState: angular.ui.IPreviousStateService, $deepstateRedirect: angular.ui.IDeepStateRedirectService) => { + controller: ($previousState: angular.ui.IPreviousStateService, $deepstateRedirect: angular.ui.IDeepStateRedirectService, $stickyState: angular.ui.IStickyStateService) => { $previousState.memo('test-memo1'); $previousState.memo('test-memo2', 'test-state-name2'); $previousState.memo('test-memo3', 'test-state-name3', {}); @@ -32,6 +32,13 @@ myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: a stateParam1: ['value1', 'value2'], stateParam2: 'value' }); + + $stickyState.getInactiveStates(); + $stickyState.reset('state1'); + $stickyState.reset('state2', { + stateParam1: ['value1', 'value2'], + stateParam2: 'value' + }); }, views: { // named views are mandatory diff --git a/types/viewport-mercator-project/index.d.ts b/types/viewport-mercator-project/index.d.ts index 4d93d755bd..15b9fc373a 100644 --- a/types/viewport-mercator-project/index.d.ts +++ b/types/viewport-mercator-project/index.d.ts @@ -16,20 +16,26 @@ export type Coordinates = [number, number]; export type CoordinatesZ = [number, number, number]; +export type ViewMatrix = number[]; + +export type ProjectionMatrix = number[]; + export interface ViewportOptions { width?: number; height?: number; - longitude?: number; - latitude?: number; - zoom?: number; - pitch?: number; - bearing?: number; - altitude?: number; - farZMultiplier?: number; + viewMatrix?: ViewMatrix; + projectionMatrix?: ProjectionMatrix; } export class Viewport { + width: number; + height: number; + scale: number; + viewMatrix: ViewMatrix; + projectionMatrix: ProjectionMatrix; + constructor(opts?: ViewportOptions); + equals(viewport: Viewport): boolean; project(lngLat: Coordinates, opts?: ProjectOptions): Coordinates; project(lngLatZ: CoordinatesZ, opts?: ProjectOptions): CoordinatesZ; @@ -41,7 +47,32 @@ export type Padding = number | { top: number; right: number; bottom: number; lef export type Bounds = [Coordinates, Coordinates]; +export interface WebMercatorViewportOptions { + width?: number; + height?: number; + longitude?: number; + latitude?: number; + zoom?: number; + pitch?: number; + bearing?: number; + altitude?: number; + farZMultiplier?: number; +} + +// Type comes from https://github.com/uber-web/math.gl +export class Vector3 extends Array {} + export class WebMercatorViewport extends Viewport { + latitude: number; + longitude: number; + zoom: number; + pitch: number; + bearing: number; + altitude: number; + center: Vector3; + + constructor(opts?: WebMercatorViewportOptions); + projectFlat(lngLat: Coordinates, scale?: number): Coordinates; unprojectFlat(xy: Coordinates, scale?: number): Coordinates; getMapCenterByLngLatPosition(opts: { lngLat: Coordinates; pos: Coordinates }): Coordinates; @@ -78,14 +109,12 @@ export interface NormalizedViewportProps extends BaseViewportProps { export function normalizeViewportProps(props: ViewportProps): NormalizedViewportProps; -export function flyToViewport(startProps: BaseViewportProps, endProps: BaseViewportProps): BaseViewportProps; +export function flyToViewport(startProps: BaseViewportProps, endProps: BaseViewportProps, t: number): BaseViewportProps; export function lngLatToWorld(lngLat: Coordinates, scale: number): Coordinates; export function worldToLngLat(point: Coordinates, scale: number): Coordinates; -export type ProjectionMatrix = number[]; - export function worldToPixels(coordinates: Coordinates | CoordinatesZ, pixelProjectionMatrix: ProjectionMatrix): CoordinatesZ; export function pixelsToWorld(pixels: Coordinates | CoordinatesZ, pixelUnprojectionMatrix: ProjectionMatrix, targetZ?: number): CoordinatesZ; @@ -121,13 +150,8 @@ export function getDistanceScales(input: DistanceScalesInput): DistanceScales; export function getDistanceScales(input: HighPrecisionDistanceScalesInput): HighPrecisionDistanceScales; -// Type comes from https://github.com/uber-web/math.gl -export class Vector3 extends Array {} - export function getWorldPosition(input: { longitude: number; latitude: number; zoom: number; scale: number; meterOffset?: number; distanceScales?: DistanceScales }): Vector3; -export type ViewMatrix = number[]; - export function getViewMatrix(input: { height: number; pitch: number; bearing: number; altitude: number; center?: CoordinatesZ; flipY?: boolean }): ViewMatrix; export interface ProjectionParametersInput { diff --git a/types/viewport-mercator-project/viewport-mercator-project-tests.ts b/types/viewport-mercator-project/viewport-mercator-project-tests.ts index 5f2cc346b3..26fc54d466 100644 --- a/types/viewport-mercator-project/viewport-mercator-project-tests.ts +++ b/types/viewport-mercator-project/viewport-mercator-project-tests.ts @@ -6,6 +6,8 @@ import WebMercatorViewport, { const mercator = new WebMercatorViewport(); +const { width, height, scale, latitude, longitude, altitude, zoom, pitch, bearing, center, viewMatrix, projectionMatrix } = mercator; + const xy = mercator.project([0, 1]); const xyz = mercator.project([0, 1, 2]); diff --git a/types/vue-select/index.d.ts b/types/vue-select/index.d.ts new file mode 100644 index 0000000000..ff8767e189 --- /dev/null +++ b/types/vue-select/index.d.ts @@ -0,0 +1,98 @@ +// Type definitions for vue-select 2.4 +// Project: https://github.com/sagalbot/vue-select#readme +// Definitions by: Ilia Beliaev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { VueConstructor } from 'vue'; + +export default VueSelect; +export const VueSelect: VueSelectConstructor; +export type OptionConsumer = (option: any) => void; + +export interface VueSelectProps { + value: any; + options: any[]; + disabled: boolean; + maxHeight: string; + searchable: boolean; + multiple: boolean; + placeholder: string; + transition: string; + clearSearchOnSelect: boolean; + closeOnSelect: boolean; + label: string; + getOptionLabel: (option: any) => string; + onChange: OptionConsumer; + taggable: boolean; + tabindex: number | null; + pushTags: boolean; + filterable: boolean; + createOption: (option: any) => any; + resetOnOptionsChange: boolean; + noDrop: boolean; + inputId: string | null; + dir: string; +} + +export interface VueSelectData { + search: string; + open: boolean; + mutableValue: any; + mutableOptions: any[]; +} + +export interface VueSelectWatch { + value: (val: any) => void; + mutableValue: (val: any, old: any) => void; + options: (val: any) => void; + mutableOptions: () => void; + multiple: (reset: boolean) => void; + created: () => void; +} + +export interface VueSelectMethods { + select: OptionConsumer; + deselect: OptionConsumer; + clearSelection: () => void; + onAfterSelect: OptionConsumer; + toggleDropdown: (e: Event) => void; + isOptionSelected: (option: any) => boolean; + onEscape: () => void; + onSearchBlur: () => void; + onSearchFocus: () => void; + maybeDeleteValue: () => void; + optionExists: (option: any) => boolean; + maybePushTag: OptionConsumer; +} + +export interface VueSelectComputed { + dropdownClasses: () => DropdownClasses; + clearSearchOnBlur: () => boolean; + searching: () => boolean; + dropdownOpen: () => boolean; + searchPlaceholder: () => boolean; + filteredOptions: () => any[]; + isValueEmpty: () => boolean; + valueAsArray: () => any[]; + showClearButton: () => boolean; +} + +export interface DropdownClasses { + open: boolean; + single: boolean; + searching: boolean; + searchable: boolean; + unsearchable: boolean; + loading: boolean; + rtl: boolean; + disabled: boolean; +} + +export interface VueSelectConstructor extends VueConstructor { + props: VueSelectProps; + data: () => VueSelectData; + watch: VueSelectWatch; + methods: VueSelectMethods; + computed: VueSelectComputed; +} diff --git a/types/vue-select/package.json b/types/vue-select/package.json new file mode 100644 index 0000000000..faefc1b2f7 --- /dev/null +++ b/types/vue-select/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "vue": ">=2.0.0" + } +} diff --git a/types/vue-select/tsconfig.json b/types/vue-select/tsconfig.json new file mode 100644 index 0000000000..656897ba29 --- /dev/null +++ b/types/vue-select/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "vue-select-tests.ts" + ] +} diff --git a/types/vue-select/tslint.json b/types/vue-select/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/vue-select/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/vue-select/vue-select-tests.ts b/types/vue-select/vue-select-tests.ts new file mode 100644 index 0000000000..8fea33b2dc --- /dev/null +++ b/types/vue-select/vue-select-tests.ts @@ -0,0 +1,65 @@ +import Vue from 'vue'; +import VueSelect from 'vue-select'; + +const options = [ + { + name: 'SomeName' + }, + { + name: 'SomeName2' + } +]; + +new Vue({ + el: '#app', + data: { + options, + value: null, + }, + components: { + 'vue-select': VueSelect + }, + methods: { + getOptionLabel(option: any) { + if (option && option.name) { + return option.name; + } + return ''; + }, + optionConsumer(option: any) { + }, + optionToOption(option: any) { + return option; + }, + onSearch(search: string, loading: (b: boolean) => void) { + loading(true); + } + }, + template: ` + + +` +}); diff --git a/types/webappsec-credential-management/index.d.ts b/types/webappsec-credential-management/index.d.ts index ba9058a9a0..a0498f34af 100644 --- a/types/webappsec-credential-management/index.d.ts +++ b/types/webappsec-credential-management/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/w3c/webappsec-credential-management // Definitions by: Iain McGinniss // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.7 // Spec: https://www.w3.org/TR/2017/WD-credential-management-1-20170804 @@ -317,6 +317,11 @@ interface CredentialRequestOptions { * This property specifies options for requesting a public-key signature. */ publicKey?: PublicKeyCredentialRequestOptions; + + /** + * This property lets the developer abort an ongoing get() operation. + */ + signal?: AbortSignal; } /** @@ -345,6 +350,10 @@ interface CredentialCreationOptions { * @see {@link https://w3c.github.io/webauthn/#dictionary-makecredentialoptions} */ publicKey?: PublicKeyCredentialCreationOptions; + /** + * @see {@link https://w3c.github.io/webappsec-credential-management/#dom-credentialrequestoptions-signal} + */ + signal?: AbortSignal; } /** diff --git a/types/webpack-chain/index.d.ts b/types/webpack-chain/index.d.ts index 691e4be9b9..033ef9951f 100644 --- a/types/webpack-chain/index.d.ts +++ b/types/webpack-chain/index.d.ts @@ -85,10 +85,14 @@ declare namespace Config { class Plugins extends TypedChainedMap> {} - class Plugin extends ChainedMap { + class Plugin extends ChainedMap implements Orderable { init(value: (plugin: PluginClass, args: any[]) => webpack.Plugin): this; use(plugin: PluginClass, args?: any[]): this; tap(f: (args: any[]) => any[]): this; + + // Orderable + before(name: string): this; + after(name: string): this; } class Module extends ChainedMap { @@ -231,11 +235,15 @@ declare namespace Config { interface LoaderOptions { [name: string]: any; } - class Use extends ChainedMap { + class Use extends ChainedMap implements Orderable { loader(value: string): this; options(value: LoaderOptions): this; tap(f: (options: LoaderOptions) => LoaderOptions): this; + + // Orderable + before(name: string): this; + after(name: string): this; } type DevTool = 'eval' | 'inline-source-map' | 'cheap-eval-source-map' | 'cheap-source-map' | @@ -255,4 +263,9 @@ declare namespace Config { interface PluginClass { new (...opts: any[]): webpack.Plugin; } + + interface Orderable { + before(name: string): this; + after(name: string): this; + } } diff --git a/types/webpack-chain/webpack-chain-tests.ts b/types/webpack-chain/webpack-chain-tests.ts index 8775fec7f9..f1d0daa5e2 100644 --- a/types/webpack-chain/webpack-chain-tests.ts +++ b/types/webpack-chain/webpack-chain-tests.ts @@ -46,8 +46,20 @@ config .use(webpack.DefinePlugin, []) .end() + .plugin('bar') + .use(webpack.DefinePlugin, []) + .before('foo') + .end() + + .plugin('baz') + .use(webpack.DefinePlugin, []) + .after('bar') + .end() + .plugins .delete('foo') + .delete('bar') + .delete('baz') .end() .devServer @@ -107,8 +119,14 @@ config .loader('babel-loader') .options({}) .end() + .use('eslint') + .loader('eslint-loader') + .options({}) + .after('babel') + .end() .uses .delete('babel') + .delete('eslint') .end() .pre() .post()