Merge branch 'master' into ts-3.2-dom-updates

This commit is contained in:
Nathan Shively-Sanders
2018-11-20 11:40:05 -08:00
138 changed files with 3776 additions and 1438 deletions
+6
View File
@@ -636,6 +636,12 @@
"sourceRepoURL": "https://github.com/mikedeboer/node-github",
"asOfVersion": "7.1.0"
},
{
"libraryName": "gitlab",
"typingsPackageName": "gitlab",
"sourceRepoURL": "https://github.com/jdalrymple/node-gitlab",
"asOfVersion": "2.0.0"
},
{
"libraryName": "graphene-pk11",
"typingsPackageName": "graphene-pk11",
-2
View File
@@ -4,8 +4,6 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as Promise from 'bluebird';
export interface ManagementClientOptions {
token?: string;
domain: string;
+131
View File
@@ -0,0 +1,131 @@
import Timeout from "await-timeout";
/**
* This test is just a TS-friendly version of the await-timeout README:
* https://github.com/vitalets/await-timeout/blob/v0.3.0/README.md
*
* How to generate this file:
* 1. Paste the source code of README.md
* 2. Replace every code fence with async () => {}
* 3. Comment out all other lines
* 4. Add and remove import statements and repeated statements
* 5. Declare required globals
*/
// -- Globals --
declare const fetch: (url: string) => Promise<any>;
declare const console: any;
declare const MyTimeoutError: any;
// --- README ---
// ## Usage
// 1. Just wait some time:
async () => {
// wait 1000 ms and resolve
await Timeout.set(1000);
// wait 1000 ms and reject with 'Error'
await Timeout.set(1000, 'Error');
};
// 2. Use `Timeout` instance inside `try...finally` block to make proper cleanup:
async () => {
const timer = new Timeout();
try {
await Promise.race([
fetch('https://example.com'),
timer.set(1000)
.then(() => Promise.reject('Timeout'))
]);
} finally {
timer.clear();
}
};
// ## API
// ### new Timeout()
// Constructs new timeout instance. It does not start timer but creates variable for timer manipulation.
async () => {
const timer = new Timeout();
};
// > Note : having separate variable is useful for clearing timeout in `finally` block
// ### .set(ms, [message]) ⇒ `Promise`
// Starts new timer like `setTimeout()` and returns promise. The promise will be resolved after `ms` milliseconds:
async () => {
const timer = new Timeout();
timer.set(1000)
.then(() => console.log('1000 ms passed.'));
};
// If you need to reject after timeout:
async () => {
const timer = new Timeout();
timer.set(1000)
.then(() => {throw new Error('Timeout'); });
};
// Or reject with custom error:
async () => {
const timer = new Timeout();
timer.set(1000)
.then(() => {throw new MyTimeoutError(); });
};
// The second parameter `message` is just convenient way to reject with `new Error(message)`:
async () => {
const timer = new Timeout();
timer.set(1000, 'Timeout');
// is equivalent to
timer.set(1000).then(() => {throw new Error('Timeout'); });
};
// If you need to just wait some time - use static version of `.set()` :
async () => {
Timeout.set(1000).then(/*...*/);
};
// ### .wrap(promise, ms, [message]) ⇒ `Promise`
// Wraps existing promise with timeout:
// * promise automatically rejected after timeout
// * timeout automatically cleared if promise fulfills first
async () => {
const promise = fetch('https://example.com');
const timeoutedPromise = Timeout.wrap(promise, 1000, 'Timeout');
};
// Actually it is a shortcut for :
async () => {
const promise = fetch('https://example.com');
const timer = new Timeout();
try {
const timeoutedPromise = await Promise.race([
promise,
timer.set(1000, 'Timeout')
]);
} finally {
timer.clear();
}
};
// ### .clear()
// Clears existing timeout like `clearTimeout()`.
async () => {
const timer = new Timeout();
timer.set(1000)
.then(() => console.log('This will never be called, because timeout is cleared on the next line'));
timer.clear();
};
// With [ES7 async / await ] `.clear()` can be used in `finally` block:
async () => {
async function foo() {
const timer = new Timeout();
try {
// some async stuff
} finally {
timer.clear();
}
}
};
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for await-timeout 0.3
// Project: https://github.com/vitalets/await-timeout
// Definitions by: Sean Zhu <https://github.com/szhu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export default Timeout;
declare class Timeout {
static set(delay: number): Promise<undefined>;
static set(delay: number, message: string): Promise<never>;
static wrap(promise: Promise<any>, delay: number, error?: string): Promise<any>;
set(delay: number): Promise<undefined>;
set(delay: number, message: string): Promise<never>;
clear(): void;
}
+23
View File
@@ -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",
"await-timeout-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1
View File
@@ -103,6 +103,7 @@ expect("abcd").to.have.length(4);
expect(5).to.equal(5);
expect({ a: 1 }).to.equal({ a: 1 });
expect([1, 2, 3]).to.equal([1, 2, 3]);
expect(Object.create(null)).to.equal({}, { prototype: false });
+2 -2
View File
@@ -125,9 +125,9 @@ export interface Values<T> {
/** Asserts that the reference value has a length property matching the provided size or an object with the specified number of keys. */
length(size: number): AssertionChain<T>;
/** Asserts that the reference value equals the provided value. */
equal(value: T, options?: any): AssertionChain<T>;
equal(value: T | T[], options?: any): AssertionChain<T>;
/** Asserts that the reference value equals the provided value. */
equals(value: T, options?: any): AssertionChain<T>;
equals(value: T | T[], options?: any): AssertionChain<T>;
/** Asserts that the reference value is greater than (>) the provided value. */
above(value: T): AssertionChain<T>;
/** Asserts that the reference value is greater than (>) the provided value. */
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for cookie 0.3
// Project: https://github.com/jshttp/cookie
// Definitions by: Pine Mizune <https://github.com/pine613>
// Definitions by: Pine Mizune <https://github.com/pine>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface CookieSerializeOptions {
+3 -2
View File
@@ -1,5 +1,4 @@
import countries from 'country-list';
const Countries = countries();
import * as Countries from 'country-list';
Countries.getCode('Barbados'); // BB
@@ -14,3 +13,5 @@ Countries.getName('BB'); // Barbados
Countries.getNameList();
Countries.getNames();
Countries.overwrite([{ code: 'TW', name: 'Taiwan' }]);
+35 -31
View File
@@ -1,41 +1,45 @@
// Type definitions for country-list 1.1
// Type definitions for country-list 2.1
// Project: https://github.com/fannarsh/country-list
// Definitions by: Kyle Roach <https://github.com/iRoachie>
// Adam Binford <https://github.com/Kimahriman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export default function Countries(): {
/**
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
*/
getName(code: string): string | undefined;
/**
* Expects an array of code and country name pairs to add to the list. Doesn't return anything.
*/
export function overwrite(countries: Array<{ code: string, name: string}>): void;
/**
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
*/
getCode(name: string): string | undefined;
/**
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
*/
export function getName(code: string): string | undefined;
/**
* Returns an array of all country names.
*/
getNames(): string[];
/**
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
*/
export function getCode(name: string): string | undefined;
/**
* Returns an array of all country codes.
*/
getCodes(): string[];
/**
* Returns an array of all country names.
*/
export function getNames(): string[];
/**
* Returns a key-value object of all countries using the name as key.
*/
getNameList(): {[name: string]: string};
/**
* Returns an array of all country codes.
*/
export function getCodes(): string[];
/**
* Returns a key-value object of all countries using the code as key.
*/
getCodeList(): {[code: string]: string};
/**
* Returns a key-value object of all countries using the name as key.
*/
export function getNameList(): {[name: string]: string};
/**
* Returns an array of all country information, in the same format as it gets imported.
*/
getData(): Array<{ code: string, name: string }>;
};
/**
* Returns a key-value object of all countries using the code as key.
*/
export function getCodeList(): {[code: string]: string};
/**
* Returns an array of all country information, in the same format as it gets imported.
*/
export function getData(): Array<{ code: string, name: string }>;
@@ -0,0 +1,16 @@
import countries from 'country-list';
const Countries = countries();
Countries.getCode('Barbados'); // BB
Countries.getCodes();
Countries.getCodeList();
Countries.getData();
Countries.getName('BB'); // Barbados
Countries.getNameList();
Countries.getNames();
+41
View File
@@ -0,0 +1,41 @@
// Type definitions for country-list 1.1
// Project: https://github.com/fannarsh/country-list
// Definitions by: Kyle Roach <https://github.com/iRoachie>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export default function Countries(): {
/**
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
*/
getName(code: string): string | undefined;
/**
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
*/
getCode(name: string): string | undefined;
/**
* Returns an array of all country names.
*/
getNames(): string[];
/**
* Returns an array of all country codes.
*/
getCodes(): string[];
/**
* Returns a key-value object of all countries using the name as key.
*/
getNameList(): {[name: string]: string};
/**
* Returns a key-value object of all countries using the code as key.
*/
getCodeList(): {[code: string]: string};
/**
* Returns an array of all country information, in the same format as it gets imported.
*/
getData(): Array<{ code: string, name: string }>;
};
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"country-list": ["country-list/v1"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"country-list-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+31
View File
@@ -0,0 +1,31 @@
import depsSort = require("deps-sort");
function browserifyTest(opts: depsSort.Options) {
const depsOpts: depsSort.Options = {
index: opts != null && opts.index,
dedupe: opts != null && opts.dedupe,
expose: opts.expose || { id: "file.txt" }
};
const res = depsSort(); // 'opts' are optional
res.pipe(depsSort(depsOpts));
res.once("error", (err: any) => {
console.error("module-deps error: ", err);
});
const inst: NodeJS.ReadWriteStream = depsSort({
index: true,
expose: { id: "file.txt" }
});
inst.on("file", (file, id) => {
console.log("file", file, id);
});
inst.on("package", (pkg) => {
console.log("package", pkg);
});
inst.on("transform", (tr, file) => {
console.log("transform", tr, file);
});
}
+85
View File
@@ -0,0 +1,85 @@
// Type definitions for deps-sort 2.0
// Project: https://github.com/browserify/deps-sort
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as stream from "stream";
/**
* Return a new through stream that should get written module-deps objects and will output sorted objects.
*/
declare function depsSort(opts?: depsSort.Options): stream.Transform;
/**
* Sort module-deps output for deterministic browserify bundles.
*/
declare namespace depsSort {
/**
* module-deps constructor options
*/
interface Options {
/**
* When true, for each module-deps row, insert 'row.index' with the numeric index and
* 'row.indexDeps' like 'row.deps' but mapping require strings to row indices
*/
index?: boolean;
/**
* array of names or object mapping names to true not to mangle with integer indexes when 'index' is turned on.
* If 'expose' maps names to strings, those strings will be used to resolve the indexed references.
*/
expose?: string[] | { [name: string]: boolean | string };
/**
* Set 'row.dedupe' for files that match existing contents. Sets 'row.dedupeIndex' when 'index' is enabled.
* When 'row.dedupe' is set, 'row.sameDeps' will be set to a boolean of whether the dependencies at the dedupe target match (true) or just the source content (false).
*/
dedupe?: boolean;
[prop: string]: any;
}
/**
* Input objects are file objects in the module-deps shape. They must at least have these properties:
*/
interface InputRow {
/**
* a unique identifier for the file
*/
id: string;
/**
* the file contents
*/
source: string;
/**
* dependencies for this file, mapping strings as used in require() to row IDs
*/
deps: string[];
}
/**
* All the input properties, and:
*/
interface OutputRow {
/**
* when 'opts.index' is true, the sorted numeric index of the row
*/
index: number;
/**
* like 'row.deps', but mapping to 'row.index' instead of 'row.id'
*/
indexDeps: { [id: string]: number };
/**
* when 'opts.dedupe' is true, contains the row ID of a file with identical contents
*/
dedupe: string;
/**
* like 'row.dedupe', but contains the 'row.index' instead of 'row.id'
*/
dedupeIndex: number;
}
}
export = depsSort;
@@ -18,6 +18,6 @@
},
"files": [
"index.d.ts",
"gitlab-tests.ts"
"deps-sort-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+33 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for dplayer 1.24
// Type definitions for dplayer 1.25
// Project: https://github.com/DIYgod/DPlayer#readme
// Definitions by: Guanyunhan <https://github.com/Guanyunhan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -9,6 +9,7 @@ export type Preload = 'none' | 'metadata' | 'auto';
export type VideoType = 'auto' | 'hls' | 'flv' | 'dash' | 'webtorrent' | 'normal';
export type SubTitleType = 'webvtt' | 'ass';
export type DirectionType = 'top' | 'right' | 'bottom';
export type FullScreenType = 'web' | 'browser';
export enum DPlayerEvents {
abort = 'abort',
@@ -98,12 +99,20 @@ export interface DPlayerHighLightItem {
time: number;
}
export interface DPlayerVideoQuality {
name: string;
url: string;
type?: string;
}
export interface DPlayerVideo {
url: string;
pic?: string;
thumbnails?: string;
type?: VideoType | string;
customType?: any;
quality?: DPlayerVideoQuality[];
defaultQuality?: number;
}
export interface DPlayerSubTitle {
@@ -131,8 +140,31 @@ export interface DPlayerAPIBackend {
send(endpoint: any, danmakuData: DPlayerDanmakuItem, callback: () => void): void;
}
export interface Danmaku {
send(danmaku: DPlayerDanmakuItem, callback: () => void): void;
draw(danmaku: DPlayerDanmakuItem): void;
opacity(percentage: number): void;
clear(): void;
hide(): void;
show(): void;
}
export interface FullScreen {
request(type: FullScreenType): void;
cancel(type: FullScreenType): void;
}
export default class DPlayer {
events: any;
video: HTMLVideoElement;
danmaku: Danmaku;
fullScreen: FullScreen;
constructor(options: DPlayerOptions);
+11 -5
View File
@@ -8,15 +8,21 @@ interface Options {
name: string;
main: string;
baseDir?: string;
exclude?: RegExp;
externals?: boolean;
indent?: string;
newLine?: string;
out?: string;
prefix?: string;
externals?: boolean;
referenceExternals?: boolean;
exclude?: RegExp | ((file: string, external: boolean) => boolean);
removeSource?: boolean;
newLine?: string;
indent?: string;
prefix?: string;
separator?: string;
verbose?: boolean;
emitOnIncludedFileNotFound?: boolean;
emitOnNoIncludedFileNotFound?: boolean;
outputAsModuleFolder?: boolean;
headerPath?: string;
headerText?: string;
}
export declare function bundle(opts: Options): void;
+28 -3
View File
@@ -9,9 +9,34 @@ declare function elementResizeDetectorMaker(options?: elementResizeDetectorMaker
declare namespace elementResizeDetectorMaker {
interface ErdmOptions {
strategy?: 'scroll' | 'object';
/**
* A custom reporter that handles reporting logs, warnings and errors.
* If not provided, a default id handler will be used.
* If set to false, then nothing will be reported.
*/
reporter?: ReporterProps;
/**
* Determines if listeners should be called when they are getting added.
* If true, the listener is guaranteed to be called when it has been added.
* If false, the listener will not be guarenteed to be called when
* it has been added (does not prevent it from being called).
*
* @default true
*/
callOnAdd?: boolean;
/**
* A custom id handler that is responsible for generating,
* setting and retrieving id's for elements.
* If not provided, a default id handler will be used.
*/
idHandler?: IdHandlerProps;
/**
* If set to true, the the system will report debug messages as default
* for the listenTo method.
*/
debug?: boolean;
}
@@ -21,9 +46,9 @@ declare namespace elementResizeDetectorMaker {
}
interface ReporterProps {
log(): void;
warn(): void;
error(): void;
log(idOrText: string, textOrId: string, element?: HTMLElement): void;
warn(text: string, element?: HTMLElement): void;
error(text: string): void;
}
interface Erd {
+1 -1
View File
@@ -11,7 +11,7 @@ Ember.Route.extend({
});
Ember.Controller.extend({
previousTransition: <Transition | null> null,
previousTransition: null as Transition | null,
actions: {
login() {
+19 -13
View File
@@ -1895,20 +1895,26 @@ declare module 'ember' {
paramsFor(name: string): {};
/**
* Refresh the model on this route and any child routes, firing the
* `beforeModel`, `model`, and `afterModel` hooks in a similar fashion
* to how routes are entered when transitioning in from other route.
* The current route params (e.g. `article_id`) will be passed in
* to the respective model hooks, and if a different model is returned,
* `setupController` and associated route hooks will re-fire as well.
* An example usage of this method is re-querying the server for the
* latest information using the same parameters as when the route
* was first entered.
* Note that this will cause `model` hooks to fire even on routes
* that were provided a model object when the route was initially
* entered.
* A hook you can implement to optionally redirect to another route.
*
* If you call `this.transitionTo` from inside of this hook, this route
* will not be entered in favor of the other hook.
*
* `redirect` and `afterModel` behave very similarly and are
* called almost at the same time, but they have an important
* distinction in the case that, from one of these hooks, a
* redirect into a child route of this route occurs: redirects
* from `afterModel` essentially invalidate the current attempt
* to enter this route, and will result in this route's `beforeModel`,
* `model`, and `afterModel` hooks being fired again within
* the new, redirecting transition. Redirects that occur within
* the `redirect` hook, on the other hand, will _not_ cause
* these hooks to be fired again the second time around; in
* other words, by the time the `redirect` hook has been called,
* both the resolved model and attempted entry into this route
* are considered to be fully validated.
*/
redirect(): Transition;
redirect(model: {}, transition: Transition): void;
/**
* Refresh the model on this route and any child routes, firing the
+8
View File
@@ -86,6 +86,14 @@ Route.extend({
},
});
class RedirectRoute extends Route {
redirect(model: {}, a: Ember.Transition) {
if (!model) {
this.transitionTo('there');
}
}
}
class RouteUsingClass extends Route.extend({
randomProperty: 'the .extend + extends bit type-checks properly',
}) {
+1 -1
View File
@@ -10,7 +10,7 @@ Ember.Route.extend({
});
Ember.Controller.extend({
previousTransition: <Ember.Transition | null> null,
previousTransition: null as Ember.Transition | null,
actions: {
login() {
+19 -13
View File
@@ -79,20 +79,26 @@ export default class Route extends EmberObject.extend(ActionHandler, Evented) {
paramsFor(name: string): {};
/**
* Refresh the model on this route and any child routes, firing the
* `beforeModel`, `model`, and `afterModel` hooks in a similar fashion
* to how routes are entered when transitioning in from other route.
* The current route params (e.g. `article_id`) will be passed in
* to the respective model hooks, and if a different model is returned,
* `setupController` and associated route hooks will re-fire as well.
* An example usage of this method is re-querying the server for the
* latest information using the same parameters as when the route
* was first entered.
* Note that this will cause `model` hooks to fire even on routes
* that were provided a model object when the route was initially
* entered.
* A hook you can implement to optionally redirect to another route.
*
* If you call `this.transitionTo` from inside of this hook, this route
* will not be entered in favor of the other hook.
*
* `redirect` and `afterModel` behave very similarly and are
* called almost at the same time, but they have an important
* distinction in the case that, from one of these hooks, a
* redirect into a child route of this route occurs: redirects
* from `afterModel` essentially invalidate the current attempt
* to enter this route, and will result in this route's `beforeModel`,
* `model`, and `afterModel` hooks being fired again within
* the new, redirecting transition. Redirects that occur within
* the `redirect` hook, on the other hand, will _not_ cause
* these hooks to be fired again the second time around; in
* other words, by the time the `redirect` hook has been called,
* both the resolved model and attempted entry into this route
* are considered to be fully validated.
*/
redirect(): Transition;
redirect(model: {}, transition: Transition): void;
/**
* Refresh the model on this route and any child routes, firing the
+16
View File
@@ -80,6 +80,22 @@ Route.extend({
},
});
class RedirectRoute extends Route {
redirect(model: {}, a: Transition) {
if (!model) {
this.transitionTo('there');
}
}
}
class InvalidRedirect extends Route {
redirect(model: {}, a: Transition, anOddArg: any) { // $ExpectError
if (!model) {
this.transitionTo('there');
}
}
}
class ApplicationController extends Controller {}
declare module '@ember/controller' {
interface Registry {
+202 -19
View File
@@ -1,4 +1,4 @@
// Type definitions for WebExtension Development in FireFox 63.0
// Type definitions for WebExtension Development in FireFox 64.0
// Project: https://developer.mozilla.org/en-US/Add-ons/WebExtensions
// Definitions by: Jasmin Bom <https://github.com/jsmnbom>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -141,6 +141,9 @@ declare namespace browser._manifest {
};
hidden?: boolean;
theme_experiment?: ThemeExperiment;
user_scripts?: {
api_script?: ExtensionURL;
};
browser_action?: {
default_title?: string;
default_icon?: IconPath;
@@ -163,8 +166,10 @@ declare namespace browser._manifest {
instant_url?: string;
/** @deprecated Unsupported on Firefox at this time. */
image_url?: string;
/** @deprecated Unsupported on Firefox at this time. */
/** POST parameters to the search_url as a query string. */
search_url_post_params?: string;
/** POST parameters to the suggest_url as a query string. */
suggest_url_post_params?: string;
/** @deprecated Unsupported on Firefox at this time. */
instant_url_post_params?: string;
/** @deprecated Unsupported on Firefox at this time. */
@@ -175,6 +180,22 @@ declare namespace browser._manifest {
prepopulated_id?: number;
/** Sets the default engine to a built-in engine only. */
is_default?: boolean;
/**
* A list of optional search url parameters. This allows the additon of search url parameters based on
* how the search is performed in Firefox.
*/
params?: Array<{
/** A url parameter name */
name: string;
/** The type of param can be either "purpose" or "pref". */
condition?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsCondition;
/** The preference to retreive the value from. */
pref?: string;
/** The context that initiates a search, required if condition is "purpose". */
purpose?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsPurpose;
/** A url parameter value. */
value?: string;
}>;
};
};
commands?: {
@@ -202,6 +223,7 @@ declare namespace browser._manifest {
browser_style?: boolean;
show_matches?: MatchPattern[];
hide_matches?: MatchPatternRestricted[];
pinned?: boolean;
};
sidebar_action?: {
default_title?: string;
@@ -363,9 +385,6 @@ declare namespace browser._manifest {
*/
type MatchPatternUnestricted = string;
/** Same as MatchPattern above, but includes moz-extension protocol */
type MatchPatternInternal = string | _MatchPatternInternal;
/**
* Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be
* set at the same time. Based on InjectDetails, but using underscore rather than camel case naming conventions.
@@ -475,6 +494,7 @@ declare namespace browser._manifest {
ntp_background?: ThemeColor;
ntp_text?: ThemeColor;
sidebar?: ThemeColor;
sidebar_border?: ThemeColor;
sidebar_text?: ThemeColor;
sidebar_highlight?: ThemeColor;
sidebar_highlight_text?: ThemeColor;
@@ -596,6 +616,7 @@ declare namespace browser._manifest {
| "bookmarks"
| "find"
| "history"
| "menus.overrideContext"
| "search"
| "activeTab"
| "tabs"
@@ -632,6 +653,17 @@ declare namespace browser._manifest {
| "tabstrip"
| "personaltoolbar";
/** The type of param can be either "purpose" or "pref". */
type _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsCondition = "purpose" | "pref";
/** The context that initiates a search, required if condition is "purpose". */
type _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsPurpose =
"contextmenu"
| "searchbar"
| "homepage"
| "keyword"
| "newtab";
type _ProtocolHandlerProtocol =
"bitcoin"
| "dat"
@@ -661,8 +693,6 @@ declare namespace browser._manifest {
type _MatchPattern = "<all_urls>";
type _MatchPatternInternal = "<all_urls>";
type _ThemeTypeAdditionalBackgroundsAlignment =
"bottom"
| "center"
@@ -785,12 +815,6 @@ declare namespace browser.clipboard {
/** Not allowed in: Content scripts, Devtools pages */
declare namespace browser.contentScripts {
/* contentScripts types */
type ExtensionFileOrCode = {
file: _manifest.ExtensionURL;
} | {
code: string;
};
/** Details of a content script registered programmatically */
interface RegisteredContentScriptOptions {
matches: _manifest.MatchPattern[];
@@ -798,9 +822,9 @@ declare namespace browser.contentScripts {
includeGlobs?: string[];
excludeGlobs?: string[];
/** The list of CSS files to inject */
css?: ExtensionFileOrCode[];
css?: extensionTypes.ExtensionFileOrCode[];
/** The list of JS files to inject */
js?: ExtensionFileOrCode[];
js?: extensionTypes.ExtensionFileOrCode[];
/**
* If allFrames is `true`, implies that the JavaScript or CSS should be injected into all frames of current
* page. By default, it's `false` and is only injected into the top frame.
@@ -1912,6 +1936,22 @@ declare namespace browser.extensionTypes {
}
type Date = string | number | object/*Date*/;
type ExtensionFileOrCode = {
file: _manifest.ExtensionURL;
} | {
code: string;
};
/** A plain JSON value */
type PlainJSONValue = null | string | number | boolean | _PlainJSONArray | _PlainJSONObject;
interface _PlainJSONArray extends Array<PlainJSONValue> {
}
interface _PlainJSONObject {
[key: string]: PlainJSONValue;
}
}
/**
@@ -2403,7 +2443,7 @@ declare namespace browser.permissions {
interface AnyPermissions {
permissions?: _manifest.Permission[];
origins?: _manifest.MatchPatternInternal[];
origins?: _manifest.MatchPattern[];
}
/* permissions functions */
@@ -2524,7 +2564,8 @@ declare namespace browser.privacy.websites {
"allow_all"
| "reject_all"
| "reject_third_party"
| "allow_visited";
| "allow_visited"
| "reject_trackers";
/* privacy.websites properties */
/**
@@ -3456,6 +3497,64 @@ declare namespace browser.types {
}
}
/**
* Manifest keys: `user_scripts`, `user_scripts`
*
* Not allowed in: Devtools pages
*/
declare namespace browser.userScripts {
/* userScripts types */
/** Details of a user script */
interface UserScriptOptions {
/** The list of JS files to inject */
js?: extensionTypes.ExtensionFileOrCode[];
/** An opaque user script metadata value */
scriptMetadata?: extensionTypes.PlainJSONValue;
matches: _manifest.MatchPattern[];
excludeMatches?: _manifest.MatchPattern[];
includeGlobs?: string[];
excludeGlobs?: string[];
/**
* If allFrames is `true`, implies that the JavaScript should be injected into all frames of current page. By
* default, it's `false` and is only injected into the top frame.
*/
allFrames?: boolean;
/**
* If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your
* extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default
* it is `false`.
*/
matchAboutBlank?: boolean;
/** The soonest that the JavaScript will be injected into the tab. Defaults to "document_idle". */
runAt?: extensionTypes.RunAt;
}
/** An object that represents a user script registered programmatically */
interface RegisteredUserScript {
/** Unregister a user script registered programmatically */
unregister(): Promise<any>;
}
/** A set of API methods provided by the extensions to its userScripts */
interface ExportedAPIMethods {
[key: string]: (...args: any[]) => any;
}
/* userScripts functions */
/**
* Register a user script programmatically given its `userScripts.UserScriptOptions`, and resolves to a
* `userScripts.RegisteredUserScript` instance
*/
function register(userScriptOptions: UserScriptOptions): Promise<RegisteredUserScript>;
/**
* Provides a set of custom API methods available to the registered userScripts
*
* Allowed in: Content scripts only
*/
function setScriptAPIs(exportedAPIMethods: ExportedAPIMethods): void;
}
/**
* Use the `browser.webNavigation` API to receive notifications about the status of navigation requests in-flight.
*
@@ -5302,9 +5401,8 @@ declare namespace browser.devtools.panels {
/**
* Sets an HTML page to be displayed in the sidebar pane.
* @param path Relative path of an extension page to display within the sidebar.
* @deprecated Unsupported on Firefox at this time.
*/
setPage?(path: string): void;
setPage(path: _manifest.ExtensionURL): Promise<any>;
/**
* Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it.
@@ -5706,6 +5804,8 @@ declare namespace browser.contextMenus {
menuItemId: number | string;
/** The parent ID, if any, for the item clicked. */
parentMenuItemId?: number | string;
/** The type of view where the menu is clicked. May be unset if the menu is not associated with a view. */
viewType?: extension.ViewType;
/**
* One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements.
*/
@@ -5735,6 +5835,8 @@ declare namespace browser.contextMenus {
bookmarkId: string;
/** An array of keyboard modifiers that were held while the menu item was clicked. */
modifiers: _OnClickDataModifiers[];
/** An integer value of button by which menu item was clicked. */
button?: number;
/**
* An identifier of the clicked element, if any. Use menus.getTargetElement in the page to find the
* corresponding element.
@@ -5749,6 +5851,12 @@ declare namespace browser.contextMenus {
| "Ctrl"
| "MacCtrl";
/**
* ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and
* 'tab' are supported. showDefaults cannot be used with this option.
*/
type _OverrideContextContext = "bookmark" | "tab";
/* contextMenus properties */
/**
* The maximum number of top level extension items that can be added to an extension action context menu. Any items
@@ -5789,6 +5897,11 @@ declare namespace browser.contextMenus {
checked?: boolean;
/** List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */
contexts?: ContextType[];
/**
* List of view types where the menu item will be shown. Defaults to any view, including those without a
* viewType.
*/
viewTypes?: extension.ViewType[];
/** Whether the item is visible in the menu. */
visible?: boolean;
/**
@@ -5827,9 +5940,13 @@ declare namespace browser.contextMenus {
*/
function update(id: number | string, updateProperties: {
type?: ItemType;
icons?: {
[key: number]: string;
};
title?: string;
checked?: boolean;
contexts?: ContextType[];
viewTypes?: extension.ViewType[];
/** Whether the item is visible in the menu. */
visible?: boolean;
/**
@@ -5853,6 +5970,24 @@ declare namespace browser.contextMenus {
/** Removes all context menu items added by this extension. */
function removeAll(): Promise<void>;
/**
* Show the matching menu items from this extension instead of the default menu. This should be called during a
* 'contextmenu' DOM event handler, and only applies to the menu that opens after this event.
*/
function overrideContext(contextOptions: {
/** Whether to also include default menu items in the menu. */
showDefaults?: boolean;
/**
* ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark'
* and 'tab' are supported. showDefaults cannot be used with this option.
*/
context?: _OverrideContextContext;
/** Required when context is 'bookmark'. Requires 'bookmark' permission. */
bookmarkId?: string;
/** Required when context is 'tab'. Requires 'tabs' permission. */
tabId?: number;
}): void;
/**
* Updates the extension items in the shown menu, including changes that have been made since the menu was shown.
* Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation, only invoke this method
@@ -5889,6 +6024,7 @@ declare namespace browser.contextMenus {
menuIds: number | string[];
/** A list of all contexts that apply to the menu. */
contexts: ContextType[];
viewType?: extension.ViewType;
editable: boolean;
mediaType?: string;
linkUrl?: string;
@@ -5947,6 +6083,8 @@ declare namespace browser.menus {
menuItemId: number | string;
/** The parent ID, if any, for the item clicked. */
parentMenuItemId?: number | string;
/** The type of view where the menu is clicked. May be unset if the menu is not associated with a view. */
viewType?: extension.ViewType;
/**
* One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements.
*/
@@ -5976,6 +6114,8 @@ declare namespace browser.menus {
bookmarkId: string;
/** An array of keyboard modifiers that were held while the menu item was clicked. */
modifiers: _OnClickDataModifiers[];
/** An integer value of button by which menu item was clicked. */
button?: number;
/**
* An identifier of the clicked element, if any. Use menus.getTargetElement in the page to find the
* corresponding element.
@@ -5990,6 +6130,12 @@ declare namespace browser.menus {
| "Ctrl"
| "MacCtrl";
/**
* ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and
* 'tab' are supported. showDefaults cannot be used with this option.
*/
type _OverrideContextContext = "bookmark" | "tab";
/* menus properties */
/**
* The maximum number of top level extension items that can be added to an extension action context menu. Any items
@@ -6030,6 +6176,11 @@ declare namespace browser.menus {
checked?: boolean;
/** List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */
contexts?: ContextType[];
/**
* List of view types where the menu item will be shown. Defaults to any view, including those without a
* viewType.
*/
viewTypes?: extension.ViewType[];
/** Whether the item is visible in the menu. */
visible?: boolean;
/**
@@ -6068,9 +6219,13 @@ declare namespace browser.menus {
*/
function update(id: number | string, updateProperties: {
type?: ItemType;
icons?: {
[key: number]: string;
};
title?: string;
checked?: boolean;
contexts?: ContextType[];
viewTypes?: extension.ViewType[];
/** Whether the item is visible in the menu. */
visible?: boolean;
/**
@@ -6094,6 +6249,24 @@ declare namespace browser.menus {
/** Removes all context menu items added by this extension. */
function removeAll(): Promise<void>;
/**
* Show the matching menu items from this extension instead of the default menu. This should be called during a
* 'contextmenu' DOM event handler, and only applies to the menu that opens after this event.
*/
function overrideContext(contextOptions: {
/** Whether to also include default menu items in the menu. */
showDefaults?: boolean;
/**
* ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark'
* and 'tab' are supported. showDefaults cannot be used with this option.
*/
context?: _OverrideContextContext;
/** Required when context is 'bookmark'. Requires 'bookmark' permission. */
bookmarkId?: string;
/** Required when context is 'tab'. Requires 'tabs' permission. */
tabId?: number;
}): void;
/**
* Updates the extension items in the shown menu, including changes that have been made since the menu was shown.
* Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation, only invoke this method
@@ -6130,6 +6303,7 @@ declare namespace browser.menus {
menuIds: number | string[];
/** A list of all contexts that apply to the menu. */
contexts: ContextType[];
viewType?: extension.ViewType;
editable: boolean;
mediaType?: string;
linkUrl?: string;
@@ -7108,6 +7282,13 @@ declare namespace browser.tabs {
function highlight(highlightInfo: {
/** The window that contains the tabs. */
windowId?: number;
/**
* If true, the `windows.Window` returned will have a `tabs` property that contains a list of the `tabs.Tab`
* objects. The `Tab` objects only contain the `url`, `title` and `favIconUrl` properties if the extension's
* manifest file includes the `"tabs"` permission. If false, the `windows.Window` won't have the `tabs`
* property.
*/
populate?: boolean;
/** One or more tab indices to highlight. */
tabs: number[] | number;
}): Promise<windows.Window | undefined>;
@@ -7632,6 +7813,8 @@ declare namespace browser.windows {
state?: WindowState;
/** Allow scripts to close the window. */
allowScriptsToClose?: boolean;
/** The CookieStoreId to use for all tabs that were created when the window is opened. */
cookieStoreId?: string;
/** A string to add to the beginning of the window title. */
titlePreface?: string;
}): Promise<Window | undefined>;
+21 -9
View File
@@ -1,13 +1,25 @@
const TYPES = {
DOCUMENT: 'DOCUMENT',
PAGE: 'PAGE',
SCREEN: 'SCREEN',
IMAGE: 'IMAGE',
RECTANGLE: 'RECT',
ELLIPSE: 'ELLIPSE',
DIAMOND: 'DIAMOND',
HOTSPOT: 'HOTSPOT',
LAYER: 'LAYER',
} as Flow.Types;
const flowFile: Flow.File = {
document: {
id: 'cjo45613k00002a5p9gj6nr3b',
name: 'Basic Document',
type: Flow.Type.Document,
type: TYPES.DOCUMENT,
children: [
{
id: 'cjo456d2700002a5p80zudiut',
name: 'Page 1',
type: Flow.Type.Page,
type: TYPES.PAGE,
backgroundColor: {
r: 0,
g: 0,
@@ -18,7 +30,7 @@ const flowFile: Flow.File = {
{
id: 'cjo45mq7500002a5p8n8u1bfz',
name: 'Sign in',
type: Flow.Type.Screen,
type: TYPES.SCREEN,
source: {
fileName: 'sign-in.png',
dirPath: './assets',
@@ -36,7 +48,7 @@ const flowFile: Flow.File = {
{
id: 'cjo45oi8700002a5pmpnxhfny',
name: 'Sign up',
type: Flow.Type.Screen,
type: TYPES.SCREEN,
source: {
fileName: 'sign-up.png',
dirPath: './assets',
@@ -65,10 +77,10 @@ flowFile.settings = {};
flowFile.schemaVersion = 1;
const document: Flow.Document = flowFile.document;
document.type = Flow.Type.Document;
document.type = TYPES.DOCUMENT;
const page: Flow.Page = document.children[0];
page.type = Flow.Type.Page;
page.type = TYPES.PAGE;
page.backgroundColor = {
r: 255,
g: 255,
@@ -79,7 +91,7 @@ page.backgroundColor = {
const hotspot: Flow.Layer = {
id: 'cjo5mezgg00003g5winhxc8o0',
name: 'Layer',
type: Flow.Type.Hotspot,
type: TYPES.HOTSPOT,
position: {
x: 390,
y: 390,
@@ -92,10 +104,10 @@ const hotspot: Flow.Layer = {
nodeID: 'cjo45mq7500002a5p8n8u1bfz',
}],
};
hotspot.type = Flow.Type.Hotspot;
hotspot.type = TYPES.HOTSPOT;
const screen = page.children[0] as Flow.Screen;
screen.type = Flow.Type.Screen;
screen.type = TYPES.SCREEN;
screen.children.push(hotspot);
screen.position = {
x: 0,
+23 -21
View File
@@ -1,4 +1,4 @@
// Type definitions for flowdoc 1.0
// Type definitions for flowdoc 1.1
// Project: https://github.com/overflowapp/Flow
// Definitions by: Stefan Mansson <https://github.com/animify>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -14,42 +14,42 @@ declare namespace Flow {
interface Document {
id: string;
name: string;
type: Type.Document;
type: Types['DOCUMENT'];
children: Page[];
}
interface Page extends Node {
type: Type.Page;
children: Array<(Screen | Image | Rectangle | Ellipse | Diamond)>;
type: Types['PAGE'];
children: Array<Screen | Image | Rectangle | Ellipse | Diamond>;
backgroundColor: Color;
startNodeID?: string;
}
interface Screen extends Graphic {
type: Type.Screen;
type: Types['SCREEN'];
children: Layer[];
connections?: Connection[];
}
interface Image extends Graphic {
type: Type.Image;
type: Types['IMAGE'];
connections?: Connection[];
}
interface Rectangle extends Shape {
type: Type.Rectangle;
type: Types['RECTANGLE'];
}
interface Ellipse extends Shape {
type: Type.Ellipse;
type: Types['ELLIPSE'];
}
interface Diamond extends Shape {
type: Type.Diamond;
type: Types['DIAMOND'];
}
interface Layer extends Node {
type: Type.Layer | Type.Hotspot;
type: Types['LAYER'] | Types['HOTSPOT'];
position: Point;
size: Size;
connections?: Connection[];
@@ -87,25 +87,27 @@ declare namespace Flow {
w: number;
}
const enum Type {
Document = 'DOCUMENT',
Page = 'PAGE',
Screen = 'SCREEN',
Image = 'IMAGE',
Rectangle = 'RECT',
Ellipse = 'ELLIPSE',
Diamond = 'DIAMOND',
Hotspot = 'HOTSPOT',
Layer = 'LAYER',
interface Types {
DOCUMENT: 'DOCUMENT';
PAGE: 'PAGE';
SCREEN: 'SCREEN';
IMAGE: 'IMAGE';
RECTANGLE: 'RECT';
ELLIPSE: 'ELLIPSE';
DIAMOND: 'DIAMOND';
HOTSPOT: 'HOTSPOT';
LAYER: 'LAYER';
}
type SchemaVersion = 1;
}
type NodeType = 'DOCUMENT' | 'PAGE' | 'SCREEN' | 'IMAGE' | 'RECT' | 'ELLIPSE' | 'DIAMOND' | 'HOTSPOT' | 'LAYER';
interface Node {
id: string;
name: string;
type: Flow.Type;
type: NodeType;
}
interface Shape extends Node {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-const-enum": false
"no-object-literal-type-assertion": false
}
}
-31
View File
@@ -1,31 +0,0 @@
import { ApiBaseOptions } from './ApiBase';
import { Labels } from './Models/Labels';
import { Users } from './Models/Users';
import { Notes } from './Models/Notes';
import { Issues } from './Models/Issues';
import { Projects } from './Models/Projects';
import { Groups } from './Models/Groups';
export interface ApiBaseOptions {
url?: string;
token?: string;
oauth_token?: string;
base_url?: string;
auth?: any;
[key: string]: any;
}
export class ApiBase {
constructor(options: ApiBaseOptions);
readonly client: this;
readonly groups: Groups
readonly projects: Projects
readonly issues: Issues
readonly notes: Notes
readonly users: Users
readonly labels: Labels
options: ApiBaseOptions;
handleOptions(): void;
init(): object;
}
-12
View File
@@ -1,12 +0,0 @@
import { ApiBase } from './ApiBase';
export class ApiBaseHTTP extends ApiBase {
prepare_opts<T>(opts: T): T;
fn_wrapper<T extends Function>(fn: T): T;
get(path: string, fn?: Function): any;
get(path: string, query?: object, fn?: Function): any;
delete(path: string, fn?: Function): any;
post(path: string, data?: object, fn?: Function): any;
put(path: string, data?: object, fn?: Function): any;
patch(path: string, data?: object, fn?: Function): any;
}
-5
View File
@@ -1,5 +0,0 @@
import { ApiBaseHTTP } from './ApiBaseHTTP';
export class ApiV3 extends ApiBaseHTTP {
}
-17
View File
@@ -1,17 +0,0 @@
export class BaseModel {
load(model: string): object;
get(path: string, fn?: Function): any;
get(path: string, query?: object, fn?: Function): any;
delete(path: string, fn?: Function): any;
post(path: string, data?: object, fn?: Function): any;
put(path: string, data?: object, fn?: Function): any;
patch(path: string, data?: object, fn?: Function): any;
}
export interface DefParams {
page?: number;
per_page?: number;
[key: string]: any;
}
export type TId = number | string;
-27
View File
@@ -1,27 +0,0 @@
import { BaseModel, DefParams } from "../BaseModel";
interface IAccessLevels {
GUEST: number
REPORTER: number
DEVELOPER: number
MASTER: number
OWNER: number
}
export class Groups extends BaseModel {
readonly access_levels: IAccessLevels;
init(): object;
all(fn?: Function): any;
all(params?: DefParams, fn?: Function): any;
show(groupId: number, fn?: Function): any;
listProjects(groupId: number, fn?: Function): any;
listMembers(groupId: number, fn?: Function): any;
addMember(groupId: number, userId: number, accessLevel: IAccessLevels[keyof IAccessLevels], fn?: Function): any;
editMember(groupId: number, userId: number, accessLevel: IAccessLevels[keyof IAccessLevels], fn?: Function): any;
removeMember(groupId: number, userId: number, fn?: Function): any;
create(params?: object, fn?: Function): any;
addProject(groupId: number, projectId: number, fn?: Function): any;
deleteGroup(groupId: number, fn?: Function): any;
search(nameOrPath: string, fn?: Function): any;
}
-6
View File
@@ -1,6 +0,0 @@
import { BaseModel, TId, DefParams } from '../BaseModel';
export class IssueNotes extends BaseModel{
all(projectId: TId, issueId: number, fn?: Function): any
all(projectId: TId, issueId: number, params?: DefParams, fn?: Function): any
}
-12
View File
@@ -1,12 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
export class Issues extends BaseModel {
all(fn?: Function): any;
all(params?: object, fn?: Function): any;
show(projectId: TId, issueId: TId, fn?: Function): any;
create(projectId: TId, params?: object, fn?: Function): any;
edit(projectId: TId, issueId: TId, params?: object, fn?: Function): any;
remove(projectId: TId, issueId: TId, fn?: Function): any;
subscribe(projectId: TId, issueId: TId, params?: object, fn?: Function): any;
unsubscribe(projectId: TId, issueId: TId, fn?: Function): any;
}
-5
View File
@@ -1,5 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
export class Labels extends BaseModel {
create(projectId: TId, params?: object, fn?: Function): any;
}
-5
View File
@@ -1,5 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
export class Notes extends BaseModel {
create(projectId: TId, issueId: number, params?: object, fn?: Function): any;
}
-5
View File
@@ -1,5 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
export class Pipelines extends BaseModel {
all(projectId: TId, fn?: Function): any;
}
-13
View File
@@ -1,13 +0,0 @@
import { BaseModel, TId, DefParams } from '../BaseModel';
interface IShowBuildParam {
projectId: TId;
[key: string]: any;
}
export class ProjectBuilds extends BaseModel {
listBuilds(projectId: TId, fn?: Function): any;
listBuilds(projectId: TId, params?: DefParams, fn?: Function): any;
showBuild(projectId: TId, buildId: string, fn?: Function): any;
triggerBuild(params?: IShowBuildParam, fn?: Function): any;
}
-7
View File
@@ -1,7 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
export class ProjectKeys extends BaseModel {
listKeys(projectId: TId, fn?: Function): any;
getKey(projectId: TId, keyId: number, fn?: Function): any;
addKey(projectId: TId, params?: object, fn?: Function): any;
}
-16
View File
@@ -1,16 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
interface IAddParam {
url: string;
[key: string]: any;
}
type HooksCb = (hooks: any[]) => any;
export class ProjectHooks extends BaseModel {
list(projectId: TId, fn?: HooksCb): any;
show(projectId: TId, hookId: number, fn?: Function): any;
add(projectId: TId, params: IAddParam | string, fn?: Function): any;
update(projectId: TId, hookId: number, url: string, fn?: Function): any;
remove(projectId: TId, hookId: number, fn?: Function): any;
}
-9
View File
@@ -1,9 +0,0 @@
import { IssueNotes } from './IssueNotes';
import { BaseModel, TId, DefParams } from '../BaseModel';
export class ProjectIssues extends BaseModel {
readonly notes: IssueNotes;
list(projectId: TId, fn?: Function): any;
list(projectId: TId, params?: DefParams, fn?: Function): any;
}
-6
View File
@@ -1,6 +0,0 @@
import { BaseModel, TId, DefParams } from '../BaseModel';
export class ProjectLabels extends BaseModel {
all(projectId: TId, fn?: Function): any;
all(projectId: TId, params?: DefParams, fn?: Function): any;
}
-12
View File
@@ -1,12 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
type MenberCb = (menber: any) => any;
type MenbersCb = (menbers: any[]) => any;
export class ProjectMembers extends BaseModel {
list(projectId: TId, fn?: MenbersCb): any;
show(projectId: TId, userId: number, fn?: MenberCb): any;
add(projectId: TId, userId: number, accessLevel: number,fn?: Function): any;
update(projectId: TId, userId: number, accessLevel: number, fn?: Function): any;
remove(projectId: TId, userId: number, fn?: Function): any;
}
-11
View File
@@ -1,11 +0,0 @@
import { BaseModel, TId, DefParams } from '../BaseModel';
export class ProjectMergeRequests extends BaseModel {
list(projectId: TId, fn?: Function): any;
list(projectId: TId, params?: DefParams, fn?: Function): any;
show(projectId: TId, mergerequestId: number, fn?: Function): any;
add(projectId: TId, sourceBranch: string, targetBranch: string, assigneeId: number, title: string, fn?: Function): any;
update(projectId: TId, mergerequestId: number, params: object, fn?: Function): any;
comment(projectId: TId, mergerequestId: number, note: any, fn?: Function): any;
merge(projectId: TId, mergerequestId: number, params: object, fn?: Function): any;
}
-12
View File
@@ -1,12 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
type MilestonesCb = (milestones: any[]) => any;
type MilestoneCb = (milestones: any) => any;
export class ProjectMilestones extends BaseModel {
list(projectId: TId, fn?: MilestonesCb): any;
all(projectId: TId, fn?: MilestonesCb): any;
show(projectId: TId, milestoneId: number, fn?: MilestoneCb): any;
add(projectId: TId, title: string, description: string, due_date: any, fn?: Function): any;
update(projectId: TId, milestoneId: number, title: string, description: string, due_date: any, state_event: any, fn?: Function): any;
}
-39
View File
@@ -1,39 +0,0 @@
import { BaseModel, TId } from '../BaseModel';
interface ShowFileParams {
file_path: string;
ref?: any;
file_id?: any;
[key: string]: any;
}
interface AddTagParams {
id: TId;
tag_name: string;
ref: string;
message?: string;
release_description?: string;
}
export class ProjectRepository extends BaseModel {
listBranches(projectId: TId, fn?: Function): any;
showBranch(projectId: TId, branchId: string, fn?: Function): any;
protectBranch(projectId: TId, branchId: string, params: object, fn?: Function): any;
unprotectBranch(projectId: TId, branchId: string, fn?: Function): any;
createBranch(params: object, fn?: Function): any;
deleteBranch(projectId: TId, branchId: string, fn?: Function): any;
addTag(params: AddTagParams, fn?: Function): any;
deleteTag(projectId: TId, tagName: string, fn?: Function): any;
showTag(projectId: TId, tagName: string, fn?: Function): any;
listTags(projectId: TId, fn?: Function): any;
listCommits(projectId: TId, fn?: Function): any;
showCommit(projectId: TId, sha: string, fn?: Function): any;
diffCommit(projectId: TId, sha: string, fn?: Function): any;
listTree(projectId: TId, fn?: Function): any;
listTree(projectId: TId, params?: object, fn?: Function): any;
showFile(projectId: TId, fn?: Function): any;
showFile(projectId: TId, params?: ShowFileParams, fn?: Function): any;
createFile(params?: object, fn?: Function): any;
updateFile(params?: object, fn?: Function): any;
compare(params?: object, fn?: Function): any;
}
-9
View File
@@ -1,9 +0,0 @@
import { BaseModel, TId } from './../BaseModel';
type ServiceCb = (service: any) => any;
export class ProjectServices extends BaseModel {
show(projectId: TId, serviceName: string, fn?: ServiceCb): any;
update(projectId: TId, serviceName: string, params: object, fn?: ServiceCb): any;
remove(projectId: TId, serviceName: string, fn?: ServiceCb): any;
}
-55
View File
@@ -1,55 +0,0 @@
import { Runners } from './Runners';
import { Pipelines } from './Pipelines';
import { ProjectBuilds } from './ProjectBuilds';
import { ProjectMergeRequests } from './ProjectMergeRequests';
import { ProjectKeys } from './ProjectDeployKeys';
import { ProjectMilestones } from './ProjectMilestones';
import { ProjectRepository } from './ProjectRepository';
import { ProjectLabels } from './ProjectLabels';
import { ProjectIssues } from './ProjectIssues';
import { ProjectHooks } from './ProjectHooks';
import { ProjectMembers } from './ProjectMembers';
import { BaseModel, DefParams, TId } from '../BaseModel';
import { ProjectServices } from './ProjectServices';
type ProjectsCb = (projects: any[]) => any;
export class Projects extends BaseModel {
readonly members: ProjectMembers;
readonly hooks: ProjectHooks;
readonly issues: ProjectIssues;
readonly labels: ProjectLabels;
readonly repository: ProjectRepository;
readonly milestones: ProjectMilestones;
readonly deploy_keys: ProjectKeys;
readonly merge_requests: ProjectMergeRequests;
readonly services: ProjectServices;
readonly builds: ProjectBuilds;
readonly pipelines: Pipelines;
readonly runners: Runners;
all(fn?: ProjectsCb): any;
all(params?: DefParams, fn?: ProjectsCb): any;
allAdmin(fn?: Function): any;
allAdmin(params?: DefParams, fn?: Function): any;
show(projectId: TId, fn?: Function): any;
create(params: object, fn?: Function): any;
create_for_user(params: object, fn?: Function): any;
edit(projectId: TId, params: object, fn?: Function): any;
addMember(params?: object, fn?: Function): any;
editMember(params?: object, fn?: Function): any;
listMembers(params?: object, fn?: Function): any;
listCommits(params?: object, fn?: Function): any;
listTags(params?: object, fn?: Function): any;
remove(projectId: TId, fn?: Function): any;
fork(params?: object, fn?: Function): any;
share(params?: object, fn?: Function): any;
search(projectName: string, fn?: Function): any;
search(projectName: string, params?: object, fn?: Function): any;
listTriggers(projectId: TId, fn?: Function): any;
showTrigger(projectId: TId, token: string, fn?: Function): any;
createTrigger(params?: object, fn?: Function): any;
removeTrigger(projectId: TId, token: string, fn?: Function): any;
}
-11
View File
@@ -1,11 +0,0 @@
import { BaseModel, DefParams, TId } from '../BaseModel';
export class Runners extends BaseModel {
all(projectId?: TId, fn?: Function): any;
all(projectId?: TId, params?: object, fn?: Function): any;
show(runnerId: number, fn?: Function): any;
update(runnerId: number, attributes: any, fn?: Function): any;
remove(runnerId: number, projectId: any, enable: any, fn?: Function): any;
enable(projectId: TId, runnerId: number, fn?: Function): any;
disable(projectId: TId, runnerId: number, fn?: Function): any;
}
-6
View File
@@ -1,6 +0,0 @@
import { BaseModel, DefParams, TId } from '../BaseModel';
export class UserKeys extends BaseModel {
all(userId?: TId, fn?: Function): any;
addKey(userId: string, title: string, key: any, fn?: Function): any;
}
-17
View File
@@ -1,17 +0,0 @@
import { BaseModel, DefParams, TId } from '../BaseModel';
import { UserKeys } from './UserKeys';
type UsersCb = (users: any[]) => any;
type UserCb = (user: any) => any;
export class Users extends BaseModel {
readonly keys: UserKeys;
all(fn?: UsersCb): any;
all(params?: DefParams, fn?: UsersCb): any;
current(fn?: Function): any;
show(userId: number, fn?: UserCb): any;
create(params?: DefParams, fn?: Function): any;
session(email: string, password: string, fn?: Function): any;
search(emailOrUsername: string, fn?: Function): any;
}
-20
View File
@@ -1,20 +0,0 @@
import * as lib from "gitlab";
const gitlab = lib({
url: 'http://example.com',
token: 'abcdefghij123456'
});
const v3 = new lib.ApiV3({ });
// From README
// Listing users
gitlab.users.all((users) => { });
// Listing projects
gitlab.projects.all((projects) => { });
// From examples/delet-service
gitlab.projects.services.remove("pid", "name", (service) => { });
-17
View File
@@ -1,17 +0,0 @@
// Type definitions for gitlab 1.8
// Project: https://github.com/node-gitlab/node-gitlab#readme
// Definitions by: sam <https://github.com/yanqing6628780>
// AryloYeung <https://github.com/Arylo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { ApiV3 } from "./ApiV3";
import { ApiBaseOptions } from "./ApiBase";
declare namespace Gitlib {
const ApiV3: new(options: ApiBaseOptions) => ApiV3;
}
declare function Gitlib(options: ApiBaseOptions): ApiV3;
export = Gitlib;
-14
View File
@@ -1,14 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
// All are TODOs
"ban-types": false,
"interface-name": false,
"no-consecutive-blank-lines": false,
"no-padding": false,
"one-line": false,
"semicolon": false,
"strict-export-declare-modifiers": false,
"whitespace": false
}
}
+2 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for Google Visualisation Apis
// Project: https://developers.google.com/chart/
// Definitions by: Dan Ludwig <https://github.com/danludwig>, Gregory Moore <https://github.com/gmoore-sjcorg>, Dan Manastireanu <https://github.com/danmana>, Michael Cheng <https://github.com/mlcheng>, Ivan Bisultanov <https://github.com/IvanBisultanov>, Gleb Mazovetskiy <https://github.com/glebm>
// Definitions by: Dan Ludwig <https://github.com/danludwig>, Gregory Moore <https://github.com/gmoore-sjcorg>, Dan Manastireanu <https://github.com/danmana>, Michael Cheng <https://github.com/mlcheng>, Ivan Bisultanov <https://github.com/IvanBisultanov>, Gleb Mazovetskiy <https://github.com/glebm>, Shrujal Shah <https://github.com/shrujalshah28>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace google {
@@ -478,6 +478,7 @@ declare namespace google {
showColorCode?: boolean;
textStyle?: ChartTextStyle;
trigger?: string;
ignoreBounds?: boolean;
}
export interface ChartBoundingBox {
+384 -243
View File
@@ -1,260 +1,401 @@
// Type definitions for intl-tel-input
// Type definitions for intl-tel-input 14.0
// Project: https://github.com/jackocnr/intl-tel-input
// Definitions by: Fidan Hakaj <https://github.com/fdnhkj>, Leonard Thieu <https://github.com/leonard-thieu>
// Definitions by: Fidan Hakaj <https://github.com/fdnhkj>, Leonard Thieu <https://github.com/leonard-thieu>, Márton Molnár <https://github.com/molnarm>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare namespace IntlTelInput {
interface Static {
/**
* Default options for all instances
*/
defaults: Options;
interface Plugin {
/**
* Get all of the plugin's country data - either to re-use elsewhere
* e.g. to populate a country dropdown.
*/
getCountryData(): CountryData[];
/**
* Load the utils.js script (included in the lib directory) to enable
* formatting/validation etc.
*/
loadUtils(path: string, utilsScriptDeferred?: boolean): void;
/**
* Get all of the plugin's country data - either to re-use elsewhere
* e.g. to populate a country dropdown.
*/
getCountryData(): intlTelInputUtils.CountryData[];
/**
* Remove the plugin from the input, and unbind any event listeners.
*/
(method: 'destroy'): void;
/**
* Get the extension from the current number.
* Requires the utilsScript option.
* e.g. if the input value was "(702) 555-5555 ext. 1234", this would
* return "1234".
*/
(method: 'getExtension'): string;
/**
* Get the current number in the given format (defaults to E.164 standard).
* The different formats are available in the enum
* intlTelInputUtils.numberFormat - taken from here.
* Requires the utilsScript option.
* Note that even if nationalMode is enabled, this can still return a full
* international number.
*/
(method: 'getNumber'): string;
/**
* Get the type (fixed-line/mobile/toll-free etc) of the current number.
* Requires the utilsScript option.
* Returns an integer, which you can match against the various options in the
* global enum intlTelInputUtils.numberType.
* Note that in the US there's no way to differentiate between fixed-line and
* mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE.
*/
(method: 'getNumberType'): intlTelInputUtils.numberType;
/**
* Get the country data for the currently selected flag.
*/
(method: 'getSelectedCountryData'): IntlTelInput.CountryData;
/**
* Get more information about a validation error.
* Requires the utilsScript option.
* Returns an integer, which you can match against the various options in the
* global enum intlTelInputUtils.validationError
*/
(method: 'getValidationError'): intlTelInputUtils.validationError;
/**
* Validate the current number. Expects an internationally formatted number
* (unless nationalMode is enabled). If validation fails, you can use
* getValidationError to get more information.
* Requires the utilsScript option.
* Also see getNumberType if you want to make sure the user enters a certain
* type of number e.g. a mobile number.
*/
(method: 'isValidNumber'): boolean;
(method: string): void;
/**
* Change the country selection (e.g. when the user is entering their address).
* @param countryCode country code of the country to be set.
*/
(method: 'setCountry', countryCode: string): void;
/**
* Insert a number, and update the selected flag accordingly.
* Note that by default, if nationalMode is enabled it will try to use
* national formatting.
* @param aNumber number to be set.
*/
(method: 'setNumber', aNumber: string): void;
(method: string, value: string): void;
/**
* Load the utils.js script (included in the lib directory) to enable
* formatting/validation etc.
*/
loadUtils(path: string, utilsScriptDeferred?: boolean): void;
}
/**
* Get the current number in the given format (defaults to E.164 standard).
* The different formats are available in the enum
* intlTelInputUtils.numberFormat - taken from here.
* Requires the utilsScript option.
* Note that even if nationalMode is enabled, this can still return a full
* international number.
* @param numberFormat the format in which the number will be returned.
*/
(method: 'getNumber', numberFormat: intlTelInputUtils.numberFormat): string;
(method: string, numberFormat: intlTelInputUtils.numberFormat): string;
interface Plugin {
/**
* Remove the plugin from the input, and unbind any event listeners.
*/
destroy(): void;
/**
* Get the extension from the current number.
* Requires the utilsScript option.
* e.g. if the input value was "(702) 555-5555 ext. 1234", this would
* return "1234".
*/
getExtension(): string;
/**
* Get the current number in the given format (defaults to E.164 standard).
* The different formats are available in the enum
* intlTelInputUtils.numberFormat - taken from here.
* Requires the utilsScript option.
* Note that even if nationalMode is enabled, this can still return a full
* international number.
* @param numberFormat the format in which the number will be returned.
*/
getNumber(numberFormat?: intlTelInputUtils.numberFormat): string;
/**
* Get the type (fixed-line/mobile/toll-free etc) of the current number.
* Requires the utilsScript option.
* Returns an integer, which you can match against the various options in the
* global enum intlTelInputUtils.numberType.
* Note that in the US there's no way to differentiate between fixed-line and
* mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE.
*/
getNumberType(): intlTelInputUtils.numberType;
/**
* Get the country data for the currently selected flag.
*/
getSelectedCountryData(): intlTelInputUtils.CountryData;
/**
* Get more information about a validation error.
* Requires the utilsScript option.
* Returns an integer, which you can match against the various options in the
* global enum ValidationError
*/
getValidationError(): intlTelInputUtils.validationError;
/**
* Validate the current number. Expects an internationally formatted number
* (unless nationalMode is enabled). If validation fails, you can use
* getValidationError to get more information.
* Requires the utilsScript option.
* Also see getNumberType if you want to make sure the user enters a certain
* type of number e.g. a mobile number.
*/
isValidNumber(): boolean;
/**
* Change the country selection (e.g. when the user is entering their address).
* @param countryCode country code of the country to be set.
*/
setCountry(countryCode: string): void;
/**
* Insert a number, and update the selected flag accordingly.
* Note that by default, if nationalMode is enabled it will try to use
* national formatting.
* @param aNumber number to be set.
*/
setNumber(aNumber: string): void;
/**
* Set the type of the placeholder number
* @param type Placeholder number type to be set
*/
setPlaceholderNumberType(type: intlTelInputUtils.placeholderNumberType): void;
}
interface JQueryPlugin {
/**
* initialise the plugin with optional options.
* @param options options that can be provided during initialization.
*/
(options?: Options): JQueryDeferred<any>;
/**
* Remove the plugin from the input, and unbind any event listeners.
*/
(method: 'destroy'): void;
/**
* Get the extension from the current number.
* Requires the utilsScript option.
* e.g. if the input value was "(702) 555-5555 ext. 1234", this would
* return "1234".
*/
(method: 'getExtension'): string;
/**
* Get the current number in the given format (defaults to E.164 standard).
* The different formats are available in the enum
* intlTelInputUtils.numberFormat - taken from here.
* Requires the utilsScript option.
* Note that even if nationalMode is enabled, this can still return a full
* international number.
* @param numberFormat the format in which the number will be returned.
*/
(method: 'getNumber', numberFormat?: intlTelInputUtils.numberFormat): string;
(method: string, numberFormat: intlTelInputUtils.numberFormat): string;
/**
* Get the type (fixed-line/mobile/toll-free etc) of the current number.
* Requires the utilsScript option.
* Returns an integer, which you can match against the various options in the
* global enum intlTelInputUtils.numberType.
* Note that in the US there's no way to differentiate between fixed-line and
* mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE.
*/
(method: 'getNumberType'): intlTelInputUtils.numberType;
/**
* Get the country data for the currently selected flag.
*/
(method: 'getSelectedCountryData'): intlTelInputUtils.CountryData;
/**
* Get more information about a validation error.
* Requires the utilsScript option.
* Returns an integer, which you can match against the various options in the
* global enum ValidationError
*/
(method: 'getValidationError'): intlTelInputUtils.validationError;
/**
* Validate the current number. Expects an internationally formatted number
* (unless nationalMode is enabled). If validation fails, you can use
* getValidationError to get more information.
* Requires the utilsScript option.
* Also see getNumberType if you want to make sure the user enters a certain
* type of number e.g. a mobile number.
*/
(method: 'isValidNumber'): boolean;
/**
* Change the country selection (e.g. when the user is entering their address).
* @param countryCode country code of the country to be set.
*/
(method: 'setCountry', countryCode: string): void;
/**
* Insert a number, and update the selected flag accordingly.
* Note that by default, if nationalMode is enabled it will try to use
* national formatting.
* @param aNumber number to be set.
*/
(method: 'setNumber', aNumber: string): void;
/**
* Set the type of the placeholder number
* @param type Placeholder number type to be set
*/
(method: 'setPlaceholderNumberType', type: intlTelInputUtils.placeholderNumberType): void;
}
interface Options {
/**
* Whether or not to allow the dropdown. If disabled, there is no dropdown
* arrow, and the selected flag is not clickable. Also we display the
* selected flag on the right instead because it is just a marker of state.
* Default = true
*/
allowDropdown?: boolean;
/**
* If there is just a dial code in the input: remove it on blur or submit,
* and re-add it on focus. This is to prevent just a dial code getting
* submitted with the form. Requires nationalMode to be set to false.
* Default = true
*/
autoHideDialCode?: boolean;
/**
* Set the input's placeholder to an example number for the selected country, and update it if the country changes.
* You can specify the number type using the placeholderNumberType option.
* By default it is set to "polite", which means it will only set the placeholder if the input doesn't already have one.
* You can also set it to "aggressive", which will replace any existing placeholder, or "off".
* Requires the utilsScript option.
* Default = "polite"
*/
autoPlaceholder?: "off" | "polite" | "aggressive";
/**
* Change the placeholder generated by autoPlaceholder. Must return a string.
* Default = null
*/
customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: intlTelInputUtils.CountryData) => string;
/**
* Expects a node e.g. document.body. Instead of putting the country dropdown next to the input,
* append it to the specified node, and it will then be positioned absolutely next to the input using JavaScript.
* This is useful when the input is inside a container with overflow: hidden.
* Note that the absolute positioning can be broken by scrolling, so it will automatically close on the window scroll event.
* Default = null
*/
dropdownContainer?: Node;
/**
* In the dropdown, display all countries except the ones you specify here.
* Default = null
*/
excludeCountries?: string[];
/**
* Format the input value (according to the nationalMode option) during initialisation, and on setNumber.
* Requires the utilsScript option.
* Default = true
*/
formatOnDisplay?: boolean;
/**
* When setting initialCountry to "auto", you must use this option to
* specify a custom function that looks up the user's location,
* and then calls the success callback with the relevant country code.
* Also note that when instantiating the plugin, if the Promise object is defined,
* one of those is returned under the promise instance property, so you can
* do something like iti.promise.then(callback) to know when initialisation requests like this have completed.
* Default = null
*/
geoIpLookup?: (callback: (countryCode: string) => void) => void;
/**
* Add a hidden input with the given name (or if your input name contains square brackets then it will give the hidden input the same name,
* replacing the contents of the brackets with the given name). On submit, populate it with the full international number (using getNumber).
* This is a quick way for people using non-ajax forms to get the full international number, even when nationalMode is enabled.
* Note: requires the input to be inside a form element, as this feature works by listening for the submit event on the closest form element.
* Also note that since this uses getNumber internally, it expects a valid number, and so should only be used after validation.
* Default = ""
*/
hiddenInput?: string;
/**
* Set the initial country selection by specifying it's country code.
* You can also set it to "auto", which will lookup the user's country based
* on their IP address (requires the geoIpLookup option).
* Note that the "auto" option will not update the country selection if the
* input already contains a number. If you leave initialCountry blank,
* it will default to the first country in the list.
*/
initialCountry?: string;
/**
* Allows to translate the countries by its given iso code e.g.: { 'de': 'Deutschland' }
* Default = {}
*/
localizedCountries?: object;
/**
* Allow users to enter national numbers (and not have to think about
* international dial codes). Formatting, validation and placeholders still
* work. Then you can use getNumber to extract a full international number.
* This option now defaults to true, and it is recommended that you leave it
* that way as it provides a better experience for the user.
* Default = true
*/
nationalMode?: boolean;
/**
* In the dropdown, display only the countries you specify.
* Default = undefined
*/
onlyCountries?: string[];
/**
* Specify one of the keys from the global enum intlTelInputUtils.numberType
* e.g. "FIXED_LINE" to set the number type to use for the placeholder.
* Default = MOBILE
*/
placeholderNumberType?: intlTelInputUtils.placeholderNumberType;
/**
* Specify the countries to appear at the top of the list.
* Default = ["us", "gb"]
*/
preferredCountries?: string[];
/**
* Display the country dial code next to the selected flag so it's not part
* of the typed number. Note that this will disable nationalMode because
* technically we are dealing with international numbers, but with the
* dial code separated.
* Default = false
*/
separateDialCode?: boolean;
/**
* Enable formatting/validation etc. by specifying the URL of the included utils.js script
* (or alternatively just point it to the file on cdnjs.com). The script is fetched when the page has finished loading (on the window load event)
* to prevent blocking (the script is ~215KB). When instantiating the plugin, if the Promise object is defined,
* one of those is returned under the promise instance property, so you can do something like
* iti.promise.then(callback) to know when initialisation requests like this have finished.
* Note that if you're lazy loading the plugin script itself (intlTelInput.js)
* this will not work and you will need to use the loadUtils method instead.
* Example: "build/js/utils.js"
* Default = ""
*/
utilsScript?: string;
}
}
declare namespace intlTelInputUtils {
interface CountryData {
name: string;
iso2: string;
dialCode: string;
}
enum numberFormat {
E164 = 0,
INTERNATIONAL = 1,
NATIONAL = 2,
RFC3966 = 3
}
enum numberType {
FIXED_LINE = 0,
MOBILE = 1,
FIXED_LINE_OR_MOBILE = 2,
TOLL_FREE = 3,
PREMIUM_RATE = 4,
SHARED_COST = 5,
VOIP = 6,
PERSONAL_NUMBER = 7,
PAGER = 8,
UAN = 9,
VOICEMAIL = 10,
UNKNOWN = -1
}
enum validationError {
IS_POSSIBLE = 0,
INVALID_COUNTRY_CODE = 1,
TOO_SHORT = 2,
TOO_LONG = 3,
NOT_A_NUMBER = 4
}
type placeholderNumberType =
| "FIXED_LINE_OR_MOBILE"
| "FIXED_LINE"
| "MOBILE"
| "PAGER"
| "PERSONAL_NUMBER"
| "PREMIUM_RATE"
| "SHARED_COST"
| "TOLL_FREE"
| "UAN"
| "UNKNOWN"
| "VOICEMAIL"
| "VOIP";
}
interface Window {
intlTelInputGlobals: IntlTelInput.Static;
/**
* initialise the plugin with optional options.
* @param options options that can be provided during initialization.
*/
(options?: IntlTelInput.Options): JQueryDeferred<any>;
}
interface Options {
/**
* Whether or not to allow the dropdown. If disabled, there is no dropdown
* arrow, and the selected flag is not clickable. Also we display the
* selected flag on the right instead because it is just a marker of state.
*/
allowDropdown?: boolean;
/**
* If there is just a dial code in the input: remove it on blur or submit,
* and re-add it on focus. This is to prevent just a dial code getting
* submitted with the form. Requires nationalMode to be set to false.
*/
autoHideDialCode?: boolean;
/**
* Set the input's placeholder to an example number for the selected country.
* You can specify the number type using the numberType option.
* If there is already a placeholder attribute set on the input then that
* will take precedence. Requires the utilsScript option.
*/
autoPlaceholder?: boolean;
/**
* Change the placeholder generated by autoPlaceholder. Must return a string.
*/
customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string;
/**
* Specify the container for the country dropdown (use a jQuery selector
* e.g. "body"). This is useful when the input is within a scrolling element,
* or an element with overflow: hidden. Wherever you put the dropdown it
* will automatically close on the window scroll event to prevent positioning
* issues. If you want it to close when a different element is scrolled
* (such as the input's parent), simply listen for the that scroll event,
* and trigger $(window).scroll() e.g.
*/
dropdownContainer?: string;
/**
* Don't display the countries you specify.
*/
excludeCountries?: Array<string>;
/**
* Format the input value during initialisation.
*/
formatOnInit?: boolean;
/**
* When setting initialCountry to "auto", you must use this option to
* specify a custom function that looks up the user's location. Also note
* that when instantiating the plugin, we now return a deferred object, so
* you can use .done(callback) to know when initialisation requests like
* this have completed.
* Note that the callback must still be called in the event of an error.
*/
geoIpLookup?: (callback: (countryCode: string) => void) => void;
/**
* Set the initial country selection by specifying it's country code.
* You can also set it to "auto", which will lookup the user's country based
* on their IP address (requires the geoIpLookup option).
* Note that the "auto" option will not update the country selection if the
* input already contains a number. If you leave initialCountry blank,
* it will default to the first country in the list.
*/
initialCountry?: string;
/**
* Allow users to enter national numbers (and not have to think about
* international dial codes). Formatting, validation and placeholders still
* work. Then you can use getNumber to extract a full international number.
* This option now defaults to true, and it is recommended that you leave it
* that way as it provides a better experience for the user.
*/
nationalMode?: boolean;
/**
* Display only the countries you specify.
*/
onlyCountries?: Array<string>;
/**
* Specify one of the keys from the global enum intlTelInputUtils.numberType
* e.g. "FIXED_LINE" to set the number type to use for the placeholder.
*/
placeholderNumberType?:
| "FIXED_LINE_OR_MOBILE"
| "FIXED_LINE"
| "MOBILE"
| "PAGER"
| "PERSONAL_NUMBER"
| "PREMIUM_RATE"
| "SHARED_COST"
| "TOLL_FREE"
| "UAN"
| "UNKNOWN"
| "VOICEMAIL"
| "VOIP";
/**
* Specify the countries to appear at the top of the list.
*/
preferredCountries?: Array<string>;
/**
* Display the country dial code next to the selected flag so it's not part
* of the typed number. Note that this will disable nationalMode because
* technically we are dealing with international numbers, but with the
* dial code separated.
*/
separateDialCode?: boolean;
/**
* Enable formatting/validation etc. by specifying the path to the included
* utils.js script, which is fetched only when the page has finished loading
* (on window.load) to prevent blocking. When instantiating the plugin,
* we return a deferred object, so you can use .done(callback) to know when
* initialisation requests like this have finished. Note that if you're
* lazy loading the plugin script itself (intlTelInput.js) this will not
* work and you will need to use the loadUtils method instead.
*/
utilsScript?: string;
}
interface CountryData {
name: string;
iso2: string;
dialCode: string;
}
}
declare namespace intlTelInputUtils {
const enum numberFormat {
E164 = 0,
INTERNATIONAL = 1,
NATIONAL = 2,
RFC3966 = 3
}
const enum numberType {
FIXED_LINE = 0,
MOBILE = 1,
FIXED_LINE_OR_MOBILE = 2,
TOLL_FREE = 3,
PREMIUM_RATE = 4,
SHARED_COST = 5,
VOIP = 6,
PERSONAL_NUMBER = 7,
PAGER = 8,
UAN = 9,
VOICEMAIL = 10,
UNKNOWN = -1
}
const enum validationError {
IS_POSSIBLE = 0,
INVALID_COUNTRY_CODE = 1,
TOO_SHORT = 2,
TOO_LONG = 3,
NOT_A_NUMBER = 4
}
intlTelInput(node: Element, options?: IntlTelInput.Options): IntlTelInput.Plugin;
}
interface JQuery {
intlTelInput: IntlTelInput.Plugin;
intlTelInput: IntlTelInput.JQueryPlugin;
}
+135 -35
View File
@@ -1,70 +1,170 @@
/// <reference types="jquery" />
// Normal version
const input = document.querySelector("#phone");
window.intlTelInput(input);
window.intlTelInput(input, {
customPlaceholder(selectedCountryPlaceholder, selectedCountryData) {
return 'e.g. ' + selectedCountryPlaceholder;
}
});
window.intlTelInput(input, {
placeholderNumberType: "MOBILE",
});
window.intlTelInput(input, {
geoIpLookup(callback) {
const countryCode = 'XY';
callback(countryCode);
}
});
window.intlTelInput(input).destroy();
const extension = window.intlTelInput(input).getExtension();
const intlNumber = window.intlTelInput(input).getNumber();
const ntlNumber = window.intlTelInput(input).getNumber(intlTelInputUtils.numberFormat.NATIONAL);
const numberType = window.intlTelInput(input).getNumberType();
if (numberType === intlTelInputUtils.numberType.MOBILE) { }
const selectedCountryData = window.intlTelInput(input).getSelectedCountryData();
const error = window.intlTelInput(input).getValidationError();
if (error === intlTelInputUtils.validationError.TOO_SHORT) { }
const isValid = window.intlTelInput(input).isValidNumber();
window.intlTelInput(input).setCountry('gb');
window.intlTelInput(input).setNumber('+447733123456');
window.intlTelInput(input).setPlaceholderNumberType("FIXED_LINE");
const countryData = window.intlTelInputGlobals.getCountryData();
const country = countryData[0];
const dialCode = country.dialCode;
const iso2 = country.iso2;
const countryName = country.name;
window.intlTelInputGlobals.loadUtils('build/js/utils.js');
window.intlTelInput(input, {
utilsScript: '../../build/js/utils.js'
});
window.intlTelInput(input, {
initialCountry: 'auto',
geoIpLookup: (callback) => {
const countryCode = 'XY';
callback(countryCode);
},
utilsScript: '../../build/js/utils.js'
});
window.intlTelInput(input, {
nationalMode: true,
utilsScript: '../../build/js/utils.js'
});
window.intlTelInput(input, {
onlyCountries: ['al'],
utilsScript: '../../build/js/utils.js'
});
window.intlTelInput(input, {
allowDropdown: false,
autoHideDialCode: false,
autoPlaceholder: "aggressive",
dropdownContainer: document.body,
excludeCountries: ["us", "uk"],
formatOnDisplay: false,
hiddenInput: "hidden-input",
localizedCountries: { de: "Deutschland" },
preferredCountries: ["us", "gb"],
separateDialCode: false
});
// jQuery-wrapped version
$('#phone').intlTelInput();
$('#phone').intlTelInput({
customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) {
return 'e.g. ' + selectedCountryPlaceholder;
}
customPlaceholder: (selectedCountryPlaceholder, selectedCountryData) => {
return 'e.g. ' + selectedCountryPlaceholder;
}
});
$('#phone').intlTelInput({
placeholderNumberType: "MOBILE",
placeholderNumberType: "MOBILE",
});
$('#phone').intlTelInput({
geoIpLookup: function(callback) {
$.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) {
let countryCode = (resp && resp.country) ? <string> resp.country : '';
callback(countryCode);
});
}
geoIpLookup: (callback) => {
const countryCode = 'XY';
callback(countryCode);
}
});
$('#phone').intlTelInput('destroy');
let extension = $('#phone').intlTelInput('getExtension');
const jqueryExtension = $('#phone').intlTelInput('getExtension');
let intlNumber = $('#phone').intlTelInput('getNumber');
let ntlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL);
const jqueryIntlNumber = $('#phone').intlTelInput('getNumber');
const jqueryNtlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL);
let numberType = $('#phone').intlTelInput('getNumberType');
if (numberType === intlTelInputUtils.numberType.MOBILE) {}
const jqueryNumberType = $('#phone').intlTelInput('getNumberType');
if (numberType === intlTelInputUtils.numberType.MOBILE) { }
let selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData');
const jquerySelectedCountryData = $('#phone').intlTelInput('getSelectedCountryData');
let error = $('#phone').intlTelInput('getValidationError');
if (error === intlTelInputUtils.validationError.TOO_SHORT) {}
const jqueryError = $('#phone').intlTelInput('getValidationError');
if (error === intlTelInputUtils.validationError.TOO_SHORT) { }
let isValid = $('#phone').intlTelInput('isValidNumber');
const jqueryIsValid = $('#phone').intlTelInput('isValidNumber');
$('#phone').intlTelInput('setCountry', 'gb');
$('#phone').intlTelInput('setNumber', '+447733123456');
let countryData = $.fn.intlTelInput.getCountryData();
$.fn.intlTelInput.loadUtils('build/js/utils.js');
$('#phone').intlTelInput('setPlaceholderNumberType', "FIXED_LINE");
$('#phone').intlTelInput({
utilsScript: '../../build/js/utils.js'
utilsScript: '../../build/js/utils.js'
});
$('#phone').intlTelInput({
initialCountry: 'auto',
geoIpLookup: function(callback) {
$.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) {
let countryCode = (resp && resp.country) ? resp.country : '';
callback(countryCode);
});
},
utilsScript: '../../build/js/utils.js'
initialCountry: 'auto',
geoIpLookup: (callback) => {
const countryCode = 'XY';
callback(countryCode);
},
utilsScript: '../../build/js/utils.js'
});
$('#phone').intlTelInput({
nationalMode: true,
utilsScript: '../../build/js/utils.js'
nationalMode: true,
utilsScript: '../../build/js/utils.js'
});
$('#phone').intlTelInput({
onlyCountries: ['al'],
utilsScript: '../../build/js/utils.js'
onlyCountries: ['al'],
utilsScript: '../../build/js/utils.js'
});
$('#phone').intlTelInput({
allowDropdown: false,
autoHideDialCode: false,
autoPlaceholder: "aggressive",
dropdownContainer: document.body,
excludeCountries: ["us", "uk"],
formatOnDisplay: false,
hiddenInput: "hidden-input",
localizedCountries: { de: "Deutschland" },
preferredCountries: ["us", "gb"],
separateDialCode: false
});
+1 -1
View File
@@ -21,4 +21,4 @@
"index.d.ts",
"intl-tel-input-tests.ts"
]
}
}
+1 -75
View File
@@ -1,80 +1,6 @@
{
"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-const-enum": 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
"unified-signatures": false
}
}
+260
View File
@@ -0,0 +1,260 @@
// Type definitions for intl-tel-input 13.0
// Project: https://github.com/jackocnr/intl-tel-input
// Definitions by: Fidan Hakaj <https://github.com/fdnhkj>, Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare namespace IntlTelInput {
interface Plugin {
/**
* Get all of the plugin's country data - either to re-use elsewhere
* e.g. to populate a country dropdown.
*/
getCountryData(): CountryData[];
/**
* Load the utils.js script (included in the lib directory) to enable
* formatting/validation etc.
*/
loadUtils(path: string, utilsScriptDeferred?: boolean): void;
/**
* Remove the plugin from the input, and unbind any event listeners.
*/
(method: 'destroy'): void;
/**
* Get the extension from the current number.
* Requires the utilsScript option.
* e.g. if the input value was "(702) 555-5555 ext. 1234", this would
* return "1234".
*/
(method: 'getExtension'): string;
/**
* Get the current number in the given format (defaults to E.164 standard).
* The different formats are available in the enum
* intlTelInputUtils.numberFormat - taken from here.
* Requires the utilsScript option.
* Note that even if nationalMode is enabled, this can still return a full
* international number.
*/
(method: 'getNumber'): string;
/**
* Get the type (fixed-line/mobile/toll-free etc) of the current number.
* Requires the utilsScript option.
* Returns an integer, which you can match against the various options in the
* global enum intlTelInputUtils.numberType.
* Note that in the US there's no way to differentiate between fixed-line and
* mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE.
*/
(method: 'getNumberType'): intlTelInputUtils.numberType;
/**
* Get the country data for the currently selected flag.
*/
(method: 'getSelectedCountryData'): IntlTelInput.CountryData;
/**
* Get more information about a validation error.
* Requires the utilsScript option.
* Returns an integer, which you can match against the various options in the
* global enum intlTelInputUtils.validationError
*/
(method: 'getValidationError'): intlTelInputUtils.validationError;
/**
* Validate the current number. Expects an internationally formatted number
* (unless nationalMode is enabled). If validation fails, you can use
* getValidationError to get more information.
* Requires the utilsScript option.
* Also see getNumberType if you want to make sure the user enters a certain
* type of number e.g. a mobile number.
*/
(method: 'isValidNumber'): boolean;
(method: string): void;
/**
* Change the country selection (e.g. when the user is entering their address).
* @param countryCode country code of the country to be set.
*/
(method: 'setCountry', countryCode: string): void;
/**
* Insert a number, and update the selected flag accordingly.
* Note that by default, if nationalMode is enabled it will try to use
* national formatting.
* @param aNumber number to be set.
*/
(method: 'setNumber', aNumber: string): void;
(method: string, value: string): void;
/**
* Get the current number in the given format (defaults to E.164 standard).
* The different formats are available in the enum
* intlTelInputUtils.numberFormat - taken from here.
* Requires the utilsScript option.
* Note that even if nationalMode is enabled, this can still return a full
* international number.
* @param numberFormat the format in which the number will be returned.
*/
(method: 'getNumber', numberFormat: intlTelInputUtils.numberFormat): string;
(method: string, numberFormat: intlTelInputUtils.numberFormat): string;
/**
* initialise the plugin with optional options.
* @param options options that can be provided during initialization.
*/
(options?: IntlTelInput.Options): JQueryDeferred<any>;
}
interface Options {
/**
* Whether or not to allow the dropdown. If disabled, there is no dropdown
* arrow, and the selected flag is not clickable. Also we display the
* selected flag on the right instead because it is just a marker of state.
*/
allowDropdown?: boolean;
/**
* If there is just a dial code in the input: remove it on blur or submit,
* and re-add it on focus. This is to prevent just a dial code getting
* submitted with the form. Requires nationalMode to be set to false.
*/
autoHideDialCode?: boolean;
/**
* Set the input's placeholder to an example number for the selected country.
* You can specify the number type using the numberType option.
* If there is already a placeholder attribute set on the input then that
* will take precedence. Requires the utilsScript option.
*/
autoPlaceholder?: boolean;
/**
* Change the placeholder generated by autoPlaceholder. Must return a string.
*/
customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string;
/**
* Specify the container for the country dropdown (use a jQuery selector
* e.g. "body"). This is useful when the input is within a scrolling element,
* or an element with overflow: hidden. Wherever you put the dropdown it
* will automatically close on the window scroll event to prevent positioning
* issues. If you want it to close when a different element is scrolled
* (such as the input's parent), simply listen for the that scroll event,
* and trigger $(window).scroll() e.g.
*/
dropdownContainer?: string;
/**
* Don't display the countries you specify.
*/
excludeCountries?: Array<string>;
/**
* Format the input value during initialisation.
*/
formatOnInit?: boolean;
/**
* When setting initialCountry to "auto", you must use this option to
* specify a custom function that looks up the user's location. Also note
* that when instantiating the plugin, we now return a deferred object, so
* you can use .done(callback) to know when initialisation requests like
* this have completed.
* Note that the callback must still be called in the event of an error.
*/
geoIpLookup?: (callback: (countryCode: string) => void) => void;
/**
* Set the initial country selection by specifying it's country code.
* You can also set it to "auto", which will lookup the user's country based
* on their IP address (requires the geoIpLookup option).
* Note that the "auto" option will not update the country selection if the
* input already contains a number. If you leave initialCountry blank,
* it will default to the first country in the list.
*/
initialCountry?: string;
/**
* Allow users to enter national numbers (and not have to think about
* international dial codes). Formatting, validation and placeholders still
* work. Then you can use getNumber to extract a full international number.
* This option now defaults to true, and it is recommended that you leave it
* that way as it provides a better experience for the user.
*/
nationalMode?: boolean;
/**
* Display only the countries you specify.
*/
onlyCountries?: Array<string>;
/**
* Specify one of the keys from the global enum intlTelInputUtils.numberType
* e.g. "FIXED_LINE" to set the number type to use for the placeholder.
*/
placeholderNumberType?:
| "FIXED_LINE_OR_MOBILE"
| "FIXED_LINE"
| "MOBILE"
| "PAGER"
| "PERSONAL_NUMBER"
| "PREMIUM_RATE"
| "SHARED_COST"
| "TOLL_FREE"
| "UAN"
| "UNKNOWN"
| "VOICEMAIL"
| "VOIP";
/**
* Specify the countries to appear at the top of the list.
*/
preferredCountries?: Array<string>;
/**
* Display the country dial code next to the selected flag so it's not part
* of the typed number. Note that this will disable nationalMode because
* technically we are dealing with international numbers, but with the
* dial code separated.
*/
separateDialCode?: boolean;
/**
* Enable formatting/validation etc. by specifying the path to the included
* utils.js script, which is fetched only when the page has finished loading
* (on window.load) to prevent blocking. When instantiating the plugin,
* we return a deferred object, so you can use .done(callback) to know when
* initialisation requests like this have finished. Note that if you're
* lazy loading the plugin script itself (intlTelInput.js) this will not
* work and you will need to use the loadUtils method instead.
*/
utilsScript?: string;
}
interface CountryData {
name: string;
iso2: string;
dialCode: string;
}
}
declare namespace intlTelInputUtils {
const enum numberFormat {
E164 = 0,
INTERNATIONAL = 1,
NATIONAL = 2,
RFC3966 = 3
}
const enum numberType {
FIXED_LINE = 0,
MOBILE = 1,
FIXED_LINE_OR_MOBILE = 2,
TOLL_FREE = 3,
PREMIUM_RATE = 4,
SHARED_COST = 5,
VOIP = 6,
PERSONAL_NUMBER = 7,
PAGER = 8,
UAN = 9,
VOICEMAIL = 10,
UNKNOWN = -1
}
const enum validationError {
IS_POSSIBLE = 0,
INVALID_COUNTRY_CODE = 1,
TOO_SHORT = 2,
TOO_LONG = 3,
NOT_A_NUMBER = 4
}
}
interface JQuery {
intlTelInput: IntlTelInput.Plugin;
}
@@ -0,0 +1,70 @@
$('#phone').intlTelInput();
$('#phone').intlTelInput({
customPlaceholder: function (selectedCountryPlaceholder, selectedCountryData) {
return 'e.g. ' + selectedCountryPlaceholder;
}
});
$('#phone').intlTelInput({
placeholderNumberType: "MOBILE",
});
$('#phone').intlTelInput({
geoIpLookup: function (callback) {
$.get('http://ipinfo.io', function () { }, 'jsonp').always(function (resp) {
let countryCode = (resp && resp.country) ? <string>resp.country : '';
callback(countryCode);
});
}
});
$('#phone').intlTelInput('destroy');
let extension = $('#phone').intlTelInput('getExtension');
let intlNumber = $('#phone').intlTelInput('getNumber');
let ntlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL);
let numberType = $('#phone').intlTelInput('getNumberType');
if (numberType === intlTelInputUtils.numberType.MOBILE) { }
let selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData');
let error = $('#phone').intlTelInput('getValidationError');
if (error === intlTelInputUtils.validationError.TOO_SHORT) { }
let isValid = $('#phone').intlTelInput('isValidNumber');
$('#phone').intlTelInput('setCountry', 'gb');
$('#phone').intlTelInput('setNumber', '+447733123456');
let countryData = $.fn.intlTelInput.getCountryData();
$.fn.intlTelInput.loadUtils('build/js/utils.js');
$('#phone').intlTelInput({
utilsScript: '../../build/js/utils.js'
});
$('#phone').intlTelInput({
initialCountry: 'auto',
geoIpLookup: function (callback) {
$.get('http://ipinfo.io', function () { }, 'jsonp').always(function (resp) {
let countryCode = (resp && resp.country) ? resp.country : '';
callback(countryCode);
});
},
utilsScript: '../../build/js/utils.js'
});
$('#phone').intlTelInput({
nationalMode: true,
utilsScript: '../../build/js/utils.js'
});
$('#phone').intlTelInput({
onlyCountries: ['al'],
utilsScript: '../../build/js/utils.js'
});
+27
View File
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"intl-tel-input": [ "intl-tel-input/v13" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"intl-tel-input-tests.ts"
]
}
+80
View File
@@ -0,0 +1,80 @@
{
"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-const-enum": 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
}
}
+17 -20
View File
@@ -1,31 +1,28 @@
// Type definitions for karma-fixture 0.2.7
// Type definitions for karma-fixture 0.2
// Project: https://github.com/billtrik/karma-fixture
// Definitions by: Ezekiel Victor <https://github.com/evictor>
// Afshawn Lotfi <https://github.com/afshawnlotfi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace fixture {
export var el: HTMLElement;
export var json: any[];
let el: HTMLElement;
let json: any[];
export function load(...files: string[]): any;
export function load(file1: string, append?: boolean): any;
export function load(file1: string, file2: string, append?: boolean): any;
export function load(file1: string, file2: string, file3: string, append?: boolean): any;
export function load(file1: string, file2: string, file3: string, file4: string, append?: boolean): any;
export function load(file1: string, file2: string, file3: string, file4: string, file5: string, append?: boolean): any;
function load(...files: string[]): any;
function load(file1: string, append?: boolean): any;
function load(file1: string, file2: string, append?: boolean): any;
function load(file1: string, file2: string, file3: string, append?: boolean): any;
function load(file1: string, file2: string, file3: string, file4: string, append?: boolean): any;
function load(file1: string, file2: string, file3: string, file4: string, file5: string, append?: boolean): any;
export function set(...htmlStrs: string[]): HTMLElement|HTMLElement[];
export function set(htmlStr1: string, append?: boolean): HTMLElement|HTMLElement[];
export function set(htmlStr1: string, htmlStr2: string, append?: boolean): HTMLElement|HTMLElement[];
export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, append?: boolean): HTMLElement|HTMLElement[];
export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, append?: boolean): HTMLElement|HTMLElement[];
export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, htmlStr5: string, append?: boolean): HTMLElement|HTMLElement[];
function set(...htmlStrs: string[]): HTMLElement|HTMLElement[];
function set(htmlStr1: string, append?: boolean): HTMLElement|HTMLElement[];
function set(htmlStr1: string, htmlStr2: string, append?: boolean): HTMLElement|HTMLElement[];
function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, append?: boolean): HTMLElement|HTMLElement[];
function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, append?: boolean): HTMLElement|HTMLElement[];
function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, htmlStr5: string, append?: boolean): HTMLElement|HTMLElement[];
export function cleanup(): void;
function cleanup(): void;
export function setBase(fixtureBasePath: string): void;
function setBase(fixtureBasePath: string): void;
}
export = fixture;
export as namespace fixture;
@@ -1,4 +1,3 @@
fixture.setBase('fixtures/base/path');
fixture.load('test1.html', 'test1.json', false);
fixture.load('test1.html', 'test2.html', 'test1.json');
+1 -77
View File
@@ -1,79 +1,3 @@
{
"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
}
"extends": "dtslint/dt.json"
}
+5
View File
@@ -47,6 +47,11 @@ declare namespace bodyParser {
*/
jsonLimit?: string;
/**
* limit of the text body. Default is 1mb.
*/
textLimit?: string;
/**
* when set to true, JSON parser will only accept arrays and objects. Default is true
*/
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for koa-ratelimit-lru 1.0
// Project: https://github.com/Dreamacro/koa-ratelimit-lru
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { Middleware } from 'koa';
declare namespace rateLimit {
interface Options {
readonly duration?: number;
readonly max?: number;
readonly prefix?: string;
readonly store?: any; // lru-cache ?
readonly rate?: number;
readonly id?: string;
readonly headers?: {
readonly remaining?: string;
readonly reset?: string;
readonly total?: string;
};
readonly errorMessage?: string;
}
}
declare function rateLimit(options?: rateLimit.Options): Middleware;
export = rateLimit;
@@ -0,0 +1,12 @@
import Koa = require('koa');
import rateLimit = require('koa-ratelimit-lru');
const app = new Koa();
app.use(rateLimit({}));
app.use(async context => {
context.body = "Hello";
});
app.listen(2000);
+23
View File
@@ -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-ratelimit-lru-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+4
View File
@@ -659,6 +659,10 @@ declare namespace Application {
* Default error handling.
*/
onerror(err: Error): void;
/**
* Custom properties.
*/
[key: string]: any;
}
interface Request extends BaseRequest {
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/malijs/mali-compose
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
import { Context } from "mali";
+8
View File
@@ -0,0 +1,8 @@
{
"private": true,
"dependencies": {
"grpc": "^1.16.1",
"mali": "^0.10.2",
"protobufjs": "^6.8.8"
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/malijs/onerror
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
import { Context } from "mali";
+8
View File
@@ -0,0 +1,8 @@
{
"private": true,
"dependencies": {
"grpc": "^1.16.1",
"mali": "^0.10.2",
"protobufjs": "^6.8.8"
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for Mapbox GL JS v0.49.0
// Type definitions for Mapbox GL JS v0.51.0
// Project: https://github.com/mapbox/mapbox-gl-js
// Definitions by: Dominik Bruderer <https://github.com/dobrud>, Patrick Reames <https://github.com/patrickr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -17,7 +17,7 @@ declare namespace mapboxgl {
export function setRTLTextPlugin(pluginURL: string, callback: (error: Error) => void): void;
type LngLatLike = LngLat | { lng: number; lat: number; } | [number, number];
type LngLatLike = LngLat | { lng: number; lat: number; } | { lon: number; lat: number; } | [number, number];
type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number];
type PointLike = Point | [number, number];
type Expression = any[];
+1
View File
@@ -417,6 +417,7 @@ function expectType<T>(value: T) { /* let the compiler handle things */ }
expectType<mapboxgl.LngLatLike>(new mapboxgl.LngLat(0, 0));
expectType<mapboxgl.LngLatLike>([0, 0]);
expectType<mapboxgl.LngLatLike>({ lng: 0, lat: 0 });
expectType<mapboxgl.LngLatLike>({ lon: 0, lat: 0 });
/*
* LngLat
+46 -33
View File
@@ -1,6 +1,8 @@
// Type definitions for nuka-carousel 4.3
// Type definitions for nuka-carousel 4.4
// Project: https://github.com/FormidableLabs/nuka-carousel
// Definitions by: Roman Charugin <https://github.com/Romic>, Alex Smith <https://github.com/altaudio>
// Definitions by: Roman Charugin <https://github.com/Romic>
// Alex Smith <https://github.com/altaudio>
// matt-sungwook <https://github.com/matt-sungwook>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -17,38 +19,23 @@ export type CarouselSlidesToScrollProp = number | 'auto';
export type CarouselSlideWidthProp = string | number;
export interface CarouselSlideRenderControlProps {
/**
* Space between slides, as an integer, but reflected as px
*/
cellSpacing: number;
/**
* Current slide index
*/
currentSlide: number;
/**
* Total amount of slides
*/
slideCount: number;
/**
* Current frame width (px)
*/
frameWidth: number;
/**
* Current slide width (px)
* Go to X slide method
* @param index Slide's index to go
*/
slideWidth: number;
/**
* Slides to scroll at once
*/
slidesToScroll: number;
/**
* Space between slides, as an integer, but reflected as px
*/
cellSpacing: number;
/**
* Slides to show at once
*/
slidesToShow: number;
/**
* Infinite mode enabled
*/
wrapAround: boolean;
goToSlide: (index: number) => void;
/**
* Go to the next slide method
*/
@@ -58,10 +45,25 @@ export interface CarouselSlideRenderControlProps {
*/
previousSlide: () => void;
/**
* Go to X slide method
* @param index Slide's index to go
* Total amount of slides
*/
goToSlide: (index: number) => void;
slideCount: number;
/**
* Slides to scroll at once
*/
slidesToScroll: number;
/**
* Slides to show at once
*/
slidesToShow: number;
/**
* Current slide width (px)
*/
slideWidth: number;
/**
* Infinite mode enabled
*/
wrapAround: boolean;
}
export type CarouselRenderControl = (props: CarouselSlideRenderControlProps) => JSX.Element;
@@ -101,6 +103,11 @@ export interface CarouselProps {
* Additional className
*/
className?: string;
/**
* When set to true, disable keyboard controls
* @default false
*/
disableKeyboardControls?: boolean;
/**
* Enable mouse swipe/dragging
*/
@@ -144,6 +151,11 @@ export interface CarouselProps {
* Window onResize callback
*/
onResize?: () => void;
/**
* Pause autoPlay when mouse is over carousel
* @default true
*/
pauseOnHover?: boolean;
/**
* Function for rendering top left control
*/
@@ -238,6 +250,10 @@ export interface CarouselState {
* Is dragging enabled
*/
dragging: boolean;
/**
* Easing function name
*/
easing: string;
/**
* Current frame width
*/
@@ -245,7 +261,10 @@ export interface CarouselState {
/**
* Current left value
*/
isWrappingAround: boolean;
left: number;
pauseOnHover: boolean;
resetWrapAroundPosition: boolean;
/**
* Total amount of slides
*/
@@ -262,14 +281,8 @@ export interface CarouselState {
* Current top value
*/
top: number;
/**
* Easing function name
*/
easing: string;
/**
* Is infinite mode enabled
*/
isWrappingAround: boolean;
wrapToIndex: boolean;
resetWrapAroundPosition: boolean;
}
+36 -29
View File
@@ -24,35 +24,6 @@
* When running within the OpenFin Runtime your web applications have access to the "fin" namespace and all the modules within the API
* without the need to include additional source files. You can treat the "fin" namespace as you would the "window", "navigator" or "documennt" objects.
*/
import { Identity } from './_v2/identity';
import { ApplicationInfo as LaunchInfo, ShortCutConfig, TrayInfo } from './_v2/api/application/application';
import { ApplicationOption } from './_v2/api/application/applicationOption';
import { ExternalApplicationInfo } from './_v2/api/external-application/external-application';
import { ApplicationInfo } from './_v2/api/system/application';
import { ClearCacheOption } from './_v2/api/system/clearCacheOption';
import { CookieInfo, CookieOption } from './_v2/api/system/cookie';
import { AppAssetInfo, AppAssetRequest, RuntimeDownloadOptions, RuntimeDownloadProgress } from './_v2/api/system/download-asset';
import { DownloadPreloadInfo, DownloadPreloadOption } from './_v2/api/system/download-preload';
import { EntityInfo } from './_v2/api/system/entity';
import { ExternalProcessRequestType, ExternalProcessInfo } from './_v2/api/system/external-process';
import { HostSpecs } from './_v2/api/system/host-specs';
import { LogInfo } from './_v2/api/system/log';
import { MonitorInfo } from './_v2/api/system/monitor';
import { PointTopLeft } from './_v2/api/system/point';
import { ProcessInfo } from './_v2/api/system/process';
import { ProxyInfo } from './_v2/api/system/proxy';
import { RegistryInfo } from './_v2/api/system/registry-info';
import { RVMInfo} from './_v2/api/system/rvm';
import { WindowDetail, WindowInfo } from './_v2/api/system/window';
import { AnchorType } from './_v2/api/window/anchor-type';
import Bounds from './_v2/api/window/bounds';
import { Transition, TransitionOptions } from './_v2/api/window/transition';
import { WindowOption } from './_v2/api/window/windowOption';
// tslint:disable-next-line:export-just-namespace
export = fin;
export as namespace fin;
declare namespace fin {
var Application: import('./_v2/api/application/application').default;
var Clipboard: import('./_v2/api/clipboard/clipboard').default;
@@ -64,6 +35,42 @@ declare namespace fin {
var System: import('./_v2/api/system/system').default;
var Window: import('./_v2/api/window/window').default;
// v2 shapes
type Identity = import('./_v2/identity').Identity;
type LaunchInfo = import('./_v2/api/application/application').ApplicationInfo;
type ShortCutConfig = import('./_v2/api/application/application').ShortCutConfig;
type TrayInfo = import('./_v2/api/application/application').TrayInfo;
type ApplicationOption = import('./_v2/api/application/applicationOption').ApplicationOption;
type ExternalApplicationInfo = import('./_v2/api/external-application/external-application').ExternalApplicationInfo;
type ApplicationInfo = import('./_v2/api/system/application').ApplicationInfo;
type ClearCacheOption = import('./_v2/api/system/clearCacheOption').ClearCacheOption;
type CookieInfo = import('./_v2/api/system/cookie').CookieInfo;
type CookieOption = import('./_v2/api/system/cookie').CookieOption;
type AppAssetInfo = import('./_v2/api/system/download-asset').AppAssetInfo;
type AppAssetRequest = import('./_v2/api/system/download-asset').AppAssetRequest;
type RuntimeDownloadOptions = import('./_v2/api/system/download-asset').RuntimeDownloadOptions;
type RuntimeDownloadProgress = import('./_v2/api/system/download-asset').RuntimeDownloadProgress;
type DownloadPreloadInfo = import('./_v2/api/system/download-preload').DownloadPreloadInfo;
type DownloadPreloadOption = import('./_v2/api/system/download-preload').DownloadPreloadOption;
type EntityInfo = import('./_v2/api/system/entity').EntityInfo;
type ExternalProcessRequestType = import('./_v2/api/system/external-process').ExternalProcessRequestType;
type ExternalProcessInfo = import('./_v2/api/system/external-process').ExternalProcessInfo;
type HostSpecs = import('./_v2/api/system/host-specs').HostSpecs;
type LogInfo = import('./_v2/api/system/log').LogInfo;
type MonitorInfo = import('./_v2/api/system/monitor').MonitorInfo;
type PointTopLeft = import('./_v2/api/system/point').PointTopLeft;
type ProcessInfo = import('./_v2/api/system/process').ProcessInfo;
type ProxyInfo = import('./_v2/api/system/proxy').ProxyInfo;
type RegistryInfo = import('./_v2/api/system/registry-info').RegistryInfo;
type RVMInfo = import('./_v2/api/system/rvm').RVMInfo;
type WindowDetail = import('./_v2/api/system/window').WindowDetail;
type WindowInfo = import('./_v2/api/system/window').WindowInfo;
type AnchorType = import('./_v2/api/window/anchor-type').AnchorType;
type Bounds = import('./_v2/api/window/bounds').default;
type Transition = import('./_v2/api/window/transition').Transition;
type TransitionOptions = import('./_v2/api/window/transition').TransitionOptions;
type WindowOption = import('./_v2/api/window/windowOption').WindowOption;
const desktop: OpenFinDesktop;
interface OpenFinDesktop {
+20
View File
@@ -173,6 +173,20 @@ declare namespace P {
* Warning: this option may not be supported by downstream transports.
*/
useOnlyCustomLevels?: boolean;
/**
* As an array, the redact option specifies paths that should have their values redacted from any log output.
*
* Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation.
*
* If an object is supplied, three options can be specified:
*
* paths (String[]): Required. An array of paths
* censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]'
* remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false
*/
redact?: string[] | redactOptions;
/**
* When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`.
*/
@@ -420,4 +434,10 @@ declare namespace P {
(msg: string, ...args: any[]): void;
(obj: object, msg?: string, ...args: any[]): void;
}
interface redactOptions {
paths: string[];
censor?: string;
remove?: boolean;
}
}
+21
View File
@@ -102,3 +102,24 @@ const handler = pino.final(logExtreme, (err: Error, finalLogger: pino.BaseLogger
});
handler(new Error('error'));
const redacted = pino({
redact: ['path']
});
redacted.info({
msg: 'logged with redacted properties',
path: 'Not shown'
});
const anotherRedacted = pino({
redact: {
paths: ['anotherPath'],
censor: 'Not the log you\re looking for'
}
});
anotherRedacted.info({
msg: 'another logged with redacted properties',
anotherPath: 'Not shown'
});
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for @pollyjs/adapter-fetch 1.2
// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter-fetch
// Definitions by: feinoujc <https://github.com/feinoujc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import Adapter from '@pollyjs/adapter';
export default class FetchAdapter extends Adapter {}
@@ -0,0 +1,8 @@
import FetchAdapter from '@pollyjs/adapter-fetch';
import { Polly } from '@pollyjs/core';
Polly.register(FetchAdapter);
new Polly('<recording>', {
adapters: ['xhr', FetchAdapter]
});
@@ -0,0 +1,40 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@pollyjs/core": [
"pollyjs__core"
],
"@pollyjs/adapter": [
"pollyjs__adapter"
],
"@pollyjs/adapter-fetch": [
"pollyjs__adapter-fetch"
],
"@pollyjs/persister": [
"pollyjs__persister"
],
"@pollyjs/utils": [
"pollyjs__utils"
]
}
},
"files": [
"index.d.ts",
"pollyjs__adapter-fetch-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for @pollyjs/adapter 1.2
// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter
// Definitions by: feinoujc <https://github.com/feinoujc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export default class Adapter {
static readonly name: string;
static readonly type: string;
connect(): void;
disconnect(): void;
}
@@ -0,0 +1,4 @@
import Adapter from '@pollyjs/adapter';
Adapter.name;
Adapter.type;
+37
View File
@@ -0,0 +1,37 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@pollyjs/core": [
"pollyjs__core"
],
"@pollyjs/adapter": [
"pollyjs__adapter"
],
"@pollyjs/persister": [
"pollyjs__persister"
],
"@pollyjs/utils": [
"pollyjs__utils"
]
}
},
"files": [
"index.d.ts",
"pollyjs__adapter-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+167
View File
@@ -0,0 +1,167 @@
// Type definitions for @pollyjs/core 1.2
// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/core
// Definitions by: feinoujc <https://github.com/feinoujc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import { MODES } from '@pollyjs/utils';
import Adapter from '@pollyjs/adapter';
import Persister from '@pollyjs/persister';
export const Timing: {
fixed(ms: number): () => Promise<void>;
relative(ratio: number): (ms: number) => Promise<void>;
};
export interface PollyConfig {
mode?: MODES;
adapters?: Array<string | typeof Adapter>;
adapterOptions?: any;
persister?: string | typeof Persister;
persisterOptions?: {
keepUnusedRequests?: boolean;
[key: string]: any;
};
logging?: boolean;
recordIfMissing?: boolean;
recordIfExpired?: boolean;
recordFailedRequests?: boolean;
expiresIn?: string | null;
timing?: ((ms: number) => Promise<void>) | (() => Promise<void>);
matchRequestsBy?: {
method?: boolean;
headers?: any;
body?: boolean;
order?: boolean;
url?: {
protocol?: boolean;
username?: boolean;
password?: boolean;
hostname?: boolean;
port?: boolean;
pathname?: boolean;
query?: boolean;
hash?: boolean;
};
};
}
export interface Request {
getHeader(name: string): string | null;
setHeader(name: string, value: string): Request;
setHeaders(headers: any): Request;
hasHeader(name: string): boolean;
type(contentType: string): Request;
send(body: any): Request;
json(body: any): Request;
jsonBody(): any;
method: string;
url: string;
protocol: string;
hostname: string;
port: string;
pathname: string;
hash: string;
headers: Record<string, string>;
body: any;
query: any;
params: any;
recordingName: string;
responseTime?: number;
}
export interface Response {
statusCode?: number;
headers: Record<string, string>;
body: any;
status(status: number): Response;
getHeader(name: string): string | null;
setHeader(name: string, value: string): Response;
setHeaders(headers: any): Response;
hasHeader(name: string): boolean;
type(contentType: string): Response;
send(body: any): Response;
sendStatus(status: number): Response;
json(body: any): Response;
jsonBody(): any;
end(): Readonly<Response>;
}
export interface Intercept {
abort(): void;
passthrough(): void;
}
export type RequestRouteEvent = 'request';
export type RecordingRouteEvent = 'beforeReplay' | 'beforePersist';
export type ResponseRouteEvent = 'beforeResponse' | 'response';
export type EventListenerResponse = any;
export type RequestEventListener = (req: Request) => EventListenerResponse;
export type RecordingEventListener = (req: Request, recording: any) => EventListenerResponse;
export type ResponseEventListener = (req: Request, res: Response) => EventListenerResponse;
export type InterceptHandler = (
req: Request,
res: Response,
intercept: Intercept
) => EventListenerResponse;
export class RouteHandler {
on(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler;
on(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler;
on(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler;
off(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler;
off(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler;
off(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler;
once(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler;
once(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler;
once(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler;
passthrough(value?: boolean): RouteHandler;
intercept(
fn: (req: Request, res: Response, intercept: Intercept) => EventListenerResponse
): RouteHandler;
recordingName(recordingName: string): RouteHandler;
configure(config: PollyConfig): RouteHandler;
}
export class PollyServer {
timeout: (ms: number) => Promise<void>;
get: (...args: any[]) => RouteHandler;
put: (...args: any[]) => RouteHandler;
post: (...args: any[]) => RouteHandler;
delete: (...args: any[]) => RouteHandler;
patch: (...args: any[]) => RouteHandler;
head: (...args: any[]) => RouteHandler;
options: (...args: any[]) => RouteHandler;
any: (...args: any[]) => RouteHandler;
host(host: string, callback: () => void): void;
namespace(path: string, callback: () => void): void;
}
export type PollyEvent = 'create' | 'stop' | 'register';
export type PollyEventListener = (poll: Polly) => void;
export class Polly {
static register(Factory: typeof Adapter | typeof Persister): void;
static on(event: PollyEvent, listener: PollyEventListener): void;
static off(event: PollyEvent, listener: PollyEventListener): void;
static once(event: PollyEvent, listener: PollyEventListener): void;
constructor(name: string, options?: PollyConfig);
readonly recordingName: string | null;
mode: MODES;
server: PollyServer;
persister: Persister;
pause: () => void;
play: () => void;
replay: () => void;
record: () => void;
stop: () => Promise<void>;
flush: () => Promise<void>;
configure(config: PollyConfig): void;
connectTo(name: string | typeof Adapter): void;
disconnectFrom(name: string | typeof Adapter): void;
disconnect(): void;
}
@@ -0,0 +1,64 @@
import { Polly, Timing } from '@pollyjs/core';
import { MODES } from '@pollyjs/utils';
const polly = new Polly('test recording', {
mode: MODES.PASSTHROUGH,
recordFailedRequests: true,
adapters: ['xhr', 'fetch'],
persister: 'rest',
timing: Timing.relative(3)
});
function log(_: string) {
// no op
}
async function test() {
polly.pause();
polly.play();
const { server } = polly;
server.get('/session').on('request', req => {
req.headers['X-AUTH'] = '<ACCESS_TOKEN>';
req.query.email = 'test@app.com';
});
server.get('/session').on('beforeResponse', (req, res) => {
res.setHeader('X-AUTH', '<ACCESS_TOKEN>');
});
server.get('/session').on('response', (req, res) => {
log(`${req.url} took ${req.responseTime}ms with a status of ${res.statusCode}.`);
});
polly.configure({
adapterOptions: {
fetch: {
context: null
}
}
});
server
.get('/session')
.once('request', req => {
req.headers['X-AUTH'] = '<ACCESS_TOKEN>';
req.query.email = 'test@app.com';
})
.once('request', () => {
/* Do something else */
});
/* Intercept all Google Analytic requests and respond with a 200 */
server.get('/google-analytics/*path').intercept((req, res, intercept) => {
if (req.pathname === 'test') {
intercept.abort();
} else {
res.sendStatus(200);
}
});
/* Pass-through all GET requests to /coverage */
server.get('/coverage')
.configure({ expiresIn: '5d' })
.passthrough();
await polly.flush();
}
+37
View File
@@ -0,0 +1,37 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@pollyjs/core": [
"pollyjs__core"
],
"@pollyjs/utils": [
"pollyjs__utils"
],
"@pollyjs/persister": [
"pollyjs__persister"
],
"@pollyjs/adapter": [
"pollyjs__adapter"
]
}
},
"files": [
"index.d.ts",
"pollyjs__core-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for @pollyjs/persister-fs 1.2
// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/persister-fs
// Definitions by: feinoujc <https://github.com/feinoujc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import Persister from '@pollyjs/persister';
export default class FSPersister extends Persister {}

Some files were not shown because too many files have changed in this diff Show More