From b24d2ab7d9003eff940302e77edec81a2375c117 Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Thu, 2 Feb 2017 21:14:23 +0100 Subject: [PATCH 001/150] rename language to culture in numbro --- numbro/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numbro/index.d.ts b/numbro/index.d.ts index ccb0892a0d..55234aad81 100644 --- a/numbro/index.d.ts +++ b/numbro/index.d.ts @@ -24,7 +24,7 @@ interface Numbro { (value?: any): Numbro; version: string; isNumbro: boolean; - language(key: string, values?: NumbroLanguage): Numbro; + culture(key: string, values?: NumbroLanguage): Numbro; zeroFormat(format: string): string; clone(): Numbro; format(inputString?: string): string; From d09124c0dadba0706409036d1b2948ee5d08496f Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Sun, 5 Feb 2017 20:34:10 +0100 Subject: [PATCH 002/150] remove numbro and add it to notNeededPackages.json --- notNeededPackages.json | 6 ++++++ numbro/index.d.ts | 49 ------------------------------------------ numbro/numbro-tests.ts | 43 ------------------------------------ numbro/tsconfig.json | 22 ------------------- 4 files changed, 6 insertions(+), 114 deletions(-) delete mode 100644 numbro/index.d.ts delete mode 100644 numbro/numbro-tests.ts delete mode 100644 numbro/tsconfig.json diff --git a/notNeededPackages.json b/notNeededPackages.json index e671ef4523..ef4e4f7f85 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -5,6 +5,12 @@ "typingsPackageName": "moment", "sourceRepoURL": "https://github.com/moment/moment", "asOfVersion": "2.13.0" + }, + { + "libraryName": "Numbro", + "typingsPackageName": "numbro", + "sourceRepoURL": "https://github.com/foretagsplatsen/numbro/", + "asOfVersion": "1.9.3" }, { "libraryName": "ng-table", diff --git a/numbro/index.d.ts b/numbro/index.d.ts deleted file mode 100644 index 55234aad81..0000000000 --- a/numbro/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Type definitions for Numbro.js -// Project: https://github.com/foretagsplatsen/numbro -// Definitions by: Vincent Bortone -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface NumbroLanguage { - delimiters: { - thousands: string; - decimal: string; - }; - abbreviations: { - thousand: string; - million: string; - billion: string; - trillion: string; - }; - ordinal(num: number): string; - currency: { - symbol: string; - }; -} - -interface Numbro { - (value?: any): Numbro; - version: string; - isNumbro: boolean; - culture(key: string, values?: NumbroLanguage): Numbro; - zeroFormat(format: string): string; - clone(): Numbro; - format(inputString?: string): string; - formatCurrency(inputString?: string): string; - unformat(inputString: string): number; - value(): number; - valueOf(): number; - set (value: any): Numbro; - add(value: any): Numbro; - subtract(value: any): Numbro; - multiply(value: any): Numbro; - divide(value: any): Numbro; - difference(value: any): number; -} - -declare var numbro: Numbro; - -declare module "numbro" { - - export = numbro; - -} diff --git a/numbro/numbro-tests.ts b/numbro/numbro-tests.ts deleted file mode 100644 index 5b5b762353..0000000000 --- a/numbro/numbro-tests.ts +++ /dev/null @@ -1,43 +0,0 @@ - - -var valueFormat: string = numbro(1000).format('0,0'); -// '1,000' - -var valueUnformat: number = numbro().unformat('($10,000.00)'); -// '-10000' - -var value3: Numbro = numbro(1000); -var added: Numbro = value3.add(10); -// 1010 - -var value4: Numbro = numbro(1000); -var formatValue4a: string = value4.format('0,0'); -// '1,000' -var formatValue4b: number = value4.value(); -// 1000 - -var value5: Numbro = numbro(); -value5.set(1000); -var value5Num: number = value5.value(); -// 1000 - -var value6: Numbro = numbro(1000); -var value: number = 100; -var difference = value6.difference(value); -// 900 - -var value7: Numbro = numbro(0); -numbro.zeroFormat('N/A'); -var zeroString: string = value7.format('0.0'); -// 'N/A' - -var a: Numbro = numbro(1000); -var b: Numbro = numbro(a); -var c: Numbro = a.clone(); - -var aVal: number = a.set(2000).value(); -// 2000 -var bVal: number = b.value(); -// 1000 -var cVal: number = c.add(10).value(); -// 1010 diff --git a/numbro/tsconfig.json b/numbro/tsconfig.json deleted file mode 100644 index 4a55ffe0ab..0000000000 --- a/numbro/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "numbro-tests.ts" - ] -} \ No newline at end of file From ec4b986bc8641599b223a79efaebafe196aeb2e8 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 14 Feb 2017 01:49:54 +0100 Subject: [PATCH 003/150] enzyme: return any as state for shallow() and mount() --- enzyme/enzyme-tests.tsx | 14 ++++++++++++++ enzyme/index.d.ts | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx index 82a8dc9822..c7323766f7 100644 --- a/enzyme/enzyme-tests.tsx +++ b/enzyme/enzyme-tests.tsx @@ -37,6 +37,13 @@ namespace ShallowWrapperTest { elementWrapper: ShallowWrapper, {}>, statelessWrapper: ShallowWrapper; + function test_props_state_inferring() { + let wrapper: ShallowWrapper; + wrapper = shallow(); + wrapper.state().stateProperty; + wrapper.props().stringProp.toUpperCase(); + } + function test_shallow_options() { shallow(, { context: { @@ -337,6 +344,13 @@ namespace ReactWrapperTest { elementWrapper: ReactWrapper, {}>, statelessWrapper: ReactWrapper; + function test_prop_state_inferring() { + let wrapper: ReactWrapper; + wrapper = mount(); + wrapper.state().stateProperty; + wrapper.props().stringProp.toUpperCase(); + } + function test_unmount() { reactWrapper = reactWrapper.unmount(); } diff --git a/enzyme/index.d.ts b/enzyme/index.d.ts index 66c86d1166..184b20ec57 100644 --- a/enzyme/index.d.ts +++ b/enzyme/index.d.ts @@ -541,14 +541,14 @@ export interface MountRendererProps { * @param node * @param [options] */ -export function shallow(node: ReactElement

, options?: ShallowRendererProps): ShallowWrapper; +export function shallow(node: ReactElement

, options?: ShallowRendererProps): ShallowWrapper; /** * Mounts and renders a react component into the document and provides a testing wrapper around it. * @param node * @param [options] */ -export function mount(node: ReactElement

, options?: MountRendererProps): ReactWrapper; +export function mount(node: ReactElement

, options?: MountRendererProps): ReactWrapper; /** * Render react components to static HTML and analyze the resulting HTML structure. From 7a0e3cf5362f8f546f20d96574a66bb53a2473a5 Mon Sep 17 00:00:00 2001 From: Gilbert Date: Thu, 16 Feb 2017 11:13:03 +0100 Subject: [PATCH 004/150] updated jasmine-expect matchers + assymetric matchers. --- jasmine-expect/index.d.ts | 221 ++++++++++++++++++++++++-------------- 1 file changed, 141 insertions(+), 80 deletions(-) diff --git a/jasmine-expect/index.d.ts b/jasmine-expect/index.d.ts index c2ee7e0ee5..f8dbc54f56 100644 --- a/jasmine-expect/index.d.ts +++ b/jasmine-expect/index.d.ts @@ -1,93 +1,154 @@ -// Type definitions for jasmine-expect 2.0 +// Type definitions for jasmine-expect 3.6.0 // Project: https://github.com/JamieMason/Jasmine-Matchers -// Definitions by: UserPixel +// Definitions by: GeneralCss // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 /// declare namespace jasmine { - interface Matchers { - // These functions are written in the order defined in the src directory of jasmine-matchers - // The type system is used smartly whenever it can provide value (by looking at the code of every matcher) - toBeAfter(otherDate: Date): boolean; // - toBeArray(): boolean; // - toBeArrayOfBooleans(): boolean; // - toBeArrayOfNumbers(): boolean; - toBeArrayOfObjects(): boolean; - toBeArrayOfSize(size: number): boolean; - toBeArrayOfStrings(): boolean; - toBeBefore(otherDate: Date): boolean; // - toBeBoolean(): boolean; - toBeCalculable(): boolean; - toBeDate(): boolean; - toBeEmptyArray(): boolean; - toBeEmptyObject(): boolean; - toBeEmptyString(): boolean; - toBeEvenNumber(): boolean; - toBeFalse(): boolean; - toBeFunction(): boolean; - toBeHtmlString(): boolean; - toBeIso8601(): boolean; - toBeJsonString(): boolean; - toBeLongerThan(other: string): boolean; - toBeNonEmptyArray(): boolean; - toBeNonEmptyObject(): boolean; - toBeNonEmptyString(): boolean; - toBeNumber(): boolean; - toBeObject(): boolean; - toBeOddNumber(): boolean; - toBeSameLengthAs(other: string): boolean; - toBeShorterThan(other: string): boolean; - toBeString(): boolean; - toBeTrue(): boolean; - toBeWhitespace(): boolean; - toBeWholeNumber(): boolean; - toBeWithinRange(floor: number, ceiling: number): boolean; + interface Matchers { + // toBe + toBeArray(): boolean; + toBeArrayOfBooleans(): boolean; + toBeArrayOfNumbers(): boolean; + toBeArrayOfObjects(): boolean; + toBeArrayOfSize(): boolean; + toBeArrayOfStrings(): boolean; + toBeEmptyArray(): boolean; + toBeNonEmptyArray(): boolean; - toEndWith(subString: string): boolean; + // Booleans + toBeBoolean(): boolean; + toBeFalse(): boolean; + toBeTrue(): boolean; - toHaveArray(key: string): boolean; - toHaveArrayOfBooleans(key: string): boolean; - toHaveArrayOfNumbers(key: string): boolean; - toHaveArrayOfObjects(key: string): boolean; - toHaveArrayOfSize(key: string, size?: number): boolean; - toHaveArrayOfStrings(key: string): boolean; - toHaveBoolean(key: string): boolean; - toHaveCalculable(key: string): boolean; - toHaveDate(key: string): boolean; - toHaveDateAfter(key: string, otherDate: Date): boolean; - toHaveDateBefore(key: string, otherDate: Date): boolean; - toHaveEmptyArray(key: string): boolean; - toHaveEmptyObject(key: string): boolean; - toHaveEmptyString(key: string): boolean; - toHaveEvenNumber(key: string): boolean; - toHaveFalse(key: string): boolean; - toHaveHtmlString(key: string): boolean; - toHaveIso8601(key: string): boolean; - toHaveJsonString(key: string): boolean; - toHaveMember(key: string): boolean; - toHaveMethod(key: string): boolean; - toHaveNonEmptyArray(key: string): boolean; - toHaveNonEmptyObject(key: string): boolean; - toHaveNonEmptyString(key: string): boolean; - toHaveNumber(key: string): boolean; - toHaveNumberWithinRange(key: string, floor: number, ceiling: number): boolean; - toHaveObject(key: string): boolean; - toHaveOddNumber(key: string): boolean; - toHaveString(key: string): boolean; - toHaveStringLongerThan(key: string, other: string): boolean; - toHaveStringSameLengthAs(key: string, other: string): boolean; - toHaveStringShorterThan(key: string, other: string): boolean; - toHaveTrue(key: string): boolean; - toHaveWhitespaceString(key: string): boolean; - toHaveWholeNumber(key: string): boolean; + // Dates + toBeAfter(date: Date): boolean + toBeBefore(date: Date): boolean + toBeDate(): boolean; + toBeValidDate(): boolean; - toImplement(api: {}): boolean; + // Functions + toBeFunction(): boolean; + toThrowAnyError(): boolean; + toThrowErrorOfType(constructorName: string): boolean - toStartWith(subString: string): boolean; + // Numbers + toBeCalculable(): boolean; + toBeEvenNumber(): boolean; + toBeGreaterThanOrEqualTo(number: number): boolean; + toBeLessThanOrEqualTo(number: number): boolean; + toBeNear(number: number, epsilon: number): boolean; + toBeNumber(): boolean; + toBeOddNumber(): boolean + toBeWholeNumber(): boolean; + toBeWithinRange(floor: number, ceiling: number): boolean; - toThrowAnyError(): boolean; - toThrowErrorOfType(type: string): boolean; - } + // Strings + toBeEmptyString(): boolean; + toBeHtmlString(): boolean; + toBeIso8601(): boolean; + toBeJsonString(): boolean; + toBeLongerThan(): boolean; + toBeNonEmptyString(): boolean; + toBeSameLengthAs(): boolean; + toBeShorterThan(): boolean; + toBeString(): boolean; + toBeWhitespace(): boolean; + toEndWith(): boolean; + toStartWith(): boolean; + + // Objects + toBeEmptyObject(): boolean; + toBeNonEmptyObject(): boolean; + toBeObject(): boolean; + + // Regular Expression + toBeRegExp(): boolean; + + // Members, Properties, Methods + toHaveArray(memberName: string): boolean; + toHaveArrayOfBooleans(memberName: string): boolean; + toHaveArrayOfNumbers(memberName: string): boolean; + toHaveArrayOfObjects(memberName: string): boolean; + toHaveArrayOfSize(memberName: string, size: number): boolean; + toHaveArrayOfStrings(memberName: string): boolean; + toHaveBoolean(memberName: string): boolean; + toHaveCalculable(memberName: string): boolean; + toHaveDate(memberName: string): boolean; + toHaveDateAfter(memberName: string, date: Date): boolean; + toHaveDateBefore(memberName: string, date: Date): boolean; + toHaveEmptyArray(memberName: string): boolean; + toHaveEmptyObject(memberName: string): boolean; + toHaveEmptyString(memberName: string): boolean; + toHaveEvenNumber(memberName: string): boolean; + toHaveFalse(memberName: string): boolean; + toHaveHtmlString(memberName: string): boolean; + toHaveIso8601(memberName: string): boolean; + toHaveJsonString(memberName: string): boolean; + toHaveMember(memberName: string): boolean; + toHaveMethod(memberName: string): boolean; + toHaveNonEmptyArray(memberName: string): boolean; + toHaveNonEmptyObject(memberName: string): boolean; + toHaveNonEmptyString(memberName: string): boolean; + toHaveNumber(memberName: string): boolean; + toHaveNumberWithinRange(memberName: string, floor: number, ceiling: number): boolean; + toHaveObject(memberName: string): boolean; + toHaveOddNumber(memberName: string): boolean; + toHaveString(memberName: string): boolean; + toHaveStringLongerThan(memberName: string, string: string): boolean; + toHaveStringSameLengthAs(memberName: string, string: string): boolean; + toHaveStringShorterThan(memberName: string, string: string): boolean; + toHaveTrue(memberName: string): boolean; + toHaveUndefined(memberName: string): boolean; + toHaveWhitespaceString(memberName: string): boolean; + toHaveWholeNumber(memberName: string): boolean; + } + + interface AssymetricMatchers { + + // Arrays + arrayOfBooleans(): boolean; + arrayOfNumbers(): boolean; + arrayOfObjects(): boolean; + arrayOfSize(number: number): boolean; + arrayOfStrings(): boolean; + emptyArray(): boolean; + nonEmptyArray(): boolean; + + // Dates + after(date: Date): boolean; + before(date: Date): boolean; + + // Numbers + calculable(): boolean; + evenNumber(): boolean; + greaterThanOrEqualTo(number: number): boolean; + lessThanOrEqualTo(number: number): boolean; + oddNumber(): boolean; + wholeNumber(): boolean; + withinRange(floor: number, ceiling: number): boolean; + + // Strings + endingWith(string: string): boolean; + iso8601(): boolean; + jsonString(): boolean; + longerThan(string: string): boolean; + nonEmptyString(string: string): boolean; + sameLengthAs(string: string): boolean; + shorterThan(string: string): boolean; + startingWith(string: string): boolean; + whitespace(): boolean; + + //Objects + emptyObject(): boolean; + nonEmptyObject(): boolean; + + // Regular expressions + regExp(): boolean; + } } + +declare var any: jasmine.AssymetricMatchers; + From d4f54ea6c1a9d2867081c71254012bc6b0d0b105 Mon Sep 17 00:00:00 2001 From: Gilbert Date: Thu, 16 Feb 2017 11:50:23 +0100 Subject: [PATCH 005/150] fixed failing tests. Did not add any new ones though --- jasmine-expect/index.d.ts | 12 ++++---- jasmine-expect/jasmine-expect-tests.ts | 38 ++------------------------ 2 files changed, 9 insertions(+), 41 deletions(-) diff --git a/jasmine-expect/index.d.ts b/jasmine-expect/index.d.ts index f8dbc54f56..1a37f8fbe7 100644 --- a/jasmine-expect/index.d.ts +++ b/jasmine-expect/index.d.ts @@ -13,7 +13,7 @@ declare namespace jasmine { toBeArrayOfBooleans(): boolean; toBeArrayOfNumbers(): boolean; toBeArrayOfObjects(): boolean; - toBeArrayOfSize(): boolean; + toBeArrayOfSize(size: number): boolean; toBeArrayOfStrings(): boolean; toBeEmptyArray(): boolean; toBeNonEmptyArray(): boolean; @@ -50,14 +50,14 @@ declare namespace jasmine { toBeHtmlString(): boolean; toBeIso8601(): boolean; toBeJsonString(): boolean; - toBeLongerThan(): boolean; + toBeLongerThan(string: string): boolean; toBeNonEmptyString(): boolean; - toBeSameLengthAs(): boolean; - toBeShorterThan(): boolean; + toBeSameLengthAs(string: string): boolean; + toBeShorterThan(string: string): boolean; toBeString(): boolean; toBeWhitespace(): boolean; - toEndWith(): boolean; - toStartWith(): boolean; + toEndWith(string: string): boolean; + toStartWith(string: string): boolean; // Objects toBeEmptyObject(): boolean; diff --git a/jasmine-expect/jasmine-expect-tests.ts b/jasmine-expect/jasmine-expect-tests.ts index 7753cc7381..d01595a171 100644 --- a/jasmine-expect/jasmine-expect-tests.ts +++ b/jasmine-expect/jasmine-expect-tests.ts @@ -873,9 +873,11 @@ describe('toHaveArrayOfSize', function() { describeToHaveArrayX('toHaveArrayOfSize', function() { describe('when number of expected items does not match', function() { it('should deny', function() { - expect({ + var xpToFail = expect; + xpToFail({ memberName: '' }).not.toHaveArrayOfSize('memberName'); + expect({ memberName: ['bar'] }).not.toHaveArrayOfSize('memberName', 0); @@ -1877,40 +1879,6 @@ describe('toHaveWholeNumber', function() { }); }); -describe('toImplement', function() { - describe('when invoked', function() { - describe('when subject IS an Object containing all of the supplied members', function() { - it('should confirm', function() { - expect({ - a: 1, - b: 2 - }).toImplement({ - a: 1, - b: 2 - }); - expect({ - a: 1, - b: 2 - }).toImplement({ - a: 1 - }); - }); - }); - describe('when subject is NOT an Object containing all of the supplied members', function() { - it('should deny', function() { - expect({ - a: 1 - }).not.toImplement({ - c: 3 - }); - expect(null).not.toImplement({ - a: 1 - }); - }); - }); - }); -}); - describe('toStartWith', function() { describe('when invoked', function() { describe('when subject is NOT an undefined or empty string', function() { From 3479affcfe6394800fc3562be7461552c3ed1326 Mon Sep 17 00:00:00 2001 From: Yuya Tanaka Date: Wed, 15 Feb 2017 03:06:14 +0900 Subject: [PATCH 006/150] react: Fix SVGAttributes contains all HTMLAttributes --- react/index.d.ts | 21 +++++++++++++++++++-- react/test/index.ts | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index b2be91bf62..61b282dfc7 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -2203,7 +2203,25 @@ declare namespace React { // - "number | string" // - "string" // - union of string literals - interface SVGAttributes extends HTMLAttributes { + interface SVGAttributes extends DOMAttributes { + // Attributes which also defined in HTMLAttributes + // See comment in SVGDOMPropertyConfig.js + className?: string; + color?: string; + height?: number | string; + id?: string; + lang?: string; + max?: number | string; + media?: string; + method?: string; + min?: number | string; + name?: string; + style?: CSSProperties; + target?: string; + type?: string; + width?: number | string; + + // SVG Specific attributes accentHeight?: number | string; accumulate?: "none" | "sum"; additive?: "replace" | "sum"; @@ -2396,7 +2414,6 @@ declare namespace React { textRendering?: number | string; to?: number | string; transform?: string; - type?: string; u1?: number | string; u2?: number | string; underlinePosition?: number | string; diff --git a/react/test/index.ts b/react/test/index.ts index 4b00e988bf..702f1632c9 100644 --- a/react/test/index.ts +++ b/react/test/index.ts @@ -341,6 +341,9 @@ React.DOM.svg({ xmlns: "http://www.w3.org/2000/svg" }, React.DOM.rect({ + className: 'foobar', + id: 'foo', + color: 'black', x: 22, y: 10, width: 4, From a302f69580ad40511c18a61d5e8bcbdabcf4f16a Mon Sep 17 00:00:00 2001 From: Yuya Tanaka Date: Wed, 15 Feb 2017 04:30:20 +0900 Subject: [PATCH 007/150] react: Add type parameter to SVGProps --- react/index.d.ts | 108 +++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index 61b282dfc7..867e066c7e 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -437,7 +437,7 @@ declare namespace React { interface ChangeTargetHTMLProps extends ChangeTargetHTMLAttributes, ClassAttributes { } - interface SVGProps extends SVGAttributes, ClassAttributes { + interface SVGProps extends SVGAttributes, ClassAttributes { } interface DOMAttributes { @@ -2810,60 +2810,60 @@ declare global { wbr: React.HTMLProps; // SVG - svg: React.SVGProps; + svg: React.SVGProps; - circle: React.SVGProps; - clipPath: React.SVGProps; - defs: React.SVGProps; - desc: React.SVGProps; - ellipse: React.SVGProps; - feBlend: React.SVGProps; - feColorMatrix: React.SVGProps; - feComponentTransfer: React.SVGProps; - feComposite: React.SVGProps; - feConvolveMatrix: React.SVGProps; - feDiffuseLighting: React.SVGProps; - feDisplacementMap: React.SVGProps; - feDistantLight: React.SVGProps; - feFlood: React.SVGProps; - feFuncA: React.SVGProps; - feFuncB: React.SVGProps; - feFuncG: React.SVGProps; - feFuncR: React.SVGProps; - feGaussianBlur: React.SVGProps; - feImage: React.SVGProps; - feMerge: React.SVGProps; - feMergeNode: React.SVGProps; - feMorphology: React.SVGProps; - feOffset: React.SVGProps; - fePointLight: React.SVGProps; - feSpecularLighting: React.SVGProps; - feSpotLight: React.SVGProps; - feTile: React.SVGProps; - feTurbulence: React.SVGProps; - filter: React.SVGProps; - foreignObject: React.SVGProps; - g: React.SVGProps; - image: React.SVGProps; - line: React.SVGProps; - linearGradient: React.SVGProps; - marker: React.SVGProps; - mask: React.SVGProps; - metadata: React.SVGProps; - path: React.SVGProps; - pattern: React.SVGProps; - polygon: React.SVGProps; - polyline: React.SVGProps; - radialGradient: React.SVGProps; - rect: React.SVGProps; - stop: React.SVGProps; - switch: React.SVGProps; - symbol: React.SVGProps; - text: React.SVGProps; - textPath: React.SVGProps; - tspan: React.SVGProps; - use: React.SVGProps; - view: React.SVGProps; + circle: React.SVGProps; + clipPath: React.SVGProps; + defs: React.SVGProps; + desc: React.SVGProps; + ellipse: React.SVGProps; + feBlend: React.SVGProps; + feColorMatrix: React.SVGProps; + feComponentTransfer: React.SVGProps; + feComposite: React.SVGProps; + feConvolveMatrix: React.SVGProps; + feDiffuseLighting: React.SVGProps; + feDisplacementMap: React.SVGProps; + feDistantLight: React.SVGProps; + feFlood: React.SVGProps; + feFuncA: React.SVGProps; + feFuncB: React.SVGProps; + feFuncG: React.SVGProps; + feFuncR: React.SVGProps; + feGaussianBlur: React.SVGProps; + feImage: React.SVGProps; + feMerge: React.SVGProps; + feMergeNode: React.SVGProps; + feMorphology: React.SVGProps; + feOffset: React.SVGProps; + fePointLight: React.SVGProps; + feSpecularLighting: React.SVGProps; + feSpotLight: React.SVGProps; + feTile: React.SVGProps; + feTurbulence: React.SVGProps; + filter: React.SVGProps; + foreignObject: React.SVGProps; + g: React.SVGProps; + image: React.SVGProps; + line: React.SVGProps; + linearGradient: React.SVGProps; + marker: React.SVGProps; + mask: React.SVGProps; + metadata: React.SVGProps; + path: React.SVGProps; + pattern: React.SVGProps; + polygon: React.SVGProps; + polyline: React.SVGProps; + radialGradient: React.SVGProps; + rect: React.SVGProps; + stop: React.SVGProps; + switch: React.SVGProps; + symbol: React.SVGProps; + text: React.SVGProps; + textPath: React.SVGProps; + tspan: React.SVGProps; + use: React.SVGProps; + view: React.SVGProps; } } } From df8b672c7a12c28d0cc05401529de547ec607be9 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Thu, 23 Feb 2017 12:16:04 +0100 Subject: [PATCH 008/150] Use Partial keyword for objectContaining --- jasmine/index.d.ts | 6 +++--- jasmine/jasmine-tests.ts | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index e18361dec4..146ab55ad4 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -49,7 +49,7 @@ declare namespace jasmine { function any(aclass: any): Any; function anything(): Any; function arrayContaining(sample: any[]): ArrayContaining; - function objectContaining(sample: any): ObjectContaining; + function objectContaining(sample: Partial): ObjectContaining; function createSpy(name: string, originalFn?: Function): Spy; function createSpyObj(baseName: string, methodNames: any[]): any; function createSpyObj(baseName: string, methodNames: any[]): T; @@ -82,8 +82,8 @@ declare namespace jasmine { jasmineToString(): string; } - interface ObjectContaining { - new (sample: any): any; + interface ObjectContaining { + new (sample: Partial): T; jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; jasmineToString(): string; diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index 4632eb8b4c..13d80af9db 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -663,7 +663,12 @@ describe("jasmine.any", function () { }); describe("jasmine.objectContaining", function () { - var foo: any; + interface fooType { + a:number; + b:number; + bar:string; + } + var foo: fooType; beforeEach(function () { foo = { @@ -674,11 +679,11 @@ describe("jasmine.objectContaining", function () { }); it("matches objects with the expect key/value pairs", function () { - expect(foo).toEqual(jasmine.objectContaining({ + expect(foo).toEqual(jasmine.objectContaining({ bar: "baz" })); - expect(foo).not.toEqual(jasmine.objectContaining({ - c: 37 + expect(foo).not.toEqual(jasmine.objectContaining({ + a: 37 })); }); From fe7183b55a5d6ee28b005a5816b6641d05b0dd12 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 23 Feb 2017 13:57:11 +0100 Subject: [PATCH 009/150] Re-indent a bit + missing ; + missing spaces --- gapi/index.d.ts | 96 ++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/gapi/index.d.ts b/gapi/index.d.ts index 28d5c990bc..3a4a78ca21 100644 --- a/gapi/index.d.ts +++ b/gapi/index.d.ts @@ -38,7 +38,7 @@ declare namespace gapi { /** * Pragmatically initialize gapi class member. */ - export function load(object: string, fn: any) : any; + export function load(object: string, fn: any): any; } @@ -155,37 +155,37 @@ declare namespace gapi.client { } /** - * Loads the client library interface to a particular API. If a callback is not provided, a promise is returned. - * @param name The name of the API to load. - * @param version The version of the API to load. - * @return promise The promise that get's resolved after the request is finished. - */ - export function load(name: string, version: string): Promise + * Loads the client library interface to a particular API. If a callback is not provided, a promise is returned. + * @param name The name of the API to load. + * @param version The version of the API to load. + * @return promise The promise that get's resolved after the request is finished. + */ + export function load(name: string, version: string): Promise; /** - * Loads the client library interface to a particular API. The new API interface will be in the form gapi.client.api.collection.method. - * @param name The name of the API to load. - * @param version The version of the API to load - * @param callback the function that is called once the API interface is loaded - * @param url optional, the url of your app - if using Google's APIs, don't set it - */ + * Loads the client library interface to a particular API. The new API interface will be in the form gapi.client.api.collection.method. + * @param name The name of the API to load. + * @param version The version of the API to load + * @param callback the function that is called once the API interface is loaded + * @param url optional, the url of your app - if using Google's APIs, don't set it + */ export function load(name: string, version: string, callback: () => any, url?: string): void; /** - * Creates a HTTP request for making RESTful requests. - * An object encapsulating the various arguments for this method. - */ + * Creates a HTTP request for making RESTful requests. + * An object encapsulating the various arguments for this method. + */ export function request(args: RequestOptions): HttpRequest; /** - * Creates an RPC Request directly. The method name and version identify the method to be executed and the RPC params are provided upon RPC creation. - * @param method The method to be executed. - * @param version The version of the API which defines the method to be executed. Defaults to v1 - * @param rpcParams A key-value pair of the params to supply to this RPC - */ + * Creates an RPC Request directly. The method name and version identify the method to be executed and the RPC params are provided upon RPC creation. + * @param method The method to be executed. + * @param version The version of the API which defines the method to be executed. Defaults to v1 + * @param rpcParams A key-value pair of the params to supply to this RPC + */ export function rpcRequest(method: string, version?: string, rpcParams?: any): RpcRequest; /** - * Sets the API key for the application. - * @param apiKey The API key to set - */ + * Sets the API key for the application. + * @param apiKey The API key to set + */ export function setApiKey(apiKey: string): void; /** @@ -210,24 +210,24 @@ declare namespace gapi.client { status: number; statusText: string; } - ) => any):void; - /** + ) => any): void; + /** * HttpRequest supports promises. */ - then(success:(response:{ - result:T; - body:string; + then(success: (response: { + result: T; + body: string; headers?: any[]; status?: number; - statusText?: string - })=>void, - failure:(response:{ - result:T; - body:string; + statusText?: string; + }) => void, + failure: (response: { + result: T; + body: string; headers?: any[]; status?: number; - statusText?: string - })=>void): void; + statusText?: string; + }) => void): void; } /** * Represents an HTTP Batch operation. Individual HTTP requests are added with the add method and the batch is executed using execute. @@ -244,16 +244,16 @@ declare namespace gapi.client { */ id: string; callback: ( - /** - * is the response for this request only. Its format is defined by the API method being called. - */ - individualResponse: any, - /** - * is the raw batch ID-response map as a string. It contains all responses to all requests in the batch. - */ - rawBatchResponse: any - ) => any - }):void; + /** + * is the response for this request only. Its format is defined by the API method being called. + */ + individualResponse: any, + /** + * is the raw batch ID-response map as a string. It contains all responses to all requests in the batch. + */ + rawBatchResponse: any + ) => any + }): void; /** * Executes all requests in the batch. The supplied callback is executed on success or failure. * @param callback The callback to execute when the batch returns. @@ -267,7 +267,7 @@ declare namespace gapi.client { * is the same response, but as an unparsed JSON-string. */ rawBatchResponse: string - ) => any):void; + ) => any): void; } /** @@ -288,7 +288,7 @@ declare namespace gapi.client { * is the same as jsonResp, except it is a raw string that has not been parsed. It is typically used when the response is not JSON. */ rawResp: string - ) => void ):void; + ) => void): void; } } From 318a5c5896c5dbee368d546f904ded23b759d2c6 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 23 Feb 2017 14:01:24 +0100 Subject: [PATCH 010/150] Better gapi.load --- gapi/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gapi/index.d.ts b/gapi/index.d.ts index 3a4a78ca21..84da600e7b 100644 --- a/gapi/index.d.ts +++ b/gapi/index.d.ts @@ -38,7 +38,7 @@ declare namespace gapi { /** * Pragmatically initialize gapi class member. */ - export function load(object: string, fn: any): any; + export function load(apiName: string, callback: () => void): void; } From ea45419314f1dd5be0b5b7c30c495b4203cc098c Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Thu, 23 Feb 2017 16:01:54 +0100 Subject: [PATCH 011/150] add qlik-visualizationextensions as typescript definition Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 2417 +++++++++++++++++ .../qlik-visualizationextensions-tests.ts | 3 + qlik-visualizationextensions/tsconfig.json | 23 + qlik-visualizationextensions/tslint.json | 7 + 4 files changed, 2450 insertions(+) create mode 100644 qlik-visualizationextensions/index.d.ts create mode 100644 qlik-visualizationextensions/qlik-visualizationextensions-tests.ts create mode 100644 qlik-visualizationextensions/tsconfig.json create mode 100644 qlik-visualizationextensions/tslint.json diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts new file mode 100644 index 0000000000..8a9c145969 --- /dev/null +++ b/qlik-visualizationextensions/index.d.ts @@ -0,0 +1,2417 @@ +// Type definitions for qlik-visualizationextensions +// Project: http://help.qlik.com/en-US/sense-developer/3.2/Subsystems/Extensions/Content/extensions-introduction.htm +// Definitions by: Konrad Mattheis +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace BackendAPI { + type StateType = "L" | "S" | "O" | "D" | "A" | "X" | "XS" | "XL"; + type SortIndicatorType = "N" | "A" | "D"; + type DimensionType = "D" | "N" | "T"; + type GroupingType = "N" | "H" | "C"; + type FieldAttributesType = "U" | "A" | "I" | "R" | "F" | "M" | "D" | "T" | "TS" | "IV"; + type PatchType = "Add" | "Remove" | "Replace"; + + interface ICharRange { + /** + * Position of the first search occurrence + * Integer + */ + qCharPos: number; + + /** + * Number of occurrences found + * Integer + */ + qCharCount: number; + } + + interface INxHighlightRanges { + /** + * Ranges of highlighted values + * Array of CharRange + */ + qRanges: ICharRange[]; + } + + interface INxSimpleValue { + /** + * Text related to the attribute expression value. + * This property is optional. No text is returned if the attribute expression value is a numeric. + * String + */ + qText: string; + + /** + * Numeric value of the attribute expression. + * This property is set to NaN (Not a Number) if the attribute expression value is not a numeric. + * Numerical values are not returned as text. + * Double precision floating point + */ + qNum: number; + } + + interface INxAttributeExpressionValues { + /** + * List of attribute expressions values. + * Array of NxSimpleValue + */ + qValues: INxSimpleValue[]; + } + + interface INxSimpleDimValue { + /** + * Text related to the attribute expression value. + * This property is optional. No text is returned if the attribute expression value is a numeric. + * String + */ + qText: string; + + /** + * Element number. + * Integer + */ + qElemNo: number; + } + + interface INxAttributeDimValues { + /** + * List of values. + * Array of NxSimpleDimValue + */ + qValues: INxSimpleDimValue[]; + } + + interface INxCell { + /** + * Some text. + * This parameter is optional. + */ + qText?: string; + + /** + * A value. + * This parameter is optional. + */ + qNum?: number; + + /** + * Rank number of the value, starting from 0. + * If the element number is a negative number, it means that the returned value is not an element number. + * You can get the following negative values: + * # -1: the cell is a Total cell. It shows a total. + * # -2: the cell is collapsed. Applies to pivot tables. + * # -3: the cell belongs to the group Others. + * # -4: the cell is empty. Applies to pivot tables. + */ + qElemNumber: number; + + /** + * State of the value. + * The default state for a measure is L. + * L for Locked + * S for Selected + * O for Optional + * D for Deselected + * A for Alternative + * X for eXcluded + * XS for eXcluded Selected + * XL for eXcluded Locked + */ + qState: StateType; + + /** + * Is set to true, if qText and qNum are empty. + * This parameter is optional. The default value is false. + */ + qIsEmpty: boolean; + + /** + * Is set to true if a total is displayed in the cell. + * This parameter is optional. The default value is false. + * Not applicable to list objects. + */ + qIsTotalCell: boolean; + + /** + * Is set to true if the cell belongs to the group Others. + * Dimension values can be set as Others depending on what has been defined in OtherTotalSpecProp. + * This parameter is optional. The default value is false. + * Not applicable to list objects. + */ + qIsOtherCell: boolean; + + /** + * Frequency of the value. + * This parameter is optional. + */ + qFrequency: string; + + /** + * Search hits. + * The search hits are highlighted. + * This parameter is optional. + */ + qHighlightRanges: INxHighlightRanges; + + /** + * Attribute expression values. + */ + qAttrExps: INxAttributeExpressionValues; + + /** + * Is set to true if the value is Null. + */ + qIsNull: boolean; + + /** + * Attribute dimensions values. + */ + qAttrDims: INxAttributeDimValues; + } + + interface INxPage { + /** + * Position from the left. + * Corresponds to the first column. + */ + qLeft: number; + + /** + * Position from the top. + * Corresponds to the first row. + */ + qTop: number; + + /** + * Number of columns in the page. The indexing of the columns may vary depending on whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). + */ + qWidth: number; + + /** + * Number of rows or elements in the page. The indexing of the rows may vary depending on whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). + */ + qHeight: number; + } + + interface INxAttrDimInfo { + /** + * Cardinality of the attribute expression. + * Integer + */ + qCardinal: number; + + /** + * Number of rows. + * Size + */ + qSize: number; + + /** + * The title for the attribute dimension. + * String + */ + qFallbackTitle: string; + + /** + * The Locked value of the dimension. + * Boolean + */ + qLocked: boolean; + + /** + * Validation error. + * REF(NxValidationError) + */ + //?Type = REF(NxValidationError)? + qError: INxValidationError; + } + + interface INxDimensionInfo { + /** + * Corresponds to the label of the dimension that is selected. + * If the label is not defined then the field name is used. + * String + */ + qFallbackTitle: string; + + /** + * Length of the longest value in the field. + * Integer + */ + qApprMaxGlyphCount: number; + + /** + * Number of distinct field values. + * Integer + */ + qCardinal: number; + + /** + * Is set to true if the field is locked. + * Boolean + */ + qLocked: boolean; + + /** + * Sort indicator. + * This parameter is optional. + * The default value is no sorting. + * One of: + * # N for no sorting + * # A for sorting ascending + * # D for sorting descending + */ + qSortIndicator: SortIndicatorType; + + /** + * Array of dimension labels. + * Contains the labels of all dimensions in a hierarchy group (for example the labels of all dimensions in a drill down group). + * Array of String + */ + qGroupFallbackTitles: string[]; + + /** + * Index of the dimension that is currently in use. + * qGroupPos is set to 0 if there are no hierarchical groups (drill-down groups) or cycle groups. + * Integer + */ + qGroupPos: number; + + /** + * Number of values in a particular state. + * NxStateCounts + */ + qStateCounts: INxStateCounts; + + /** + * Gives information on a field. For example, it can return the type of the field. + * Examples: key, text, ASCII + * Array of String + */ + qTags: string[]; + + /** + * This parameter is optional. + * Gives information on the error. + * Null or NxValidationError + */ + qError: INxValidationError; + + /** + * Binary format of the field. + * One of: + * # D for discrete (String) + * # N for numeric (Double) + * # T for Time (Timestamp) + */ + qDimensionType: DimensionType; + + /** + * If set to true, it inverts the sort criteria in the field. + * Boolean + */ + qReverseSort: boolean; + + /** + * Defines the grouping. + * One of: + * # N for no grouping + * # H for drill-down + * # C for cyclic + */ + qGrouping: GroupingType; + + /** + * If set to true, it means that the field is a semantic. + * Boolean + */ + qIsSemantic: boolean; + + /** + * Format of the field. + * This parameter is optional. + * FieldAttributes + */ + qNumFormat: FieldAttributesType; + + /** + * This parameter is set to true if qNumFormat is set to U (unknown). The engine guesses the type of the field based on the field's definition. + * Boolean + */ + qIsAutoFormat: boolean; + + /** + * Array of field names. + * Array of String + */ + qGroupFieldDefs: string[]; + + /** + * Array of attribute expressions. + * Array of NxAttrExprInfo + */ + qAttrExprInfo: INxAttrExprInfo; + + /** + * Minimum value. + * Double + */ + qMin: number; + + /** + * Maximum value. + * Double + */ + qMax: number; + + /** + * Is continuous axis used. + * Boolean + */ + qContinuousAxes: boolean; + + /** + * Is a cyclic dimension used. + * Boolean + */ + qIsCyclic: boolean; + + /** + * Is derived field is used as a dimension. + * Boolean + */ + qDerivedField: boolean; + + /** + * Array of attribute dimensions. + * Array of NxAttrDimInfo + */ + qAttrDimInfo: INxAttrDimInfo; + } + + interface INxAttrExprInfo { + /** + * Minimum value. + */ + qMin: number; + + /** + * Maximum value. + */ + qMax: number; + + /** + * Is continuous axis used. + */ + qContinuousAxes: boolean; + + /** + * Is a cyclic dimension used. + */ + qIsCyclic: boolean; + + /** + * Corresponds to the label of the dimension that is selected. + */ + qFallbackTitle: string; + } + + interface INxStateCounts { + /** + * Number of values in locked state. + * Integer + */ + qLocked: number; + + /** + * Number of values in selected state. + * Integer + */ + qSelected: number; + + /** + * Number of values in optional state. + * Integer + */ + qOption: number; + + /** + * Number of values in deselected state. + * Integer + */ + qDeselected: number; + + /** + * Number of values in alternative state. + * Integer + */ + qAlternative: number; + + /** + * Number of values in excluded state + * Integer + */ + qExcluded: number; + + /** + * Number of values in selected excluded state. + * Integer + */ + qSelectedExcluded: number; + + /** + * Number of values in locked excluded state. + * Integer + */ + qLockedExcluded: number; + } + + interface INxValidationError { + /** + * Error code. + * This parameter is always displayed in case of error. + * Integer + */ + qErrorCode: number; + + /** + * Context related to the error, from the user app domain. + * It can be the identifier of an object, a field name, a table name. + * This parameter is optional. + * String + */ + qContext: string; + + /** + * Internal information from the server. + * This parameter is optional. + * String + */ + qExtendedMessage: string; + } + + interface IFieldAttributes { + /** + * Type of the field. + * Default is U. + * One of: + * # U for UNKNOWN type. + * # A for ASCII; Numeric fields values contain only standard ASCII characters. + * # I for INTEGER; Numeric fields values are shown as integer numbers. + * # R for REAL; Numeric fields values are shown as real numbers. + * # F for FIX; Numeric fields values are shown as numbers with a fix number of decimals. + * # M for MONEY; Numeric fields values are shown as in the money format. + * # D for DATE; Numeric fields values are shown as dates. + * # T for TIME; Numeric fields values are shown as times. + * # TS TIMESTAMP; Numeric fields values are shown as time stamps. + * # IV for INTERVAL; Numeric fields values are shown as intervals. + */ + qType: FieldAttributesType; + + /** + * Number of decimals. + * Default is 10. + * Integer between 0 and 15. + */ + qnDec: number; + + /** + * Defines whether or not a thousands separator must be used. + * Default is 0. + * One of: 0 for false | 1 for true + */ + qUseThou: boolean; + + /** + * Defines the format pattern that applies to qText. + * Is used in connection to the type of the field (parameter qType). + * For more information, see Struct FieldAttributes. + * Example: YYYY-MM-DD for a date + */ + qFmt: string; + + /** + * Defines the decimal separator. + * Example: . + */ + qDec: string; + + /** + * Defines the thousand separator (if any). + * Is used if qUseThou is set to 1. + * Example: , + */ + qThou: string; + + /** + * Array + */ + qSAFEARRAY: any[]; + } + + interface INxMeasureInfo { + /** + * Corresponds to the label of the measure. If the label is not defined then the measure name is used. + * String + */ + qFallbackTitle: string; + + /** + * Length of the longest value in the field. + * Integer + */ + qApprMaxGlyphCount: number; + + /** + * Number of distinct field values. + * Integer + */ + qCardinal: number; + + /** + * Sort indicator. This parameter is optional. The default value is no sorting. + */ + qSortIndicator: SortIndicatorType; + + /** + * Format of the field. This parameter is optional. + * One of: N for no sorting, A for sorting ascending, D for sorting descending + */ + qNumFormat: IFieldAttributes; + + /** + * This parameter is set to true if qNumFormat is set to U (unknown). The engine guesses the type of the field based on the field's expression. + */ + qIsAutoFormat: boolean; + + /** + * Lowest value in the range. + */ + qMin: number; + + /** + * Highest value in the range. + */ + qMax: number; + + /** + * This parameter is optional. Gives information on the error. + */ + qError: INxValidationError; + + /** + * If set to true, it inverts the sort criteria in the field. + */ + qReverseSort: boolean; + + /** + * List of attribute expressions. + */ + qAttrExprInfo: INxAttrExprInfo[]; + + /** + * List of attribute dimensions. + */ + qAttrDimInfo: INxMeasureInfo[]; + } + + interface IRange { + /** + * Lowest value in the range + * Double + */ + qMin: number; + + /** + * Highest value in the range + * Double + */ + qMax: number; + + /** + * If set to true, the range includes the lowest value in the range of selections (Equals to ). [bn(50500)] + * Example: The range is [1,10]. If qMinInclEq is set to true it means that 1 is included in the range of selections. + */ + qMinInclEq: boolean; + + /** + * If set to true, the range includes the highest value in the range of selections (Equals to ). [bn(50500)] + * Example: The range is [1,10]. If qMinInclEq is set to true it means that 10 is included in the range of selections. + */ + qMaxInclEq: boolean; + } + + interface INxPatch { + /** + * Operation to perform. + * One of: + * # Add + * # Remove + * # Replace + */ + qOp: PatchType; + + /** + * Path to the property to add, remove or replace. + * String + */ + qPath: string; + + /** + * This parameter is not used in a remove operation. + * Corresponds to the value of the property to add or to the new value of the property to update. + * Examples: "false", "2", "\"New title\"" + * String + */ + qValue: string; + } + + interface IBackend { + /** + * Aborts the result of a search in a list object. Clears the existing search and returns the object to the state it was in prior to the search started. + */ + abortSearch(): void; + + /** + * Accepts the result of a search in a list object and the search result is selected in the field. + * @param {boolean} toggleMode - If true, toggle state for selected values + */ + acceptSearch(toggleMode: boolean): void; + + /** + * Updates the properties for this object. + * @param {array} qPatches - Array of patches. Each path contains: + * #qOp: Add/Remove/Replace + * #qPath: Path to property + * #qValue: The new value in string format. Strings need to be surrounded by \". + * @param {boolean} qSoftPatch - Set to True if properties should be soft, that is not persisted. + * @return {Promise} - A promise of a Qlik engine reply. + */ + applyPatches(qPatches: any[], qSoftPatch: boolean): ng.IPromise; + + /** + * Clears unconfirmed selections for this object. + */ + clearSelections(): void; + + /** + * Clears all soft patches that has previously been applied for this object using the applyPatches method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + clearSoftPatches(): ng.IPromise; + + /** + * Collapse the left dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ + collapseLeft(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; + + /** + * Collapse the top dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ + collapseTop(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; + + /** + * Loops through data rows for this object. Only rows that are available client side will be used. + * @param {function} callback - Function to call for each row. + * Parameters are row number and row data as an array of NxCell objects. + * The loop is terminated if the function returns false. + * @return {NxCell[]} - An array of NxCell. + */ + eachDataRow(callback: any): INxCell[]; + + /** + * Expands the left dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ + expandLeft(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; + + /** + * Expands the top dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ + expandTop(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; + + /** + * Geta data from Qlik engine for this object. + * @param {array} qPages - An array of NxPage objects. + * @return {Promise} - A promise of qDataPages. + */ + getData(qPages: INxPage[]): ng.IPromise; + + /** + * Gets a data row for this object. + * @param {number} rownum - The row number. + * @return {NxCell} - A row of NxCell or null if the row is not available client side and need to be fetched with getData method. + */ + getDataRow(rownum: number): INxCell; + + /** + * Gets qDimensionInfo for this object. + * @return {NxDimensionInfo[]} - An array of qDimensionInfo objects. + */ + getDimensionInfos(): INxDimensionInfo[]; + + /** + * Gets qMeasureInfo for this object. + * @return {NxMeasureInfo} - An array of qMeasureInfo objects. + */ + getMeasureInfos(): INxMeasureInfo; + + /** + * Gets pivot data from the Qlik engine for this object. Only works for hypercubes with qMode = P. + * @param {array} qPages - An array of request page objects. + * @return {Promise} - A promise of pivot data pages. + */ + getPivotData(qPages: INxPage[]): ng.IPromise; + + /** + * Get properties for this object. + * @return {Promise} - A promise of object properties. + */ + getProperties(): ng.IPromise; + + /** + * Get reduced data from the Qlik engine for this object. This method is intended for preserving the shape of the data, not for viewing the actual data points. + * @param {array} qPages - An array of request page objects. + * @param {number} qZoomFactor - Zoom factor. + * If set to -1, the Qlik engine decides of the zoom factor. + * If qReductionMode is D1 or S, the zoom factor is 2ⁿ. If the zoom factor is 5, the data are reduced by a factor 32. + * If qReductionMode is C, the zoom factor defines the number of centroids. + * @param {string} qReductionMode - Reduction mode.Can be: + * # N for no data reduction. + * # D1 to reduce a bar chart or line chart. The profile of the chart is reduced whatever the number of dimensions in the chart. + * # S to reduce the resolution of a scatter plot. + * # C to reduce the data of a scatter plot chart. + * # ST to reduce the data of a stacked pivot table. + * @return {Promise} - A promise of reduced data pages. + */ + getReducedData(qPages: INxPage[], qZoomFactor: number, qReductionMode: string): ng.IPromise; + + /** + * Get total number of data rows for this object. + * @return {Number} - A number. + */ + getRowCount(): number; + + /** + * Get stacked data from the Qlik engine for this object. Only works for hypercubes with qMode = S. + * @param {array} qPages - An array of request page objects. + * @param {number} qMaxNbrCells - Maximum number of cells at outer level. + * @return {Promise} - A promise of stack data pages. + */ + getStackedData(qPages: INxPage[], qMaxNbrCells: number): ng.IPromise; + + /** + * Find out if there are unconfirmed selections for this object. + * @return {boolean} - True if there are unconfirmed selections. + */ + hasSelections(): boolean; + + /** + * Save this object. + * @return {Promise} - A promise. In case of success, it returns "undefined". In case of failure it returns the error. + */ + save(): ng.IPromise; + + /** + * Search for a term in a list object. Results in an updated layout, containing only matching records. + * @param {string} term - Term to search for. + */ + search(term: string): void; + + /** + * Select values in this object using ranges. + * @param {array} qRanges - Array of ranges to select. + * @param {boolean} qOrMode - If true only one of the measures needs to be in range. + */ + selectRange(qRanges: IRange[], qOrMode: boolean): void; + + /** + * Select values in this object with a Qlik engine call which triggers a repaint of the object. + * @param {number} qDimNo - Dimension number. 0 = first dimension. + * @param {array} qValues - Array of values (qElemNumber in the matrix from the Qlik engine) to select or deselect. + * @param {boolean} qToggleMode - If true, values in the field are selected in addition to any previously selected items. + * If false, values in the field are selected while previously selected items are deselected. + */ + selectValues(qDimNo: number, qValues: any[], qToggleMode: boolean): void; + + /** + * Set properties for this object. + * @param {object} props - The properties to set. + * @return {Promise} - A promise of a Qlik engine reply. + */ + setProperties(props: any): ng.IPromise; + } +} + +declare namespace RootAPI { + interface IAppConfig { + /** + * Optional Qlik host. + */ + host?: string; + + /** + * Port number. + */ + port: string | number; + + /** + * Optional. Qlik virtual proxy. "/" if no proxy. + */ + prefix?: string; + + /** + * Optional. Use SSL. + */ + isSecure?: boolean; + + /** + * Optional. Open app without loading data. Introduced in version 1.1. + */ + openWithoutData?: boolean; + + /** + * Optional. Unique identity for the session. If omitted, the session will be shared. + */ + identity?: string; + } + + interface IGlobalConfig { + /** + * Qlik Sense host + */ + host: string; + + /** + * Port number + */ + port: string; + + /** + * Qlik Sense virtual proxy. / if no virtual proxy + */ + prefix: string; + + /** + * Use SSL + */ + isSecure: boolean; + + /** + * Unique identity for the session. If omitted, the session will be shared. + */ + identity: string; + } + + interface IRoot { + /** + * Calls the Qlik Sense repository. + * @param {string} path - Path to the Qlik Sense repository. + * Refer to Qlik Sense repository documentation for the available paths. + * @param {string} [method] - Optional. HTTP method. Default is GET. + * @param {string} [body] - Optional. Body of the post. + * @return {Promise} - A promise of a Qlik engine reply. + */ + callRepository(path: string, method?: string, body?: string): ng.IPromise; + + /** currApp + * Gets a reference to the current app. Use the currApp method in an extension to get a reference to the app currently displayed. + * @param {object} [reference] - Optional. Reference to extension object. Introduced in version 1.1. + * @return {IApp} - An App JavaScript object with app methods. + */ + currApp(object?: any): AppAPI.IApp; + + /** + * Gets a list of Qlik Sense apps that you potentially can connect to and registers a callback to receive the data. + * The getAppList method opens a WebSocket, gets the app list, and then closes the WebSocket. + * @param {function} callback - Callback method. + * @param {object} [config] - Optional. Additional configuration parameters: + * Name | Type | Descr | Name + * host | String | Optional. Qlik host. | host + * port | String or integer | Port number. | port + * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. | prefix + * isSecure | Boolean | Optional. Use SSL. | isSecure + * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. | openWithoutData + * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. | identity + */ + getAppList(callback: any, config?: any): void; + + /** + * Gets a list of extensions installed for Qlik Sense. The reply contains all extensions, that is widget libraries, visualization extensions and mashups. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getExtensionList(callback?: any): ng.IPromise; + + /** + * Opens a WebSocekt connection to the Qlik engine for global methods. + * @param {object} [config] - Optional. Parameters: + * Name | Type | Description + * host | String | Qlik Sense host + * port | String | Port number + * prefix | String | Qlik Sense virtual proxy. / if no virtual proxy + * isSecure | Boolean | Use SSL + * identity | String | Unique identity for the session. If omitted, the session will be shared. + * @return {ANY} - A global JavaScript object with global methods. + */ + getGlobal(config: any): any; + + /** Opens a Qlik Sense app. You can open multiple apps. + * Most other methods are defined on the app. Returns: App JavaScript object with app methods. + * @param {string} appId The app id. + * @param {object} [config] Optional. Additional configuration parameters: + * Name | Type | Descr + * host | String | Optional. Qlik host. + * port | String or Integer | Port number. + * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. + * isSecure | Boolean | Optional. Use SSL. + * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. + * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. + * Parameter updated in version 2.2. + * @return {any} - App JavaScript object with app methods. + */ + openApp(appId: string, config?: any): any; + + /** + * Registers an extension for use in this mashup. The extension is not installed on the Qlik Sense server and only available in the session where it is created. + * As long as a JavaScript module is created in the correct format, it can be sent to the registerExtension function. + * @param {string} id - Set the ID of the visualization extension. + * @param {object} impl - Set the extension implementation. + * @param {object} [metadata] - Optional. Extension meta-data, same format as the QEXT file. Default: {"type":"visualization"} + */ + registerExtension(id: string, impl: any, metadata?: any): void; + + /** + * Sends a resize event to all Qlik Sense objects. + * @param {string} [ID] - Object id. Optional: if no ID resize event will be sent to all objects. + */ + resize(ID?: string): void; + + /** + * Sets a specific language for the Qlik Sense session. + * Language should be defined before the app is opened meaning the setLanguage method should be called before the openApp method is called. + * @param {string} lang - Language code. Can be: + * # German: short: de long: de-DE + * # English: short: en long: en-US + * # Spanish: short: es long: es-ES + * # French: short: fr long: fr-FR + * # Italian: short: it long: it-IT + * # Japanese: short: ja long: ja-JP + * # Korean: (introduced in version 3.0) short: ko long: ko-KR + * # Dutch: short: nl long: nl-NL + * # Polish: (introduced in version 3.0) short: pl long: pl-PL + * # Brazilian Portuguese: short: pt long: pt-BR + * # Russian: short: ru long: ru-RU + * # Swedish: short: sv long: sv-SE + * # Turkish: (introduced in version 3.0) short: tr long: tr-TR + * # Simplified Chinese: short: Do not use! long: zh-CN + * # Traditional Chinese: (introduced in version 3.0) short: Do not use! long: zh-TW + */ + setLanguage(lang: string): void; + + /** + * Registers a callback for error handling. Standard Qlik Sense error handling is used if this method is not called. + * @param {function} onError - Error handling function + * @param {function} [onWarning] - Optional. Warning handling function. Introduced in version 2.1. + */ + setOnError(onError: any, onWarning?: any): void; + + /** + * Create a QTable object that wraps data in your extension and provides an object oriented interface. + * @param {object} ext - Extension or angular scope for the extension. + * @param {string} [path] - Optional. Path to the hypercube. Default: qHyperCube + * @return {QTable} - A QTable object that holds data and options for the table. + */ + table(ext: any, path?: string): TableAPI.IQTable; + + navigation: NavigationAPI.INavigation; + } +} + +declare namespace AppAPI { + interface IApp { + /** + * Adds an alternate state in the app. Multiple states within a Qlik Sense app can be created and applied to specific objects within the app. Objects in a given state are not affected by user selection in the other states. + * @param {string} qStateName - Mandatory. Alternate state name. + * @return {Promise} - A promise of a Qlik engine reply. + */ + addAlternateState(qStateName: string): ng.IPromise; + + /** + * Steps back in the list of selections. + * @return {Promise} - A promise of a Qlik engine reply. + */ + back(): ng.IPromise; + + /** + * Clears all selections in all fields of the current Qlik Sense app. + * @param {boolean} [lockedAlso] - Optional. Alternate state name. Default: false Introduced in version 2.1. + * @param {string} [state] - Optional. Alternate state name. Default: $ Introduced in version 2.1. + * @return {Promise} - A promise of a Qlik engine reply. + */ + clearAll(lockedAlso?: boolean, state?: string): ng.IPromise; + + /** + * Closes a Qlik Sense app. Also closes the WebSocket and clears out client side data. + */ + close(): void; + + /** + * Defines a hypercube and registers a callback to receive the data. + * @param {object} qHyperCubeDef - Cube definition. + * @param {function} [callback] - Optional. Callback method. Parameter will contain a qHyperCube. + * @return {Promise} - A promise of an object model. + */ + createCube(qHyperCubeDef: any, callback?: any): ng.IPromise; + + /** + * Creates a generic object and registers a callback to receive the data. The generic object can contain the following: + * # qHyperCubeDef + * # qListObjectDef + * # qStringExpression + * # qValueExpression + * The callback method will be called whenever the selection state changes in a way that affects the generic object. The parameter will be the evaluated version of the definition. + * @param {object} [def] - Optional. Generic object definition + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of an object model. + */ + createGenericObject(def?: any, callback?: any): ng.IPromise; + + /** + * Defines a list of field values and registers a callback to receive the data. + * @param {object} qListObjectDef - List definition. + * @param {function} [callback] - Optional. Callback method. Parameter will contain a qListObject. + * @return {Promise} - A promise of an object model. + */ + createList(qListObjectDef: any, callback?: any): ng.IPromise; + + /** + * Defines a hypercube for a table and is the entry point to the Table API. It creates a table object that wraps the hypercube. + * @param {Array.} dimensions - Dimensions to use. + * Should, for each entry, be a field name or a NxDimension structure. + * @param {Array.} measures - Measures to use. + * Should, for each entry, be an expression or a NxMeasure structure. + * @param {object} [options] - Optional. Options to set. + * @return {QTable} - A table object of type QTable, which is initially empty but that eventually will contain data. The table object will be updated when selection state changes. + */ + createTable(dimensions: string[] | any[], measures: string[] | any[], options?: any): TableAPI.IQTable; + + /** + * Destroys a Qlik Sense session object created with the createGenericObject method or any of createCube, createList or getList methods. + * Calling this method removes the object from the Qlik engine, no more updates are sent to the client and all methods on the object are invalid. + * @param {string} id - Session object id. + * @return {Promise} - A promise of a Qlik engine reply. + */ + destroySessionObject(id: string): ng.IPromise; + + /** + * Reloads the data in a Qlik Sense app. + * @param {string} [qMode] - Optional. Error handling mode: + * # 0 = default mode. + * # 1 = attempt recovery on all errors. + * # 2 = fail on all errors. + * @param {boolean} [qPartial] - Optional. Set to true for partial reload. + * @param {boolean} [qDebug] - Optional. Set to true if debug breakpoints are honored. Execution of the script will be in debug mode. + * @return {Promise} - A promise of a Qlik engine reply. + */ + doReload(qMode?: string, qPartial?: boolean, qDebug?: boolean): ng.IPromise; + + /** + * Saves a Qlik Sense app, including all objects and data in the data model. + * @param {string} [qFileName] - Optional. File name of the file to save. + * @return {Promise} - A promise of a Qlik engine reply. + */ + doSave(qFileName?: string): ng.IPromise; + + /** + * Gets a field reference with methods that can be used to manipulate the field. + * @param {string} [field] - Optional. Name of the field. + * @param {string} [state] - Optional. Alternate state name. Default is $. + * @return {QField} - A QField object with methods and properties that can be used to manipulate the field. + */ + field(field?: string, state?: string): FieldAPI.IQField; + + /** + * Step forward in list of selections. + * @return {Promise} - A promise of a Qlik engine reply. + */ + forward(): ng.IPromise; + + /** + * Gets a layout for this Qlik Sense app and registers a callback to receive the data. Returns the dynamic properties (if any) in addition to the fixed properties. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getAppLayout(callback?: any): ng.IPromise; + + /** + * Gets a list of sheets and visualizations and registers a callback to receive the data. + * @param {string} [field] - Optional. Type of object. One of: + * # sheet + * # masterobject + * Default is sheet. + * @param {function} [callback] - Optional. Callback method. + */ + getAppObjectList(type?: string, callback?: any): void; + + /** + * Gets properties for a generic object, the children of the generic object and the bookmarks and/or embedded snapshots of the generic object. + * @param {string} id - Object id. + * @return {Promise} - A promise of an object model. + */ + getFullPropertyTree(id: string): ng.IPromise; + + /** + * Gets a list of internal Qlik Sense objects and registers a callback to receive the data. + * @param {string} type - Type of object: + * # FieldList + * # MeasureList + * # DimensionList + * # BookmarkList + * # SelectionObject + * # SnapshotList (Introduced in version 1.1) + * # MediaList (Introduced in version 1.1) + * # Sheet (Introduced in version 1.1) + * # MasterObject (Introduced in version 1.1) + * # VariableList (Introduced in version 2.0) + * # story (Introduced in version 2.1) + * @param {function} [callback] - Optional. Registers a callback that is executed every time data is returned. + * @return {Promise} - A promise of an object model. + */ + getList(type: string, callback?: any): ng.IPromise; + + /** + * Retrieves a Qlik Sense object from the Qlik Sense application and inserts it into a HTML element. The object fills the HTML object, so you can size and position the element to determine how large the Qlik Sense object will be. + * If you supply only one parameter, you get the model without displaying the object. + * @param {string} id - Object id or 'CurrentSelections' if used for Selections bar. + * @param {Element | string} [elem] - Optional. HTML element. + * Since version 1.1 it is also possible to define a string of the HTML element id. + * @param {object} [options] - Optional. + * Name | Type | Description + * noInteraction | Boolean | Set to true if you want to disable interaction, including selections, in the visualization. Introduced in version 1.1 and updated in version 3.0. + * noSelections | Boolean | Set to true if you want to disable selections in the visualization. Introduced in version 3.0. + * @return {Promise} - A promise of an object model. + */ + getObject(id: string, elem?: any | string, options?: any): ng.IPromise; + + /** + * Gets properties for a Qlik Sense object. + * @param {string} id - Object id. + * @return {Promise} - A promise of an object model. + */ + getObjectProperties(id: string): ng.IPromise; + + /** + * Inserts a Qlik Sense snapshot into a HTML element. The snapshot fills the HTML object so you can size and position the element to determine how large the Qlik Sense object will be. + * If you only supply one parameter, you will just get the model without displaying the object. + * @param {string} id - Snapshot ID. + * @param {element | string} [elem] - Optional. HTML element or string with HTML element id. + * @return {Promise} - A promise of an object model. + */ + getSnapshot(id: string, elem?: any | string): ng.IPromise; + + /** + * Locks all selections. + * @param {string} [state=$] - Optional. Alternate state name. + * Default: $ + * Introduced in version 2.1. + * @return {Promise} - A promise of a Qlik engine reply. + */ + lockAll(state?: string): ng.IPromise; + + /** + * Removes an alternate state in the app. + * @param {string} qStateName - Alternate state name. + * @return {Promise} - A promise of a Qlik engine reply. + */ + removeAlternateState(qStateName: string): ng.IPromise; + + /** + * Searches for one or more terms in the values of a Qlik Sense app. + * @param {array} qTerms - Terms to search for. + * @param {object} qPage - Properties: + * Name | Type | Description + * qOffset | Number | Position from the top, starting from 0. + * qCount | Number | Number of search results to return. + * qMaxNbrFieldMatches | Number | Maximum number of matching values to return per search result. + * @param {object} qOptions - Properties + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * qContext | | Search context. Can be one of: + * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * | | Default value is LockedFieldsOnly. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + searchAssociations(qTerms: any[], qPage: any, qOptions: any, callback?: any): ng.IPromise; + + /** + * Searches for one or more terms in the values of a Qlik Sense app. + * @param {array} qTerms - Terms to search for. + * @param {object} qPage - Properties: + * Name | Type | Description + * qOffset | Number | Position from the top, starting from 0. + * qCount | Number | Number of search results to return. + * qGroupOptions | Array | This parameter is optional. Options of the search groups. If this property is not set, all values are returned. + * qGroupItemOptions | Array | This parameter is optional. Options of the search group items. If this property is not set, all values are returned. + * qOptions | Object | Optional. Search options. Properties: + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * qContext | | Search context. Can be one of: + * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * | | Default value is LockedFieldsOnly. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + searchResults(qTerms: any[], qPage: any, qOptions?: any, callback?: any): ng.IPromise; + + /** + * Returns suggestions of words from the values entered in the search. Acts as a helper for the searchAssociations method. + * @param {array} qTerms - Terms to search for. + * @param {object} [qOptions] - Optional. Search options. Properties: + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + searchSuggest(qTerms: any[], qOptions?: any, callback?: any): ng.IPromise; + + /** + * Makes a selection based on searchAssociation results. + * @param {number} qMatchIx - Index to search result. + * @param {array} qTerms - Values to select. + * @param {object} qOptions - Values to select. + * @param {array} [qTerms] - Optional. Parameter sent to the Qlik engine containing information about the search fields and the search context. + * @param {object} [qSoftLock] - Optional. This parameter was deprecated in version 2.0 and is ignored in newer versions. Use the qOtions.qContext parameter instead. + * @return {Promise} - A promise of a Qlik engine reply. + */ + selectAssociations(qMatchIx: number, qTerms: any[], qOptions?: any, qSoftLock?: any): ng.IPromise; + + /** + * Creates a QSelectionState object that encapsulates the selection state. Entry point to the Selection API. + * @param {string} [state] - Optional. Sets the state. Default is $. + */ + selectionState(state?: string): SelectionStateAPI.IQSelectionState; + + /** + * Unlocks all selections that has previously been locked. + * @param {string} [state] - Optional. Alternate state name. Default: $ Introduced in version 2.1. + */ + unlockAll(state?: string): ng.IPromise; + } +} + +declare namespace BookmarkAPI { + interface IBookmark { + /** + * Applies a bookmark. + * @param {string} id - Bookmark id. + * @return {Promise} - A promise of a Qlik engine reply. + */ + apply(id: string): ng.IPromise; + + /** + * Creates a bookmark based on the current selection. + * @param {string} title - Bookmark title. + * @param {string} description - Bookmark description. + * @param {string} [sheetId] - Optional. Bookmark sheet id. Introduced in version 2.2. + * @return {Promise} - A promise of a Qlik engine reply. + */ + create(title: string, description: string, sheetId?: string): ng.IPromise; + + /** + * Removes a bookmark. + * @param {string} id - Bookmark id. + * @return {Promise} - A promise of a Qlik engine reply. + */ + remove(id: string): ng.IPromise; + } +} + +declare namespace FieldAPI { + interface IQField { + /** + * Clears a field selection. + * @return {Promise} - A promise. + */ + clear(): ng.IPromise; + + /** + * Clears all fields except the selected one. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + clearOther(softlock?: boolean): ng.IPromise; + + /** + * Gets field data. The values are available as QFieldValue in array field.rows and will updated when the selection state changes. Notification OnData will be triggered after each update. + * @param {boolean} [options] - Optional. Properties: + * Name | Type | Description + * rows | Number | Number of rows to fetch. Default: 200. + * frequencyMode | String | Can be one of: + * # V=Absolute + * # P=Percent + * # R=Relative + * # N=No frequency + * | | Default: V. + * @return {IQField} - The field object. + */ + getData(options?: boolean): IQField; + + /** + * Gets more data for your field. Notification OnData is triggered when complete. + * @return {IQField} - The field object. + */ + getMoreData(): IQField; + + /** + * Locks a field selection. + * @return {Promise} - A promise. + */ + lock(): ng.IPromise; + + /** + * Selects field values using indexes. + * @param {number[]} Array - Array of index values to select + * @param {boolean} [toggle] - Optional. If true, toggle selected state. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + select(Array: number[], toggle?: boolean, softlock?: boolean): ng.IPromise; + + /** + * Selects all values in a field. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectAll(softlock?: boolean): ng.IPromise; + + /** + * Selects alternative values in a field. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectAlternative(softlock?: boolean): ng.IPromise; + + /** + * Selects excluded values in a field. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectExcluded(softlock?: boolean): ng.IPromise; + + /** + * Selects matching field values. + * @param {string} match - Match string. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectMatch(match: string, softlock?: boolean): ng.IPromise; + + /** + * Selects possible values in a field. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectPossible(softlock?: boolean): ng.IPromise; + + /** + * Selects specific values in a field. + * @param {array} array - Array of qFieldValues to select. A simplified syntax with strings or numbers also works since version 1.1. + * For a numeric field you need to provide the numeric value. + * @param {boolean} [toggle] - Optional. If true, toggle selected state. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectValues(array: IQFieldValue[], toggle?: boolean, softlock?: boolean): ng.IPromise; + + /** + * Toggles a field selection. + * @param {string} match - Match string. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + toggleSelect(match: string, softlock?: boolean): ng.IPromise; + + /** + * Unlocks field selections. + * @return {Promise} - A promise. + */ + unlock(): ng.IPromise; + + /** + * Field values. You need to call getData() method to make this available. Introduced in 2.1. + */ + rows: IQFieldValue[]; + + /** + * Optional. Number of different values. Only after getData() call. Introduced in 2.1. + */ + rowCount: number; + + /** + * Optional. Object with number of values in different states. Only after getData() call. Introduced in 2.1. + */ + qStateCounts: any; + } + + interface IQFieldValue { + /** + * Cell value formatted as set up in properties. + */ + qText: string; + + /** + * Cell value index. + */ + qElemNumber: number; + + /** + * Cell state. + */ + qState: any; + + /** + * Optional. Cell numeric value, if cell is numeric. + */ + qNum?: number; + + /** + * Optional. Frequency, if calculated by the Qlik engine. + */ + qFrequency?: string; + + /** + * Selects a field value. + * @param {boolean} [toggle] - Optional. If true, toggle selected state. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + select(toggle?: boolean, softlock?: boolean): ng.IPromise; + } +} + +declare namespace GlobalAPI { + interface IGlobal { + /** + * Cancels an ongoing reload. The reload of the app is stopped. + * @return {Promise} - A promise of a Qlik engine reply. + */ + cancelReload(): ng.IPromise; + + /** + * Gets a list of Qlik Sense apps that you potentially can connect to and registers a callback to receive the data. + * Calling the getAppList method opens a WebSocket, gets the app list, and then keeps the WebSocket open for you to make other calls as well. + * @param {Function} callback - Callback method. + */ + getAppList(callback: any): void; + + /** + * Gets information (user directory and user id) about the authenticated user. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getAuthenticatedUser(callback?: any): ng.IPromise; + + /** + * Gets information about progress of doReload and doSave calls. + * @param {Number} qRequestId - Request id from doReload call or 0. + * Complete information is returned if the identifier of the request is specified. + * If qRequestId = 0, less information is returned. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getProgress(qRequestId: number, callback?: any): ng.IPromise; + + /** + * Gets the product version. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getProductVersion(callback?: any): ng.IPromise; + + /** + * Gets the Qlik product name. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getQTProduct(callback?: any): ng.IPromise; + + /** + * Gets the Qlik Sense version number. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise. + */ + getQvVersion(callback?: any): ng.IPromise; + + /** + * Gets information if the user is working in personal mode (returns true if Qlik Sense Desktop is used) or not (returns false if Qlik Sense Desktop is not used). + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + isPersonalMode(callback?: any): ng.IPromise; + } +} + +declare namespace NavigationAPI { + type NavigationModeType = "ANALYSIS" | "EDIT"; + type NavigationErrorType = "NOSUCHSHEET" | "NOCURRENTSHEET" | "NOSUCHSTORY"; + + /** + * The navigation result object. + */ + interface NavigationResult { + /** + * Returns true if successful. + */ + success: boolean; + + /** + * The new sheet ID. + */ + sheetId: string; + + /** + * The new story ID. + */ + storyId: string; + + /** + * The new mode. + */ + mode: string; + + /** + * Error code. Can be: NOSUCHSHEET | NOCURRENTSHEET | NOSUCHSTORY + */ + error: NavigationErrorType; + + /** + * Error message, for example 'No current sheet'. + */ + errorMsg: string; + } + + /** Navigation API for Qlik Sense. The Navigation API allows you to navigate + * within a Qlik Sense app, and is meant to be used in visualization extensions + * and will not work in Mashup scenarios. + */ + interface INavigation { + /** + * Used for analysis mode. + */ + edit: "edit"; + + /** + * Used for edit mode. + */ + analysis: "analysis"; + + /** + * Gets the current sheet ID. + * @return {NavigationResult} - A navigation result object. + */ + getCurrentSheetId(): NavigationResult; + + /** + * Gets the current mode. + * @return {string} - The current mode as a string. + */ + getMode(): string; + + /** + * Navigate to a given sheet in the current app. The method will return before the actual navigation takes place. + * @param {string} sheetId - Set the sheet ID to navigate to. + * @return {NavigationResult} - A navigation result object. + */ + gotoSheet(sheetId: string): NavigationResult; + + /** + * Navigate to a given story in the current app. The method will return before the actual navigation takes place. + * @param {string} storyId - Set the story ID to navigate to. + * @return {NavigationResult} - A navigation result object. + */ + gotoStory(storyId: string): NavigationResult; + + /** + * Checks if a given mode is allowed. + * @param {NavigationModeType} mode - Can be one of the strings: edit | analysis + * or one of the constants: qlik.navigation.EDIT | qlik.navigation.ANALYSIS + * @return {boolean} - A Boolean value (true or false). + */ + isModeAllowed(mode: NavigationModeType): boolean; + + /** + * Go to the next sheet in the current app. It will do nothing if you do not have sheets in the current context. + * The method will return before the actual navigation takes place. + * @return {NavigationResult} - A navigation result object. + */ + nextSheet(): NavigationResult; + + /** + * Jumps to the previous sheet in the current app. It will do nothing if you do not have sheets in the current context. + * The method will return before the actual navigation takes place + * @return {NavigationResult} - A navigation result object. + */ + prevSheet(): NavigationResult; + + /** + * Sets the current working mode of Qlik Sense. + * @param {string | constant} mode - Can be one of the strings: edit | analysis + * or one of the constants: qlik.navigation.EDIT | qlik.navigation.ANALYSIS + * @return {NavigationResult} - A navigation result object. + */ + setMode(mode: string): NavigationResult; + + /** + * Switches the working mode of Qlik Sense. + * @param {NavigationModeType} mode - Can be one of the strings: edit | analysis + * or one of the constants: qlik.navigation.EDIT | qlik.navigation.ANALYSIS + * @return {NavigationResult} - A navigation result object. + */ + switchMode(mode: NavigationModeType): NavigationResult; + } +} + +declare namespace SelectionStateAPI { + interface IQFieldSelections { + /** + * Selection state for a field. + */ + fieldName: string; + + /** + * Sort index. Starting from 0. + */ + qSortIndex: number; + + /** + * Reference to the field. + */ + field: FieldAPI.IQField; + + /** + * Defines if the field is locked. + */ + locked: boolean; + + /** + * Defines if the field is numeric. + */ + isNumeric: boolean; + + /** + * Total number of values in the field. + */ + totalCount: number; + + /** + * Number of selected values. + */ + selectedCount: number; + + /** + * Number of values that will be listed. + */ + qSelectionThreshold: number; + + /** + * Object with number of values in different states. + */ + qStateCounts: any; + + /** + * Concatenated string of selected values if number of values are less than the threshold, or if the string is of format "7 of 123". + */ + qSelected: string; + + /** + * Array with maximum of qSelectionThreshold values that are selected. For each value, the text plus the selection mode (NORMAL/AND/NOT) + */ + selectedValues: number[]; + + /** + * Array with maximum of qSelectionThreshold values that are not selected. For each value, the text plus the selection mode (NORMAL/AND/NOT) + */ + notSelectedValues: number[]; + } + + interface IQSelectionState { + /** + * State name. $ for default state. + */ + stateName: string; + + /** + * Selections + */ + selections: IQFieldSelections; + + /** + * Number of back steps available. + */ + backCount: number; + + /** + * Number of forward steps available. OnData notification will be triggered after each update. + */ + forwardCount: number; + + /** + * Cleara all selections in this state. + * @param {boolean} lockedAlso - Use to also clear locked fields. + * @return {Promise} - A promise of a Qlik engine reply. + */ + clearAll(lockedAlso: boolean): ng.IPromise; + + /** + * Locks all selections in this state. + * @return {Promise} - A promise of a Qlik engine reply. + */ + lockAll(): ng.IPromise; + + /** + * Unlocks all selections in this state. + * @return {Promise} - A promise of a Qlik engine reply. + */ + unlockAll(): ng.IPromise; + } +} + +declare namespace TableAPI { + interface IQTable { + /** + * Data rows. + */ + rows: IQRow[]; + + /** + * Header information. + */ + headers: IQHeader[]; + + /** + * Total information for measures. + */ + totals: IQMeasureCell[]; + + /** + * Total number of rows for the qHyperCube, including rows not fetched from the server. + */ + rowCount: number; + + /** + * Total number of columns for the qHyperCube. + */ + colCount: number; + + /** + * Exports data of the underlying hypercube in OOXML or CSV format. + * @param {object} [options] - Optional. Properties: + * Name | Type | Description + * format | String | Data format. Can be one of: + * # OOXML: open XML, default + * # CSV_C: comma separated CSV + * # CSV_T: tab separated CSV + * filename | String | Name of the exported file after download from browser. This parameter is optional and only used in desktop. + * state | String | Can be: + * # A: all values + * # P: possible values (default) + * download | Boolean | Automatically start download of file (with window.open). + * @param {Function} [callback] - Optional. Callback function returning the link to the exported file. + */ + exportData(options?: any, callback?: any): void; + + /** + * Gets the column number for a given field name. + * @param {string} fld - Field name. + * @return {number} - Column number, starting with zero. Undefined if no column with that name exists. + */ + getColByName(fld: string): number; + + /** + * Gets more data for your qHyperCube. + */ + getMoreData(): any; + } + + interface IQHeader { + /** + * Column title. + */ + qFallbackTitle: string; + + /** + * Can be: + * # A: ascending + * # D: descending + */ + qSortIndicator: string; + + /** + * True indicates if this is the first column for sorting. + */ + isOrderedBy: boolean; + + /** + * True indicates if the sort order is reversed for this column. + */ + qReverseSort: boolean; + + /** + * Column number. + */ + col: number; + + /** + * Optional. Number of different values. Only used for dimensions. + */ + qCardinal?: number; + + /** + * Optional. Object with number of values in different states. Only used for dimensions. + */ + qStateCounts?: any; + + /** + * Optional. Field object with methods to manipulate the underlying field. Only used for dimensions. + */ + field?: any; + + /** + * Optional. Minimum value. Only used for measures. + */ + qMin?: number; + + /** + * Optional. Maximum value. Only used for measures. + */ + qMax?: number; + + /** + * Optional. Error code for this column. Only if column has an error. Introduced in version 2.2. + */ + errorCode?: number; + + /** + * Error message for this column. Only if column has an error. Introduced in version 2.2. + */ + errorMessage: number; + + /** + * Sets this column to be the first in the sort order. + */ + orderBy(): void; + + /** + * Reverses the sort order for this column. + */ + reverseOrder(): void; + + /** + * Select a range in this measure. + * @param {number} min - Sets the minimum value of the range. + * @param {number} max - Sets the maximum value of the range. + * @param {boolean} [inclMin] - Optional. Set to true to include minimum value. + * @param {boolean} [inclMax] - Optional. Set to true to include maximum value. + * @return {Promise} - A promise. + */ + selectRange(min: number, max: number, inclMin?: boolean, inclMax?: boolean): ng.IPromise; + } + + interface IQRow { + /** + * Dimension cells. + */ + dimensions: IQDimensionCell[]; + + /** + * Measure cells. + */ + measures: IQMeasureCell[]; + + /** + * All cells, in the order they are defined in the properties. + */ + cells: any[]; + } + + interface IQDimensionCell extends IQMeasureCell { + /** + * Cell value index. + */ + qElemNumber: number; + + /** + * Cell state. + */ + qState: string; + + /** + * Selects the value in this cell. + */ + select(): void; + } + + interface IQMeasureCell { + /** + * Cell value formatted as set up in properties. + */ + qText: string; + + /** + * Optional. Cell numeric value, if cell is numeric. + */ + qNum?: number; + + /** + * Gets the value of this cell as a percentage of the total. Might be more than 100% if this is an average. + */ + getPercent(): number; + + /** + * Gets the value of this cell as a percentage of the maximum. + */ + getPercentOfMax(): number; + } +} + +declare namespace VariableAPI { + interface IVariable { + /** + * Creates a variable. + * @param {string | object} qProp - Variable name or properties. Properties: + * Name | Type | Description + * qInfo.qId | String | Optional. Variable id. If the selected ID is already in use, a new ID is automatically set by the engine. + * qName | String | Variable name. The name must be unique. + * qComment | String | Optional. Comment related to the variable. + * qDefinition | String | Optional. Variable definition. + * qNumberPresentation | Object | Optional. Defines the format of the value. + * qIncludeInBookmark | Boolean | Optional. Set to true to update the variable when applying a bookmark. The variable value will be persisted in the bookmark. + * @return {Promise} - Returns a promise of a variable model. + */ + create(qProp: string | any): ng.IPromise; + + /** + * Creates a session variable, that is a temporary variable which is not persisted and needs to be recreated for each new session. + * @param {object} qProp - Variable properties: + * Name | Type | Description + * qInfo.qId | String | Optional. Variable id. + * qName | String | Variable name. + * qComment | String | Optional. Comment. + * qDefinition | String | Optional. Variable definition. + * qNumberPresentation | Object | Optional. + * qIncludeInBookmark | Boolean | Optional. Include in bookmark flag. + * @return {Promise} - A promise of a variable model. + */ + createSessionVariable(qProp: any): ng.IPromise; + + /** + * Gets a variable by id. + * @param {string} qId - Variable id. + * @return {Promise} - A promise of a variable model. + */ + get(qId: string): ng.IPromise; + + /** + * Gets a variable by name. + * @param {string} qName - Variable name. + * @return {Promise} - A promise of a variable model. + */ + getByName(qName: string): ng.IPromise; + + /** + * Gets variable content. + * @param {string} name - Variable name. + * @param {Function} callback - Callback to receive the content. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getContent(name: string, callback: any): ng.IPromise; + + /** + * Sets the content of a variable. + * @param {string} name - Variable name. + * @param {string} content - Variable content. + * @return {Promise} - A promise of a Qlik engine reply. + */ + setContent(name: string, content: string): ng.IPromise; + + /** + * Sets a numeric value as a variable. + * @param {string} qName - Variable name. + * @param {Number} qVal - Variable value. + * @return {Promise} - A promise of a Qlik engine reply. + */ + setNumValue(qName: string, qVal: number): ng.IPromise; + + /** + * Sets variable string value. + * @param {string} qName - Variable name. + * @param {string} qVal - Variable value. + * @return {Promise} - A promise of a Qlik engine reply. + */ + setStringValue(qName: string, qVal: string): ng.IPromise; + } +} + +declare namespace VisualizationAPI { + type VisualizationType = "barchart" | "combochart" | "gauge" | "kpi" | "linechart" | "piechart" | "pivot-table" | + "scatterplot" | "table" | "treemap" | "extension"; + + interface IVisualization { + /** + * Create a new visualization on the fly based on a session object and will not be persisted in the app. + * @param {VisualizationType} type - Visualization type. Can be: + * # barchart + * # combochart + * # gauge + * # kpi + * # linechart + * # piechart + * # pivot-table + * # scatterplot + * # table + * # treemap + * # extension + * @param {array} [cols] - Optional. Column definitions, dimensions and measures. Each entry can be of the following structures: + * # String + * # NxDimension + * # NxMeasure + * If the NxDimension or the NxMeasure refer to a library dimension or a library measure, you also need to add qType : "measure" or "dimension". + * @param {object} [options] - Optional. Options to set. + * @return {Promise} - A promise of a QVisualization. + */ + create(type: VisualizationType, cols?: any[], options?: any): ng.IPromise; + + /** + * Gets an existing visualization. + * @param {string} id - Id for an existing visualization. + * @return {Promise} - A promise of a QVisualization. + */ + get(id: string): ng.IPromise; + } + + interface IQVisualization { + /** + * Table object for this visualization. Only for visualizations built on a hypercube. + */ + table: TableAPI.IQTable; + + /** + * Closes a visualization and releases the session object. + * @return {Promise} - A promise. + */ + close(): ng.IPromise; + + /** + * Tells the visualization it has been resized and should re-paint. + */ + resize(): void; + + /** + * Sets options for a visualization. + * @param {object} options - Options to set (using applyPatches). + */ + setOptions(options?: any): void; + + /** + * Shows the visualization in an HTML element. + * @param {Element | string} [element] - Optional. HTML element or HTML element ID. + * @param {object} [options] - Optional. + * Name | Type | Description + * noInteraction | Boolean | Set to true if you want to disable all interaction, including selections, in the visualization. + * noSelections | Boolean | Set to true if you want to disable selections in the visualization. + * | | Parameter introduced in version 3.0. + */ + show(element?: any | string, options?: any): void; + } +} + +declare namespace ExtensionAPI { + + + interface IExtensionModel { + + } + + interface IExtensionComponent { + model: IExtensionModel; + } + + interface IExtensionScope extends ng.IScope { + component: IExtensionComponent; + } + + + //ExtensionAPI + type SelectionModeType = "CONFIRM" | "QUICK"; + + interface IInitialProperties { + qHyperCubeDef?: any; //IHyperCubeDef; + qListObjectDef?: any; //IListObjectDef; + fixed?: boolean; + width?: number; + percent?: boolean; + selectionMode?: SelectionModeType; + } + + interface ISupport { + snapshot?: boolean; + export?: boolean; + exportData?: boolean; + } + + interface IExtension { + definition?: IDefinition; + paint?: ($element: HTMLElement, layout?: any) => void; + initialProperties?: IInitialProperties; + template?: string; + controller?: any; + support?: ISupport; + } + + interface ISupport { + snapshot?: boolean; // | () => boolean; + export?: boolean; // | () => boolean; + canTakeSnapshot?: boolean; + } + + interface IInitialProperties { + // qHyperCubeDef: IVisualizationHyperCubeDef; + // qListObjectDef: IVis + + //[""]: + } + + //#region IDefinition + type ExpressionType = "always" | "optional" | ""; + + type func = () => T; + type valueOrfunc = T | func; + + //#region Controls + interface ICustomControlOption { + value: string; + label: string; + } + + interface ICustomControl { + type: string; + label: string; + ref: string; + } + + interface ICustomString extends ICustomControl { + defaultValue: string; + expression: ExpressionType; + show: valueOrfunc; + maxlength: number; + } + + interface ICustomNumber extends ICustomControl { + defaultValue: number; + min: number; + max: number; + } + + interface ICustomInteger extends ICustomNumber { + } + + interface ICustomArray extends ICustomControl { + itemTitleRef: string; + addTranslation: string; + allowAdd: boolean; + allowMove: boolean; + allowRemove: boolean; + } + + interface ICustomButton extends ICustomControl { + label: string; + component: "button"; + action: valueOrfunc; + } + + interface ICustomButtonGroup extends ICustomControl { + component: "buttongroup"; + defaultValue: string; + options: valueOrfunc; + } + + interface ICustomCheckBox extends ICustomControl { + component: "checkbox"; + defaultValue: boolean; + } + + interface ICustomColorPicker extends ICustomControl { + component: "color-picker"; + defaultValue: number; + } + + interface ICustomDropDownList extends ICustomControl { + component: "dropdown"; + defaultValue: string; + options: valueOrfunc; + } + + interface ICustomLink { + type: string; + component: "link"; + label: string; + url: string; + } + + interface ICustomMedia extends ICustomControl { + component: "media"; + layoutRef: string; + } + + interface ICustomRadioButton extends ICustomControl { + component: "radiobuttons"; + defaultValue: string; + options: valueOrfunc; + } + + interface ICustomSlider extends ICustomControl { + component: "slider"; + defaultValue: number; + min: number; + max: number; + step: number; + } + + interface ICustomRangeSlider extends ICustomControl { + component: "slider"; + defaultValue: number[]; + min: number; + max: number; + step: number; + } + + interface ICustomSwitch { + component: "switch"; + defaultValue: boolean; + options: valueOrfunc; + } + + interface ICustomText { + type: "text"; + component: "text"; + label: string; + } + + interface ICustomTextArea extends ICustomControl { + component: "textarea"; + rows: number; + maxlength: number; + defaultValue: string; + show: valueOrfunc; + } + //#endregion + + interface IDefinition { + type: "items"; + component: "accordion"; + items: IItems; + } + + interface IItems { + dimentions?: IDimensions; + measures?: IMeasures; + appearance?: IAppearance; + sorting?: ISorting; + AddOns?: IAddOns; + [other: string]: any; + } + + interface IAddOns { + uses: "addons"; + } + + interface ISorting { + uses: "sorting"; + } + + interface IDimensions { + uses: "dimensions"; + min?: number; + max?: number; + } + + interface IAppearance { + uses: "settings"; + min?: number; + max?: number; + items: any; + } + + //?Das selbe wie Appearance? + interface ISettings { + uses: "settings"; + min?: number; + max?: number; + } + + interface IMeasures { + uses: "measures"; + min?: number; + max?: number; + } + + //#endregion +} + +declare module "qlik" { + var e: RootAPI.IRoot; export = e; +} + +interface IQVAngular { + /** + * Register a new directive with the compiler. + * + * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) + * @param directiveFactory An injectable directive factory function. + */ + directive(name: string, directiveFactory: ng.Injectable): void; + directive(object: { [directiveName: string]: ng.Injectable }): void; + + filter(name: string, filterFactoryFunction: ng.Injectable): void; + filter(object: { [name: string]: ng.Injectable }): void; + + /** + * Register a service constructor, which will be invoked with new to create the service instance. This is short for registering a service where its provider's $get property is a factory function that returns an instance instantiated by the injector from the service constructor function. + * + * @param name The name of the instance. + * @param serviceConstructor An injectable class (constructor function) that will be instantiated. + * @return Returns the constructed singleton of the service class/function. + */ + service(name: string, serviceConstructor: ng.Injectable): T; + service(object: { [name: string]: ng.Injectable }): T; + + //provider(name: string, serviceProviderFactory: ng.IServiceProviderFactory): void; + //provider(name: string, serviceProviderConstructor: ng.IServiceProviderClass): void; +} + +declare module "qvangular" { + var e: IQVAngular; export = e; +} \ No newline at end of file diff --git a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts new file mode 100644 index 0000000000..032b755b34 --- /dev/null +++ b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts @@ -0,0 +1,3 @@ +import * as qlik from "qlik"; + +const t = qlik.currApp(); \ No newline at end of file diff --git a/qlik-visualizationextensions/tsconfig.json b/qlik-visualizationextensions/tsconfig.json new file mode 100644 index 0000000000..47e4903e2e --- /dev/null +++ b/qlik-visualizationextensions/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "amd", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "qlik-visualizationextensions-tests.ts" + ] +} \ No newline at end of file diff --git a/qlik-visualizationextensions/tslint.json b/qlik-visualizationextensions/tslint.json new file mode 100644 index 0000000000..965a36a968 --- /dev/null +++ b/qlik-visualizationextensions/tslint.json @@ -0,0 +1,7 @@ +{ "extends": "../tslint.json", + "rules": { + "forbidden-types": false, + "no-empty-interface": false, + "interface-name": false + } +} \ No newline at end of file From 47134067acfda2acc7230e44d1c2b7ba9c6ef85b Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Thu, 23 Feb 2017 16:08:25 +0100 Subject: [PATCH 012/150] fixes BOM & module to run npm test Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 4 ++-- .../qlik-visualizationextensions-tests.ts | 2 +- qlik-visualizationextensions/tsconfig.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index 8a9c145969..c7eb32273c 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for qlik-visualizationextensions +// Type definitions for qlik-visualizationextensions 3.2 // Project: http://help.qlik.com/en-US/sense-developer/3.2/Subsystems/Extensions/Content/extensions-introduction.htm // Definitions by: Konrad Mattheis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -791,7 +791,7 @@ declare namespace BackendAPI { * @param {array} qPages - An array of request page objects. * @param {number} qZoomFactor - Zoom factor. * If set to -1, the Qlik engine decides of the zoom factor. - * If qReductionMode is D1 or S, the zoom factor is 2ⁿ. If the zoom factor is 5, the data are reduced by a factor 32. + * If qReductionMode is D1 or S, the zoom factor is 2n. If the zoom factor is 5, the data are reduced by a factor 32. * If qReductionMode is C, the zoom factor defines the number of centroids. * @param {string} qReductionMode - Reduction mode.Can be: * # N for no data reduction. diff --git a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts index 032b755b34..2e1d738198 100644 --- a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts +++ b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts @@ -1,3 +1,3 @@ -import * as qlik from "qlik"; +import qlik=require("qlik"); const t = qlik.currApp(); \ No newline at end of file diff --git a/qlik-visualizationextensions/tsconfig.json b/qlik-visualizationextensions/tsconfig.json index 47e4903e2e..f4a5bc132a 100644 --- a/qlik-visualizationextensions/tsconfig.json +++ b/qlik-visualizationextensions/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "module": "amd", + "module": "commonjs", "lib": [ "es6", "dom" From 28be3862f5ad801e7e8c23ab6052bc5bdf4d926e Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 24 Feb 2017 01:15:16 +0100 Subject: [PATCH 013/150] Basic definitions for Google+ API (gapi.plus) --- gapi.plus/gapi.plus-tests.ts | 10 ++++ gapi.plus/index.d.ts | 111 +++++++++++++++++++++++++++++++++++ gapi.plus/tsconfig.json | 18 ++++++ 3 files changed, 139 insertions(+) create mode 100644 gapi.plus/gapi.plus-tests.ts create mode 100644 gapi.plus/index.d.ts create mode 100644 gapi.plus/tsconfig.json diff --git a/gapi.plus/gapi.plus-tests.ts b/gapi.plus/gapi.plus-tests.ts new file mode 100644 index 0000000000..12368dd63c --- /dev/null +++ b/gapi.plus/gapi.plus-tests.ts @@ -0,0 +1,10 @@ +/* Example taken from https://developers.google.com/+/web/people/ */ + +gapi.client.load('plus','v1', function(){ + var request = gapi.client.plus.people.get({ + 'userId': 'me' + }); + request.execute(function(resp) { + console.log('Retrieved profile for:' + resp.displayName); + }); +}); diff --git a/gapi.plus/index.d.ts b/gapi.plus/index.d.ts new file mode 100644 index 0000000000..3e24b79ce1 --- /dev/null +++ b/gapi.plus/index.d.ts @@ -0,0 +1,111 @@ +// Type definitions for Google+ Platform API 1.0 +// Project: https://developers.google.com/+/web/people/ +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +// See Google+ REST API Reference https://developers.google.com/+/web/api/rest/latest/ +declare namespace gapi.client.plus { + export namespace people { + + interface GetParameters { + userId: string; + } + function get(parameters: GetParameters): HttpRequest; + + interface SearchParameters { + query: string; + language?: string; + maxResults?: number; + pageToken?: string; + } + function search(parameters: SearchParameters): HttpRequest; + + // Search response + interface PeopleFeed { + kind: 'plus#peopleFeed'; + etag: string; + selfLink: string; + title: string; + nextPageToken: string; + totalItems: number; + items: Person[]; + } + + interface Person { + kind: 'plus#person'; + etag: string; + nickname: string; + occupation: string; + skills: string; + birthday: string; + gender: string; + emails: { + value: string; + type: string; + }[]; + urls: { + value: string; + type: string; + label: string; + }[]; + objectType: string; + id: string; + displayName: string; + name: { + formatted: string; + familyName: string; + givenName: string; + middleName: string; + honorificPrefix: string; + honorificSuffix: string; + }; + tagline: string; + braggingRights: string; + aboutMe: string; + relationshipStatus: string; + url: string; + image: { + url: string; + }; + organizations: { + name: string; + department: string; + title: string; + type: string; + startDate: string; + endDate: string; + location: string; + description: string; + primary: boolean; + }[]; + placesLived: { + value: string; + primary: boolean; + }[]; + isPlusUser: boolean; + language: string; + ageRange: { + min: number; + max: number; + }; + plusOneCount: number; + circledByCount: number; + verified: boolean; + cover: { + layout: string; + coverPhoto: { + url: string; + height: number; + width: number; + }; + coverInfo: { + topImageOffset: number; + leftImageOffset: number; + } + }; + domain: string; + } + } +} diff --git a/gapi.plus/tsconfig.json b/gapi.plus/tsconfig.json new file mode 100644 index 0000000000..1fc2401de1 --- /dev/null +++ b/gapi.plus/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "module": "commonjs", + "lib": ["es6", "dom"], + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts", + "gapi.plus-tests.ts" + ] +} From 9e80f1e890b49247de1b9fd37b6d5c68f8fc52b3 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 24 Feb 2017 01:17:28 +0100 Subject: [PATCH 014/150] Add definitions for Google People API (gapi.people) --- gapi.people/gapi.people-tests.ts | 99 +++++++++++++ gapi.people/index.d.ts | 246 +++++++++++++++++++++++++++++++ gapi.people/tsconfig.json | 18 +++ 3 files changed, 363 insertions(+) create mode 100644 gapi.people/gapi.people-tests.ts create mode 100644 gapi.people/index.d.ts create mode 100644 gapi.people/tsconfig.json diff --git a/gapi.people/gapi.people-tests.ts b/gapi.people/gapi.people-tests.ts new file mode 100644 index 0000000000..65b6339765 --- /dev/null +++ b/gapi.people/gapi.people-tests.ts @@ -0,0 +1,99 @@ +/* Example taken from Google People API JavaScript Quickstart https://developers.google.com/people/quickstart/js */ + +{ + // Your Client ID can be retrieved from your project in the Google + // Developer Console, https://console.developers.google.com + var CLIENT_ID = ''; + + var SCOPES = ["https://www.googleapis.com/auth/contacts.readonly"]; + + /** + * Check if current user has authorized this application. + */ + function checkAuth() { + gapi.auth.authorize( + { + 'client_id': CLIENT_ID, + 'scope': SCOPES.join(' '), + 'immediate': true + }, handleAuthResult); + } + + /** + * Handle response from authorization server. + * + * @param {Object} authResult Authorization result. + */ + function handleAuthResult(authResult: GoogleApiOAuth2TokenObject) { + var authorizeDiv = document.getElementById('authorize-div')!; + if (authResult && !authResult.error) { + // Hide auth UI, then load client library. + authorizeDiv.style.display = 'none'; + loadPeopleApi(); + } else { + // Show auth UI, allowing the user to initiate authorization by + // clicking authorize button. + authorizeDiv.style.display = 'inline'; + } + } + + /** + * Initiate auth flow in response to user clicking authorize button. + * + * @param {Event} event Button click event. + */ + function handleAuthClick(event: MouseEvent) { + gapi.auth.authorize( + {client_id: CLIENT_ID, scope: SCOPES, immediate: false}, + handleAuthResult); + return false; + } + + /** + * Load Google People client library. List names if available + * of 10 connections. + */ + function loadPeopleApi() { + gapi.client.load('https://people.googleapis.com/$discovery/rest', 'v1', listConnectionNames); + } + + /** + * Print the display name if available for 10 connections. + */ + function listConnectionNames() { + var request = gapi.client.people.people.connections.list({ + 'resourceName': 'people/me', + 'pageSize': 10, + }); + + request.execute(function(resp) { + var connections = resp.connections; + appendPre('Connections:'); + + if (connections.length > 0) { + for (var i = 0; i < connections.length; i++) { + var person = connections[i]; + if (person.names && person.names.length > 0) { + appendPre(person.names[0].displayName) + } else { + appendPre("No display name found for connection."); + } + } + } else { + appendPre('No upcoming events found.'); + } + }); + } + + /** + * Append a pre element to the body containing the given message + * as its text node. + * + * @param {string} message Text to be placed in pre element. + */ + function appendPre(message: string) { + var pre = document.getElementById('output')!; + var textContent = document.createTextNode(message + '\n'); + pre.appendChild(textContent); + } +} diff --git a/gapi.people/index.d.ts b/gapi.people/index.d.ts new file mode 100644 index 0000000000..86bf930beb --- /dev/null +++ b/gapi.people/index.d.ts @@ -0,0 +1,246 @@ +// Type definitions for Google People API 1.0 +// Project: https://developers.google.com/people/ +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace gapi.client.people { + export namespace people { + + interface GetParameters { + resourceName: string; + + // Query parameters + requestMask?: RequestMask; + } + + function get(parameters: GetParameters): HttpRequest; + + interface GetBatchGetParameters { + // Query parameters + resourcesName?: string; + requestMask?: RequestMask; + } + + function getBatchGet(parameters: GetBatchGetParameters): HttpRequest; + + interface BatchGetResponse { + responses: PersonResponse[]; + } + + interface PersonResponse { + httpStatusCode: number; + person: Person; + requestedResourceName: string; + } + + namespace connections { + function list(parameters: ListParameters): HttpRequest; + + type SortOrder = 'LAST_MODIFIED_ASCENDING' | 'FIRST_NAME_ASCENDING' | 'LAST_NAME_ASCENDING'; + + interface ListParameters { + resourceName: string; + + // Query parameters + pageToken?: string; + pageSize?: number; + sortOrder?: SortOrder; + syncToken?: string; + requestMask?: RequestMask; + } + + interface Response { + connections: Person[]; + nextPageToken: string; + nextSyncToken: string; + } + } + } + + interface RequestMask { + includeField: string; + } + + type SourceType = 'SOURCE_TYPE_UNSPECIFIED' | 'ACCOUNT' | 'PROFILE' | 'DOMAIN_PROFILE' | 'CONTACT'; + + interface Source { + type: SourceType; + id: string; + etag: string; + resourceName: string; + } + + type ObjectType = 'OBJECT_TYPE_UNSPECIFIED' | 'PERSON' | 'PAGE'; + + interface PersonMetadata { + sources: Source[]; + previousResourceNames: string[]; + linkedPeopleResourceNames: string[]; + deleted: boolean; + objectType: ObjectType; + } + + interface FieldMetadata { + primary: boolean; + verified: boolean; + source: Source; + } + + interface Locale { + metadata: FieldMetadata; + value: string; + } + + interface Name { + metadata: FieldMetadata; + displayName: string; + displayNameLastFirst: string; + familyName: string; + givenName: string; + middleName: string; + honorificPrefix: string; + honorificSuffix: string; + phoneticFullName: string; + phoneticFamilyName: string; + phoneticGivenName: string; + phoneticMiddleName: string; + phoneticHonorificPrefix: string; + phoneticHonorificSuffix: string; + } + + type NicknameType = 'DEFAULT' | 'MAIDEN_NAME' | 'INITIALS' | 'GPLUS' | 'OTHER_NAME'; + + interface Nickname { + metadata: FieldMetadata; + value: string; + type: NicknameType; + } + + interface CoverPhoto { + } + + interface Photo { + } + + interface Gender { + } + + interface AgeRange { + } + + interface Birthday { + } + + interface Event { + } + + interface Address { + metadata: FieldMetadata; + formattedValue: string; + type: string; + formattedType: string; + poBox: string; + streetAddress: string; + extendedAddress: string; + city: string; + region: string; + postalCode: string; + country: string; + countryCode: string; + } + + interface Residence { + metadata: FieldMetadata; + value: string; + current: boolean; + } + + interface EmailAddress { + metadata: FieldMetadata; + value: string; + type: string; + formattedType: string; + displayName: string; + } + + interface PhoneNumber { + metadata: FieldMetadata; + value: string; + canonicalForm: string; + type: string; + formattedType: string; + } + + interface ImClient { + } + + interface Tagline { + } + + interface Biography { + } + + interface Url { + } + + interface Organization { + } + + interface Occupation { + } + + interface Interest { + } + + interface Skill { + } + + interface BraggingRights { + } + + interface Relation { + } + + interface RelationshipInterest { + } + + interface RelationshipStatus { + } + + interface Membership { + } + + interface Person { + resourceName: string; + etag: string; + metadata: PersonMetadata; + locales: Locale[]; + names: Name[]; + nicknames?: Nickname[]; + coverPhotos: CoverPhoto[]; + photos?: Photo[]; + genders?: Gender[]; + ageRange?: AgeRange; + birthdays?: Birthday[]; + events?: Event[]; + addresses?: Address[]; + residences?: Residence[]; + emailAddresses?: EmailAddress[]; + phoneNumbers?: PhoneNumber[]; + imClients?: ImClient[]; + taglines?: Tagline[]; + biographies?: Biography[]; + urls?: Url[]; + organizations?: Organization[]; + occupations?: Occupation[]; + interests?: Interest[]; + skills?: Skill[]; + BraggingRights?: BraggingRights[]; + relations?: Relation[]; + relationshipInterests?: RelationshipInterest[]; + relationshipStatuses?: RelationshipStatus[]; + memberships?: Membership[]; + } +} diff --git a/gapi.people/tsconfig.json b/gapi.people/tsconfig.json new file mode 100644 index 0000000000..93fcfc59b6 --- /dev/null +++ b/gapi.people/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "module": "commonjs", + "lib": ["es6", "dom"], + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts", + "gapi.people-tests.ts" + ] +} From fc9bff794033c7509144dd53f28cba8fe8748796 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 24 Feb 2017 01:18:59 +0100 Subject: [PATCH 015/150] Add tests for gapi Includes various fixes due to the tests --- gapi/gapi-tests.ts | 97 ++++++++++++++++++++++++++++++++++++++++++++++ gapi/index.d.ts | 86 ++++++++++++++++++++++++++++++---------- gapi/tsconfig.json | 10 +++-- 3 files changed, 168 insertions(+), 25 deletions(-) create mode 100644 gapi/gapi-tests.ts diff --git a/gapi/gapi-tests.ts b/gapi/gapi-tests.ts new file mode 100644 index 0000000000..b16cade6bb --- /dev/null +++ b/gapi/gapi-tests.ts @@ -0,0 +1,97 @@ +/// +/// + +/* Examples taken from https://developers.google.com/api-client-library/javascript/start/start-js */ + +{ + function start1() { + // 2. Initialize the JavaScript client library. + gapi.client.init({ + 'apiKey': 'YOUR_API_KEY', + 'discoveryDocs': ['https://people.googleapis.com/$discovery/rest'], + // clientId and scope are optional if auth is not required. + 'clientId': 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com', + 'scope': 'profile', + }).then(function() { + // 3. Initialize and make the API request. + return gapi.client.people.people.get({ + resourceName: 'people/me' + }); + }).then(function(response) { + console.log(response.result); + }, function(reason) { + console.log('Error: ' + reason.result.error.message); + }); + }; + // 1. Load the JavaScript client library. + gapi.load('client', start1); +} + +{ + function start2() { + // 2. Initialize the JavaScript client library. + gapi.client.init({ + 'apiKey': 'YOUR_API_KEY', + // clientId and scope are optional if auth is not required. + 'clientId': 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com', + 'scope': 'profile', + }).then(function() { + // 3. Initialize and make the API request. + return gapi.client.request({ + 'path': 'https://people.googleapis.com/v1/people/me', + }) + }).then(function(response) { + console.log(response.result); + }, function(reason) { + console.log('Error: ' + reason.result.error.message); + }); + }; + // 1. Load the JavaScript client library. + gapi.load('client', start2); +} + + +/* Examples taken from https://developers.google.com/api-client-library/javascript/features/promises */ + +gapi.client.request({'path': '/plus/v1/people', 'params': {'query': 'John'}}).then(function(response) { + // Handle response +}, function(reason) { + // Handle error +}); + +gapi.client.load('plus', 'v1').then(function() { + gapi.client.plus.people.search({'query': ''}).then(response => { }); +}); + +var personFetcher = { + results: [], + + // Why this: any? Check https://github.com/Microsoft/TypeScript/issues/10835 + + fetch: function(this: any, name: string) { + gapi.client.request({path: '/plus/v1/people', params:{query: name}}).then(function(this: any, response) { + this.results.push(response.result); + }, function(reason) { + console.error(name, 'was not fetched:', reason.result.error.message); + }, this); + } +}; +personFetcher.fetch('John'); + +gapi.client.request({ + 'path': 'plus/v1/people', + 'params': {'query': name} +}).execute(function(resp, rawResp) { + processResponse(resp); +}); + +gapi.client.request({ + 'path': 'plus/v1/people', + 'params': {'query': name} +}).then(function(resp) { + processResponse(resp.result); +}); + +function processResponse(response: any) { + // Stub +} diff --git a/gapi/index.d.ts b/gapi/index.d.ts index 84da600e7b..8f8e621fa3 100644 --- a/gapi/index.d.ts +++ b/gapi/index.d.ts @@ -1,8 +1,8 @@ -// Type definitions for Google API Client +// Type definitions for Google API Client 0.0 // Project: https://code.google.com/p/google-api-javascript-client/ // Definitions by: Frank M // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - +// TypeScript Version: 2.1 /** * The OAuth 2.0 token object represents the OAuth 2.0 token and any associated data. @@ -102,7 +102,7 @@ declare namespace gapi.auth { /** * A function in the global namespace, which is called when the sign-in button is rendered and also called after a sign-in flow completes. */ - callback?: Function; + callback?: () => void; /** * If true, all previously granted scopes remain granted in each incremental request, for incremental authorization. The default value true is correct for most use cases; use false only if employing delegated auth, where you pass the bearer token to a less-trusted component with lower programmatic authority. */ @@ -127,6 +127,30 @@ declare namespace gapi.auth { } declare namespace gapi.client { + /** + * Initializes the JavaScript client with API key, OAuth client ID, scope, and API discovery document(s). + * If OAuth client ID and scope are provided, this function will load the gapi.auth2 module to perform OAuth. + * The gapi.client.init function can be run multiple times, such as to set up more APIs, to change API key, or initialize OAuth lazily. + */ + export function init(args: { + /** + * The API Key to use. + */ + apiKey?: string; + /** + * An array of discovery doc URLs or discovery doc JSON objects. + */ + discoveryDocs?: string[]; + /** + * The app's client ID, found and created in the Google Developers Console. + */ + clientId?: string; + /** + * The scopes to request, as a space-delimited string. + */ + scope?: string + }): Promise; + interface RequestOptions { /** * The URL to handle the request @@ -188,10 +212,46 @@ declare namespace gapi.client { */ export function setApiKey(apiKey: string): void; + interface HttpRequestFulfilled { + result: T; + body: string; + headers?: any[]; + status?: number; + statusText?: string; + } + + interface HttpRequestRejected { + result: { + error: { + message: string; + } + }; + body: string; + headers?: any[]; + status?: number; + statusText?: string; + } + + /** + * HttpRequest supports promises. + * See Google API Client JavaScript Using Promises https://developers.google.com/api-client-library/javascript/features/promises + * + * TODO This should be updated when TypeScript 2.3 is released + * See https://github.com/Microsoft/TypeScript/issues/12409 + * See https://github.com/Microsoft/TypeScript/blob/65da012527937a3074c62655d60ee08fee809f7f/lib/lib.es5.d.ts#L1339 + */ + class HttpRequestPromise { + then( + opt_onFulfilled?: ((response: HttpRequestFulfilled) => void) | null, + opt_onRejected?: ((reason: HttpRequestRejected) => void) | null, + opt_context?: any + ): Promise; + } + /** * An object encapsulating an HTTP request. This object is not instantiated directly, rather it is returned by gapi.client.request. */ - export class HttpRequest { + export class HttpRequest extends HttpRequestPromise { /** * Executes the request and runs the supplied callback on response. * @param callback The callback function which executes when the request succeeds or fails. @@ -211,24 +271,8 @@ declare namespace gapi.client { statusText: string; } ) => any): void; - /** - * HttpRequest supports promises. - */ - then(success: (response: { - result: T; - body: string; - headers?: any[]; - status?: number; - statusText?: string; - }) => void, - failure: (response: { - result: T; - body: string; - headers?: any[]; - status?: number; - statusText?: string; - }) => void): void; } + /** * Represents an HTTP Batch operation. Individual HTTP requests are added with the add method and the batch is executed using execute. */ diff --git a/gapi/tsconfig.json b/gapi/tsconfig.json index 27e01ecd7b..22f5738c1a 100644 --- a/gapi/tsconfig.json +++ b/gapi/tsconfig.json @@ -2,11 +2,12 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -16,6 +17,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "gapi-tests.ts" ] -} \ No newline at end of file +} From 966f6241c6c5471138737e047b95bd404c87b8c8 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 24 Feb 2017 01:19:43 +0100 Subject: [PATCH 016/150] gapi.auth2 small fixes --- gapi.auth2/gapi.auth2-tests.ts | 12 ++++++------ gapi.auth2/index.d.ts | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gapi.auth2/gapi.auth2-tests.ts b/gapi.auth2/gapi.auth2-tests.ts index 621ca6f056..362a60c904 100644 --- a/gapi.auth2/gapi.auth2-tests.ts +++ b/gapi.auth2/gapi.auth2-tests.ts @@ -1,6 +1,6 @@ -function test_init(){ +function test_init() { var auth = gapi.auth2.init({ client_id: 'my-id', cookie_policy: 'single_host_origin', @@ -9,7 +9,7 @@ function test_init(){ }); } -function test_getAuthInstance(){ +function test_getAuthInstance() { gapi.auth2.init({ client_id: 'my-id', cookie_policy: 'single_host_origin', @@ -19,14 +19,14 @@ function test_getAuthInstance(){ var auth = gapi.auth2.getAuthInstance(); } -function test_signIn(){ +function test_signIn() { gapi.auth2.getAuthInstance().signIn({ scope: 'email profile', prompt: 'content' }); } -function test_signInOptionsBuild(){ +function test_signInOptionsBuild() { var options = new gapi.auth2.SigninOptionsBuilder(); options.setAppPackageName('com.example.app'); options.setFetchBasicProfile(true); @@ -35,13 +35,13 @@ function test_signInOptionsBuild(){ gapi.auth2.getAuthInstance().signIn(options); } -function test_getAuthResponse(){ +function test_getAuthResponse() { var user = gapi.auth2.getAuthInstance().currentUser.get(); var authResponse = user.getAuthResponse(); var authResponseWithAuth = user.getAuthResponse(true); } -function test_render(){ +function test_render() { var success = (googleUser: gapi.auth2.GoogleUser): void => { console.log(googleUser); }; diff --git a/gapi.auth2/index.d.ts b/gapi.auth2/index.d.ts index 6146a87e28..402da68699 100644 --- a/gapi.auth2/index.d.ts +++ b/gapi.auth2/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Sign-In API +// Type definitions for Google Sign-In API 0.0 // Project: https://developers.google.com/identity/sign-in/web/ // Definitions by: Derek Lawless // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -21,7 +21,7 @@ declare namespace gapi.auth2 { * Calls the onInit function when the GoogleAuth object is fully initialized, or calls the onFailure function if * initialization fails. */ - then(onInit: () => any, onFailure: (reason: string) => any): any; + then(onInit: () => any, onFailure?: (reason: string) => any): any; /** * Signs in the user with the options specified to gapi.auth2.init(). @@ -58,7 +58,7 @@ declare namespace gapi.auth2 { onsuccess: (googleUser: GoogleUser) => any, onfailure: (reason: string) => any): any; } - export interface IsSignedIn{ + export interface IsSignedIn { /** * Returns whether the current user is currently signed in. */ From 2b11d2ab76a29a2dfec9972eec486d9754ec0ede Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 24 Feb 2017 01:20:07 +0100 Subject: [PATCH 017/150] More tests for gapi.auth2 --- gapi.auth2/gapi.auth2-tests.ts | 86 +++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/gapi.auth2/gapi.auth2-tests.ts b/gapi.auth2/gapi.auth2-tests.ts index 362a60c904..1d389d59e9 100644 --- a/gapi.auth2/gapi.auth2-tests.ts +++ b/gapi.auth2/gapi.auth2-tests.ts @@ -1,4 +1,4 @@ - +/// function test_init() { var auth = gapi.auth2.init({ @@ -59,3 +59,87 @@ function test_render() { onfailure: failure }); } + +/* Example taken from https://developers.google.com/identity/sign-in/web/ */ +function onSignIn(googleUser: gapi.auth2.GoogleUser) { + // Useful data for your client-side scripts: + var profile = googleUser.getBasicProfile(); + console.log("ID: " + profile.getId()); // Don't send this directly to your server! + console.log('Full Name: ' + profile.getName()); + console.log('Given Name: ' + profile.getGivenName()); + console.log('Family Name: ' + profile.getFamilyName()); + console.log("Image URL: " + profile.getImageUrl()); + console.log("Email: " + profile.getEmail()); + + // The ID token you need to pass to your backend: + var id_token = googleUser.getAuthResponse().id_token; + console.log("ID Token: " + id_token); +}; + + +/* Example taken from https://github.com/google/google-api-javascript-client/blob/master/samples/authSample.html */ + +// Enter an API key from the Google API Console: +// https://console.developers.google.com/apis/credentials +var apiKey = 'YOUR_API_KEY'; +// Enter the API Discovery Docs that describes the APIs you want to +// access. In this example, we are accessing the People API, so we load +// Discovery Doc found here: https://developers.google.com/people/api/rest/ +var discoveryDocs = ["https://people.googleapis.com/$discovery/rest?version=v1"]; +// Enter a client ID for a web application from the Google API Console: +// https://console.developers.google.com/apis/credentials?project=_ +// In your API Console project, add a JavaScript origin that corresponds +// to the domain where you will be running the script. +var clientId = 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com'; +// Enter one or more authorization scopes. Refer to the documentation for +// the API or https://developers.google.com/people/v1/how-tos/authorizing +// for details. +var scopes = 'profile'; +var authorizeButton = document.getElementById('authorize-button'); +var signoutButton = document.getElementById('signout-button'); +function handleClientLoad() { + // Load the API client and auth2 library + gapi.load('client:auth2', initClient); +} +function initClient() { + gapi.client.init({ + apiKey: apiKey, + discoveryDocs: discoveryDocs, + clientId: clientId, + scope: scopes + }).then(function () { + // Listen for sign-in state changes. + gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus); + // Handle the initial sign-in state. + updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get()); + authorizeButton.onclick = handleAuthClick; + signoutButton.onclick = handleSignoutClick; + }); +} +function updateSigninStatus(isSignedIn: boolean) { + if (isSignedIn) { + authorizeButton.style.display = 'none'; + signoutButton.style.display = 'block'; + makeApiCall(); + } else { + authorizeButton.style.display = 'block'; + signoutButton.style.display = 'none'; + } +} +function handleAuthClick(event: MouseEvent) { + gapi.auth2.getAuthInstance().signIn(); +} +function handleSignoutClick(event: MouseEvent) { + gapi.auth2.getAuthInstance().signOut(); +} +// Load the API and make an API call. Display the results on the screen. +function makeApiCall() { + gapi.client.people.people.get({ + resourceName: 'people/me' + }).then(function(resp) { + var p = document.createElement('p'); + var name = resp.result.names[0].givenName; + p.appendChild(document.createTextNode('Hello, '+name+'!')); + document.getElementById('content').appendChild(p); + }); +} From 77af13e3b476ff344e90063a6787483bffa562ef Mon Sep 17 00:00:00 2001 From: Stefan Dobrev Date: Fri, 24 Feb 2017 11:04:40 +0200 Subject: [PATCH 018/150] [react-native] SubViewRenderer can return null SubViewRenderer could potentially return `null` along with JSX element. --- react-native/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-native/index.d.ts b/react-native/index.d.ts index 2f95939db6..60556d3d09 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -7635,7 +7635,7 @@ declare module "react" { onNavigateBack?(): void; } - type SubViewRenderer = (subViewProps: SubViewProps) => JSX.Element; + type SubViewRenderer = (subViewProps: SubViewProps) => JSX.Element | null; export interface NavigationHeaderProps extends NavigationSceneRendererProps { onNavigateBack?(): void, From 1dfe4c5dada036e164d2114a1cf3ebbb71224bf0 Mon Sep 17 00:00:00 2001 From: Jan Alonzo Date: Sat, 25 Feb 2017 15:55:05 +1100 Subject: [PATCH 019/150] Remove localforage and point to upstream typings instead --- localforage/index.d.ts | 115 ------------------------------ localforage/localforage-tests.ts | 117 ------------------------------- localforage/package.json | 5 ++ localforage/tsconfig.json | 23 ------ notNeededPackages.json | 8 ++- 5 files changed, 12 insertions(+), 256 deletions(-) delete mode 100644 localforage/index.d.ts delete mode 100644 localforage/localforage-tests.ts create mode 100644 localforage/package.json delete mode 100644 localforage/tsconfig.json diff --git a/localforage/index.d.ts b/localforage/index.d.ts deleted file mode 100644 index d0194ec60f..0000000000 --- a/localforage/index.d.ts +++ /dev/null @@ -1,115 +0,0 @@ -// Type definitions for Mozilla's localForage -// Project: https://github.com/mozilla/localforage -// Definitions by: yuichi david pichsenmeister -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface LocalForageOptions { - driver?: string | LocalForageDriver | LocalForageDriver[]; - - name?: string; - - size?: number; - - storeName?: string; - - version?: number; - - description?: string; -} - -interface LocalForageDbMethods { - getItem(key: string): Promise; - getItem(key: string, callback: (err: any, value: T) => void): void; - - setItem(key: string, value: T): Promise; - setItem(key: string, value: T, callback: (err: any, value: T) => void): void; - - removeItem(key: string): Promise; - removeItem(key: string, callback: (err: any) => void): void; - - clear(): Promise; - clear(callback: (err: any) => void): void; - - length(): Promise; - length(callback: (err: any, numberOfKeys: number) => void): void; - - key(keyIndex: number): Promise; - key(keyIndex: number, callback: (err: any, key: string) => void): void; - - keys(): Promise; - keys(callback: (err: any, keys: string[]) => void): void; - - iterate(iteratee: (value: any, key: string, iterationNumber: number) => any): Promise; - iterate(iteratee: (value: any, key: string, iterationNumber: number) => any, - callback: (err: any, result: any) => void): void; -} - -interface LocalForageDriverSupportFunc { - (): Promise; -} - -interface LocalForageDriver extends LocalForageDbMethods { - _driver: string; - - _initStorage(options: LocalForageOptions): void; - - _support?: boolean | LocalForageDriverSupportFunc; -} - -interface LocalForageSerializer { - serialize(value: T | ArrayBuffer | Blob, callback: (value: string, error: any) => void): void; - - deserialize(value: string): T | ArrayBuffer | Blob; - - stringToBuffer(serializedString: string): ArrayBuffer; - - bufferToString(buffer: ArrayBuffer): string; -} - -interface LocalForage extends LocalForageDbMethods { - LOCALSTORAGE: string; - WEBSQL: string; - INDEXEDDB: string; - - /** - * Set and persist localForage options. This must be called before any other calls to localForage are made, but can be called after localForage is loaded. - * If you set any config values with this method they will persist after driver changes, so you can call config() then setDriver() - * @param {LocalForageOptions} options? - */ - config(options: LocalForageOptions): boolean; - - /** - * Create a new instance of localForage to point to a different store. - * All the configuration options used by config are supported. - * @param {LocalForageOptions} options - */ - createInstance(options: LocalForageOptions): LocalForage; - - driver(): string; - /** - * Force usage of a particular driver or drivers, if available. - * @param {string} driver - */ - setDriver(driver: string | string[]): Promise; - setDriver(driver: string | string[], callback: () => void, errorCallback: (error: any) => void): void; - defineDriver(driver: LocalForageDriver): Promise; - defineDriver(driver: LocalForageDriver, callback: () => void, errorCallback: (error: any) => void): void; - /** - * Return a particular driver - * @param {string} driver - */ - getDriver(driver: string): Promise; - - getSerializer(): Promise; - getSerializer(callback: (serializer: LocalForageSerializer) => void): void; - - supports(driverName: string): boolean; - - ready(callback: () => void): void; - ready(): Promise; -} - -declare module "localforage" { - let localforage: LocalForage; - export = localforage; -} diff --git a/localforage/localforage-tests.ts b/localforage/localforage-tests.ts deleted file mode 100644 index e3edeba2d0..0000000000 --- a/localforage/localforage-tests.ts +++ /dev/null @@ -1,117 +0,0 @@ - - -declare let localForage: LocalForage; - -namespace LocalForageTest { - localForage.clear((err: any) => { - let newError: any = err; - }); - - localForage.iterate((str: string, key: string, num: number) => { - let newStr: string = str; - let newKey: string = key; - let newNum: number = num; - }); - - localForage.length((err: any, num: number) => { - let newError: any = err; - let newNumber: number = num; - }); - - localForage.length().then((num: number) => { - var newNumber: number = num; - }); - - localForage.key(0, (err: any, value: string) => { - let newError: any = err; - let newValue: string = value; - }); - - localForage.keys((err: any, keys: Array) => { - let newError: any = err; - let newArray: Array = keys; - }); - - localForage.keys().then((keys: Array) => { - var newArray: Array = keys; - }); - - localForage.getItem("key",(err: any, str: string) => { - let newError: any = err; - let newStr: string = str - }); - - localForage.getItem("key").then((str: string) => { - let newStr: string = str; - }); - - localForage.setItem("key", "value",(err: any, str: string) => { - let newError: any = err; - let newStr: string = str - }); - - localForage.setItem("key", "value").then((str: string) => { - let newStr: string = str; - }); - - localForage.removeItem("key",(err: any) => { - let newError: any = err; - }); - - localForage.removeItem("key").then(() => { - }); - - localForage.getDriver("CustomDriver").then((result: LocalForageDriver) => { - var driver: LocalForageDriver = result; - // we need to use a variable for proper type guards before TS 2.0 - var _support = driver._support; - if (typeof _support === "function") { - // _support = _support.bind(driver); - _support().then((result: boolean) => { - let doesSupport: boolean = result; - }); - } else if (typeof _support === "boolean") { - let doesSupport: boolean = _support; - } - }); - - { - let config: boolean; - - config = localForage.config({ - name: "testyo", - driver: localForage.LOCALSTORAGE - }); - } - - { - let store: LocalForage; - - store = localForage.createInstance({ - name: "da instance", - driver: localForage.LOCALSTORAGE - }); - } - - { - let testSerializer: LocalForageSerializer; - - localForage.getSerializer() - .then((serializer: LocalForageSerializer) => { - testSerializer = serializer; - }); - - localForage.getSerializer((serializer: LocalForageSerializer) => { - testSerializer = serializer; - }); - } - - { - let store: LocalForage; - - store.ready() - .then(() => {}); - - store.ready(() => {}); - } -} \ No newline at end of file diff --git a/localforage/package.json b/localforage/package.json new file mode 100644 index 0000000000..29f45814b2 --- /dev/null +++ b/localforage/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "localforage": ">=1.5.0" + } +} diff --git a/localforage/tsconfig.json b/localforage/tsconfig.json deleted file mode 100644 index 1e3cbf9e63..0000000000 --- a/localforage/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "localforage-tests.ts" - ] -} \ No newline at end of file diff --git a/notNeededPackages.json b/notNeededPackages.json index 0cd56b96d1..bcdf36987a 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -305,6 +305,12 @@ "typingsPackageName": "gaea-model", "sourceRepoURL": "https://github.com/ascoders/gaea-model", "asOfVersion": "0.0.0" + }, + { + "libraryName": "localforage", + "typingsPackageName": "localforage", + "sourceRepoURL": "https://github.com/localForage/localForage", + "asOfVersion": "0.0.34" } ] -} +} \ No newline at end of file From a8059edc7aab2c3ac955fb6049209c102fd3db86 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sat, 25 Feb 2017 12:55:26 -0500 Subject: [PATCH 020/150] placeId => placeid As per https://developers.google.com/places/web-service/details --- googlemaps/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemaps/index.d.ts b/googlemaps/index.d.ts index 06eba68a94..d4d0935717 100644 --- a/googlemaps/index.d.ts +++ b/googlemaps/index.d.ts @@ -2258,7 +2258,7 @@ declare namespace google.maps { } export interface PlaceDetailsRequest { - placeId: string; + placeid: string; } export interface PlaceGeometry { From 01ad861c95798ff83d7f5a05eefafd8bace185ac Mon Sep 17 00:00:00 2001 From: Diogo Sant'Ana Date: Sat, 25 Feb 2017 21:46:31 -0300 Subject: [PATCH 021/150] Update chart.js Chart constructor from v2.4.0 Version 2.4.0 new Chart constructor signature https://github.com/chartjs/Chart.js/commit/4a5b5a0e7eba85ca44f658375cb0c78e6af93e5c --- chart.js/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index 08781f4463..d21fc3ec80 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -5,7 +5,10 @@ declare class Chart { static readonly Chart: typeof Chart; - constructor(context: CanvasRenderingContext2D | HTMLCanvasElement, options: Chart.ChartConfiguration); + constructor( + context: string | JQuery | CanvasRenderingContext2D | HTMLCanvasElement | string[] | CanvasRenderingContext2D[] | HTMLCanvasElement[], + options: Chart.ChartConfiguration + ); config: Chart.ChartConfiguration; data: Chart.ChartData; destroy: () => {}; From 279fcd17bcf56d08b1dfa423cf62381f5a1bf8f5 Mon Sep 17 00:00:00 2001 From: Diogo Sant'Ana Date: Sat, 25 Feb 2017 22:00:25 -0300 Subject: [PATCH 022/150] Added jquery import declaration --- chart.js/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index d21fc3ec80..c103ab40ec 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Alberto Nuti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + declare class Chart { static readonly Chart: typeof Chart; constructor( From e45de33a3f658465e6c96a6b686eea9afc49757e Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Thu, 23 Feb 2017 15:32:05 +0100 Subject: [PATCH 023/150] Add generic parameter to Matchers --- jasmine/index.d.ts | 55 ++++-- jasmine/jasmine-tests.ts | 391 ++++++++++++++++++++------------------- 2 files changed, 233 insertions(+), 213 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index 146ab55ad4..78fea75ec2 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -24,8 +24,9 @@ declare function afterEach(action: (done: DoneFn) => void, timeout?: number): vo declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void; declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void; -declare function expect(spy: Function): jasmine.Matchers; -declare function expect(actual: any): jasmine.Matchers; +declare function expect>(actual: ArrayLike): jasmine.ArrayLikeMatchers; +declare function expect(actual: T): jasmine.Matchers; +declare function expect(spy: Function): jasmine.Matchers; declare function fail(e?: any): void; /** Action method that should be called when the async work is complete */ @@ -43,23 +44,33 @@ declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, t declare function waits(timeout?: number): void; declare namespace jasmine { + type Expected = T | ObjectContaining | Any | Spy; var clock: () => Clock; function any(aclass: any): Any; + function anything(): Any; + function arrayContaining(sample: any[]): ArrayContaining; function objectContaining(sample: Partial): ObjectContaining; function createSpy(name: string, originalFn?: Function): Spy; + function createSpyObj(baseName: string, methodNames: any[]): any; function createSpyObj(baseName: string, methodNames: any[]): T; + function pp(value: any): string; + function getEnv(): Env; + function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; + function addMatchers(matchers: CustomMatcherFactories): void; + function stringMatching(str: string): Any; function stringMatching(str: RegExp): Any; - function formatErrorMsg(domain: string, usage: string) : (msg: string) => string + + function formatErrorMsg(domain: string, usage: string): (msg: string) => string interface Any { @@ -83,7 +94,7 @@ declare namespace jasmine { } interface ObjectContaining { - new (sample: Partial): T; + new (sample: Partial): Partial; jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; jasmineToString(): string; @@ -150,7 +161,7 @@ declare namespace jasmine { currentSpec: Spec; - matchersClass: Matchers; + matchersClass: Matchers; version(): any; versionString(): string; @@ -224,12 +235,12 @@ declare namespace jasmine { passed(): boolean; } - interface MessageResult extends Result { + interface MessageResult extends Result { values: any; trace: Trace; } - interface ExpectationResult extends Result { + interface ExpectationResult extends Result { matcherName: string; passed(): boolean; expected: any; @@ -242,12 +253,13 @@ declare namespace jasmine { new (options: {random: boolean, seed: string}): any; random: boolean; seed: string; - sort(items: T[]) : T[]; + sort(items: T[]): T[]; } namespace errors { class ExpectationFailed extends Error { constructor(); + stack: any; } } @@ -255,7 +267,7 @@ declare namespace jasmine { interface TreeProcessor { new (attrs: any): any; execute: (done: Function) => void; - processTree() : any; + processTree(): any; } interface Trace { @@ -301,18 +313,18 @@ declare namespace jasmine { results(): NestedResults; } - interface Matchers { + interface Matchers { - new (env: Env, actual: any, spec: Env, isNot?: boolean): any; + new (env: Env, actual: T, spec: Env, isNot?: boolean): any; env: Env; - actual: any; + actual: T; spec: Env; isNot?: boolean; message(): any; - toBe(expected: any, expectationFailOutput?: any): boolean; - toEqual(expected: any, expectationFailOutput?: any): boolean; + toBe(expected: Expected, expectationFailOutput?: any): boolean; + toEqual(expected: Expected, expectationFailOutput?: any): boolean; toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; toBeDefined(expectationFailOutput?: any): boolean; toBeUndefined(expectationFailOutput?: any): boolean; @@ -332,11 +344,18 @@ declare namespace jasmine { toThrow(expected?: any): boolean; toThrowError(message?: string | RegExp): boolean; toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean; - not: Matchers; + not: Matchers; Any: Any; } + interface ArrayLikeMatchers> extends Matchers { + toBe(expected: Expected>, expectationFailOutput?: any): boolean; + toEqual(expected: Expected>, expectationFailOutput?: any): boolean; + toContain(expected: T, expectationFailOutput?: any): boolean; + not: ArrayLikeMatchers; + } + interface Reporter { reportRunnerStarting(runner: Runner): void; reportRunnerResults(runner: Runner): void; @@ -433,7 +452,7 @@ declare namespace jasmine { spies_: Spy[]; results_: NestedResults; - matchersClass: Matchers; + matchersClass: Matchers; getFullName(): string; results(): NestedResults; @@ -446,7 +465,7 @@ declare namespace jasmine { waits(timeout: number): Spec; waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; fail(e?: any): void; - getMatchersClass_(): Matchers; + getMatchersClass_(): Matchers; addMatchers(matchersPrototype: CustomMatcherFactories): void; finishCallback(): void; finish(onComplete?: () => void): void; @@ -494,7 +513,7 @@ declare namespace jasmine { identity: string; and: SpyAnd; calls: Calls; - mostRecentCall: { args: any[]; }; + mostRecentCall: {args: any[];}; argsForCall: any[]; } diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index 13d80af9db..f841a613c5 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -1,34 +1,34 @@ // tests based on http://jasmine.github.io/2.2/introduction.html -describe("A suite", function () { - it("contains spec with an expectation", function () { +describe("A suite", function() { + it("contains spec with an expectation", function() { expect(true).toBe(true); }); }); -describe("A suite is just a function", function () { +describe("A suite is just a function", function() { var a: boolean; - it("and so is a spec", function () { + it("and so is a spec", function() { a = true; expect(a).toBe(true); }); }); -describe("The 'toBe' matcher compares with ===", function () { +describe("The 'toBe' matcher compares with ===", function() { - it("and has a positive case", function () { + it("and has a positive case", function() { expect(true).toBe(true); }); - it("and can have a negative case", function () { + it("and can have a negative case", function() { expect(false).not.toBe(true); }); }); -describe("Included matchers:", function () { +describe("Included matchers:", function() { - it("The 'toBe' matcher compares with ===", function () { + it("The 'toBe' matcher compares with ===", function() { var a = 12; var b = a; @@ -36,14 +36,14 @@ describe("Included matchers:", function () { expect(a).not.toBe(null); }); - describe("The 'toEqual' matcher", function () { + describe("The 'toEqual' matcher", function() { - it("works for simple literals and variables", function () { + it("works for simple literals and variables", function() { var a = 12; expect(a).toEqual(12); }); - it("should work for objects", function () { + it("should work for objects", function() { var foo = { a: 12, b: 34 @@ -56,7 +56,7 @@ describe("Included matchers:", function () { }); }); - it("The 'toMatch' matcher is for regular expressions", function () { + it("The 'toMatch' matcher is for regular expressions", function() { var message = "foo bar baz"; expect(message).toMatch(/bar/); @@ -64,7 +64,7 @@ describe("Included matchers:", function () { expect(message).not.toMatch(/quux/); }); - it("The 'toBeDefined' matcher compares against `undefined`", function () { + it("The 'toBeDefined' matcher compares against `undefined`", function() { var a = { foo: "foo" }; @@ -73,16 +73,16 @@ describe("Included matchers:", function () { expect((a).bar).not.toBeDefined(); }); - it("The `toBeUndefined` matcher compares against `undefined`", function () { + it("The `toBeUndefined` matcher compares against `undefined`", function() { var a = { foo: "foo" }; expect(a.foo).not.toBeUndefined(); - expect((a).bar).toBeUndefined(); + expect((a as any).bar).toBeUndefined(); }); - it("The 'toBeNull' matcher compares against null", function () { + it("The 'toBeNull' matcher compares against null", function() { var a: string = null; var foo = "foo"; @@ -91,28 +91,28 @@ describe("Included matchers:", function () { expect(foo).not.toBeNull(); }); - it("The 'toBeTruthy' matcher is for boolean casting testing", function () { + it("The 'toBeTruthy' matcher is for boolean casting testing", function() { var a: string, foo = "foo"; expect(foo).toBeTruthy(); expect(a).not.toBeTruthy(); }); - it("The 'toBeFalsy' matcher is for boolean casting testing", function () { + it("The 'toBeFalsy' matcher is for boolean casting testing", function() { var a: string, foo = "foo"; expect(a).toBeFalsy(); expect(foo).not.toBeFalsy(); }); - it("The 'toContain' matcher is for finding an item in an Array", function () { + it("The 'toContain' matcher is for finding an item in an Array", function() { var a = ["foo", "bar", "baz"]; - expect(a).toContain("bar"); + expect(a).toContain('foo'); expect(a).not.toContain("quux"); }); - it("The 'toBeLessThan' matcher is for mathematical comparisons", function () { + it("The 'toBeLessThan' matcher is for mathematical comparisons", function() { var pi = 3.1415926, e = 2.78; @@ -120,7 +120,7 @@ describe("Included matchers:", function () { expect(pi).not.toBeLessThan(e); }); - it("The 'toBeGreaterThan' is for mathematical comparisons", function () { + it("The 'toBeGreaterThan' is for mathematical comparisons", function() { var pi = 3.1415926, e = 2.78; @@ -128,7 +128,7 @@ describe("Included matchers:", function () { expect(e).not.toBeGreaterThan(pi); }); - it("The 'toBeCloseTo' matcher is for precision math comparison", function () { + it("The 'toBeCloseTo' matcher is for precision math comparison", function() { var pi = 3.1415926, e = 2.78; @@ -136,11 +136,11 @@ describe("Included matchers:", function () { expect(pi).toBeCloseTo(e, 0); }); - it("The 'toThrow' matcher is for testing if a function throws an exception", function () { - var foo = function () { + it("The 'toThrow' matcher is for testing if a function throws an exception", function() { + var foo = function() { return 1 + 2; }; - var bar = function () { + var bar = function() { var a: any = undefined; return a + 1; }; @@ -161,15 +161,15 @@ describe("Included matchers:", function () { }); }); -describe("A spec", function () { - it("is just a function, so it can contain any code", function () { +describe("A spec", function() { + it("is just a function, so it can contain any code", function() { var foo = 0; foo += 1; expect(foo).toEqual(1); }); - it("can have more than one expectation", function () { + it("can have more than one expectation", function() { var foo = 0; foo += 1; @@ -178,94 +178,94 @@ describe("A spec", function () { }); }); -describe("A spec (with setup and tear-down)", function () { +describe("A spec (with setup and tear-down)", function() { var foo: number; - beforeEach(function () { + beforeEach(function() { foo = 0; foo += 1; }); - afterEach(function () { + afterEach(function() { foo = 0; }); - it("is just a function, so it can contain any code", function () { + it("is just a function, so it can contain any code", function() { expect(foo).toEqual(1); }); - it("can have more than one expectation", function () { + it("can have more than one expectation", function() { expect(foo).toEqual(1); expect(true).toEqual(true); }); }); -describe("A spec", function () { +describe("A spec", function() { var foo: number; - beforeEach(function () { + beforeEach(function() { foo = 0; foo += 1; }); - afterEach(function () { + afterEach(function() { foo = 0; }); - it("is just a function, so it can contain any code", function () { + it("is just a function, so it can contain any code", function() { expect(foo).toEqual(1); }); - it("can have more than one expectation", function () { + it("can have more than one expectation", function() { expect(foo).toEqual(1); expect(true).toEqual(true); }); - describe("nested inside a second describe", function () { + describe("nested inside a second describe", function() { var bar: number; - beforeEach(function () { + beforeEach(function() { bar = 1; }); - it("can reference both scopes as needed", function () { + it("can reference both scopes as needed", function() { expect(foo).toEqual(bar); }); }); }); -xdescribe("A spec", function () { +xdescribe("A spec", function() { var foo: number; - beforeEach(function () { + beforeEach(function() { foo = 0; foo += 1; }); - it("is just a function, so it can contain any code", function () { + it("is just a function, so it can contain any code", function() { expect(foo).toEqual(1); }); }); -describe("Pending specs", function () { +describe("Pending specs", function() { - xit("can be declared 'xit'", function () { + xit("can be declared 'xit'", function() { expect(true).toBe(false); }); it("can be declared with 'it' but without a function"); - it("can be declared by calling 'pending' in the spec body", function () { + it("can be declared by calling 'pending' in the spec body", function() { expect(true).toBe(false); pending(); // without reason pending('this is why it is pending'); }); }); -describe("A spy", function () { +describe("A spy", function() { var foo: any, bar: any = null; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; @@ -278,29 +278,29 @@ describe("A spy", function () { foo.setBar(456, 'another param'); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.setBar).toHaveBeenCalled(); }); - it("tracks all the arguments of its calls", function () { + it("tracks all the arguments of its calls", function() { expect(foo.setBar).toHaveBeenCalledWith(123); expect(foo.setBar).toHaveBeenCalledWith(456, 'another param'); }); - it("stops all execution on a function", function () { + it("stops all execution on a function", function() { expect(bar).toBeNull(); }); }); -describe("A spy, when configured to call through", function () { +describe("A spy, when configured to call through", function() { var foo: any, bar: any, fetchedBar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; }, - getBar: function () { + getBar: function() { return bar; } }; @@ -311,28 +311,28 @@ describe("A spy, when configured to call through", function () { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function () { + it("should not effect other functions", function() { expect(bar).toEqual(123); }); - it("when called returns the requested value", function () { + it("when called returns the requested value", function() { expect(fetchedBar).toEqual(123); }); }); -describe("A spy, when configured to fake a return value", function () { +describe("A spy, when configured to fake a return value", function() { var foo: any, bar: any, fetchedBar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; }, - getBar: function () { + getBar: function() { return bar; } }; @@ -343,15 +343,15 @@ describe("A spy, when configured to fake a return value", function () { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function () { + it("should not effect other functions", function() { expect(bar).toEqual(123); }); - it("when called returns the requested value", function () { + it("when called returns the requested value", function() { expect(fetchedBar).toEqual(745); }); }); @@ -361,7 +361,7 @@ describe("A spy, when configured to fake a series of return values", function() beforeEach(function() { foo = { - setBar: function(value: any) { + setBar: function (value: any) { bar = value; }, getBar: function() { @@ -390,20 +390,20 @@ describe("A spy, when configured to fake a series of return values", function() }); }); -describe("A spy, when configured with an alternate implementation", function () { +describe("A spy, when configured with an alternate implementation", function() { var foo: any, bar: any, fetchedBar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; }, - getBar: function () { + getBar: function() { return bar; } }; - spyOn(foo, "getBar").and.callFake(function () { + spyOn(foo, "getBar").and.callFake(function() { return 1001; }); @@ -411,23 +411,23 @@ describe("A spy, when configured with an alternate implementation", function () fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function () { + it("should not effect other functions", function() { expect(bar).toEqual(123); }); - it("when called returns the requested value", function () { + it("when called returns the requested value", function() { expect(fetchedBar).toEqual(1001); }); }); -describe("A spy, when configured to throw a value", function () { +describe("A spy, when configured to throw a value", function() { var foo: any, bar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; @@ -437,55 +437,55 @@ describe("A spy, when configured to throw a value", function () { spyOn(foo, "setBar").and.throwError("quux"); }); - it("throws the value", function () { - expect(function () { + it("throws the value", function() { + expect(function() { foo.setBar(123) - }).toThrowError("quux"); + }).toThrowError("quux"); }); }); -describe("A spy, when configured with multiple actions", function () { +describe("A spy, when configured with multiple actions", function() { var foo: any, bar: any, fetchedBar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; }, - getBar: function () { + getBar: function() { return bar; } }; spyOn(foo, 'getBar').and.callThrough().and.callFake(() => { - this.fakeCalled = true; + this.fakeCalled = true; }); foo.setBar(123); fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function () { + it("should not effect other functions", function() { expect(bar).toEqual(123); }); - it("when called returns the requested value", function () { + it("when called returns the requested value", function() { expect(fetchedBar).toEqual(123); }); - it("should have called the fake implementation", function () { + it("should have called the fake implementation", function() { expect(this.fakeCalled).toEqual(true); }); }); -describe("A spy", function () { +describe("A spy", function() { var foo: any, bar: any = null; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; @@ -495,7 +495,7 @@ describe("A spy", function () { spyOn(foo, 'setBar').and.callThrough(); }); - it("can call through and then stub in the same spec", function () { + it("can call through and then stub in the same spec", function() { foo.setBar(123); expect(bar).toEqual(123); @@ -507,10 +507,10 @@ describe("A spy", function () { }); }); -describe("A spy", function () { +describe("A spy", function() { var foo: any, bar: any = null; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; @@ -520,7 +520,7 @@ describe("A spy", function () { spyOn(foo, 'setBar'); }); - it("tracks if it was called at all", function () { + it("tracks if it was called at all", function() { expect(foo.setBar.calls.any()).toEqual(false); foo.setBar(); @@ -528,7 +528,7 @@ describe("A spy", function () { expect(foo.setBar.calls.any()).toEqual(true); }); - it("tracks the number of times it was called", function () { + it("tracks the number of times it was called", function() { expect(foo.setBar.calls.count()).toEqual(0); foo.setBar(); @@ -537,7 +537,7 @@ describe("A spy", function () { expect(foo.setBar.calls.count()).toEqual(2); }); - it("tracks the arguments of each call", function () { + it("tracks the arguments of each call", function() { foo.setBar(123); foo.setBar(456, "baz"); @@ -545,34 +545,34 @@ describe("A spy", function () { expect(foo.setBar.calls.argsFor(1)).toEqual([456, "baz"]); }); - it("tracks the arguments of all calls", function () { + it("tracks the arguments of all calls", function() { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.allArgs()).toEqual([[123], [456, "baz"]]); }); - it("can provide the context and arguments to all calls", function () { + it("can provide the context and arguments to all calls", function() { foo.setBar(123); expect(foo.setBar.calls.all()).toEqual([{ object: foo, args: [123], returnValue: undefined }]); }); - it("has a shortcut to the most recent call", function () { + it("has a shortcut to the most recent call", function() { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.mostRecent()).toEqual({ object: foo, args: [456, "baz"], returnValue: undefined }); }); - it("has a shortcut to the first call", function () { + it("has a shortcut to the first call", function() { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.first()).toEqual({ object: foo, args: [123], returnValue: undefined }); }); - it("can be reset", function () { + it("can be reset", function() { foo.setBar(123); foo.setBar(456, "baz"); @@ -584,40 +584,40 @@ describe("A spy", function () { }); }); -describe("A spy, when created manually", function () { +describe("A spy, when created manually", function() { var whatAmI: any; - beforeEach(function () { + beforeEach(function() { whatAmI = jasmine.createSpy('whatAmI'); whatAmI("I", "am", "a", "spy"); }); - it("is named, which helps in error reporting", function () { + it("is named, which helps in error reporting", function() { expect(whatAmI.and.identity()).toEqual('whatAmI'); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(whatAmI).toHaveBeenCalled(); }); - it("tracks its number of calls", function () { + it("tracks its number of calls", function() { expect(whatAmI.calls.count()).toEqual(1); }); - it("tracks all the arguments of its calls", function () { + it("tracks all the arguments of its calls", function() { expect(whatAmI).toHaveBeenCalledWith("I", "am", "a", "spy"); }); - it("allows access to the most recent call", function () { + it("allows access to the most recent call", function() { expect(whatAmI.calls.mostRecent().args[0]).toEqual("I"); }); }); -describe("Multiple spies, when created manually", function () { +describe("Multiple spies, when created manually", function() { var tape: any; - beforeEach(function () { + beforeEach(function() { tape = jasmine.createSpyObj('tape', ['play', 'pause', 'stop', 'rewind']); tape.play(); @@ -625,35 +625,35 @@ describe("Multiple spies, when created manually", function () { tape.rewind(0); }); - it("creates spies for each requested function", function () { + it("creates spies for each requested function", function() { expect(tape.play).toBeDefined(); expect(tape.pause).toBeDefined(); expect(tape.stop).toBeDefined(); expect(tape.rewind).toBeDefined(); }); - it("tracks that the spies were called", function () { + it("tracks that the spies were called", function() { expect(tape.play).toHaveBeenCalled(); expect(tape.pause).toHaveBeenCalled(); expect(tape.rewind).toHaveBeenCalled(); expect(tape.stop).not.toHaveBeenCalled(); }); - it("tracks all the arguments of its calls", function () { + it("tracks all the arguments of its calls", function() { expect(tape.rewind).toHaveBeenCalledWith(0); }); }); -describe("jasmine.any", function () { - it("matches any value", function () { +describe("jasmine.any", function() { + it("matches any value", function() { expect({}).toEqual(jasmine.any(Object)); expect(12).toEqual(jasmine.any(Number)); }); - describe("when used with a spy", function () { - it("is useful for comparing arguments", function () { + describe("when used with a spy", function() { + it("is useful for comparing arguments", function() { var foo = jasmine.createSpy('foo'); - foo(12, function () { + foo(12, function() { return true; }); @@ -662,15 +662,15 @@ describe("jasmine.any", function () { }); }); -describe("jasmine.objectContaining", function () { +describe("jasmine.objectContaining", function() { interface fooType { - a:number; - b:number; - bar:string; + a: number; + b: number; + bar: string; } var foo: fooType; - beforeEach(function () { + beforeEach(function() { foo = { a: 1, b: 2, @@ -678,17 +678,18 @@ describe("jasmine.objectContaining", function () { }; }); - it("matches objects with the expect key/value pairs", function () { + it("matches objects with the expect key/value pairs", function() { expect(foo).toEqual(jasmine.objectContaining({ - bar: "baz" + bar: '' })); - expect(foo).not.toEqual(jasmine.objectContaining({ + + expect(foo).not.toEqual(jasmine.objectContaining({ a: 37 })); }); - describe("when used with a spy", function () { - it("is useful for comparing arguments", function () { + describe("when used with a spy", function() { + it("is useful for comparing arguments", function() { var callback = jasmine.createSpy('callback'); callback({ @@ -706,43 +707,43 @@ describe("jasmine.objectContaining", function () { }); describe("jasmine.arrayContaining", function() { - var foo: any; + var foo: any; - beforeEach(function() { - foo = [1, 2, 3, 4]; - }); + beforeEach(function() { + foo = [1, 2, 3, 4]; + }); - it("matches arrays with some of the values", function() { - expect(foo).toEqual(jasmine.arrayContaining([3, 1])); - expect(foo).not.toEqual(jasmine.arrayContaining([6])); - }); + it("matches arrays with some of the values", function() { + expect(foo).toEqual(jasmine.arrayContaining([3, 1])); + expect(foo).not.toEqual(jasmine.arrayContaining([6])); + }); - describe("when used with a spy", function() { - it("is useful when comparing arguments", function() { - var callback = jasmine.createSpy('callback'); + describe("when used with a spy", function() { + it("is useful when comparing arguments", function() { + var callback = jasmine.createSpy('callback'); - callback([1, 2, 3, 4]); + callback([1, 2, 3, 4]); - expect(callback).toHaveBeenCalledWith(jasmine.arrayContaining([4, 2, 3])); - expect(callback).not.toHaveBeenCalledWith(jasmine.arrayContaining([5, 2])); + expect(callback).toHaveBeenCalledWith(jasmine.arrayContaining([4, 2, 3])); + expect(callback).not.toHaveBeenCalledWith(jasmine.arrayContaining([5, 2])); + }); }); - }); }); -describe("Manually ticking the Jasmine Clock", function () { +describe("Manually ticking the Jasmine Clock", function() { var timerCallback: any; - beforeEach(function () { + beforeEach(function() { timerCallback = jasmine.createSpy("timerCallback"); jasmine.clock().install(); }); - afterEach(function () { + afterEach(function() { jasmine.clock().uninstall(); }); - it("causes a timeout to be called synchronously", function () { - setTimeout(function () { + it("causes a timeout to be called synchronously", function() { + setTimeout(function() { timerCallback(); }, 100); @@ -753,8 +754,8 @@ describe("Manually ticking the Jasmine Clock", function () { expect(timerCallback).toHaveBeenCalled(); }); - it("causes an interval to be called synchronously", function () { - setInterval(function () { + it("causes an interval to be called synchronously", function() { + setInterval(function() { timerCallback(); }, 100); @@ -770,7 +771,7 @@ describe("Manually ticking the Jasmine Clock", function () { expect(timerCallback.calls.count()).toEqual(2); }); - describe("Mocking the Date object", function(){ + describe("Mocking the Date object", function() { it("mocks the Date object and sets it to a given time", function() { var baseTime = new Date(2013, 9, 23); @@ -782,10 +783,10 @@ describe("Manually ticking the Jasmine Clock", function () { }); }); -describe("Asynchronous specs", function () { +describe("Asynchronous specs", function() { var value: number; beforeEach(function (done: DoneFn) { - setTimeout(function () { + setTimeout(function() { value = 0; done(); }, 1); @@ -798,42 +799,42 @@ describe("Asynchronous specs", function () { }); describe("long asynchronous specs", function() { - beforeEach(function(done: DoneFn) { - done(); + beforeEach(function (done: DoneFn) { + done(); }, 1000); - it("takes a long time", function(done: DoneFn) { - setTimeout(function() { - done(); - }, 9000); + it("takes a long time", function (done: DoneFn) { + setTimeout(function() { + done(); + }, 9000); }, 10000); - afterEach(function(done: DoneFn) { - done(); + afterEach(function (done: DoneFn) { + done(); }, 1000); }); }); -describe("Fail", function () { +describe("Fail", function() { - it("should fail test when called without arguments", function () { - fail(); - }); + it("should fail test when called without arguments", function() { + fail(); + }); - it("should fail test when called with a fail message", function () { - fail("The test failed"); - }); + it("should fail test when called with a fail message", function() { + fail("The test failed"); + }); - it("should fail test when called an error", function () { - fail(new Error("The test failed with this error")); - }); + it("should fail test when called an error", function() { + fail(new Error("The test failed with this error")); + }); }); // test based on http://jasmine.github.io/2.2/custom_equality.html describe("custom equality", function() { - var myCustomEquality: jasmine.CustomEqualityTester = function(first: any, second: any): boolean { + var myCustomEquality: jasmine.CustomEqualityTester = function (first: any, second: any): boolean { if (typeof first == "string" && typeof second == "string") { return first[0] == second[1]; } @@ -886,29 +887,29 @@ var customMatchers: jasmine.CustomMatcherFactories = { // } // } declare namespace jasmine { - interface Matchers { - toBeGoofy(expected?: any): boolean; + interface Matchers { + toBeGoofy(expected?: jasmine.Expected): boolean; } } -describe("Custom matcher: 'toBeGoofy'", function () { - beforeEach(function () { +describe("Custom matcher: 'toBeGoofy'", function() { + beforeEach(function() { jasmine.addMatchers(customMatchers); }); - it("is available on an expectation", function () { + it("is available on an expectation", function() { expect({ hyuk: 'gawrsh' }).toBeGoofy(); }); - it("can take an 'expected' parameter", function () { + it("can take an 'expected' parameter", function() { expect({ hyuk: 'gawrsh is fun' - }).toBeGoofy(' is fun'); + }).toBeGoofy({ hyuk: ' is fun' }); }); - it("can be negated", function () { + it("can be negated", function() { expect({ hyuk: 'this is fun' }).not.toBeGoofy(); @@ -917,7 +918,7 @@ describe("Custom matcher: 'toBeGoofy'", function () { // test based on http://jasmine.github.io/2.5/custom_reporter.html var myReporter: jasmine.CustomReporter = { - jasmineStarted: function (suiteInfo: jasmine.SuiteInfo ) { + jasmineStarted: function (suiteInfo: jasmine.SuiteInfo) { console.log("Running suite with " + suiteInfo.totalSpecsDefined); }, @@ -948,7 +949,7 @@ var myReporter: jasmine.CustomReporter = { } }, - jasmineDone: function(runDetails: jasmine.RunDetails) { + jasmineDone: function (runDetails: jasmine.RunDetails) { console.log('Finished suite'); console.log('Random:', runDetails.order.random); } @@ -957,20 +958,20 @@ var myReporter: jasmine.CustomReporter = { jasmine.getEnv().addReporter(myReporter); describe("Randomize Tests", function() { - it("should allow randomization of the order of tests", function() { - expect(function() { - var env = jasmine.getEnv(); - return env.randomizeTests(true); - }).not.toThrow(); - }); + it("should allow randomization of the order of tests", function() { + expect(function() { + var env = jasmine.getEnv(); + return env.randomizeTests(true); + }).not.toThrow(); + }); - it("should allow a seed to be passed in for randomization", function() { - expect(function() { - var env = jasmine.getEnv(); - env.randomizeTests(true); - return env.seed(1234); - }).not.toThrow(); - }); + it("should allow a seed to be passed in for randomization", function() { + expect(function() { + var env = jasmine.getEnv(); + env.randomizeTests(true); + return env.seed(1234); + }).not.toThrow(); + }); }); (() => { @@ -986,7 +987,7 @@ describe("Randomize Tests", function() { }; var currentWindowOnload = window.onload; - window.onload = function () { + window.onload = function() { if (currentWindowOnload) { (currentWindowOnload)(null); } From 5d864d9772c27269b06f0ecccc2cd88e98af9428 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Sun, 26 Feb 2017 12:29:39 +0100 Subject: [PATCH 024/150] Fix linter errors --- jasmine/index.d.ts | 34 ++-- jasmine/jasmine-tests.ts | 386 ++++++++++++++++++------------------ jasmine/v1/jasmine-tests.ts | 22 +- 3 files changed, 219 insertions(+), 223 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index 78fea75ec2..03c1e30c78 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -70,7 +70,7 @@ declare namespace jasmine { function stringMatching(str: string): Any; function stringMatching(str: RegExp): Any; - function formatErrorMsg(domain: string, usage: string): (msg: string) => string + function formatErrorMsg(domain: string, usage: string): (msg: string) => string; interface Any { @@ -124,18 +124,14 @@ declare namespace jasmine { withMock(func: () => void): void; } - interface CustomEqualityTester { - (first: any, second: any): boolean; - } + type CustomEqualityTester = (first: any, second: any) => boolean; interface CustomMatcher { compare(actual: T, expected: T): CustomMatcherResult; compare(actual: any, expected: any): CustomMatcherResult; } - interface CustomMatcherFactory { - (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher; - } + type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => CustomMatcher; interface CustomMatcherFactories { [index: string]: CustomMatcherFactory; @@ -147,9 +143,9 @@ declare namespace jasmine { } interface MatchersUtil { - equals(a: any, b: any, customTesters?: Array): boolean; - contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean; - buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string; + equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean; + contains(haystack: ArrayLike | string, needle: any, customTesters?: CustomEqualityTester[]): boolean; + buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string; } interface Env { @@ -390,18 +386,18 @@ declare namespace jasmine { } interface CustomReporterResult { - description: string, - failedExpectations?: FailedExpectation[], - fullName: string, + description: string; + failedExpectations?: FailedExpectation[]; + fullName: string; id: string; - passedExpectations?: PassedExpectation[], + passedExpectations?: PassedExpectation[]; pendingReason?: string; status?: string; } interface RunDetails { failedExpectations: ExpectationResult[]; - order: jasmine.Order + order: jasmine.Order; } interface CustomReporter { @@ -431,9 +427,7 @@ declare namespace jasmine { results(): NestedResults; } - interface SpecFunction { - (spec?: Spec): void; - } + type SpecFunction = (spec?: Spec) => void; interface SuiteOrSpec { id: number; @@ -513,7 +507,7 @@ declare namespace jasmine { identity: string; and: SpyAnd; calls: Calls; - mostRecentCall: {args: any[];}; + mostRecentCall: {args: any[]; }; argsForCall: any[]; } @@ -574,7 +568,7 @@ declare namespace jasmine { finished: boolean; result: any; messages: any; - runDetails: RunDetails + runDetails: RunDetails; new (): any; diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index f841a613c5..e80060510b 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -1,34 +1,34 @@ // tests based on http://jasmine.github.io/2.2/introduction.html -describe("A suite", function() { - it("contains spec with an expectation", function() { +describe("A suite", () => { + it("contains spec with an expectation", () => { expect(true).toBe(true); }); }); -describe("A suite is just a function", function() { +describe("A suite is just a function", () => { var a: boolean; - it("and so is a spec", function() { + it("and so is a spec", () => { a = true; expect(a).toBe(true); }); }); -describe("The 'toBe' matcher compares with ===", function() { +describe("The 'toBe' matcher compares with ===", () => { - it("and has a positive case", function() { + it("and has a positive case", () => { expect(true).toBe(true); }); - it("and can have a negative case", function() { + it("and can have a negative case", () => { expect(false).not.toBe(true); }); }); -describe("Included matchers:", function() { +describe("Included matchers:", () => { - it("The 'toBe' matcher compares with ===", function() { + it("The 'toBe' matcher compares with ===", () => { var a = 12; var b = a; @@ -36,14 +36,14 @@ describe("Included matchers:", function() { expect(a).not.toBe(null); }); - describe("The 'toEqual' matcher", function() { + describe("The 'toEqual' matcher", () => { - it("works for simple literals and variables", function() { + it("works for simple literals and variables", () => { var a = 12; expect(a).toEqual(12); }); - it("should work for objects", function() { + it("should work for objects", () => { var foo = { a: 12, b: 34 @@ -56,7 +56,7 @@ describe("Included matchers:", function() { }); }); - it("The 'toMatch' matcher is for regular expressions", function() { + it("The 'toMatch' matcher is for regular expressions", () => { var message = "foo bar baz"; expect(message).toMatch(/bar/); @@ -64,16 +64,16 @@ describe("Included matchers:", function() { expect(message).not.toMatch(/quux/); }); - it("The 'toBeDefined' matcher compares against `undefined`", function() { + it("The 'toBeDefined' matcher compares against `undefined`", () => { var a = { foo: "foo" }; expect(a.foo).toBeDefined(); - expect((a).bar).not.toBeDefined(); + expect((a as any).bar).not.toBeDefined(); }); - it("The `toBeUndefined` matcher compares against `undefined`", function() { + it("The `toBeUndefined` matcher compares against `undefined`", () => { var a = { foo: "foo" }; @@ -82,7 +82,7 @@ describe("Included matchers:", function() { expect((a as any).bar).toBeUndefined(); }); - it("The 'toBeNull' matcher compares against null", function() { + it("The 'toBeNull' matcher compares against null", () => { var a: string = null; var foo = "foo"; @@ -91,28 +91,28 @@ describe("Included matchers:", function() { expect(foo).not.toBeNull(); }); - it("The 'toBeTruthy' matcher is for boolean casting testing", function() { + it("The 'toBeTruthy' matcher is for boolean casting testing", () => { var a: string, foo = "foo"; expect(foo).toBeTruthy(); expect(a).not.toBeTruthy(); }); - it("The 'toBeFalsy' matcher is for boolean casting testing", function() { + it("The 'toBeFalsy' matcher is for boolean casting testing", () => { var a: string, foo = "foo"; expect(a).toBeFalsy(); expect(foo).not.toBeFalsy(); }); - it("The 'toContain' matcher is for finding an item in an Array", function() { + it("The 'toContain' matcher is for finding an item in an Array", () => { var a = ["foo", "bar", "baz"]; expect(a).toContain('foo'); expect(a).not.toContain("quux"); }); - it("The 'toBeLessThan' matcher is for mathematical comparisons", function() { + it("The 'toBeLessThan' matcher is for mathematical comparisons", () => { var pi = 3.1415926, e = 2.78; @@ -120,7 +120,7 @@ describe("Included matchers:", function() { expect(pi).not.toBeLessThan(e); }); - it("The 'toBeGreaterThan' is for mathematical comparisons", function() { + it("The 'toBeGreaterThan' is for mathematical comparisons", () => { var pi = 3.1415926, e = 2.78; @@ -128,7 +128,7 @@ describe("Included matchers:", function() { expect(e).not.toBeGreaterThan(pi); }); - it("The 'toBeCloseTo' matcher is for precision math comparison", function() { + it("The 'toBeCloseTo' matcher is for precision math comparison", () => { var pi = 3.1415926, e = 2.78; @@ -136,12 +136,12 @@ describe("Included matchers:", function() { expect(pi).toBeCloseTo(e, 0); }); - it("The 'toThrow' matcher is for testing if a function throws an exception", function() { - var foo = function() { + it("The 'toThrow' matcher is for testing if a function throws an exception", () => { + var foo = () => { return 1 + 2; }; - var bar = function() { - var a: any = undefined; + var bar = () => { + var a: any; return a + 1; }; @@ -149,8 +149,8 @@ describe("Included matchers:", function() { expect(bar).toThrow(); }); - it("The 'toThrowError' matcher is for testing a specific thrown exception", function() { - var foo = function() { + it("The 'toThrowError' matcher is for testing a specific thrown exception", () => { + var foo = () => { throw new TypeError("foo bar baz"); }; @@ -161,15 +161,15 @@ describe("Included matchers:", function() { }); }); -describe("A spec", function() { - it("is just a function, so it can contain any code", function() { +describe("A spec", () => { + it("is just a function, so it can contain any code", () => { var foo = 0; foo += 1; expect(foo).toEqual(1); }); - it("can have more than one expectation", function() { + it("can have more than one expectation", () => { var foo = 0; foo += 1; @@ -178,96 +178,96 @@ describe("A spec", function() { }); }); -describe("A spec (with setup and tear-down)", function() { +describe("A spec (with setup and tear-down)", () => { var foo: number; - beforeEach(function() { + beforeEach(() => { foo = 0; foo += 1; }); - afterEach(function() { + afterEach(() => { foo = 0; }); - it("is just a function, so it can contain any code", function() { + it("is just a function, so it can contain any code", () => { expect(foo).toEqual(1); }); - it("can have more than one expectation", function() { + it("can have more than one expectation", () => { expect(foo).toEqual(1); expect(true).toEqual(true); }); }); -describe("A spec", function() { +describe("A spec", () => { var foo: number; - beforeEach(function() { + beforeEach(() => { foo = 0; foo += 1; }); - afterEach(function() { + afterEach(() => { foo = 0; }); - it("is just a function, so it can contain any code", function() { + it("is just a function, so it can contain any code", () => { expect(foo).toEqual(1); }); - it("can have more than one expectation", function() { + it("can have more than one expectation", () => { expect(foo).toEqual(1); expect(true).toEqual(true); }); - describe("nested inside a second describe", function() { + describe("nested inside a second describe", () => { var bar: number; - beforeEach(function() { + beforeEach(() => { bar = 1; }); - it("can reference both scopes as needed", function() { + it("can reference both scopes as needed", () => { expect(foo).toEqual(bar); }); }); }); -xdescribe("A spec", function() { +xdescribe("A spec", () => { var foo: number; - beforeEach(function() { + beforeEach(() => { foo = 0; foo += 1; }); - it("is just a function, so it can contain any code", function() { + it("is just a function, so it can contain any code", () => { expect(foo).toEqual(1); }); }); -describe("Pending specs", function() { +describe("Pending specs", () => { - xit("can be declared 'xit'", function() { + xit("can be declared 'xit'", () => { expect(true).toBe(false); }); it("can be declared with 'it' but without a function"); - it("can be declared by calling 'pending' in the spec body", function() { + it("can be declared by calling 'pending' in the spec body", () => { expect(true).toBe(false); pending(); // without reason pending('this is why it is pending'); }); }); -describe("A spy", function() { +describe("A spy", () => { var foo: any, bar: any = null; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -278,29 +278,29 @@ describe("A spy", function() { foo.setBar(456, 'another param'); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.setBar).toHaveBeenCalled(); }); - it("tracks all the arguments of its calls", function() { + it("tracks all the arguments of its calls", () => { expect(foo.setBar).toHaveBeenCalledWith(123); expect(foo.setBar).toHaveBeenCalledWith(456, 'another param'); }); - it("stops all execution on a function", function() { + it("stops all execution on a function", () => { expect(bar).toBeNull(); }); }); -describe("A spy, when configured to call through", function() { +describe("A spy, when configured to call through", () => { var foo: any, bar: any, fetchedBar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; @@ -311,28 +311,28 @@ describe("A spy, when configured to call through", function() { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function() { + it("should not effect other functions", () => { expect(bar).toEqual(123); }); - it("when called returns the requested value", function() { + it("when called returns the requested value", () => { expect(fetchedBar).toEqual(123); }); }); -describe("A spy, when configured to fake a return value", function() { +describe("A spy, when configured to fake a return value", () => { var foo: any, bar: any, fetchedBar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; @@ -343,28 +343,28 @@ describe("A spy, when configured to fake a return value", function() { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function() { + it("should not effect other functions", () => { expect(bar).toEqual(123); }); - it("when called returns the requested value", function() { + it("when called returns the requested value", () => { expect(fetchedBar).toEqual(745); }); }); -describe("A spy, when configured to fake a series of return values", function() { +describe("A spy, when configured to fake a series of return values", () => { var foo: any, bar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; @@ -374,36 +374,36 @@ describe("A spy, when configured to fake a series of return values", function() foo.setBar(123); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { foo.getBar(123); expect(foo.getBar).toHaveBeenCalled(); }); - it("should not affect other functions", function() { + it("should not affect other functions", () => { expect(bar).toEqual(123); }); - it("when called multiple times returns the requested values in order", function() { + it("when called multiple times returns the requested values in order", () => { expect(foo.getBar()).toEqual("fetched first"); expect(foo.getBar()).toEqual("fetched second"); expect(foo.getBar()).toBeUndefined(); }); }); -describe("A spy, when configured with an alternate implementation", function() { +describe("A spy, when configured with an alternate implementation", () => { var foo: any, bar: any, fetchedBar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; - spyOn(foo, "getBar").and.callFake(function() { + spyOn(foo, "getBar").and.callFake(() => { return 1001; }); @@ -411,25 +411,25 @@ describe("A spy, when configured with an alternate implementation", function() { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function() { + it("should not effect other functions", () => { expect(bar).toEqual(123); }); - it("when called returns the requested value", function() { + it("when called returns the requested value", () => { expect(fetchedBar).toEqual(1001); }); }); -describe("A spy, when configured to throw a value", function() { +describe("A spy, when configured to throw a value", () => { var foo: any, bar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -437,22 +437,22 @@ describe("A spy, when configured to throw a value", function() { spyOn(foo, "setBar").and.throwError("quux"); }); - it("throws the value", function() { - expect(function() { - foo.setBar(123) + it("throws the value", () => { + expect(() => { + foo.setBar(123); }).toThrowError("quux"); }); }); -describe("A spy, when configured with multiple actions", function() { +describe("A spy, when configured with multiple actions", () => { var foo: any, bar: any, fetchedBar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; @@ -465,29 +465,29 @@ describe("A spy, when configured with multiple actions", function() { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function() { + it("should not effect other functions", () => { expect(bar).toEqual(123); }); - it("when called returns the requested value", function() { + it("when called returns the requested value", () => { expect(fetchedBar).toEqual(123); }); - it("should have called the fake implementation", function() { + it("should have called the fake implementation", () => { expect(this.fakeCalled).toEqual(true); }); }); -describe("A spy", function() { +describe("A spy", () => { var foo: any, bar: any = null; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -495,7 +495,7 @@ describe("A spy", function() { spyOn(foo, 'setBar').and.callThrough(); }); - it("can call through and then stub in the same spec", function() { + it("can call through and then stub in the same spec", () => { foo.setBar(123); expect(bar).toEqual(123); @@ -507,12 +507,12 @@ describe("A spy", function() { }); }); -describe("A spy", function() { +describe("A spy", () => { var foo: any, bar: any = null; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -520,7 +520,7 @@ describe("A spy", function() { spyOn(foo, 'setBar'); }); - it("tracks if it was called at all", function() { + it("tracks if it was called at all", () => { expect(foo.setBar.calls.any()).toEqual(false); foo.setBar(); @@ -528,7 +528,7 @@ describe("A spy", function() { expect(foo.setBar.calls.any()).toEqual(true); }); - it("tracks the number of times it was called", function() { + it("tracks the number of times it was called", () => { expect(foo.setBar.calls.count()).toEqual(0); foo.setBar(); @@ -537,7 +537,7 @@ describe("A spy", function() { expect(foo.setBar.calls.count()).toEqual(2); }); - it("tracks the arguments of each call", function() { + it("tracks the arguments of each call", () => { foo.setBar(123); foo.setBar(456, "baz"); @@ -545,34 +545,34 @@ describe("A spy", function() { expect(foo.setBar.calls.argsFor(1)).toEqual([456, "baz"]); }); - it("tracks the arguments of all calls", function() { + it("tracks the arguments of all calls", () => { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.allArgs()).toEqual([[123], [456, "baz"]]); }); - it("can provide the context and arguments to all calls", function() { + it("can provide the context and arguments to all calls", () => { foo.setBar(123); expect(foo.setBar.calls.all()).toEqual([{ object: foo, args: [123], returnValue: undefined }]); }); - it("has a shortcut to the most recent call", function() { + it("has a shortcut to the most recent call", () => { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.mostRecent()).toEqual({ object: foo, args: [456, "baz"], returnValue: undefined }); }); - it("has a shortcut to the first call", function() { + it("has a shortcut to the first call", () => { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.first()).toEqual({ object: foo, args: [123], returnValue: undefined }); }); - it("can be reset", function() { + it("can be reset", () => { foo.setBar(123); foo.setBar(456, "baz"); @@ -584,40 +584,40 @@ describe("A spy", function() { }); }); -describe("A spy, when created manually", function() { +describe("A spy, when created manually", () => { var whatAmI: any; - beforeEach(function() { + beforeEach(() => { whatAmI = jasmine.createSpy('whatAmI'); whatAmI("I", "am", "a", "spy"); }); - it("is named, which helps in error reporting", function() { + it("is named, which helps in error reporting", () => { expect(whatAmI.and.identity()).toEqual('whatAmI'); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(whatAmI).toHaveBeenCalled(); }); - it("tracks its number of calls", function() { + it("tracks its number of calls", () => { expect(whatAmI.calls.count()).toEqual(1); }); - it("tracks all the arguments of its calls", function() { + it("tracks all the arguments of its calls", () => { expect(whatAmI).toHaveBeenCalledWith("I", "am", "a", "spy"); }); - it("allows access to the most recent call", function() { + it("allows access to the most recent call", () => { expect(whatAmI.calls.mostRecent().args[0]).toEqual("I"); }); }); -describe("Multiple spies, when created manually", function() { +describe("Multiple spies, when created manually", () => { var tape: any; - beforeEach(function() { + beforeEach(() => { tape = jasmine.createSpyObj('tape', ['play', 'pause', 'stop', 'rewind']); tape.play(); @@ -625,35 +625,35 @@ describe("Multiple spies, when created manually", function() { tape.rewind(0); }); - it("creates spies for each requested function", function() { + it("creates spies for each requested function", () => { expect(tape.play).toBeDefined(); expect(tape.pause).toBeDefined(); expect(tape.stop).toBeDefined(); expect(tape.rewind).toBeDefined(); }); - it("tracks that the spies were called", function() { + it("tracks that the spies were called", () => { expect(tape.play).toHaveBeenCalled(); expect(tape.pause).toHaveBeenCalled(); expect(tape.rewind).toHaveBeenCalled(); expect(tape.stop).not.toHaveBeenCalled(); }); - it("tracks all the arguments of its calls", function() { + it("tracks all the arguments of its calls", () => { expect(tape.rewind).toHaveBeenCalledWith(0); }); }); -describe("jasmine.any", function() { - it("matches any value", function() { +describe("jasmine.any", () => { + it("matches any value", () => { expect({}).toEqual(jasmine.any(Object)); expect(12).toEqual(jasmine.any(Number)); }); - describe("when used with a spy", function() { - it("is useful for comparing arguments", function() { + describe("when used with a spy", () => { + it("is useful for comparing arguments", () => { var foo = jasmine.createSpy('foo'); - foo(12, function() { + foo(12, () => { return true; }); @@ -662,7 +662,7 @@ describe("jasmine.any", function() { }); }); -describe("jasmine.objectContaining", function() { +describe("jasmine.objectContaining", () => { interface fooType { a: number; b: number; @@ -670,7 +670,7 @@ describe("jasmine.objectContaining", function() { } var foo: fooType; - beforeEach(function() { + beforeEach(() => { foo = { a: 1, b: 2, @@ -678,7 +678,7 @@ describe("jasmine.objectContaining", function() { }; }); - it("matches objects with the expect key/value pairs", function() { + it("matches objects with the expect key/value pairs", () => { expect(foo).toEqual(jasmine.objectContaining({ bar: '' })); @@ -688,8 +688,8 @@ describe("jasmine.objectContaining", function() { })); }); - describe("when used with a spy", function() { - it("is useful for comparing arguments", function() { + describe("when used with a spy", () => { + it("is useful for comparing arguments", () => { var callback = jasmine.createSpy('callback'); callback({ @@ -706,20 +706,20 @@ describe("jasmine.objectContaining", function() { }); }); -describe("jasmine.arrayContaining", function() { +describe("jasmine.arrayContaining", () => { var foo: any; - beforeEach(function() { + beforeEach(() => { foo = [1, 2, 3, 4]; }); - it("matches arrays with some of the values", function() { + it("matches arrays with some of the values", () => { expect(foo).toEqual(jasmine.arrayContaining([3, 1])); expect(foo).not.toEqual(jasmine.arrayContaining([6])); }); - describe("when used with a spy", function() { - it("is useful when comparing arguments", function() { + describe("when used with a spy", () => { + it("is useful when comparing arguments", () => { var callback = jasmine.createSpy('callback'); callback([1, 2, 3, 4]); @@ -730,20 +730,20 @@ describe("jasmine.arrayContaining", function() { }); }); -describe("Manually ticking the Jasmine Clock", function() { +describe("Manually ticking the Jasmine Clock", () => { var timerCallback: any; - beforeEach(function() { + beforeEach(() => { timerCallback = jasmine.createSpy("timerCallback"); jasmine.clock().install(); }); - afterEach(function() { + afterEach(() => { jasmine.clock().uninstall(); }); - it("causes a timeout to be called synchronously", function() { - setTimeout(function() { + it("causes a timeout to be called synchronously", () => { + setTimeout(() => { timerCallback(); }, 100); @@ -754,8 +754,8 @@ describe("Manually ticking the Jasmine Clock", function() { expect(timerCallback).toHaveBeenCalled(); }); - it("causes an interval to be called synchronously", function() { - setInterval(function() { + it("causes an interval to be called synchronously", () => { + setInterval(() => { timerCallback(); }, 100); @@ -771,8 +771,8 @@ describe("Manually ticking the Jasmine Clock", function() { expect(timerCallback.calls.count()).toEqual(2); }); - describe("Mocking the Date object", function() { - it("mocks the Date object and sets it to a given time", function() { + describe("Mocking the Date object", () => { + it("mocks the Date object and sets it to a given time", () => { var baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); @@ -783,82 +783,82 @@ describe("Manually ticking the Jasmine Clock", function() { }); }); -describe("Asynchronous specs", function() { +describe("Asynchronous specs", () => { var value: number; - beforeEach(function (done: DoneFn) { - setTimeout(function() { + beforeEach((done: DoneFn) => { + setTimeout(() => { value = 0; done(); }, 1); }); - it("should support async execution of test preparation and expectations", function (done: DoneFn) { + it("should support async execution of test preparation and expectations", (done: DoneFn) => { value++; expect(value).toBeGreaterThan(0); done(); }); - describe("long asynchronous specs", function() { - beforeEach(function (done: DoneFn) { + describe("long asynchronous specs", () => { + beforeEach((done: DoneFn) => { done(); }, 1000); - it("takes a long time", function (done: DoneFn) { - setTimeout(function() { + it("takes a long time", (done: DoneFn) => { + setTimeout(() => { done(); }, 9000); }, 10000); - afterEach(function (done: DoneFn) { + afterEach((done: DoneFn) => { done(); }, 1000); }); }); -describe("Fail", function() { +describe("Fail", () => { - it("should fail test when called without arguments", function() { + it("should fail test when called without arguments", () => { fail(); }); - it("should fail test when called with a fail message", function() { + it("should fail test when called with a fail message", () => { fail("The test failed"); }); - it("should fail test when called an error", function() { + it("should fail test when called an error", () => { fail(new Error("The test failed with this error")); }); }); // test based on http://jasmine.github.io/2.2/custom_equality.html -describe("custom equality", function() { - var myCustomEquality: jasmine.CustomEqualityTester = function (first: any, second: any): boolean { - if (typeof first == "string" && typeof second == "string") { - return first[0] == second[1]; +describe("custom equality", () => { + var myCustomEquality: jasmine.CustomEqualityTester = function(first: any, second: any): boolean { + if (typeof first === "string" && typeof second === "string") { + return first[0] === second[1]; } }; - beforeEach(function() { + beforeEach(() => { jasmine.addCustomEqualityTester(myCustomEquality); }); - it("should be custom equal", function() { + it("should be custom equal", () => { expect("abc").toEqual("aaa"); }); - it("should be custom not equal", function() { + it("should be custom not equal", () => { expect("abc").not.toEqual("abc"); }); }); // test based on http://jasmine.github.io/2.2/custom_matcher.html var customMatchers: jasmine.CustomMatcherFactories = { - toBeGoofy: function (util: jasmine.MatchersUtil, customEqualityTesters: Array) { + toBeGoofy: (util: jasmine.MatchersUtil, customEqualityTesters: jasmine.CustomEqualityTester[]) => { return { - compare: function (actual: any, expected: any): jasmine.CustomMatcherResult { + compare: (actual: any, expected: any): jasmine.CustomMatcherResult => { if (expected === undefined) { expected = ''; } @@ -892,24 +892,24 @@ declare namespace jasmine { } } -describe("Custom matcher: 'toBeGoofy'", function() { - beforeEach(function() { +describe("Custom matcher: 'toBeGoofy'", () => { + beforeEach(() => { jasmine.addMatchers(customMatchers); }); - it("is available on an expectation", function() { + it("is available on an expectation", () => { expect({ hyuk: 'gawrsh' }).toBeGoofy(); }); - it("can take an 'expected' parameter", function() { + it("can take an 'expected' parameter", () => { expect({ hyuk: 'gawrsh is fun' }).toBeGoofy({ hyuk: ' is fun' }); }); - it("can be negated", function() { + it("can be negated", () => { expect({ hyuk: 'this is fun' }).not.toBeGoofy(); @@ -918,20 +918,21 @@ describe("Custom matcher: 'toBeGoofy'", function() { // test based on http://jasmine.github.io/2.5/custom_reporter.html var myReporter: jasmine.CustomReporter = { - jasmineStarted: function (suiteInfo: jasmine.SuiteInfo) { + jasmineStarted: (suiteInfo: jasmine.SuiteInfo) => { console.log("Running suite with " + suiteInfo.totalSpecsDefined); }, - suiteStarted: function (result: jasmine.CustomReporterResult) { + suiteStarted: (result: jasmine.CustomReporterResult) => { console.log("Suite started: " + result.description + " whose full description is: " + result.fullName); }, - specStarted: function (result: jasmine.CustomReporterResult) { + specStarted: (result: jasmine.CustomReporterResult) => { console.log("Spec started: " + result.description + " whose full description is: " + result.fullName); }, - specDone: function (result: jasmine.CustomReporterResult) { + specDone: (result: jasmine.CustomReporterResult) => { console.log("Spec: " + result.description + " was " + result.status); + //tslint:disable-next-line:prefer-for-of for (var i = 0; i < result.failedExpectations.length; i++) { console.log("Failure: " + result.failedExpectations[i].message); console.log("Actual: " + result.failedExpectations[i].actual); @@ -941,15 +942,16 @@ var myReporter: jasmine.CustomReporter = { console.log(result.passedExpectations.length); }, - suiteDone: function (result: jasmine.CustomReporterResult) { + suiteDone: (result: jasmine.CustomReporterResult) => { console.log('Suite: ' + result.description + ' was ' + result.status); + //tslint:disable-next-line:prefer-for-of for (var i = 0; i < result.failedExpectations.length; i++) { console.log('AfterAll ' + result.failedExpectations[i].message); console.log(result.failedExpectations[i].stack); } }, - jasmineDone: function (runDetails: jasmine.RunDetails) { + jasmineDone: (runDetails: jasmine.RunDetails) => { console.log('Finished suite'); console.log('Random:', runDetails.order.random); } @@ -957,16 +959,16 @@ var myReporter: jasmine.CustomReporter = { jasmine.getEnv().addReporter(myReporter); -describe("Randomize Tests", function() { - it("should allow randomization of the order of tests", function() { - expect(function() { +describe("Randomize Tests", () => { + it("should allow randomization of the order of tests", () => { + expect(() => { var env = jasmine.getEnv(); return env.randomizeTests(true); }).not.toThrow(); }); - it("should allow a seed to be passed in for randomization", function() { - expect(function() { + it("should allow a seed to be passed in for randomization", () => { + expect(() => { var env = jasmine.getEnv(); env.randomizeTests(true); return env.seed(1234); @@ -982,14 +984,14 @@ describe("Randomize Tests", function() { env.addReporter(htmlReporter); var specFilter = new jasmine.HtmlSpecFilter(); - env.specFilter = function (spec) { + env.specFilter = (spec) => { return specFilter.matches(spec.getFullName()); }; var currentWindowOnload = window.onload; - window.onload = function() { + window.onload = () => { if (currentWindowOnload) { - (currentWindowOnload)(null); + (currentWindowOnload as any)(null); } htmlReporter.initialize(); env.execute(); diff --git a/jasmine/v1/jasmine-tests.ts b/jasmine/v1/jasmine-tests.ts index 9177679f8a..c47fc84007 100644 --- a/jasmine/v1/jasmine-tests.ts +++ b/jasmine/v1/jasmine-tests.ts @@ -60,7 +60,7 @@ describe("Included matchers:", () => { foo: 'foo' }; expect(a.foo).toBeDefined(); - expect((a).bar).not.toBeDefined(); + expect((a as any).bar).not.toBeDefined(); }); it("The `toBeUndefined` matcher compares against `undefined`", () => { @@ -68,7 +68,7 @@ describe("Included matchers:", () => { foo: 'foo' }; expect(a.foo).not.toBeUndefined(); - expect((a).bar).toBeUndefined(); + expect((a as any).bar).toBeUndefined(); }); it("The 'toBeNull' matcher compares against null", () => { @@ -202,7 +202,7 @@ describe("A spy", () => { var foo: any, bar: any = null; beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -235,7 +235,7 @@ describe("A spy, when configured to call through", () => { var foo: any, bar: any, fetchedBar: any; beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, getBar: () => { @@ -261,7 +261,7 @@ describe("A spy, when faking a return value", () => { var foo: any, bar: any, fetchedBar: any; beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, getBar: () => { @@ -287,7 +287,7 @@ describe("A spy, when faking a return value", () => { var foo: any, bar: any, fetchedBar: any; beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, getBar: () => { @@ -319,7 +319,7 @@ describe("A spy, when created manually", () => { whatAmI("I", "am", "a", "spy"); }); it("is named, which helps in error reporting", () => { - expect(whatAmI.identity).toEqual('whatAmI') + expect(whatAmI.identity).toEqual('whatAmI'); }); it("tracks that the spy was called", () => { expect(whatAmI).toHaveBeenCalled(); @@ -369,7 +369,7 @@ describe("jasmine.any", () => { it("is useful for comparing arguments", () => { var foo = jasmine.createSpy('foo'); foo(12, () => { - return true + return true; }); expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function)); }); @@ -430,7 +430,7 @@ describe("Asynchronous specs", () => { jasmineEnv.updateInterval = 250; var htmlReporter = new jasmine.HtmlReporter(); jasmineEnv.addReporter(htmlReporter); - jasmineEnv.specFilter = function (spec) { + jasmineEnv.specFilter = (spec) => { return htmlReporter.specFilter(spec); }; var currentWindowOnload = (arg: any) => window.onload(arg); @@ -439,11 +439,11 @@ describe("Asynchronous specs", () => { currentWindowOnload(null); } - (document.querySelector('.version')).innerHTML = jasmineEnv.versionString(); + (document.querySelector('.version') as HTMLElement).innerHTML = jasmineEnv.versionString(); execJasmine(); }; function execJasmine() { jasmineEnv.execute(); } -})(); \ No newline at end of file +})(); From ba29010d1438767c5db5e73d716447178d85f0f3 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Sun, 26 Feb 2017 13:17:07 +0100 Subject: [PATCH 025/150] Fix other jasmine packages --- jasmine-es6-promise-matchers/index.d.ts | 2 +- jasmine-expect/index.d.ts | 2 +- jasmine-jquery/index.d.ts | 6 +++--- jasmine-jquery/jasmine-jquery-tests.ts | 4 ++-- jasmine-matchers/index.d.ts | 2 +- jasmine-promise-matchers/index.d.ts | 2 +- jasmine/v1/index.d.ts | 16 ++++++++-------- jasminewd2/index.d.ts | 17 ++++++++++++----- 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/jasmine-es6-promise-matchers/index.d.ts b/jasmine-es6-promise-matchers/index.d.ts index 89e3146c2c..7d61d4d660 100644 --- a/jasmine-es6-promise-matchers/index.d.ts +++ b/jasmine-es6-promise-matchers/index.d.ts @@ -13,7 +13,7 @@ declare namespace JasminePromiseMatchers { declare namespace jasmine { - interface Matchers { + interface Matchers { /** * Verifies that a Promise is (or has been) rejected. */ diff --git a/jasmine-expect/index.d.ts b/jasmine-expect/index.d.ts index c2ee7e0ee5..25a21d49d5 100644 --- a/jasmine-expect/index.d.ts +++ b/jasmine-expect/index.d.ts @@ -7,7 +7,7 @@ /// declare namespace jasmine { - interface Matchers { + interface Matchers { // These functions are written in the order defined in the src directory of jasmine-matchers // The type system is used smartly whenever it can provide value (by looking at the code of every matcher) toBeAfter(otherDate: Date): boolean; // diff --git a/jasmine-jquery/index.d.ts b/jasmine-jquery/index.d.ts index fb91e0c37b..ebc14cee75 100644 --- a/jasmine-jquery/index.d.ts +++ b/jasmine-jquery/index.d.ts @@ -81,7 +81,7 @@ declare namespace jasmine { proxyCallTo_(methodName: string, passedArguments: any): any; } - interface Matchers { + interface Matchers { /** * Check if DOM element has class. * @@ -232,7 +232,7 @@ declare namespace jasmine { * */ toHaveData(key : string, expectedValue : string): boolean; - toBe(selector: JQuery): boolean; + toBe(selector: T): boolean; /** * Check if DOM element is matched by the given selector. @@ -241,7 +241,7 @@ declare namespace jasmine { * // returns true * expect($('

')).toContain('some-class') */ - toContain(selector: JQuery): boolean; + toContain(selector: T): boolean; /** * Check if DOM element exists inside the given parent element. diff --git a/jasmine-jquery/jasmine-jquery-tests.ts b/jasmine-jquery/jasmine-jquery-tests.ts index 67b349d45e..9d51a3775b 100644 --- a/jasmine-jquery/jasmine-jquery-tests.ts +++ b/jasmine-jquery/jasmine-jquery-tests.ts @@ -4,8 +4,8 @@ describe("Jasmine jQuery extension", () => { it("Adds jQuery matchers", () => { - expect($('
')).toBe('div'); - expect($('
')).toBe('div#some-id'); + expect($('
')).toBe($('div')); + expect($('
')).toBe($('div#some-id')); expect($('')).toBeChecked(); expect($('
')).toBeHidden(); expect($('
')).toHaveCss({ display: "none", margin: "10px" }); diff --git a/jasmine-matchers/index.d.ts b/jasmine-matchers/index.d.ts index ac44d25c1c..d4cad3b77c 100644 --- a/jasmine-matchers/index.d.ts +++ b/jasmine-matchers/index.d.ts @@ -23,7 +23,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI /// declare namespace jasmine { - interface Matchers { + interface Matchers { //toBe toBeArray(): boolean; diff --git a/jasmine-promise-matchers/index.d.ts b/jasmine-promise-matchers/index.d.ts index c511019b62..ffe4f65142 100644 --- a/jasmine-promise-matchers/index.d.ts +++ b/jasmine-promise-matchers/index.d.ts @@ -10,7 +10,7 @@ declare function installPromiseMatchers(): void; declare namespace jasmine { - interface Matchers { + interface Matchers { /** * Verifies that a Promise is (or has been) rejected. */ diff --git a/jasmine/v1/index.d.ts b/jasmine/v1/index.d.ts index 5cbb2a9f83..3f51240f63 100644 --- a/jasmine/v1/index.d.ts +++ b/jasmine/v1/index.d.ts @@ -16,9 +16,9 @@ declare function xit(expectation: string, assertion: () => void): void; declare function beforeEach(action: () => void): void; declare function afterEach(action: () => void): void; -declare function expect(spy: Function): jasmine.Matchers; -//declare function expect(spy: jasmine.Spy): jasmine.Matchers; -declare function expect(actual: any): jasmine.Matchers; +declare function expect(spy: Function): jasmine.Matchers; +//declare function expect(spy: jasmine.Spy): jasmine.Matchers; +declare function expect(actual: any): jasmine.Matchers; declare function spyOn(object: any, method: string): jasmine.Spy; @@ -91,7 +91,7 @@ declare namespace jasmine { currentSpec: Spec; - matchersClass: Matchers; + matchersClass: Matchers; version(): any; versionString(): string; @@ -204,7 +204,7 @@ declare namespace jasmine { results(): NestedResults; } - interface Matchers { + interface Matchers { new (env: Env, actual: any, spec: Env, isNot?: boolean): any; @@ -232,7 +232,7 @@ declare namespace jasmine { toContainHtml(expected: string): boolean; toContainText(expected: string): boolean; toThrow(expected?: any): boolean; - not: Matchers; + not: Matchers; Any: Any; } @@ -287,7 +287,7 @@ declare namespace jasmine { spies_: Spy[]; results_: NestedResults; - matchersClass: Matchers; + matchersClass: Matchers; getFullName(): string; results(): NestedResults; @@ -299,7 +299,7 @@ declare namespace jasmine { waits(timeout: number): Spec; waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; fail(e?: any): void; - getMatchersClass_(): Matchers; + getMatchersClass_(): Matchers; addMatchers(matchersPrototype: any): void; finishCallback(): void; finish(onComplete?: () => void): void; diff --git a/jasminewd2/index.d.ts b/jasminewd2/index.d.ts index 9d8ecde76e..a4122c6639 100644 --- a/jasminewd2/index.d.ts +++ b/jasminewd2/index.d.ts @@ -17,10 +17,10 @@ declare function afterAll(action: () => Promise, timeout?: number): void; declare namespace jasmine { // The global `Promise` type is too strict and kinda wrong interface Promise { - then(onFulfill?: (value: T) => U | Promise, onReject?: (error: any) => U | Promise): Promise; + then(onFulfill?: (value: T) => U | Promise, onReject?: (error: any) => U | Promise): Promise; } - interface Matchers { + interface Matchers { toBe(expected: any, expectationFailOutput?: any): Promise; toEqual(expected: any, expectationFailOutput?: any): Promise; toMatch(expected: string | RegExp | Promise, expectationFailOutput?: any): Promise; @@ -44,6 +44,13 @@ declare namespace jasmine { toThrowError(expected?: new (...args: any[]) => Error | Promise Error>, message?: string | RegExp | Promise): Promise; } + interface ArrayLikeMatchers> extends Matchers { + toBe(expected: Expected>, expectationFailOutput?: any): Promise; + toEqual(expected: Expected>, expectationFailOutput?: any): Promise; + toContain(expected: T, expectationFailOutput?: any): Promise; + not: ArrayLikeMatchers; + } + function addMatchers(matchers: AsyncCustomMatcherFactories): void; interface Env { @@ -59,12 +66,12 @@ declare namespace jasmine { } interface AsyncCustomMatcherFactory { - (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]): AsyncCustomMatcher; + (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]): AsyncCustomMatcher; } interface AsyncCustomMatcher { - compare(actual: T, expected: T): AsyncCustomMatcherResult; - compare(actual: any, expected: any): AsyncCustomMatcherResult; + compare(actual: T, expected: T): AsyncCustomMatcherResult; + compare(actual: any, expected: any): AsyncCustomMatcherResult; } interface AsyncCustomMatcherResult { From 4fa3d7fda8444f7d880aa31f0ef82ed1e7fab92d Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 24 Feb 2017 01:20:39 +0100 Subject: [PATCH 026/150] Add definitions for Google Calendar API (gapi.calendar) --- gapi.calendar/gapi.calendar-tests.ts | 152 ++++++ gapi.calendar/index.d.ts | 675 +++++++++++++++++++++++++++ gapi.calendar/tsconfig.json | 18 + 3 files changed, 845 insertions(+) create mode 100644 gapi.calendar/gapi.calendar-tests.ts create mode 100644 gapi.calendar/index.d.ts create mode 100644 gapi.calendar/tsconfig.json diff --git a/gapi.calendar/gapi.calendar-tests.ts b/gapi.calendar/gapi.calendar-tests.ts new file mode 100644 index 0000000000..de335c6a15 --- /dev/null +++ b/gapi.calendar/gapi.calendar-tests.ts @@ -0,0 +1,152 @@ +/* Example taken from Google Calendar API JavaScript Quickstart https://developers.google.com/google-apps/calendar/quickstart/js */ + +{ + // Your Client ID can be retrieved from your project in the Google + // Developer Console, https://console.developers.google.com + var CLIENT_ID = ''; + + var SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"]; + + /** + * Check if current user has authorized this application. + */ + function checkAuth() { + gapi.auth.authorize( + { + 'client_id': CLIENT_ID, + 'scope': SCOPES.join(' '), + 'immediate': true + }, handleAuthResult); + } + + /** + * Handle response from authorization server. + * + * @param {Object} authResult Authorization result. + */ + function handleAuthResult(authResult: GoogleApiOAuth2TokenObject) { + var authorizeDiv = document.getElementById('authorize-div')!; + if (authResult && !authResult.error) { + // Hide auth UI, then load client library. + authorizeDiv.style.display = 'none'; + loadCalendarApi(); + } else { + // Show auth UI, allowing the user to initiate authorization by + // clicking authorize button. + authorizeDiv.style.display = 'inline'; + } + } + + /** + * Initiate auth flow in response to user clicking authorize button. + * + * @param {Event} event Button click event. + */ + function handleAuthClick(event: MouseEvent) { + gapi.auth.authorize( + {client_id: CLIENT_ID, scope: SCOPES, immediate: false}, + handleAuthResult); + return false; + } + + /** + * Load Google Calendar client library. List upcoming events + * once client library is loaded. + */ + function loadCalendarApi() { + gapi.client.load('calendar', 'v3', listUpcomingEvents); + } + + /** + * Print the summary and start datetime/date of the next ten events in + * the authorized user's calendar. If no events are found an + * appropriate message is printed. + */ + function listUpcomingEvents() { + var request = gapi.client.calendar.events.list({ + 'calendarId': 'primary', + 'timeMin': (new Date()).toISOString(), + 'showDeleted': false, + 'singleEvents': true, + 'maxResults': 10, + 'orderBy': 'startTime' + }); + + request.execute(function(resp) { + var events = resp.items; + appendPre('Upcoming events:'); + + if (events.length > 0) { + for (let i = 0; i < events.length; i++) { + var event = events[i]; + var when = event.start.dateTime; + if (!when) { + when = event.start.date; + } + appendPre(event.summary + ' (' + when + ')') + } + } else { + appendPre('No upcoming events found.'); + } + + }); + } + + /** + * Append a pre element to the body containing the given message + * as its text node. + * + * @param {string} message Text to be placed in pre element. + */ + function appendPre(message: string) { + var pre = document.getElementById('output')!; + var textContent = document.createTextNode(message + '\n'); + pre.appendChild(textContent); + } +} + +/* Example taken from https://developers.google.com/google-apps/calendar/v3/reference/events/insert#examples */ + +{ + // Refer to the JavaScript quickstart on how to setup the environment: + // https://developers.google.com/google-apps/calendar/quickstart/js + // Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any + // stored credentials. + + const event = { + 'summary': 'Google I/O 2015', + 'location': '800 Howard St., San Francisco, CA 94103', + 'description': 'A chance to hear more about Google\'s developer products.', + 'start': { + 'dateTime': '2015-05-28T09:00:00-07:00', + 'timeZone': 'America/Los_Angeles' + }, + 'end': { + 'dateTime': '2015-05-28T17:00:00-07:00', + 'timeZone': 'America/Los_Angeles' + }, + 'recurrence': [ + 'RRULE:FREQ=DAILY;COUNT=2' + ], + 'attendees': [ + {'email': 'lpage@example.com'}, + {'email': 'sbrin@example.com'} + ], + 'reminders': { + 'useDefault': false, + 'overrides': [ + {'method': 'email', 'minutes': 24 * 60}, + {'method': 'popup', 'minutes': 10} + ] + } + }; + + var request = gapi.client.calendar.events.insert({ + 'calendarId': 'primary', + 'resource': event + }); + + request.execute(function(event) { + appendPre('Event created: ' + event.htmlLink); + }); +} diff --git a/gapi.calendar/index.d.ts b/gapi.calendar/index.d.ts new file mode 100644 index 0000000000..bd0e3b0d17 --- /dev/null +++ b/gapi.calendar/index.d.ts @@ -0,0 +1,675 @@ +// Type definitions for Google Calendar API 3.0 +// Project: https://developers.google.com/google-apps/calendar/ +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace gapi.client.calendar { + export class freebusy { + static query(parameters: FreeBusyQueryParameters): HttpRequest; + } + + interface FreeBusyQueryParameters { + timeMin: datetime; + timeMax: datetime; + timeZone?: string; + groupExpansionMax?: integer; + calendarExpansionMax?: integer; + items: {id: string}[]; + } + + interface FreeBusy { + kind: 'calendar#freeBusy'; + timeMin: datetime; + timeMax: datetime; + groups: { + (key: string): { + errors?: { + domain: string; + reason: string; + }[]; + calendars: string[]; + } + }; + calendars: { + (key: string): { + errors?: { + domain: string; + reason: string; + }[]; + busy: { + start: datetime; + end: datetime; + }[]; + } + }; + } + + export class acl { + static insert(parameters: AclInsertParameters): HttpRequest; + static get(parameters: AclGetParameters): HttpRequest; + static update(parameters: AclUpdateParameters): HttpRequest; + static delete(parameters: AclDeleteParameters): HttpRequest; + } + + // The type of the scope. Possible values are: + type ScopeType = + // The public scope. This is the default value. + // Note: The permissions granted to the "default", or public, scope apply to any user, authenticated or not. + 'default' | + // Limits the scope to a single user. + 'user' | + // Limits the scope to a group. + 'group' | + // Limits the scope to a domain. + 'domain'; + + interface Acl { + kind: 'calendar#aclRule'; + etag: etag; + id: string; + scope: { + type: ScopeType; + value: string; + }; + role: AccessRole; + } + + interface AclInsertParameters { + calendarId: string; + + // Acl resource + role: AccessRole; + scope: { + type: ScopeType; + value?: string; + }; + } + + interface AclGetParameters { + calendarId: string; + ruleId: string; + } + + interface AclUpdateParameters extends AclInsertParameters { + ruleId: string; + } + + interface AclDeleteParameters extends AclGetParameters { + } + + export class calendarList { + static list(parameters?: CalendarListListParameters): HttpRequest; + static insert(parameters: CalendarListInsertParameters): HttpRequest; + } + + type AccessRoleWithoutNone = + // The user has read access to free/busy information. + 'freeBusyReader' | + // The user has read access to the calendar. Private events will appear to users with reader access, but event details will be hidden. + 'reader' | + // The user has read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible. + 'writer' | + // The user has ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs. + 'owner'; + + // The user's access role for this calendar. Read-only. Possible values are: + type AccessRole = + // The user has no access. + 'none' | + AccessRoleWithoutNone; + + interface CalendarListListParameters { + maxResults?: integer; + // The minimum access role for the user in the returned entries. Optional. The default is no restriction. Acceptable values are: + minAccessRole?: AccessRoleWithoutNone; + pageToken?: string; + showDeleted?: boolean; + showHidden?: boolean; + syncToken?: string; + } + + interface CalendarListInsertParameters { + // Parameters + // Optional query parameters + colorRgbFormat?: boolean; + + // CalendarList resource + resource: CalendarListInput; + } + + interface CalendarListInput { + // Required Properties + id: string; + + // Optional Properties + backgroundColor?: string; + colorId?: string; + defaultReminders?: { + method: ReminderMethod; + minutes: integer; + }[]; + foregroundColor?: string; + hidden?: boolean; + notificationSettings?: { + notifications: { + type: NotificationType; + method: string; + }[]; + }; + selected?: boolean; + summaryOverride?: string; + } + + interface CalendarList { + kind: 'calendar#calendarList'; + etag: etag; + + /** + * Token used to access the next page of this result. + * Omitted if no further results are available, in which case nextSyncToken is provided. + */ + nextPageToken?: string; + + /** + * Token used at a later point in time to retrieve only the entries that have changed since this result was returned. + * Omitted if further results are available, in which case nextPageToken is provided. + */ + nextSyncToken?: string; + + items: CalendarListEntry[]; + } + + // The type of notification. Possible values are: + type NotificationType = + // Notification sent when a new event is put on the calendar. + 'eventCreation' | + // Notification sent when an event is changed. + 'eventChange' | + // Notification sent when an event is cancelled. + 'eventCancellation' | + // Notification sent when an event is changed. + 'eventResponse' | + // An agenda with the events of the day (sent out in the morning). + 'agenda'; + + interface CalendarListEntry { + kind: 'calendar#calendarListEntry'; + etag: etag; + id: string; + summary: string; + description?: string; + location?: string; + timeZone?: string; + summaryOverride?: string; + colorId?: string; + backgroundColor?: string; + foregroundColor?: string; + hidden?: boolean; + selected?: boolean; + // The effective access role that the authenticated user has on the calendar. Read-only. + accessRole: AccessRoleWithoutNone; + defaultReminders: { + method: ReminderMethod; + minutes: integer; + }[]; + notificationSettings?: { + notifications: { + type: NotificationType; + method: string; + }[]; + }; + primary?: boolean; + deleted?: boolean; + } + + export class calendars { + static insert(parameters: CalendarsInsertParameters): HttpRequest; + static update(parameters: CalendarsUpdateParameters): HttpRequest; + static delete(parameters: CalendarsDeleteParameters): HttpRequest; + } + + interface CalendarsUpdateParameters { + calendarId: string; + + // Calendars resource + // Optional Properties + description?: string; + location?: string; + summary?: string; + timeZone?: string; + } + + interface CalendarsInsertParameters { + // Calendars resource + // Required Properties + summary: string; + + description?: string; + location?: string; + timeZone?: string; + } + + interface CalendarsDeleteParameters { + calendarId: string; + } + + interface Calendar { + kind: 'calendar#calendar'; + etag: etag; + id: string; + summary: string; + description?: string; + location?: string; + timeZone?: string; + } + + export class events { + static list(parameters: EventsListParameters): HttpRequest; + static insert(parameters: EventsInsertParameters): HttpRequest; + static update(parameters: EventsUpdateParameters): HttpRequest; + static get(parameters: EventsGetParameters): HttpRequest; + } + + interface EventsGetParameters { + calendarId: string; + eventId: string; + + alwaysIncludeEmail?: boolean; + maxAttendees?: integer; + timeZone?: string; + } + + interface EventsInsertParameters { + calendarId: string; + + maxAttendees?: integer; + sendNotifications?: boolean; + supportsAttachments?: boolean; + + // Event resource + resource: EventInput; + } + + interface EventsUpdateParameters { + calendarId: string; + eventId: string; + + alwaysIncludeEmail?: boolean; + maxAttendees?: integer; + sendNotifications?: boolean; + supportsAttachments?: boolean; + + // Event resource + resource: EventInput; + } + + interface EventInput { + // Required Properties + attachments?: { + fileUrl: string; + }[]; + attendees?: { + email: string; + displayName?: string; + optional?: boolean; + responseStatus?: AttendeeResponseStatus; + comment?: string; + additionalGuests?: integer; + }[]; + end: { + date?: date; + dateTime?: datetime; + timeZone?: string + }; + reminders?: { + overrides: { + method: string; + minutes: integer; + }[]; + useDefault: boolean; + }; + start: { + date?: date; + dateTime?: datetime; + timeZone: string; + }; + + // Optional Properties + anyoneCanAddSelf?: boolean; + colorId?: string; + description?: string; + extendedProperties?: { + private: { + (key: string): string + }; + shared: { + (key: string): string + } + }; + gadget?: { + display?: GadgetDisplayMode; + height: integer; + iconLink: string; + link: string; + preferences: { + (key: string): string + } + title: string; + type: string; + width: integer; + }; + guestsCanInviteOthers?: boolean; + guestsCanSeeOtherGuests?: boolean; + id?: string; + location?: string; + originalStartTime?: { + date: date; + dateTime: datetime; + timeZone: string + }; + recurrence?: string[]; + sequence?: integer; + source?: { + url: string; + title: string + }; + status?: EventStatus; + summary?: string; + transparency?: EventTransparency; + visibility?: EventVisibility; + } + + // The order of the events returned in the result. Optional. The default is an unspecified, stable order. + // Acceptable values are: + type EventsOrder = + // Order by the start date/time (ascending). This is only available when querying single events (i.e. the parameter singleEvents is True) + 'startTime' | + // Order by last modification time (ascending). + 'updated'; + + // Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. + // It makes the result of this list request contain only entries that have changed since then. + // All events deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False. + // There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state. + // These are: + type SyncToken = + 'iCalUID' | + 'orderBy' | + 'privateExtendedProperty' | + 'q' | + 'sharedExtendedProperty' | + 'timeMin' | + 'timeMax' | + 'updatedMin'; + + interface EventsListParameters { + calendarId: string; + alwaysIncludeEmail?: boolean; + iCalUID?: string; + maxAttendees?: integer; + maxResults?: integer; + orderBy?: EventsOrder; + pageToken?: string; + privateExtendedProperty?: string; + q?: string; + sharedExtendedProperty?: string; + showDeleted?: boolean; + showHiddenInvitations?: boolean; + singleEvents?: boolean; + syncToken?: SyncToken; + timeMax?: datetime; + timeMin?: datetime; + timeZone?: string; + updatedMin?: datetime; + } + + interface Events { + kind: 'calendar#events'; + etag: etag; + summary: string; + description: string; + updated: datetime; + timeZone: string; + // The user's access role for this calendar. Read-only. Possible values are: + accessRole: AccessRole; + defaultReminders: { + method: ReminderMethod; + minutes: integer; + }[]; + nextPageToken?: string; + nextSyncToken?: string; + items: Event[]; + } + + type etag = string; + type datetime = string; + type date = string; + type integer = number; + + // The attendee's response status. Possible values are: + type AttendeeResponseStatus = + // The attendee has not responded to the invitation. + 'needsAction' | + // The attendee has declined the invitation. + 'declined' | + // The attendee has tentatively accepted the invitation. + 'tentative' | + // The attendee has accepted the invitation. + 'accepted'; + + // The gadget's display mode. Optional. Possible values are: + type GadgetDisplayMode = + // The gadget displays next to the event's title in the calendar view. + 'icon' | + // The gadget displays when the event is clicked. + 'chip'; + + // The method used by this reminder. Possible values are: + type ReminderMethod = + // Reminders are sent via email. + 'email' | + // Reminders are sent via SMS. These are only available for Google Apps for Work, Education, and Government customers. Requests to set SMS reminders for other account types are ignored. + 'sms' | + // Reminders are sent via a UI popup. + 'popup'; + + // Status of the event. Optional. Possible values are: + type EventStatus = + // The event is confirmed. This is the default status. + 'confirmed' | + // The event is tentatively confirmed. + 'tentative' | + // The event is cancelled. + 'cancelled'; + + // Whether the event blocks time on the calendar. Optional. Possible values are: + type EventTransparency = + // The event blocks time on the calendar. This is the default value. + 'opaque' | + // The event does not block time on the calendar. + 'transparent'; + + // Visibility of the event. Optional. Possible values are: + type EventVisibility = + // Uses the default visibility for events on the calendar. This is the default value. + 'default' | + // The event is public and event details are visible to all readers of the calendar. + 'public' | + // The event is private and only event attendees may view event details. + 'private' | + // The event is private. This value is provided for compatibility reasons. + 'confidential'; + + class Event { + kind: 'calendar#event'; + etag: etag; + id: string; + status?: EventStatus; + htmlLink: string; + created: datetime; + updated: datetime; + summary: string; + description: string; + location?: string; + colorId?: string; + + // The creator of the event. Read-only. + creator: { + // The creator's Profile ID, if available. + id?: string; + + // The creator's email address, if available. + email?: string; + + // The creator's name, if available. + displayName?: string; + + // Whether the creator corresponds to the calendar on which this copy of the event appears. Read-only. The default is False. + self?: boolean; + }; + + // The organizer of the event. + organizer: { + // The organizer's Profile ID, if available. + id?: string; + + // The organizer's email address, if available. + email?: string; + + // The organizer's name, if available. + displayName?: string; + + // Whether the organizer corresponds to the calendar on which this copy of the event appears. Read-only. The default is False. + self?: boolean; + }; + + // The (inclusive) start time of the event. For a recurring event, this is the start time of the first instance. + start: { + // The date, in the format "yyyy-mm-dd", if this is an all-day event. + date?: date; + + // The time, as a combined date-time value (formatted according to RFC3339). + // A time zone offset is required unless a time zone is explicitly specified in timeZone. + dateTime?: datetime; + + // The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) + // For recurring events this field is required and specifies the time zone in which the recurrence is expanded. + // For single events this field is optional and indicates a custom time zone for the event start/end. + timeZone?: string; + }; + + // The (exclusive) end time of the event. For a recurring event, this is the end time of the first instance. + end: { + // The date, in the format "yyyy-mm-dd", if this is an all-day event. + date?: date; + + // The time, as a combined date-time value (formatted according to RFC3339). + // A time zone offset is required unless a time zone is explicitly specified in timeZone. + dateTime?: datetime; + + // The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) + // For recurring events this field is required and specifies the time zone in which the recurrence is expanded. + // For single events this field is optional and indicates a custom time zone for the event start/end. + timeZone?: string; + }; + + // Whether the end time is actually unspecified. An end time is still provided for compatibility reasons, even if this attribute is set to True. + // The default is False. + endTimeUnspecified?: boolean; + + recurrence: string[]; + + // For an instance of a recurring event, this is the id of the recurring event to which this instance belongs. Immutable. + recurringEventId?: string; + + // Whether the organizer corresponds to the calendar on which this copy of the event appears. Read-only. The default is False. + originalStartTime?: { + date: date; + dateTime: datetime; + timeZone?: string; + }; + + transparency?: EventTransparency; + visibility?: EventVisibility; + iCalUID: string; + sequence: integer; + + // The attendees of the event. + attendees?: { + id: string; + email: string; + displayName?: string; + organizer: boolean; + self: boolean; + resource: boolean; + optional?: boolean; + responseStatus: AttendeeResponseStatus; + comment?: string; + additionalGuests?: integer; + }[]; + + attendeesOmitted?: boolean; + + // Extended properties of the event. + extendedProperties?: { + private: { + (key: string): string; + }; + shared: { + (key: string): string; + } + }; + + // An absolute link to the Google+ hangout associated with this event. Read-only. + hangoutLink?: string; + + // A gadget that extends this event. + gadget?: { + type: string; + title: string; + link: string; + iconLink: string; + width?: integer; + height?: integer; + display?: GadgetDisplayMode; + preferences: { + (key: string): string; + } + }; + + anyoneCanAddSelf?: boolean; + guestsCanInviteOthers?: boolean; + guestsCanModify?: boolean; + guestsCanSeeOtherGuests?: boolean; + privateCopy?: boolean; + + // Whether this is a locked event copy where no changes can be made to the main event fields "summary", "description", "location", "start", "end" or "recurrence". The default is False. Read-Only. + locked?: boolean; + + reminders: { + useDefault: boolean; + overrides?: { + method: ReminderMethod; + minutes: integer; + }[]; + }; + + // Source from which the event was created. For example, a web page, an email message or any document identifiable by an URL with HTTP or HTTPS scheme. + // Can only be seen or modified by the creator of the event. + source?: { + url: string; + title: string; + }; + + // File attachments for the event. Currently only Google Drive attachments are supported. + attachments?: { + fileUrl: string; + title: string; + mimeType: string; + iconLink: string; + fileId: string; + }[]; + } +} diff --git a/gapi.calendar/tsconfig.json b/gapi.calendar/tsconfig.json new file mode 100644 index 0000000000..7613ee5b3d --- /dev/null +++ b/gapi.calendar/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "module": "commonjs", + "lib": ["es6", "dom"], + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts", + "gapi.calendar-tests.ts" + ] +} From 5e762d799d6779106c33b899ed71839501b1443a Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Mon, 6 Mar 2017 01:18:30 +0200 Subject: [PATCH 027/150] Add compression-webpack-plugin --- .../compression-webpack-plugin-tests.ts | 14 +++++++ compression-webpack-plugin/index.d.ts | 40 +++++++++++++++++++ compression-webpack-plugin/tsconfig.json | 20 ++++++++++ compression-webpack-plugin/tslint.json | 7 ++++ 4 files changed, 81 insertions(+) create mode 100644 compression-webpack-plugin/compression-webpack-plugin-tests.ts create mode 100644 compression-webpack-plugin/index.d.ts create mode 100644 compression-webpack-plugin/tsconfig.json create mode 100644 compression-webpack-plugin/tslint.json diff --git a/compression-webpack-plugin/compression-webpack-plugin-tests.ts b/compression-webpack-plugin/compression-webpack-plugin-tests.ts new file mode 100644 index 0000000000..4ee93c78b7 --- /dev/null +++ b/compression-webpack-plugin/compression-webpack-plugin-tests.ts @@ -0,0 +1,14 @@ +import { Configuration } from 'webpack' +import * as CompressionPlugin from 'compression-webpack-plugin' + +const c: Configuration = { + plugins: [ + new CompressionPlugin({ + asset: "[path].gz[query]", + algorithm: "gzip", + test: /\.js$|\.html$/, + threshold: 10240, + minRatio: 0.8 + }) + ] +}; diff --git a/compression-webpack-plugin/index.d.ts b/compression-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..cf65f55300 --- /dev/null +++ b/compression-webpack-plugin/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for compression-webpack-plugin 0.3.2 +// Project: https://github.com/webpack-contrib/compression-webpack-plugin +// Definitions by: Anton Kandybo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin } from 'webpack'; + +export = CompressionPlugin; + +declare class CompressionPlugin extends Plugin { + constructor(options?: CompressionPlugin.Options); +} + +declare namespace CompressionPlugin { + export interface Options { + asset?: string; + algorithm?: string; + test?: RegExp | RegExp[]; + regExp?: RegExp | RegExp[]; + threshold?: number; + minRatio?: number; + + // zopfli options + verbose?: boolean; + verbose_more?: boolean; + numiterations?: number; + blocksplitting?: boolean; + blocksplittinglast?: boolean; + blocksplittingmax?: number; + + // zlib options + level?: number; + flush?: number; + chunkSize?: number; + windowBits?: number; + memLevel?: number; + strategy?: number; + dictionary?: any; + } +} diff --git a/compression-webpack-plugin/tsconfig.json b/compression-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..f9c84d64f8 --- /dev/null +++ b/compression-webpack-plugin/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "compression-webpack-plugin-tests.ts" + ] +} diff --git a/compression-webpack-plugin/tslint.json b/compression-webpack-plugin/tslint.json new file mode 100644 index 0000000000..02312e1c7d --- /dev/null +++ b/compression-webpack-plugin/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../tslint.json", + "rules": { + "dt-header": false + } + } + \ No newline at end of file From 972fc4d5606f96fc50b01bf2578f2cff786dd3a7 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Mon, 6 Mar 2017 01:26:47 +0200 Subject: [PATCH 028/150] Added es6 lib --- compression-webpack-plugin/tsconfig.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compression-webpack-plugin/tsconfig.json b/compression-webpack-plugin/tsconfig.json index f9c84d64f8..70383d3658 100644 --- a/compression-webpack-plugin/tsconfig.json +++ b/compression-webpack-plugin/tsconfig.json @@ -2,6 +2,9 @@ "compilerOptions": { "module": "commonjs", "target": "es6", + "lib": [ + "es6" + ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From eadbc0cd3badb6f402d66311b171e57d860f0b84 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 6 Mar 2017 15:32:29 +0100 Subject: [PATCH 029/150] async: Various fixes, mostly related to strict-nulls. Also some places where the error type was wrong. --- async/index.d.ts | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/async/index.d.ts b/async/index.d.ts index e3fbe7e512..7f71f3b9bc 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -6,17 +6,16 @@ interface Dictionary { [key: string]: T; } interface ErrorCallback { (err?: T): void; } -interface AsyncWaterfallCallback { (err: E, ...args: any[]): void; } -interface AsyncBooleanResultCallback { (err: E, truthValue: boolean): void; } -interface AsyncResultCallback { (err: E, result: T): void; } -interface AsyncResultArrayCallback { (err: E, results: T[]): void; } -interface AsyncResultObjectCallback { (err: E, results: Dictionary): void; } +interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } +interface AsyncResultCallback { (err?: E, result?: T): void; } +interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } +interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } -interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } +interface AsyncFunction { (callback: (err?: E, result?: T) => void): any; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } -interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; } +interface AsyncMemoIterator { (memo: R | undefined, item: T, callback: AsyncResultCallback): void; } interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanResultCallback): void; } interface AsyncWorker { (task: T, callback: ErrorCallback): void; } @@ -76,7 +75,7 @@ interface AsyncPriorityQueue { interface AsyncCargo { length(): number; - payload: number; + payload?: number; push(task: any, callback? : Function): void; push(task: any[], callback? : Function): void; saturated(): void; @@ -186,25 +185,25 @@ interface Async { cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; auto(tasks: any, concurrency?: number, callback?: AsyncResultCallback): void; autoInject(tasks: any, callback?: AsyncResultCallback): void; - retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; - retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; - retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; - apply(fn: Function, ...arguments: any[]): AsyncFunction; + retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; + retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; + retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; + apply(fn: Function, ...arguments: any[]): AsyncFunction; nextTick(callback: Function, ...args: any[]): void; setImmediate: typeof async.nextTick; - reflect(fn: AsyncFunction) : (callback: (err: void, result: {error?: Error, value?: T}) => void) => void; - reflectAll(tasks: AsyncFunction[]): ((callback: (err: void, result: {error?: Error, value?: T}) => void) => void)[]; + reflect(fn: AsyncFunction) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void; + reflectAll(tasks: AsyncFunction[]): ((callback: (err: undefined, result: {error?: E, value?: T}) => void) => void)[]; - timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; - timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; + timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; + timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; times (n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; transform(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void; - transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void; + transform(arr: T[], acc: R[], iteratee: (acc: R[] | null, item: T | undefined[], key?: string, callback?: (error?: E) => void) => void): void; transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; @@ -226,4 +225,3 @@ declare var async: Async; declare module "async" { export = async; } - From e19736d7fe980db3ddf649d7fb5a78a028c81d0f Mon Sep 17 00:00:00 2001 From: bappleyard Date: Tue, 7 Mar 2017 09:09:09 +0000 Subject: [PATCH 030/150] #15029 include declaration for DOMImplementation --- xmldom/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) mode change 100644 => 100755 xmldom/index.d.ts diff --git a/xmldom/index.d.ts b/xmldom/index.d.ts old mode 100644 new mode 100755 index dfbe34599c..8c252389cc --- a/xmldom/index.d.ts +++ b/xmldom/index.d.ts @@ -7,6 +7,11 @@ declare namespace xmldom { var DOMParser: DOMParserStatic; var XMLSerializer: XMLSerializerStatic; + var DOMImplementation: DOMImplementationStatic; + + interface DOMImplementationStatic { + new(): DOMImplementation; + } interface DOMParserStatic { new (): DOMParser; From 476377219255cabaf8ba512ccb4ac1cd5cb68907 Mon Sep 17 00:00:00 2001 From: Ben Swartz Date: Wed, 8 Mar 2017 11:18:34 -0800 Subject: [PATCH 031/150] Update Faker Definitions to V4.1.0 --- faker/faker-tests.ts | 22 +++ faker/index.d.ts | 36 +++- faker/v3/faker-tests.ts | 183 ++++++++++++++++++ faker/v3/index.d.ts | 416 ++++++++++++++++++++++++++++++++++++++++ faker/v3/tsconfig.json | 25 +++ 5 files changed, 680 insertions(+), 2 deletions(-) create mode 100644 faker/v3/faker-tests.ts create mode 100644 faker/v3/index.d.ts create mode 100644 faker/v3/tsconfig.json diff --git a/faker/faker-tests.ts b/faker/faker-tests.ts index 4dc2a3735f..5fb6a53746 100644 --- a/faker/faker-tests.ts +++ b/faker/faker-tests.ts @@ -52,6 +52,11 @@ resultStr = faker.company.bsAdjective(); resultStr = faker.company.bsBuzz(); resultStr = faker.company.bsNoun(); +resultStr = faker.database.column(); +resultStr = faker.database.type(); +resultStr = faker.database.collation(); +resultStr = faker.database.engine(); + resultDate = faker.date.past(); resultDate = faker.date.future(); resultDate = faker.date.between('foo', 'bar'); @@ -80,6 +85,8 @@ resultStr = faker.finance.transactionType(); resultStr = faker.finance.currencyCode(); resultStr = faker.finance.currencyName(); resultStr = faker.finance.currencySymbol(); +resultStr = faker.finance.bitcoinAddress(); +resultStr = faker.finance.bic(); resultStr = faker.hacker.abbreviation(); resultStr = faker.hacker.adjective(); @@ -110,6 +117,8 @@ resultStr = userCard.address.suite; resultStr = faker.internet.avatar(); resultStr = faker.internet.email(); resultStr = faker.internet.email('foo', 'bar', 'quux'); +resultStr = faker.internet.exampleEmail(); +resultStr = faker.internet.exampleEmail('foo', 'bar'); resultStr = faker.internet.protocol(); resultStr = faker.internet.url(); resultStr = faker.internet.domainName(); @@ -128,12 +137,18 @@ resultStr = faker.lorem.words(); resultStr = faker.lorem.words(0); resultStr = faker.lorem.sentence(); resultStr = faker.lorem.sentence(0, 0); +resultStr = faker.lorem.slug(); +resultStr = faker.lorem.slug(0); resultStr = faker.lorem.sentences(); resultStr = faker.lorem.sentences(0); resultStr = faker.lorem.paragraph(); resultStr = faker.lorem.paragraph(0); resultStr = faker.lorem.paragraphs(); resultStr = faker.lorem.paragraphs(0, ''); +resultStr = faker.lorem.text(); +resultStr = faker.lorem.text(0); +resultStr = faker.lorem.lines(); +resultStr = faker.lorem.lines(0); resultStr = faker.name.firstName(); resultStr = faker.name.firstName(0); @@ -169,6 +184,13 @@ resultStr = faker.random.objectElement(); resultStr = faker.random.objectElement({foo: 'bar', field: 'foo'}); resultStr = faker.random.uuid(); resultBool = faker.random.boolean(); +resultStr = faker.random.word(); +resultStr = faker.random.words(); +resultStr = faker.random.words(0); +resultStr = faker.random.image(); +resultStr = faker.random.locale(); +resultStr = faker.random.alphaNumeric(); +resultStr = faker.random.alphaNumeric(0); resultStr = faker.system.fileName( "foo", "bar" ); resultStr = faker.system.commonFileName( "foo", "bar" ); diff --git a/faker/index.d.ts b/faker/index.d.ts index 01e01b8b8b..8c6ea8ec6f 100644 --- a/faker/index.d.ts +++ b/faker/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for faker v3.1 +// Based off type definitions for faker v4.1.0 // Project: http://marak.com/faker.js/ -// Definitions by: Bas Pennings , Yuki Kokubun +// Definitions by: Ben Swartz , Bas Pennings , Yuki Kokubun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var fakerStatic: Faker.FakerStatic; @@ -52,6 +52,13 @@ declare namespace Faker { bsNoun(): string; }; + database: { + column(): string; + type(): string; + collation(): string; + engine(): string; + }; + date: { past(years?: number, refDate?: string|Date): Date; future(years?: number, refDate?: string|Date): Date; @@ -72,6 +79,8 @@ declare namespace Faker { currencyCode(): string; currencyName(): string; currencySymbol(): string; + bitcoinAddress(): string; + bic(): string }; hacker: { @@ -116,11 +125,13 @@ declare namespace Faker { sports(width?: number, height?: number): string; technics(width?: number, height?: number): string; transport(width?: number, height?: number): string; + dataUri(width?: number, height?: number): string; }; internet: { avatar(): string; email(firstName?: string, lastName?: string, provider?: string): string; + exampleEmail(firstName?: string, lastName?: string): string; userName(firstName?: string, lastName?: string): string; protocol(): string; url(): string; @@ -128,6 +139,7 @@ declare namespace Faker { domainSuffix(): string; domainWord(): string; ip(): string; + ipv6(): string; userAgent(): string; color(baseRed255?: number, baseGreen255?: number, baseBlue255?: number): string; mac(): string; @@ -138,9 +150,12 @@ declare namespace Faker { word(): string; words(num?: number): string; sentence(wordCount?: number, range?: number): string; + slug(wordCount?: number): string; sentences(sentenceCount?: number): string; paragraph(sentenceCount?: number): string; paragraphs(paragraphCount?: number, separator?: string): string; + text(times?: number): string; + lines(lineCount?: number): string; }; name: { @@ -171,6 +186,11 @@ declare namespace Faker { objectElement(object?: { [key: string]: T }, field?: any): T; uuid(): string; boolean(): boolean; + word(): string; // TODO: have ability to return specific type of word? As in: noun, adjective, verb, etc + words(count?: number): string; + image(): string; + locale(): string; + alphaNumeric(count?: number): string; }; system: { @@ -275,6 +295,14 @@ declare module "faker" { export = fakerStatic; } +declare module "faker/locale/az" { + export = fakerStatic; +} + +declare module "faker/locale/cz" { + export = fakerStatic; +} + declare module "faker/locale/de" { export = fakerStatic; } @@ -351,6 +379,10 @@ declare module "faker/locale/ge" { export = fakerStatic; } +declare module "faker/locale/id_ID" { + export = fakerStatic; +} + declare module "faker/locale/it" { export = fakerStatic; } diff --git a/faker/v3/faker-tests.ts b/faker/v3/faker-tests.ts new file mode 100644 index 0000000000..4dc2a3735f --- /dev/null +++ b/faker/v3/faker-tests.ts @@ -0,0 +1,183 @@ + + +let resultStr: string; +let resultBool: boolean; +let resultNum: number; +let resultStrArr: string[]; +let resultDate: Date; + +import faker = require('faker'); +faker.locale = 'en'; + +resultStr = faker.address.zipCode(); +resultStr = faker.address.zipCode('###'); +resultStr = faker.address.city(); +resultStr = faker.address.city(0); +resultStr = faker.address.cityPrefix(); +resultStr = faker.address.citySuffix(); +resultStr = faker.address.streetName(); +resultStr = faker.address.streetAddress(); +resultStr = faker.address.streetAddress(false);; +resultStr = faker.address.streetSuffix(); +resultStr = faker.address.streetPrefix(); +resultStr = faker.address.secondaryAddress(); +resultStr = faker.address.county(); +resultStr = faker.address.country(); +resultStr = faker.address.countryCode(); +resultStr = faker.address.state(); +resultStr = faker.address.state(false); +resultStr = faker.address.stateAbbr(); +resultStr = faker.address.latitude(); +resultStr = faker.address.longitude(); + +resultStr = faker.commerce.color(); +resultStr = faker.commerce.department(); +resultStr = faker.commerce.productName(); +resultStr = faker.commerce.price(); +resultStr = faker.commerce.price(0, 0, 0, '#'); +resultStr = faker.commerce.productAdjective(); +resultStr = faker.commerce.productMaterial(); +resultStr = faker.commerce.product(); + +resultStrArr = faker.company.suffixes(); +resultStr = faker.company.companyName(); +resultStr = faker.company.companyName(0); +resultStr = faker.company.companySuffix(); +resultStr = faker.company.catchPhrase(); +resultStr = faker.company.bs(); +resultStr = faker.company.catchPhraseAdjective(); +resultStr = faker.company.catchPhraseDescriptor(); +resultStr = faker.company.catchPhraseNoun(); +resultStr = faker.company.bsAdjective(); +resultStr = faker.company.bsBuzz(); +resultStr = faker.company.bsNoun(); + +resultDate = faker.date.past(); +resultDate = faker.date.future(); +resultDate = faker.date.between('foo', 'bar'); +resultDate = faker.date.between(new Date(), new Date()); +resultDate = faker.date.recent(); +resultDate = faker.date.recent(100); +resultStr = faker.date.month(); +resultStr = faker.date.month({ + abbr: true, + context: true +}); +resultStr = faker.date.weekday(); +resultStr = faker.date.weekday({ + abbr: true, + context: true +}); + +resultStr = faker.finance.account(); +resultStr = faker.finance.account(0); +resultStr = faker.finance.accountName(); +resultStr = faker.finance.mask(); +resultStr = faker.finance.mask(0, false, false); +resultStr = faker.finance.amount(); +resultStr = faker.finance.amount(0, 0, 0, '#'); +resultStr = faker.finance.transactionType(); +resultStr = faker.finance.currencyCode(); +resultStr = faker.finance.currencyName(); +resultStr = faker.finance.currencySymbol(); + +resultStr = faker.hacker.abbreviation(); +resultStr = faker.hacker.adjective(); +resultStr = faker.hacker.noun(); +resultStr = faker.hacker.verb(); +resultStr = faker.hacker.ingverb(); +resultStr = faker.hacker.phrase(); + +resultStr = faker.helpers.randomize(); +resultNum = faker.helpers.randomize([1,2,3,4]); +resultStr = faker.helpers.randomize(['foo', 'bar', 'quux']); +resultStr = faker.helpers.slugify('foo bar quux'); +resultStr = faker.helpers.replaceSymbolWithNumber('foo# bar#'); +resultStr = faker.helpers.replaceSymbols('foo# bar? quux#'); +resultStrArr = faker.helpers.shuffle(['foo', 'bar', 'quux']); +resultStr = faker.helpers.mustache('{{foo}}{{bar}}', {foo: 'x', bar: 'y'}); + +const card = faker.helpers.createCard(); +resultStr = card.name; +resultStr = card.address.streetA; +const contextualCard = faker.helpers.contextualCard(); +resultStr = contextualCard.name; +resultStr = contextualCard.address.suite; +const userCard = faker.helpers.userCard(); +resultStr = userCard.name; +resultStr = userCard.address.suite; + +resultStr = faker.internet.avatar(); +resultStr = faker.internet.email(); +resultStr = faker.internet.email('foo', 'bar', 'quux'); +resultStr = faker.internet.protocol(); +resultStr = faker.internet.url(); +resultStr = faker.internet.domainName(); +resultStr = faker.internet.domainSuffix(); +resultStr = faker.internet.domainWord(); +resultStr = faker.internet.ip(); +resultStr = faker.internet.userAgent(); +resultStr = faker.internet.color(); +resultStr = faker.internet.color(0, 0, 0); +resultStr = faker.internet.mac(); +resultStr = faker.internet.password(); +resultStr = faker.internet.password(0, false, '#', 'foo'); + +resultStr = faker.lorem.word(); +resultStr = faker.lorem.words(); +resultStr = faker.lorem.words(0); +resultStr = faker.lorem.sentence(); +resultStr = faker.lorem.sentence(0, 0); +resultStr = faker.lorem.sentences(); +resultStr = faker.lorem.sentences(0); +resultStr = faker.lorem.paragraph(); +resultStr = faker.lorem.paragraph(0); +resultStr = faker.lorem.paragraphs(); +resultStr = faker.lorem.paragraphs(0, ''); + +resultStr = faker.name.firstName(); +resultStr = faker.name.firstName(0); +resultStr = faker.name.lastName(); +resultStr = faker.name.lastName(0); +resultStr = faker.name.findName(); +resultStr = faker.name.findName('', '', 0); +resultStr = faker.name.jobTitle(); +resultStr = faker.name.prefix(); +resultStr = faker.name.suffix(); +resultStr = faker.name.title(); +resultStr = faker.name.jobDescriptor(); +resultStr = faker.name.jobArea(); +resultStr = faker.name.jobType(); + +resultStr = faker.phone.phoneNumber(); +resultStr = faker.phone.phoneNumber('#'); +resultStr = faker.phone.phoneNumberFormat(); +// https://github.com/Marak/faker.js/blob/master/lib/phone_number.js#L9-L13 +resultStr = faker.phone.phoneNumberFormat(0); +resultStr = faker.phone.phoneFormats(); + +resultNum = faker.random.number(); +resultNum = faker.random.number(0); +resultNum = faker.random.number({ + min: 0, + max: 0, + precision: 0 +}); +resultStr = faker.random.arrayElement(); +resultStr = faker.random.arrayElement(['foo', 'bar', 'quux']) +resultStr = faker.random.objectElement(); +resultStr = faker.random.objectElement({foo: 'bar', field: 'foo'}); +resultStr = faker.random.uuid(); +resultBool = faker.random.boolean(); + +resultStr = faker.system.fileName( "foo", "bar" ); +resultStr = faker.system.commonFileName( "foo", "bar" ); +resultStr = faker.system.mimeType(); +resultStr = faker.system.commonFileType(); +resultStr = faker.system.commonFileExt(); +resultStr = faker.system.fileType(); +resultStr = faker.system.fileExt( "foo" ); +resultStr = faker.system.semver(); + +import fakerEn = require('faker/locale/en'); +resultStr = faker.name.firstName(); diff --git a/faker/v3/index.d.ts b/faker/v3/index.d.ts new file mode 100644 index 0000000000..01e01b8b8b --- /dev/null +++ b/faker/v3/index.d.ts @@ -0,0 +1,416 @@ +// Type definitions for faker v3.1 +// Project: http://marak.com/faker.js/ +// Definitions by: Bas Pennings , Yuki Kokubun +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare var fakerStatic: Faker.FakerStatic; + +declare namespace Faker { + interface FakerStatic { + locale: string; + + address: { + zipCode(format?: string): string; + city(format?: number): string; + cityPrefix(): string; + citySuffix(): string; + streetName(): string; + streetAddress(useFullAddress?: boolean): string; + streetSuffix(): string; + streetPrefix(): string; + secondaryAddress(): string; + county(): string; + country(): string; + countryCode(): string; + state(useAbbr?: boolean): string; + stateAbbr(): string; + latitude(): string; + longitude(): string; + }; + + commerce: { + color(): string; + department(): string; + productName(): string; + price(min?: number, max?: number, dec?: number, symbol?: string): string; + productAdjective(): string; + productMaterial(): string; + product(): string; + }; + + company: { + suffixes(): string[]; + companyName(format?: number): string; + companySuffix(): string; + catchPhrase(): string; + bs(): string; + catchPhraseAdjective(): string; + catchPhraseDescriptor(): string; + catchPhraseNoun(): string; + bsAdjective(): string; + bsBuzz(): string; + bsNoun(): string; + }; + + date: { + past(years?: number, refDate?: string|Date): Date; + future(years?: number, refDate?: string|Date): Date; + between(from: string|number|Date, to: string|Date): Date; + recent(days?: number): Date; + month(options?: { abbr?: boolean, context?: boolean }): string; + weekday(options?: { abbr?: boolean, context?: boolean }): string; + }; + + fake(str: string): string; + + finance: { + account(length?: number): string; + accountName(): string; + mask(length?: number, parens?: boolean, elipsis?: boolean): string; + amount(min?:number, max?: number, dec?: number, symbol?: string): string; + transactionType(): string; + currencyCode(): string; + currencyName(): string; + currencySymbol(): string; + }; + + hacker: { + abbreviation(): string; + adjective(): string; + noun(): string; + verb(): string; + ingverb(): string; + phrase(): string; + }; + + helpers: { + randomize(array: T[]): T; + randomize(): string; + slugify(string?: string): string; + replaceSymbolWithNumber(string?: string, symbol?: string): string; + replaceSymbols(string?: string): string; + shuffle(o: T[]): T[]; + shuffle(): string[]; + mustache(str: string, data: { [key: string]: string|((substring: string, ...args: any[]) => string) }): string; + createCard(): Faker.Card; + contextualCard(): Faker.ContextualCard; + userCard(): Faker.UserCard; + createTransaction(): Faker.Transaction; + }; + + + image: { + image(): string; + avatar(): string; + imageUrl(width?: number, height?: number, category?: string): string; + abstract(width?: number, height?: number): string; + animals(width?: number, height?: number): string; + business(width?: number, height?: number): string; + cats(width?: number, height?: number): string; + city(width?: number, height?: number): string; + food(width?: number, height?: number): string; + nightlife(width?: number, height?: number): string; + fashion(width?: number, height?: number): string; + people(width?: number, height?: number): string; + nature(width?: number, height?: number): string; + sports(width?: number, height?: number): string; + technics(width?: number, height?: number): string; + transport(width?: number, height?: number): string; + }; + + internet: { + avatar(): string; + email(firstName?: string, lastName?: string, provider?: string): string; + userName(firstName?: string, lastName?: string): string; + protocol(): string; + url(): string; + domainName(): string; + domainSuffix(): string; + domainWord(): string; + ip(): string; + userAgent(): string; + color(baseRed255?: number, baseGreen255?: number, baseBlue255?: number): string; + mac(): string; + password(len?: number, memorable?: boolean, pattern?: string|RegExp, prefix?: string): string; + }; + + lorem: { + word(): string; + words(num?: number): string; + sentence(wordCount?: number, range?: number): string; + sentences(sentenceCount?: number): string; + paragraph(sentenceCount?: number): string; + paragraphs(paragraphCount?: number, separator?: string): string; + }; + + name: { + firstName(gender?: number): string; + lastName(gender?: number): string; + findName(firstName?: string, lastName?: string, gender?: number): string; + jobTitle(): string; + prefix(): string; + suffix(): string; + title(): string; + jobDescriptor(): string; + jobArea(): string; + jobType(): string; + }; + + phone: { + phoneNumber(format?: string): string; + phoneNumberFormat(phoneFormatsArrayIndex?: number): string; + phoneFormats(): string; + }; + + random: { + number(max: number): number; + number(options?: { min?: number, max?: number, precision?: number }): number; + arrayElement(): string; + arrayElement(array: T[]): T; + objectElement(object?: { [key: string]: any }, field?: "key"): string; + objectElement(object?: { [key: string]: T }, field?: any): T; + uuid(): string; + boolean(): boolean; + }; + + system: { + fileName(ext: string, type: string): string; + commonFileName(ext: string, type: string): string; + mimeType(): string; + commonFileType(): string; + commonFileExt(): string; + fileType(): string; + fileExt(mimeType: string): string; + //directoryPath(): string; + //filePath(): string; + semver(): string; + }; + + seed(value: number): void; + } + + interface Card { + name: string; + username: string; + email: string; + address: FullAddress; + phone: string; + website: string; + company: Company; + posts: Post[]; + accountHistory: string[]; + } + + interface FullAddress { + streetA: string; + streetB: string; + streetC: string; + streetD: string; + city: string; + state: string; + county: string; + zipcode: string; + geo: Geo; + } + + interface Geo { + lat: string; + lng: string; + } + + interface Company { + name: string; + catchPhrase: string; + bs: string; + } + + interface Post { + words: string; + sentence: string; + sentences: string; + paragraph: string; + } + + interface ContextualCard { + name: string; + username: string; + email: string; + dob: Date; + phone: string; + address: Address; + website: string; + company: Company; + } + + interface Address { + street: string; + suite: string; + city: string; + state: string; + zipcode: string; + geo: Geo; + } + + interface UserCard { + name: string; + username: string; + email: string; + address: Address; + phone: string; + website: string; + company: Company; + } + + interface Transaction { + amount: string; + date: Date; + business: string; + name: string; + type: string; + account: string; + } +} + +declare module "faker" { + export = fakerStatic; +} + +declare module "faker/locale/de" { + export = fakerStatic; +} + +declare module "faker/locale/de_AT" { + export = fakerStatic; +} + +declare module "faker/locale/de_CH" { + export = fakerStatic; +} + +declare module "faker/locale/el_GR" { + export = fakerStatic; +} + +declare module "faker/locale/en" { + export = fakerStatic; +} + +declare module "faker/locale/en_AU" { + export = fakerStatic; +} + +declare module "faker/locale/en_BORK" { + export = fakerStatic; +} + +declare module "faker/locale/en_CA" { + export = fakerStatic; +} + +declare module "faker/locale/en_GB" { + export = fakerStatic; +} + +declare module "faker/locale/en_IE" { + export = fakerStatic; +} + +declare module "faker/locale/en_IND" { + export = fakerStatic; +} + +declare module "faker/locale/en_US" { + export = fakerStatic; +} + +declare module "faker/locale/en_au_ocker" { + export = fakerStatic; +} + +declare module "faker/locale/es" { + export = fakerStatic; +} + +declare module "faker/locale/es_MX" { + export = fakerStatic; +} + +declare module "faker/locale/fa" { + export = fakerStatic; +} + +declare module "faker/locale/fr" { + export = fakerStatic; +} + +declare module "faker/locale/fr_CA" { + export = fakerStatic; +} + +declare module "faker/locale/ge" { + export = fakerStatic; +} + +declare module "faker/locale/it" { + export = fakerStatic; +} + +declare module "faker/locale/ja" { + export = fakerStatic; +} + +declare module "faker/locale/ko" { + export = fakerStatic; +} + +declare module "faker/locale/nb_NO" { + export = fakerStatic; +} + +declare module "faker/locale/nep" { + export = fakerStatic; +} + +declare module "faker/locale/nl" { + export = fakerStatic; +} + +declare module "faker/locale/pl" { + export = fakerStatic; +} + +declare module "faker/locale/pt_BR" { + export = fakerStatic; +} + +declare module "faker/locale/ru" { + export = fakerStatic; +} + +declare module "faker/locale/sk" { + export = fakerStatic; +} + +declare module "faker/locale/sv" { + export = fakerStatic; +} + +declare module "faker/locale/tr" { + export = fakerStatic; +} + +declare module "faker/locale/uk" { + export = fakerStatic; +} + +declare module "faker/locale/vi" { + export = fakerStatic; +} + +declare module "faker/locale/zh_CN" { + export = fakerStatic; +} + +declare module "faker/locale/zh_TW" { + export = fakerStatic; +} diff --git a/faker/v3/tsconfig.json b/faker/v3/tsconfig.json new file mode 100644 index 0000000000..40af61eba9 --- /dev/null +++ b/faker/v3/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "faker": [ "faker/v3" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "faker-tests.ts" + ] +} From c105965b68d0639a6360c5a6bb3b7c98c79b2bee Mon Sep 17 00:00:00 2001 From: Ben Swartz Date: Wed, 8 Mar 2017 11:28:16 -0800 Subject: [PATCH 032/150] Change Header Comment --- faker/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faker/index.d.ts b/faker/index.d.ts index 8c6ea8ec6f..ccca40e51a 100644 --- a/faker/index.d.ts +++ b/faker/index.d.ts @@ -1,4 +1,4 @@ -// Based off type definitions for faker v4.1.0 +// Type definitions for faker v4.1.0 // Project: http://marak.com/faker.js/ // Definitions by: Ben Swartz , Bas Pennings , Yuki Kokubun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 7275ca875933bc55aa8bef54fd296560ae0ecc7c Mon Sep 17 00:00:00 2001 From: Ben Swartz Date: Wed, 8 Mar 2017 13:52:41 -0800 Subject: [PATCH 033/150] set strictNullChecks to true, add new line at eof --- faker/tsconfig.json | 4 ++-- faker/v3/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/faker/tsconfig.json b/faker/tsconfig.json index c2ce14c941..0589e5dc54 100644 --- a/faker/tsconfig.json +++ b/faker/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "faker-tests.ts" ] -} \ No newline at end of file +} diff --git a/faker/v3/tsconfig.json b/faker/v3/tsconfig.json index 40af61eba9..052493a9c7 100644 --- a/faker/v3/tsconfig.json +++ b/faker/v3/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From 3186a2ba273c41c91bde9f4adff3067ae1c901f7 Mon Sep 17 00:00:00 2001 From: voxmatt Date: Thu, 9 Mar 2017 16:52:56 -0800 Subject: [PATCH 034/150] fleshing out the relayProp --- react-relay/index.d.ts | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index 9c45ed9c7c..8170e03190 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -31,6 +31,24 @@ declare module "react-relay" { response: any } + type RelayMutationStatus = + 'UNCOMMITTED' | // Transaction hasn't yet been sent to the server. Transaction can be committed or rolled back. + 'COMMIT_QUEUED' | // Transaction was committed but another transaction with the same collision key is pending, so the transaction has been queued to send to the server. + 'COLLISION_COMMIT_FAILED' | //Transaction was queued for commit but another transaction with the same collision key failed. All transactions in the collision queue, including this one, have been failed. Transaction can be recommitted or rolled back. + 'COMMITTING' | // Transaction is waiting for the server to respond. + 'COMMIT_FAILED'; + + class RelayMutationTransaction { + applyOptimistic(): RelayMutationTransaction; + commit(): RelayMutationTransaction; + recommit(): void; + rollback(): void; + getError(): Error; + getStatus(): RelayMutationStatus; + getHash(): string; + getID(): string; + } + interface RelayMutationRequest { getQueryString(): string getVariables(): RelayVariables @@ -104,7 +122,7 @@ declare module "react-relay" { renderFailure?(error: Error, retry: Function): JSX.Element } - type ReadyStateEvent = + type ReadyStateEvent = 'ABORT' | 'CACHE_RESTORED_REQUIRED' | 'CACHE_RESTORE_FAILED' | @@ -128,7 +146,12 @@ declare module "react-relay" { } interface RelayProp { - variables: any - setVariables(variables: Object, onReadyStateChange?: OnReadyStateChange): void + route: { name: string; }; // incomplete, also has params and queries + variables: any; + pendingVariables?: any; + setVariables(variables: Object, onReadyStateChange?: OnReadyStateChange): void; + forceFetch(variables: Object, onReadyStateChange?: OnReadyStateChange): void; + hasOptimisticUpdate(record: any): boolean; + getPendingTransactions(record: any): RelayMutationTransaction[]; } } From 4cc74c831a3f186cf42e417a462257f97fa526e3 Mon Sep 17 00:00:00 2001 From: voxmatt Date: Thu, 9 Mar 2017 17:22:18 -0800 Subject: [PATCH 035/150] fixing tests --- react-relay/index.d.ts | 4 ++-- react-relay/react-relay-tests.tsx | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index 8170e03190..5b40145d18 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -151,7 +151,7 @@ declare module "react-relay" { pendingVariables?: any; setVariables(variables: Object, onReadyStateChange?: OnReadyStateChange): void; forceFetch(variables: Object, onReadyStateChange?: OnReadyStateChange): void; - hasOptimisticUpdate(record: any): boolean; - getPendingTransactions(record: any): RelayMutationTransaction[]; + hasOptimisticUpdate(record?: any): boolean; + getPendingTransactions(record?: any): RelayMutationTransaction[]; } } diff --git a/react-relay/react-relay-tests.tsx b/react-relay/react-relay-tests.tsx index 7160e60b0a..fa27f10c01 100644 --- a/react-relay/react-relay-tests.tsx +++ b/react-relay/react-relay-tests.tsx @@ -74,10 +74,16 @@ class StubbedArtwork extends React.Component { const props = { artwork: { title: "CHAMPAGNE FORMICA FLAG" }, relay: { + route: { + name: "champagne" + }, variables: { artworkID: "champagne-formica-flag", }, setVariables: () => {}, + forceFetch: () => {}, + hasOptimisticUpdate: () => false, + getPendingTransactions: (): Relay.RelayMutationTransaction[] => undefined, } } return From 498bf589489249b77f4259a95fe9dd97a670aab6 Mon Sep 17 00:00:00 2001 From: voxmatt Date: Thu, 9 Mar 2017 17:26:33 -0800 Subject: [PATCH 036/150] adding in commitUpdate while I'm at it --- react-relay/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index 5b40145d18..0f6dbba024 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -153,5 +153,6 @@ declare module "react-relay" { forceFetch(variables: Object, onReadyStateChange?: OnReadyStateChange): void; hasOptimisticUpdate(record?: any): boolean; getPendingTransactions(record?: any): RelayMutationTransaction[]; + commitUpdate?: (mutation: Mutation, callbacks?: StoreUpdateCallbacks) => any; } } From b00b86d7197ed3217557fc6e88657c19a8b67f55 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 09:57:24 +0200 Subject: [PATCH 037/150] Enable dt-header tslint rule --- compression-webpack-plugin/tslint.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/compression-webpack-plugin/tslint.json b/compression-webpack-plugin/tslint.json index 02312e1c7d..70cee1ba88 100644 --- a/compression-webpack-plugin/tslint.json +++ b/compression-webpack-plugin/tslint.json @@ -1,7 +1,4 @@ { - "extends": "../tslint.json", - "rules": { - "dt-header": false - } - } + "extends": "../tslint.json" +} \ No newline at end of file From 9e069e784e7a5bc12f1abacd71b319a9f02f1c8b Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 10:13:16 +0200 Subject: [PATCH 038/150] Using require syntax in tests --- .../compression-webpack-plugin-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compression-webpack-plugin/compression-webpack-plugin-tests.ts b/compression-webpack-plugin/compression-webpack-plugin-tests.ts index 4ee93c78b7..3939bf5847 100644 --- a/compression-webpack-plugin/compression-webpack-plugin-tests.ts +++ b/compression-webpack-plugin/compression-webpack-plugin-tests.ts @@ -1,5 +1,5 @@ -import { Configuration } from 'webpack' -import * as CompressionPlugin from 'compression-webpack-plugin' +import { Configuration } from 'webpack'; +import CompressionPlugin = require('compression-webpack-plugin'); const c: Configuration = { plugins: [ From 911335f7fe972e349f402ce229627095b38ab020 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 10:14:53 +0200 Subject: [PATCH 039/150] Remove patch version --- compression-webpack-plugin/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compression-webpack-plugin/index.d.ts b/compression-webpack-plugin/index.d.ts index cf65f55300..536a77b8e9 100644 --- a/compression-webpack-plugin/index.d.ts +++ b/compression-webpack-plugin/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for compression-webpack-plugin 0.3.2 +// Type definitions for compression-webpack-plugin 0.3 // Project: https://github.com/webpack-contrib/compression-webpack-plugin // Definitions by: Anton Kandybo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From e466571159287b9cbab031fc0b4f919a95694c12 Mon Sep 17 00:00:00 2001 From: voxmatt Date: Fri, 10 Mar 2017 10:29:12 -0800 Subject: [PATCH 040/150] a bunch of updates in response to code review --- react-relay/index.d.ts | 16 +++++++++------- react-relay/react-relay-tests.tsx | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index 0f6dbba024..961acbccc2 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -7,6 +7,8 @@ declare module "react-relay" { import * as React from "react"; + type ClientMutationID = string; + /** Fragments are a hash of functions */ interface Fragments { [query: string]: ((variables?: RelayVariables) => string) @@ -40,13 +42,13 @@ declare module "react-relay" { class RelayMutationTransaction { applyOptimistic(): RelayMutationTransaction; - commit(): RelayMutationTransaction; + commit(): RelayMutationTransaction | null; recommit(): void; rollback(): void; getError(): Error; getStatus(): RelayMutationStatus; getHash(): string; - getID(): string; + getID(): ClientMutationID; } interface RelayMutationRequest { @@ -147,12 +149,12 @@ declare module "react-relay" { interface RelayProp { route: { name: string; }; // incomplete, also has params and queries - variables: any; - pendingVariables?: any; + variables: Object; + pendingVariables?: Object | null; setVariables(variables: Object, onReadyStateChange?: OnReadyStateChange): void; forceFetch(variables: Object, onReadyStateChange?: OnReadyStateChange): void; - hasOptimisticUpdate(record?: any): boolean; - getPendingTransactions(record?: any): RelayMutationTransaction[]; - commitUpdate?: (mutation: Mutation, callbacks?: StoreUpdateCallbacks) => any; + hasOptimisticUpdate(record: Object): boolean; + getPendingTransactions(record: Object): RelayMutationTransaction[]; + commitUpdate: (mutation: Mutation, callbacks?: StoreUpdateCallbacks) => any; } } diff --git a/react-relay/react-relay-tests.tsx b/react-relay/react-relay-tests.tsx index fa27f10c01..091909cabd 100644 --- a/react-relay/react-relay-tests.tsx +++ b/react-relay/react-relay-tests.tsx @@ -84,6 +84,7 @@ class StubbedArtwork extends React.Component { forceFetch: () => {}, hasOptimisticUpdate: () => false, getPendingTransactions: (): Relay.RelayMutationTransaction[] => undefined, + commitUpdate: () => {}, } } return From 0a5c482bc7b4a830644c6103640d391749517fae Mon Sep 17 00:00:00 2001 From: voxmatt Date: Fri, 10 Mar 2017 14:23:33 -0800 Subject: [PATCH 041/150] fixing tests and removing Object references --- react-relay/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index 961acbccc2..a693527e3e 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -15,7 +15,7 @@ declare module "react-relay" { } interface CreateContainerOpts { - initialVariables?: Object + initialVariables?: any fragments: Fragments prepareVariables?(prevVariables: RelayVariables): RelayVariables } @@ -148,13 +148,13 @@ declare module "react-relay" { } interface RelayProp { - route: { name: string; }; // incomplete, also has params and queries - variables: Object; - pendingVariables?: Object | null; - setVariables(variables: Object, onReadyStateChange?: OnReadyStateChange): void; - forceFetch(variables: Object, onReadyStateChange?: OnReadyStateChange): void; - hasOptimisticUpdate(record: Object): boolean; - getPendingTransactions(record: Object): RelayMutationTransaction[]; + readonly route: { name: string; }; // incomplete, also has params and queries + readonly variables: any; + readonly pendingVariables?: any | null; + setVariables(variables: any, onReadyStateChange?: OnReadyStateChange): void; + forceFetch(variables: any, onReadyStateChange?: OnReadyStateChange): void; + hasOptimisticUpdate(record: any): boolean; + getPendingTransactions(record: any): RelayMutationTransaction[]; commitUpdate: (mutation: Mutation, callbacks?: StoreUpdateCallbacks) => any; } } From 5dc3a5eb9caab465735a863f8d53feaa9e09dc68 Mon Sep 17 00:00:00 2001 From: Jan Alonzo Date: Sat, 11 Mar 2017 16:04:46 +1100 Subject: [PATCH 042/150] Remove localforage folder --- localforage/package.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 localforage/package.json diff --git a/localforage/package.json b/localforage/package.json deleted file mode 100644 index 29f45814b2..0000000000 --- a/localforage/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "localforage": ">=1.5.0" - } -} From 8fcc61d878839c2166a9ededf4cda7aced43a030 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Thu, 23 Feb 2017 19:41:04 +0100 Subject: [PATCH 043/150] Added export for nodejs Closes #14815 --- jointjs/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jointjs/index.d.ts b/jointjs/index.d.ts index 95e2b2b7e3..cd9d722ec5 100644 --- a/jointjs/index.d.ts +++ b/jointjs/index.d.ts @@ -6,6 +6,9 @@ /// +declare module "jointjs" { + export = joint; +} declare namespace joint { export var g: any; From 8dd3e03bedbb3e94a25761ab5cfea65b4b728abb Mon Sep 17 00:00:00 2001 From: CaselIT Date: Thu, 23 Feb 2017 20:45:45 +0100 Subject: [PATCH 044/150] Changed to export as namespace --- jointjs/index.d.ts | 1684 ++++++++++++++++++++++---------------------- rappid/index.d.ts | 49 +- 2 files changed, 867 insertions(+), 866 deletions(-) diff --git a/jointjs/index.d.ts b/jointjs/index.d.ts index cd9d722ec5..5ce0f187f0 100644 --- a/jointjs/index.d.ts +++ b/jointjs/index.d.ts @@ -6,894 +6,892 @@ /// -declare module "jointjs" { - export = joint; +import * as Backbone from "backbone"; + +export as namespace joint; + +export var g: any; +export var V: any; + +export namespace dia { + interface Size { + width: number; + height: number; + } + + interface Point { + x: number; + y: number; + } + + interface BBox extends Point, Size { } + + interface TranslateOptions { + restrictedArea?: BBox; + transition?: TransitionOptions; + } + + interface TransitionOptions { + delay?: number; + duration?: number; + timingFunction?: (t: number) => number; + valueFunction?: (a: any, b: any) => (t: number) => any; + } + + interface DfsBfsOptions { + inbound?: boolean; + outbound?: boolean; + deep?: boolean; + } + + interface ExploreOptions { + breadthFirst?: boolean; + deep?: boolean; + } + + class Graph extends Backbone.Model { + constructor(attributes?: any, options?: { cellNamespace: any }); + addCell(cell: Cell | Cell[]): this; + addCells(cells: Cell[]): this; + resetCells(cells: Cell[], options?: any): this; + getCell(id: string): Cell; + getElements(): Element[]; + getLinks(): Link[]; + getCells(): Cell[]; + getFirstCell(): Cell; + getLastCell(): Cell; + getConnectedLinks(element: Cell, options?: { inbound?: boolean, outbound?: boolean, deep?: boolean }): Link[]; + disconnectLinks(cell: Cell, options?: any): void; + removeLinks(cell: Cell, options?: any): void; + translate(tx: number, ty?: number, options?: TranslateOptions): void; + cloneCells(cells: Cell[]): { [id: string]: Cell }; + getSubgraph(cells: Cell[], options?: { deep?: boolean }): Cell[]; + cloneSubgraph(cells: Cell[], options?: { deep?: boolean }): { [id: string]: Cell }; + dfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions, visited?: Object, distance?: number): void; + bfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions): void; + search(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: { breadthFirst?: boolean }): void; + getSuccessors(element: Element, options?: ExploreOptions): Element[]; + getPredecessors(element: Element, options?: ExploreOptions): Element[]; + isSuccessor(elementA: Element, elementB: Element): boolean; + isPredecessor(elementA: Element, elementB: Element): boolean; + isSource(element: Element): boolean; + isSink(element: Element): boolean; + getSources(): Element[]; + getSinks(): Element[]; + getNeighbors(element: Element, options?: DfsBfsOptions): Element[]; + isNeighbor(elementA: Element, elementB: Element, options?: { inbound?: boolean, outbound?: boolean; }): boolean; + getCommonAncestor(...cells: Cell[]): Element; + toJSON(): any; + fromJSON(json: any, options?: any): this; + clear(options?: any): this; + findModelsFromPoint(rect: BBox): Element[]; + findModelsUnderElement(element: Element, options?: { searchBy?: 'bbox' | 'center' | 'origin' | 'corner' | 'topRight' | 'bottomLeft' }): Element[]; + getBBox(elements: Element[], options?: any): BBox; + toGraphLib(): any; // graphlib graph object + findModelsInArea(rect: BBox, options?: any): BBox | boolean; + getCellsBBox(cells: Cell[], options?: any): BBox; + getInboundEdges(node: string): Object; + getOutboundEdges(node: string): Object; + hasActiveBatch(name?: string): number | boolean; + maxZIndex(): number; + removeCells(cells: Cell[], options?: any): this; + resize(width: number, height: number, options?: number): this; + resizeCells(width: number, height: number, cells: Cell[], options?: number): this; + set(key: Object | string, value: any, options?: any): this; + startBatch(name: string, data?: Object): any; + stopBatch(name: string, data?: Object): any; + } + + class Cell extends Backbone.Model { + id: string; + toJSON(): any; + remove(options?: { disconnectLinks?: boolean }): this; + toFront(options?: { deep?: boolean }): this; + toBack(options?: { deep?: boolean }): this; + getAncestors(): Cell[]; + isEmbeddedIn(element: Element, options?: { deep: boolean }): boolean; + prop(key: string): any; + prop(object: any): this; + prop(key: string, value: any, options?: any): this; + removeProp(path: string, options?: any): this; + attr(key: string): any; + attr(object: SVGAttributes): this; + attr(key: string, value: any): this; + clone(): Cell; + clone(opt: { deep?: boolean }): Cell | Cell[]; + removeAttr(path: string | string[], options?: any): this; + transition(path: string, value?: any, options?: TransitionOptions, delim?: string): number; + getTransitions(): string[]; + stopTransitions(path?: string, delim?: string): this; + addTo(graph: Graph, options?: any): this; + isLink(): boolean; + embed(cell: Cell, options?: any): this; + findView(paper: Paper): CellView; + getEmbeddedCells(options?: any): Cell[]; + initialize(options?: any): void; + isElement(): boolean; + isEmbedded(): boolean; + processPorts(): void; + startBatch(name: string, options?: any): this; + stopBatch(name: string, options?: any): this; + unembed(cell: Cell, options?: any): this; + } + + type Padding = number | { + top?: number; + right?: number; + bottom?: number; + left?: number + }; + + class Element extends Cell { + translate(tx: number, ty?: number, options?: TranslateOptions): this; + position(options?: { parentRelative: boolean }): Point; + position(x: number, y: number, options?: { parentRelative?: boolean }): this; + resize(width: number, height: number, options?: { direction?: 'left' | 'right' | 'top' | 'bottom' | 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right' }): this; + rotate(deg: number, absolute?: boolean, origin?: Point): this; + embed(cell: Cell): this; + unembed(cell: Cell): this; + getEmbeddedCells(options?: ExploreOptions): Cell[]; + fitEmbeds(options?: { deep?: boolean, padding?: Padding }): this; + getBBox(options?: any): BBox; + findView(paper: Paper): ElementView; + isElement(): boolean; + scale(scaleX: number, scaleY: number, origin?: Point, options?: any): this; + addPort(port: any, opt?: any): this; + addPorts(ports: any[], opt?: any): this; + removePort(port: any, opt?: any): this; + hasPorts(): boolean; + hasPort(id: string): boolean; + getPorts(): any[]; + getPort(id: string): any; + getPortIndex(port: any): number; + portProp(portId: string, path: any, value?: any, opt?: any): joint.dia.Element; + } + + interface CSSSelector { + [key: string]: string | number | Object; // Object added to support special attributes like filter http://jointjs.com/api#SpecialAttributes:filter + } + + interface SVGAttributes { + [selector: string]: CSSSelector; + } + + interface CellAttributes { + [key: string]: any; + } + + interface TextAttrs extends SVGAttributes { + text?: { + [key: string]: string | number; + text?: string; + }; + } + + interface Label { + position: number; + attrs?: TextAttrs; + } + interface LinkAttributes extends CellAttributes { + source?: Point | { id: string, selector?: string, port?: string }; + target?: Point | { id: string, selector?: string, port?: string }; + labels?: Label[]; + vertices?: Point[]; + smooth?: boolean; + attrs?: TextAttrs; + z?: number; + } + + class Link extends Cell { + markup: string; + labelMarkup: string; + toolMakup: string; + vertexMarkup: string; + arrowHeadMarkup: string; + + constructor(attributes?: LinkAttributes, options?: Object); + disconnect(): this; + label(index?: number): any; + label(index: number, value: Label): this; + reparent(options?: any): Element; + findView(paper: Paper): LinkView; + getSourceElement(): Element; + getTargetElement(): Element; + hasLoop(options?: { deep?: boolean }): boolean; + applyToPoints(fn: Function, options?: any): this; + getRelationshipAncestor(): Element; + isLink(): boolean; + isRelationshipEmbeddedIn(element: Element): boolean; + scale(sx: number, sy: number, origin: Point, optionts?: any): this; + translate(tx: number, ty: number, options?: any): this; + } + + interface ManhattanRouterArgs { + excludeTypes?: string[]; + excludeEnds?: 'source' | 'target'; + startDirections?: ['left' | 'right' | 'top' | 'bottom']; + endDirections?: ['left' | 'right' | 'top' | 'bottom']; + } + + interface PaperOptions extends Backbone.ViewOptions { + el?: string | JQuery | HTMLElement; + width?: number; + height?: number; + origin?: Point; + gridSize?: number; + perpendicularLinks?: boolean; + elementView?: (element: Element) => ElementView | ElementView; + linkView?: (link: Link) => LinkView | LinkView; + defaultLink?: ((cellView: CellView, magnet: SVGElement) => Link) | Link; + defaultRouter?: ((vertices: Point[], args: Object, linkView: LinkView) => Point[]) | { name: string, args?: ManhattanRouterArgs }; + defaultConnector?: ((sourcePoint: Point, targetPoint: Point, vertices: Point[], args: Object, linkView: LinkView) => string) | { name: string, args?: { radius?: number } }; + interactive?: ((cellView: CellView, event: string) => boolean) | boolean | { vertexAdd?: boolean, vertexMove?: boolean, vertexRemove?: boolean, arrowheadMove?: boolean }; + validateMagnet?: (cellView: CellView, magnet: SVGElement) => boolean; + validateConnection?: (cellViewS: CellView, magnetS: SVGElement, cellViewT: CellView, magnetT: SVGElement, end: 'source' | 'target', linkView: LinkView) => boolean; + linkConnectionPoint?: (linkView: LinkView, view: ElementView, magnet: SVGElement, reference: Point) => Point; + snapLinks?: boolean | { radius: number }; + linkPinning?: boolean; + markAvailable?: boolean; + async?: boolean | { batchZise: number }; + embeddingMode?: boolean; + validateEmbedding?: (childView: ElementView, parentView: ElementView) => boolean; + restrictTranslate?: ((elementView: ElementView) => BBox) | boolean; + guard?: (evt: Event, view: CellView) => boolean; + multiLinks?: boolean; + cellViewNamespace?: Object; + /** useful undocumented option */ + clickThreshold?: number; + highlighting?: any; + } + + interface ScaleContentOptions { + padding?: number; + preserveAspectRatio?: boolean; + minScale?: number; + minScaleX?: number; + minScaleY?: number; + maxScale?: number; + maxScaleX?: number; + maxScaleY?: number; + scaleGrid?: number; + fittingBBox?: BBox; + } + + interface FitToContentOptions { + gridWidth?: number; + gridHeight?: number; + padding?: Padding; + allowNewOrigin?: 'negative' | 'positive' | 'any'; + minWidth?: number; + minHeight?: number; + maxWidth?: number; + maxHeight?: number; + } + + class Paper extends Backbone.View { + constructor(options?: PaperOptions); + options: PaperOptions; + svg: SVGElement; + viewport: SVGGElement; + defs: SVGDefsElement; + setDimensions(width: number, height: number): void; + setOrigin(x: number, y: number): void; + scale(sx: number, sy?: number, ox?: number, oy?: number): this; + findView(element: any): CellView; + findViewByModel(model: Cell | string): CellView; + findViewsFromPoint(point: Point): ElementView[]; + findViewsInArea(rect: BBox, options?: { strict?: boolean }): CellView[]; + fitToContent(options?: FitToContentOptions): void; + scaleContentToFit(options?: ScaleContentOptions): void; + getContentBBox(): BBox; + clientToLocalPoint(p: Point): Point; + + rotate(deg: number, ox?: number, oy?: number): Paper; // @todo not released yet though it's in the source code already + + afterRenderViews(): void; + asyncRenderViews(cells: Cell[], options?: any): void; + beforeRenderViews(cells: Cell[]): Cell[]; + cellMouseout(evt: Event): void; + cellMouseover(evt: Event): void; + clearGrid(): this; + contextmenu(evt: Event): void; + createViewForModel(cell: Cell): CellView; + drawGrid(options?: any): this; + fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, options?: any): void; + getArea(): BBox; + getDefaultLink(cellView: CellView, magnet: HTMLElement): Link; + getModelById(id: string): Cell; + getRestrictedArea(): BBox; + guard(evt: Event, view: CellView): boolean; + linkAllowed(linkViewOrModel: LinkView | Link): boolean; + mouseclick(evt: Event): void; + mousedblclick(evt: Event): void; + mousewheel(evt: Event): void; + onCellAdded(cell: Cell, graph: Graph, options: Object): void; + onCellHighlight(cellView: CellView, magnetEl: HTMLElement, options?: any): void; + onCellUnhighlight(cellView: CellView, magnetEl: HTMLElement, options?: any): void; + onRemove(): void; + pointerdown(evt: Event): void; + pointermove(evt: Event): void; + pointerup(evt: Event): void; + remove(): this; + removeView(cell: Cell): CellView; + removeViews(): void; + renderView(cell: Cell): CellView; + resetViews(cellsCollection: Cell[], options: any): void; + resolveHighlighter(options?: any): boolean | Object; + setGridSize(gridSize: number): this; + setInteractivity(value: any): void; + snapToGrid(p: Point): Point; + sortViews(): void; + } + + + interface GradientOptions { + type: 'linearGradient' | 'radialGradient'; + stops: Array<{ + offset: string; + color: string; + opacity?: number; + }>; + } + class CellViewGeneric extends Backbone.View { + getBBox(options?: { useModelGeometry?: boolean }): BBox; + highlight(el?: any, options?: any): this; + unhighlight(el?: any, options?: any): this; + applyFilter(selector: string | HTMLElement, filter: Object): void; + applyGradient(selector: string | HTMLElement, attr: 'fill' | 'stroke', gradient: GradientOptions): void; + can(feature: string): boolean; + findBySelector(selector: string): JQuery; + findMagnet(el: any): HTMLElement; + getSelector(el: HTMLElement, prevSelector: string): string; + getStrokeBBox(el: any): BBox; // string|HTMLElement|Vectorizer + mouseout(evt: Event): void; + mouseover(evt: Event): void; + mousewheel(evt: Event, x: number, y: number, delta: number): void + notify(eventName: string): void; + onChangeAttrs(cell: Cell, attrs: Backbone.ViewOptions, options?: any): this; + onSetTheme(oldTheme: string, newTheme: string): void; + pointerclick(evt: Event, x: number, y: number): void; + pointerdblclick(evt: Event, x: number, y: number): void; + pointerdown(evt: Event, x: number, y: number): void; + pointermove(evt: Event, x: number, y: number): void; + pointerup(evt: Event, x: number, y: number): void; + remove(): this; + setInteractivity(value: any): void; + setTheme(theme: string, options?: any): this; + } + + class CellView extends CellViewGeneric { } + + interface ElementViewAttributes { + style?: string; + text?: string; + html?: string; + "ref-x"?: string | number; + "ref-y"?: string | number; + "ref-dx"?: number; + "ref-dy"?: number; + "ref-width"?: string | number; + "ref-height"?: string | number; + ref?: string; + "x-alignment"?: 'middle' | 'right' | number; + "y-alignment"?: 'middle' | 'bottom' | number; + port?: string; + } + class ElementView extends CellViewGeneric { + scale(sx: number, sy: number): void; // @todo Documented in source but not released + finalizeEmbedding(options?: any): void; + getBBox(options?: any): BBox; + pointerdown(evt: Event, x: number, y: number): void; + pointermove(evt: Event, x: number, y: number): void; + pointerup(evt: Event, x: number, y: number): void; + positionRelative(vel: any, bbox: BBox, attributes: ElementViewAttributes, nodesBySelector?: Object): void; // Vectorizer + prepareEmbedding(options?: any): void; + processEmbedding(options?: any): void; + render(): this; + renderMarkup(): void; + resize(): void; + rotate(): void; + translate(model: Backbone.Model, changes?: any, options?: any): void; + update(cell: Cell, renderingOnlyAttrs?: Object): void; + } + + class LinkView extends CellViewGeneric { + options: { + shortLinkLength?: number, + doubleLinkTools?: boolean, + longLinkLength?: number, + linkToolsOffset?: number, + doubleLinkToolsOffset?: number, + sampleInterval: number + }; + getConnectionLength(): number; + sendToken(token: SVGElement, duration?: number, callback?: () => void): void; + addVertex(vertex: Point): number; + getPointAtLength(length: number): Point; // Marked as public api in source but not in the documents + createWatcher(endType: { id: string }): Function; + findRoute(oldVertices: Point[]): Point[]; + getConnectionPoint(end: 'source' | 'target', selectorOrPoint: Element | Point, referenceSelectorOrPoint: Element | Point): Point; + getPathData(vertices: Point[]): any; + onEndModelChange(endType: 'source' | 'target', endModel?: Element, opt?: any): void; + onLabelsChange(): void; + onSourceChange(cell: Cell, sourceEnd: { id: string }, options: any): void; + onTargetChange(cell: Cell, targetEnd: { id: string }, options: any): void; + onToolsChange(): void; + onVerticesChange(cell: Cell, changed: any, options: any): void; + pointerdown(evt: Event, x: number, y: number): void; + pointermove(evt: Event, x: number, y: number): void; + pointerup(evt: Event, x: number, y: number): void; + removeVertex(idx: number): this; + render(): this; + renderArrowheadMarkers(): this; + renderLabels(): this; + renderTools(): this; + renderVertexMarkers(): this; + startArrowheadMove(end: 'source' | 'target', options?: any): void; + startListening(): void; + update(model: any, attributes: any, options?: any): this; + updateArrowheadMarkers(): this; + updateAttributes(): void; + updateConnection(options?: any): void; + updateLabelPositions(): this; + updateToolsPosition(): this; + } } -declare namespace joint { - export var g: any; - export var V: any; +export namespace ui { } - namespace dia { - interface Size { - width: number; - height: number; +export namespace shapes { + interface GenericAttributes extends dia.CellAttributes { + position?: dia.Point; + size?: dia.Size; + angle?: number; + attrs?: T; + } + interface ShapeAttrs extends dia.CSSSelector { + fill?: string; + stroke?: string; + r?: string | number; + rx?: string | number; + ry?: string | number; + cx?: string | number; + cy?: string | number; + height?: string | number; + width?: string | number; + transform?: string; + points?: string; + 'stroke-width'?: string | number; + 'ref-x'?: string | number; + 'ref-y'?: string | number; + ref?: string + } + + namespace basic { + class Generic extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface Point { - x: number; - y: number; + interface RectAttrs extends dia.TextAttrs { + rect?: ShapeAttrs; } - - interface BBox extends Point, Size { } - - interface TranslateOptions { - restrictedArea?: BBox; - transition?: TransitionOptions; + class Rect extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface TransitionOptions { - delay?: number; - duration?: number; - timingFunction?: (t: number) => number; - valueFunction?: (a: any, b: any) => (t: number) => any; + class Text extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface DfsBfsOptions { - inbound?: boolean; - outbound?: boolean; - deep?: boolean; + interface CircleAttrs extends dia.TextAttrs { + circle?: ShapeAttrs; } - - interface ExploreOptions { - breadthFirst?: boolean; - deep?: boolean; + class Circle extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - class Graph extends Backbone.Model { - constructor(attributes?: any, options?: { cellNamespace: any }); - addCell(cell: Cell | Cell[]): this; - addCells(cells: Cell[]): this; - resetCells(cells: Cell[], options?: any): this; - getCell(id: string): Cell; - getElements(): Element[]; - getLinks(): Link[]; - getCells(): Cell[]; - getFirstCell(): Cell; - getLastCell(): Cell; - getConnectedLinks(element: Cell, options?: { inbound?: boolean, outbound?: boolean, deep?: boolean }): Link[]; - disconnectLinks(cell: Cell, options?: any): void; - removeLinks(cell: Cell, options?: any): void; - translate(tx: number, ty?: number, options?: TranslateOptions): void; - cloneCells(cells: Cell[]): { [id: string]: Cell }; - getSubgraph(cells: Cell[], options?: { deep?: boolean }): Cell[]; - cloneSubgraph(cells: Cell[], options?: { deep?: boolean }): { [id: string]: Cell }; - dfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions, visited?: Object, distance?: number): void; - bfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions): void; - search(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: { breadthFirst?: boolean }): void; - getSuccessors(element: Element, options?: ExploreOptions): Element[]; - getPredecessors(element: Element, options?: ExploreOptions): Element[]; - isSuccessor(elementA: Element, elementB: Element): boolean; - isPredecessor(elementA: Element, elementB: Element): boolean; - isSource(element: Element): boolean; - isSink(element: Element): boolean; - getSources(): Element[]; - getSinks(): Element[]; - getNeighbors(element: Element, options?: DfsBfsOptions): Element[]; - isNeighbor(elementA: Element, elementB: Element, options?: { inbound?: boolean, outbound?: boolean; }): boolean; - getCommonAncestor(...cells: Cell[]): Element; - toJSON(): any; - fromJSON(json: any, options?: any): this; - clear(options?: any): this; - findModelsFromPoint(rect: BBox): Element[]; - findModelsUnderElement(element: Element, options?: { searchBy?: 'bbox' | 'center' | 'origin' | 'corner' | 'topRight' | 'bottomLeft' }): Element[]; - getBBox(elements: Element[], options?: any): BBox; - toGraphLib(): any; // graphlib graph object - findModelsInArea(rect: BBox, options?: any): BBox | boolean; - getCellsBBox(cells: Cell[], options?: any): BBox; - getInboundEdges(node: string): Object; - getOutboundEdges(node: string): Object; - hasActiveBatch(name?: string): number | boolean; - maxZIndex(): number; - removeCells(cells: Cell[], options?: any): this; - resize(width: number, height: number, options?: number): this; - resizeCells(width: number, height: number, cells: Cell[], options?: number): this; - set(key: Object | string, value: any, options?: any): this; - startBatch(name: string, data?: Object): any; - stopBatch(name: string, data?: Object): any; + interface EllipseAttrs extends dia.TextAttrs { + ellipse?: ShapeAttrs; } - - class Cell extends Backbone.Model { - id: string; - toJSON(): any; - remove(options?: { disconnectLinks?: boolean }): this; - toFront(options?: { deep?: boolean }): this; - toBack(options?: { deep?: boolean }): this; - getAncestors(): Cell[]; - isEmbeddedIn(element: Element, options?: { deep: boolean }): boolean; - prop(key: string): any; - prop(object: any): this; - prop(key: string, value: any, options?: any): this; - removeProp(path: string, options?: any): this; - attr(key: string): any; - attr(object: SVGAttributes): this; - attr(key: string, value: any): this; - clone(): Cell; - clone(opt: { deep?: boolean }): Cell | Cell[]; - removeAttr(path: string | string[], options?: any): this; - transition(path: string, value?: any, options?: TransitionOptions, delim?: string): number; - getTransitions(): string[]; - stopTransitions(path?: string, delim?: string): this; - addTo(graph: Graph, options?: any): this; - isLink(): boolean; - embed(cell: Cell, options?: any): this; - findView(paper: Paper): CellView; - getEmbeddedCells(options?: any): Cell[]; - initialize(options?: any): void; - isElement(): boolean; - isEmbedded(): boolean; - processPorts(): void; - startBatch(name: string, options?: any): this; - stopBatch(name: string, options?: any): this; - unembed(cell: Cell, options?: any): this; + class Ellipse extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - type Padding = number | { - top?: number; - right?: number; - bottom?: number; - left?: number - }; - - class Element extends Cell { - translate(tx: number, ty?: number, options?: TranslateOptions): this; - position(options?: { parentRelative: boolean }): Point; - position(x: number, y: number, options?: { parentRelative?: boolean }): this; - resize(width: number, height: number, options?: { direction?: 'left' | 'right' | 'top' | 'bottom' | 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right' }): this; - rotate(deg: number, absolute?: boolean, origin?: Point): this; - embed(cell: Cell): this; - unembed(cell: Cell): this; - getEmbeddedCells(options?: ExploreOptions): Cell[]; - fitEmbeds(options?: { deep?: boolean, padding?: Padding }): this; - getBBox(options?: any): BBox; - findView(paper: Paper): ElementView; - isElement(): boolean; - scale(scaleX: number, scaleY: number, origin?: Point, options?: any): this; - addPort(port: any, opt?: any): this; - addPorts(ports: any[], opt?: any): this; - removePort(port: any, opt?: any): this; - hasPorts(): boolean; - hasPort(id: string): boolean; - getPorts(): any[]; - getPort(id: string): any; - getPortIndex(port: any): number; - portProp(portId: string, path: any, value?: any, opt?: any): joint.dia.Element; + interface PolygonAttrs extends dia.TextAttrs { + polygon?: ShapeAttrs; } - - interface CSSSelector { - [key: string]: string | number | Object; // Object added to support special attributes like filter http://jointjs.com/api#SpecialAttributes:filter + class Polygon extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface SVGAttributes { - [selector: string]: CSSSelector; + interface PolylineAttrs extends dia.TextAttrs { + polyline?: ShapeAttrs; } - - interface CellAttributes { - [key: string]: any; + class Polyline extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface TextAttrs extends SVGAttributes { - text?: { - [key: string]: string | number; - text?: string; - }; + class Image extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface Label { - position: number; - attrs?: TextAttrs; + interface PathAttrs extends dia.TextAttrs { + path?: ShapeAttrs; } - interface LinkAttributes extends CellAttributes { - source?: Point | { id: string, selector?: string, port?: string }; - target?: Point | { id: string, selector?: string, port?: string }; - labels?: Label[]; - vertices?: Point[]; - smooth?: boolean; - attrs?: TextAttrs; - z?: number; + class Path extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - class Link extends Cell { - markup: string; - labelMarkup: string; - toolMakup: string; - vertexMarkup: string; - arrowHeadMarkup: string; - - constructor(attributes?: LinkAttributes, options?: Object); - disconnect(): this; - label(index?: number): any; - label(index: number, value: Label): this; - reparent(options?: any): Element; - findView(paper: Paper): LinkView; - getSourceElement(): Element; - getTargetElement(): Element; - hasLoop(options?: { deep?: boolean }): boolean; - applyToPoints(fn: Function, options?: any): this; - getRelationshipAncestor(): Element; - isLink(): boolean; - isRelationshipEmbeddedIn(element: Element): boolean; - scale(sx: number, sy: number, origin: Point, optionts?: any): this; - translate(tx: number, ty: number, options?: any): this; + interface RhombusAttrs extends dia.TextAttrs { + path?: ShapeAttrs; } - - interface ManhattanRouterArgs { - excludeTypes?: string[]; - excludeEnds?: 'source' | 'target'; - startDirections?: ['left' | 'right' | 'top' | 'bottom']; - endDirections?: ['left' | 'right' | 'top' | 'bottom']; + class Rhombus extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface PaperOptions extends Backbone.ViewOptions { - el?: string | JQuery | HTMLElement; - width?: number; - height?: number; - origin?: Point; - gridSize?: number; - perpendicularLinks?: boolean; - elementView?: (element: Element) => ElementView | ElementView; - linkView?: (link: Link) => LinkView | LinkView; - defaultLink?: ((cellView: CellView, magnet: SVGElement) => Link) | Link; - defaultRouter?: ((vertices: Point[], args: Object, linkView: LinkView) => Point[]) | { name: string, args?: ManhattanRouterArgs }; - defaultConnector?: ((sourcePoint: Point, targetPoint: Point, vertices: Point[], args: Object, linkView: LinkView) => string) | { name: string, args?: { radius?: number } }; - interactive?: ((cellView: CellView, event: string) => boolean) | boolean | { vertexAdd?: boolean, vertexMove?: boolean, vertexRemove?: boolean, arrowheadMove?: boolean }; - validateMagnet?: (cellView: CellView, magnet: SVGElement) => boolean; - validateConnection?: (cellViewS: CellView, magnetS: SVGElement, cellViewT: CellView, magnetT: SVGElement, end: 'source' | 'target', linkView: LinkView) => boolean; - linkConnectionPoint?: (linkView: LinkView, view: ElementView, magnet: SVGElement, reference: Point) => Point; - snapLinks?: boolean | { radius: number }; - linkPinning?: boolean; - markAvailable?: boolean; - async?: boolean | { batchZise: number }; - embeddingMode?: boolean; - validateEmbedding?: (childView: ElementView, parentView: ElementView) => boolean; - restrictTranslate?: ((elementView: ElementView) => BBox) | boolean; - guard?: (evt: Event, view: CellView) => boolean; - multiLinks?: boolean; - cellViewNamespace?: Object; - /** useful undocumented option */ - clickThreshold?: number; - highlighting?: any; + interface TextBlockAttrs extends dia.TextAttrs { + rect?: ShapeAttrs; } - - interface ScaleContentOptions { - padding?: number; - preserveAspectRatio?: boolean; - minScale?: number; - minScaleX?: number; - minScaleY?: number; - maxScale?: number; - maxScaleX?: number; - maxScaleY?: number; - scaleGrid?: number; - fittingBBox?: BBox; + class TextBlock extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); + updateSize(cell: dia.Cell, size: dia.Size): void; + updateContent(cell: dia.Cell, content: string): void; } + } - interface FitToContentOptions { - gridWidth?: number; - gridHeight?: number; - padding?: Padding; - allowNewOrigin?: 'negative' | 'positive' | 'any'; - minWidth?: number; - minHeight?: number; - maxWidth?: number; - maxHeight?: number; + namespace chess { + class KingWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - class Paper extends Backbone.View { - constructor(options?: PaperOptions); - options: PaperOptions; - svg: SVGElement; - viewport: SVGGElement; - defs: SVGDefsElement; - setDimensions(width: number, height: number): void; - setOrigin(x: number, y: number): void; - scale(sx: number, sy?: number, ox?: number, oy?: number): this; - findView(element: any): CellView; - findViewByModel(model: Cell | string): CellView; - findViewsFromPoint(point: Point): ElementView[]; - findViewsInArea(rect: BBox, options?: { strict?: boolean }): CellView[]; - fitToContent(options?: FitToContentOptions): void; - scaleContentToFit(options?: ScaleContentOptions): void; - getContentBBox(): BBox; - clientToLocalPoint(p: Point): Point; - - rotate(deg: number, ox?: number, oy?: number): Paper; // @todo not released yet though it's in the source code already - - afterRenderViews(): void; - asyncRenderViews(cells: Cell[], options?: any): void; - beforeRenderViews(cells: Cell[]): Cell[]; - cellMouseout(evt: Event): void; - cellMouseover(evt: Event): void; - clearGrid(): this; - contextmenu(evt: Event): void; - createViewForModel(cell: Cell): CellView; - drawGrid(options?: any): this; - fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, options?: any): void; - getArea(): BBox; - getDefaultLink(cellView: CellView, magnet: HTMLElement): Link; - getModelById(id: string): Cell; - getRestrictedArea(): BBox; - guard(evt: Event, view: CellView): boolean; - linkAllowed(linkViewOrModel: LinkView | Link): boolean; - mouseclick(evt: Event): void; - mousedblclick(evt: Event): void; - mousewheel(evt: Event): void; - onCellAdded(cell: Cell, graph: Graph, options: Object): void; - onCellHighlight(cellView: CellView, magnetEl: HTMLElement, options?: any): void; - onCellUnhighlight(cellView: CellView, magnetEl: HTMLElement, options?: any): void; - onRemove(): void; - pointerdown(evt: Event): void; - pointermove(evt: Event): void; - pointerup(evt: Event): void; - remove(): this; - removeView(cell: Cell): CellView; - removeViews(): void; - renderView(cell: Cell): CellView; - resetViews(cellsCollection: Cell[], options: any): void; - resolveHighlighter(options?: any): boolean | Object; - setGridSize(gridSize: number): this; - setInteractivity(value: any): void; - snapToGrid(p: Point): Point; - sortViews(): void; + class KingBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - - interface GradientOptions { - type: 'linearGradient' | 'radialGradient'; - stops: Array<{ - offset: string; - color: string; - opacity?: number; - }>; + class QueenWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - class CellViewGeneric extends Backbone.View { - getBBox(options?: { useModelGeometry?: boolean }): BBox; - highlight(el?: any, options?: any): this; - unhighlight(el?: any, options?: any): this; - applyFilter(selector: string | HTMLElement, filter: Object): void; - applyGradient(selector: string | HTMLElement, attr: 'fill' | 'stroke', gradient: GradientOptions): void; - can(feature: string): boolean; - findBySelector(selector: string): JQuery; - findMagnet(el: any): HTMLElement; - getSelector(el: HTMLElement, prevSelector: string): string; - getStrokeBBox(el: any): BBox; // string|HTMLElement|Vectorizer - mouseout(evt: Event): void; - mouseover(evt: Event): void; - mousewheel(evt: Event, x: number, y: number, delta: number): void - notify(eventName: string): void; - onChangeAttrs(cell: Cell, attrs: Backbone.ViewOptions, options?: any): this; - onSetTheme(oldTheme: string, newTheme: string): void; - pointerclick(evt: Event, x: number, y: number): void; - pointerdblclick(evt: Event, x: number, y: number): void; - pointerdown(evt: Event, x: number, y: number): void; - pointermove(evt: Event, x: number, y: number): void; - pointerup(evt: Event, x: number, y: number): void; - remove(): this; - setInteractivity(value: any): void; - setTheme(theme: string, options?: any): this; + class QueenBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); } + class RookWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class RookBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class BishopWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class BishopBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class KnightWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class KnightBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class PawnWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class PawnBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + } - class CellView extends CellViewGeneric { } + namespace devs { + interface ModelAttributes extends GenericAttributes { + inPorts?: string[]; + outPorts?: string[]; + ports?: Object; + } + class Model extends basic.Generic { + constructor(attributes?: ModelAttributes, options?: Object); + changeInGroup(properties: any, opt?: any): boolean; + changeOutGroup(properties: any, opt?: any): boolean; + createPortItem(group: string, port: string): any; + createPortItems(group: string, ports: string[]): any[]; + addOutPort(port: string, opt?: any): this; + addInPort(port: string, opt?: any): this; + removeOutPort(port: string, opt?: any): this; + removeInPort(port: string, opt?: any): this; + } + class Coupled extends Model { + constructor(attributes?: ModelAttributes, options?: Object); + } + class Atomic extends Model { + constructor(attributes?: ModelAttributes, options?: Object); + } + class Link extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + } - interface ElementViewAttributes { - style?: string; - text?: string; - html?: string; - "ref-x"?: string | number; - "ref-y"?: string | number; - "ref-dx"?: number; - "ref-dy"?: number; - "ref-width"?: string | number; - "ref-height"?: string | number; + namespace erd { + class Entity extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class WeakEntity extends Entity { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Relationship extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class IdentifyingRelationship extends Relationship { + constructor(attributes?: GenericAttributes, options?: Object); + } + interface AttributeAttrs extends dia.TextAttrs { + ellipse?: ShapeAttrs; + } + class Attribute extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Multivalued extends Attribute { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Derived extends Attribute { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Key extends Attribute { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Normal extends Attribute { + constructor(attributes?: GenericAttributes, options?: Object); + } + interface ISAAttrs extends dia.Element { + polygon?: ShapeAttrs; + } + class ISA extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Line extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + cardinality(value: string | number): void; + } + } + + namespace fsa { + class State extends basic.Circle { + constructor(attributes?: GenericAttributes, options?: Object); + } + class StartState extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class EndState extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Arrow extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + } + + namespace logic { + interface LogicAttrs extends ShapeAttrs { ref?: string; - "x-alignment"?: 'middle' | 'right' | number; - "y-alignment"?: 'middle' | 'bottom' | number; + 'ref-x'?: number | string; + 'ref-dx'?: number | string; + 'ref-y'?: number | string; + 'ref-dy'?: number | string; + magnet?: boolean; + 'class'?: string; port?: string; } - class ElementView extends CellViewGeneric { - scale(sx: number, sy: number): void; // @todo Documented in source but not released - finalizeEmbedding(options?: any): void; - getBBox(options?: any): BBox; - pointerdown(evt: Event, x: number, y: number): void; - pointermove(evt: Event, x: number, y: number): void; - pointerup(evt: Event, x: number, y: number): void; - positionRelative(vel: any, bbox: BBox, attributes: ElementViewAttributes, nodesBySelector?: Object): void; // Vectorizer - prepareEmbedding(options?: any): void; - processEmbedding(options?: any): void; - render(): this; - renderMarkup(): void; - resize(): void; - rotate(): void; - translate(model: Backbone.Model, changes?: any, options?: any): void; - update(cell: Cell, renderingOnlyAttrs?: Object): void; + interface IOAttrs extends dia.TextAttrs { + circle?: LogicAttrs; } - - class LinkView extends CellViewGeneric { - options: { - shortLinkLength?: number, - doubleLinkTools?: boolean, - longLinkLength?: number, - linkToolsOffset?: number, - doubleLinkToolsOffset?: number, - sampleInterval: number - }; - getConnectionLength(): number; - sendToken(token: SVGElement, duration?: number, callback?: () => void): void; - addVertex(vertex: Point): number; - getPointAtLength(length: number): Point; // Marked as public api in source but not in the documents - createWatcher(endType: { id: string }): Function; - findRoute(oldVertices: Point[]): Point[]; - getConnectionPoint(end: 'source' | 'target', selectorOrPoint: Element | Point, referenceSelectorOrPoint: Element | Point): Point; - getPathData(vertices: Point[]): any; - onEndModelChange(endType: 'source' | 'target', endModel?: Element, opt?: any): void; - onLabelsChange(): void; - onSourceChange(cell: Cell, sourceEnd: { id: string }, options: any): void; - onTargetChange(cell: Cell, targetEnd: { id: string }, options: any): void; - onToolsChange(): void; - onVerticesChange(cell: Cell, changed: any, options: any): void; - pointerdown(evt: Event, x: number, y: number): void; - pointermove(evt: Event, x: number, y: number): void; - pointerup(evt: Event, x: number, y: number): void; - removeVertex(idx: number): this; - render(): this; - renderArrowheadMarkers(): this; - renderLabels(): this; - renderTools(): this; - renderVertexMarkers(): this; - startArrowheadMove(end: 'source' | 'target', options?: any): void; - startListening(): void; - update(model: any, attributes: any, options?: any): this; - updateArrowheadMarkers(): this; - updateAttributes(): void; - updateConnection(options?: any): void; - updateLabelPositions(): this; - updateToolsPosition(): this; + class Gate extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class IO extends Gate { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Input extends IO { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Output extends IO { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Gate11 extends Gate { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Gate21 extends Gate { + constructor(attributes?: GenericAttributes, options?: Object); + } + interface Image { + 'xlink:href'?: string; + } + interface ImageAttrs extends LogicAttrs { + image?: Image; + } + class Repeater extends Gate11 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input: any): any; + } + class Note extends Gate11 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input: any): boolean; + } + class Or extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class And extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class Nor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class Nand extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class Xor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class Xnor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + interface WireArgs extends dia.LinkAttributes { + router?: Object; + connector?: Object; + } + class Wire extends dia.Link { + constructor(attributes?: WireArgs, options?: Object); } } - namespace ui { } - - namespace shapes { - interface GenericAttributes extends dia.CellAttributes { - position?: dia.Point; - size?: dia.Size; - angle?: number; - attrs?: T; + namespace org { + interface MemberAttrs { + rect?: ShapeAttrs; + image?: ShapeAttrs; } - interface ShapeAttrs extends dia.CSSSelector { - fill?: string; - stroke?: string; - r?: string | number; - rx?: string | number; - ry?: string | number; - cx?: string | number; - cy?: string | number; - height?: string | number; - width?: string | number; - transform?: string; - points?: string; - 'stroke-width'?: string | number; - 'ref-x'?: string | number; - 'ref-y'?: string | number; - ref?: string + class Member extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); } - - namespace basic { - class Generic extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface RectAttrs extends dia.TextAttrs { - rect?: ShapeAttrs; - } - class Rect extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Text extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface CircleAttrs extends dia.TextAttrs { - circle?: ShapeAttrs; - } - class Circle extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface EllipseAttrs extends dia.TextAttrs { - ellipse?: ShapeAttrs; - } - class Ellipse extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface PolygonAttrs extends dia.TextAttrs { - polygon?: ShapeAttrs; - } - class Polygon extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface PolylineAttrs extends dia.TextAttrs { - polyline?: ShapeAttrs; - } - class Polyline extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Image extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface PathAttrs extends dia.TextAttrs { - path?: ShapeAttrs; - } - class Path extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface RhombusAttrs extends dia.TextAttrs { - path?: ShapeAttrs; - } - class Rhombus extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface TextBlockAttrs extends dia.TextAttrs { - rect?: ShapeAttrs; - } - class TextBlock extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - updateSize(cell: dia.Cell, size: dia.Size): void; - updateContent(cell: dia.Cell, content: string): void; - } - } - - namespace chess { - class KingWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class KingBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class QueenWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class QueenBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class RookWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class RookBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class BishopWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class BishopBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class KnightWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class KnightBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class PawnWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class PawnBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - } - - namespace devs { - interface ModelAttributes extends GenericAttributes { - inPorts?: string[]; - outPorts?: string[]; - ports?: Object; - } - class Model extends basic.Generic { - constructor(attributes?: ModelAttributes, options?: Object); - changeInGroup(properties: any, opt?: any): boolean; - changeOutGroup(properties: any, opt?: any): boolean; - createPortItem(group: string, port: string): any; - createPortItems(group: string, ports: string[]): any[]; - addOutPort(port: string, opt?: any): this; - addInPort(port: string, opt?: any): this; - removeOutPort(port: string, opt?: any): this; - removeInPort(port: string, opt?: any): this; - } - class Coupled extends Model { - constructor(attributes?: ModelAttributes, options?: Object); - } - class Atomic extends Model { - constructor(attributes?: ModelAttributes, options?: Object); - } - class Link extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - } - - namespace erd { - class Entity extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class WeakEntity extends Entity { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Relationship extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class IdentifyingRelationship extends Relationship { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface AttributeAttrs extends dia.TextAttrs { - ellipse?: ShapeAttrs; - } - class Attribute extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Multivalued extends Attribute { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Derived extends Attribute { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Key extends Attribute { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Normal extends Attribute { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface ISAAttrs extends dia.Element { - polygon?: ShapeAttrs; - } - class ISA extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Line extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - cardinality(value: string | number): void; - } - } - - namespace fsa { - class State extends basic.Circle { - constructor(attributes?: GenericAttributes, options?: Object); - } - class StartState extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class EndState extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Arrow extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - } - - namespace logic { - interface LogicAttrs extends ShapeAttrs { - ref?: string; - 'ref-x'?: number | string; - 'ref-dx'?: number | string; - 'ref-y'?: number | string; - 'ref-dy'?: number | string; - magnet?: boolean; - 'class'?: string; - port?: string; - } - interface IOAttrs extends dia.TextAttrs { - circle?: LogicAttrs; - } - class Gate extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class IO extends Gate { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Input extends IO { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Output extends IO { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Gate11 extends Gate { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Gate21 extends Gate { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface Image { - 'xlink:href'?: string; - } - interface ImageAttrs extends LogicAttrs { - image?: Image; - } - class Repeater extends Gate11 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input: any): any; - } - class Note extends Gate11 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input: any): boolean; - } - class Or extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class And extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class Nor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class Nand extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class Xor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class Xnor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - interface WireArgs extends dia.LinkAttributes { - router?: Object; - connector?: Object; - } - class Wire extends dia.Link { - constructor(attributes?: WireArgs, options?: Object); - } - } - - namespace org { - interface MemberAttrs { - rect?: ShapeAttrs; - image?: ShapeAttrs; - } - class Member extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Arrow extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - } - - namespace pn { - class Place extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class PlaceView extends dia.ElementView { - renderTokens(): void; - } - class Transition extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Link extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - } - - namespace uml { - interface ClassAttributes extends GenericAttributes { - name: string[]; - attributes: string[]; - methods: string[]; - } - class Class extends basic.Generic { - constructor(attributes?: ClassAttributes, options?: Object); - getClassName(): string[]; - updateRectangles(): void; - } - class ClassView extends dia.ElementView { - } - class Abstract extends Class { - constructor(attributes?: ClassAttributes, options?: Object); - } - class AbstractView extends ClassView { - constructor(attributes?: ClassAttributes, options?: Object); - } - class Interface extends Class { - constructor(attributes?: ClassAttributes, options?: Object); - } - class InterfaceView extends ClassView { - constructor(attributes?: ClassAttributes, options?: Object); - } - class Generalization extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - class Implementation extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - class Aggregation extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - class Composition extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - class Association extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - interface StateAttributes extends GenericAttributes { - events?: string[]; - } - class State extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - updateName(): void; - updateEvents(): void; - updatePath(): void; - } - class StartState extends basic.Circle { - constructor(attributes?: GenericAttributes, options?: Object); - } - class EndState extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Transition extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } + class Arrow extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); } } - namespace util { - - namespace format { - export function number(specifier: string, value: number): string; + namespace pn { + class Place extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class PlaceView extends dia.ElementView { + renderTokens(): void; + } + class Transition extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Link extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); } - - export function uuid(): string; - export function guid(obj?: Object): string; - export function nextFrame(callback: () => void, context?: Object): number; - export function cancelFrame(requestId: number): void; - export function flattenObject(object: Object, delim: string, stop: (node: any) => boolean): any; - export function getByPath(object: Object, path: string, delim: string): any; - export function setByPath(object: Object, path: string, value: Object, delim: string): any; - export function unsetByPath(object: Object, path: string, delim: string): any; - export function breakText(text: string, size: dia.Size, attrs?: dia.SVGAttributes, options?: { svgDocument?: SVGElement }): string; - export function normalizeSides(box: number | { x?: number, y?: number, height?: number, width?: number }): dia.BBox; - export function getElementBBox(el: Element): dia.BBox; - export function setAttributesBySelector(el: Element, attrs: dia.SVGAttributes): void; - export function sortElements(elements: Element[] | string | JQuery, comparator: (a: Element, b: Element) => number): Element[]; - export function shapePerimeterConnectionPoint(linkView: dia.LinkView, view: dia.ElementView, magnet: SVGElement, ref: dia.Point): dia.Point; - export function imageToDataUri(url: string, callback: (err: Error, dataUri: string) => void): void; - - // Not documented but used in examples - /** @deprecated use lodash _.defaultsDeep */ - export function deepSupplement(objects: any, defaultIndicator?: any): any; - - // Private functions - /** @deprecated use lodash _.assign */ - export function mixin(objects: any[]): any; - /** @deprecated use lodash _.defaults */ - export function supplement(objects: any[]): any; - /** @deprecated use lodash _.mixin */ - export function deepMixin(objects: any[]): any; } - namespace layout { - - interface LayoutOptions { - nodeSep?: number; - edgeSep?: number; - rankSep?: number; - rankDir?: 'TB' | 'BT' | 'LR' | 'RL'; - marginX?: number; - marginY?: number; - resizeCluster?: boolean; - setPosition?: (element: dia.Element, position: dia.BBox) => void; - setLinkVertices?: (link: dia.Link, vertices: Position[]) => void; + namespace uml { + interface ClassAttributes extends GenericAttributes { + name: string[]; + attributes: string[]; + methods: string[]; } - - export class DirectedGraph { - static layout(graph: dia.Graph | dia.Cell[], options?: LayoutOptions): dia.BBox; + class Class extends basic.Generic { + constructor(attributes?: ClassAttributes, options?: Object); + getClassName(): string[]; + updateRectangles(): void; + } + class ClassView extends dia.ElementView { + } + class Abstract extends Class { + constructor(attributes?: ClassAttributes, options?: Object); + } + class AbstractView extends ClassView { + constructor(attributes?: ClassAttributes, options?: Object); + } + class Interface extends Class { + constructor(attributes?: ClassAttributes, options?: Object); + } + class InterfaceView extends ClassView { + constructor(attributes?: ClassAttributes, options?: Object); + } + class Generalization extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + class Implementation extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + class Aggregation extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + class Composition extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + class Association extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + interface StateAttributes extends GenericAttributes { + events?: string[]; + } + class State extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + updateName(): void; + updateEvents(): void; + updatePath(): void; + } + class StartState extends basic.Circle { + constructor(attributes?: GenericAttributes, options?: Object); + } + class EndState extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Transition extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); } } } + +export namespace util { + + namespace format { + export function number(specifier: string, value: number): string; + } + + export function uuid(): string; + export function guid(obj?: Object): string; + export function nextFrame(callback: () => void, context?: Object): number; + export function cancelFrame(requestId: number): void; + export function flattenObject(object: Object, delim: string, stop: (node: any) => boolean): any; + export function getByPath(object: Object, path: string, delim: string): any; + export function setByPath(object: Object, path: string, value: Object, delim: string): any; + export function unsetByPath(object: Object, path: string, delim: string): any; + export function breakText(text: string, size: dia.Size, attrs?: dia.SVGAttributes, options?: { svgDocument?: SVGElement }): string; + export function normalizeSides(box: number | { x?: number, y?: number, height?: number, width?: number }): dia.BBox; + export function getElementBBox(el: Element): dia.BBox; + export function setAttributesBySelector(el: Element, attrs: dia.SVGAttributes): void; + export function sortElements(elements: Element[] | string | JQuery, comparator: (a: Element, b: Element) => number): Element[]; + export function shapePerimeterConnectionPoint(linkView: dia.LinkView, view: dia.ElementView, magnet: SVGElement, ref: dia.Point): dia.Point; + export function imageToDataUri(url: string, callback: (err: Error, dataUri: string) => void): void; + + // Not documented but used in examples + /** @deprecated use lodash _.defaultsDeep */ + export function deepSupplement(objects: any, defaultIndicator?: any): any; + + // Private functions + /** @deprecated use lodash _.assign */ + export function mixin(objects: any[]): any; + /** @deprecated use lodash _.defaults */ + export function supplement(objects: any[]): any; + /** @deprecated use lodash _.mixin */ + export function deepMixin(objects: any[]): any; +} + +export namespace layout { + + interface LayoutOptions { + nodeSep?: number; + edgeSep?: number; + rankSep?: number; + rankDir?: 'TB' | 'BT' | 'LR' | 'RL'; + marginX?: number; + marginY?: number; + resizeCluster?: boolean; + setPosition?: (element: dia.Element, position: dia.BBox) => void; + setLinkVertices?: (link: dia.Link, vertices: Position[]) => void; + } + + class DirectedGraph { + static layout(graph: dia.Graph | dia.Cell[], options?: LayoutOptions): dia.BBox; + } +} diff --git a/rappid/index.d.ts b/rappid/index.d.ts index 5cbf07b995..d70023e055 100644 --- a/rappid/index.d.ts +++ b/rappid/index.d.ts @@ -5,33 +5,36 @@ /// -declare namespace joint { - namespace ui { - interface Handle { - name: string; - position: string; - icon: string; - } +import * as joint from 'jointjs'; +import * as Backbone from "backbone"; - class SelectionView extends Backbone.Model { +export as namespace joint; + +export namespace ui { + interface Handle { + name: string; + position: string; + icon: string; + } + + class SelectionView extends Backbone.Model { + paper: joint.dia.Paper; + graph: joint.dia.Graph; + model: Backbone.Collection; + + constructor(opt: { paper: joint.dia.Paper; graph: joint.dia.Graph; - model: Backbone.Collection; + model: Backbone.Collection + }); - constructor(opt: { - paper: joint.dia.Paper; - graph: joint.dia.Graph; - model: Backbone.Collection - }); + createSelectionBox(cellView: joint.dia.CellView): void; + destroySelectionBox(cellView: joint.dia.CellView): void; + startSelecting(evt: any): void; + cancelSelection(): void; - createSelectionBox(cellView: joint.dia.CellView): void; - destroySelectionBox(cellView: joint.dia.CellView): void; - startSelecting(evt: any): void; - cancelSelection(): void; - - addHandle(handle: Handle): void; - removeHandle(name: string): void; - changeHandle(name: string, handle: Handle): void; - } + addHandle(handle: Handle): void; + removeHandle(name: string): void; + changeHandle(name: string, handle: Handle): void; } } From fcc78898d3baf2e1ed7c45f693fdc4e2aaf94530 Mon Sep 17 00:00:00 2001 From: Victor Palomo de Castro Date: Sat, 11 Mar 2017 23:56:50 -0300 Subject: [PATCH 045/150] Added positions prop for DrawerLayoutAndroidStatic --- react-native/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/react-native/index.d.ts b/react-native/index.d.ts index 35a7eae5ce..c0d1884a97 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -2563,8 +2563,18 @@ declare module "react" { ref?: Ref } + interface DrawerPosition { + Left: number + Right: number + } + export interface DrawerLayoutAndroidStatic extends NativeMethodsMixin, React.ClassicComponentClass { + /** + * drawer's positions. + */ + positions: DrawerPosition + /** * Opens the drawer. */ From 7f0410d887d7893c6232020356bbd890437af80d Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Sun, 12 Mar 2017 15:58:56 +0100 Subject: [PATCH 046/150] fix requested changes from @minestarks for PR #14816 --- qlik-visualizationextensions/index.d.ts | 816 ++++++++++-------- .../qlik-visualizationextensions-tests.ts | 2 +- qlik-visualizationextensions/tsconfig.json | 2 +- qlik-visualizationextensions/tslint.json | 3 +- 4 files changed, 447 insertions(+), 376 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index c7eb32273c..4f384ca925 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -14,10 +14,10 @@ declare namespace BackendAPI { type PatchType = "Add" | "Remove" | "Replace"; interface ICharRange { - /** - * Position of the first search occurrence - * Integer - */ + /** + * Position of the first search occurrence + * Integer + */ qCharPos: number; /** @@ -84,8 +84,8 @@ declare namespace BackendAPI { } interface INxCell { - /** - * Some text. + /** + * Some text. * This parameter is optional. */ qText?: string; @@ -97,13 +97,13 @@ declare namespace BackendAPI { qNum?: number; /** - * Rank number of the value, starting from 0. + * Rank number of the value, starting from 0. * If the element number is a negative number, it means that the returned value is not an element number. * You can get the following negative values: - * # -1: the cell is a Total cell. It shows a total. - * # -2: the cell is collapsed. Applies to pivot tables. - * # -3: the cell belongs to the group Others. - * # -4: the cell is empty. Applies to pivot tables. + * # -1: the cell is a Total cell. It shows a total. + * # -2: the cell is collapsed. Applies to pivot tables. + * # -3: the cell belongs to the group Others. + * # -4: the cell is empty. Applies to pivot tables. */ qElemNumber: number; @@ -130,15 +130,15 @@ declare namespace BackendAPI { /** * Is set to true if a total is displayed in the cell. * This parameter is optional. The default value is false. - * Not applicable to list objects. + * Not applicable to list objects. */ qIsTotalCell: boolean; /** * Is set to true if the cell belongs to the group Others. * Dimension values can be set as Others depending on what has been defined in OtherTotalSpecProp. - * This parameter is optional. The default value is false. - * Not applicable to list objects. + * This parameter is optional. The default value is false. + * Not applicable to list objects. */ qIsOtherCell: boolean; @@ -150,7 +150,7 @@ declare namespace BackendAPI { /** * Search hits. - * The search hits are highlighted. + * The search hits are highlighted. * This parameter is optional. */ qHighlightRanges: INxHighlightRanges; @@ -185,12 +185,14 @@ declare namespace BackendAPI { qTop: number; /** - * Number of columns in the page. The indexing of the columns may vary depending on whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). + * Number of columns in the page. The indexing of the columns may vary depending on whether + * the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). */ qWidth: number; /** - * Number of rows or elements in the page. The indexing of the rows may vary depending on whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). + * Number of rows or elements in the page. The indexing of the rows may vary depending on + * whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). */ qHeight: number; } @@ -198,13 +200,13 @@ declare namespace BackendAPI { interface INxAttrDimInfo { /** * Cardinality of the attribute expression. - * Integer + * Integer */ qCardinal: number; /** * Number of rows. - * Size + * Size */ qSize: number; @@ -267,7 +269,8 @@ declare namespace BackendAPI { /** * Array of dimension labels. - * Contains the labels of all dimensions in a hierarchy group (for example the labels of all dimensions in a drill down group). + * Contains the labels of all dimensions in a hierarchy group + * (for example the labels of all dimensions in a drill down group). * Array of String */ qGroupFallbackTitles: string[]; @@ -337,7 +340,8 @@ declare namespace BackendAPI { qNumFormat: FieldAttributesType; /** - * This parameter is set to true if qNumFormat is set to U (unknown). The engine guesses the type of the field based on the field's definition. + * This parameter is set to true if qNumFormat is set to U (unknown). + * The engine guesses the type of the field based on the field's definition. * Boolean */ qIsAutoFormat: boolean; @@ -582,7 +586,8 @@ declare namespace BackendAPI { qNumFormat: IFieldAttributes; /** - * This parameter is set to true if qNumFormat is set to U (unknown). The engine guesses the type of the field based on the field's expression. + * This parameter is set to true if qNumFormat is set to U (unknown). + * The engine guesses the type of the field based on the field's expression. */ qIsAutoFormat: boolean; @@ -631,14 +636,18 @@ declare namespace BackendAPI { qMax: number; /** - * If set to true, the range includes the lowest value in the range of selections (Equals to ). [bn(50500)] - * Example: The range is [1,10]. If qMinInclEq is set to true it means that 1 is included in the range of selections. + * If set to true, the range includes the lowest value in the range of + * selections (Equals to ). [bn(50500)] + * Example: The range is [1,10]. If qMinInclEq is set to true it means + * that 1 is included in the range of selections. */ qMinInclEq: boolean; /** - * If set to true, the range includes the highest value in the range of selections (Equals to ). [bn(50500)] - * Example: The range is [1,10]. If qMinInclEq is set to true it means that 10 is included in the range of selections. + * If set to true, the range includes the highest value in the range of + * selections (Equals to ). [bn(50500)] + * Example: The range is [1,10]. If qMinInclEq is set to true it means + * that 10 is included in the range of selections. */ qMaxInclEq: boolean; } @@ -660,8 +669,8 @@ declare namespace BackendAPI { qPath: string; /** - * This parameter is not used in a remove operation. - * Corresponds to the value of the property to add or to the new value of the property to update. + * This parameter is not used in a remove operation. Corresponds to the value of the + * property to add or to the new value of the property to update. * Examples: "false", "2", "\"New title\"" * String */ @@ -669,25 +678,26 @@ declare namespace BackendAPI { } interface IBackend { - /** - * Aborts the result of a search in a list object. Clears the existing search and returns the object to the state it was in prior to the search started. + /** + * Aborts the result of a search in a list object. Clears the existing search and returns the + * object to the state it was in prior to the search started. */ abortSearch(): void; /** * Accepts the result of a search in a list object and the search result is selected in the field. - * @param {boolean} toggleMode - If true, toggle state for selected values + * @param {boolean} toggleMode - If true, toggle state for selected values */ acceptSearch(toggleMode: boolean): void; /** - * Updates the properties for this object. + * Updates the properties for this object. * @param {array} qPatches - Array of patches. Each path contains: - * #qOp: Add/Remove/Replace - * #qPath: Path to property - * #qValue: The new value in string format. Strings need to be surrounded by \". - * @param {boolean} qSoftPatch - Set to True if properties should be soft, that is not persisted. - * @return {Promise} - A promise of a Qlik engine reply. + * #qOp: Add/Remove/Replace + * #qPath: Path to property + * #qValue: The new value in string format. Strings need to be surrounded by \". + * @param {boolean} qSoftPatch - Set to True if properties should be soft, that is not persisted. + * @return {Promise} - A promise of a Qlik engine reply. */ applyPatches(qPatches: any[], qSoftPatch: boolean): ng.IPromise; @@ -697,164 +707,173 @@ declare namespace BackendAPI { clearSelections(): void; /** - * Clears all soft patches that has previously been applied for this object using the applyPatches method. - * @return {Promise} - A promise of a Qlik engine reply. + * Clears all soft patches that has previously been applied for this object using the + * applyPatches method. + * @return {Promise} - A promise of a Qlik engine reply. */ clearSoftPatches(): ng.IPromise; /** - * Collapse the left dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. - * @param {number} qRow - Row index. - * @param {number} qCol - Column index. - * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. - * @return {Promise} - A promise of a Qlik engine reply. + * Collapse the left dimensions of a pivot table. Only works for hypercubes with + * qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. */ collapseLeft(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; /** - * Collapse the top dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. - * @param {number} qRow - Row index. - * @param {number} qCol - Column index. - * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. - * @return {Promise} - A promise of a Qlik engine reply. + * Collapse the top dimensions of a pivot table. Only works for hypercubes with + * qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. */ collapseTop(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; /** * Loops through data rows for this object. Only rows that are available client side will be used. - * @param {function} callback - Function to call for each row. - * Parameters are row number and row data as an array of NxCell objects. - * The loop is terminated if the function returns false. - * @return {NxCell[]} - An array of NxCell. - */ + * @param {function} callback - Function to call for each row. + * Parameters are row number and row data as an array of NxCell objects. + * The loop is terminated if the function returns false. + * @return {NxCell[]} - An array of NxCell. + */ eachDataRow(callback: any): INxCell[]; /** - * Expands the left dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. - * @param {number} qRow - Row index. - * @param {number} qCol - Column index. - * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Expands the left dimensions of a pivot table. Only works for hypercubes with + * qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ expandLeft(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; /** - * Expands the top dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. - * @param {number} qRow - Row index. - * @param {number} qCol - Column index. - * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. - * @return {Promise} - A promise of a Qlik engine reply. + * Expands the top dimensions of a pivot table. Only works for hypercubes with + * qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. */ expandTop(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; /** * Geta data from Qlik engine for this object. - * @param {array} qPages - An array of NxPage objects. - * @return {Promise} - A promise of qDataPages. + * @param {array} qPages - An array of NxPage objects. + * @return {Promise} - A promise of qDataPages. */ getData(qPages: INxPage[]): ng.IPromise; /** * Gets a data row for this object. - * @param {number} rownum - The row number. - * @return {NxCell} - A row of NxCell or null if the row is not available client side and need to be fetched with getData method. + * @param {number} rownum - The row number. + * @return {NxCell} - A row of NxCell or null if the row is not available client side + * and need to be fetched with getData method. */ getDataRow(rownum: number): INxCell; /** * Gets qDimensionInfo for this object. - * @return {NxDimensionInfo[]} - An array of qDimensionInfo objects. + * @return {NxDimensionInfo[]} - An array of qDimensionInfo objects. */ getDimensionInfos(): INxDimensionInfo[]; /** * Gets qMeasureInfo for this object. - * @return {NxMeasureInfo} - An array of qMeasureInfo objects. + * @return {NxMeasureInfo} - An array of qMeasureInfo objects. */ getMeasureInfos(): INxMeasureInfo; /** * Gets pivot data from the Qlik engine for this object. Only works for hypercubes with qMode = P. - * @param {array} qPages - An array of request page objects. - * @return {Promise} - A promise of pivot data pages. + * @param {array} qPages - An array of request page objects. + * @return {Promise} - A promise of pivot data pages. */ getPivotData(qPages: INxPage[]): ng.IPromise; /** - * Get properties for this object. - * @return {Promise} - A promise of object properties. - */ + * Get properties for this object. + * @return {Promise} - A promise of object properties. + */ getProperties(): ng.IPromise; /** - * Get reduced data from the Qlik engine for this object. This method is intended for preserving the shape of the data, not for viewing the actual data points. - * @param {array} qPages - An array of request page objects. - * @param {number} qZoomFactor - Zoom factor. - * If set to -1, the Qlik engine decides of the zoom factor. - * If qReductionMode is D1 or S, the zoom factor is 2n. If the zoom factor is 5, the data are reduced by a factor 32. - * If qReductionMode is C, the zoom factor defines the number of centroids. - * @param {string} qReductionMode - Reduction mode.Can be: - * # N for no data reduction. - * # D1 to reduce a bar chart or line chart. The profile of the chart is reduced whatever the number of dimensions in the chart. - * # S to reduce the resolution of a scatter plot. - * # C to reduce the data of a scatter plot chart. - * # ST to reduce the data of a stacked pivot table. - * @return {Promise} - A promise of reduced data pages. + * Get reduced data from the Qlik engine for this object. This method is intended for preserving the + * shape of the data, not for viewing the actual data points. + * @param {array} qPages - An array of request page objects. + * @param {number} qZoomFactor - Zoom factor. + * If set to -1, the Qlik engine decides of the zoom factor. + * If qReductionMode is D1 or S, the zoom factor is 2n. + * If the zoom factor is 5, the data are reduced by a factor 32. + * If qReductionMode is C, the zoom factor defines the number of centroids. + * @param {string} qReductionMode - Reduction mode.Can be: + * # N for no data reduction. + * # D1 to reduce a bar chart or line chart. + * The profile of the chart is reduced whatever the number of dimensions in the chart. + * # S to reduce the resolution of a scatter plot. + * # C to reduce the data of a scatter plot chart. + * # ST to reduce the data of a stacked pivot table. + * @return {Promise} - A promise of reduced data pages. */ getReducedData(qPages: INxPage[], qZoomFactor: number, qReductionMode: string): ng.IPromise; /** * Get total number of data rows for this object. - * @return {Number} - A number. + * @return {Number} - A number. */ getRowCount(): number; /** * Get stacked data from the Qlik engine for this object. Only works for hypercubes with qMode = S. - * @param {array} qPages - An array of request page objects. - * @param {number} qMaxNbrCells - Maximum number of cells at outer level. - * @return {Promise} - A promise of stack data pages. + * @param {array} qPages - An array of request page objects. + * @param {number} qMaxNbrCells - Maximum number of cells at outer level. + * @return {Promise} - A promise of stack data pages. */ getStackedData(qPages: INxPage[], qMaxNbrCells: number): ng.IPromise; /** * Find out if there are unconfirmed selections for this object. - * @return {boolean} - True if there are unconfirmed selections. + * @return {boolean} - True if there are unconfirmed selections. */ hasSelections(): boolean; /** * Save this object. - * @return {Promise} - A promise. In case of success, it returns "undefined". In case of failure it returns the error. + * @return {Promise} - A promise. In case of success, it returns "undefined". In case of failure it returns the error. */ save(): ng.IPromise; /** * Search for a term in a list object. Results in an updated layout, containing only matching records. - * @param {string} term - Term to search for. + * @param {string} term - Term to search for. */ search(term: string): void; /** * Select values in this object using ranges. - * @param {array} qRanges - Array of ranges to select. - * @param {boolean} qOrMode - If true only one of the measures needs to be in range. + * @param {array} qRanges - Array of ranges to select. + * @param {boolean} qOrMode - If true only one of the measures needs to be in range. */ selectRange(qRanges: IRange[], qOrMode: boolean): void; /** * Select values in this object with a Qlik engine call which triggers a repaint of the object. - * @param {number} qDimNo - Dimension number. 0 = first dimension. - * @param {array} qValues - Array of values (qElemNumber in the matrix from the Qlik engine) to select or deselect. - * @param {boolean} qToggleMode - If true, values in the field are selected in addition to any previously selected items. - * If false, values in the field are selected while previously selected items are deselected. + * @param {number} qDimNo - Dimension number. 0 = first dimension. + * @param {array} qValues - Array of values (qElemNumber in the matrix from the Qlik engine) to select or deselect. + * @param {boolean} qToggleMode - If true, values in the field are selected in addition to any previously selected items. + * If false, values in the field are selected while previously selected items are deselected. */ selectValues(qDimNo: number, qValues: any[], qToggleMode: boolean): void; /** * Set properties for this object. - * @param {object} props - The properties to set. - * @return {Promise} - A promise of a Qlik engine reply. + * @param {object} props - The properties to set. + * @return {Promise} - A promise of a Qlik engine reply. */ setProperties(props: any): ng.IPromise; } @@ -923,114 +942,119 @@ declare namespace RootAPI { interface IRoot { /** * Calls the Qlik Sense repository. - * @param {string} path - Path to the Qlik Sense repository. - * Refer to Qlik Sense repository documentation for the available paths. - * @param {string} [method] - Optional. HTTP method. Default is GET. - * @param {string} [body] - Optional. Body of the post. + * @param {string} path - Path to the Qlik Sense repository. + * Refer to Qlik Sense repository documentation for the available paths. + * @param {string} [method] - Optional. HTTP method. Default is GET. + * @param {string} [body] - Optional. Body of the post. * @return {Promise} - A promise of a Qlik engine reply. */ callRepository(path: string, method?: string, body?: string): ng.IPromise; /** currApp * Gets a reference to the current app. Use the currApp method in an extension to get a reference to the app currently displayed. - * @param {object} [reference] - Optional. Reference to extension object. Introduced in version 1.1. + * @param {object} [reference] - Optional. Reference to extension object. Introduced in version 1.1. * @return {IApp} - An App JavaScript object with app methods. */ currApp(object?: any): AppAPI.IApp; /** * Gets a list of Qlik Sense apps that you potentially can connect to and registers a callback to receive the data. - * The getAppList method opens a WebSocket, gets the app list, and then closes the WebSocket. - * @param {function} callback - Callback method. - * @param {object} [config] - Optional. Additional configuration parameters: - * Name | Type | Descr | Name - * host | String | Optional. Qlik host. | host - * port | String or integer | Port number. | port - * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. | prefix - * isSecure | Boolean | Optional. Use SSL. | isSecure - * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. | openWithoutData - * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. | identity + * The getAppList method opens a WebSocket, gets the app list, and then closes the WebSocket. + * @param {function} callback - Callback method. + * @param {object} [config] - Optional. Additional configuration parameters: + * Name | Type | Descr | Name + * host | String | Optional. Qlik host. | host + * port | String or integer | Port number. | port + * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. | prefix + * isSecure | Boolean | Optional. Use SSL. | isSecure + * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. | openWithoutData + * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. | identity */ getAppList(callback: any, config?: any): void; /** - * Gets a list of extensions installed for Qlik Sense. The reply contains all extensions, that is widget libraries, visualization extensions and mashups. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. + * Gets a list of extensions installed for Qlik Sense. The reply contains all extensions, + * that is widget libraries, visualization extensions and mashups. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. */ getExtensionList(callback?: any): ng.IPromise; /** - * Opens a WebSocekt connection to the Qlik engine for global methods. - * @param {object} [config] - Optional. Parameters: - * Name | Type | Description - * host | String | Qlik Sense host - * port | String | Port number - * prefix | String | Qlik Sense virtual proxy. / if no virtual proxy - * isSecure | Boolean | Use SSL - * identity | String | Unique identity for the session. If omitted, the session will be shared. - * @return {ANY} - A global JavaScript object with global methods. - */ + * Opens a WebSocekt connection to the Qlik engine for global methods. + * @param {object} [config] - Optional. Parameters: + * Name | Type | Description + * host | String | Qlik Sense host + * port | String | Port number + * prefix | String | Qlik Sense virtual proxy. / if no virtual proxy + * isSecure | Boolean | Use SSL + * identity | String | Unique identity for the session. If omitted, the session will be shared. + * @return {ANY} - A global JavaScript object with global methods. + */ getGlobal(config: any): any; /** Opens a Qlik Sense app. You can open multiple apps. * Most other methods are defined on the app. Returns: App JavaScript object with app methods. - * @param {string} appId The app id. - * @param {object} [config] Optional. Additional configuration parameters: - * Name | Type | Descr - * host | String | Optional. Qlik host. - * port | String or Integer | Port number. - * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. - * isSecure | Boolean | Optional. Use SSL. - * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. - * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. - * Parameter updated in version 2.2. - * @return {any} - App JavaScript object with app methods. + * @param {string} appId The app id. + * @param {object} [config] Optional. Additional configuration parameters: + * Name | Type | Descr + * host | String | Optional. Qlik host. + * port | String or Integer | Port number. + * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. + * isSecure | Boolean | Optional. Use SSL. + * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. + * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. + * Parameter updated in version 2.2. + * @return {any} - App JavaScript object with app methods. */ openApp(appId: string, config?: any): any; /** - * Registers an extension for use in this mashup. The extension is not installed on the Qlik Sense server and only available in the session where it is created. - * As long as a JavaScript module is created in the correct format, it can be sent to the registerExtension function. - * @param {string} id - Set the ID of the visualization extension. - * @param {object} impl - Set the extension implementation. - * @param {object} [metadata] - Optional. Extension meta-data, same format as the QEXT file. Default: {"type":"visualization"} - */ + * Registers an extension for use in this mashup. The extension is not installed on the + * Qlik Sense server and only available in the session where it is created. + * As long as a JavaScript module is created in the correct format, it can be sent to + * the registerExtension function. + * @param {string} id - Set the ID of the visualization extension. + * @param {object} impl - Set the extension implementation. + * @param {object} [metadata] - Optional. Extension meta-data, same format as the QEXT file. Default: {"type":"visualization"} + */ registerExtension(id: string, impl: any, metadata?: any): void; /** - * Sends a resize event to all Qlik Sense objects. - * @param {string} [ID] - Object id. Optional: if no ID resize event will be sent to all objects. - */ + * Sends a resize event to all Qlik Sense objects. + * @param {string} [ID] - Object id. Optional: if no ID resize event will be sent to all objects. + */ resize(ID?: string): void; /** - * Sets a specific language for the Qlik Sense session. - * Language should be defined before the app is opened meaning the setLanguage method should be called before the openApp method is called. - * @param {string} lang - Language code. Can be: - * # German: short: de long: de-DE - * # English: short: en long: en-US - * # Spanish: short: es long: es-ES - * # French: short: fr long: fr-FR - * # Italian: short: it long: it-IT - * # Japanese: short: ja long: ja-JP - * # Korean: (introduced in version 3.0) short: ko long: ko-KR - * # Dutch: short: nl long: nl-NL - * # Polish: (introduced in version 3.0) short: pl long: pl-PL - * # Brazilian Portuguese: short: pt long: pt-BR - * # Russian: short: ru long: ru-RU - * # Swedish: short: sv long: sv-SE - * # Turkish: (introduced in version 3.0) short: tr long: tr-TR - * # Simplified Chinese: short: Do not use! long: zh-CN - * # Traditional Chinese: (introduced in version 3.0) short: Do not use! long: zh-TW - */ + * Sets a specific language for the Qlik Sense session. + * Language should be defined before the app is opened meaning the setLanguage + * method should be called before the openApp method is called. + * @param {string} lang - Language code. Can be: + * # German: short: de long: de-DE + * # English: short: en long: en-US + * # Spanish: short: es long: es-ES + * # French: short: fr long: fr-FR + * # Italian: short: it long: it-IT + * # Japanese: short: ja long: ja-JP + * # Korean: (introduced in version 3.0) short: ko long: ko-KR + * # Dutch: short: nl long: nl-NL + * # Polish: (introduced in version 3.0) short: pl long: pl-PL + * # Brazilian Portuguese: short: pt long: pt-BR + * # Russian: short: ru long: ru-RU + * # Swedish: short: sv long: sv-SE + * # Turkish: (introduced in version 3.0) short: tr long: tr-TR + * # Simplified Chinese: short: Do not use! long: zh-CN + * # Traditional Chinese: (introduced in version 3.0) short: Do not use! long: zh-TW + */ setLanguage(lang: string): void; /** - * Registers a callback for error handling. Standard Qlik Sense error handling is used if this method is not called. - * @param {function} onError - Error handling function - * @param {function} [onWarning] - Optional. Warning handling function. Introduced in version 2.1. - */ + * Registers a callback for error handling. Standard Qlik Sense error + * handling is used if this method is not called. + * @param {function} onError - Error handling function + * @param {function} [onWarning] - Optional. Warning handling function. Introduced in version 2.1. + */ setOnError(onError: any, onWarning?: any): void; /** @@ -1047,260 +1071,278 @@ declare namespace RootAPI { declare namespace AppAPI { interface IApp { - /** - * Adds an alternate state in the app. Multiple states within a Qlik Sense app can be created and applied to specific objects within the app. Objects in a given state are not affected by user selection in the other states. - * @param {string} qStateName - Mandatory. Alternate state name. - * @return {Promise} - A promise of a Qlik engine reply. + /** + * Adds an alternate state in the app. Multiple states within a Qlik Sense + * app can be created and applied to specific objects within the app. + * Objects in a given state are not affected by user selection in the other states. + * @param {string} qStateName - Mandatory. Alternate state name. + * @return {Promise} - A promise of a Qlik engine reply. */ addAlternateState(qStateName: string): ng.IPromise; /** - * Steps back in the list of selections. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Steps back in the list of selections. + * @return {Promise} - A promise of a Qlik engine reply. + */ back(): ng.IPromise; /** - * Clears all selections in all fields of the current Qlik Sense app. - * @param {boolean} [lockedAlso] - Optional. Alternate state name. Default: false Introduced in version 2.1. - * @param {string} [state] - Optional. Alternate state name. Default: $ Introduced in version 2.1. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Clears all selections in all fields of the current Qlik Sense app. + * @param {boolean} [lockedAlso] - Optional. Alternate state name. Default: false Introduced in version 2.1. + * @param {string} [state] - Optional. Alternate state name. Default: $ Introduced in version 2.1. + * @return {Promise} - A promise of a Qlik engine reply. + */ clearAll(lockedAlso?: boolean, state?: string): ng.IPromise; /** - * Closes a Qlik Sense app. Also closes the WebSocket and clears out client side data. - */ + * Closes a Qlik Sense app. Also closes the WebSocket and clears out client side data. + */ close(): void; /** - * Defines a hypercube and registers a callback to receive the data. - * @param {object} qHyperCubeDef - Cube definition. - * @param {function} [callback] - Optional. Callback method. Parameter will contain a qHyperCube. - * @return {Promise} - A promise of an object model. - */ + * Defines a hypercube and registers a callback to receive the data. + * @param {object} qHyperCubeDef - Cube definition. + * @param {function} [callback] - Optional. Callback method. Parameter will contain a qHyperCube. + * @return {Promise} - A promise of an object model. + */ createCube(qHyperCubeDef: any, callback?: any): ng.IPromise; /** - * Creates a generic object and registers a callback to receive the data. The generic object can contain the following: - * # qHyperCubeDef - * # qListObjectDef - * # qStringExpression - * # qValueExpression - * The callback method will be called whenever the selection state changes in a way that affects the generic object. The parameter will be the evaluated version of the definition. - * @param {object} [def] - Optional. Generic object definition - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of an object model. - */ + * Creates a generic object and registers a callback to receive the data. The generic object can contain the following: + * # qHyperCubeDef + * # qListObjectDef + * # qStringExpression + * # qValueExpression + * The callback method will be called whenever the selection state changes + * in a way that affects the generic object. + * The parameter will be the evaluated version of the definition. + * @param {object} [def] - Optional. Generic object definition + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of an object model. + */ createGenericObject(def?: any, callback?: any): ng.IPromise; /** - * Defines a list of field values and registers a callback to receive the data. - * @param {object} qListObjectDef - List definition. - * @param {function} [callback] - Optional. Callback method. Parameter will contain a qListObject. - * @return {Promise} - A promise of an object model. - */ + * Defines a list of field values and registers a callback to receive the data. + * @param {object} qListObjectDef - List definition. + * @param {function} [callback] - Optional. Callback method. Parameter will contain a qListObject. + * @return {Promise} - A promise of an object model. + */ createList(qListObjectDef: any, callback?: any): ng.IPromise; /** - * Defines a hypercube for a table and is the entry point to the Table API. It creates a table object that wraps the hypercube. - * @param {Array.} dimensions - Dimensions to use. + * Defines a hypercube for a table and is the entry point to the Table API. + * It creates a table object that wraps the hypercube. + * @param {Array.} dimensions - Dimensions to use. * Should, for each entry, be a field name or a NxDimension structure. - * @param {Array.} measures - Measures to use. + * @param {Array.} measures - Measures to use. * Should, for each entry, be an expression or a NxMeasure structure. - * @param {object} [options] - Optional. Options to set. - * @return {QTable} - A table object of type QTable, which is initially empty but that eventually will contain data. The table object will be updated when selection state changes. - */ + * @param {object} [options] - Optional. Options to set. + * @return {QTable} - A table object of type QTable, which is initially + * empty but that eventually will contain data. + * The table object will be updated when selection state changes. + */ createTable(dimensions: string[] | any[], measures: string[] | any[], options?: any): TableAPI.IQTable; /** - * Destroys a Qlik Sense session object created with the createGenericObject method or any of createCube, createList or getList methods. - * Calling this method removes the object from the Qlik engine, no more updates are sent to the client and all methods on the object are invalid. - * @param {string} id - Session object id. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Destroys a Qlik Sense session object created with the createGenericObject + * method or any of createCube, createList or getList methods. + * Calling this method removes the object from the Qlik engine, + * no more updates are sent to the client and all methods on the object are invalid. + * @param {string} id - Session object id. + * @return {Promise} - A promise of a Qlik engine reply. + */ destroySessionObject(id: string): ng.IPromise; /** - * Reloads the data in a Qlik Sense app. - * @param {string} [qMode] - Optional. Error handling mode: - * # 0 = default mode. - * # 1 = attempt recovery on all errors. - * # 2 = fail on all errors. - * @param {boolean} [qPartial] - Optional. Set to true for partial reload. - * @param {boolean} [qDebug] - Optional. Set to true if debug breakpoints are honored. Execution of the script will be in debug mode. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Reloads the data in a Qlik Sense app. + * @param {string} [qMode] - Optional. Error handling mode: + * # 0 = default mode. + * # 1 = attempt recovery on all errors. + * # 2 = fail on all errors. + * @param {boolean} [qPartial] - Optional. Set to true for partial reload. + * @param {boolean} [qDebug] - Optional. Set to true if debug breakpoints are honored. Execution of the script will be in debug mode. + * @return {Promise} - A promise of a Qlik engine reply. + */ doReload(qMode?: string, qPartial?: boolean, qDebug?: boolean): ng.IPromise; /** - * Saves a Qlik Sense app, including all objects and data in the data model. - * @param {string} [qFileName] - Optional. File name of the file to save. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Saves a Qlik Sense app, including all objects and data in the data model. + * @param {string} [qFileName] - Optional. File name of the file to save. + * @return {Promise} - A promise of a Qlik engine reply. + */ doSave(qFileName?: string): ng.IPromise; /** - * Gets a field reference with methods that can be used to manipulate the field. - * @param {string} [field] - Optional. Name of the field. - * @param {string} [state] - Optional. Alternate state name. Default is $. - * @return {QField} - A QField object with methods and properties that can be used to manipulate the field. - */ + * Gets a field reference with methods that can be used to manipulate the field. + * @param {string} [field] - Optional. Name of the field. + * @param {string} [state] - Optional. Alternate state name. Default is $. + * @return {QField} - A QField object with methods and properties that can be used to manipulate the field. + */ field(field?: string, state?: string): FieldAPI.IQField; /** - * Step forward in list of selections. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Step forward in list of selections. + * @return {Promise} - A promise of a Qlik engine reply. + */ forward(): ng.IPromise; /** - * Gets a layout for this Qlik Sense app and registers a callback to receive the data. Returns the dynamic properties (if any) in addition to the fixed properties. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Gets a layout for this Qlik Sense app and registers a callback to receive the data. + * Returns the dynamic properties (if any) in addition to the fixed properties. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ getAppLayout(callback?: any): ng.IPromise; /** - * Gets a list of sheets and visualizations and registers a callback to receive the data. - * @param {string} [field] - Optional. Type of object. One of: - * # sheet - * # masterobject - * Default is sheet. - * @param {function} [callback] - Optional. Callback method. - */ + * Gets a list of sheets and visualizations and registers a callback to receive the data. + * @param {string} [field] - Optional. Type of object. One of: + * # sheet + * # masterobject + * Default is sheet. + * @param {function} [callback] - Optional. Callback method. + */ getAppObjectList(type?: string, callback?: any): void; /** - * Gets properties for a generic object, the children of the generic object and the bookmarks and/or embedded snapshots of the generic object. - * @param {string} id - Object id. - * @return {Promise} - A promise of an object model. - */ + * Gets properties for a generic object, the children of the generic object + * and the bookmarks and/or embedded snapshots of the generic object. + * @param {string} id - Object id. + * @return {Promise} - A promise of an object model. + */ getFullPropertyTree(id: string): ng.IPromise; /** - * Gets a list of internal Qlik Sense objects and registers a callback to receive the data. - * @param {string} type - Type of object: - * # FieldList - * # MeasureList - * # DimensionList - * # BookmarkList - * # SelectionObject - * # SnapshotList (Introduced in version 1.1) - * # MediaList (Introduced in version 1.1) - * # Sheet (Introduced in version 1.1) - * # MasterObject (Introduced in version 1.1) - * # VariableList (Introduced in version 2.0) - * # story (Introduced in version 2.1) - * @param {function} [callback] - Optional. Registers a callback that is executed every time data is returned. - * @return {Promise} - A promise of an object model. - */ + * Gets a list of internal Qlik Sense objects and registers a callback to receive the data. + * @param {string} type - Type of object: + * # FieldList + * # MeasureList + * # DimensionList + * # BookmarkList + * # SelectionObject + * # SnapshotList (Introduced in version 1.1) + * # MediaList (Introduced in version 1.1) + * # Sheet (Introduced in version 1.1) + * # MasterObject (Introduced in version 1.1) + * # VariableList (Introduced in version 2.0) + * # story (Introduced in version 2.1) + * @param {function} [callback] - Optional. Registers a callback that is executed every time data is returned. + * @return {Promise} - A promise of an object model. + */ getList(type: string, callback?: any): ng.IPromise; /** - * Retrieves a Qlik Sense object from the Qlik Sense application and inserts it into a HTML element. The object fills the HTML object, so you can size and position the element to determine how large the Qlik Sense object will be. - * If you supply only one parameter, you get the model without displaying the object. - * @param {string} id - Object id or 'CurrentSelections' if used for Selections bar. + * Retrieves a Qlik Sense object from the Qlik Sense application and inserts + * it into a HTML element. The object fills the HTML object, so you can size + * and position the element to determine how large the Qlik Sense object will be. + * If you supply only one parameter, you get the model without displaying the object. + * @param {string} id - Object id or 'CurrentSelections' if used for Selections bar. * @param {Element | string} [elem] - Optional. HTML element. * Since version 1.1 it is also possible to define a string of the HTML element id. - * @param {object} [options] - Optional. - * Name | Type | Description - * noInteraction | Boolean | Set to true if you want to disable interaction, including selections, in the visualization. Introduced in version 1.1 and updated in version 3.0. - * noSelections | Boolean | Set to true if you want to disable selections in the visualization. Introduced in version 3.0. - * @return {Promise} - A promise of an object model. - */ + * @param {object} [options] - Optional. + * Name | Type | Description + * noInteraction | Boolean | Set to true if you want to disable interaction, + * including selections, in the visualization. + * Introduced in version 1.1 and updated in version 3.0. + * noSelections | Boolean | Set to true if you want to disable selections in the visualization. + * Introduced in version 3.0. + * @return {Promise} - A promise of an object model. + */ getObject(id: string, elem?: any | string, options?: any): ng.IPromise; /** - * Gets properties for a Qlik Sense object. - * @param {string} id - Object id. - * @return {Promise} - A promise of an object model. - */ + * Gets properties for a Qlik Sense object. + * @param {string} id - Object id. + * @return {Promise} - A promise of an object model. + */ getObjectProperties(id: string): ng.IPromise; /** - * Inserts a Qlik Sense snapshot into a HTML element. The snapshot fills the HTML object so you can size and position the element to determine how large the Qlik Sense object will be. - * If you only supply one parameter, you will just get the model without displaying the object. + * Inserts a Qlik Sense snapshot into a HTML element. The snapshot fills + * the HTML object so you can size and position the element to determine + * how large the Qlik Sense object will be. If you only supply one parameter, + * you will just get the model without displaying the object. * @param {string} id - Snapshot ID. * @param {element | string} [elem] - Optional. HTML element or string with HTML element id. - * @return {Promise} - A promise of an object model. - */ + * @return {Promise} - A promise of an object model. + */ getSnapshot(id: string, elem?: any | string): ng.IPromise; /** - * Locks all selections. - * @param {string} [state=$] - Optional. Alternate state name. - * Default: $ - * Introduced in version 2.1. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Locks all selections. + * @param {string} [state=$] - Optional. Alternate state name. + * Default: $ + * Introduced in version 2.1. + * @return {Promise} - A promise of a Qlik engine reply. + */ lockAll(state?: string): ng.IPromise; /** - * Removes an alternate state in the app. - * @param {string} qStateName - Alternate state name. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Removes an alternate state in the app. + * @param {string} qStateName - Alternate state name. + * @return {Promise} - A promise of a Qlik engine reply. + */ removeAlternateState(qStateName: string): ng.IPromise; /** - * Searches for one or more terms in the values of a Qlik Sense app. - * @param {array} qTerms - Terms to search for. - * @param {object} qPage - Properties: - * Name | Type | Description - * qOffset | Number | Position from the top, starting from 0. - * qCount | Number | Number of search results to return. - * qMaxNbrFieldMatches | Number | Maximum number of matching values to return per search result. - * @param {object} qOptions - Properties - * Name | Type | Description - * qSearchFields | Array | List of search fields. - * qContext | | Search context. Can be one of: - * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. - * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. - * | | Default value is LockedFieldsOnly. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Searches for one or more terms in the values of a Qlik Sense app. + * @param {array} qTerms - Terms to search for. + * @param {object} qPage - Properties: + * Name | Type | Description + * qOffset | Number | Position from the top, starting from 0. + * qCount | Number | Number of search results to return. + * qMaxNbrFieldMatches | Number | Maximum number of matching values to return per search result. + * @param {object} qOptions - Properties + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * qContext | | Search context. Can be one of: + * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * | | Default value is LockedFieldsOnly. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ searchAssociations(qTerms: any[], qPage: any, qOptions: any, callback?: any): ng.IPromise; /** - * Searches for one or more terms in the values of a Qlik Sense app. - * @param {array} qTerms - Terms to search for. - * @param {object} qPage - Properties: - * Name | Type | Description - * qOffset | Number | Position from the top, starting from 0. - * qCount | Number | Number of search results to return. - * qGroupOptions | Array | This parameter is optional. Options of the search groups. If this property is not set, all values are returned. - * qGroupItemOptions | Array | This parameter is optional. Options of the search group items. If this property is not set, all values are returned. - * qOptions | Object | Optional. Search options. Properties: - * Name | Type | Description - * qSearchFields | Array | List of search fields. - * qContext | | Search context. Can be one of: - * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. - * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. - * | | Default value is LockedFieldsOnly. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Searches for one or more terms in the values of a Qlik Sense app. + * @param {array} qTerms - Terms to search for. + * @param {object} qPage - Properties: + * Name | Type | Description + * qOffset | Number | Position from the top, starting from 0. + * qCount | Number | Number of search results to return. + * qGroupOptions | Array | This parameter is optional. Options of the search groups. If this property is not set, all values are returned. + * qGroupItemOptions | Array | This parameter is optional. Options of the search group items. If this property is not set, all values are returned. + * qOptions | Object | Optional. Search options. Properties: + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * qContext | | Search context. Can be one of: + * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * | | Default value is LockedFieldsOnly. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ searchResults(qTerms: any[], qPage: any, qOptions?: any, callback?: any): ng.IPromise; /** - * Returns suggestions of words from the values entered in the search. Acts as a helper for the searchAssociations method. - * @param {array} qTerms - Terms to search for. - * @param {object} [qOptions] - Optional. Search options. Properties: - * Name | Type | Description - * qSearchFields | Array | List of search fields. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Returns suggestions of words from the values entered in the search. Acts as a helper for the searchAssociations method. + * @param {array} qTerms - Terms to search for. + * @param {object} [qOptions] - Optional. Search options. Properties: + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ searchSuggest(qTerms: any[], qOptions?: any, callback?: any): ng.IPromise; /** - * Makes a selection based on searchAssociation results. - * @param {number} qMatchIx - Index to search result. - * @param {array} qTerms - Values to select. + * Makes a selection based on searchAssociation results. + * @param {number} qMatchIx - Index to search result. + * @param {array} qTerms - Values to select. * @param {object} qOptions - Values to select. * @param {array} [qTerms] - Optional. Parameter sent to the Qlik engine containing information about the search fields and the search context. * @param {object} [qSoftLock] - Optional. This parameter was deprecated in version 2.0 and is ignored in newer versions. Use the qOtions.qContext parameter instead. @@ -1365,7 +1407,9 @@ declare namespace FieldAPI { clearOther(softlock?: boolean): ng.IPromise; /** - * Gets field data. The values are available as QFieldValue in array field.rows and will updated when the selection state changes. Notification OnData will be triggered after each update. + * Gets field data. The values are available as QFieldValue in array + * field.rows and will updated when the selection state changes. + * Notification OnData will be triggered after each update. * @param {boolean} [options] - Optional. Properties: * Name | Type | Description * rows | Number | Number of rows to fetch. Default: 200. @@ -1438,7 +1482,8 @@ declare namespace FieldAPI { /** * Selects specific values in a field. - * @param {array} array - Array of qFieldValues to select. A simplified syntax with strings or numbers also works since version 1.1. + * @param {array} array - Array of qFieldValues to select. A simplified syntax with + * strings or numbers also works since version 1.1. * For a numeric field you need to provide the numeric value. * @param {boolean} [toggle] - Optional. If true, toggle selected state. * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. @@ -1471,7 +1516,8 @@ declare namespace FieldAPI { rowCount: number; /** - * Optional. Object with number of values in different states. Only after getData() call. Introduced in 2.1. + * Optional. Object with number of values in different states. + * Only after getData() call. Introduced in 2.1. */ qStateCounts: any; } @@ -1521,8 +1567,10 @@ declare namespace GlobalAPI { cancelReload(): ng.IPromise; /** - * Gets a list of Qlik Sense apps that you potentially can connect to and registers a callback to receive the data. - * Calling the getAppList method opens a WebSocket, gets the app list, and then keeps the WebSocket open for you to make other calls as well. + * Gets a list of Qlik Sense apps that you potentially can connect to and + * registers a callback to receive the data. Calling the getAppList method + * opens a WebSocket, gets the app list, and then keeps the WebSocket open + * for you to make other calls as well. * @param {Function} callback - Callback method. */ getAppList(callback: any): void; @@ -1566,7 +1614,9 @@ declare namespace GlobalAPI { getQvVersion(callback?: any): ng.IPromise; /** - * Gets information if the user is working in personal mode (returns true if Qlik Sense Desktop is used) or not (returns false if Qlik Sense Desktop is not used). + * Gets information if the user is working in personal mode + * (returns true if Qlik Sense Desktop is used) or not + * (returns false if Qlik Sense Desktop is not used). * @param {Function} [callback] - Optional. Callback method. * @return {Promise} - A promise of a Qlik engine reply. */ @@ -1641,14 +1691,16 @@ declare namespace NavigationAPI { getMode(): string; /** - * Navigate to a given sheet in the current app. The method will return before the actual navigation takes place. + * Navigate to a given sheet in the current app. + * The method will return before the actual navigation takes place. * @param {string} sheetId - Set the sheet ID to navigate to. * @return {NavigationResult} - A navigation result object. */ gotoSheet(sheetId: string): NavigationResult; /** - * Navigate to a given story in the current app. The method will return before the actual navigation takes place. + * Navigate to a given story in the current app. + * The method will return before the actual navigation takes place. * @param {string} storyId - Set the story ID to navigate to. * @return {NavigationResult} - A navigation result object. */ @@ -1663,14 +1715,16 @@ declare namespace NavigationAPI { isModeAllowed(mode: NavigationModeType): boolean; /** - * Go to the next sheet in the current app. It will do nothing if you do not have sheets in the current context. + * Go to the next sheet in the current app. + * It will do nothing if you do not have sheets in the current context. * The method will return before the actual navigation takes place. * @return {NavigationResult} - A navigation result object. */ nextSheet(): NavigationResult; /** - * Jumps to the previous sheet in the current app. It will do nothing if you do not have sheets in the current context. + * Jumps to the previous sheet in the current app. + * It will do nothing if you do not have sheets in the current context. * The method will return before the actual navigation takes place * @return {NavigationResult} - A navigation result object. */ @@ -1742,17 +1796,20 @@ declare namespace SelectionStateAPI { qStateCounts: any; /** - * Concatenated string of selected values if number of values are less than the threshold, or if the string is of format "7 of 123". + * Concatenated string of selected values if number of values are less + * than the threshold, or if the string is of format "7 of 123". */ qSelected: string; /** - * Array with maximum of qSelectionThreshold values that are selected. For each value, the text plus the selection mode (NORMAL/AND/NOT) + * Array with maximum of qSelectionThreshold values that are selected. + * For each value, the text plus the selection mode (NORMAL/AND/NOT) */ selectedValues: number[]; /** - * Array with maximum of qSelectionThreshold values that are not selected. For each value, the text plus the selection mode (NORMAL/AND/NOT) + * Array with maximum of qSelectionThreshold values that are not selected. + * For each value, the text plus the selection mode (NORMAL/AND/NOT) */ notSelectedValues: number[]; } @@ -1834,7 +1891,8 @@ declare namespace TableAPI { * # OOXML: open XML, default * # CSV_C: comma separated CSV * # CSV_T: tab separated CSV - * filename | String | Name of the exported file after download from browser. This parameter is optional and only used in desktop. + * filename | String | Name of the exported file after download from browser. + * This parameter is optional and only used in desktop. * state | String | Can be: * # A: all values * # P: possible values (default) @@ -1890,12 +1948,14 @@ declare namespace TableAPI { qCardinal?: number; /** - * Optional. Object with number of values in different states. Only used for dimensions. + * Optional. Object with number of values in different states. + * Only used for dimensions. */ qStateCounts?: any; /** - * Optional. Field object with methods to manipulate the underlying field. Only used for dimensions. + * Optional. Field object with methods to manipulate the underlying field. + * Only used for dimensions. */ field?: any; @@ -1910,12 +1970,14 @@ declare namespace TableAPI { qMax?: number; /** - * Optional. Error code for this column. Only if column has an error. Introduced in version 2.2. + * Optional. Error code for this column. + * Only if column has an error. Introduced in version 2.2. */ errorCode?: number; /** - * Error message for this column. Only if column has an error. Introduced in version 2.2. + * Error message for this column. + * Only if column has an error. Introduced in version 2.2. */ errorMessage: number; @@ -1986,7 +2048,8 @@ declare namespace TableAPI { qNum?: number; /** - * Gets the value of this cell as a percentage of the total. Might be more than 100% if this is an average. + * Gets the value of this cell as a percentage of the total. + * Might be more than 100% if this is an average. */ getPercent(): number; @@ -2014,7 +2077,8 @@ declare namespace VariableAPI { create(qProp: string | any): ng.IPromise; /** - * Creates a session variable, that is a temporary variable which is not persisted and needs to be recreated for each new session. + * Creates a session variable, that is a temporary variable which is not + * persisted and needs to be recreated for each new session. * @param {object} qProp - Variable properties: * Name | Type | Description * qInfo.qId | String | Optional. Variable id. @@ -2081,7 +2145,8 @@ declare namespace VisualizationAPI { interface IVisualization { /** - * Create a new visualization on the fly based on a session object and will not be persisted in the app. + * Create a new visualization on the fly based on a session object + * and will not be persisted in the app. * @param {VisualizationType} type - Visualization type. Can be: * # barchart * # combochart @@ -2094,11 +2159,13 @@ declare namespace VisualizationAPI { * # table * # treemap * # extension - * @param {array} [cols] - Optional. Column definitions, dimensions and measures. Each entry can be of the following structures: + * @param {array} [cols] - Optional. Column definitions, dimensions and measures. + Each entry can be of the following structures: * # String * # NxDimension * # NxMeasure - * If the NxDimension or the NxMeasure refer to a library dimension or a library measure, you also need to add qType : "measure" or "dimension". + * If the NxDimension or the NxMeasure refer to a library dimension + * or a library measure, you also need to add qType : "measure" or "dimension". * @param {object} [options] - Optional. Options to set. * @return {Promise} - A promise of a QVisualization. */ @@ -2114,7 +2181,8 @@ declare namespace VisualizationAPI { interface IQVisualization { /** - * Table object for this visualization. Only for visualizations built on a hypercube. + * Table object for this visualization. + * Only for visualizations built on a hypercube. */ table: TableAPI.IQTable; @@ -2399,8 +2467,10 @@ interface IQVAngular { filter(object: { [name: string]: ng.Injectable }): void; /** - * Register a service constructor, which will be invoked with new to create the service instance. This is short for registering a service where its provider's $get property is a factory function that returns an instance instantiated by the injector from the service constructor function. - * + * Register a service constructor, which will be invoked with new to create + * the service instance. This is short for registering a service where its + * provider's $get property is a factory function that returns an instance + * instantiated by the injector from the service constructor function. * @param name The name of the instance. * @param serviceConstructor An injectable class (constructor function) that will be instantiated. * @return Returns the constructed singleton of the service class/function. diff --git a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts index 2e1d738198..76a71d22dc 100644 --- a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts +++ b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts @@ -1,3 +1,3 @@ -import qlik=require("qlik"); +import qlik = require("qlik"); const t = qlik.currApp(); \ No newline at end of file diff --git a/qlik-visualizationextensions/tsconfig.json b/qlik-visualizationextensions/tsconfig.json index f4a5bc132a..c71a5c597d 100644 --- a/qlik-visualizationextensions/tsconfig.json +++ b/qlik-visualizationextensions/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/qlik-visualizationextensions/tslint.json b/qlik-visualizationextensions/tslint.json index 965a36a968..cae1bdf2ad 100644 --- a/qlik-visualizationextensions/tslint.json +++ b/qlik-visualizationextensions/tslint.json @@ -1,4 +1,5 @@ -{ "extends": "../tslint.json", +{ + "extends": "../tslint.json", "rules": { "forbidden-types": false, "no-empty-interface": false, From 63fd21838b726dc7dacd07c2704819fd8a8cb0c5 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Sun, 12 Mar 2017 16:01:20 +0100 Subject: [PATCH 047/150] fix trailing whitespaces Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index 4f384ca925..bb1d6dd6f5 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -772,7 +772,7 @@ declare namespace BackendAPI { /** * Gets a data row for this object. * @param {number} rownum - The row number. - * @return {NxCell} - A row of NxCell or null if the row is not available client side + * @return {NxCell} - A row of NxCell or null if the row is not available client side * and need to be fetched with getData method. */ getDataRow(rownum: number): INxCell; @@ -1242,7 +1242,7 @@ declare namespace AppAPI { * Since version 1.1 it is also possible to define a string of the HTML element id. * @param {object} [options] - Optional. * Name | Type | Description - * noInteraction | Boolean | Set to true if you want to disable interaction, + * noInteraction | Boolean | Set to true if you want to disable interaction, * including selections, in the visualization. * Introduced in version 1.1 and updated in version 3.0. * noSelections | Boolean | Set to true if you want to disable selections in the visualization. From 26f66082018071739cdc822b1bfdd4d68ba8e750 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Mon, 13 Mar 2017 07:43:51 +0100 Subject: [PATCH 048/150] fix "max-line-length Exceeds maximum line length of 200" Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 30 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index bb1d6dd6f5..d12cbac656 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -1297,9 +1297,18 @@ declare namespace AppAPI { * Name | Type | Description * qSearchFields | Array | List of search fields. * qContext | | Search context. Can be one of: - * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. - * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * # Cleared: In this mode, the first step is to clear any current selections in the app. + * The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated + * with the selections made in locked fields, ignoring selections + * in any unlocked field. If no locked fields, the behavior is + * identical to the Cleared context. You cannot make any new selections + * in a locked field. You can get search hits for the associated values + * of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections:In this mode, the current selections are kept (if any). Search + * for one or more terms in the values of the app. New selections + * are made on top of the current selections. If no selections were + * made before the search, this mode is identical to the Cleared context. * | | Default value is LockedFieldsOnly. * @param {function} [callback] - Optional. Callback method. * @return {Promise} - A promise of a Qlik engine reply. @@ -1319,9 +1328,18 @@ declare namespace AppAPI { * Name | Type | Description * qSearchFields | Array | List of search fields. * qContext | | Search context. Can be one of: - * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. - * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * # Cleared: In this mode, the first step is to clear any current selections in the app. + * The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated + * with the selections made in locked fields, ignoring selections + * in any unlocked field. If no locked fields, the behavior is + * identical to the Cleared context. You cannot make any new selections + * in a locked field. You can get search hits for the associated values + * of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections:In this mode, the current selections are kept (if any). Search + * for one or more terms in the values of the app. New selections + * are made on top of the current selections. If no selections were + * made before the search, this mode is identical to the Cleared context. * | | Default value is LockedFieldsOnly. * @param {function} [callback] - Optional. Callback method. * @return {Promise} - A promise of a Qlik engine reply. From 31a8844a49a39605d37f4ef4d3062a55881a6481 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Mon, 13 Mar 2017 07:49:25 +0100 Subject: [PATCH 049/150] fix some trailing white spaces Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index d12cbac656..e5d5850423 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -1299,7 +1299,7 @@ declare namespace AppAPI { * qContext | | Search context. Can be one of: * # Cleared: In this mode, the first step is to clear any current selections in the app. * The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated + * # LockedFieldsOnly: In this mode, the search applies only to the values associated * with the selections made in locked fields, ignoring selections * in any unlocked field. If no locked fields, the behavior is * identical to the Cleared context. You cannot make any new selections @@ -1330,8 +1330,8 @@ declare namespace AppAPI { * qContext | | Search context. Can be one of: * # Cleared: In this mode, the first step is to clear any current selections in the app. * The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated - * with the selections made in locked fields, ignoring selections + * # LockedFieldsOnly: In this mode, the search applies only to the values associated + * with the selections made in locked fields, ignoring selections * in any unlocked field. If no locked fields, the behavior is * identical to the Cleared context. You cannot make any new selections * in a locked field. You can get search hits for the associated values From 10b1dd1ba5964dbbc380a96782d110edbe099f3c Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 13 Mar 2017 10:20:33 +0100 Subject: [PATCH 050/150] Async: made AsyncFunction return void again. --- async/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/async/index.d.ts b/async/index.d.ts index 7f71f3b9bc..b46002d971 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -11,7 +11,7 @@ interface AsyncResultCallback { (err?: E, result?: T): void; } interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } -interface AsyncFunction { (callback: (err?: E, result?: T) => void): any; } +interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } From aebfd7772bc582ed8d6f646f0ecfcb183e5a02c5 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 13 Mar 2017 12:53:33 +0100 Subject: [PATCH 051/150] async: reflectAll err is always null --- async/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/async/index.d.ts b/async/index.d.ts index b46002d971..88d4cf900b 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -193,7 +193,7 @@ interface Async { setImmediate: typeof async.nextTick; reflect(fn: AsyncFunction) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void; - reflectAll(tasks: AsyncFunction[]): ((callback: (err: undefined, result: {error?: E, value?: T}) => void) => void)[]; + reflectAll(tasks: AsyncFunction[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[]; timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; From 8875c23774e1fea4f4e6293c6a29d57172c3b5a8 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 13 Mar 2017 14:20:12 +0100 Subject: [PATCH 052/150] async: 3 more small errors i found --- async/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/async/index.d.ts b/async/index.d.ts index 88d4cf900b..a17735eb6e 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -9,7 +9,7 @@ interface ErrorCallback { (err?: T): void; } interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } interface AsyncResultCallback { (err?: E, result?: T): void; } interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } -interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } +interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } @@ -174,7 +174,7 @@ interface Async { during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; - waterfall(tasks: Function[], callback?: AsyncResultCallback): void; + waterfall(tasks: Function[], callback?: AsyncResultCallback): void; compose(...fns: Function[]): Function; seq(...fns: Function[]): Function; applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. @@ -207,7 +207,7 @@ interface Async { transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; - race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; + race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; // Utils memoize(fn: Function, hasher?: Function): Function; From 04573ae491126ace626edc4866c73502d1881dbb Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 13 Mar 2017 14:27:09 +0100 Subject: [PATCH 053/150] async: Changed strictNullChecks to true, and fixed the tests --- async/test/explicit.ts | 54 ++++++++++++++++++++++++++++++++---------- async/test/index.ts | 16 ++++++------- async/tsconfig.json | 4 ++-- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/async/test/explicit.ts b/async/test/explicit.ts index 80343cf6b1..b9ea9c84ed 100644 --- a/async/test/explicit.ts +++ b/async/test/explicit.ts @@ -1,44 +1,74 @@ -interface StringCallback { (err: Error, result: string): void; } +interface StringCallback { (err?: Error, result?: string): void; } interface AsyncStringGetter { (callback: StringCallback): void; } var taskArray: AsyncStringGetter[] = [ function (callback) { setTimeout(function () { - callback(null, 'one'); + callback(undefined, 'one'); }, 200); }, function (callback) { setTimeout(function () { - callback(null, 'two'); + callback(undefined, 'two'); }, 100); }, ]; -async.series(taskArray, function (err, results) { console.log(results[0].match(/o/)) }); -async.parallel(taskArray, function (err, results) { console.log(results[0].match(/o/)) }); -async.parallelLimit(taskArray, 3, function (err, results) { console.log(results[0].match(/o/)) }); +async.series(taskArray, function (err, results) { + if (results) { + let first = results[0]; + if (first) { + console.log(first.match(/o/)) + } + } +}); +async.parallel(taskArray, function (err, results) { + if (results) { + let first = results[0]; + if (first) { + console.log(first.match(/o/)) + } + } +}); +async.parallelLimit(taskArray, 3, function (err, results) { + if (results) { + let first = results[0]; + if (first) { + console.log(first.match(/o/)) + } + } +}); interface Lookup { [key: string]: T; } -interface NumberCallback { (err: Error, result: number): void; } +interface NumberCallback { (err?: Error, result?: number): void; } interface AsyncNumberGetter { (callback: NumberCallback): void; } var taskDict: Lookup = { one: function(callback){ setTimeout(function(){ - callback(null, 1); + callback(undefined, 1); }, 200); }, two: function(callback){ setTimeout(function(){ - callback(null, 2); + callback(undefined, 2); }, 100); } } -async.series(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) }); -async.parallel(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) }); -async.parallelLimit(taskDict, 3, function(err, results) { console.log(results['one'].toFixed(1)) }); +async.series(taskDict, function(err, results) { + let one = results['one']; + console.log(one && one.toFixed(1)) +}); +async.parallel(taskDict, function(err, results) { + let one = results['one']; + console.log(one && one.toFixed(1)) +}); +async.parallelLimit(taskDict, 3, function(err, results) { + let one = results['one']; + console.log(one && one.toFixed(1)) +}); diff --git a/async/test/index.ts b/async/test/index.ts index 8c6be303e4..b30ca4c7ba 100644 --- a/async/test/index.ts +++ b/async/test/index.ts @@ -350,9 +350,9 @@ q2.unshift(['task3', 'task4', 'task5'], function (error) { }); -var aq = async.queue(function (level: number, callback: (error : Error, newLevel: number) => void) { +var aq = async.queue(function (level: number, callback: (error?: Error, newLevel?: number) => void) { console.log('hello ' + level); - callback(null, level+1); + callback(undefined, level+1); }); aq.push(1, function (err : Error, newLevel : number) { @@ -807,9 +807,9 @@ async.some({ // timeout -function myFunction1(foo : any, callback: (err : Error, result : any) => void ) : void { +function myFunction1(foo : any, callback: (err?: Error, result?: any) => void ) : void { console.log(`async.timeout 1 ${foo}`); - return callback(null, foo); + return callback(undefined, foo); } var wrapped1 = async.timeout(myFunction1, 1000); wrapped1({ bar: 'bar' }, function(err : Error, data : any) { @@ -817,9 +817,9 @@ wrapped1({ bar: 'bar' }, function(err : Error, data : any) { }); -function myFunction2(callback: (err : Error, result : any) => void ) : void { +function myFunction2(callback: (err?: Error, result?: any) => void ) : void { console.log(`async.timeout 2`); - return callback(null, { bar: 'bar' }); + return callback(undefined, { bar: 'bar' }); } var wrapped2 = async.timeout(myFunction2, 1000); @@ -827,9 +827,9 @@ wrapped2( function(err : Error, data : any) { console.log(`async.timeout 2 end ${data}`); }); -function myFunction3(callback: (err : Error, result : any) => void ) : void { +function myFunction3(callback: (err?: Error, result?: any) => void ) : void { console.log(`async.timeout 3`); - return callback(null, { bar: 'bar' }); + return callback(undefined, { bar: 'bar' }); } var wrapped3 = async.timeout(myFunction3, 1000, { bar: 'bar' }); diff --git a/async/tsconfig.json b/async/tsconfig.json index 851293fccf..5b8f42c6d2 100644 --- a/async/tsconfig.json +++ b/async/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +20,4 @@ "test/index.ts", "test/explicit.ts" ] -} \ No newline at end of file +} From 2cabef6efec4cff49b27d36542f25a3669945b0f Mon Sep 17 00:00:00 2001 From: joshuacaffey Date: Mon, 13 Mar 2017 14:35:37 -0500 Subject: [PATCH 054/150] Add middleware definition to aws-serverless-express (#15112) --- aws-serverless-express/aws-serverless-express-tests.ts | 5 +++-- aws-serverless-express/index.d.ts | 6 +++--- aws-serverless-express/middleware.d.ts | 8 ++++++++ aws-serverless-express/tsconfig.json | 3 ++- aws-serverless-express/tslint.json | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 aws-serverless-express/middleware.d.ts create mode 100644 aws-serverless-express/tslint.json diff --git a/aws-serverless-express/aws-serverless-express-tests.ts b/aws-serverless-express/aws-serverless-express-tests.ts index c46056ed25..97d236e043 100644 --- a/aws-serverless-express/aws-serverless-express-tests.ts +++ b/aws-serverless-express/aws-serverless-express-tests.ts @@ -1,9 +1,10 @@ -/// - import * as awsServerlessExpress from 'aws-serverless-express'; import * as express from 'express'; +import { eventContext } from 'aws-serverless-express/middleware'; const app = express(); +app.use(eventContext()); + const server = awsServerlessExpress.createServer(app, () => {}); const mockEvent = { diff --git a/aws-serverless-express/index.d.ts b/aws-serverless-express/index.d.ts index e4601e6ccd..db49e6ca6b 100644 --- a/aws-serverless-express/index.d.ts +++ b/aws-serverless-express/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for aws-serverless-express +// Type definitions for aws-serverless-express 2.1 // Project: https://github.com/awslabs/aws-serverless-express -// Definitions by: Ben Speakman +// Definitions by: Ben Speakman , Josh Caffey // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -16,4 +16,4 @@ export function proxy( server: http.Server, event: any, context: lambda.Context -): void; \ No newline at end of file +): void; diff --git a/aws-serverless-express/middleware.d.ts b/aws-serverless-express/middleware.d.ts new file mode 100644 index 0000000000..ff33b4c6ea --- /dev/null +++ b/aws-serverless-express/middleware.d.ts @@ -0,0 +1,8 @@ +import { RequestHandler } from 'express'; + +export interface Options { + reqPropKey?: string; + deleteHeaders?: boolean; +} + +export function eventContext(options?: Options): RequestHandler; diff --git a/aws-serverless-express/tsconfig.json b/aws-serverless-express/tsconfig.json index a62cead1a1..62885fcda3 100644 --- a/aws-serverless-express/tsconfig.json +++ b/aws-serverless-express/tsconfig.json @@ -17,6 +17,7 @@ }, "files": [ "index.d.ts", + "middleware.d.ts", "aws-serverless-express-tests.ts" ] -} \ No newline at end of file +} diff --git a/aws-serverless-express/tslint.json b/aws-serverless-express/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/aws-serverless-express/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From a217b4a320fa74afa68b6a59bd8ec496f5626ae9 Mon Sep 17 00:00:00 2001 From: Damiano Date: Mon, 13 Mar 2017 20:48:46 +0100 Subject: [PATCH 055/150] angular-ui-bootstrap rename IModalServiceInstance angular-ui-bootstrap IModalServiceInstance should be IModaInstanceService see #15142 --- angular-ui-bootstrap/index.d.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/angular-ui-bootstrap/index.d.ts b/angular-ui-bootstrap/index.d.ts index bc80d96b5a..1e4d15d282 100644 --- a/angular-ui-bootstrap/index.d.ts +++ b/angular-ui-bootstrap/index.d.ts @@ -15,6 +15,7 @@ export type IDropdownConfig = angular.ui.bootstrap.IDropdownConfig; export type IModalProvider = angular.ui.bootstrap.IModalProvider; export type IModalService = angular.ui.bootstrap.IModalService; export type IModalServiceInstance = angular.ui.bootstrap.IModalServiceInstance; +export type IModalInstanceService = angular.ui.bootstrap.IModalInstanceService; export type IModalScope = angular.ui.bootstrap.IModalScope; export type IModalSettings = angular.ui.bootstrap.IModalSettings; export type IModalStackService = angular.ui.bootstrap.IModalStackService; @@ -320,12 +321,12 @@ declare module 'angular' { interface IModalService { /** * @param {IModalSettings} options - * @returns {IModalServiceInstance} + * @returns {IModalInstanceService} */ - open(options: IModalSettings): IModalServiceInstance; + open(options: IModalSettings): IModalInstanceService; } - interface IModalServiceInstance { + interface IModalInstanceService { /** * A method that can be used to close a modal, passing a result. If `preventDefault` is called on the `modal.closing` event then the modal will remain open. */ @@ -357,6 +358,11 @@ declare module 'angular' { closed: angular.IPromise; } + /** + * @deprecated use IModalInstanceService instead. + */ + interface IModalServiceInstance extends IModalInstanceService { } + interface IModalScope extends angular.IScope { /** * Dismiss the dialog without assigning a value to the promise output. If `preventDefault` is called on the `modal.closing` event then the modal will remain open. @@ -512,17 +518,17 @@ declare module 'angular' { /** * Opens a new modal instance. */ - open(modalInstance: IModalServiceInstance, modal: any): void; + open(modalInstance: IModalInstanceService, modal: any): void; /** * Closes a modal instance with an optional result. */ - close(modalInstance: IModalServiceInstance, result?: any): void; + close(modalInstance: IModalInstanceService, result?: any): void; /** * Dismisses a modal instance with an optional reason. */ - dismiss(modalInstance: IModalServiceInstance, reason?: any): void; + dismiss(modalInstance: IModalInstanceService, reason?: any): void; /** * Dismiss all open modal instances with an optional reason that will be passed to each instance. @@ -536,7 +542,7 @@ declare module 'angular' { } interface IModalStackedMapKeyValuePair { - key: IModalServiceInstance; + key: IModalInstanceService; value: any; } From 4bdfa8fd6d27ed5a38d9aeb8714acc733fc2625c Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Tue, 14 Mar 2017 08:33:15 +0100 Subject: [PATCH 056/150] Add comments to tests for generic version of jasmine.objectContaining --- jasmine/index.d.ts | 2 +- jasmine/jasmine-tests.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index cb19aa7cd8..f75a9f2127 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -24,9 +24,9 @@ declare function afterEach(action: (done: DoneFn) => void, timeout?: number): vo declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void; declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void; +declare function expect(spy: Function): jasmine.Matchers; declare function expect>(actual: ArrayLike): jasmine.ArrayLikeMatchers; declare function expect(actual: T): jasmine.Matchers; -declare function expect(spy: Function): jasmine.Matchers; declare function fail(e?: any): void; /** Action method that should be called when the async work is complete */ diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index e80060510b..1c9d5366e1 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -679,12 +679,19 @@ describe("jasmine.objectContaining", () => { }); it("matches objects with the expect key/value pairs", () => { - expect(foo).toEqual(jasmine.objectContaining({ - bar: '' + // not explictly providing the type on objectContaining only guards against + // missmatching types on know properties + expect(foo).not.toEqual(jasmine.objectContaining({ + a: 37, + foo: 2, // <-- this does not cause an error as the compiler cannot infer the type completely + // b: '123', <-- this would cause an error as `b` defined as number in fooType })); - expect(foo).not.toEqual(jasmine.objectContaining({ - a: 37 + // explictly providing the type on objectContaining makes the guard more precise + // as misspelled properties are detected as well + expect(foo).not.toEqual(jasmine.objectContaining({ + bar: '', + // foo: 1, <-- this would cause an error as `foo` is not defined in fooType })); }); From 9ad681855ff9b53e76e5057db01b8197ad458b73 Mon Sep 17 00:00:00 2001 From: Geert Jansen Date: Tue, 14 Mar 2017 11:59:33 +0100 Subject: [PATCH 057/150] Update to IBottomSheetOptions Adds missing bindToController property on interface IBottomSheetOptions. --- angular-material/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-material/index.d.ts b/angular-material/index.d.ts index 0e27fe3b60..64441a96be 100644 --- a/angular-material/index.d.ts +++ b/angular-material/index.d.ts @@ -18,6 +18,7 @@ declare module 'angular' { controller?: string | Function; locals?: { [index: string]: any }; clickOutsideToClose?: boolean; + bindToController?: boolean; // default: false disableBackdrop?: boolean; escapeToClose?: boolean; resolve?: { [index: string]: () => angular.IPromise }; From d0ed29f8a20a386bc82b075efda68e549efb316c Mon Sep 17 00:00:00 2001 From: use-strict Date: Tue, 14 Mar 2017 15:03:47 +0200 Subject: [PATCH 058/150] http-errors: Add missing constructor Allows the following to work: ```typescript import { HttpError } from "http-errors"; let error: HttpError; console.log(error instanceof HttpError); ``` --- http-errors/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/http-errors/index.d.ts b/http-errors/index.d.ts index 176703f23f..aff5b312dd 100644 --- a/http-errors/index.d.ts +++ b/http-errors/index.d.ts @@ -23,6 +23,8 @@ declare module 'http-errors' { [code: string]: new (msg?: string) => HttpError; (...args: Array): HttpError; + + HttpError: HttpErrorConstructor; Continue: HttpErrorConstructor; SwitchingProtocols: HttpErrorConstructor; From 12f7d2809dfa8e5da27c281a521a91f2acdc1c39 Mon Sep 17 00:00:00 2001 From: Alexander Abashkin Date: Tue, 14 Mar 2017 17:00:06 +0300 Subject: [PATCH 059/150] Added module declaration --- platform/index.d.ts | 23 ++++++++++++----------- platform/platform-tests.ts | 8 +++----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/platform/index.d.ts b/platform/index.d.ts index c02615b932..ad6100c707 100644 --- a/platform/index.d.ts +++ b/platform/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface PlatformStatic { +interface Platform { description?: string; layout?: string; manufacturer?: string; @@ -13,18 +13,19 @@ interface PlatformStatic { product?: string; ua?: string; version?: string; - os?: PlatformOS; - parse?(ua: string): PlatformStatic; + os?: { + architecture?: number; + family?: string; + version?: string; + toString(): string; + }; + parse?(ua: string): Platform; toString?(): string; } -interface PlatformOS { - architecture?: number; //platform's docs say this is a string, but their code doesn't agree - family?: string; - version?: string; - toString(): string; +declare var platform: Platform; + +declare module "platform" { + export = platform; } -declare var platform: PlatformStatic; - - diff --git a/platform/platform-tests.ts b/platform/platform-tests.ts index ce24ada335..572e85830c 100644 --- a/platform/platform-tests.ts +++ b/platform/platform-tests.ts @@ -1,7 +1,5 @@ - - interface ITestContainer { - [name: string]: PlatformStatic; + [name: string]: Platform; } @@ -40,8 +38,8 @@ var tests: ITestContainer = { function runTests() { - var t: PlatformStatic; - var p: PlatformStatic; + var t: Platform; + var p: Platform; var x: string; var px: any; var res: boolean; From adcadc8b7cb1a3d69a00925b68ed88a2c77a7ae2 Mon Sep 17 00:00:00 2001 From: NomiBernard Date: Tue, 14 Mar 2017 15:35:33 +0100 Subject: [PATCH 060/150] fix transaction callback return type return bluebird instead of T --- bookshelf/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookshelf/index.d.ts b/bookshelf/index.d.ts index 4aa6fd38b5..c7947579c8 100644 --- a/bookshelf/index.d.ts +++ b/bookshelf/index.d.ts @@ -17,7 +17,7 @@ interface Bookshelf extends Bookshelf.Events { Collection: typeof Bookshelf.Collection; plugin(name: string | string[] | Function, options?: any): Bookshelf; - transaction(callback: (transaction: knex.Transaction) => T): BlueBird; + transaction(callback: (transaction: knex.Transaction) => BlueBird): BlueBird; } declare function Bookshelf(knex: knex): Bookshelf; From dda288d3f6f1995d667cd05cc39fbe0af1f9596c Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 14 Mar 2017 15:37:32 +0100 Subject: [PATCH 061/150] async: fixed the types of async.transform --- async/index.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/async/index.d.ts b/async/index.d.ts index a17735eb6e..62e047b209 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -202,10 +202,11 @@ interface Async { timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; - transform(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void; - transform(arr: T[], acc: R[], iteratee: (acc: R[] | null, item: T | undefined[], key?: string, callback?: (error?: E) => void) => void): void; - transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; - transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; + transform(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; + transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; + + transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; + transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; From 264c29142589d25f87f2d3e4144c0426f1ba4c63 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Mar 2017 07:43:39 -0700 Subject: [PATCH 062/150] Remove more unnecessary references in test files (#15167) --- gapi.calendar/gapi.calendar-tests.ts | Bin 4385 -> 9070 bytes gapi/gapi-tests.ts | Bin 2877 -> 5944 bytes .../jquery-toastmessage-plugin-tests.ts | 3 --- .../knuddels-userapps-api-tests.ts | 2 -- nanoscroller/nanoscroller-tests.ts | 2 -- .../protractor-helpers-tests.ts | 2 -- 6 files changed, 9 deletions(-) diff --git a/gapi.calendar/gapi.calendar-tests.ts b/gapi.calendar/gapi.calendar-tests.ts index de335c6a1552bb34fce8383919b79bdd06aa64bb..909e503846a038e58a583b4e930fcdeb0868b805 100644 GIT binary patch literal 9070 zcmc(kYi}Dx6o%(B68~WV2|JY9X}Jel5z;_|3V~ieK&h%Uw;B>V*iKuh^4Ed)nX|_; zv%5}OT7fLzc4yA@J-6Av{~Ct(LKQZ{v#=A6!$~*_`}#lEzu)w0tltM=8Ya3|g>Upd z35WHX4Xt7IIPB@yRQK1z4`EB+-|GJpz3+rwT_1_+TvvY#r~17sy0b`s8m~Uq=Ugjh zVJ!^x+7rbmdLN0?iN2@0GZ4?jc_13dGc2xN7Qd57XQ=z7WW(@#2k&9{RkSPVKMZe% zH{$zw{H$~pS*q}pIGsk_HYCv~YKtyg;f6lpgM}XHdZktS(gb}?gFRhKw)BS=^YA!Q$!&~ONtPQm-DH_6Y>3iWT1=uR-q-4;J+W0Ae}g4|l`E+5*>fy%)Zaowmcha9h{gtFCLs=L-v?k5jy()!V|%rjSwvXx$HQw={Sf zc$FBy*Q1CG$HI>Mgbmx?A4JdWNOLT46#fv82Mvjcg7+4_2NURvN5CsSI?(5C!~%XE zN6(!~0uYMTcOsTtiixg{!k@Ye3XltFE3E>fAPMZu^^Ht}g0rC!I~|DMIHJVXA%V-Z zUhCTrD_WUw%f7?NXC%5VPx_T4>t|fq)udwA@b7Mh{fClyPuJG8zU}MxTQs54lkWJ5 zc($Fn=Ld>~iKvc4Uw2u(5|+^!DejM>RY%c&PLH@d)pf_L%YG(G<{h#W*~;y9Tfb-8 zb0jaU)M#MWS)}1~x^Qt*oSm9Q{Y;u!l#vHg%)9m7=E>ugc!L}=-L&C<=WQtbQnZOb zvNImqR<`lnai%NIBiDyaY|+rg8T`8DFOEDA?pizboM*pN5>S$7v~_7Sk`7Mcs&dJs zt~9x3ZA^R4aD82~eP!a2>}dIe7$-`>2r)|5AS-W1-}}|ClmoVe2k_RWcUgC!2oB%M zkO4X@4|MBVg?II;w8v@Y_8CM^lli9|5esdrI5)+E8kjs=DYI@x99xZ`;!p#~Xk>)E zF7f+OM9Wk<=H9i4aLJn18we3|?I1#^5o9a!)Q+y1WqYzG7$@Q^n;S*@ba|RRf%%&p zRqg?~)OezxEAN;s?kL+$l>57EL4}9wQ^`7(mo3XeEoJ4o?pu8wNjuLNiJDs>kIP5W zI7OgoXVRFZsRz!nZB2RsA`i}GUVnA_!xjH_`M|OkJTA^(TcXfy4|12;)VmVP6?t|u znM>4Kd_PtG!=kcJ?T+T5a8zMSt?7cX`;TU01uZ+eWlDH2dP} zoXKe4$-8EOBwssY{rf7M$F$YkW!08C;+2&(d0nOQwd*CT4iwiGd(_8dBg1HyE%Hp( zjAbw~mp!KPOinvR{Kc5OC5u`<%c}()M%l@`ryT{&d{?PQC3n$RpDKe{cj)n&yg19W zrq?4{cVjNfZBL%f^C|YEi}P$pcbDhb^D*YTnmVN%+029qLAg|e1%K)nePlj`^k)JR2)(`SEHpR+5x6o10o6)OKGpt(xpUjdr>oF(JBU-@a zzABzy!2@*IPK_M*O#irouc;Oufp`G!3AcFAceZmfRnqenohTS8Z8p%gt;nAm*W`ut z*4GjB^gyOv$=^DA>O1pYsx|02(`zSoB90(ig9Tp}Ll^t9Ya;OO2~C)VkqPTEb1g$z z+e*0)K%vRfZ%iL#kv1;rx2*T?)fRHBfYM}3%RxO!XBhb|`r3B(W&Qow58SAcgsv-! zL8{W0vfsAeHiOd>aJP&0tnMqAsEHl(g7HYXv3sZG5_aYBV|#rH>Dr05&om*Y-g{Qt z<4RcVl#=d*PH-CNSKW3gp6=Eb>J`>ITf}m1)6(w)QGKR2oie)jTNSY%F;5TJu4{P6 z@suON&;%#;4I~}3kM%EA0`o5M!yHUx?`i&L54o(Fp~^^H(+aOWxo*((zC4!)gu>xa zay-_W>w2#)(FYm_!Vt53zs3YqO{Z09VE?|*_i`S#>QcCL4wr808K0c;eR20w3b$JR z?H+g;V(e4-G`Q^_u=utRN=dE02vxpI!b zFW<4ttqQjBSij-#O8JlI`$ZH}#&$HDcAQ713cyM0NGRk)rdux0`w8o*OMRIq7|qjh z$z zZ`7L++x_&V>j{X>J)Do)DT_r35;4!6NCM9SXz)bx(%+63xniv$(|=>#E=}xNj%N$A z5U64b;RG;glICT%TTkoCXHc*D#DU7=^A8B~9@DO-^Cgp$tU%{s`N$%TU7&B%hLX%a9Q^MRM~Y^7FpBhYW>OGPwL-I{zf0WP;GvWzVT-wJz1Bl z*bd(fbv81Q77umZq5@nph2%DGo(T1{hA#beX?JCzi|P1(Ye(GW&-LgFOxOE`UCh$A zHNoAJ9XI8Vul0LVPqnY<3B&T0-KIr$c18FZIsr$3R-~l)R_TsKhLqbW@wfX9rZJ^Qh%$X={W%k0qmN z#MArb$gxwI8`{CtZO`It_4!lyB-ZR{M7Cv!Wgc@~i34gG(QIo=Ym$w6wcIunyWCfm zo$N{6$BM%)Tb{>*lXH5p6H#BzgY4IyIvy1GOZU&}dD{Kp9UYc`U1vLaXVN_1d6l!B zo_q$%$;4A3)MG8pa;{aHZ~RKB-;11KB&zLhJMTZ!3B+bS!%!vio_A02ZWATFZK6Af Vy~DBMkaOp;o)wgxs{b?Z{R2avS2_Ry literal 4385 zcmbtX+j84R5`EWKw6j$KBufCLB)bV6r6N;G%#>m|x;!|J%QXUq097D^{GI!_(3E`0VBNJD5MF=@E(Z#E? zE6BY0Bt+o;{=Rcv)T(jri`LG1zY`-xuB&44$y=u;-P?mQ+N04-W_P3}l(ojN?`~=Nrj^~{C1NkCypW9Q zQZ{X2cc0~TsJsPY zW9+Lx3bio1C0q}Y#ca~67o8HtEw(>B$O0B8|}|7<29MLgmt#q?_?R*L_8W7CHI+ zQK4>)Fbn4?wD&fFEotnckV&qZx)2Ml>`GS>)yy!+X$h?kmt&VBWQk;fbof$o2(D)O zeuY33g}ztS)U}|iS*y{J%5ov}_I(y^7o9D%Iq+t8e6EK`x2?5ZO#@H=d@FQS6{-in zgxbw&8m|MO2_P~{^u+~;4(j6|y3Pzmb~Z;U5f1)C&mC6pg@5#DagEs9*c~0xj~d3E zwvgG!TGS^Njk(^J8O`zLudaAJ%u5RnTc`K=Um7$6h?=f_ljQ9!Fnb zbgmkZR1JdXEIQX3PVXM+Dw7ZDk-%GArZV3WCVsI|dF#aG%_b}pM`3zI`xMPT!)E~y zHys8S(Pj&^yfO+I;}OxcWr^+}a1Hs%m7_|nDrL%FNKc$tB|ktOo#nkk>3GLjMPHV= zE1{^tg!1z-q49(&9S#Wt64Na#iS9Uv+vwW3#wcaeh^geb;7Mh-2j&mn^`y?kW8|-` zL=uiY#dneF;dt-~hbRv1+edKBJRiX{$0G{W5^*SgR2AOEmAt1@1SQ_xO{^YYU0h)T zSJSv>{HOsDoXSE1JPx>8>J>E*EqswT-8ksqmEwbESblRj=$~toOY?kzhmlLpHNZrU zF_y@x`_j3b$PY4Wfh~-^m|Ht^lb_*T?v7p8C(6pQ2~>wfV550uWE_R!>9RJAf+f$) zA%?P=+8KRAgOv@;Tx}?Z`=pS9!882%x>J*&B5(kYo<3bav4#vsyz(~+n*bBA|KY^m zGpl#+!P?lc5-v}U$GRwwjwdX;X@dUj{Q6m@%Cld5((m(^SuUGYLSL<+G({2x$PHgN6mT1J?WU}85Pc*$j} zQBeKA_W8)olH9Q%zVd4<>s*{klvoLzByLfB-Ms$=1Fg?IYF6iMW}77Fb7TZf9y`znUSjQx`C#zH z!O@r3gRh2z0e%k#|H9|yeEFHTP6ks-gL_PRuA6r!$Uq^Rj_o_};OM_#>X0q`T~h|* zgs)v0BYWdw2j?y?Z_dw#-(8;lbbNX;K7ajebaC_Y`uNDheA~ek79E;PpkE#R7|Bwo zg54}?%=vG-KHv*s)GudiQq3*+VpGbY2u6&=nuYPmM*84mjXaeTftwAUZq8qgo07p* zVI36idr>KIEpoHp1H>W)#Tcb5c=S0q^Phtr-{yf@*KN(4*XqFGAdG>x4lVz;?61dv zZ9nlu(QPP??k5q3JnsE2M~-FKnxEHyx)(UPK*KAZj?UZ`@2M1XeMy5@@f>E1Y{YKdn@*hVoLmOu+F}3cO8Z zAKX@0Rmz(3v4a&SxDN52GEDI%gA4_Jd&+qRDY-YF%e9Q>L&!(@D_Pd@bL<=9nqk!o zj81TsSU1JG30CEJs&qv>UdC$jx`Y*!h1aS6Cz#!Zyu`Qyl>(!rMrB0?@(pIfYVI&C ztwMrCHn8JB_YRfE*Wj4C+SmKtIhR{CE|W;Iq#;?h;EN{(E!WY=aH5?$XmG|oDbA#2 z+ye(QJgw>66Zutsmq+qUewK&e`WfD@%M-l65}jxicCeqw7OFKOejDR$%o)9>xHol7 zy}BL7x;1{Nao6$J(mo-F9%ef+^*EyJgLIL>>An6Ev#hN{XC1)x%sSjFq-(~5P+Hk*$ zy?xg18aRSkh2x%yL8@(`dR(osqwxafS zAEyu1yFW%m4bhYslkNasQjaL~nK=GC-)E}(^Jk9L&oXm-iP4@Xcu!&d^lrwN&m~5C z2DM1v7mrh5GSpn;xO_-8aUv_oQe9Cz&VbYjqjo)~e~IE_L|V&KmRUZ%D89PLJ|T+J z26A)+|NowbeIR{>)e*glmTr9(Ygf+1olVGc^~`2EW^Efhv+aeXZT(-4%D?GVmK|*u zJFz32ZT@?TyU}K^;68m9v2P!BM+&d|P(QQG@(WI7wa-e)tGZAjQKx5`!7ow=bx{s= zjM4NefKPq+)@uq!(Geq-DXj1!^>^PnPCM@WGqnZwJ=?&Xakon&)I`ihvqnwub>TX& zJ;lYfR-=Ux5n$gv#d}6vcJiz(?_gZ%*_Z!FZ?Eu$kRoSM~aNhriaJieugL3 zd$ez^rOsz^1EX7*9pRLh7&kM<9@cZ$u{;OP-f2F-EWZ#G%I7Xtjcb!l0`oRJZ>MxbQ zfL;ANL9l}nqR|>wa2*l&7@ZMmIZp0@R=Zd~KOHc543=$J(~$9@@?q z9*g?2MZD9kuRmu5D>O+Nt48?dNT25yn-Q#|?R9Q>rh_50^$06VSX69-mN(h|)6;zo zqZjjNuscU7j(X?!%~)z`(lg?}ffvu~`@-W$y&o>I&vv8K)DE)*qwl*>cRhrNA9HE> NVGCBk2ygbm|F^fEt8oAT literal 2877 zcmd^B+m6#P5Pk1gj1W><=*Dyr5-Kc+OA+NREhQtoGQz)x`84r9Czrc7B zr(L#OBm^(Kv{CGtIdeNFUq62lLcmpvbF`>41iz}#9h_OnN~IN=s=zZKuJwL)tEe5{ z>4|eN`6x@Wap2`U)G)WEgxveejfI%u5(`tIb?L&GMS*E%NU^KyE7pX%S2n(v$_LImp`Qpd4u9 z!Q%T`S)4T~5SD1)p?x{Id3fu=bn@u=;q-PYt14E#c4#xBJykrQ+N8r#gMDSqTou@! ztOqGoQTJobyJB;>FPEmf=-Zt4$Y?M!Vmd?ZT@ zxOg5#iAmdm_23FWoq|Y)mC+94TmVqU&d|seX3>wQDLvGMk4}c&SkVpXjNWaXOsqAQ z;J|qT81A)xQVa)aiO$IdMz8$84mhdHqZA$(Is5fka)k=I+HX6X4BJ^Jf9qXKu;2CN zpDw}wJi1{CX}CMWpf#+d&%+A+oCua9v6!mTsT z<|^|?FOb>^qzw%OZ~@YClIQA~I9-PU_WlxRqn}t`q!)@_Bv4()Unh);Kfw;yHa_ zG-@oAbF@EVbm8*FOTphfL>q5dxN|%N%?jYWReBL=c{|~*n_&TI|4#R^Y32Bs`#5HY zr<=GHG1ewV1J1LhdMa-1@;?v~ZgoFoMJ@dx8&T){aW5vTGwa3J|YqR1}zw-@Bjb+ diff --git a/jquery-toastmessage-plugin/jquery-toastmessage-plugin-tests.ts b/jquery-toastmessage-plugin/jquery-toastmessage-plugin-tests.ts index d1feba15ce..f11813cfbb 100644 --- a/jquery-toastmessage-plugin/jquery-toastmessage-plugin-tests.ts +++ b/jquery-toastmessage-plugin/jquery-toastmessage-plugin-tests.ts @@ -1,6 +1,3 @@ -/// - - /* code examples from documentation */ $().toastmessage('showNoticeToast', 'some message here'); diff --git a/knuddels-userapps-api/knuddels-userapps-api-tests.ts b/knuddels-userapps-api/knuddels-userapps-api-tests.ts index 1faaa193e5..a940b7f19b 100644 --- a/knuddels-userapps-api/knuddels-userapps-api-tests.ts +++ b/knuddels-userapps-api/knuddels-userapps-api-tests.ts @@ -1,5 +1,3 @@ -/// - class Server implements App { private usersPlaying: { [nick: string]: number } = {}; diff --git a/nanoscroller/nanoscroller-tests.ts b/nanoscroller/nanoscroller-tests.ts index 3b9eeea820..46e61c1aaf 100644 --- a/nanoscroller/nanoscroller-tests.ts +++ b/nanoscroller/nanoscroller-tests.ts @@ -1,5 +1,3 @@ -/// - $('.nano').nanoScroller(); $('.nano').nanoScroller({ diff --git a/protractor-helpers/protractor-helpers-tests.ts b/protractor-helpers/protractor-helpers-tests.ts index 9b03e43005..543991392b 100644 --- a/protractor-helpers/protractor-helpers-tests.ts +++ b/protractor-helpers/protractor-helpers-tests.ts @@ -1,5 +1,3 @@ -/// - import helpers = require('protractor-helpers'); declare var $$: any, $: any, by: any, element: any; // ?? From 04fed0d7022ff5e02089e8f8fdcded8963281cad Mon Sep 17 00:00:00 2001 From: Balazs Erdos Date: Tue, 14 Mar 2017 15:48:45 +0100 Subject: [PATCH 063/150] Add missing parameter. --- riot/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/riot/index.d.ts b/riot/index.d.ts index 3abb3fa147..3c76a0b1d0 100644 --- a/riot/index.d.ts +++ b/riot/index.d.ts @@ -205,8 +205,9 @@ declare namespace riot { * Register a shared mixin, globally available to be used in any tag using `TagInstance.mixin(mixinName)` * @param mixinName Name of the mixin * @param mixinObject Mixin object + * @param isGlobal Is global mixin? */ - function mixin(mixinName: string, mixinObject: TagMixin): void; + function mixin(mixinName: string, mixinObject: TagMixin, isGlobal?: boolean): void; /** * Create a new custom tag “manually” without the compiler. Returns name of the tag. From 023bcf3e7ae33cac5fc278cfd415683d4297f5a6 Mon Sep 17 00:00:00 2001 From: Alexander Abashkin Date: Tue, 14 Mar 2017 17:55:00 +0300 Subject: [PATCH 064/150] =?UTF-8?q?Platform=20=E2=80=94=20Fixed=20declarat?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/index.d.ts | 9 ++++----- platform/platform-tests.ts | 34 ++++++++++++++-------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/platform/index.d.ts b/platform/index.d.ts index ad6100c707..eed60394f4 100644 --- a/platform/index.d.ts +++ b/platform/index.d.ts @@ -1,10 +1,9 @@ -// Type definitions for Platform 1.0.0 +// Type definitions for Platform 1.3 // Project: https://github.com/bestiejs/platform.js // Definitions by: Jake Hickman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface Platform { +declare interface Platform { description?: string; layout?: string; manufacturer?: string; @@ -23,9 +22,9 @@ interface Platform { toString?(): string; } -declare var platform: Platform; - declare module "platform" { + declare var platform: Platform; + export = platform; } diff --git a/platform/platform-tests.ts b/platform/platform-tests.ts index 572e85830c..65433ffb13 100644 --- a/platform/platform-tests.ts +++ b/platform/platform-tests.ts @@ -1,9 +1,8 @@ -interface ITestContainer { +interface TestContainer { [name: string]: Platform; } - -var tests: ITestContainer = { +var tests: TestContainer = { 'Chrome Mobile 16.0.912.77 on Android 4.0.3': { description: "Chrome Mobile 16.0.912.77 on Android 4.0.3", layout: "WebKit", @@ -45,34 +44,29 @@ function runTests() { var res: boolean; var onFalse: (name: string) => () => any; - for (var n in tests) { - + for (const [n, value] of Object.entries(tests)) { t = tests[n]; p = platform.parse(t.ua); - onFalse = (name: string) => { return () => { console.log('\tfailed on prop "' + name + '" for "' + n + '"'); - } - } + }; + }; console.log('Starting tests for: ' + n); - falsy(() => { return t.description === p.description }, onFalse('description')); - falsy(() => { return t.layout === p.layout }, onFalse('layout')); - falsy(() => { return t.name === p.name }, onFalse('name')); - falsy(() => { return t.prerelease === p.prerelease }, onFalse('prerelease')); - falsy(() => { return t.ua === p.ua }, onFalse('ua')); - falsy(() => { return t.version === p.version }, onFalse('version')); - - falsy(() => { return t.os.architecture === p.os.architecture }, onFalse('os.architecture')); - falsy(() => { return t.os.family === p.os.family }, onFalse('os.family')); - falsy(() => { return t.os.version === p.os.version }, onFalse('os.version')); + falsy(() => t.description === p.description, onFalse('description')); + falsy(() => t.layout === p.layout, onFalse('layout')); + falsy(() => t.name === p.name, onFalse('name')); + falsy(() => t.prerelease === p.prerelease, onFalse('prerelease')); + falsy(() => t.ua === p.ua, onFalse('ua')); + falsy(() => t.version === p.version, onFalse('version')); + falsy(() => t.os.architecture === p.os.architecture, onFalse('os.architecture')); + falsy(() => t.os.family === p.os.family, onFalse('os.family')); + falsy(() => t.os.version === p.os.version, onFalse('os.version')); console.log('Finished tests for: ' + n); - - } } From bb8dfc6c4744926ef38245fb85cb6186f1100b49 Mon Sep 17 00:00:00 2001 From: Alexander Abashkin Date: Tue, 14 Mar 2017 18:01:18 +0300 Subject: [PATCH 065/150] =?UTF-8?q?Platform=20=E2=80=94=20Fixed=20declarat?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/index.d.ts | 4 ++-- platform/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/index.d.ts b/platform/index.d.ts index eed60394f4..fd995a085e 100644 --- a/platform/index.d.ts +++ b/platform/index.d.ts @@ -22,9 +22,9 @@ declare interface Platform { toString?(): string; } -declare module "platform" { - declare var platform: Platform; +declare var platform: Platform; +declare module "platform" { export = platform; } diff --git a/platform/tsconfig.json b/platform/tsconfig.json index c7a29f12be..2efb10866a 100644 --- a/platform/tsconfig.json +++ b/platform/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", + "es2017", "dom" ], "noImplicitAny": true, From 5141daceb0a11f126a035ccc6e7044530bb2c3c1 Mon Sep 17 00:00:00 2001 From: use-strict Date: Tue, 14 Mar 2017 17:15:43 +0200 Subject: [PATCH 066/150] Update http-errors-tests.ts --- http-errors/http-errors-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/http-errors/http-errors-tests.ts b/http-errors/http-errors-tests.ts index e8c12126b4..51017828a1 100644 --- a/http-errors/http-errors-tests.ts +++ b/http-errors/http-errors-tests.ts @@ -83,3 +83,4 @@ var err = new createError.MisdirectedRequest(); var err = new createError.MisdirectedRequest('Where should this go?'); let error: createError.HttpError; +console.log(error instanceof createError.HttpError); From 3c2d2dd01970440b2b6e268183214c7a75b2c76b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 14 Mar 2017 11:43:53 -0700 Subject: [PATCH 067/150] Fix transform argument type, and add deprecated method documentation. (#15158) --- typeahead/index.d.ts | 15 +++++++++++++-- typeahead/typeahead-tests.ts | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/typeahead/index.d.ts b/typeahead/index.d.ts index 95100bbbba..d6ed81a921 100644 --- a/typeahead/index.d.ts +++ b/typeahead/index.d.ts @@ -1015,7 +1015,7 @@ declare namespace Bloodhound { * @param response Prefetch response. * @returns Transform response. */ - transform?: (response: T[]) => T[]; + transform?: (response: T) => T; } /** @@ -1069,7 +1069,13 @@ declare namespace Bloodhound { * @param response Prefetch response. * @returns Transform response. */ - transform?: (response: T[]) => T[]; + transform?: (response: T) => T; + + /** + * DEPRECATED: transform the remote response before the Bloodhound instance operates on it. + * */ + filter?: (response: T) => T; + } /** @@ -1200,6 +1206,11 @@ declare class Bloodhound { * clearRemoteCache offers a way to programmatically clear said cache. */ public clearRemoteCache(): Bloodhound; + + /* + * DEPRECATED: wraps the suggestion engine in an adapter that is compatible with the typeahead jQuery plugin + */ + public ttAdapter(): any; } declare module "bloodhound" { diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 61d48b6aa9..d298508e11 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -374,7 +374,7 @@ function test_bloodhout() { } function test_bloodhout_prefetch_options_transform() { - var options: Bloodhound.PrefetchOptions = { + var options: Bloodhound.PrefetchOptions = { url: 'url', transform: (response: string[]) => { return new Array(); } }; @@ -383,7 +383,7 @@ function test_bloodhout() { function test_bloodhout_prefetch_options_all() { var ajaxSettings: JQueryAjaxSettings = { url: 'url' }; - var options: Bloodhound.PrefetchOptions = { + var options: Bloodhound.PrefetchOptions = { url: 'url', cache: true, ttl: 86400000, @@ -433,7 +433,7 @@ function test_bloodhout() { } function test_bloodhout_remote_options_transform() { - var options: Bloodhound.RemoteOptions = { + var options: Bloodhound.RemoteOptions = { url: 'url', transform: (response: string[]) => { return new Array(); } }; @@ -442,7 +442,7 @@ function test_bloodhout() { function test_bloodhout_remote_options_all() { var ajaxSettings: JQueryAjaxSettings = { url: 'url' }; - var options: Bloodhound.RemoteOptions = { + var options: Bloodhound.RemoteOptions = { url: 'url', prepare: (query: string, settings: JQueryAjaxSettings) => { return ajaxSettings; }, wildcard: '%QUERY', From 28924690db8c6e9845ca8eb9855abc2ec3a4933b Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Mar 2017 12:12:20 -0700 Subject: [PATCH 068/150] Remove unnecessary references to "q" (#15172) --- cordova-plugin-app-version/index.d.ts | 11 ++++------- pathwatcher/index.d.ts | 9 +++------ q/index.d.ts | 5 +---- text-buffer/index.d.ts | 5 ++--- webdriverio/index.d.ts | 11 +++++++---- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/cordova-plugin-app-version/index.d.ts b/cordova-plugin-app-version/index.d.ts index e295724474..b30beef9c6 100644 --- a/cordova-plugin-app-version/index.d.ts +++ b/cordova-plugin-app-version/index.d.ts @@ -3,14 +3,11 @@ // Definitions by: Markus Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// -/// - interface Cordova { getAppVersion: { - getAppName: () => Q.IPromise & JQueryPromise; - getPackageName: () => Q.IPromise & JQueryPromise; - getVersionCode: () => Q.IPromise & JQueryPromise; - getVersionNumber: () => Q.IPromise & JQueryPromise; + getAppName: () => Promise; + getPackageName: () => Promise; + getVersionCode: () => Promise; + getVersionNumber: () => Promise; }; } diff --git a/pathwatcher/index.d.ts b/pathwatcher/index.d.ts index 0a44ee596b..61f084b6ca 100644 --- a/pathwatcher/index.d.ts +++ b/pathwatcher/index.d.ts @@ -4,8 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// +import { EventEmitter } from "events"; import * as Q from "q"; export as namespace PathWatcher; @@ -28,7 +28,7 @@ export interface IFile { getBaseName():string; write(text:string):void; readSync(flushCache:boolean):string; - read(flushCache?:boolean):Q.Promise; + read(flushCache?:boolean): Promise; // exists():boolean; existsSync():boolean; setDigest(contents:string):void; @@ -62,10 +62,7 @@ export interface IDirectory { isPathPrefixOf(prefix:string, fullPath:string):boolean; } - -import events = require("events"); - -export interface IHandleWatcher extends events.EventEmitter { +export interface IHandleWatcher extends EventEmitter { onEvent(event:any, filePath:any, oldFilePath:any):any; start():void; closeIfNoListener():void; diff --git a/q/index.d.ts b/q/index.d.ts index c6f2a068a7..6b2deb3161 100644 --- a/q/index.d.ts +++ b/q/index.d.ts @@ -168,10 +168,7 @@ declare namespace Q { } interface PromiseState { - /** - * "fulfilled", "rejected", "pending" - */ - state: string; + state: "fulfilled" | "rejected" | "pending"; value?: T; reason?: any; } diff --git a/text-buffer/index.d.ts b/text-buffer/index.d.ts index 60207c7e80..a3d652bd28 100644 --- a/text-buffer/index.d.ts +++ b/text-buffer/index.d.ts @@ -5,7 +5,6 @@ /// /// -/// declare namespace TextBuffer { @@ -240,7 +239,7 @@ declare namespace TextBuffer { positionForCharacterIndex(offset:number):IPoint; getMaxCharacterIndex():number; loadSync():ITextBuffer; - load():Q.IPromise; + load():Promise; finishLoading():ITextBuffer; handleTextChange(event:any):any; destroy():any; @@ -253,7 +252,7 @@ declare namespace TextBuffer { hasMultipleEditors():boolean; reload():any; updateCachedDiskContentsSync():string; - updateCachedDiskContents():Q.IPromise; + updateCachedDiskContents():Promise; getBaseName():string; getPath():string; getUri():string; diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index f091159263..e74b4712a5 100644 --- a/webdriverio/index.d.ts +++ b/webdriverio/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// declare namespace WebdriverIO { export type Method = 'POST' | 'GET' | 'DELETE'; @@ -506,7 +505,11 @@ declare namespace WebdriverIO { onRejected?: (error: any) => P | Client

): Client

; - inspect(): Q.PromiseState; + inspect(): { + state: "fulfilled" | "rejected" | "pending"; + value?: T; + reason?: any; + }; } export interface Client { @@ -1815,14 +1818,14 @@ declare namespace WebdriverIO { ): Client

; waitUntil( - condition: () => boolean | Q.IPromise | Client> & RawResult, + condition: () => boolean | Promise | Client> & RawResult, timeout?: number, timeoutMsg?: string, interval?: number ): Client & any; waitUntil

( - condition: () => boolean | Q.IPromise | Client> & RawResult, + condition: () => boolean | Promise | Client> & RawResult, timeout?: number, timeoutMsg?: string, interval?: number From 21a11ab7d96f315cbbcf8e3e7bdfbdd3c91cfe36 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Mar 2017 12:12:30 -0700 Subject: [PATCH 069/150] nedb: Lint (#15173) --- nedb/index.d.ts | 156 ++++++++++--------- nedb/nedb-tests.ts | 371 ++++++++++++++++++++------------------------- nedb/tslint.json | 3 + 3 files changed, 250 insertions(+), 280 deletions(-) create mode 100644 nedb/tslint.json diff --git a/nedb/index.d.ts b/nedb/index.d.ts index 23519d3579..790f3f6d06 100644 --- a/nedb/index.d.ts +++ b/nedb/index.d.ts @@ -1,34 +1,31 @@ -// Type definitions for NeDB +// Type definitions for NeDB 1.8 // Project: https://github.com/louischatriot/nedb // Definitions by: Stefan Steinhart // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = NeDBDataStore; +export = Nedb; export as namespace Nedb; -declare namespace NeDBDataStore { } -declare class NeDBDataStore { - constructor(); - constructor(path:string); - constructor(options:NeDB.DataStoreOptions); +declare class Nedb { + constructor(pathOrOptions?: string | Nedb.DataStoreOptions); - persistence:NeDB.Persistence; + persistence: Nedb.Persistence; /** * Load the database from the datafile, and trigger the execution of buffered commands if any */ - loadDatabase(cb?:(err:Error)=>void):void; + loadDatabase(cb?: (err: Error) => void): void; /** * Get an array of all the data in the database */ - getAllData():Array; + getAllData(): Array; /** * Reset all currently defined indexes */ - resetIndexes(newData:any):void; + resetIndexes(newData: any): void; /** * Ensure an index is kept for this field. Same parameters as lib/indexes @@ -39,34 +36,32 @@ declare class NeDBDataStore { * @param {Boolean} options.sparse * @param {Function} cb Optional callback, signature: err */ - ensureIndex(options:NeDB.EnsureIndexOptions, cb?:(err:Error)=>void):void; + ensureIndex(options: Nedb.EnsureIndexOptions, cb?: (err: Error) => void): void; /** * Remove an index * @param {String} fieldName * @param {Function} cb Optional callback, signature: err */ - removeIndex(fieldName:string, cb?:(err:Error)=>void):void; + removeIndex(fieldName: string, cb?: (err: Error) => void): void; /** * Add one or several document(s) to all indexes */ - addToIndexes(doc:T):void; - addToIndexes(doc:Array):void; + addToIndexes(doc: T | T[]): void; /** * Remove one or several document(s) from all indexes */ - removeFromIndexes(doc:T):void; - removeFromIndexes(doc:Array):void; + removeFromIndexes(doc: T | T[]): void; /** * Update one or several documents in all indexes * To update multiple documents, oldDoc must be an array of { oldDoc, newDoc } pairs * If one update violates a constraint, all changes are rolled back */ - updateIndexes(oldDoc:T, newDoc:T):void; - updateIndexes(updates:Array<{oldDoc:T; newDoc:T;}>):void; + updateIndexes(oldDoc: T, newDoc: T): void; + updateIndexes(updates: Array<{oldDoc: T; newDoc: T}>): void; /** * Return the list of candidates for a given query @@ -77,20 +72,20 @@ declare class NeDBDataStore { * * TODO: needs to be moved to the Cursor module */ - getCandidates(query:any):void; + getCandidates(query: any): void; /** * Insert a new document * @param {Function} cb Optional callback, signature: err, insertedDoc */ - insert(newDoc:T, cb?:(err:Error, document:T)=>void):void; + insert(newDoc: T, cb?: (err: Error, document: T) => void): void; /** * Count all documents matching the query * @param {any} query MongoDB-style query */ - count(query:any, callback:(err:Error, n:number)=>void):void; - count(query:any):NeDB.CursorCount; + count(query: any, callback: (err: Error, n: number) => void): void; + count(query: any): Nedb.CursorCount; /** * Find all documents matching the query @@ -98,61 +93,61 @@ declare class NeDBDataStore { * @param {any} query MongoDB-style query * @param {any} projection MongoDB-style projection */ - find(query:any, projection:T, callback:(err:Error, documents:Array)=>void):void; - find(query:any, projection:T):NeDB.Cursor; + find(query: any, projection: T, callback: (err: Error, documents: Array) => void): void; + find(query: any, projection?: T): Nedb.Cursor; /** * Find all documents matching the query * If no callback is passed, we return the cursor so that user can limit, skip and finally exec * * @param {any} query MongoDB-style query */ - find(query:any, callback:(err:Error, documents:Array)=>void):void; - find(query:any):NeDB.Cursor; + find(query: any, callback: (err: Error, documents: Array) => void): void; /** * Find one document matching the query * @param {any} query MongoDB-style query * @param {any} projection MongoDB-style projection */ - findOne(query:any, projection:T, callback:(err:Error, document:T)=>void):void; + findOne(query: any, projection: T, callback: (err: Error, document: T) => void): void; /** * Find one document matching the query * @param {any} query MongoDB-style query */ - findOne(query:any, callback:(err:Error, document:T)=>void):void; + findOne(query: any, callback: (err: Error, document: T) => void): void; /** - * Update all docs matching query v1.7.4 and prior signature. + * Update all docs matching query v1.7.4 and prior signature. * For now, very naive implementation (recalculating the whole database) * @param {any} query * @param {any} updateQuery * @param {Object} options Optional options * options.multi If true, can update multiple documents (defaults to false) * options.upsert If true, document is inserted if the query doesn't match anything - * @param {Function} cb Optional callback, signature: err, - * numReplaced, - * upsert (set to true if the update was in fact an upsert) + * @param {Function} cb Optional callback, signature: err, + * numReplaced, + * upsert (set to true if the update was in fact an upsert) * * @api private Use Datastore.update which has the same signature */ - update(query:any, updateQuery:any, options?:NeDB.UpdateOptions, cb?:(err:Error, numberOfUpdated:number, upsert:boolean)=>void):void; - /** - * Update all docs matching query v1.8 signature. - * For now, very naive implementation (recalculating the whole database) - * @param {any} query - * @param {any} updateQuery - * @param {Object} options Optional options - * options.multi If true, can update multiple documents (defaults to false) - * options.upsert If true, document is inserted if the query doesn't match anything - * @param {Function} cb Optional callback, signature: err, - * numAffected, - * affectedDocuments (when returnUpdatedDocs is set to true), obj or array - * upsert (set to true if the update was in fact an upsert) - * - * @api private Use Datastore.update which has the same signature - */ - update(query:any, updateQuery:any, options?:NeDB.UpdateOptions, cb?:(err:Error, numberOfUpdated:number, affectedDocuments:any, upsert:boolean)=>void):void; + update(query: any, updateQuery: any, options?: Nedb.UpdateOptions, cb?: (err: Error, numberOfUpdated: number, upsert: boolean) => void): void; + + /** + * Update all docs matching query v1.8 signature. + * For now, very naive implementation (recalculating the whole database) + * @param {any} query + * @param {any} updateQuery + * @param {Object} options Optional options + * options.multi If true, can update multiple documents (defaults to false) + * options.upsert If true, document is inserted if the query doesn't match anything + * @param {Function} cb Optional callback, signature: err, + * numAffected, + * affectedDocuments (when returnUpdatedDocs is set to true), obj or array + * upsert (set to true if the update was in fact an upsert) + * + * @api private Use Datastore.update which has the same signature + */ + update(query: any, updateQuery: any, options?: Nedb.UpdateOptions, cb?: (err: Error, numberOfUpdated: number, affectedDocuments: any, upsert: boolean) => void): void; /** * Remove all docs matching the query @@ -164,32 +159,45 @@ declare class NeDBDataStore { * * @api private Use Datastore.remove which has the same signature */ - remove(query:any, options:NeDB.RemoveOptions, cb?:(err:Error, n:number)=>void):void; - remove(query:any, cb?:(err:Error, n:number)=>void):void; + remove(query: any, options: Nedb.RemoveOptions, cb?: (err: Error, n: number) => void): void; + remove(query: any, cb?: (err: Error, n: number) => void): void; } -declare namespace NeDB { +declare namespace Nedb { interface Cursor { - sort(query:any):Cursor; - skip(n:number):Cursor; - limit(n:number):Cursor; - projection(query:any):Cursor; - exec(callback:(err:Error, documents:Array)=>void):void; + sort(query: any): Cursor; + skip(n: number): Cursor; + limit(n: number): Cursor; + projection(query: any): Cursor; + exec(callback: (err: Error, documents: Array) => void): void; } interface CursorCount { - exec(callback:(err:Error, count:number)=>void):void; + exec(callback: (err: Error, count: number) => void): void; } interface DataStoreOptions { - filename?:string // Optional, datastore will be in-memory only if not provided - inMemoryOnly?:boolean // Optional, default to false - nodeWebkitAppName?:boolean // Optional, specify the name of your NW app if you want options.filename to be relative to the directory where - autoload?:boolean // Optional, defaults to false - onload?:(error:Error)=>any // Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown - afterSerialization?:(line:string)=>string; // (optional): hook you can use to transform data after it was serialized and before it is written to disk. Can be used for example to encrypt data before writing database to disk. This function takes a string as parameter (one line of an NeDB data file) and outputs the transformed string, which must absolutely not contain a \n character (or data will be lost) - beforeDeserialization?:(line:string)=>string; // (optional): reverse of afterSerialization. Make sure to include both and not just one or you risk data loss. For the same reason, make sure both functions are inverses of one another. Some failsafe mechanisms are in place to prevent data loss if you misuse the serialization hooks: NeDB checks that never one is declared without the other, and checks that they are reverse of one another by testing on random strings of various lengths. In addition, if too much data is detected as corrupt, NeDB will refuse to start as it could mean you're not using the deserialization hook corresponding to the serialization hook used before (see below) - corruptAlertThreshold?:number; // (optional): between 0 and 1, defaults to 10%. NeDB will refuse to start if more than this percentage of the datafile is corrupt. 0 means you don't tolerate any corruption, 1 means you don't care + filename?: string // Optional, datastore will be in-memory only if not provided + inMemoryOnly?: boolean // Optional, default to false + nodeWebkitAppName?: boolean // Optional, specify the name of your NW app if you want options.filename to be relative to the directory where + autoload?: boolean // Optional, defaults to false + // Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown + onload?: (error: Error) => any + // (optional): hook you can use to transform data after it was serialized and before it is written to disk. + // Can be used for example to encrypt data before writing database to disk. + // This function takes a string as parameter (one line of an NeDB data file) and outputs the transformed string, which must absolutely not contain a \n character (or data will be lost) + afterSerialization?: (line: string) => string; + // (optional): reverse of afterSerialization. + // Make sure to include both and not just one or you risk data loss. + // For the same reason, make sure both functions are inverses of one another. + // Some failsafe mechanisms are in place to prevent data loss if you misuse the serialization hooks: + // NeDB checks that never one is declared without the other, and checks that they are reverse of one another by testing on random strings of various lengths. + // In addition, if too much data is detected as corrupt, + // NeDB will refuse to start as it could mean you're not using the deserialization hook corresponding to the serialization hook used before (see below) + beforeDeserialization?: (line: string) => string; + // (optional): between 0 and 1, defaults to 10%. NeDB will refuse to start if more than this percentage of the datafile is corrupt. + // 0 means you don't tolerate any corruption, 1 means you don't care + corruptAlertThreshold?: number; } /** @@ -206,18 +214,18 @@ declare namespace NeDB { * options only one option for now: multi which allows the removal of multiple documents if set to true. Default is false */ interface RemoveOptions { - multi?:boolean + multi?: boolean } interface EnsureIndexOptions { - fieldName:string; - unique?:boolean; - sparse?:boolean; + fieldName: string; + unique?: boolean; + sparse?: boolean; } interface Persistence { - compactDatafile():void; - setAutocompactionInterval(interval:number):void; - stopAutocompaction():void; + compactDatafile(): void; + setAutocompactionInterval(interval: number): void; + stopAutocompaction(): void; } } diff --git a/nedb/nedb-tests.ts b/nedb/nedb-tests.ts index 5faa3d0ffb..e90b682c68 100644 --- a/nedb/nedb-tests.ts +++ b/nedb/nedb-tests.ts @@ -2,193 +2,152 @@ * Created by stefansteinhart on 31.01.15. */ -/// /// - import * as es6styleimport from 'nedb'; -import Q = require('q'); import nedb = require('nedb'); class BaseCollection { + private dataStore: nedb; - private dataStore:nedb; - - constructor(dataStore:nedb) { - + constructor(dataStore: nedb) { this.dataStore = dataStore; } - public insert(document:T):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.insert(document, function (err:Error, newDoc:T) { // Callback is optional - // newDoc is the newly inserted document, including its _id - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(newDoc); - } + insert(document: T): Promise { + return new Promise((resolve, reject) => { + this.dataStore.insert(document, (err: Error, newDoc: T) => { // Callback is optional + // newDoc is the newly inserted document, including its _id + if (err) { + reject(err); + } else { + resolve(newDoc); + } + }); }); - - return deferred.promise; } - public count():Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.count({}, function (err:Error, count:number) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(count); - } + count(): Promise { + return new Promise((resolve, reject) => { + this.dataStore.count({}, (err: Error, count: number) => { + if (err) { + reject(err); + } else { + resolve(count); + } + }); }); - - return deferred.promise; } - public countBy(criteria:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.count(criteria, function (err:Error, count:number) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(count); - } + countBy(criteria: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.count(criteria, (err: Error, count: number) => { + if (err) { + reject(err); + } else { + resolve(count); + } + }); }); - - return deferred.promise; } - public findByID(id:string):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.findOne({_id: id}, function (err:Error, doc:T) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(doc); - } + findByID(id: string): Promise { + return new Promise((resolve, reject) => { + this.dataStore.findOne({_id: id}, (err: Error, doc: T) => { + if (err) { + reject(err); + } else { + resolve(doc); + } + }); }); - - return deferred.promise; } - public findOne(criteria:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.findOne(criteria, function (err:Error, doc:T) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(doc); - } + findOne(criteria: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.findOne(criteria, (err: Error, doc: T) => { + if (err) { + reject(err); + } else { + resolve(doc); + } + }); }); - - return deferred.promise; } - public find(criteria:any):Q.Promise> { - - var deferred = Q.defer>(); - - this.dataStore.find(criteria, function (err:Error, docs:Array) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(docs); - } + find(criteria: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.find(criteria, (err: Error, docs: T[]) => { + if (err) { + reject(err); + } + else { + resolve(docs); + } + }); }); - - return deferred.promise; } - public all():Q.Promise> { - - var deferred = Q.defer>(); - - this.dataStore.find({}, function (err:Error, docs:Array) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(docs); - } + all(): Promise { + return new Promise((resolve, reject) => { + this.dataStore.find({}, (err: Error, docs: T[]) => { + if (err) { + reject(err); + } else { + resolve(docs); + } + }); }); - - return deferred.promise; } - public upsert(query:any, updateQuery:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.update(query, updateQuery, {upsert: true}, function (err:Error, numberOfUpdated:number, upsert: boolean) { - if (err) { - deferred.reject(err); - } - else { - //deferred.resolve(newDoc); - } + upsert(query: any, updateQuery: any): Promise { + const a: Promise = new Promise((resolve, reject) => { + this.dataStore.update(query, updateQuery, {upsert: true}, (err: Error, numberOfUpdated: number, upsert: boolean) => { + if (err) { + reject(err); + } else { + //resolve(newDoc); + } + }); }); - this.dataStore.update(query, updateQuery, {upsert: true}, function (err:Error, numberOfUpdated:number, affectedDocs:any, upsert: boolean) { - if (err) { - deferred.reject(err); - } - else { - //deferred.resolve(newDoc); - } + const b: Promise = new Promise((resolve, reject) => { + this.dataStore.update(query, updateQuery, {upsert: true}, (err: Error, numberOfUpdated: number, affectedDocs: any, upsert: boolean) => { + if (err) { + reject(err); + } else { + //resolve(newDoc); + } + }); }); - return deferred.promise; + return a || b; } - public update(query:Object, updateQuery:Object, options?:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.update(query, updateQuery, options, function (err:Error, numberOfUpdated:number) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(numberOfUpdated); - } + update(query: {}, updateQuery: {}, options?: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.update(query, updateQuery, options, (err: Error, numberOfUpdated: number) => { + if (err) { + reject(err); + } else { + resolve(numberOfUpdated); + } + }); }); - - return deferred.promise; } - public remove(criteria:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.remove(criteria, function (err:Error, numberOfDeletedEntrys:number) { - - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(numberOfDeletedEntrys); - } + remove(criteria: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.remove(criteria, (err: Error, numberOfDeletedEntrys: number) => { + if (err) { + reject(err); + } + else { + resolve(numberOfDeletedEntrys); + } + }); }); - - return deferred.promise; } } @@ -199,7 +158,7 @@ var db = new Datastore(); // Type 2: Persistent datastore with manual loading db = new Datastore({filename: 'path/to/datafile'}); -db.loadDatabase(function (err) { // Callback is optional +db.loadDatabase((err) => { // Callback is optional // Now commands will be executed }); @@ -217,7 +176,7 @@ db = new Datastore({filename: path.join(require('nw.gui').App.dataPath, 'somethi // Of course you can create multiple datastores if you need several // collections. In this case it's usually a good idea to use autoload for all collections. -var dbContainer:any = {}; +var dbContainer: any = {}; dbContainer.users = new Datastore('path/to/users.db'); dbContainer.robots = new Datastore('path/to/robots.db'); @@ -225,7 +184,7 @@ dbContainer.robots = new Datastore('path/to/robots.db'); dbContainer.users.loadDatabase(); dbContainer.robots.loadDatabase(); -var doc:any = { +var doc: any = { hello: 'world' , n: 5 , today: new Date() @@ -236,151 +195,151 @@ var doc:any = { , infos: {name: 'nedb'} }; -db.insert(doc, function (err:Error, newDoc:any) { // Callback is optional +db.insert(doc, (err: Error, newDoc: any) => { // Callback is optional // newDoc is the newly inserted document, including its _id // newDoc has no key called notToBeSaved since its value was undefined }); -db.insert([{a: 5}, {a: 42}], function (err:Error, newdocs:Array) { +db.insert([{a: 5}, {a: 42}], (err: Error, newdocs: any[]) => { // Two documents were inserted in the database // newDocs is an array with these documents, augmented with their _id }); // If there is a unique constraint on field 'a', this will fail -db.insert([{a: 5}, {a: 42}, {a: 5}], function (err:Error) { +db.insert([{a: 5}, {a: 42}, {a: 5}], (err: Error) => { // err is a 'uniqueViolated' error // The database was not modified }); // Finding all planets in the solar system -db.find({system: 'solar'}, function (err:Error, docs:Array) { +db.find({system: 'solar'}, (err: Error, docs: any[]) => { // docs is an array containing documents Mars, Earth, Jupiter // If no document is found, docs is equal to [] }); // Finding all planets whose name contain the substring 'ar' using a regular expression -db.find({planet: /ar/}, function (err:Error, docs:Array) { +db.find({planet: /ar/}, (err: Error, docs: any[]) => { // docs contains Mars and Earth }); // Finding all inhabited planets in the solar system -db.find({system: 'solar', inhabited: true}, function (err:Error, docs:Array) { +db.find({system: 'solar', inhabited: true}, (err: Error, docs: any[]) => { // docs is an array containing document Earth only }); // Use the dot-notation to match fields in subdocuments -db.find({"humans.genders": 2}, function (err:Error, docs:Array) { +db.find({"humans.genders": 2}, (err: Error, docs: any[]) => { // docs contains Earth }); // Use the dot-notation to navigate arrays of subdocuments -db.find({"completeData.planets.name": "Mars"}, function (err:Error, docs:Array) { +db.find({"completeData.planets.name": "Mars"}, (err: Error, docs: any[]) => { // docs contains document 5 }); -db.find({"completeData.planets.name": "Jupiter"}, function (err:Error, docs:Array) { +db.find({"completeData.planets.name": "Jupiter"}, (err: Error, docs: any[]) => { // docs is empty }); -db.find({"completeData.planets.0.name": "Earth"}, function (err:Error, docs:Array) { +db.find({"completeData.planets.0.name": "Earth"}, (err: Error, docs: any[]) => { // docs contains document 5 // If we had tested against "Mars" docs would be empty because we are matching against a specific array element }); // You can also deep-compare objects. Don't confuse this with dot-notation! -db.find({humans: {genders: 2}}, function (err:Error, docs:Array) { +db.find({humans: {genders: 2}}, (err: Error, docs: any[]) => { // docs is empty, because { genders: 2 } is not equal to { genders: 2, eyes: true } }); // Find all documents in the collection -db.find({}, function (err:Error, docs:Array) { +db.find({}, (err: Error, docs: any[]) => { }); // The same rules apply when you want to only find one document -db.findOne({_id: 'id1'}, function (err:Error, doc:any) { +db.findOne({_id: 'id1'}, (err: Error, doc: any) => { // doc is the document Mars // If no document is found, doc is null }); // $lt, $lte, $gt and $gte work on numbers and strings -db.find({"humans.genders": {$gt: 5}}, function (err:Error, docs:Array) { +db.find({"humans.genders": {$gt: 5}}, (err: Error, docs: any[]) => { // docs contains Omicron Persei 8, whose humans have more than 5 genders (7). }); // When used with strings, lexicographical order is used -db.find({planet: {$gt: 'Mercury'}}, function (err:Error, docs:Array) { +db.find({planet: {$gt: 'Mercury'}}, (err: Error, docs: any[]) => { // docs contains Omicron Persei 8 }) // Using $in. $nin is used in the same way -db.find({planet: {$in: ['Earth', 'Jupiter']}}, function (err:Error, docs:Array) { +db.find({planet: {$in: ['Earth', 'Jupiter']}}, (err: Error, docs: any[]) => { // docs contains Earth and Jupiter }); // Using $exists -db.find({satellites: {$exists: true}}, function (err:Error, docs:Array) { +db.find({satellites: {$exists: true}}, (err: Error, docs: any[]) => { // docs contains only Mars }); // Using $regex with another operator -db.find({planet: {$regex: /ar/, $nin: ['Jupiter', 'Earth']}}, function (err:Error, docs:Array) { +db.find({planet: {$regex: /ar/, $nin: ['Jupiter', 'Earth']}}, (err: Error, docs: any[]) => { // docs only contains Mars because Earth was excluded from the match by $nin }); // Using an array-specific comparison function // Note: you can't use nested comparison functions, e.g. { $size: { $lt: 5 } } will throw an error -db.find({satellites: {$size: 2}}, function (err:Error, docs:Array) { +db.find({satellites: {$size: 2}}, (err: Error, docs: any[]) => { // docs contains Mars }); -db.find({satellites: {$size: 1}}, function (err:Error, docs:Array) { +db.find({satellites: {$size: 1}}, (err: Error, docs: any[]) => { // docs is empty }); // If a document's field is an array, matching it means matching any element of the array -db.find({satellites: 'Phobos'}, function (err:Error, docs:Array) { +db.find({satellites: 'Phobos'}, (err: Error, docs: any[]) => { // docs contains Mars. Result would have been the same if query had been { satellites: 'Deimos' } }); // This also works for queries that use comparison operators -db.find({satellites: {$lt: 'Amos'}}, function (err:Error, docs:Array) { +db.find({satellites: {$lt: 'Amos'}}, (err: Error, docs: any[]) => { // docs is empty since Phobos and Deimos are after Amos in lexicographical order }); // This also works with the $in and $nin operator -db.find({satellites: {$in: ['Moon', 'Deimos']}}, function (err:Error, docs:Array) { +db.find({satellites: {$in: ['Moon', 'Deimos']}}, (err: Error, docs: any[]) => { // docs contains Mars (the Earth document is not complete!) }); -db.find({$or: [{planet: 'Earth'}, {planet: 'Mars'}]}, function (err:Error, docs:Array) { +db.find({$or: [{planet: 'Earth'}, {planet: 'Mars'}]}, (err: Error, docs: any[]) => { // docs contains Earth and Mars }); -db.find({$not: {planet: 'Earth'}}, function (err:Error, docs:Array) { +db.find({$not: {planet: 'Earth'}}, (err: Error, docs: any[]) => { // docs contains Mars, Jupiter, Omicron Persei 8 }); db.find({ - $where: function () { + $where() { return parseInt(Object.keys(this)[0]) > 6; } -}, function (err:Error, docs:Array) { +}, (err: Error, docs: any[]) => { // docs with more than 6 properties }); // You can mix normal queries, comparison queries and logical operators -db.find({$or: [{planet: 'Earth'}, {planet: 'Mars'}], inhabited: true}, function (err:Error, docs:Array) { +db.find({$or: [{planet: 'Earth'}, {planet: 'Mars'}], inhabited: true}, (err: Error, docs: any[]) => { // docs contains Earth }); // No query used means all results are returned (before the Cursor modifiers) -db.find({}).sort({planet: 1}).skip(1).limit(2).exec(function (err:Error, docs:Array) { +db.find({}).sort({planet: 1}).skip(1).limit(2).exec((err: Error, docs: any[]) => { // docs is [doc3, doc1] }); // You can sort in reverse order like this -db.find({system: 'solar'}).sort({planet: -1}).exec(function (err:Error, docs:Array) { +db.find({system: 'solar'}).sort({planet: -1}).exec((err: Error, docs: any[]) => { // docs is [doc1, doc3, doc2] }); @@ -390,38 +349,38 @@ db.find({}).sort({firstField: 1, secondField: -1}); // Same database as above // Keeping only the given fields -db.find({planet: 'Mars'}, {planet: 1, system: 1}, function (err:Error, docs:Array) { +db.find({planet: 'Mars'}, {planet: 1, system: 1}, (err: Error, docs: any[]) => { // docs is [{ planet: 'Mars', system: 'solar', _id: 'id1' }] }); // Keeping only the given fields but removing _id -db.find({planet: 'Mars'}, {planet: 1, system: 1, _id: 0}, function (err:Error, docs:Array) { +db.find({planet: 'Mars'}, {planet: 1, system: 1, _id: 0}, (err: Error, docs: any[]) => { // docs is [{ planet: 'Mars', system: 'solar' }] }); // Omitting only the given fields and removing _id -db.find({planet: 'Mars'}, {planet: 0, system: 0, _id: 0}, function (err:Error, docs:Array) { +db.find({planet: 'Mars'}, {planet: 0, system: 0, _id: 0}, (err: Error, docs: any[]) => { // docs is [{ inhabited: false, satellites: ['Phobos', 'Deimos'] }] }); // Failure: using both modes at the same time -db.find({planet: 'Mars'}, {planet: 0, system: 1}, function (err:Error, docs:Array) { +db.find({planet: 'Mars'}, {planet: 0, system: 1}, (err: Error, docs: any[]) => { // err is the error message, docs is undefined }); // You can also use it in a Cursor way but this syntax is not compatible with MongoDB // If upstream compatibility is important don't use this method -db.find({planet: 'Mars'}).projection({planet: 1, system: 1}).exec(function (err:Error, docs:Array) { +db.find({planet: 'Mars'}).projection({planet: 1, system: 1}).exec((err: Error, docs: any[]) => { // docs is [{ planet: 'Mars', system: 'solar', _id: 'id1' }] }); // Count all planets in the solar system -db.count({system: 'solar'}, function (err:Error, count:number) { +db.count({system: 'solar'}, (err: Error, count: number) => { // count equals to 3 }); // Count all documents in the datastore -db.count({}, function (err:Error, count:number) { +db.count({}, (err: Error, count: number) => { // count equals to 4 }); @@ -432,7 +391,7 @@ db.count({}, function (err:Error, count:number) { // { _id: 'id4', planet: 'Omicron Persia 8', system: 'futurama', inhabited: true } // Replace a document by another -db.update({planet: 'Jupiter'}, {planet: 'Pluton'}, {}, function (err:Error, numReplaced:number) { +db.update({planet: 'Jupiter'}, {planet: 'Pluton'}, {}, (err: Error, numReplaced: number) => { // numReplaced = 1 // The doc #3 has been replaced by { _id: 'id3', planet: 'Pluton' } // Note that the _id is kept unchanged, and the document has been replaced @@ -440,19 +399,19 @@ db.update({planet: 'Jupiter'}, {planet: 'Pluton'}, {}, function (err:Error, numR }); // Set an existing field's value -db.update({system: 'solar'}, {$set: {system: 'solar system'}}, {multi: true}, function (err:Error, numReplaced:number) { +db.update({system: 'solar'}, {$set: {system: 'solar system'}}, {multi: true}, (err: Error, numReplaced: number) => { // numReplaced = 3 // Field 'system' on Mars, Earth, Jupiter now has value 'solar system' }); // Setting the value of a non-existing field in a subdocument by using the dot-notation -db.update({planet: 'Mars'}, {$set: {"data.satellites": 2, "data.red": true}}, {}, function () { +db.update({planet: 'Mars'}, {$set: {"data.satellites": 2, "data.red": true}}, {}, () => { // Mars document now is { _id: 'id1', system: 'solar', inhabited: false // , data: { satellites: 2, red: true } // } // Not that to set fields in subdocuments, you HAVE to use dot-notation // Using object-notation will just replace the top-level field - db.update({planet: 'Mars'}, {$set: {data: {satellites: 3}}}, {}, function () { + db.update({planet: 'Mars'}, {$set: {data: {satellites: 3}}}, {}, () => { // Mars document now is { _id: 'id1', system: 'solar', inhabited: false // , data: { satellites: 3 } // } @@ -461,7 +420,7 @@ db.update({planet: 'Mars'}, {$set: {"data.satellites": 2, "data.red": true}}, {} }); // Deleting a field -db.update({planet: 'Mars'}, {$unset: {planet: true}}, {}, function () { +db.update({planet: 'Mars'}, {$unset: {planet: true}}, {}, () => { // Now the document for Mars doesn't contain the planet field // You can unset nested fields with the dot notation of course }); @@ -470,14 +429,14 @@ db.update({planet: 'Mars'}, {$unset: {planet: true}}, {}, function () { db.update({planet: 'Pluton'}, { planet: 'Pluton', inhabited: false -}, {upsert: true}, function (err:Error, numReplaced:number, upsert:boolean) { +}, {upsert: true}, (err: Error, numReplaced: number, upsert: boolean) => { // numReplaced = 1, upsert = { _id: 'id5', planet: 'Pluton', inhabited: false } // A new document { _id: 'id5', planet: 'Pluton', inhabited: false } has been added to the collection }); // If you upsert with a modifier, the upserted doc is the query modified by the modifier // This is simpler than it sounds :) -db.update({planet: 'Pluton'}, {$inc: {distance: 38}}, {upsert: true}, function () { +db.update({planet: 'Pluton'}, {$inc: {distance: 38}}, {upsert: true}, () => { // A new document { _id: 'id5', planet: 'Pluton', distance: 38 } has been added to the collection }); @@ -485,12 +444,12 @@ db.update({planet: 'Pluton'}, {$inc: {distance: 38}}, {upsert: true}, function ( // let's see how we can modify the array field atomically // $push inserts new elements at the end of the array -db.update({_id: 'id6'}, {$push: {fruits: 'banana'}}, {}, function () { +db.update({_id: 'id6'}, {$push: {fruits: 'banana'}}, {}, () => { // Now the fruits array is ['apple', 'orange', 'pear', 'banana'] }); // $pop removes an element from the end (if used with 1) or the front (if used with -1) of the array -db.update({_id: 'id6'}, {$pop: {fruits: 1}}, {}, function () { +db.update({_id: 'id6'}, {$pop: {fruits: 1}}, {}, () => { // Now the fruits array is ['apple', 'orange'] // With { $pop: { fruits: -1 } }, it would have been ['orange', 'pear'] }); @@ -498,23 +457,23 @@ db.update({_id: 'id6'}, {$pop: {fruits: 1}}, {}, function () { // $addToSet adds an element to an array only if it isn't already in it // Equality is deep-checked (i.e. $addToSet will not insert an object in an array already containing the same object) // Note that it doesn't check whether the array contained duplicates before or not -db.update({_id: 'id6'}, {$addToSet: {fruits: 'apple'}}, {}, function () { +db.update({_id: 'id6'}, {$addToSet: {fruits: 'apple'}}, {}, () => { // The fruits array didn't change // If we had used a fruit not in the array, e.g. 'banana', it would have been added to the array }); // $pull removes all values matching a value or even any NeDB query from the array -db.update({_id: 'id6'}, {$pull: {fruits: 'apple'}}, {}, function () { +db.update({_id: 'id6'}, {$pull: {fruits: 'apple'}}, {}, () => { // Now the fruits array is ['orange', 'pear'] }); -db.update({_id: 'id6'}, {$pull: {fruits: {$in: ['apple', 'pear']}}}, {}, function () { +db.update({_id: 'id6'}, {$pull: {fruits: {$in: ['apple', 'pear']}}}, {}, () => { // Now the fruits array is ['orange'] }); // $each can be used to $push or $addToSet multiple values at once // This example works the same way with $addToSet -db.update({_id: 'id6'}, {$push: {fruits: {$each: ['banana', 'orange']}}}, {}, function () { +db.update({_id: 'id6'}, {$push: {fruits: {$each: ['banana', 'orange']}}}, {}, () => { // Now the fruits array is ['apple', 'orange', 'pear', 'banana', 'orange'] }); @@ -526,33 +485,33 @@ db.update({_id: 'id6'}, {$push: {fruits: {$each: ['banana', 'orange']}}}, {}, fu // Remove one document from the collection // options set to {} since the default for multi is false -db.remove({_id: 'id2'}, {}, function (err:Error, numRemoved:number) { +db.remove({_id: 'id2'}, {}, (err: Error, numRemoved: number) => { // numRemoved = 1 }); // Remove multiple documents -db.remove({system: 'solar'}, {multi: true}, function (err:Error, numRemoved:number) { +db.remove({system: 'solar'}, {multi: true}, (err: Error, numRemoved: number) => { // numRemoved = 3 // All planets from the solar system were removed }); -db.ensureIndex({fieldName: 'somefield'}, function (err:Error) { +db.ensureIndex({fieldName: 'somefield'}, (err: Error) => { // If there was an error, err is not null }); // Using a unique constraint with the index -db.ensureIndex({fieldName: 'somefield', unique: true}, function (err:Error) { +db.ensureIndex({fieldName: 'somefield', unique: true}, (err: Error) => { }); // Using a sparse unique index -db.ensureIndex({fieldName: 'somefield', unique: true, sparse: true}, function (err:Error) { +db.ensureIndex({fieldName: 'somefield', unique: true, sparse: true}, (err: Error) => { }); // Format of the error message when the unique constraint is not met -db.insert({somefield: 'nedb'}, function (err:Error) { +db.insert({somefield: 'nedb'}, (err: Error) => { // err is null - db.insert({somefield: 'nedb'}, function (err:Error) { + db.insert({somefield: 'nedb'}, (err: Error) => { // err is { errorType: 'uniqueViolated' // , key: 'name' // , message: 'Unique constraint violated for key name' } @@ -560,5 +519,5 @@ db.insert({somefield: 'nedb'}, function (err:Error) { }); // Remove index on field somefield -db.removeIndex('somefield', function (err:Error) { +db.removeIndex('somefield', (err: Error) => { }); \ No newline at end of file diff --git a/nedb/tslint.json b/nedb/tslint.json new file mode 100644 index 0000000000..192203ab54 --- /dev/null +++ b/nedb/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file From a3dc5d2e661c26006481ad0f0eb75c5925adf018 Mon Sep 17 00:00:00 2001 From: Wil Lee Date: Tue, 14 Mar 2017 11:12:46 -0700 Subject: [PATCH 070/150] Add rheostat typings --- rheostat/index.d.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 rheostat/index.d.ts diff --git a/rheostat/index.d.ts b/rheostat/index.d.ts new file mode 100644 index 0000000000..372e5c6f1b --- /dev/null +++ b/rheostat/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for rheostat 2.1 +// Project: https://github.com/airbnb/rheostat +// Definitions by: Sasha Bayan , Wil Lee +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +import * as React from 'react'; + +export type Orientation = 'horizontal' | 'vertical'; + +export interface Algorithm { + getPosition(value: number, min: number, max: number): number; + getValue(pos: number, min: number, max: number): number; +} + +export interface PublicState { + max: number; + min: number; + values: number[]; +} + +export interface Events { + onClick?: () => any; + onChange?: (publicState: PublicState) => any; + onKeyPress?: () => any; + onSliderDragEnd?: () => any; + onSliderDragMove?: () => any; + onSliderDragStart?: () => any; + onValuesUpdated?: (publicState: PublicState) => any; +} + +export interface Props extends Events { + algorithm?: Algorithm; + className?: string; + disabled?: boolean; + handle?: React.ReactType; + max?: number; + min?: number; + orientation?: Orientation; + pitComponent?: React.ReactType; + pitPoints?: number[]; + progressBar?: React.ReactType; + snap?: boolean; + snapPoints?: number[]; + values?: number[]; +} + +export default class Rheostat extends React.Component {} + From d0b032eb4a61bac2702dfd0fa59da1221b5f4835 Mon Sep 17 00:00:00 2001 From: Wil Lee Date: Tue, 14 Mar 2017 11:13:03 -0700 Subject: [PATCH 071/150] Add rheostat tests --- rheostat/rheostat-tests.tsx | 74 +++++++++++++++++++++++++++++++++++++ rheostat/tsconfig.json | 21 +++++++++++ 2 files changed, 95 insertions(+) create mode 100644 rheostat/rheostat-tests.tsx create mode 100644 rheostat/tsconfig.json diff --git a/rheostat/rheostat-tests.tsx b/rheostat/rheostat-tests.tsx new file mode 100644 index 0000000000..1116861943 --- /dev/null +++ b/rheostat/rheostat-tests.tsx @@ -0,0 +1,74 @@ +import * as React from 'react'; +import Rheostat, {Orientation, Algorithm, PublicState} from 'rheostat'; + +type Element = React.ReactElement; + +function Basic(props: {}): Element { + return ; +} + +function MultiHandles(props: {}): Element { + return ( + + ); +} + +function CustomAlgorithm(props: {}): Element { + const geometric: Algorithm = { + getPosition(x: number, min: number, max: number) { + return ((max / (max - min)) ** 0.5) * (((x - min) / max) ** 0.5) * 100; + }, + + getValue(x: number, min: number, max: number) { + return (Math.floor(((x / 100) ** 2) * (max - min)) + min); + } + }; + + return ; +} + +function ComponentOverrides(props: {}): Element { + function Bar(props: {}): Element { return


; } + return ( + + ); +} + +function Vertical(props: {}): Element { + return ; +} + +function Pits(props: {}): Element { + function Pit(props: {}): Element { return ; } + return ( + + ); +} + +function CustomValues(props: {}): Element { + return ( + + ); +} + +function Handlers(props: {}): Element { + function handler(data: PublicState): void {} + return ( + + ); +} diff --git a/rheostat/tsconfig.json b/rheostat/tsconfig.json new file mode 100644 index 0000000000..384dce128d --- /dev/null +++ b/rheostat/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "jsx": "react", + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rheostat-tests.tsx" + ] +} From 9593fd1968f13b2d144492f458221bb6a4fe4c89 Mon Sep 17 00:00:00 2001 From: Wil Lee Date: Tue, 14 Mar 2017 12:06:59 -0700 Subject: [PATCH 072/150] Turn on linting --- rheostat/tslint.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 rheostat/tslint.json diff --git a/rheostat/tslint.json b/rheostat/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/rheostat/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From 9a57ca6254125457328aa2cd0e4ebf59bd7389e4 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Mar 2017 15:04:44 -0700 Subject: [PATCH 073/150] Remove 'promises-a-plus' and lint stamplay (#15176) --- promises-a-plus/index.d.ts | 18 ------ promises-a-plus/promises-a-plus-tests.ts | 79 ------------------------ promises-a-plus/tsconfig.json | 22 ------- stamplay-js-sdk/index.d.ts | 42 +++++-------- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 26 ++++---- stamplay-js-sdk/tslint.json | 1 + 6 files changed, 30 insertions(+), 158 deletions(-) delete mode 100644 promises-a-plus/index.d.ts delete mode 100644 promises-a-plus/promises-a-plus-tests.ts delete mode 100644 promises-a-plus/tsconfig.json create mode 100644 stamplay-js-sdk/tslint.json diff --git a/promises-a-plus/index.d.ts b/promises-a-plus/index.d.ts deleted file mode 100644 index 806020d051..0000000000 --- a/promises-a-plus/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Type definitions for promises-a-plus -// Project: http://promisesaplus.com/ -// Definitions by: Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace PromisesAPlus { - interface PromiseCtor { - (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; - } - - interface PromiseImpl { - new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; - } - - interface Thenable { - then(onFulfill?: (value: T) => Thenable|R, onReject?: (error: any) => Thenable|R): Thenable; - } -} diff --git a/promises-a-plus/promises-a-plus-tests.ts b/promises-a-plus/promises-a-plus-tests.ts deleted file mode 100644 index 222cca14d8..0000000000 --- a/promises-a-plus/promises-a-plus-tests.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// -/// -/// - -var thenNum: PromisesAPlus.Thenable; -var thenStr: PromisesAPlus.Thenable; -var thenBool: PromisesAPlus.Thenable; - -var impl: PromisesAPlus.PromiseImpl; - -declare class PromiseImpl { - constructor(resolver: (resolvePromise: (value: R) => void, rejectPromise: (reason: any) => void) => void); - - then(onFulfill: (value: R) => PromiseImpl, onReject: (error: any) => PromiseImpl): PromiseImpl; - then(onFulfill: (value: R) => PromiseImpl, onReject?: (error: any) => U): PromiseImpl; - then(onFulfill: (value: R) => U, onReject: (error: any) => PromiseImpl): PromiseImpl; - then(onFulfill?: (value: R) => U, onReject?: (error: any) => U): PromiseImpl; -} - -function testCompatibleWithPromiseImpl() { - var pNum: PromiseImpl = thenNum; - - thenNum = pNum; - - impl = PromiseImpl; -} - -function testCompatibleWithRxJS() { - // from spec to Rx - var rxThenNum: Rx.IPromise = thenNum; - var rxThenStr: Rx.IPromise = thenStr; - - // from Rx to spec - thenNum = rxThenNum; - thenStr = rxThenStr; - - var obsNum: Rx.Observable; - - // implementation usage - thenNum = obsNum.toPromise>(impl); - thenNum = obsNum.toPromise(impl); - obsNum.toPromise(PromiseImpl); -} - -function testCompatibleWithES6Promises() { - // define ES6 thenables - var es6ThenNum: PromiseLike; - var es6ThenStr: PromiseLike; - - // from ES6 to spec - thenNum = es6ThenNum; - thenStr = es6ThenStr; - - // implementation - impl = Promise; -} - -function testCompatibleWithQ() { - // from spec to ES6 - var qThenNum: Q.IPromise = thenNum; - var qThenStr: Q.IPromise = thenStr; - - // from ES6 to spec - thenNum = qThenNum; - thenStr = qThenStr; - - // there's no standart implementation with constructor behaviour -} - -function testCompatibleWithWhen() { - var whenPromiseNum: When.Promise; - var whenPromiseStr: When.Promise; - - // from ES6 to spec - thenNum = whenPromiseNum; - thenStr = whenPromiseStr; - - // there's no standart implementation with constructor behaviour -} diff --git a/promises-a-plus/tsconfig.json b/promises-a-plus/tsconfig.json deleted file mode 100644 index d5ccf86f75..0000000000 --- a/promises-a-plus/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "promises-a-plus-tests.ts" - ] -} \ No newline at end of file diff --git a/stamplay-js-sdk/index.d.ts b/stamplay-js-sdk/index.d.ts index 53f57ad86c..81f20d8c95 100644 --- a/stamplay-js-sdk/index.d.ts +++ b/stamplay-js-sdk/index.d.ts @@ -1,35 +1,27 @@ -// Type definitions for stamplay-js-sdk 1.2.9 +// Type definitions for stamplay-js-sdk 1.2 // Project: https://github.com/Stamplay/stamplay-js-sdk // Definitions by: Riderman de Sousa Barbosa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare namespace Stamplay { + export function init(appId: string): void; + export function User(): StamplayObject; + export function Cobject(object: string): StamplayObject; - export interface IStamplayModel { - signup({}) : PromisesAPlus.Thenable - new() : IStamplayModel - get(property : string) : any - set(property : string, value: any) : void - unset(property : string) : void - fetch(id : any) : PromisesAPlus.Thenable - destroy() : PromisesAPlus.Thenable - save({}?) : PromisesAPlus.Thenable - upVote() : PromisesAPlus.Thenable + export interface Model { + signup({}): Promise; + new(): Model; // This is suspicious, but tests show model instances being constructable... + get(property: string): any; + set(property: string, value: any): void; + unset(property: string) : void; + fetch(id: any) : Promise; + destroy(): Promise; + save({}?): Promise; + upVote(): Promise; } - export interface IStamplayObject { - Model : IStamplayModel - Collection : any - - } - - export interface StamplayStatic { - init(appId : string) : void; - User() : IStamplayObject - Cobject(object : string) : IStamplayObject + export interface StamplayObject { + Model: Model; + Collection : any; } } - -declare var Stamplay: Stamplay.StamplayStatic; diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts index d9a4247e03..9dddc1b242 100644 --- a/stamplay-js-sdk/stamplay-js-sdk-tests.ts +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -11,26 +11,24 @@ var registrationData = { password: 'mySecret' }; -user.signup(registrationData).then(function(){ - user.set('phoneNumber', '020 123 4567' ); - return user.save(); - }).then(function(){ - var number = user.get('phoneNumber'); - console.log(number); // number value is 020 123 4567 - }); +user.signup(registrationData).then(() => { + user.set('phoneNumber', '020 123 4567' ); + return user.save(); +}).then(() => { + var number = user.get('phoneNumber'); + console.log(number); // number value is 020 123 4567 +}); // Action var colFoo = Stamplay.Cobject('foo'); var fooMod = new colFoo.Model(); -fooMod.fetch(5).then( - function(){ - return fooMod.upVote() - } -).then( - function(){ +fooMod.fetch(5) + .then(() => fooMod.upVote()) + .then( + () => { //success callback - }, function( err : any ){ + }, (err: any) => { //error callback } ) diff --git a/stamplay-js-sdk/tslint.json b/stamplay-js-sdk/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/stamplay-js-sdk/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 643304a0f407b25c50560665b45635ff7076df34 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Tue, 14 Mar 2017 18:15:52 -0700 Subject: [PATCH 074/150] Add csprng (#15178) --- csprng/csprng-tests.ts | 5 +++++ csprng/index.d.ts | 7 +++++++ csprng/tsconfig.json | 22 ++++++++++++++++++++++ csprng/tslint.json | 3 +++ 4 files changed, 37 insertions(+) create mode 100644 csprng/csprng-tests.ts create mode 100644 csprng/index.d.ts create mode 100644 csprng/tsconfig.json create mode 100644 csprng/tslint.json diff --git a/csprng/csprng-tests.ts b/csprng/csprng-tests.ts new file mode 100644 index 0000000000..aafddc4021 --- /dev/null +++ b/csprng/csprng-tests.ts @@ -0,0 +1,5 @@ +import csprng = require("csprng"); + +let rngStr: string; + +rngStr = csprng(32, 16); diff --git a/csprng/index.d.ts b/csprng/index.d.ts new file mode 100644 index 0000000000..90aa83b017 --- /dev/null +++ b/csprng/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for csprng 0.1 +// Project: https://github.com/jcoglan/node-csprng +// Definitions by: Wink Saville +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = csprng; + +declare function csprng(bits: number, radix: number): string; diff --git a/csprng/tsconfig.json b/csprng/tsconfig.json new file mode 100644 index 0000000000..0877c1ab25 --- /dev/null +++ b/csprng/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "csprng-tests.ts" + ] +} diff --git a/csprng/tslint.json b/csprng/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/csprng/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From 295246936681b56d5a9555b25dfbe275bf0da851 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 14 Mar 2017 18:21:24 -0700 Subject: [PATCH 075/150] Add Q.try definition (#15161) * Add Q.try defintion * Persever q@0.0 * Depend on q@0.0 * Remove uneeded `/// ` * Use built-in Promise instead of Q.Promise * Remove usused path mappings * Use Q again * Use global reference instead of path mapping for q * Add dependncy on q@0.0 * Switch hystrixjs to a module * Remove import when there is a triple-slash-reference-types in the index * Use triple-slash-reference-types instead of path mapping * Update version of Q to 1.0 * Switch the file to a module and use declare global * Switch to a module * use import instead of triple-slash-reference-types * Do not use triple-slash-reference types * Switch firebase-client to a module * import q as a module * use import for q --- atom/index.d.ts | 2 +- atom/tsconfig.json | 3 + business-rules-engine/Validation.d.ts | 2 - business-rules-engine/index.d.ts | 1 - business-rules-engine/node-validators.d.ts | 1 - business-rules-engine/tsconfig.json | 3 + cordova-plugin-ibeacon/index.d.ts | 168 +- cordova-plugin-ibeacon/tsconfig.json | 3 + easy-api-request/index.d.ts | 1 - easy-api-request/tsconfig.json | 3 + firebase-client/firebase-client-tests.ts | 14 +- firebase-client/index.d.ts | 22 +- firebase-client/tsconfig.json | 3 + gulp-help-doc/tsconfig.json | 3 + gulp-help/tsconfig.json | 3 + gulp-protractor/tsconfig.json | 3 + gulp-tsd/tsconfig.json | 3 + gulp/tsconfig.json | 3 + hystrixjs/index.d.ts | 271 +- hystrixjs/tsconfig.json | 3 + microsoft-sdk-soap/index.d.ts | 5655 ++++++++--------- .../microsoft-sdk-soap-tests.ts | 3 +- microsoft-sdk-soap/tsconfig.json | 3 + mongoose-seeder/tsconfig.json | 3 + msportalfx-test/index.d.ts | 2 - msportalfx-test/tsconfig.json | 3 + node-form/index.d.ts | 2 - node-form/tsconfig.json | 3 + node-persist/index.d.ts | 1 - node-persist/tsconfig.json | 3 + o.js/index.d.ts | 4 +- o.js/tsconfig.json | 3 + orchestrator/index.d.ts | 2 - orchestrator/tsconfig.json | 3 + pathwatcher/tsconfig.json | 3 + promise-pg/index.d.ts | 1 - promise-pg/tsconfig.json | 3 + promise-pool/index.d.ts | 1 - promise-pool/tsconfig.json | 3 + q-io/index.d.ts | 282 +- q-io/q-io-tests.ts | 2 - q-io/tsconfig.json | 3 + q-retry/index.d.ts | 2 - q-retry/tsconfig.json | 3 + q/index.d.ts | 20 +- q/q-tests.ts | 11 + q/v0/index.d.ts | 357 ++ q/v0/q-tests.ts | 226 + q/v0/tsconfig.json | 26 + qajax/index.d.ts | 2 - qajax/tsconfig.json | 3 + run-sequence/tsconfig.json | 3 + status-bar/tsconfig.json | 3 + text-buffer/tsconfig.json | 3 + twilio/index.d.ts | 3 +- twilio/tsconfig.json | 3 + vso-node-api/index.d.ts | 2 +- vso-node-api/tsconfig.json | 3 + 58 files changed, 3877 insertions(+), 3296 deletions(-) create mode 100644 q/v0/index.d.ts create mode 100644 q/v0/q-tests.ts create mode 100644 q/v0/tsconfig.json diff --git a/atom/index.d.ts b/atom/index.d.ts index 7c984bd812..05c9794eec 100644 --- a/atom/index.d.ts +++ b/atom/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// /// /// @@ -1519,6 +1518,7 @@ declare var atom:AtomCore.IAtom; declare module "atom" { import spacePen = require("space-pen"); + import Q = require("q"); var $:typeof spacePen.$; var $$:typeof spacePen.$$; diff --git a/atom/tsconfig.json b/atom/tsconfig.json index 3bb8fe9761..6c1bb13aef 100644 --- a/atom/tsconfig.json +++ b/atom/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/business-rules-engine/Validation.d.ts b/business-rules-engine/Validation.d.ts index 0dd8283dc2..7f61f517be 100644 --- a/business-rules-engine/Validation.d.ts +++ b/business-rules-engine/Validation.d.ts @@ -3,8 +3,6 @@ // Definitions by: Roman Samec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare namespace Validation { interface IErrorCustomMessage { (config: any, args: any): string; diff --git a/business-rules-engine/index.d.ts b/business-rules-engine/index.d.ts index 4f71b43dfb..a74bcf180d 100644 --- a/business-rules-engine/index.d.ts +++ b/business-rules-engine/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Source: typings/business-rules-engine/Validation.d.ts -/// import * as Q from "q"; diff --git a/business-rules-engine/node-validators.d.ts b/business-rules-engine/node-validators.d.ts index 73746eef92..fa2b9cb39e 100644 --- a/business-rules-engine/node-validators.d.ts +++ b/business-rules-engine/node-validators.d.ts @@ -3,7 +3,6 @@ // Definitions by: Roman Samec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// import Validation = require("business-rules-engine"); diff --git a/business-rules-engine/tsconfig.json b/business-rules-engine/tsconfig.json index 008e622d1f..a80b05099b 100644 --- a/business-rules-engine/tsconfig.json +++ b/business-rules-engine/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/cordova-plugin-ibeacon/index.d.ts b/cordova-plugin-ibeacon/index.d.ts index bfbfe607d4..3530ccb70d 100644 --- a/cordova-plugin-ibeacon/index.d.ts +++ b/cordova-plugin-ibeacon/index.d.ts @@ -3,95 +3,97 @@ // Definitions by: Markus Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as Q from "q"; -interface CordovaPlugins { - locationManager: BeaconPlugin.LocationManager; -} - -declare namespace BeaconPlugin { - /** - * Beacon Plugin. - */ - export interface LocationManager { - delegate: Delegate; - BeaconRegion: BeaconRegion; - Region: Region; - onDomDelegateReady(): Q.Promise; - startMonitoringForRegion(region: Region): Q.Promise; - stopMonitoringForRegion(region: Region): Q.Promise; - requestStateForRegion(region: Region): Q.Promise; - startRangingBeaconsInRegion(region: Region): Q.Promise; - stopRangingBeaconsInRegion(region: Region): Q.Promise; - getAuthorizationStatus(): Q.Promise; - requestWhenInUseAuthorization(): Q.Promise; - requestAlwaysAuthorization(): Q.Promise; - getMonitoredRegions(): Q.Promise; - getRangedRegions(): Q.Promise; - isRangingAvailable(): Q.Promise; - isMonitoringAvailableForClass(region: Region): Q.Promise; - startAdvertising(region: Region, measuredPower: boolean): Q.Promise; - stopAdvertising(): Q.Promise; - isAdvertisingAvailable(): Q.Promise; - isAdvertising(): Q.Promise; - disableDebugLogs(): Q.Promise; - enableDebugNotifications(): Q.Promise; - disableDebugNotifications(): Q.Promise; - enableDebugLogs(): Q.Promise; - isBluetoothEnabled(): Q.Promise; - enableBluetooth(): Q.Promise; - disableBluetooth(): Q.Promise; - appendToDeviceLog(message: string): Q.Promise; +declare global { + interface CordovaPlugins { + locationManager: BeaconPlugin.LocationManager; } - export interface PluginResult { - eventType: string; - region: Region; - beacons: Beacon[]; - authorizationStatus: string; - state: string; - error: string; - } + namespace BeaconPlugin { + /** + * Beacon Plugin. + */ + export interface LocationManager { + delegate: Delegate; + BeaconRegion: BeaconRegion; + Region: Region; + onDomDelegateReady(): Q.Promise; + startMonitoringForRegion(region: Region): Q.Promise; + stopMonitoringForRegion(region: Region): Q.Promise; + requestStateForRegion(region: Region): Q.Promise; + startRangingBeaconsInRegion(region: Region): Q.Promise; + stopRangingBeaconsInRegion(region: Region): Q.Promise; + getAuthorizationStatus(): Q.Promise; + requestWhenInUseAuthorization(): Q.Promise; + requestAlwaysAuthorization(): Q.Promise; + getMonitoredRegions(): Q.Promise; + getRangedRegions(): Q.Promise; + isRangingAvailable(): Q.Promise; + isMonitoringAvailableForClass(region: Region): Q.Promise; + startAdvertising(region: Region, measuredPower: boolean): Q.Promise; + stopAdvertising(): Q.Promise; + isAdvertisingAvailable(): Q.Promise; + isAdvertising(): Q.Promise; + disableDebugLogs(): Q.Promise; + enableDebugNotifications(): Q.Promise; + disableDebugNotifications(): Q.Promise; + enableDebugLogs(): Q.Promise; + isBluetoothEnabled(): Q.Promise; + enableBluetooth(): Q.Promise; + disableBluetooth(): Q.Promise; + appendToDeviceLog(message: string): Q.Promise; + } - export interface Delegate { - didDetermineStateForRegion(pluginResult: PluginResult): void; - didStartMonitoringForRegion(pluginResult: PluginResult): void; - didExitRegion(pluginResult: PluginResult): void; - didEnterRegion(pluginResult: PluginResult): void; - didRangeBeaconsInRegion(pluginResult: PluginResult): void; - peripheralManagerDidStartAdvertising(pluginResult: PluginResult): void; - peripheralManagerDidUpdateState(pluginResult: PluginResult): void; - didChangeAuthorizationStatus(authorizationStatus: string): void; - monitoringDidFailForRegionWithError(pluginResult: PluginResult): void; - } + export interface PluginResult { + eventType: string; + region: Region; + beacons: Beacon[]; + authorizationStatus: string; + state: string; + error: string; + } - export interface Region { - identifier: string; - new (identifier: string): Region; - } + export interface Delegate { + didDetermineStateForRegion(pluginResult: PluginResult): void; + didStartMonitoringForRegion(pluginResult: PluginResult): void; + didExitRegion(pluginResult: PluginResult): void; + didEnterRegion(pluginResult: PluginResult): void; + didRangeBeaconsInRegion(pluginResult: PluginResult): void; + peripheralManagerDidStartAdvertising(pluginResult: PluginResult): void; + peripheralManagerDidUpdateState(pluginResult: PluginResult): void; + didChangeAuthorizationStatus(authorizationStatus: string): void; + monitoringDidFailForRegionWithError(pluginResult: PluginResult): void; + } - export interface BeaconRegion extends Region { - uuid: string; - major: string; - minor: string; - notifyEntryStateOnDisplay: boolean; - new (identifier: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion; - } + export interface Region { + identifier: string; + new (identifier: string): Region; + } - export interface CircularRegion extends Region { - latitude: number; - longitude: number; - radius: number; - new (identifier: string, latitude: number, longitude: number, radius: number): CircularRegion; - } + export interface BeaconRegion extends Region { + uuid: string; + major: string; + minor: string; + notifyEntryStateOnDisplay: boolean; + new (identifier: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion; + } - export interface Beacon { - uuid: string; - major: string; - minor: string; - proximity: string; - tx: number; - rssi: number; - accuracy: number; + export interface CircularRegion extends Region { + latitude: number; + longitude: number; + radius: number; + new (identifier: string, latitude: number, longitude: number, radius: number): CircularRegion; + } + + export interface Beacon { + uuid: string; + major: string; + minor: string; + proximity: string; + tx: number; + rssi: number; + accuracy: number; + } } -} +} \ No newline at end of file diff --git a/cordova-plugin-ibeacon/tsconfig.json b/cordova-plugin-ibeacon/tsconfig.json index 603b991c64..af70edc7f5 100644 --- a/cordova-plugin-ibeacon/tsconfig.json +++ b/cordova-plugin-ibeacon/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/easy-api-request/index.d.ts b/easy-api-request/index.d.ts index 8f4ca0d553..f04b68be3a 100644 --- a/easy-api-request/index.d.ts +++ b/easy-api-request/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: Karl Düüna // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// import stream = require('stream'); diff --git a/easy-api-request/tsconfig.json b/easy-api-request/tsconfig.json index 663d9a15d0..0f8b3873e0 100644 --- a/easy-api-request/tsconfig.json +++ b/easy-api-request/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/firebase-client/firebase-client-tests.ts b/firebase-client/firebase-client-tests.ts index 0b79ec75d6..987b4b638b 100644 --- a/firebase-client/firebase-client-tests.ts +++ b/firebase-client/firebase-client-tests.ts @@ -19,16 +19,16 @@ var client = new FirebaseClient({ var newUser:User = new User(); newUser.name = { first: "Fred", - last: "Flinstone" + last: "Flinstone" }; client.push("users", newUser) .then(function (result){ console.log(result.name); var newUser2:User = new User(); - newUser2.name = { - first: "Fred", - last: "Rockington" + newUser2.name = { + first: "Fred", + last: "Rockington" } return client.update("users/" + result.name, newUser2); }).then(function (result){ @@ -36,15 +36,15 @@ client.push("users", newUser) var newUser3:User = new User(); newUser3.name = { first: "Axe", - last: "Steel" + last: "Steel" }; return client.set("users/AXESTEEL", newUser3); }).then(function (result){ console.log(result.name.first); return client.get(); - }).then(function (result){ + }).then(function (result){ console.log(result); return client.get("users/AXESTEEL") }).then(function (result){ - console.log(result.name.first); + console.log(result.name.first); }); \ No newline at end of file diff --git a/firebase-client/index.d.ts b/firebase-client/index.d.ts index d2c58bb5ba..b766fc2478 100644 --- a/firebase-client/index.d.ts +++ b/firebase-client/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Andrew Breen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as Q from "q"; interface PushResponse { /** @@ -17,7 +17,7 @@ interface FirebaseConfig { * path for the Firebase instance */ url : string; - + /** * Token for authorisation */ @@ -29,38 +29,38 @@ interface FirebaseClient { * Creates a new FirebaseClient given the provided configuration */ new (config : FirebaseConfig) : FirebaseClient; - + /** * Retrieves all objects at the base path */ get() : Q.Promise; - + /** * Retrieves an object * @param path Relative path from the base for the resource */ get(path : string) : Q.Promise; - + /** * Returns a promise of the HTTP response from setting the value at the given path * @param path Relative path from the base for the resource * @param data Data to be set as the value for the given path */ set(path : string, data : T) : Q.Promise; - + /** * Update a node at a given path * @param path Relative path from the base for the resource * @param value Value of the response */ update(path : string, value : T) : Q.Promise; - + /** * Deletes the resource at a given path * @param path Relative path from the base for the resource */ delete(path : string) : Q.Promise; - + /** * @param path Relative path from the base for the resource * @param value Object to push to the path @@ -70,7 +70,5 @@ interface FirebaseClient { declare var FirebaseClient: FirebaseClient; -declare module 'firebase-client' { - export = FirebaseClient; -} - +export = FirebaseClient; +export as namespace FirebaseClient; diff --git a/firebase-client/tsconfig.json b/firebase-client/tsconfig.json index fdb35ab929..b439fb8310 100644 --- a/firebase-client/tsconfig.json +++ b/firebase-client/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-help-doc/tsconfig.json b/gulp-help-doc/tsconfig.json index 646e8ad141..283808fe7b 100644 --- a/gulp-help-doc/tsconfig.json +++ b/gulp-help-doc/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-help/tsconfig.json b/gulp-help/tsconfig.json index d0647ad22a..f8e499e793 100644 --- a/gulp-help/tsconfig.json +++ b/gulp-help/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-protractor/tsconfig.json b/gulp-protractor/tsconfig.json index 1141cf2042..667da98b75 100644 --- a/gulp-protractor/tsconfig.json +++ b/gulp-protractor/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-tsd/tsconfig.json b/gulp-tsd/tsconfig.json index a5738eb561..4252bbc080 100644 --- a/gulp-tsd/tsconfig.json +++ b/gulp-tsd/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp/tsconfig.json b/gulp/tsconfig.json index f6670453d1..01afedbf29 100644 --- a/gulp/tsconfig.json +++ b/gulp/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/hystrixjs/index.d.ts b/hystrixjs/index.d.ts index d4a738b999..39fef977e1 100644 --- a/hystrixjs/index.d.ts +++ b/hystrixjs/index.d.ts @@ -3,146 +3,141 @@ // Definitions by: Igor Sechyn // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// -/// +import * as Q from "q"; +import * as RX from "rx"; -declare namespace HystrixJS { +export as namespace hystrixjs; +export as namespace HystrixJS; - interface HystrixProperties { - "hystrix.force.circuit.open"?: boolean, - "hystrix.force.circuit.closed"?: boolean, - "hystrix.circuit.sleepWindowInMilliseconds"?:number, - "hystrix.circuit.errorThresholdPercentage"?: number, - "hystrix.circuit.volumeThreshold"?:number, - "hystrix.circuit.volumeThreshold.forceOverride"?: boolean, - "hystrix.circuit.volumeThreshold.override"?: number, - "hystrix.execution.timeoutInMilliseconds"?: number, - "hystrix.metrics.statistical.window.timeInMilliseconds"?: number, - "hystrix.metrics.statistical.window.bucketsNumber"?: number, - "hystrix.metrics.percentile.window.timeInMilliseconds"?: number, - "hystrix.metrics.percentile.window.bucketsNumber"?: number, - "hystrix.request.volume.rejectionThreshold"?: number - } - - interface HystrixConfig { - metricsPercentileWindowBuckets(): number; - circuitBreakerForceClosed(): boolean; - circuitBreakerForceOpened(): boolean; - circuitBreakerSleepWindowInMilliseconds(): number; - circuitBreakerErrorThresholdPercentage(): number; - circuitBreakerRequestVolumeThreshold(): number; - circuitBreakerRequestVolumeThresholdForceOverride(): boolean; - circuitBreakerRequestVolumeThresholdOverride(): number; - executionTimeoutInMilliseconds(): number; - metricsStatisticalWindowBuckets(): number; - metricsStatisticalWindowInMilliseconds(): number; - metricsPercentileWindowInMilliseconds(): number; - metricsPercentileWindowBuckets(): number; - requestVolumeRejectionThreshold(): number; - resetProperties(): void; - init(properties: HystrixProperties): void; - } - - interface Command { - execute(...args: any[]): Q.Promise; - } - - interface CommandBuilder { - circuitBreakerSleepWindowInMilliseconds(value: number): CommandBuilder; - errorHandler(value: (error: any) => boolean): CommandBuilder; - timeout(value: number): CommandBuilder; - circuitBreakerRequestVolumeThreshold(value: number): CommandBuilder; - requestVolumeRejectionThreshold(value: number): CommandBuilder; - circuitBreakerForceOpened(value: boolean): CommandBuilder; - circuitBreakerForceClosed(value: boolean): CommandBuilder; - statisticalWindowNumberOfBuckets(value: number): CommandBuilder; - statisticalWindowLength(value: number): CommandBuilder; - percentileWindowNumberOfBuckets(value: number): CommandBuilder; - percentileWindowLength(value: number): CommandBuilder; - circuitBreakerErrorThresholdPercentage(value: number): CommandBuilder; - run(value: (args: any) => Q.Promise): CommandBuilder; - fallbackTo(value: (...args: any[]) => Q.Promise): CommandBuilder; - context(value: any): CommandBuilder; - build(): Command; - } - - interface CommandFactory { - getOrCreate(commandKey: string, commandGroup?: string): CommandBuilder; - resetCache(): void; - } - - interface HealthCounts { - totalCount: number; - errorCount: number; - errorPercentage: number; - } - - interface CommandMetrics { - markSuccess(): void; - markRejected(): void; - markFailure(): void; - markTimeout(): void; - markShortCircuited(): void; - incrementExecutionCount(): void; - decrementExecutionCount(): void; - getCurrentExecutionCount(): number; - addExecutionTime(value: number): void; - getRollingCount(type: any): number; - getExecutionTime(percentile: any): number; - getHealthCounts(): HealthCounts; - reset(): void; - } - - interface MetricsProperties { - commandKey: string, - commandGroup: string, - statisticalWindowTimeInMilliSeconds?: number, - statisticalWindowNumberOfBuckets?: number, - percentileWindowTimeInMilliSeconds?: number, - percentileWindowNumberOfBuckets?: number - } - - interface MetricsFactory { - getOrCreate(config: MetricsProperties): CommandMetrics; - resetCache(): void; - getAllMetrics(): Array; - } - - interface CirctuiBreakerConfig { - circuitBreakerSleepWindowInMilliseconds: number, - commandKey: string, - circuitBreakerErrorThresholdPercentage: number, - circuitBreakerRequestVolumeThreshold: number, - commandGroup: string, - circuitBreakerForceClosed: boolean, - circuitBreakerForceOpened: boolean - } - - interface CircuitBreaker { - allowRequest(): boolean; - allowSingleTest(): boolean; - isOpen(): boolean; - markSuccess(): void; - } - - interface CircuitFactory { - getOrCreate(config: CirctuiBreakerConfig): CircuitBreaker; - getCache(): Array; - resetCache(): void; - } - - interface HystrixSSEStream { - toObservable(): Rx.Observable - } +export interface HystrixProperties { + "hystrix.force.circuit.open"?: boolean, + "hystrix.force.circuit.closed"?: boolean, + "hystrix.circuit.sleepWindowInMilliseconds"?: number, + "hystrix.circuit.errorThresholdPercentage"?: number, + "hystrix.circuit.volumeThreshold"?: number, + "hystrix.circuit.volumeThreshold.forceOverride"?: boolean, + "hystrix.circuit.volumeThreshold.override"?: number, + "hystrix.execution.timeoutInMilliseconds"?: number, + "hystrix.metrics.statistical.window.timeInMilliseconds"?: number, + "hystrix.metrics.statistical.window.bucketsNumber"?: number, + "hystrix.metrics.percentile.window.timeInMilliseconds"?: number, + "hystrix.metrics.percentile.window.bucketsNumber"?: number, + "hystrix.request.volume.rejectionThreshold"?: number } -declare var hystrixjs: { - commandFactory: HystrixJS.CommandFactory, - metricsFactory: HystrixJS.MetricsFactory, - circuitFactory: HystrixJS.CircuitFactory, - hystrixSSEStream: HystrixJS.HystrixSSEStream, - hystrixConfig: HystrixJS.HystrixConfig -}; -declare module "hystrixjs" { - export = hystrixjs; +export interface HystrixConfig { + metricsPercentileWindowBuckets(): number; + circuitBreakerForceClosed(): boolean; + circuitBreakerForceOpened(): boolean; + circuitBreakerSleepWindowInMilliseconds(): number; + circuitBreakerErrorThresholdPercentage(): number; + circuitBreakerRequestVolumeThreshold(): number; + circuitBreakerRequestVolumeThresholdForceOverride(): boolean; + circuitBreakerRequestVolumeThresholdOverride(): number; + executionTimeoutInMilliseconds(): number; + metricsStatisticalWindowBuckets(): number; + metricsStatisticalWindowInMilliseconds(): number; + metricsPercentileWindowInMilliseconds(): number; + metricsPercentileWindowBuckets(): number; + requestVolumeRejectionThreshold(): number; + resetProperties(): void; + init(properties: HystrixProperties): void; } + +export interface Command { + execute(...args: any[]): Q.Promise; +} + +export interface CommandBuilder { + circuitBreakerSleepWindowInMilliseconds(value: number): CommandBuilder; + errorHandler(value: (error: any) => boolean): CommandBuilder; + timeout(value: number): CommandBuilder; + circuitBreakerRequestVolumeThreshold(value: number): CommandBuilder; + requestVolumeRejectionThreshold(value: number): CommandBuilder; + circuitBreakerForceOpened(value: boolean): CommandBuilder; + circuitBreakerForceClosed(value: boolean): CommandBuilder; + statisticalWindowNumberOfBuckets(value: number): CommandBuilder; + statisticalWindowLength(value: number): CommandBuilder; + percentileWindowNumberOfBuckets(value: number): CommandBuilder; + percentileWindowLength(value: number): CommandBuilder; + circuitBreakerErrorThresholdPercentage(value: number): CommandBuilder; + run(value: (args: any) => Q.Promise): CommandBuilder; + fallbackTo(value: (...args: any[]) => Q.Promise): CommandBuilder; + context(value: any): CommandBuilder; + build(): Command; +} + +export interface CommandFactory { + getOrCreate(commandKey: string, commandGroup?: string): CommandBuilder; + resetCache(): void; +} + +export interface HealthCounts { + totalCount: number; + errorCount: number; + errorPercentage: number; +} + +export interface CommandMetrics { + markSuccess(): void; + markRejected(): void; + markFailure(): void; + markTimeout(): void; + markShortCircuited(): void; + incrementExecutionCount(): void; + decrementExecutionCount(): void; + getCurrentExecutionCount(): number; + addExecutionTime(value: number): void; + getRollingCount(type: any): number; + getExecutionTime(percentile: any): number; + getHealthCounts(): HealthCounts; + reset(): void; +} + +export interface MetricsProperties { + commandKey: string, + commandGroup: string, + statisticalWindowTimeInMilliSeconds?: number, + statisticalWindowNumberOfBuckets?: number, + percentileWindowTimeInMilliSeconds?: number, + percentileWindowNumberOfBuckets?: number +} + +export interface MetricsFactory { + getOrCreate(config: MetricsProperties): CommandMetrics; + resetCache(): void; + getAllMetrics(): Array; +} + +export interface CirctuiBreakerConfig { + circuitBreakerSleepWindowInMilliseconds: number, + commandKey: string, + circuitBreakerErrorThresholdPercentage: number, + circuitBreakerRequestVolumeThreshold: number, + commandGroup: string, + circuitBreakerForceClosed: boolean, + circuitBreakerForceOpened: boolean +} + +export interface CircuitBreaker { + allowRequest(): boolean; + allowSingleTest(): boolean; + isOpen(): boolean; + markSuccess(): void; +} + +export interface CircuitFactory { + getOrCreate(config: CirctuiBreakerConfig): CircuitBreaker; + getCache(): Array; + resetCache(): void; +} + +export interface HystrixSSEStream { + toObservable(): Rx.Observable +} + +export var commandFactory: CommandFactory; +export var metricsFactory: MetricsFactory; +export var circuitFactory: CircuitFactory; +export var hystrixSSEStream: HystrixSSEStream; +export var hystrixConfig: HystrixConfig; \ No newline at end of file diff --git a/hystrixjs/tsconfig.json b/hystrixjs/tsconfig.json index c23c0c6875..e1cb1a7c4d 100644 --- a/hystrixjs/tsconfig.json +++ b/hystrixjs/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/microsoft-sdk-soap/index.d.ts b/microsoft-sdk-soap/index.d.ts index 9effce35ad..de1c43db12 100644 --- a/microsoft-sdk-soap/index.d.ts +++ b/microsoft-sdk-soap/index.d.ts @@ -3,2968 +3,2869 @@ // Definitions by: Markus Mauch // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - -declare namespace Sdk -{ - interface IEntityView - { - attributes: AttributeCollection; - entityState: EntityState; - id: string; - logicalName: string; - relatedEntities: RelatedEntityCollection; - } - - interface IEntityCollectionView - { - entityName: string; - entities: Array; - minActiveRowVersion: string; - moreRecords: boolean; - pagingCookie: string; - totalRecordCount: number; - totalRecordCountLimitExceeded: boolean; - } - - interface IEntityReferenceView - { - Id: string; - Type: string; - Name: string; - } - - interface IEntityReferenceCollectionView extends Array - { - } - - class Q - { - /** - * Creates a link between records. - * @param entityName The logical name of the entity that is specified in the entityId parameter. - * @param entityId The ID of the record to which the related records are associated. - * @param relationship The name of the relationship to be used to create the link. - * @param relatedEntities A collection of Sdk.EntityReference objects to be associated. - */ - static associate( entityName: string, entityId: string, relationship: string, relatedEntities: Sdk.Collection ): Q.Promise; - /** - * Creates an entity record and returns a string representation of the GUID value that is the Id of the created entity. - * @param entity An entity instance. - */ - static create( entity: Sdk.Entity ): Q.Promise; - - /** - * Deletes an entity record - * @param entityName The LogicalName of the entity to delete. - * @param id An ID of the record to delete. - */ - static del( entityName: string, id: string ): Q.Promise; - - /** - * Removes a link between records. - * @param entityName The logical name of the entity that is specified in the entityId parameter. - * @param entityId The ID of the record to which the related records are disassociated. - * @param relationship The name of the relationship to be used to remove the link. - * @param relatedEntities A collection of Sdk.EntityReference objects to be disassociated. - */ - static disassociate( entityName: string, entityId: string, relationship: string, relatedEntities: Sdk.Collection ): Q.Promise; - - /** - * Executes a SOAP Request using the SOAPAction Execute. - * @param request A request object. - */ - static execute( request: Sdk.OrganizationRequest ): Q.Promise; - - /** - * Retrieves an entity instance. - * @param entityName The logical name of the entity to retrieve. - * @param id The id of the entity to retrieve. - * @param columnSet The columns of the entities to retrieve. - */ - static retrieve( entityName: string, id: string, columnSet: Sdk.ColumnSet ): Q.Promise; - - /** - * Retrieves the results of a query - * @param query An Sdk.Query.QueryByAttribute query. - */ - static retrieveMultiple( query: Sdk.Query.QueryByAttribute ): Q.Promise; - - /** - * Retrieves the results of a query - * @param query An Sdk.Query.QueryExpression query. - */ - static retrieveMultiple( query: Sdk.Query.QueryExpression ): Q.Promise; - - /** - * Retrieves the results of a query - * @param query An Sdk.Query.FetchExpression query. - */ - static retrieveMultiple( query: Sdk.Query.FetchExpression ): Q.Promise; - - /** - * Updates an entity instance. - * @param entity An entity instance to update. - */ - static update( entity: Entity ): Q.Promise; - } - - class ColumnSet - { - /** - * Specifies the attributes for which non- null values are returned from a query. - * @param columns Comma separated string values for attribute logical names. - */ - constructor( ...columns: string[] ); - - /** - * Specifies the attributes for which non- null values are returned from a query. - * @param columns An array of string values. - */ - constructor( columns: string[] ); - - /** - * Specifies the attributes for which non- null values are returned from a query. - * @param allColumns If Boolean true value is passed as the first parameter all columns will be included. (Not recommended for production code). - */ - constructor( allColumns: boolean ); - - /** - * Gets the collection of column names. - * @returns The collection of column names. - */ - getColumns(): Sdk.Collection; - - /** - * Adds a column to the collection. - * @param column The logical name of the attribute to add. - */ - addColumn( column: string ): void; - - /** - * Adds a string array of column names. - * @param columns A string array of column names. - */ - addColumns( columns: Array ): void; - - /** - * Sets the AllColumns property. - * @params allColumns A boolean value. - */ - setAllColumns( allColumns: boolean ): void; - - /** - * Whether all columns will be returned. - */ - getAllColumns(): boolean; - - /** - * Gets the number of columns. - */ - getCount(): number; - - - /// prototype methods - - /** - * Removes a column from the ColumnSet. - * @param columnName The logical name of an attribute to be removed from the ColumnSet. - * @param errorIfNotFound Whether to throw an error when the column to remove is not found. The default is false - */ - removeColumn( columnName: string, errorIfNotFound?: boolean ): void; - - /** - * The XML node with "" as the root element. - */ - toXml(): string; - - /** - * XML nodes for columnSet properties. - */ - toValueXml(): string; - } - - class ValueType - { - } - - class Collection - { - /** - * A Collection for a specified type. - * @param type The function that specifies the type. - * @param items An array of items to add to the collection. - */ - constructor( type: T, items?: Array ); - - /** - * Gets the type defined for the collection. - */ - getType(): T; - - /** - * Adds an item to the collection. - * @param item An item to add to the collection. - */ - add( item: T ): void; - - /** - * Adds an array of objects to the collection. - * @param items An array of items to add to the collection. - */ - addRange( items: any[] ): void; - - /** - * Removes all items from the collection. - */ - clear(): void; - - /** - * Returns whether an object exists within the collection. - * @param item The item to search in the collection. - */ - contains( item: T ): boolean; - - /** - * Returns whether an object exists within the collection. - * @param predicate A comparer function which is invoked for each item of the collection. - */ - contains( predicate: ( item: T ) => boolean ): boolean; - - /** - * Returns an Sdk.Collection that contains all the items of this collection that satisfy the specified predicate function. - * @param predicate A predicate function that takes a collection item as argument and returns a boolean. - */ - select( predicate: ( item: T ) => boolean ): Collection; - - /** - * Applies the action contained within a delegate function. - * @param fn Delegate function with parameters for item and index. - */ - forEach( fn: ( item: T, index: number ) => any ): void; - - /** - * Gets the item in the collection at the specified index. - * @param index The index of the item to return. - */ - getByIndex( index: number ): T; - - /** - * Removes an item from the collection. - * @param item A reference to the item to be removed. - */ - remove( item: T ): void; - - /** - * Gets a copy of the array of items in the collection. - */ - toArray(): Array; - - /** - * Returns the number of items in the collection. - */ - getCount(): number; - } - - class EntityCollection - { - /** - * Contains a collection of entity instances. - * @param entities Initializes a new instance of the EntityCollection class setting the Sdk.Collection of Sdk.Entity objects. - */ - constructor( entities: Sdk.Collection ); - - /** - * Adds an entity to the collection. - * @param entity - */ - addEntity( entity: Sdk.Entity ): void; - - /** - * Gets the collection of entities. - */ - getEntities(): Sdk.Collection; - - /** - * Gets an entity in the collection. - * @param index The index of the entity in the collection. - */ - getEntity( index: number ): Sdk.Entity; - - /** - * Gets an entity in the collection. - * @param id The id of the entity in the collection. - */ - getEntity( id: Sdk.Guid ): Sdk.Entity; - - /** - * Sets an item in the collection. - * @param index The index of the entity in the collection. - * @param value The Sdk.Entity value to set. - */ - setEntity( index: number, value: Sdk.Entity ): void; - - /** - * Sets an item in the collection. - * @param id The Sdk.Guid id of the entity in the collection. - * @param value The Sdk.Entity value to set. - */ - setEntity( id: Sdk.Guid, value: Sdk.Entity ): void; - - /** - * Gets the logical name of the entity. - */ - getEntityName(): string; - - /** - * Sets the logical name of the entity. - * @param name The logical name of the entity. - */ - setEntityName( name: string ): void; - - /** - * Gets the lowest active row version value. - */ - getMinActiveRowVersion(): string; - - /** - * Sets the lowest active row version value. - * @param minActiveRowVersion The lowest active row version value. - */ - setMinActiveRowVersion( minActiveRowVersion: string ): void; - - /** - * Gets whether there are more records available. - */ - getMoreRecords(): boolean; - - /** - * Sets whether there are more records available. - * @param moreRecords Whether there are more records available. - */ - setMoreRecords( moreRecords: boolean ): void; - - /** - * Gets the current paging information. - */ - getPagingCookie(): string; - - /** - * Sets the current paging information. - * @param pagingCookie The current paging information. - */ - setPagingCookie( pagingCookie: string ): void; - - /** - * Gets the total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. - */ - getTotalRecordCount(): number; - - /** - * Sets the total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. - * @param totalRecordCount The total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. - */ - setTotalRecordCount( totalRecordCount: number ): void; - - /** - * Gets whether the results of the query exceeds the total record count. - */ - getTotalRecordCountLimitExceeded(): boolean; - - /** - * Sets whether the results of the query exceeds the total record count. - * @param totalRecordCountLimitExceeded Whether the results of the query exceeds the total record count. - */ - setTotalRecordCountLimitExceeded( totalRecordCountLimitExceeded: boolean ): void; - - /** - * XML definition of an the child nodes of an entity. - */ - toValueXml(): string; - - /** - * Returns a view of the entity collection - */ - view(): IEntityCollectionView; - } - - class EntityReferenceCollection - { - /** - * Contains a collection of EntityReference instances. - * @param entityReferences Initializes a new instance of the EntityReferenceCollection class setting the Sdk.Collection of Sdk.EntityReference objects. - */ - constructor( entityReferences?: Sdk.Collection ); - - /** - * Gets the collection of entity references. - */ - getEntityReferences(): Sdk.Collection; - - /** - * Sets the collection of entity references. - * @param entityReferences The entity references - */ - setEntityReferences( entityReferences: Sdk.Collection ): void; - - - /// prototype methods - - /** - * Removes an entity reference to the collection. - * @param entityReference The entity reference to remove. - */ - remove( entityReference: Sdk.EntityReference ): void; - - /** - * Returns a view of the data in an entity reference collection instance. - */ - view(): IEntityReferenceCollectionView; - - /** - * Returns the values of serialized entity reference collection as XML nodes. - */ - toValueXml(): string; - } - - class RelatedEntityCollection extends EntityCollection - { - } - - class AttributeCollection extends Collection - { - constructor(); - - /** - * Adds an attribute to the Attribute Collection. - * @param attribute The attribute to add. - * @param isChanged Override the the attribute IsChanged value. - */ - add( attribute: AttributeBase, isChanged?: boolean ): void; - - /** - * Gets the attributes in the collection. - */ - getAttributes(): Collection; - - - /// prototype methods - - /** - * Allows for a delegate function to be applied to each attribute in the collection. - * @param fm The function to be applied. Function should have parameters for the attribute and the iterator i.e.: '(att,i)' - */ - forEach( fn: ( attribute: AttributeBase, index: number ) => any ): void; - - /** - * Returns all attributes in the collection. - */ - get(): Sdk.Collection; - - /** - * Returns the attribute with matching name. - * @param attribuetName - */ - get( attribuetName: string ): AttributeBase; - - /** - * Returns the attribute with matching index. - * @param attribuetName - */ - get( index: number ): AttributeBase; - - /** - * Gets an attribute at a given index. - * @param index The index. - */ - getAttributeByIndex( index: number ): AttributeBase; - - /** - * Gets an attribute with a given name. - * @param name The Logical name of the attribute. - */ - getAttributeByName( name: string ): AttributeBase; - - /** - * Gets an array of the names of attributes in a collection. - */ - getNames(): Array; - /** - * The XML for an attribute collection. - */ - toXml( action: string ): string; - } - - class FormattedValueCollection - { - } - - class RelatedEntitiesCollection - { - } - - class AttributeBase - { - /** - * Gets whether the value of the attribute has changed. - */ - getIsChanged(): boolean; - - /** - * Gets the logical name of the attribute. - */ - getName(): string; - - /** - * Gets the value type of the attribute. - */ - getType(): Sdk.ValueType; - - /** - * Gets the value of the attribute. - * The type of value depends on the type of attribute. - */ - getValue(): any; - - /** - * Whether the value of the attribute is set. - */ - isValueSet(): boolean; - - /** - * Sets whether the value of the attribute has changed. - * @param isChanged Whether the value of the attribute has changed. - */ - setIsChanged( isChanged: boolean ): void; - - /** - * Sets the name of the attribute - * @param name The name of the attribute. - */ - setName( name: string ): void; - - /** - * For internal use only. - * @param type The type of the attribute. - */ - setType( type: Sdk.ValueType ): void; - - /** - * Sets the general value of the attribute - * @param name The value of the attribute. - */ - setValue( value: any ): void; - - /// prototype methods - /** - * XML node for Attribute. - */ - toXml( action: string ): string; - } - - class Boolean extends AttributeBase - { - /** - * A Boolean Attribute. - * @param name The logical name of the attribute . - * @param value The value of the managed property. - */ - constructor( name: string, value?: boolean ) - - /** - * Gets the value of a Boolean attribute. - */ - getValue(): boolean; - - /** - * Sets the value of a Boolean attribute. - * @param value - */ - setValue( value: boolean ): void; - } - - class DateTime extends AttributeBase - { - /** - * A DateTime Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: Date ); - - /** - * Gets the value of a DateTime attribute. - */ - getValue(): Date; - - /** - * Sets the value of a DateTime attribute. - * @param value The value to set. - */ - setValue( value: Date ): void; - } - - class Decimal extends AttributeBase - { - /** - * A Decimal Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a Decimal attribute. - */ - getValue(): number; - - /** - * Sets the value of a Decimal attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class Double - { - /** - * A Double Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a Double attribute. - */ - getValue(): number; - - /** - * Sets the value of a Double attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class Guid extends AttributeBase - { - /** - * A Guid Attribute. - * @param name The logical name of the attribute. - * @param value" The value of the attribute - */ - constructor( name: string, value?: string ); - - /** - * Gets the value of a Guid attribute. - */ - getValue(): string; - - /** - * Sets the value of a Guid attribute. - * @param value The value to set. - */ - setValue( value: string ): void; - } - - class Int extends AttributeBase - { - /** - * An Integer Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of an Integer attribute. - */ - getValue(): number; - - /** - * Sets the value of an Integer attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class Long extends AttributeBase - { - /** - * A Long Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a Long attribute. - */ - getValue(): number; - - /** - * Sets the value of a Long attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class Lookup extends AttributeBase - { - /** - * A Lookup Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: EntityReference ); - - /** - * Gets the value of a Lookup attribute. - */ - getValue(): EntityReference; - - /** - * Sets the value of a Lookup attribute. - * @param value The value to set. - */ - setValue( value: EntityReference ): void; - } - - class Money extends AttributeBase - { - /** - * A Money Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a Money attribute. - */ - getValue(): number; - - /** - * Sets the value of a Money attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class OptionSet extends AttributeBase - { - /** - * An OptionSet Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a OptionSet attribute. - */ - getValue(): number; - - /** - * Sets the value of an OptionSet attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class PartyList extends AttributeBase - { - /** - * A PartyList Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: EntityCollection ); - - /** - * Gets the value of a PartyList attribute. - */ - getValue(): EntityCollection; - - /** - * Sets the value of a PartyList attribute. - * @param value The value to set. - */ - setValue( value: EntityCollection ): void; - } - - class String extends AttributeBase - { - /** - * A String Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: string ); - - /** - * Gets the value of a String attribute. - */ - getValue(): string; - - /** - * Sets the value of a String attribute. - * @param value The value to set. - */ - setValue( value: string ): void; - } - - class EntityState - { - } - - class Entity - { - /** - * Represents an instance of an entity (a record). - * @param type The logical name of the entity. - */ - constructor( type: string ); - - /** - * Gets the collection of attributes for the entity. - */ - getAttributes(): Sdk.AttributeCollection; - - /** - * Gets the collection of attributes for the entity. - * @param attributeName The attribute with matching name is returned. - */ - getAttributes( attributeName: string ): Sdk.AttributeBase; - - /** - * Gets the collection of attributes for the entity. - * @param index The attribute with matching index is returned. - */ - getAttributes( index: number ): Sdk.AttributeBase; - - /** - * Checks whether the entity has an attribute that satisfies the specified predicate. - * @param A comparer function that takes an Sdk.AttributeBase as argument and returns a boolean. - */ - containsAttribute( predicate: ( attribute: Sdk.AttributeBase ) => boolean ): boolean; - - /** - * Checks whether the entity has an attribute with the specified name. - * @param The name of the attribute. - */ - containsAttribute( name: string ): boolean; - - /** - * Sets the collection of attributes for the entity. - * @param attributes The collection of attributes for the entity. - */ - setAttributes( attributes: Sdk.AttributeCollection ): void; - - /** - * Gets the state of the entity. - */ - getEntityState(): Sdk.EntityState; - - /** - * Sets the state of the entity. - * @param state The state of the entity. - */ - setEntityState( state: Sdk.EntityState ): void; - - /** - * Gets the collection of formatted values for the entity attributes. - */ - getFormattedValues(): Sdk.FormattedValueCollection; - - /** - * Sets the collection of formatted values for the entity attributes. - * @param values" The collection of formatted values for the entity attributes. - */ - setFormattedValues( values: Sdk.FormattedValueCollection ): void; - - /** - * Gets the Id of the record represented by this entity instance. - */ - getId(): string; - - /** - * Sets the Id of the record represented by this entity instance. - * @param id The Id of the record represented by this entity instance. - * @param override Allow setting the Id property, for example when creating a new record from an existing one. - */ - setId( id: string, override?: boolean ): void; - - /** - * Gets the logical name of the entity. - */ - getType(): string; - - /** - * Sets the logical name of the entity. - * @param type The logical name of the entity. - */ - setType( type: string ): void; - - /** - * Gets a collection of related entities. - */ - getRelatedEntities(): Sdk.RelatedEntitiesCollection; - - /** - * Sets a collection of related entities. - * @param relatedEntities A collection of related entities. - */ - setRelatedEntities( relatedEntities: Sdk.RelatedEntitiesCollection ): void; - - /** - * Adds an attribute with an optional value to a newly instantiated Sdk.Entity - * @param attribute The attribute to add - * @param isChanged Whether the attribute should be considered changed, the default is true. - */ - addAttribute( attribute: Sdk.AttributeBase, isChanged?: boolean ): void; - - /** - * Adds an entity to the related entities. - * @param relationshipSchemaName The relationship SchemaName. - * @param entity The entity to add. - */ - addRelatedEntity( relationshipSchemaName: string, entity: Sdk.Entity ): void; - - /** - * Gets the value to indicate whether data for the entity has changed. - */ - getIsChanged(): boolean; - - /** - * Sets the value to indicate whether data for the entity has changed. - * @param isChanged The value to indicate whether data for the entity has changed. - */ - setIsChanged( isChanged: boolean ): void; - - /** - * Gets the value of the specified attribute. - * @param logicalName The logical name of the attribute. - */ - getValue( logicalName: string ): any; - - /** - * Generates properties for the entity based on metadata. - */ - initializeSubClass( metadata: Sdk.Mdq.IEntityMetadata ): void; - - /** - * Sets the value of the specified attribute. - * @param logicalName The logical name of the attribute. - * @param value The value for the attribute. Simple JavaScript types may be used for most attribute types. Sdk.EntityReference, Sdk.EntityCollection, and Sdk.BooleanManagedPropertyValue cannot use simple JavaScript types. - */ - setValue( logicalName: string, value: Object ): void; - - /** - * Generates an entity reference. - */ - toEntityReference(): Sdk.EntityReference; - - /** - * Overrides the default toString method. - */ - toString(): string; - - /** - * XML definition of an the child nodes of an entity. - * @param action - */ - toValueXml( action: string ): string; - - /** - * XML definition of an entity where the root node is . - */ - toXml( action: string ): string; - - /** - * Returns a view of the data in an entity instance - */ - view(): IEntityView; - } - - class EntityReference - { - /** - * Identifies a record. - * @param logicalName The logical name of the entity. - * @param id The id of the record. - * @param name The value of the primary attribute of the entity instance. This property can contain a value or null. This property is not automatically populated unless the EntityReference object has been retrieved from the server. - */ - constructor( logicalName: string, id: string, name?: string ); - - /** - * Gets the logicalName representing the type of referenced entity. - */ - getType(): string; - - /** - * Gets the Id value of the referenced entity. - */ - getId(): string; - - /** - * Gets the primary attribute value of the referenced entity. - */ - getName(): string; - - /** - * Sets the logicalName representing the type of referenced entity. - * @param type The logicalName representing the type of referenced entity. - */ - setType( type: string ): void; - - /** - * Sets the Id value of the entity. - * @param id The Id value of the entity. - */ - setId( id: string ): void; - - /** - * Sets the primary attribute value of the referenced entity. - * @param name The primary attribute value of the referenced entity. - */ - setName( name: string ): void; - - - /// prototype methods - - /** - * Returns a serialized entity reference where the root element is . - */ - toXml(): string; - - /** - * Returns the values of serialized entity reference as XML nodes. - */ - toValueXml(): string; - - /** - * Returns a view of the data in an EntityReference - */ - view(): IEntityReferenceView; - } - - class OrganizationRequest - { - /** - * Sets the request XML. - * @param xml The request XML. - */ - setRequestXml( xml: string ): void; - - /** - * Gets the request XML. - */ - getRequestXml(): string; - - /** - * Sets the response type. - * @param type A class that inherits from Sdk.OrganizationResponse. - */ - setResponseType( type: OrganizationResponse ): void; - - /** - * Gets the response type. - */ - getResponseType(): OrganizationResponse; - } - - class OrganizationResponse - { - } - - /** - * Contains the data that is needed to convert a query in FetchXML to a QueryExpression. - * @param fetchXml Sets the query to convert. - */ - class FetchXmlToQueryExpressionRequest extends Sdk.OrganizationRequest - { - constructor( fetchXml: string ); - - /** - * Sets the query to convert. - * @param The query to convert. - */ - setFetchXml( value: string ): void; - } - - /** - * Response to FetchXmlToQueryExpressionRequest. - * @param responseXml The response XML to the FetchXmlToQueryExpressionRequest. - */ - class FetchXmlToQueryExpressionResponse extends Sdk.OrganizationResponse - { - constructor( responseXml: string ); - - /** - * Gets the results of the query conversion. - */ - public getQuery(): Query.QueryExpression; - } - - /** - * Contains the data that is needed to convert a query, which is represented as a QueryExpression class, to its equivalent query, which is represented as FetchXML. - * @param query The query. - */ - class QueryExpressionToFetchXmlRequest extends Sdk.OrganizationRequest - { - constructor( query: Sdk.Query.QueryBase ); - - /** - * Sets the query to convert. +import * as Q from "q"; + +declare global { + namespace Sdk { + interface IEntityView { + attributes: AttributeCollection; + entityState: EntityState; + id: string; + logicalName: string; + relatedEntities: RelatedEntityCollection; + } + + interface IEntityCollectionView { + entityName: string; + entities: Array; + minActiveRowVersion: string; + moreRecords: boolean; + pagingCookie: string; + totalRecordCount: number; + totalRecordCountLimitExceeded: boolean; + } + + interface IEntityReferenceView { + Id: string; + Type: string; + Name: string; + } + + interface IEntityReferenceCollectionView extends Array { + } + + class Q { + /** + * Creates a link between records. + * @param entityName The logical name of the entity that is specified in the entityId parameter. + * @param entityId The ID of the record to which the related records are associated. + * @param relationship The name of the relationship to be used to create the link. + * @param relatedEntities A collection of Sdk.EntityReference objects to be associated. + */ + static associate(entityName: string, entityId: string, relationship: string, relatedEntities: Sdk.Collection): Q.Promise; + /** + * Creates an entity record and returns a string representation of the GUID value that is the Id of the created entity. + * @param entity An entity instance. + */ + static create(entity: Sdk.Entity): Q.Promise; + + /** + * Deletes an entity record + * @param entityName The LogicalName of the entity to delete. + * @param id An ID of the record to delete. + */ + static del(entityName: string, id: string): Q.Promise; + + /** + * Removes a link between records. + * @param entityName The logical name of the entity that is specified in the entityId parameter. + * @param entityId The ID of the record to which the related records are disassociated. + * @param relationship The name of the relationship to be used to remove the link. + * @param relatedEntities A collection of Sdk.EntityReference objects to be disassociated. + */ + static disassociate(entityName: string, entityId: string, relationship: string, relatedEntities: Sdk.Collection): Q.Promise; + + /** + * Executes a SOAP Request using the SOAPAction Execute. + * @param request A request object. + */ + static execute(request: Sdk.OrganizationRequest): Q.Promise; + + /** + * Retrieves an entity instance. + * @param entityName The logical name of the entity to retrieve. + * @param id The id of the entity to retrieve. + * @param columnSet The columns of the entities to retrieve. + */ + static retrieve(entityName: string, id: string, columnSet: Sdk.ColumnSet): Q.Promise; + + /** + * Retrieves the results of a query + * @param query An Sdk.Query.QueryByAttribute query. + */ + static retrieveMultiple(query: Sdk.Query.QueryByAttribute): Q.Promise; + + /** + * Retrieves the results of a query + * @param query An Sdk.Query.QueryExpression query. + */ + static retrieveMultiple(query: Sdk.Query.QueryExpression): Q.Promise; + + /** + * Retrieves the results of a query + * @param query An Sdk.Query.FetchExpression query. + */ + static retrieveMultiple(query: Sdk.Query.FetchExpression): Q.Promise; + + /** + * Updates an entity instance. + * @param entity An entity instance to update. + */ + static update(entity: Entity): Q.Promise; + } + + class ColumnSet { + /** + * Specifies the attributes for which non- null values are returned from a query. + * @param columns Comma separated string values for attribute logical names. + */ + constructor(...columns: string[]); + + /** + * Specifies the attributes for which non- null values are returned from a query. + * @param columns An array of string values. + */ + constructor(columns: string[]); + + /** + * Specifies the attributes for which non- null values are returned from a query. + * @param allColumns If Boolean true value is passed as the first parameter all columns will be included. (Not recommended for production code). + */ + constructor(allColumns: boolean); + + /** + * Gets the collection of column names. + * @returns The collection of column names. + */ + getColumns(): Sdk.Collection; + + /** + * Adds a column to the collection. + * @param column The logical name of the attribute to add. + */ + addColumn(column: string): void; + + /** + * Adds a string array of column names. + * @param columns A string array of column names. + */ + addColumns(columns: Array): void; + + /** + * Sets the AllColumns property. + * @params allColumns A boolean value. + */ + setAllColumns(allColumns: boolean): void; + + /** + * Whether all columns will be returned. + */ + getAllColumns(): boolean; + + /** + * Gets the number of columns. + */ + getCount(): number; + + + /// prototype methods + + /** + * Removes a column from the ColumnSet. + * @param columnName The logical name of an attribute to be removed from the ColumnSet. + * @param errorIfNotFound Whether to throw an error when the column to remove is not found. The default is false + */ + removeColumn(columnName: string, errorIfNotFound?: boolean): void; + + /** + * The XML node with "" as the root element. + */ + toXml(): string; + + /** + * XML nodes for columnSet properties. + */ + toValueXml(): string; + } + + class ValueType { + } + + class Collection + { + /** + * A Collection for a specified type. + * @param type The function that specifies the type. + * @param items An array of items to add to the collection. + */ + constructor(type: T, items?: Array); + + /** + * Gets the type defined for the collection. + */ + getType(): T; + + /** + * Adds an item to the collection. + * @param item An item to add to the collection. + */ + add(item: T): void; + + /** + * Adds an array of objects to the collection. + * @param items An array of items to add to the collection. + */ + addRange(items: any[]): void; + + /** + * Removes all items from the collection. + */ + clear(): void; + + /** + * Returns whether an object exists within the collection. + * @param item The item to search in the collection. + */ + contains(item: T): boolean; + + /** + * Returns whether an object exists within the collection. + * @param predicate A comparer function which is invoked for each item of the collection. + */ + contains(predicate: (item: T) => boolean): boolean; + + /** + * Returns an Sdk.Collection that contains all the items of this collection that satisfy the specified predicate function. + * @param predicate A predicate function that takes a collection item as argument and returns a boolean. + */ + select(predicate: (item: T) => boolean): Collection; + + /** + * Applies the action contained within a delegate function. + * @param fn Delegate function with parameters for item and index. + */ + forEach(fn: (item: T, index: number) => any): void; + + /** + * Gets the item in the collection at the specified index. + * @param index The index of the item to return. + */ + getByIndex(index: number): T; + + /** + * Removes an item from the collection. + * @param item A reference to the item to be removed. + */ + remove(item: T): void; + + /** + * Gets a copy of the array of items in the collection. + */ + toArray(): Array; + + /** + * Returns the number of items in the collection. + */ + getCount(): number; + } + + class EntityCollection { + /** + * Contains a collection of entity instances. + * @param entities Initializes a new instance of the EntityCollection class setting the Sdk.Collection of Sdk.Entity objects. + */ + constructor(entities: Sdk.Collection); + + /** + * Adds an entity to the collection. + * @param entity + */ + addEntity(entity: Sdk.Entity): void; + + /** + * Gets the collection of entities. + */ + getEntities(): Sdk.Collection; + + /** + * Gets an entity in the collection. + * @param index The index of the entity in the collection. + */ + getEntity(index: number): Sdk.Entity; + + /** + * Gets an entity in the collection. + * @param id The id of the entity in the collection. + */ + getEntity(id: Sdk.Guid): Sdk.Entity; + + /** + * Sets an item in the collection. + * @param index The index of the entity in the collection. + * @param value The Sdk.Entity value to set. + */ + setEntity(index: number, value: Sdk.Entity): void; + + /** + * Sets an item in the collection. + * @param id The Sdk.Guid id of the entity in the collection. + * @param value The Sdk.Entity value to set. + */ + setEntity(id: Sdk.Guid, value: Sdk.Entity): void; + + /** + * Gets the logical name of the entity. + */ + getEntityName(): string; + + /** + * Sets the logical name of the entity. + * @param name The logical name of the entity. + */ + setEntityName(name: string): void; + + /** + * Gets the lowest active row version value. + */ + getMinActiveRowVersion(): string; + + /** + * Sets the lowest active row version value. + * @param minActiveRowVersion The lowest active row version value. + */ + setMinActiveRowVersion(minActiveRowVersion: string): void; + + /** + * Gets whether there are more records available. + */ + getMoreRecords(): boolean; + + /** + * Sets whether there are more records available. + * @param moreRecords Whether there are more records available. + */ + setMoreRecords(moreRecords: boolean): void; + + /** + * Gets the current paging information. + */ + getPagingCookie(): string; + + /** + * Sets the current paging information. + * @param pagingCookie The current paging information. + */ + setPagingCookie(pagingCookie: string): void; + + /** + * Gets the total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. + */ + getTotalRecordCount(): number; + + /** + * Sets the total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. + * @param totalRecordCount The total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. + */ + setTotalRecordCount(totalRecordCount: number): void; + + /** + * Gets whether the results of the query exceeds the total record count. + */ + getTotalRecordCountLimitExceeded(): boolean; + + /** + * Sets whether the results of the query exceeds the total record count. + * @param totalRecordCountLimitExceeded Whether the results of the query exceeds the total record count. + */ + setTotalRecordCountLimitExceeded(totalRecordCountLimitExceeded: boolean): void; + + /** + * XML definition of an the child nodes of an entity. + */ + toValueXml(): string; + + /** + * Returns a view of the entity collection + */ + view(): IEntityCollectionView; + } + + class EntityReferenceCollection { + /** + * Contains a collection of EntityReference instances. + * @param entityReferences Initializes a new instance of the EntityReferenceCollection class setting the Sdk.Collection of Sdk.EntityReference objects. + */ + constructor(entityReferences?: Sdk.Collection); + + /** + * Gets the collection of entity references. + */ + getEntityReferences(): Sdk.Collection; + + /** + * Sets the collection of entity references. + * @param entityReferences The entity references + */ + setEntityReferences(entityReferences: Sdk.Collection): void; + + + /// prototype methods + + /** + * Removes an entity reference to the collection. + * @param entityReference The entity reference to remove. + */ + remove(entityReference: Sdk.EntityReference): void; + + /** + * Returns a view of the data in an entity reference collection instance. + */ + view(): IEntityReferenceCollectionView; + + /** + * Returns the values of serialized entity reference collection as XML nodes. + */ + toValueXml(): string; + } + + class RelatedEntityCollection extends EntityCollection { + } + + class AttributeCollection extends Collection + { + constructor(); + + /** + * Adds an attribute to the Attribute Collection. + * @param attribute The attribute to add. + * @param isChanged Override the the attribute IsChanged value. + */ + add(attribute: AttributeBase, isChanged?: boolean): void; + + /** + * Gets the attributes in the collection. + */ + getAttributes(): Collection; + + + /// prototype methods + + /** + * Allows for a delegate function to be applied to each attribute in the collection. + * @param fm The function to be applied. Function should have parameters for the attribute and the iterator i.e.: '(att,i)' + */ + forEach(fn: (attribute: AttributeBase, index: number) => any): void; + + /** + * Returns all attributes in the collection. + */ + get(): Sdk.Collection; + + /** + * Returns the attribute with matching name. + * @param attribuetName + */ + get(attribuetName: string): AttributeBase; + + /** + * Returns the attribute with matching index. + * @param attribuetName + */ + get(index: number): AttributeBase; + + /** + * Gets an attribute at a given index. + * @param index The index. + */ + getAttributeByIndex(index: number): AttributeBase; + + /** + * Gets an attribute with a given name. + * @param name The Logical name of the attribute. + */ + getAttributeByName(name: string): AttributeBase; + + /** + * Gets an array of the names of attributes in a collection. + */ + getNames(): Array; + /** + * The XML for an attribute collection. + */ + toXml(action: string): string; + } + + class FormattedValueCollection { + } + + class RelatedEntitiesCollection { + } + + class AttributeBase { + /** + * Gets whether the value of the attribute has changed. + */ + getIsChanged(): boolean; + + /** + * Gets the logical name of the attribute. + */ + getName(): string; + + /** + * Gets the value type of the attribute. + */ + getType(): Sdk.ValueType; + + /** + * Gets the value of the attribute. + * The type of value depends on the type of attribute. + */ + getValue(): any; + + /** + * Whether the value of the attribute is set. + */ + isValueSet(): boolean; + + /** + * Sets whether the value of the attribute has changed. + * @param isChanged Whether the value of the attribute has changed. + */ + setIsChanged(isChanged: boolean): void; + + /** + * Sets the name of the attribute + * @param name The name of the attribute. + */ + setName(name: string): void; + + /** + * For internal use only. + * @param type The type of the attribute. + */ + setType(type: Sdk.ValueType): void; + + /** + * Sets the general value of the attribute + * @param name The value of the attribute. + */ + setValue(value: any): void; + + /// prototype methods + /** + * XML node for Attribute. + */ + toXml(action: string): string; + } + + class Boolean extends AttributeBase { + /** + * A Boolean Attribute. + * @param name The logical name of the attribute . + * @param value The value of the managed property. + */ + constructor(name: string, value?: boolean) + + /** + * Gets the value of a Boolean attribute. + */ + getValue(): boolean; + + /** + * Sets the value of a Boolean attribute. + * @param value + */ + setValue(value: boolean): void; + } + + class DateTime extends AttributeBase { + /** + * A DateTime Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: Date); + + /** + * Gets the value of a DateTime attribute. + */ + getValue(): Date; + + /** + * Sets the value of a DateTime attribute. + * @param value The value to set. + */ + setValue(value: Date): void; + } + + class Decimal extends AttributeBase { + /** + * A Decimal Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a Decimal attribute. + */ + getValue(): number; + + /** + * Sets the value of a Decimal attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class Double { + /** + * A Double Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a Double attribute. + */ + getValue(): number; + + /** + * Sets the value of a Double attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class Guid extends AttributeBase { + /** + * A Guid Attribute. + * @param name The logical name of the attribute. + * @param value" The value of the attribute + */ + constructor(name: string, value?: string); + + /** + * Gets the value of a Guid attribute. + */ + getValue(): string; + + /** + * Sets the value of a Guid attribute. + * @param value The value to set. + */ + setValue(value: string): void; + } + + class Int extends AttributeBase { + /** + * An Integer Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of an Integer attribute. + */ + getValue(): number; + + /** + * Sets the value of an Integer attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class Long extends AttributeBase { + /** + * A Long Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a Long attribute. + */ + getValue(): number; + + /** + * Sets the value of a Long attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class Lookup extends AttributeBase { + /** + * A Lookup Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: EntityReference); + + /** + * Gets the value of a Lookup attribute. + */ + getValue(): EntityReference; + + /** + * Sets the value of a Lookup attribute. + * @param value The value to set. + */ + setValue(value: EntityReference): void; + } + + class Money extends AttributeBase { + /** + * A Money Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a Money attribute. + */ + getValue(): number; + + /** + * Sets the value of a Money attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class OptionSet extends AttributeBase { + /** + * An OptionSet Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a OptionSet attribute. + */ + getValue(): number; + + /** + * Sets the value of an OptionSet attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class PartyList extends AttributeBase { + /** + * A PartyList Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: EntityCollection); + + /** + * Gets the value of a PartyList attribute. + */ + getValue(): EntityCollection; + + /** + * Sets the value of a PartyList attribute. + * @param value The value to set. + */ + setValue(value: EntityCollection): void; + } + + class String extends AttributeBase { + /** + * A String Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: string); + + /** + * Gets the value of a String attribute. + */ + getValue(): string; + + /** + * Sets the value of a String attribute. + * @param value The value to set. + */ + setValue(value: string): void; + } + + class EntityState { + } + + class Entity { + /** + * Represents an instance of an entity (a record). + * @param type The logical name of the entity. + */ + constructor(type: string); + + /** + * Gets the collection of attributes for the entity. + */ + getAttributes(): Sdk.AttributeCollection; + + /** + * Gets the collection of attributes for the entity. + * @param attributeName The attribute with matching name is returned. + */ + getAttributes(attributeName: string): Sdk.AttributeBase; + + /** + * Gets the collection of attributes for the entity. + * @param index The attribute with matching index is returned. + */ + getAttributes(index: number): Sdk.AttributeBase; + + /** + * Checks whether the entity has an attribute that satisfies the specified predicate. + * @param A comparer function that takes an Sdk.AttributeBase as argument and returns a boolean. + */ + containsAttribute(predicate: (attribute: Sdk.AttributeBase) => boolean): boolean; + + /** + * Checks whether the entity has an attribute with the specified name. + * @param The name of the attribute. + */ + containsAttribute(name: string): boolean; + + /** + * Sets the collection of attributes for the entity. + * @param attributes The collection of attributes for the entity. + */ + setAttributes(attributes: Sdk.AttributeCollection): void; + + /** + * Gets the state of the entity. + */ + getEntityState(): Sdk.EntityState; + + /** + * Sets the state of the entity. + * @param state The state of the entity. + */ + setEntityState(state: Sdk.EntityState): void; + + /** + * Gets the collection of formatted values for the entity attributes. + */ + getFormattedValues(): Sdk.FormattedValueCollection; + + /** + * Sets the collection of formatted values for the entity attributes. + * @param values" The collection of formatted values for the entity attributes. + */ + setFormattedValues(values: Sdk.FormattedValueCollection): void; + + /** + * Gets the Id of the record represented by this entity instance. + */ + getId(): string; + + /** + * Sets the Id of the record represented by this entity instance. + * @param id The Id of the record represented by this entity instance. + * @param override Allow setting the Id property, for example when creating a new record from an existing one. + */ + setId(id: string, override?: boolean): void; + + /** + * Gets the logical name of the entity. + */ + getType(): string; + + /** + * Sets the logical name of the entity. + * @param type The logical name of the entity. + */ + setType(type: string): void; + + /** + * Gets a collection of related entities. + */ + getRelatedEntities(): Sdk.RelatedEntitiesCollection; + + /** + * Sets a collection of related entities. + * @param relatedEntities A collection of related entities. + */ + setRelatedEntities(relatedEntities: Sdk.RelatedEntitiesCollection): void; + + /** + * Adds an attribute with an optional value to a newly instantiated Sdk.Entity + * @param attribute The attribute to add + * @param isChanged Whether the attribute should be considered changed, the default is true. + */ + addAttribute(attribute: Sdk.AttributeBase, isChanged?: boolean): void; + + /** + * Adds an entity to the related entities. + * @param relationshipSchemaName The relationship SchemaName. + * @param entity The entity to add. + */ + addRelatedEntity(relationshipSchemaName: string, entity: Sdk.Entity): void; + + /** + * Gets the value to indicate whether data for the entity has changed. + */ + getIsChanged(): boolean; + + /** + * Sets the value to indicate whether data for the entity has changed. + * @param isChanged The value to indicate whether data for the entity has changed. + */ + setIsChanged(isChanged: boolean): void; + + /** + * Gets the value of the specified attribute. + * @param logicalName The logical name of the attribute. + */ + getValue(logicalName: string): any; + + /** + * Generates properties for the entity based on metadata. + */ + initializeSubClass(metadata: Sdk.Mdq.IEntityMetadata): void; + + /** + * Sets the value of the specified attribute. + * @param logicalName The logical name of the attribute. + * @param value The value for the attribute. Simple JavaScript types may be used for most attribute types. Sdk.EntityReference, Sdk.EntityCollection, and Sdk.BooleanManagedPropertyValue cannot use simple JavaScript types. + */ + setValue(logicalName: string, value: Object): void; + + /** + * Generates an entity reference. + */ + toEntityReference(): Sdk.EntityReference; + + /** + * Overrides the default toString method. + */ + toString(): string; + + /** + * XML definition of an the child nodes of an entity. + * @param action + */ + toValueXml(action: string): string; + + /** + * XML definition of an entity where the root node is . + */ + toXml(action: string): string; + + /** + * Returns a view of the data in an entity instance + */ + view(): IEntityView; + } + + class EntityReference { + /** + * Identifies a record. + * @param logicalName The logical name of the entity. + * @param id The id of the record. + * @param name The value of the primary attribute of the entity instance. This property can contain a value or null. This property is not automatically populated unless the EntityReference object has been retrieved from the server. + */ + constructor(logicalName: string, id: string, name?: string); + + /** + * Gets the logicalName representing the type of referenced entity. + */ + getType(): string; + + /** + * Gets the Id value of the referenced entity. + */ + getId(): string; + + /** + * Gets the primary attribute value of the referenced entity. + */ + getName(): string; + + /** + * Sets the logicalName representing the type of referenced entity. + * @param type The logicalName representing the type of referenced entity. + */ + setType(type: string): void; + + /** + * Sets the Id value of the entity. + * @param id The Id value of the entity. + */ + setId(id: string): void; + + /** + * Sets the primary attribute value of the referenced entity. + * @param name The primary attribute value of the referenced entity. + */ + setName(name: string): void; + + + /// prototype methods + + /** + * Returns a serialized entity reference where the root element is . + */ + toXml(): string; + + /** + * Returns the values of serialized entity reference as XML nodes. + */ + toValueXml(): string; + + /** + * Returns a view of the data in an EntityReference + */ + view(): IEntityReferenceView; + } + + class OrganizationRequest { + /** + * Sets the request XML. + * @param xml The request XML. + */ + setRequestXml(xml: string): void; + + /** + * Gets the request XML. + */ + getRequestXml(): string; + + /** + * Sets the response type. + * @param type A class that inherits from Sdk.OrganizationResponse. + */ + setResponseType(type: OrganizationResponse): void; + + /** + * Gets the response type. + */ + getResponseType(): OrganizationResponse; + } + + class OrganizationResponse { + } + + /** + * Contains the data that is needed to convert a query in FetchXML to a QueryExpression. + * @param fetchXml Sets the query to convert. + */ + class FetchXmlToQueryExpressionRequest extends Sdk.OrganizationRequest { + constructor(fetchXml: string); + + /** + * Sets the query to convert. + * @param The query to convert. + */ + setFetchXml(value: string): void; + } + + /** + * Response to FetchXmlToQueryExpressionRequest. + * @param responseXml The response XML to the FetchXmlToQueryExpressionRequest. + */ + class FetchXmlToQueryExpressionResponse extends Sdk.OrganizationResponse { + constructor(responseXml: string); + + /** + * Gets the results of the query conversion. + */ + public getQuery(): Query.QueryExpression; + } + + /** + * Contains the data that is needed to convert a query, which is represented as a QueryExpression class, to its equivalent query, which is represented as FetchXML. * @param query The query. - * @param query */ - public setQuery( query: Sdk.Query.QueryBase ): void; + class QueryExpressionToFetchXmlRequest extends Sdk.OrganizationRequest { + constructor(query: Sdk.Query.QueryBase); + + /** + * Sets the query to convert. + * @param query The query. + * @param query + */ + public setQuery(query: Sdk.Query.QueryBase): void; + } + + /** + * Response to QueryExpressionToFetchXmlRequest. + */ + class QueryExpressionToFetchXmlResponse extends Sdk.OrganizationResponse { + constructor(responseXml: string); + + /** + * Gets the results of the query conversion. + */ + public getFetchXml(): string; + } + + /** + * Request to retrieve metadata and metadata changes. + * @param query The Sdk.Mdq.EntityQueryExpression that defines the query. + * @param clientVersionStamp The Sdk.Mdq.RetrieveMetadataChangesResponse.ServerVersionStamp value from a previous request. When included only the metadata changes since the previous request will be returned. + * @param deletedMetadataFilters An Sdk.Mdq.DeletedMetadataFilters enumeration value. When included the deleted metadata changes will be limited to the types defined by the enumeration. + */ + class RetrieveMetadataChangesRequest extends Sdk.OrganizationRequest { + constructor(query: Sdk.Mdq.EntityQueryExpression, clientVersionStamp?: string, deletedMetadataFilters?: Sdk.Mdq.DeletedMetadataFilters); + getEntityMetadata(): Sdk.Mdq.IEntityMetadata[]; + getServerVersionStamp(): string; + getDeletedMetadata(): Object; + } + + /** + * Response to RetrieveMetadataChangesRequest. + * @param resopnseXml The response XML. + */ + class RetrieveMetadataChangesResponse { + constructor(responseXml: string); + + /*** + * + */ + public getEntityMetadata(): Array; + + /*** + * + */ + public getServerVersionStamp(): string; + + /*** + * + */ + public getDeletedMetadata(): any; + } + + + /** + * Contains the data that is needed to set the state of an entity record. + * @param entityMoniker Sets the entity. + * @param state Sets the state of the entity record. + * @param status Sets the status that corresponds to the State property. + */ + class SetStateRequest extends Sdk.OrganizationRequest { + constructor(entityMoniker: EntityReference, state: number, status: number); + + /** + * Sets the entity. + * @param value The entity. + */ + public setEntityMoniker(value: EntityReference): void; + + /** + * Sets the state of the entity record. + * @param value The state of the entity record. + */ + setState(value: number): void; + + /** + * Sets the status that corresponds to the State property. + * @param value The status that corresponds to the State property. + */ + setStatus(value: number): void; + } + + /** + * Response to SetStateRequest. + */ + class SetStateResponse { + constructor(responseXml: string); + } } - /** - * Response to QueryExpressionToFetchXmlRequest. - */ - class QueryExpressionToFetchXmlResponse extends Sdk.OrganizationResponse - { - constructor( responseXml: string ); - - /** - * Gets the results of the query conversion. - */ - public getFetchXml(): string; - } - - /** - * Request to retrieve metadata and metadata changes. - * @param query The Sdk.Mdq.EntityQueryExpression that defines the query. - * @param clientVersionStamp The Sdk.Mdq.RetrieveMetadataChangesResponse.ServerVersionStamp value from a previous request. When included only the metadata changes since the previous request will be returned. - * @param deletedMetadataFilters An Sdk.Mdq.DeletedMetadataFilters enumeration value. When included the deleted metadata changes will be limited to the types defined by the enumeration. - */ - class RetrieveMetadataChangesRequest extends Sdk.OrganizationRequest - { - constructor( query: Sdk.Mdq.EntityQueryExpression, clientVersionStamp?: string, deletedMetadataFilters?: Sdk.Mdq.DeletedMetadataFilters ); - getEntityMetadata(): Sdk.Mdq.IEntityMetadata[]; - getServerVersionStamp(): string; - getDeletedMetadata(): Object; - } - - /** - * Response to RetrieveMetadataChangesRequest. - * @param resopnseXml The response XML. - */ - class RetrieveMetadataChangesResponse - { - constructor( responseXml: string ); - - /*** - * - */ - public getEntityMetadata(): Array; - - /*** - * - */ - public getServerVersionStamp(): string; - - /*** - * - */ - public getDeletedMetadata(): any; - } - - - /** - * Contains the data that is needed to set the state of an entity record. - * @param entityMoniker Sets the entity. - * @param state Sets the state of the entity record. - * @param status Sets the status that corresponds to the State property. - */ - class SetStateRequest extends Sdk.OrganizationRequest - { - constructor( entityMoniker: EntityReference, state: number, status: number ); - - /** - * Sets the entity. - * @param value The entity. - */ - public setEntityMoniker( value: EntityReference ): void; - - /** - * Sets the state of the entity record. - * @param value The state of the entity record. - */ - setState( value: number ): void; - - /** - * Sets the status that corresponds to the State property. - * @param value The status that corresponds to the State property. - */ - setStatus( value: number ): void; - } - - /** - * Response to SetStateRequest. - */ - class SetStateResponse - { - constructor( responseXml: string ); - } -} - -declare namespace Sdk.Query -{ - class QueryBase - { - /** - * Internal Use Only. - * @param type An Abstract class for different query classes to inherit from. - */ - constructor( type: string ); - - /** - * Gets the columns to include. - */ - getColumnSet(): Sdk.ColumnSet; - - /** - * Sets the columns to include. - * @param columns An Sdk.ColumnSet instance. - */ - setColumnSet( columns: Sdk.ColumnSet ): void; - - /** - * Sets the columns to include. - * @param columns An array of attribute logical names for the columns to return. - */ - setColumnSet( columns: Array ): void; - - /** - * Sets the columns to include. - * @param columns Pass each attribute logical name as an argument. - */ - setColumnSet( ...columns: string[] ): void; - - /** - * - */ - getQueryType(): string; - - /** - * Gets the logical name of the entity. - */ - getEntityName(): string; - - /** - * Sets the logical name of the entity. - * @param name The logical name of the entity. - */ - setEntityName( name: string ): void; - - /** - * Gets the number of pages and the number of entity instances per page returned from the query. - */ - getPageInfo(): Sdk.Query.PagingInfo; - - /** - * Sets the number of pages and the number of entity instances per page returned from the query. - * @param pageInfo The number of pages and the number of entity instances per page returned from the query. - */ - setPageInfo( pageInfo: Sdk.Query.PagingInfo ): void; - - /** - * Adds the specified column to the column set. - * @param columnName The logical name of the column to add. - */ - addColumn( columnName: string ): void; - - /** - * Removes a column from the ColumnSet used by the query. - * @param columnName The logical name of an attribute to be removed from the ColumnSet. - * @param errorIfNotFound Whether to throw an error when the column to remove is not found. The default is false. - */ - removeColumn( columnName: string, errorIfNotFound?: boolean ): void; - - /** - * Gets an Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. - */ - getOrders(): Sdk.Collection; - - /** - * Gets the number of rows to be returned. - */ - getTopCount(): number; - - /** - * Sets the number of rows to be returned. - * @param count The number of rows to be returned. - */ - setTopCount( count: number ): void; - - /** - * Gets the serialized QueryExpression. - */ - toXml(): string; - - /** - * Gets the serialized QueryExpression values. - */ - toValueXml(): string; - } - - class QueryByAttribute extends QueryBase - { - /** - * Initializes a new instance of the QueryByAttribute class setting the entity name. - * @param entityName The logical name of the entity. - * - */ - constructor( entityName: string ); - - /** - * Gets An Sdk.Collection of Sdk.AttributeBase attributes. - */ - getAttributeValues(): Sdk.Collection; - - /** - * Sets an Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. - * @param orders An Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. - */ - setOrders( orders: Sdk.Collection ): void; - - /// prototype methods - - /** - * Adds the attribute with values to include in the query. - * @param attributeValue One of the classes that inherit from Sdk.AttributeBase including the value to use as criteria. - */ - addAttributeValue( attributeValue: Sdk.AttributeBase ): void; - - /** - * Adds an order to apply to the results of the query. - * @param order An order expression. - */ - addOrder( order: Sdk.Query.OrderExpression ): void; - - /** - * Removes an attribute with values to include in the query. - * @param attributeValue One of the classes that inherit from Sdk.AttributeBase including the value to use as criteria. - * @param errorIfNotFound Whether to throw an error when the attribute to remove is not found. The default is false. - */ - removeAttributeValue( attributeValue: Sdk.AttributeBase, errorIfNotFound?: boolean ): void; - } - - class QueryExpression extends QueryBase - { - /** - * Initializes a new instance of the QueryExpression class setting the entity name. - * @param entityName The name of the entity. - */ - constructor( entityName: string ); - - /** - * Gets the complex condition and logical filter expressions that filter the results of the query. - */ - getCriteria(): FilterExpression; - - /** - * Sets the complex condition and logical filter expressions that filter the results of the query. - * @param criteria The query condition and filter criteria. - */ - setCriteria( criteria: FilterExpression ): void; - - /** - * Gets whether the results of the query contain duplicate entity instances. - */ - getDistinct(): boolean; - - /** - * Sets whether the results of the query contain duplicate entity instances. - */ - setDistinct( isDistinct: boolean ): void; - - /** - * Gets an Sdk.Collection of Sdk.Query.LinkEntity instances. - */ - getLinkEntities(): Sdk.Collection; - - /** - * Gets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query. - */ - getNoLock(): boolean; - - /** - * Sets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query. - * @param isNoLock True if there are no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query; otherwise, false. - */ - setNoLock( isNoLock: boolean ): void; - - /// prototype methods - - /** - * Contains a condition expression used to filter the results of the query. - * @param entityName The logical name of the entity in the condition expression. - * @param attributeName The logical name of the attribute in the condition expression. - * @param operator The condition operator. - * @param values The value(s) to compare. Use one of the following classes that inherit from Sdk.Query.ValueBase: - * Sdk.Query.Booleans - * Sdk.Query.BooleanManagedProperties - * Sdk.Query.Dates - * Sdk.Query.Decimals - * Sdk.Query.Doubles - * Sdk.Query.EntityReferences - * Sdk.Query.Guids - * Sdk.Query.Ints - * Sdk.Query.Longs - * Sdk.Query.Money - * Sdk.Query.OptionSets - * Sdk.Query.Strings - */ - addCondition( entityName: string, attributeName: string, conditionOperator: Sdk.Query.ConditionOperator, values: Sdk.Query.ValueBase ): void; - - /** - * Adds the specified link to the query expression setting the entity name to link to, the attribute name to link from and the attribute name to link to. - * @param firstParam An Sdk.Query.LinkEntity instance. - */ - addLink( firstParam: Sdk.Query.LinkEntity ): void; - - /** - * Adds the specified link to the query expression setting the entity name to link to, the attribute name to link from and the attribute name to link to. - * @param firstParam The name of entity to link from. - * @param linkFromAttributeName The name of the attribute to link from. - * @param linkToAttributeName The name of the attribute to link to. - * @param joinOperator The join operator. The default value is Inner - */ - addLink( firstParam: string, linkFromAttributeName: string, linkToAttributeName: string, joinOperator: Sdk.Query.JoinOperator ): void; - - /** - * Adds the specified order expression to the query expression. - * @param attributeName The name of the attribute. - * @param orderType The order, ascending or descending. Ascending is the default if not specified. - */ - addOrder( attributeName: string, orderType: Sdk.Query.OrderType ): void; - } - - class OrderExpression - { - } - - class ConditionExpression - { - /** - * Contains a condition expression used to filter the results of the query. - * @param name entityName The logical name of the entity in the condition expression. - * @param name attributeName The logical name of the attribute in the condition expression. - * @param name operator The condition operator. - * @param name values The value(s) to compare. - * Use one of the following classes that inherit from Sdk.Query.ValueBase: - * - Sdk.Query.Booleans - * - Sdk.Query.BooleanManagedProperties - * - Sdk.Query.Dates - * - Sdk.Query.Decimals - * - Sdk.Query.Doubles - * - Sdk.Query.EntityReferences - * - Sdk.Query.Guids - * - Sdk.Query.Ints - * - Sdk.Query.Longs - * - Sdk.Query.Money - * - Sdk.Query.OptionSets - * - Sdk.Query.Strings - */ - constructor( entityName: string, attributeName: string, operator: ConditionOperator, values?: ValueBase ); - - /** - * Returns the logical name of the entity in the condition expression. - */ - getEntityName(): string; - - /** - * Sets the logical name of the entity in the condition expression. - * @param name The logical name of the entity in the condition expression. - */ - setEntityName( name: string ): void; - - /** - * Returns the logical name of the attribute in the condition expression. - */ - getAttributeName(): string; - - /** - * Sets the logical name of the attribute in the condition expression. - * @param name The logical name of the attribute in the condition expression. - */ - setAttributeName( name: string ): void; - - /** - * Returns the condition operator. - */ - getOperator(): ConditionOperator; - - /** - * Sets the condition operator. - * @param operator The condition operator. - */ - setOperator( operator: ConditionOperator ): void; - - /** - * Returns the values for the attribute. - */ - getValues(): ValueBase; - - /** - * Sets the values for the attribute. - * @param The value(s) to compare - * Use one of the following classes that inherit from Sdk.Query.ValueBase: - * - Sdk.Query.Booleans - * - Sdk.Query.BooleanManagedProperties - * - Sdk.Query.Dates - * - Sdk.Query.Decimals - * - Sdk.Query.Doubles - * - Sdk.Query.EntityReferences - * - Sdk.Query.Guids - * - Sdk.Query.Ints - * - Sdk.Query.Longs - * - Sdk.Query.Money - * - Sdk.Query.OptionSets - * - Sdk.Query.Strings - */ - setValues( values: ValueBase ): void; - } - - /** - * Specifies complex condition and logical filter expressions used for filtering the results of the query. - * @param logicalOperator The filter operator. - */ - class FilterExpression - { - constructor( logicalOperator: LogicalOperator ); - - /** - * Adds a condition to the filter expression setting the attribute name, condition operator, and values. - * @param conditionExpression The expression that will set the condition. - */ - public addCondition( firstParam: ConditionExpression ): void; - - /** - * Adds a condition to the filter expression setting the attribute name, condition operator, and values. - * @param entityName The entityName of the new ConditionExpression that will be instantiated using the other parameters. - * @param attributeName The attribute name to use in the condition expression. - * @param conditionOperator The condition operator if the first parameter is a string. - * @param values The value(s) to compare. - * Use one of the following classes that - * - Sdk.Query.Booleans - * - Sdk.Query.BooleanManagedProperties - * - Sdk.Query.Dates - * - Sdk.Query.Decimals - * - Sdk.Query.Doubles - * - Sdk.Query.EntityReferences - * - Sdk.Query.Guids - * - Sdk.Query.Ints - * - Sdk.Query.Longs - * - Sdk.Query.Money - * - Sdk.Query.OptionSets - * - Sdk.Query.Strings - */ - public addCondition( entityName: string, attributeName: string, conditionOperator: ConditionOperator, values?: ValueBase ): void; - - /** - * Adds a child filter to the filter expression. - * @param filterExpression The filter to add. - */ - addFilter( filterExpression: FilterExpression ): void; - - /** - * Adds a child filter to the filter expression. - * @param logicalOperator Creates new FilterExpression with the specified logical operator and adds it. - */ - addFilter( logicalOperator: LogicalOperator ): void; - - /** - * Returns a collection of Sdk.Query.ConditionExpression values. - */ - getConditions(): Sdk.Collection; - - /** - * Gets the logical AND/OR filter operator. - */ - getFilterOperator(): LogicalOperator - - /** - * Returns an Sdk.Collection of Sdk.Query.FilterExpression. - */ - getFilters(): Sdk.Collection; - - /** - * Gets whether the expression is part of a quick find query. - */ - getIsQuickFindFilter(): boolean; - - /** - * Sets the filter operator. - * @param filterOperator The filter operator. - */ - setFilterOperator( filterOperator: LogicalOperator ): void; - - /** - * Sets whether the expression is part of a quick find query. - * @param isQuickFind True if the filter is part of a quick find query; otherwise, false. - */ - setIsQuickFindFilter( isQuickFind: boolean ): void; - } - - class FetchExpression - { - /** - * @param fetchXml The FetchXml to be used in a query. - */ - constructor( fetchXml: string ); - - /** - * Gets the FetchXml to be used in a query. - */ - public getFetchXml(): string; - - /** - * Sets the FetchXml to be used in a query. - * @param fetchXml The FetchXml to be used in a query. - */ - public setFetchXml( fetchXml: string ): void; - } - - class LinkEntity - { - /** - * Initializes a new instance of the Sdk.Query.LinkEntity class setting the required properties. - * @param linkFromEntityName The logical name of the entity to link from. - * @param linkToEntityName The logical name of the entity to link to. - * @param linkFromAttributeName The name of the attribute to link from. - * @param linkToAttributeName The name of the attribute to link to. - * @param joinOperator The join operator. - * @param entityAlias The string representing an alias for the linkToEntityName. - */ - constructor( - linkFromEntityName: string, - linkToEntityName: string, - linkFromAttributeName: string, - linkToAttributeName: string, - joinOperator: Sdk.Query.JoinOperator, - entityAlias: string ); - - /** - * Adds a linked entity. - * @param linkEntity An Sdk.Query.LinkEntity to add. - */ - public addLink( linkEntity: Sdk.Query.LinkEntity ): void; - - /** - * Gets the column set. - */ - public getColumns(): Sdk.ColumnSet; - - /** - * Sets the columns to include. - * @param columns An Sdk.ColumnSet instance. - */ - public setColumns( columns: Sdk.ColumnSet ): void; - - /** - * Sets the columns to include. - * @param columns An Array of attribute logical names for the columns to return. - */ - public setColumns( columns: string[] ): void; - - /** - * Sets the columns to include. - * @param columns Pass each attribute logical name as an argument. - */ - public setColumns( ...columns: string[] ): void; - - /** - * Gets the alias for the entity. - */ - public getEntityAlias(): string; - - /** - * Sets the alias for the entity. - * @param alias The alias for the entity. - */ - public setEntityAlias( alias: string ): void; - - /** - * Gets the join operator. - */ - public getJoinOperator(): Sdk.Query.JoinOperator; - - /** - * Sets the join operator. - * @param operator The join operator. - */ - public setJoinOperator( operator: Sdk.Query.JoinOperator ): void; - - /** - * Gets the complex condition and logical filter expressions that filter the results of the query. - */ - public getLinkCriteria(): Sdk.Query.FilterExpression; - - /** - * Sets the complex condition and logical filter expressions that filter the results of the query. - * @param criteria The complex condition and logical filter expressions that filter the results of the query. - */ - public setLinkCriteria( criteria: Sdk.Query.FilterExpression ): void; - - /** - * Gets the collection of Sdk.Query.LinkEntity that define links between multiple entity types. - */ - public getLinkEntities(): Sdk.Collection; - - /** - * Gets the logical name of the attribute of the entity that you are linking from. - */ - public getLinkFromAttributeName(): string; - - /** - * Sets the logical name of the attribute of the entity that you are linking from. - * @param name The logical name of the attribute of the entity that you are linking from. - */ - public setLinkFromAttributeName( name: string ): void; - - /** - * Gets the logical name of the entity that you are linking from. - */ - public getLinkFromEntityName(): string; - - /** - * Sets the logical name of the entity that you are linking from. - * @param name The logical name of the entity that you are linking from. - */ - public setLinkFromEntityName( name: string ): void; - - /** - * Gets the logical name of the attribute of the entity that you are linking to - */ - public getLinkToAttributeName(): string; - - /** - * Sets the logical name of the attribute of the entity that you are linking to. - * @param name The logical name of the attribute of the entity that you are linking to. - */ - public setLinkToAttributeName( name: string ): void; - - /** - * Gets the logical name of the entity that you are linking to. - */ - public getLinkToEntityName(): string; - - /** - * Sets the logical name of the entity that you are linking to. - * @param name The logical name of the entity that you are linking to. - */ - public setLinkToEntityName( name: string ): void; - - /** - * Gets the serialized link entity. - */ - public toXml(): string; - - /** - * Gets the serialized link entity values. - */ - public toValueXml(): string; - } - - class PagingInfo - { - /** - * Gets the number of entity instances returned per page. - */ - getCount(): number; - - /** - * Sets the number of entity instances returned per page. - * @param The number of entity instances returned per page - */ - setCount( count: number ): void; - - /** - * Gets the number of pages returned from the query. - */ - getPageNumber(): number; - - /** - * Sets the number of pages returned from the query. - * @param The number of pages returned from the query. - */ - setPageNumber( pages: number ): void; - - /** - * Gets the info used to page large result sets. - */ - getPagingCookie(): string; - - /** - * Sets the info used to page large result sets. - */ - setPagingCookie( cookie: string ): void; - - /** - * Gets whether the total number of records should be returned from the query. - */ - getReturnTotalRecordCount(): boolean; - - /** - * Sets whether the total number of records should be returned from the query. - * @param Specifies whether the TotalRecordCount should be set when the query is executed. - */ - setReturnTotalRecordCount( returnTotalRecordsCount: boolean ): void; - - - /// prototype methods - - /** - * Gets the serialized paging info. - * - toXml():string; - - /** - * Gets the serialized paging info values. - */ - toValueXml(): string; - } - - export enum ConditionOperator - { - Equal, - NotEqual, - GreaterThan, - LessThan, - GreaterEqual, - LessEqual, - Like, - NotLike, - In, - NotIn, - Between, - NotBetween, - Null, - NotNull, - Yesterday, - Today, - Tomorrow, - Last7Days, - Next7Days, - LastWeek, - ThisWeek, - NextWeek, - LastMonth, - ThisMonth, - NextMonth, - On, - OnOrBefore, - OnOrAfter, - LastYear, - ThisYear, - NextYear, - LastXHours, - NextXHours, - LastXDays, - NextXDays, - LastXWeeks, - NextXWeeks, - LastXMonths, - NextXMonths, - LastXYears, - NextXYears, - EqualUserId, - NotEqualUserId, - EqualBusinessId, - NotEqualBusinessId, - Mask, - NotMask, - Contains, - DoesNotContain, - EqualUserLanguage, - NotOn, - OlderThanXMonths, - BeginsWith, - DoesNotBeginWith, - EndsWith, - DoesNotEndWith, - ThisFiscalYear, - ThisFiscalPeriod, - NextFiscalYear, - NextFiscalPeriod, - LastFiscalYear, - LastFiscalPeriod, - LastXFiscalYears, - LastXFiscalPeriods, - NextXFiscalYears, - NextXFiscalPeriods, - InFiscalYear, - InFiscalPeriod, - InFiscalPeriodAndYear, - InOrBeforeFiscalPeriodAndYear, - InOrAfterFiscalPeriodAndYear, - EqualUserOrUserTeams, - EqualUserTeams, - } - - export enum JoinOperator - { - Inner, - LeftOuter, - Natural, - } - - export enum OrderType - { - Ascending, - Descending, - } - - export class ValueBase - { } - - /** - * Specifies Boolean values to be compared in the query. - * @param args An array of Boolean values. - */ - class Booleans extends ValueBase - { - constructor( args: boolean[] ); - - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of boolean values. - */ - public getValues(): Sdk.Collection; - - - /** - * Specifies a Boolean value to be compared in the query. - * @param setValueArgs An array of boolean values. - */ - public setValues( setValueArgs: boolean[] ): void; - } - - /** - * Specifies the Date values to be compared in the query. - * @param args An array of Date values. - */ - class Dates extends ValueBase - { - constructor( args: Date[] ); - - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of Date values. - */ - public getValues(): Sdk.Collection; + namespace Sdk.Query { + class QueryBase { + /** + * Internal Use Only. + * @param type An Abstract class for different query classes to inherit from. + */ + constructor(type: string); + + /** + * Gets the columns to include. + */ + getColumnSet(): Sdk.ColumnSet; + + /** + * Sets the columns to include. + * @param columns An Sdk.ColumnSet instance. + */ + setColumnSet(columns: Sdk.ColumnSet): void; + + /** + * Sets the columns to include. + * @param columns An array of attribute logical names for the columns to return. + */ + setColumnSet(columns: Array): void; + + /** + * Sets the columns to include. + * @param columns Pass each attribute logical name as an argument. + */ + setColumnSet(...columns: string[]): void; + + /** + * + */ + getQueryType(): string; + + /** + * Gets the logical name of the entity. + */ + getEntityName(): string; + + /** + * Sets the logical name of the entity. + * @param name The logical name of the entity. + */ + setEntityName(name: string): void; + + /** + * Gets the number of pages and the number of entity instances per page returned from the query. + */ + getPageInfo(): Sdk.Query.PagingInfo; + + /** + * Sets the number of pages and the number of entity instances per page returned from the query. + * @param pageInfo The number of pages and the number of entity instances per page returned from the query. + */ + setPageInfo(pageInfo: Sdk.Query.PagingInfo): void; + + /** + * Adds the specified column to the column set. + * @param columnName The logical name of the column to add. + */ + addColumn(columnName: string): void; + + /** + * Removes a column from the ColumnSet used by the query. + * @param columnName The logical name of an attribute to be removed from the ColumnSet. + * @param errorIfNotFound Whether to throw an error when the column to remove is not found. The default is false. + */ + removeColumn(columnName: string, errorIfNotFound?: boolean): void; + + /** + * Gets an Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. + */ + getOrders(): Sdk.Collection; + + /** + * Gets the number of rows to be returned. + */ + getTopCount(): number; + + /** + * Sets the number of rows to be returned. + * @param count The number of rows to be returned. + */ + setTopCount(count: number): void; + + /** + * Gets the serialized QueryExpression. + */ + toXml(): string; + + /** + * Gets the serialized QueryExpression values. + */ + toValueXml(): string; + } + + class QueryByAttribute extends QueryBase { + /** + * Initializes a new instance of the QueryByAttribute class setting the entity name. + * @param entityName The logical name of the entity. + * + */ + constructor(entityName: string); + + /** + * Gets An Sdk.Collection of Sdk.AttributeBase attributes. + */ + getAttributeValues(): Sdk.Collection; + + /** + * Sets an Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. + * @param orders An Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. + */ + setOrders(orders: Sdk.Collection): void; + + /// prototype methods + + /** + * Adds the attribute with values to include in the query. + * @param attributeValue One of the classes that inherit from Sdk.AttributeBase including the value to use as criteria. + */ + addAttributeValue(attributeValue: Sdk.AttributeBase): void; + + /** + * Adds an order to apply to the results of the query. + * @param order An order expression. + */ + addOrder(order: Sdk.Query.OrderExpression): void; + + /** + * Removes an attribute with values to include in the query. + * @param attributeValue One of the classes that inherit from Sdk.AttributeBase including the value to use as criteria. + * @param errorIfNotFound Whether to throw an error when the attribute to remove is not found. The default is false. + */ + removeAttributeValue(attributeValue: Sdk.AttributeBase, errorIfNotFound?: boolean): void; + } + + class QueryExpression extends QueryBase { + /** + * Initializes a new instance of the QueryExpression class setting the entity name. + * @param entityName The name of the entity. + */ + constructor(entityName: string); + + /** + * Gets the complex condition and logical filter expressions that filter the results of the query. + */ + getCriteria(): FilterExpression; + + /** + * Sets the complex condition and logical filter expressions that filter the results of the query. + * @param criteria The query condition and filter criteria. + */ + setCriteria(criteria: FilterExpression): void; + + /** + * Gets whether the results of the query contain duplicate entity instances. + */ + getDistinct(): boolean; + + /** + * Sets whether the results of the query contain duplicate entity instances. + */ + setDistinct(isDistinct: boolean): void; + + /** + * Gets an Sdk.Collection of Sdk.Query.LinkEntity instances. + */ + getLinkEntities(): Sdk.Collection; + + /** + * Gets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query. + */ + getNoLock(): boolean; + + /** + * Sets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query. + * @param isNoLock True if there are no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query; otherwise, false. + */ + setNoLock(isNoLock: boolean): void; + + /// prototype methods + + /** + * Contains a condition expression used to filter the results of the query. + * @param entityName The logical name of the entity in the condition expression. + * @param attributeName The logical name of the attribute in the condition expression. + * @param operator The condition operator. + * @param values The value(s) to compare. Use one of the following classes that inherit from Sdk.Query.ValueBase: + * Sdk.Query.Booleans + * Sdk.Query.BooleanManagedProperties + * Sdk.Query.Dates + * Sdk.Query.Decimals + * Sdk.Query.Doubles + * Sdk.Query.EntityReferences + * Sdk.Query.Guids + * Sdk.Query.Ints + * Sdk.Query.Longs + * Sdk.Query.Money + * Sdk.Query.OptionSets + * Sdk.Query.Strings + */ + addCondition(entityName: string, attributeName: string, conditionOperator: Sdk.Query.ConditionOperator, values: Sdk.Query.ValueBase): void; + + /** + * Adds the specified link to the query expression setting the entity name to link to, the attribute name to link from and the attribute name to link to. + * @param firstParam An Sdk.Query.LinkEntity instance. + */ + addLink(firstParam: Sdk.Query.LinkEntity): void; + + /** + * Adds the specified link to the query expression setting the entity name to link to, the attribute name to link from and the attribute name to link to. + * @param firstParam The name of entity to link from. + * @param linkFromAttributeName The name of the attribute to link from. + * @param linkToAttributeName The name of the attribute to link to. + * @param joinOperator The join operator. The default value is Inner + */ + addLink(firstParam: string, linkFromAttributeName: string, linkToAttributeName: string, joinOperator: Sdk.Query.JoinOperator): void; + + /** + * Adds the specified order expression to the query expression. + * @param attributeName The name of the attribute. + * @param orderType The order, ascending or descending. Ascending is the default if not specified. + */ + addOrder(attributeName: string, orderType: Sdk.Query.OrderType): void; + } + + class OrderExpression { + } + + class ConditionExpression { + /** + * Contains a condition expression used to filter the results of the query. + * @param name entityName The logical name of the entity in the condition expression. + * @param name attributeName The logical name of the attribute in the condition expression. + * @param name operator The condition operator. + * @param name values The value(s) to compare. + * Use one of the following classes that inherit from Sdk.Query.ValueBase: + * - Sdk.Query.Booleans + * - Sdk.Query.BooleanManagedProperties + * - Sdk.Query.Dates + * - Sdk.Query.Decimals + * - Sdk.Query.Doubles + * - Sdk.Query.EntityReferences + * - Sdk.Query.Guids + * - Sdk.Query.Ints + * - Sdk.Query.Longs + * - Sdk.Query.Money + * - Sdk.Query.OptionSets + * - Sdk.Query.Strings + */ + constructor(entityName: string, attributeName: string, operator: ConditionOperator, values?: ValueBase); + + /** + * Returns the logical name of the entity in the condition expression. + */ + getEntityName(): string; + + /** + * Sets the logical name of the entity in the condition expression. + * @param name The logical name of the entity in the condition expression. + */ + setEntityName(name: string): void; + + /** + * Returns the logical name of the attribute in the condition expression. + */ + getAttributeName(): string; + + /** + * Sets the logical name of the attribute in the condition expression. + * @param name The logical name of the attribute in the condition expression. + */ + setAttributeName(name: string): void; + + /** + * Returns the condition operator. + */ + getOperator(): ConditionOperator; + + /** + * Sets the condition operator. + * @param operator The condition operator. + */ + setOperator(operator: ConditionOperator): void; + + /** + * Returns the values for the attribute. + */ + getValues(): ValueBase; + + /** + * Sets the values for the attribute. + * @param The value(s) to compare + * Use one of the following classes that inherit from Sdk.Query.ValueBase: + * - Sdk.Query.Booleans + * - Sdk.Query.BooleanManagedProperties + * - Sdk.Query.Dates + * - Sdk.Query.Decimals + * - Sdk.Query.Doubles + * - Sdk.Query.EntityReferences + * - Sdk.Query.Guids + * - Sdk.Query.Ints + * - Sdk.Query.Longs + * - Sdk.Query.Money + * - Sdk.Query.OptionSets + * - Sdk.Query.Strings + */ + setValues(values: ValueBase): void; + } + + /** + * Specifies complex condition and logical filter expressions used for filtering the results of the query. + * @param logicalOperator The filter operator. + */ + class FilterExpression { + constructor(logicalOperator: LogicalOperator); + + /** + * Adds a condition to the filter expression setting the attribute name, condition operator, and values. + * @param conditionExpression The expression that will set the condition. + */ + public addCondition(firstParam: ConditionExpression): void; + + /** + * Adds a condition to the filter expression setting the attribute name, condition operator, and values. + * @param entityName The entityName of the new ConditionExpression that will be instantiated using the other parameters. + * @param attributeName The attribute name to use in the condition expression. + * @param conditionOperator The condition operator if the first parameter is a string. + * @param values The value(s) to compare. + * Use one of the following classes that + * - Sdk.Query.Booleans + * - Sdk.Query.BooleanManagedProperties + * - Sdk.Query.Dates + * - Sdk.Query.Decimals + * - Sdk.Query.Doubles + * - Sdk.Query.EntityReferences + * - Sdk.Query.Guids + * - Sdk.Query.Ints + * - Sdk.Query.Longs + * - Sdk.Query.Money + * - Sdk.Query.OptionSets + * - Sdk.Query.Strings + */ + public addCondition(entityName: string, attributeName: string, conditionOperator: ConditionOperator, values?: ValueBase): void; + + /** + * Adds a child filter to the filter expression. + * @param filterExpression The filter to add. + */ + addFilter(filterExpression: FilterExpression): void; + + /** + * Adds a child filter to the filter expression. + * @param logicalOperator Creates new FilterExpression with the specified logical operator and adds it. + */ + addFilter(logicalOperator: LogicalOperator): void; + + /** + * Returns a collection of Sdk.Query.ConditionExpression values. + */ + getConditions(): Sdk.Collection; + + /** + * Gets the logical AND/OR filter operator. + */ + getFilterOperator(): LogicalOperator + + /** + * Returns an Sdk.Collection of Sdk.Query.FilterExpression. + */ + getFilters(): Sdk.Collection; + + /** + * Gets whether the expression is part of a quick find query. + */ + getIsQuickFindFilter(): boolean; + + /** + * Sets the filter operator. + * @param filterOperator The filter operator. + */ + setFilterOperator(filterOperator: LogicalOperator): void; + + /** + * Sets whether the expression is part of a quick find query. + * @param isQuickFind True if the filter is part of a quick find query; otherwise, false. + */ + setIsQuickFindFilter(isQuickFind: boolean): void; + } + + class FetchExpression { + /** + * @param fetchXml The FetchXml to be used in a query. + */ + constructor(fetchXml: string); + + /** + * Gets the FetchXml to be used in a query. + */ + public getFetchXml(): string; + + /** + * Sets the FetchXml to be used in a query. + * @param fetchXml The FetchXml to be used in a query. + */ + public setFetchXml(fetchXml: string): void; + } + + class LinkEntity { + /** + * Initializes a new instance of the Sdk.Query.LinkEntity class setting the required properties. + * @param linkFromEntityName The logical name of the entity to link from. + * @param linkToEntityName The logical name of the entity to link to. + * @param linkFromAttributeName The name of the attribute to link from. + * @param linkToAttributeName The name of the attribute to link to. + * @param joinOperator The join operator. + * @param entityAlias The string representing an alias for the linkToEntityName. + */ + constructor( + linkFromEntityName: string, + linkToEntityName: string, + linkFromAttributeName: string, + linkToAttributeName: string, + joinOperator: Sdk.Query.JoinOperator, + entityAlias: string); + + /** + * Adds a linked entity. + * @param linkEntity An Sdk.Query.LinkEntity to add. + */ + public addLink(linkEntity: Sdk.Query.LinkEntity): void; + + /** + * Gets the column set. + */ + public getColumns(): Sdk.ColumnSet; + + /** + * Sets the columns to include. + * @param columns An Sdk.ColumnSet instance. + */ + public setColumns(columns: Sdk.ColumnSet): void; + + /** + * Sets the columns to include. + * @param columns An Array of attribute logical names for the columns to return. + */ + public setColumns(columns: string[]): void; + + /** + * Sets the columns to include. + * @param columns Pass each attribute logical name as an argument. + */ + public setColumns(...columns: string[]): void; + + /** + * Gets the alias for the entity. + */ + public getEntityAlias(): string; + + /** + * Sets the alias for the entity. + * @param alias The alias for the entity. + */ + public setEntityAlias(alias: string): void; + + /** + * Gets the join operator. + */ + public getJoinOperator(): Sdk.Query.JoinOperator; + + /** + * Sets the join operator. + * @param operator The join operator. + */ + public setJoinOperator(operator: Sdk.Query.JoinOperator): void; + + /** + * Gets the complex condition and logical filter expressions that filter the results of the query. + */ + public getLinkCriteria(): Sdk.Query.FilterExpression; + + /** + * Sets the complex condition and logical filter expressions that filter the results of the query. + * @param criteria The complex condition and logical filter expressions that filter the results of the query. + */ + public setLinkCriteria(criteria: Sdk.Query.FilterExpression): void; + + /** + * Gets the collection of Sdk.Query.LinkEntity that define links between multiple entity types. + */ + public getLinkEntities(): Sdk.Collection; + + /** + * Gets the logical name of the attribute of the entity that you are linking from. + */ + public getLinkFromAttributeName(): string; + + /** + * Sets the logical name of the attribute of the entity that you are linking from. + * @param name The logical name of the attribute of the entity that you are linking from. + */ + public setLinkFromAttributeName(name: string): void; + + /** + * Gets the logical name of the entity that you are linking from. + */ + public getLinkFromEntityName(): string; + + /** + * Sets the logical name of the entity that you are linking from. + * @param name The logical name of the entity that you are linking from. + */ + public setLinkFromEntityName(name: string): void; + + /** + * Gets the logical name of the attribute of the entity that you are linking to + */ + public getLinkToAttributeName(): string; + + /** + * Sets the logical name of the attribute of the entity that you are linking to. + * @param name The logical name of the attribute of the entity that you are linking to. + */ + public setLinkToAttributeName(name: string): void; + + /** + * Gets the logical name of the entity that you are linking to. + */ + public getLinkToEntityName(): string; + + /** + * Sets the logical name of the entity that you are linking to. + * @param name The logical name of the entity that you are linking to. + */ + public setLinkToEntityName(name: string): void; + + /** + * Gets the serialized link entity. + */ + public toXml(): string; + + /** + * Gets the serialized link entity values. + */ + public toValueXml(): string; + } + + class PagingInfo { + /** + * Gets the number of entity instances returned per page. + */ + getCount(): number; + + /** + * Sets the number of entity instances returned per page. + * @param The number of entity instances returned per page + */ + setCount(count: number): void; + + /** + * Gets the number of pages returned from the query. + */ + getPageNumber(): number; + + /** + * Sets the number of pages returned from the query. + * @param The number of pages returned from the query. + */ + setPageNumber(pages: number): void; + + /** + * Gets the info used to page large result sets. + */ + getPagingCookie(): string; + + /** + * Sets the info used to page large result sets. + */ + setPagingCookie(cookie: string): void; + + /** + * Gets whether the total number of records should be returned from the query. + */ + getReturnTotalRecordCount(): boolean; + + /** + * Sets whether the total number of records should be returned from the query. + * @param Specifies whether the TotalRecordCount should be set when the query is executed. + */ + setReturnTotalRecordCount(returnTotalRecordsCount: boolean): void; + + + /// prototype methods + + /** + * Gets the serialized paging info. + * + toXml():string; + + /** + * Gets the serialized paging info values. + */ + toValueXml(): string; + } + + export enum ConditionOperator { + Equal, + NotEqual, + GreaterThan, + LessThan, + GreaterEqual, + LessEqual, + Like, + NotLike, + In, + NotIn, + Between, + NotBetween, + Null, + NotNull, + Yesterday, + Today, + Tomorrow, + Last7Days, + Next7Days, + LastWeek, + ThisWeek, + NextWeek, + LastMonth, + ThisMonth, + NextMonth, + On, + OnOrBefore, + OnOrAfter, + LastYear, + ThisYear, + NextYear, + LastXHours, + NextXHours, + LastXDays, + NextXDays, + LastXWeeks, + NextXWeeks, + LastXMonths, + NextXMonths, + LastXYears, + NextXYears, + EqualUserId, + NotEqualUserId, + EqualBusinessId, + NotEqualBusinessId, + Mask, + NotMask, + Contains, + DoesNotContain, + EqualUserLanguage, + NotOn, + OlderThanXMonths, + BeginsWith, + DoesNotBeginWith, + EndsWith, + DoesNotEndWith, + ThisFiscalYear, + ThisFiscalPeriod, + NextFiscalYear, + NextFiscalPeriod, + LastFiscalYear, + LastFiscalPeriod, + LastXFiscalYears, + LastXFiscalPeriods, + NextXFiscalYears, + NextXFiscalPeriods, + InFiscalYear, + InFiscalPeriod, + InFiscalPeriodAndYear, + InOrBeforeFiscalPeriodAndYear, + InOrAfterFiscalPeriodAndYear, + EqualUserOrUserTeams, + EqualUserTeams, + } + + export enum JoinOperator { + Inner, + LeftOuter, + Natural, + } + + export enum OrderType { + Ascending, + Descending, + } + + export class ValueBase + { } + + /** + * Specifies Boolean values to be compared in the query. + * @param args An array of Boolean values. + */ + class Booleans extends ValueBase { + constructor(args: boolean[]); + + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of boolean values. + */ + public getValues(): Sdk.Collection; + + + /** + * Specifies a Boolean value to be compared in the query. + * @param setValueArgs An array of boolean values. + */ + public setValues(setValueArgs: boolean[]): void; + } /** * Specifies the Date values to be compared in the query. - * @param setValueArgs An array of Date values. + * @param args An array of Date values. */ - public setValues( setValueArgs: Date[] ): void; - } + class Dates extends ValueBase { + constructor(args: Date[]); - /** - * Specifies the Decimal values to be compared in the query. - * @param args An array of Decimal values. - */ - class Decimals extends ValueBase - { - constructor( args: number[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; + /** + * Returns an Sdk.Collection of Date values. + */ + public getValues(): Sdk.Collection; - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Date values to be compared in the query. + * @param setValueArgs An array of Date values. + */ + public setValues(setValueArgs: Date[]): void; + } /** * Specifies the Decimal values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of Decimal values. */ - public setValues( setValueArgs: number[] ): void; - } + class Decimals extends ValueBase { + constructor(args: number[]); - /** - * Specifies the Double values to be compared in the query. - * @param args An array of Double values. - */ - class Doubles extends ValueBase - { - constructor( args: number[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Decimal values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** * Specifies the Double values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of Double values. */ - public setValues( setValueArgs: number[] ): void; - } + class Doubles extends ValueBase { + constructor(args: number[]); - /** - * Specifies the Int values to be compared in the query. - * @param args An array of Int values. - */ - class Ints extends ValueBase - { - constructor( args: number[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; + + /** + * Specifies the Double values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** - * Returns the type of value with namespace prefix. + * Specifies the Int values to be compared in the query. + * @param args An array of Int values. */ - public getType(): string; + class Ints extends ValueBase { + constructor(args: number[]); - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Specifies the Int values to be compared in the query - * @param setValueArgs An array of number values. - */ - public setValues( setValueArgs: number[] ): void; - } + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; - /** - * Specifies the Long values to be compared in the query. - * @param args An array of Long values. - */ - class Longs extends ValueBase - { - constructor( args: number[] ); - - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Int values to be compared in the query + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** * Specifies the Long values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of Long values. */ - public setValues( setValueArgs: number[] ): void; - } + class Longs extends ValueBase { + constructor(args: number[]); - /** - * Specifies the Sdk.EntityReference values to be compared in the query. - * @param args An array of Sdk.EntityReference values. - */ - class EntityReferences extends ValueBase - { - constructor( args: Sdk.EntityReference[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; + + /** + * Specifies the Long values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** - * Returns the type of value with namespace prefix. + * Specifies the Sdk.EntityReference values to be compared in the query. + * @param args An array of Sdk.EntityReference values. */ - public getType(): string; + class EntityReferences extends ValueBase { + constructor(args: Sdk.EntityReference[]); + + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of Sdk.EntityReference values. + */ + public getValues(): Sdk.Collection; + + /** + * Specifies the Long values to be compared in the query. + * @param setValueArgs An array of Sdk.EntityReference values. + */ + public setValues(setValueArgs: Sdk.EntityReference[]): void; + } /** - * Returns an Sdk.Collection of Sdk.EntityReference values. + * Specifies the Sdk.Query.Guids values to be compared in the query. + * @param args An array of GUID string values. */ - public getValues(): Sdk.Collection; + class Guids extends ValueBase { + constructor(args: string[]); - /** - * Specifies the Long values to be compared in the query. - * @param setValueArgs An array of Sdk.EntityReference values. - */ - public setValues( setValueArgs: Sdk.EntityReference[] ): void; - } + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Specifies the Sdk.Query.Guids values to be compared in the query. - * @param args An array of GUID string values. - */ - class Guids extends ValueBase - { - constructor( args: string[] ); + /** + * Returns an Sdk.Collection of GUID string values. + */ + public getValues(): Sdk.Collection; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of GUID string values. - */ - public getValues(): Sdk.Collection; - - /** - * Specifies the Long values to be compared in the query. - * @param setValueArgs An array of GUID string values. - */ - public setValues( setValueArgs: string[] ): void; - } - - /** - * Specifies the Money values to be compared in the query. - * @param args An array of number values. - */ - class Money extends ValueBase - { - constructor( args: number[] ); - - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Long values to be compared in the query. + * @param setValueArgs An array of GUID string values. + */ + public setValues(setValueArgs: string[]): void; + } /** * Specifies the Money values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of number values. */ - public setValues( setValueArgs: number[] ): void; - } + class Money extends ValueBase { + constructor(args: number[]); - /** - * Specifies the OptionSet values to be compared in the query. - * @param args An array of number values. - */ - class OptionSets extends ValueBase - { - constructor( args: number[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Money values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** * Specifies the OptionSet values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of number values. */ - public setValues( setValueArgs: number[] ): void; - } + class OptionSets extends ValueBase { + constructor(args: number[]); - /** - * Specifies the String values to be compared in the query. - * @param args An array of String values. - */ - class Strings extends ValueBase - { - constructor( args: string[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; - /** - * Returns an Sdk.Collection of String values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the OptionSet values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** * Specifies the String values to be compared in the query. - * @param setValueArgs An array of String values. + * @param args An array of String values. */ - public setValues( setValueArgs: string[] ): void + class Strings extends ValueBase { + constructor(args: string[]); + + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of String values. + */ + public getValues(): Sdk.Collection; + + /** + * Specifies the String values to be compared in the query. + * @param setValueArgs An array of String values. + */ + public setValues(setValueArgs: string[]): void + } + + export enum LogicalOperator { + Or, + And, + } } - export enum LogicalOperator - { - Or, - And, - } -} - -declare namespace Sdk.Util -{ - /** - * Verifies the parameter is a string formatted as a GUID. - * @param value The value to check. - */ - function isGuid( value: string ): boolean; - - /** - * Verifies the parameter is a string formatted as a GUID or null. - * @param value The value to check. - */ - function isGuidOrNull( value: string ): boolean; - - /** - * Verifies the parameter is a valid enum value. - * @param enumeration The enumeration. - * @param value The value to check. - */ - - /** - * Returns an empty GUID. - */ - function getEmptyGuid(): string; - - /** - * Formats a string with the arguments from an array. - * @param string The string containing placeholders for items in the array. - * @param args An array of strings to replace the placeholders. - */ - function format( string: string, args: string[] ): string; - - /** - * - */ - function getError( resp: any ): string; - - /** - * Returns the clinent URL. - */ - function getClientUrl(): string; - - /** - * Provides a way to override the client Url when a client-side context is not available. - * @param url The client URL to use instead of the default. - */ - function setClientUrl( url: string ): void; - - /** - * - */ - function getXMLHttpRequest( action: string, async: boolean ): any; - - /** - * Creates an entity from XML. - * @param The serialized entity returned from the SOAP service as XML. - */ - function createEntityFromNode( node: string ): void; -} - -declare namespace Sdk.Xml -{ -} - -declare namespace Sdk.Mdq -{ - /** - * Defines a complex query to retrieve entity metadata. - * @param criteria The filter criteria for the metadata query. - * @param properties The properties to be returned by the query. - * @param attributeQuery A query expression for the entity attribute metadata to return. - * @param relationshipQuery A query expression for the entity relationship metadata to return. - * @param labelQuery A query expression for the labels to return. - */ - export class EntityQueryExpression - { - constructor( - criteria: Sdk.Mdq.MetadataFilterExpression, - properties: Sdk.Mdq.MetadataPropertiesExpression, - attributeQuery?: Sdk.Mdq.AttributeQueryExpression, - relationshipQuery?: Sdk.Mdq.RelationshipQueryExpression, - labelQuery?: Sdk.Mdq.LabelQueryExpression ); - } - - /** - * An enumeration that specifies the type of deleted metadata to retrieve. - */ - export enum DeletedMetadataFilters - { - All, // All deleted metadata - Attribute, // Deleted Attribute metadata - Default, // The value used if not set. Equals Entity - Entity, //Deleted Entity metadata - Label, //Deleted Label metadata - OptionSet, // Deleted OptionSet metadata - Relationship, //Deleted Relationship metadata - } - - /** - * Specifies complex condition and logical filter expressions used for filtering the results of a metadata query. - * @param filterOperator The logical AND/OR filter operator. - */ - - export class MetadataFilterExpression - { - constructor( filterOperator: Sdk.Mdq.LogicalOperator ); + namespace Sdk.Util { + /** + * Verifies the parameter is a string formatted as a GUID. + * @param value The value to check. + */ + function isGuid(value: string): boolean; /** - * Adds a condition. This method accepts either the properties to create a new Sdk.Mdq.MetadataConditionExpression or a Sdk.Mdq.MetadataConditionExpression as the first argument. - * @param propertyName The metadata property to evaluate. - * @param conditionOperator The condition operator. - * @param value The metadata value to evaluate. + * Verifies the parameter is a string formatted as a GUID or null. + * @param value The value to check. */ - public addCondition( - propertyName: SearchableEntityMetadataProperties|SearchableAttributeMetadataProperties|SearchableRelationshipMetadataProperties, - conditionOperator: MetadataConditionOperator, - value: Object ): void; - public addCondition( - propertyName: SearchableAttributeMetadataProperties, conditionOperator: MetadataConditionOperator, value: any): void; - public addCondition( - propertyName: SearchableEntityMetadataProperties|SearchableAttributeMetadataProperties|SearchableRelationshipMetadataProperties, - conditionOperator: MetadataConditionOperator, - value: Object ): void; - addCondition(propertyName: SearchableAttributeMetadataProperties, conditionOperator: MetadataConditionOperator): void; - public addCondition( - propertyName: SearchableEntityMetadataProperties|SearchableAttributeMetadataProperties|SearchableRelationshipMetadataProperties, - conditionOperator: MetadataConditionOperator, - value: Object): void; + function isGuidOrNull(value: string): boolean; + + /** + * Verifies the parameter is a valid enum value. + * @param enumeration The enumeration. + * @param value The value to check. + */ + + /** + * Returns an empty GUID. + */ + function getEmptyGuid(): string; + + /** + * Formats a string with the arguments from an array. + * @param string The string containing placeholders for items in the array. + * @param args An array of strings to replace the placeholders. + */ + function format(string: string, args: string[]): string; + + /** + * + */ + function getError(resp: any): string; + + /** + * Returns the clinent URL. + */ + function getClientUrl(): string; + + /** + * Provides a way to override the client Url when a client-side context is not available. + * @param url The client URL to use instead of the default. + */ + function setClientUrl(url: string): void; + + /** + * + */ + function getXMLHttpRequest(action: string, async: boolean): any; + + /** + * Creates an entity from XML. + * @param The serialized entity returned from the SOAP service as XML. + */ + function createEntityFromNode(node: string): void; } - /** - * Defines a complex query to retrieve attribute metadata for entities retrieved using an Sdk.Mdq.EntityQueryExpression. - * @param criteria The filter criteria for the metadata query. - * @param properties The properties to be returned by the query. - */ - export class AttributeQueryExpression - { - constructor( criteria: MetadataFilterExpression, properties: Sdk.Mdq.MetadataPropertiesExpression ); + namespace Sdk.Xml { } - /** - * Defines a complex query to retrieve entity relationship metadata for entities retrieved using an EntityQueryExpression. - * @param criteria The filter criteria for the metadata query. - * @param properties The properties to be returned by the query. - */ - export class RelationshipQueryExpression - { - constructor( criteria: MetadataFilterExpression, properties: Mdq.MetadataPropertiesExpression ); - } - - /** - * Defines the languages for the labels to be retrieved for metadata items that have labels. - * @param languages An array of LCID number values. - */ - export class LabelQueryExpression - { - constructor( languages: Array ); - } - - /** - * Logical operator. - */ - export enum LogicalOperator - { - And, - Or, - } - - /** - * Specifies the properties for which non-null values are returned from a query. - * @param allProperties Whether to retrieve all the properties of a metadata object. - * @param propertyNames: >An array of strings representing the metadata properties to retrieve. - */ - export class MetadataPropertiesExpression - { - constructor( allProperties: boolean, propertyNames?: Array ); - } - - export enum RelationshipMetadataProperties - { - AssociatedMenuConfiguration, - CascadeConfiguration, - HasChanged, - Entity1AssociatedMenuConfiguration, - Entity1IntersectAttribute, - Entity1LogicalName, - Entity2AssociatedMenuConfiguration, - Entity2IntersectAttribute, - Entity2LogicalName, - IntersectEntityName, - IsCustomizable, - IntroducedVersion, - IsCustomRelationship, - IsManaged, - IsValidForAdvancedFind, - MetadataId, - ReferencedAttribute, - ReferencedEntity, - ReferencingAttribute, - ReferencingEntity, - RelationshipType, - SchemaName, - SecurityTypes, - } - - export enum AttributeMetadataProperties - { - AttributeOf, - AttributeType, - AttributeTypeName, - CalculationOf, - CanBeSecuredForCreate, - CanBeSecuredForRead, - CanBeSecuredForUpdate, - CanModifyAdditionalSettings, - ColumnNumber, - DefaultFormValue, - DefaultValue, - DeprecatedVersion, - Description, - DisplayName, - EntityLogicalName, - Format, - FormatName, - ImeMode, - IntroducedVersion, - IsAuditEnabled, - IsCustomAttribute, - IsCustomizable, - IsManaged, - IsPrimaryId, - IsPrimaryName, - IsRenameable, - IsSecured, - IsValidForAdvancedFind, - IsValidForCreate, - IsValidForRead, - IsValidForUpdate, - LinkedAttributeId, - LogicalName, - MaxLength, - MaxValue, - MetadataId, - MinValue, - OptionSet, - Precision, - PrecisionSource, - RequiredLevel, - SchemaName, - Targets, - YomiOf, - } - - export enum EntityMetadataProperties - { - ActivityTypeMask, - Attributes, - AutoCreateAccessTeams, - AutoRouteToOwnerQueue, - CanBeInManyToMany, - CanBePrimaryEntityInRelationship, - CanBeRelatedEntityInRelationship, - CanCreateAttributes, - CanCreateCharts, - CanCreateForms, - CanCreateViews, - CanModifyAdditionalSettings, - CanTriggerWorkflow, - Description, - DisplayCollectionName, - DisplayName, - IconLargeName, - IconMediumName, - IconSmallName, - IntroducedVersion, - IsActivity, - IsActivityParty, - IsAIRUpdated, - IsAuditEnabled, - IsAvailableOffline, - IsBusinessProcessEnabled, - IsChildEntity, - IsConnectionsEnabled, - IsCustomEntity, - IsCustomizable, - IsDocumentManagementEnabled, - IsDuplicateDetectionEnabled, - IsEnabledForCharts, - IsImportable, - IsIntersect, - IsMailMergeEnabled, - IsManaged, - IsMappable, - IsQuickCreateEnabled, - IsReadingPaneEnabled, - IsRenameable, - IsValidForAdvancedFind, - IsValidForQueue, - IsVisibleInMobile, - IsVisibleInMobileClient, - LogicalName, - ManyToManyRelationships, - ManyToOneRelationships, - MetadataId, - ObjectTypeCode, - OneToManyRelationships, - OwnershipType, - PrimaryIdAttribute, - PrimaryImageAttribute, - PrimaryNameAttribute, - Privileges, - RecurrenceBaseEntityLogicalName, - ReportViewName, - SchemaName, - } - - export enum SearchableEntityMetadataProperties - { - ActivityTypeMask, - AutoCreateAccessTeams, - AutoRouteToOwnerQueue, - CanBeInManyToMany, - CanBePrimaryEntityInRelationship, - CanBeRelatedEntityInRelationship, - CanCreateAttributes, - CanCreateCharts, - CanCreateForms, - CanCreateViews, - CanModifyAdditionalSettings, - CanTriggerWorkflow, - IconLargeName, - IconMediumName, - IconSmallName, - IntroducedVersion, - IsActivity, - IsActivityParty, - IsAIRUpdated, - IsAuditEnabled, - IsAvailableOffline, - IsBusinessProcessEnabled, - IsChildEntity, - IsConnectionsEnabled, - IsCustomEntity, - IsCustomizable, - IsDocumentManagementEnabled, - IsDuplicateDetectionEnabled, - IsEnabledForCharts, - IsImportable, - IsIntersect, - IsMailMergeEnabled, - IsManaged, - IsMappable, - IsQuickCreateEnabled, - IsReadingPaneEnabled, - IsRenameable, - IsValidForAdvancedFind, - IsValidForQueue, - IsVisibleInMobile, - IsVisibleInMobileClient, - LogicalName, - MetadataId, - ObjectTypeCode, - OwnershipType, - PrimaryIdAttribute, - PrimaryImageAttribute, - PrimaryNameAttribute, - RecurrenceBaseEntityLogicalName, - ReportViewName, - SchemaName, - } - - export enum SearchableAttributeMetadataProperties - { - AttributeOf, - AttributeType, - CalculationOf, - CanBeSecuredForCreate, - CanBeSecuredForRead, - CanBeSecuredForUpdate, - CanModifyAdditionalSettings, - ColumnNumber, - DefaultFormValue, - DefaultValue, - DeprecatedVersion, - EntityLogicalName, - Format, - FormatName, - ImeMode, - IntroducedVersion, - IsAuditEnabled, - IsCustomAttribute, - IsCustomizable, - IsManaged, - IsPrimaryId, - IsPrimaryName, - IsRenameable, - IsSecured, - IsValidForAdvancedFind, - IsValidForCreate, - IsValidForRead, - IsValidForUpdate, - LinkedAttributeId, - LogicalName, - MaxLength, - MaxValue, - MetadataId, - MinValue, - Precision, - PrecisionSource, - RequiredLevel, - SchemaName, - YomiOf, - } - - export enum SearchableRelationshipMetadataProperties - { - HasChanged, - Entity1IntersectAttribute, - Entity1LogicalName, - Entity2IntersectAttribute, - Entity2LogicalName, - IntersectEntityName, - IsCustomizable, - IntroducedVersion, - IsCustomRelationship, - IsManaged, - IsValidForAdvancedFind, - MetadataId, - ReferencedAttribute, - ReferencedEntity, - ReferencingAttribute, - ReferencingEntity, - RelationshipType, - SchemaName, - SecurityTypes, - } - - export enum MetadataConditionOperator - { - Equals, - NotEquals, - In, - NotIn, - GreaterThan, - LessThan, - } - - export interface IEntityMetadata - { - ActivityTypeMask: number; - Attributes: IAttributeMetadata[]; - AutoCreateAccessTeams: any; - AutoRouteToOwnerQueue: boolean; - CanBeInManyToMany: ManagedProperty; - CanBePrimaryEntityInRelationship: ManagedProperty; - CanBeRelatedEntityInRelationship: ManagedProperty; - CanCreateAttributes: ManagedProperty; - CanCreateCharts: ManagedProperty; - CanCreateForms: ManagedProperty; - CanCreateViews: ManagedProperty; - CanModifyAdditionalSettings: ManagedProperty; - CanTriggerWorkflow: boolean; - Description: Label; - DisplayCollectionName: Label; - DisplayName: Label; - IconLargeName: string; - IconMediumName: string; - IconSmallName: string; - IntroducedVersion: any; - IsActivity: boolean; - IsActivityParty: boolean; - IsAIRUpdated: boolean; - IsAuditEnabled: ManagedProperty; - IsAvailableOffline: boolean; - IsBusinessProcessEnabled: boolean; - IsChildEntity: boolean; - IsConnectionsEnabled: ManagedProperty; - IsCustomEntity: boolean; - IsCustomizable: ManagedProperty; - IsDocumentManagementEnabled: boolean; - IsDuplicateDetectionEnabled: ManagedProperty; - IsEnabledForCharts: boolean; - IsImportable: boolean; - IsIntersect: boolean; - IsMailMergeEnabled: ManagedProperty; - IsManaged: boolean; - IsMappable: ManagedProperty; - IsQuickCreateEnabled: boolean; - IsReadingPaneEnabled: boolean; - IsRenameable: boolean; - IsValidForAdvancedFind: boolean; - IsValidForQueue: ManagedProperty; - IsVisibleInMobile: ManagedProperty; - IsVisibleInMobileClient: boolean; - LogicalName: string; - ManyToManyRelationships: ManyToManyRelationshipMetadata; - ManyToOneRelationships: OneToManyRelationshipMetadata; - MetadataId: string; - ObjectTypeCode: number; - OneToManyRelationships: OneToManyRelationshipMetadata; - OwnershipType: "BusinessOwned" | "BusinessParented" | "None OrganizationOwned" | "TeamOwned UserOwned"; - PrimaryIdAttribute: string; - PrimaryImageAttribute: string; - PrimaryNameAttribute: string; - Privileges: SecurityPrivilegeMetadata[]; - RecurrenceBaseEntityLogicalName: string; - ReportViewName: string; - SchemaName: string; - } - - export interface SecurityPrivilegeMetadata - { - CanBeBasic: boolean; - CanBeDeep: boolean; - CanBeEntityReference: boolean; - CanBeGlobal: boolean; - CanBeLocal: boolean; - CanBeParentEntityReference: boolean; - ExtensionData: boolean; - Name: string; - PrivilegeId: string; - PrivilegeType: "Append" | "AppendTo" | "Assign" | "Create" | "Delete" | "None" | "Read" | "Share" | "Write"; - } - - export interface OneToManyRelationshipMetadata - { - AssociatedMenuConfiguration: AssociatedMenuConfiguration; - CascadeConfiguration: CascadeConfiguration; - HasChanged: any; - IntroducedVersion: any; - IsCustomizable: ManagedProperty; - IsCustomRelationship: boolean; - IsHierarchical: any; - IsManaged: boolean; - IsValidForAdvancedFind: boolean; - MetadataId: string; - ReferencedAttribute: string; - ReferencedEntity: string; - ReferencingAttribute: string; - ReferencingEntity: string; - RelationshipType: string; - SchemaName: string; - SecurityTypes: any; - } - - export interface CascadeConfiguration - { - Assign: CascadeType; - Delete: CascadeType; - ExtensionData: CascadeType; - Merge: CascadeType; - Reparent: CascadeType; - Share: CascadeType; - Unshare: CascadeType; - } - - export type CascadeType = "Active" | "Cascade" | "NoCascade" | "UserOwned"; - - export interface ManyToManyRelationshipMetadata - { - Entity1AssociatedMenuConfiguration: AssociatedMenuConfiguration; - Entity1IntersectAttribute: string; - Entity1LogicalName: string; - Entity2AssociatedMenuConfiguration: AssociatedMenuConfiguration; - Entity2IntersectAttribute: string; - Entity2LogicalName: string; - HasChanged: boolean; - IntersectEntityName: string; - IntroducedVersion: any; - IsCustomizable: ManagedProperty; - IsCustomRelationship: boolean; - IsManaged: boolean; - IsValidForAdvancedFind: boolean; - MetadataId: string; - RelationshipType: RelationshipType; - SchemaName: string; - SecurityTypes: SecurityType; - } - - export interface AssociatedMenuConfiguration - { - Behavior: AssociatedMenuBehavior; - Group: AssociatedMenuGroup; - Label: Label; - Order: number; - } - - export type AssociatedMenuBehavior = "DoNotDisplay" | "UseCollectionName" | "UseLabel"; - - export type AssociatedMenuGroup = "Details" | "Marketing" | "Sales" | "Service"; - - export type RelationshipType = "Default" | "ManyToManyRelationship" | "OneToManyRelationship"; - - export type SecurityType = "Append" | "Inheritance" | "None" | "ParentChild" | "Pointer"; - - export interface IAttributeMetadata - { - AttributeOf: string; - AttributeType: "Customer" | "DateTime" | "Decimal" | "Double" | "EntityName" | "Integer" | "Lookup" | "ManagedProperty" | "Memo" | "Money" | "Owner" | "PartyList" | "Picklist" | "State" | "Status" | "Uniqueidentifier" | "Virtual" - AttributeTypeName: "BigIntType" | "BooleanType" | "CalendarRulesType" | "CustomerType" | "DateTimeType" | "DecimalType" | "DoubleType" | "EntityNameType" | "ImageType" | "IntegerType" | "LookupType" | "ManagedPropertyType" | "MemoType" | "MoneyType" | "OwnerType" | "PartyListType" | "PicklistType" | "StateType StatusType" | "StringType" | "UniqueidentifierType" | "VirtualType"; - CalculationOf: any; - CanBeSecuredForCreate: boolean; - CanBeSecuredForRead: boolean; - CanBeSecuredForUpdate: boolean; - CanModifyAdditionalSettings: ManagedProperty; - ColumnNumber: number; - DefaultFormValue: any; - DefaultValue: any; - DeprecatedVersion: any; - Description: Label; - DisplayName: Label; - EntityLogicalName: string; - Format: any; - FormatName: string; - ImeMode: any; - IntroducedVersion: any; - IsAuditEnabled: boolean; - IsCustomAttribute: boolean; - IsCustomizable: ManagedProperty; - IsManaged: boolean; - IsPrimaryId: boolean; - IsPrimaryName: boolean; - IsRenameable: ManagedProperty; - IsSecured: boolean; - IsValidForAdvancedFind: ManagedProperty; - IsValidForCreate: boolean; - IsValidForRead: boolean; - IsValidForUpdate: boolean; - LinkedAttributeId: string; - LogicalName: string; - MaxLength: number; - MaxValue: any; - MetadataId: string; - MinValue: number; - OptionSet: any; - Precision: any; - PrecisionSource: any; - RequiredLevel: ManagedProperty; - SchemaName: string; - Targets: string[]; - YomiOf: any; - } - - export interface ManagedProperty - { - CanBeChanged: boolean; - ManagedPropertyLogicalName: string; - Value: T; - } - - export interface Label - { - LocalizedLabels: LocalizedLabel[]; - UserLocalizedLabel: LocalizedLabel; - } - - export interface LocalizedLabel - { - Label: string; - LangaugeCode: number; - MetadataId: string; - HasChanged: boolean; - IsManaged: boolean; - } - - namespace ValueEnums - { - export enum OwnershipType - { - None, - OrganizationOwned, - TeamOwned, - UserOwned, + namespace Sdk.Mdq { + /** + * Defines a complex query to retrieve entity metadata. + * @param criteria The filter criteria for the metadata query. + * @param properties The properties to be returned by the query. + * @param attributeQuery A query expression for the entity attribute metadata to return. + * @param relationshipQuery A query expression for the entity relationship metadata to return. + * @param labelQuery A query expression for the labels to return. + */ + export class EntityQueryExpression { + constructor( + criteria: Sdk.Mdq.MetadataFilterExpression, + properties: Sdk.Mdq.MetadataPropertiesExpression, + attributeQuery?: Sdk.Mdq.AttributeQueryExpression, + relationshipQuery?: Sdk.Mdq.RelationshipQueryExpression, + labelQuery?: Sdk.Mdq.LabelQueryExpression); } - export enum AttributeTypeCode - { - BigInt, - Boolean, - CalendarRules, - Customer, - DateTime, - Decimal, - Double, - EntityName, - Integer, - Lookup, - ManagedProperty, - Memo, - Money, - Owner, - PartyList, - Picklist, - State, - Status, - String, - Uniqueidentifier, - Virtual, + /** + * An enumeration that specifies the type of deleted metadata to retrieve. + */ + export enum DeletedMetadataFilters { + All, // All deleted metadata + Attribute, // Deleted Attribute metadata + Default, // The value used if not set. Equals Entity + Entity, //Deleted Entity metadata + Label, //Deleted Label metadata + OptionSet, // Deleted OptionSet metadata + Relationship, //Deleted Relationship metadata } + /** + * Specifies complex condition and logical filter expressions used for filtering the results of a metadata query. + * @param filterOperator The logical AND/OR filter operator. + */ - export enum AttributeRequiredLevel - { - ApplicationRequired, - None, - Recommended, - SystemRequired, + export class MetadataFilterExpression { + constructor(filterOperator: Sdk.Mdq.LogicalOperator); + + /** + * Adds a condition. This method accepts either the properties to create a new Sdk.Mdq.MetadataConditionExpression or a Sdk.Mdq.MetadataConditionExpression as the first argument. + * @param propertyName The metadata property to evaluate. + * @param conditionOperator The condition operator. + * @param value The metadata value to evaluate. + */ + public addCondition( + propertyName: SearchableEntityMetadataProperties | SearchableAttributeMetadataProperties | SearchableRelationshipMetadataProperties, + conditionOperator: MetadataConditionOperator, + value: Object): void; + public addCondition( + propertyName: SearchableAttributeMetadataProperties, conditionOperator: MetadataConditionOperator, value: any): void; + public addCondition( + propertyName: SearchableEntityMetadataProperties | SearchableAttributeMetadataProperties | SearchableRelationshipMetadataProperties, + conditionOperator: MetadataConditionOperator, + value: Object): void; + addCondition(propertyName: SearchableAttributeMetadataProperties, conditionOperator: MetadataConditionOperator): void; + public addCondition( + propertyName: SearchableEntityMetadataProperties | SearchableAttributeMetadataProperties | SearchableRelationshipMetadataProperties, + conditionOperator: MetadataConditionOperator, + value: Object): void; } - - export enum DateTimeFormat - { - DateAndTime, - DateOnly, + /** + * Defines a complex query to retrieve attribute metadata for entities retrieved using an Sdk.Mdq.EntityQueryExpression. + * @param criteria The filter criteria for the metadata query. + * @param properties The properties to be returned by the query. + */ + export class AttributeQueryExpression { + constructor(criteria: MetadataFilterExpression, properties: Sdk.Mdq.MetadataPropertiesExpression); } - export enum ImeMode - { - Active, - Auto, - Disabled, - Inactive, + /** + * Defines a complex query to retrieve entity relationship metadata for entities retrieved using an EntityQueryExpression. + * @param criteria The filter criteria for the metadata query. + * @param properties The properties to be returned by the query. + */ + export class RelationshipQueryExpression { + constructor(criteria: MetadataFilterExpression, properties: Mdq.MetadataPropertiesExpression); } - - - export enum IntegerFormat - { - Duration, - Language, - Locale, - None, - TimeZone, + /** + * Defines the languages for the labels to be retrieved for metadata items that have labels. + * @param languages An array of LCID number values. + */ + export class LabelQueryExpression { + constructor(languages: Array); } - - export enum SecurityTypes - { - Append, - Inheritance, - None, - ParentChild, - Pointer, + /** + * Logical operator. + */ + export enum LogicalOperator { + And, + Or, } - export enum StringFormat - { - Email, - PhoneticGuide, - Text, - TextArea, - TickerSymbol, - Url, - VersionNumber, + /** + * Specifies the properties for which non-null values are returned from a query. + * @param allProperties Whether to retrieve all the properties of a metadata object. + * @param propertyNames: >An array of strings representing the metadata properties to retrieve. + */ + export class MetadataPropertiesExpression { + constructor(allProperties: boolean, propertyNames?: Array); + } + + export enum RelationshipMetadataProperties { + AssociatedMenuConfiguration, + CascadeConfiguration, + HasChanged, + Entity1AssociatedMenuConfiguration, + Entity1IntersectAttribute, + Entity1LogicalName, + Entity2AssociatedMenuConfiguration, + Entity2IntersectAttribute, + Entity2LogicalName, + IntersectEntityName, + IsCustomizable, + IntroducedVersion, + IsCustomRelationship, + IsManaged, + IsValidForAdvancedFind, + MetadataId, + ReferencedAttribute, + ReferencedEntity, + ReferencingAttribute, + ReferencingEntity, + RelationshipType, + SchemaName, + SecurityTypes, + } + + export enum AttributeMetadataProperties { + AttributeOf, + AttributeType, + AttributeTypeName, + CalculationOf, + CanBeSecuredForCreate, + CanBeSecuredForRead, + CanBeSecuredForUpdate, + CanModifyAdditionalSettings, + ColumnNumber, + DefaultFormValue, + DefaultValue, + DeprecatedVersion, + Description, + DisplayName, + EntityLogicalName, + Format, + FormatName, + ImeMode, + IntroducedVersion, + IsAuditEnabled, + IsCustomAttribute, + IsCustomizable, + IsManaged, + IsPrimaryId, + IsPrimaryName, + IsRenameable, + IsSecured, + IsValidForAdvancedFind, + IsValidForCreate, + IsValidForRead, + IsValidForUpdate, + LinkedAttributeId, + LogicalName, + MaxLength, + MaxValue, + MetadataId, + MinValue, + OptionSet, + Precision, + PrecisionSource, + RequiredLevel, + SchemaName, + Targets, + YomiOf, + } + + export enum EntityMetadataProperties { + ActivityTypeMask, + Attributes, + AutoCreateAccessTeams, + AutoRouteToOwnerQueue, + CanBeInManyToMany, + CanBePrimaryEntityInRelationship, + CanBeRelatedEntityInRelationship, + CanCreateAttributes, + CanCreateCharts, + CanCreateForms, + CanCreateViews, + CanModifyAdditionalSettings, + CanTriggerWorkflow, + Description, + DisplayCollectionName, + DisplayName, + IconLargeName, + IconMediumName, + IconSmallName, + IntroducedVersion, + IsActivity, + IsActivityParty, + IsAIRUpdated, + IsAuditEnabled, + IsAvailableOffline, + IsBusinessProcessEnabled, + IsChildEntity, + IsConnectionsEnabled, + IsCustomEntity, + IsCustomizable, + IsDocumentManagementEnabled, + IsDuplicateDetectionEnabled, + IsEnabledForCharts, + IsImportable, + IsIntersect, + IsMailMergeEnabled, + IsManaged, + IsMappable, + IsQuickCreateEnabled, + IsReadingPaneEnabled, + IsRenameable, + IsValidForAdvancedFind, + IsValidForQueue, + IsVisibleInMobile, + IsVisibleInMobileClient, + LogicalName, + ManyToManyRelationships, + ManyToOneRelationships, + MetadataId, + ObjectTypeCode, + OneToManyRelationships, + OwnershipType, + PrimaryIdAttribute, + PrimaryImageAttribute, + PrimaryNameAttribute, + Privileges, + RecurrenceBaseEntityLogicalName, + ReportViewName, + SchemaName, + } + + export enum SearchableEntityMetadataProperties { + ActivityTypeMask, + AutoCreateAccessTeams, + AutoRouteToOwnerQueue, + CanBeInManyToMany, + CanBePrimaryEntityInRelationship, + CanBeRelatedEntityInRelationship, + CanCreateAttributes, + CanCreateCharts, + CanCreateForms, + CanCreateViews, + CanModifyAdditionalSettings, + CanTriggerWorkflow, + IconLargeName, + IconMediumName, + IconSmallName, + IntroducedVersion, + IsActivity, + IsActivityParty, + IsAIRUpdated, + IsAuditEnabled, + IsAvailableOffline, + IsBusinessProcessEnabled, + IsChildEntity, + IsConnectionsEnabled, + IsCustomEntity, + IsCustomizable, + IsDocumentManagementEnabled, + IsDuplicateDetectionEnabled, + IsEnabledForCharts, + IsImportable, + IsIntersect, + IsMailMergeEnabled, + IsManaged, + IsMappable, + IsQuickCreateEnabled, + IsReadingPaneEnabled, + IsRenameable, + IsValidForAdvancedFind, + IsValidForQueue, + IsVisibleInMobile, + IsVisibleInMobileClient, + LogicalName, + MetadataId, + ObjectTypeCode, + OwnershipType, + PrimaryIdAttribute, + PrimaryImageAttribute, + PrimaryNameAttribute, + RecurrenceBaseEntityLogicalName, + ReportViewName, + SchemaName, + } + + export enum SearchableAttributeMetadataProperties { + AttributeOf, + AttributeType, + CalculationOf, + CanBeSecuredForCreate, + CanBeSecuredForRead, + CanBeSecuredForUpdate, + CanModifyAdditionalSettings, + ColumnNumber, + DefaultFormValue, + DefaultValue, + DeprecatedVersion, + EntityLogicalName, + Format, + FormatName, + ImeMode, + IntroducedVersion, + IsAuditEnabled, + IsCustomAttribute, + IsCustomizable, + IsManaged, + IsPrimaryId, + IsPrimaryName, + IsRenameable, + IsSecured, + IsValidForAdvancedFind, + IsValidForCreate, + IsValidForRead, + IsValidForUpdate, + LinkedAttributeId, + LogicalName, + MaxLength, + MaxValue, + MetadataId, + MinValue, + Precision, + PrecisionSource, + RequiredLevel, + SchemaName, + YomiOf, + } + + export enum SearchableRelationshipMetadataProperties { + HasChanged, + Entity1IntersectAttribute, + Entity1LogicalName, + Entity2IntersectAttribute, + Entity2LogicalName, + IntersectEntityName, + IsCustomizable, + IntroducedVersion, + IsCustomRelationship, + IsManaged, + IsValidForAdvancedFind, + MetadataId, + ReferencedAttribute, + ReferencedEntity, + ReferencingAttribute, + ReferencingEntity, + RelationshipType, + SchemaName, + SecurityTypes, + } + + export enum MetadataConditionOperator { + Equals, + NotEquals, + In, + NotIn, + GreaterThan, + LessThan, + } + + export interface IEntityMetadata { + ActivityTypeMask: number; + Attributes: IAttributeMetadata[]; + AutoCreateAccessTeams: any; + AutoRouteToOwnerQueue: boolean; + CanBeInManyToMany: ManagedProperty; + CanBePrimaryEntityInRelationship: ManagedProperty; + CanBeRelatedEntityInRelationship: ManagedProperty; + CanCreateAttributes: ManagedProperty; + CanCreateCharts: ManagedProperty; + CanCreateForms: ManagedProperty; + CanCreateViews: ManagedProperty; + CanModifyAdditionalSettings: ManagedProperty; + CanTriggerWorkflow: boolean; + Description: Label; + DisplayCollectionName: Label; + DisplayName: Label; + IconLargeName: string; + IconMediumName: string; + IconSmallName: string; + IntroducedVersion: any; + IsActivity: boolean; + IsActivityParty: boolean; + IsAIRUpdated: boolean; + IsAuditEnabled: ManagedProperty; + IsAvailableOffline: boolean; + IsBusinessProcessEnabled: boolean; + IsChildEntity: boolean; + IsConnectionsEnabled: ManagedProperty; + IsCustomEntity: boolean; + IsCustomizable: ManagedProperty; + IsDocumentManagementEnabled: boolean; + IsDuplicateDetectionEnabled: ManagedProperty; + IsEnabledForCharts: boolean; + IsImportable: boolean; + IsIntersect: boolean; + IsMailMergeEnabled: ManagedProperty; + IsManaged: boolean; + IsMappable: ManagedProperty; + IsQuickCreateEnabled: boolean; + IsReadingPaneEnabled: boolean; + IsRenameable: boolean; + IsValidForAdvancedFind: boolean; + IsValidForQueue: ManagedProperty; + IsVisibleInMobile: ManagedProperty; + IsVisibleInMobileClient: boolean; + LogicalName: string; + ManyToManyRelationships: ManyToManyRelationshipMetadata; + ManyToOneRelationships: OneToManyRelationshipMetadata; + MetadataId: string; + ObjectTypeCode: number; + OneToManyRelationships: OneToManyRelationshipMetadata; + OwnershipType: "BusinessOwned" | "BusinessParented" | "None OrganizationOwned" | "TeamOwned UserOwned"; + PrimaryIdAttribute: string; + PrimaryImageAttribute: string; + PrimaryNameAttribute: string; + Privileges: SecurityPrivilegeMetadata[]; + RecurrenceBaseEntityLogicalName: string; + ReportViewName: string; + SchemaName: string; + } + + export interface SecurityPrivilegeMetadata { + CanBeBasic: boolean; + CanBeDeep: boolean; + CanBeEntityReference: boolean; + CanBeGlobal: boolean; + CanBeLocal: boolean; + CanBeParentEntityReference: boolean; + ExtensionData: boolean; + Name: string; + PrivilegeId: string; + PrivilegeType: "Append" | "AppendTo" | "Assign" | "Create" | "Delete" | "None" | "Read" | "Share" | "Write"; + } + + export interface OneToManyRelationshipMetadata { + AssociatedMenuConfiguration: AssociatedMenuConfiguration; + CascadeConfiguration: CascadeConfiguration; + HasChanged: any; + IntroducedVersion: any; + IsCustomizable: ManagedProperty; + IsCustomRelationship: boolean; + IsHierarchical: any; + IsManaged: boolean; + IsValidForAdvancedFind: boolean; + MetadataId: string; + ReferencedAttribute: string; + ReferencedEntity: string; + ReferencingAttribute: string; + ReferencingEntity: string; + RelationshipType: string; + SchemaName: string; + SecurityTypes: any; + } + + export interface CascadeConfiguration { + Assign: CascadeType; + Delete: CascadeType; + ExtensionData: CascadeType; + Merge: CascadeType; + Reparent: CascadeType; + Share: CascadeType; + Unshare: CascadeType; + } + + export type CascadeType = "Active" | "Cascade" | "NoCascade" | "UserOwned"; + + export interface ManyToManyRelationshipMetadata { + Entity1AssociatedMenuConfiguration: AssociatedMenuConfiguration; + Entity1IntersectAttribute: string; + Entity1LogicalName: string; + Entity2AssociatedMenuConfiguration: AssociatedMenuConfiguration; + Entity2IntersectAttribute: string; + Entity2LogicalName: string; + HasChanged: boolean; + IntersectEntityName: string; + IntroducedVersion: any; + IsCustomizable: ManagedProperty; + IsCustomRelationship: boolean; + IsManaged: boolean; + IsValidForAdvancedFind: boolean; + MetadataId: string; + RelationshipType: RelationshipType; + SchemaName: string; + SecurityTypes: SecurityType; + } + + export interface AssociatedMenuConfiguration { + Behavior: AssociatedMenuBehavior; + Group: AssociatedMenuGroup; + Label: Label; + Order: number; + } + + export type AssociatedMenuBehavior = "DoNotDisplay" | "UseCollectionName" | "UseLabel"; + + export type AssociatedMenuGroup = "Details" | "Marketing" | "Sales" | "Service"; + + export type RelationshipType = "Default" | "ManyToManyRelationship" | "OneToManyRelationship"; + + export type SecurityType = "Append" | "Inheritance" | "None" | "ParentChild" | "Pointer"; + + export interface IAttributeMetadata { + AttributeOf: string; + AttributeType: "Customer" | "DateTime" | "Decimal" | "Double" | "EntityName" | "Integer" | "Lookup" | "ManagedProperty" | "Memo" | "Money" | "Owner" | "PartyList" | "Picklist" | "State" | "Status" | "Uniqueidentifier" | "Virtual" + AttributeTypeName: "BigIntType" | "BooleanType" | "CalendarRulesType" | "CustomerType" | "DateTimeType" | "DecimalType" | "DoubleType" | "EntityNameType" | "ImageType" | "IntegerType" | "LookupType" | "ManagedPropertyType" | "MemoType" | "MoneyType" | "OwnerType" | "PartyListType" | "PicklistType" | "StateType StatusType" | "StringType" | "UniqueidentifierType" | "VirtualType"; + CalculationOf: any; + CanBeSecuredForCreate: boolean; + CanBeSecuredForRead: boolean; + CanBeSecuredForUpdate: boolean; + CanModifyAdditionalSettings: ManagedProperty; + ColumnNumber: number; + DefaultFormValue: any; + DefaultValue: any; + DeprecatedVersion: any; + Description: Label; + DisplayName: Label; + EntityLogicalName: string; + Format: any; + FormatName: string; + ImeMode: any; + IntroducedVersion: any; + IsAuditEnabled: boolean; + IsCustomAttribute: boolean; + IsCustomizable: ManagedProperty; + IsManaged: boolean; + IsPrimaryId: boolean; + IsPrimaryName: boolean; + IsRenameable: ManagedProperty; + IsSecured: boolean; + IsValidForAdvancedFind: ManagedProperty; + IsValidForCreate: boolean; + IsValidForRead: boolean; + IsValidForUpdate: boolean; + LinkedAttributeId: string; + LogicalName: string; + MaxLength: number; + MaxValue: any; + MetadataId: string; + MinValue: number; + OptionSet: any; + Precision: any; + PrecisionSource: any; + RequiredLevel: ManagedProperty; + SchemaName: string; + Targets: string[]; + YomiOf: any; + } + + export interface ManagedProperty { + CanBeChanged: boolean; + ManagedPropertyLogicalName: string; + Value: T; + } + + export interface Label { + LocalizedLabels: LocalizedLabel[]; + UserLocalizedLabel: LocalizedLabel; + } + + export interface LocalizedLabel { + Label: string; + LangaugeCode: number; + MetadataId: string; + HasChanged: boolean; + IsManaged: boolean; + } + + namespace ValueEnums { + export enum OwnershipType { + None, + OrganizationOwned, + TeamOwned, + UserOwned, + } + + export enum AttributeTypeCode { + BigInt, + Boolean, + CalendarRules, + Customer, + DateTime, + Decimal, + Double, + EntityName, + Integer, + Lookup, + ManagedProperty, + Memo, + Money, + Owner, + PartyList, + Picklist, + State, + Status, + String, + Uniqueidentifier, + Virtual, + } + + + export enum AttributeRequiredLevel { + ApplicationRequired, + None, + Recommended, + SystemRequired, + } + + + export enum DateTimeFormat { + DateAndTime, + DateOnly, + } + + export enum ImeMode { + Active, + Auto, + Disabled, + Inactive, + } + + + + export enum IntegerFormat { + Duration, + Language, + Locale, + None, + TimeZone, + } + + + export enum SecurityTypes { + Append, + Inheritance, + None, + ParentChild, + Pointer, + } + + export enum StringFormat { + Email, + PhoneticGuide, + Text, + TextArea, + TickerSymbol, + Url, + VersionNumber, + } } } -} -declare namespace Sdk.Mdq.ValueEnums -{ } + namespace Sdk.Mdq.ValueEnums + { } +} \ No newline at end of file diff --git a/microsoft-sdk-soap/microsoft-sdk-soap-tests.ts b/microsoft-sdk-soap/microsoft-sdk-soap-tests.ts index 2e55285870..3be28629c3 100644 --- a/microsoft-sdk-soap/microsoft-sdk-soap-tests.ts +++ b/microsoft-sdk-soap/microsoft-sdk-soap-tests.ts @@ -1,4 +1,5 @@ +import * as Q from "q"; // QueryByAttribute var queryByAttribute = new Sdk.Query.QueryByAttribute( "account" ); @@ -17,4 +18,4 @@ queryExpression.addCondition( "account", "accountname", Sdk.Query.ConditionOpera Sdk.Q.retrieveMultiple( queryExpression ).then( entityCollection => { console.log( "Query matches " + entityCollection.getTotalRecordCount() + " records." ); -} ); \ No newline at end of file +} ); \ No newline at end of file diff --git a/microsoft-sdk-soap/tsconfig.json b/microsoft-sdk-soap/tsconfig.json index ef973bcb22..41ffa9a040 100644 --- a/microsoft-sdk-soap/tsconfig.json +++ b/microsoft-sdk-soap/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/mongoose-seeder/tsconfig.json b/mongoose-seeder/tsconfig.json index 143fcc1ce4..8e3f193dbf 100644 --- a/mongoose-seeder/tsconfig.json +++ b/mongoose-seeder/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/msportalfx-test/index.d.ts b/msportalfx-test/index.d.ts index a3fbc2d26f..c2d64f95d4 100644 --- a/msportalfx-test/index.d.ts +++ b/msportalfx-test/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Julio Casal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from "q"; export = MsPortalTestFx; diff --git a/msportalfx-test/tsconfig.json b/msportalfx-test/tsconfig.json index 115af8c6ef..16c68ed3a8 100644 --- a/msportalfx-test/tsconfig.json +++ b/msportalfx-test/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/node-form/index.d.ts b/node-form/index.d.ts index 41781ee154..ddeb3d542f 100644 --- a/node-form/index.d.ts +++ b/node-form/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Roman Samec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from "q"; export as namespace Validation; diff --git a/node-form/tsconfig.json b/node-form/tsconfig.json index 1bb627df73..d0fa4eb87b 100644 --- a/node-form/tsconfig.json +++ b/node-form/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/node-persist/index.d.ts b/node-persist/index.d.ts index 42d72fe587..bb8df33369 100644 --- a/node-persist/index.d.ts +++ b/node-persist/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import * as Q from "q"; diff --git a/node-persist/tsconfig.json b/node-persist/tsconfig.json index f6bd656274..b2563c2ac3 100644 --- a/node-persist/tsconfig.json +++ b/node-persist/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/o.js/index.d.ts b/o.js/index.d.ts index eaa6732c40..00a5f2b5ae 100644 --- a/o.js/index.d.ts +++ b/o.js/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Matteo Antony Mistretta , Brad Zacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare module 'o.js' { + import Q = require("q"); + interface Options { endpoint : string json ?: boolean diff --git a/o.js/tsconfig.json b/o.js/tsconfig.json index a72850afef..b16d5111e8 100644 --- a/o.js/tsconfig.json +++ b/o.js/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/orchestrator/index.d.ts b/orchestrator/index.d.ts index 23c8a0f507..c1eae16416 100644 --- a/orchestrator/index.d.ts +++ b/orchestrator/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from "q"; declare type Strings = string|string[]; diff --git a/orchestrator/tsconfig.json b/orchestrator/tsconfig.json index 1ce0c08b62..d3af83cd62 100644 --- a/orchestrator/tsconfig.json +++ b/orchestrator/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/pathwatcher/tsconfig.json b/pathwatcher/tsconfig.json index 199b1ce4e0..00b8e7052f 100644 --- a/pathwatcher/tsconfig.json +++ b/pathwatcher/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/promise-pg/index.d.ts b/promise-pg/index.d.ts index 5deba594a1..d93f13d8c0 100644 --- a/promise-pg/index.d.ts +++ b/promise-pg/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import * as stream from 'stream'; import * as pg from 'pg'; diff --git a/promise-pg/tsconfig.json b/promise-pg/tsconfig.json index 0f74dbb52b..b28fb9baa9 100644 --- a/promise-pg/tsconfig.json +++ b/promise-pg/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/promise-pool/index.d.ts b/promise-pool/index.d.ts index 810b629ee2..51af449480 100644 --- a/promise-pool/index.d.ts +++ b/promise-pool/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import * as Q from "q"; /** diff --git a/promise-pool/tsconfig.json b/promise-pool/tsconfig.json index b72557a58b..f7be6ce41d 100644 --- a/promise-pool/tsconfig.json +++ b/promise-pool/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/q-io/index.d.ts b/q-io/index.d.ts index b69a9c72e0..783f70ddc4 100644 --- a/q-io/index.d.ts +++ b/q-io/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// //TODO add support for q-io/http-apps //TODO add verified support for q-io/fs-mock @@ -15,94 +14,94 @@ declare namespace QioFS { //TODO how to define the multiple return types? use any for now? - export function open(path:string, options?:any):Q.Promise; + export function open(path: string, options?: any): Q.Promise; //export function open(path:string, options?:any):Q.Promise; //export function open(path:string, options?:any):Q.Promise; //export function open(path:string, options?:any):Q.Promise; //TODO how to define the multiple return types? use any for now? - export function read(path:string, options?:any):Q.Promise; + export function read(path: string, options?: any): Q.Promise; //export function read(path:string, options?:any):Q.Promise; //export function read(path:string, options?:any):Q.Promise; - export function write(path:string, content:Buffer, options?:any):Q.Promise; - export function write(path:string, content:string, options?:any):Q.Promise; + export function write(path: string, content: Buffer, options?: any): Q.Promise; + export function write(path: string, content: string, options?: any): Q.Promise; - export function append(path:string, content:Buffer, options?:any):Q.Promise; - export function append(path:string, content:string, options?:any):Q.Promise; + export function append(path: string, content: Buffer, options?: any): Q.Promise; + export function append(path: string, content: string, options?: any): Q.Promise; - export function copy(source:string, target:string):Q.Promise; - export function copyTree(source:string, target:string):Q.Promise; + export function copy(source: string, target: string): Q.Promise; + export function copyTree(source: string, target: string): Q.Promise; - export function list(path:string):Q.Promise; - export function listTree(path:string, guard?:(path:string, stat:any) => boolean):Q.Promise; - export function listDirectoryTree(path:string):Q.Promise; + export function list(path: string): Q.Promise; + export function listTree(path: string, guard?: (path: string, stat: any) => boolean): Q.Promise; + export function listDirectoryTree(path: string): Q.Promise; - export function makeDirectory(path:string, mode?:string):Q.Promise; - export function makeDirectory(path:string, mode?:number):Q.Promise; - export function makeTree(path:string, mode?:string):Q.Promise; - export function makeTree(path:string, mode?:number):Q.Promise; + export function makeDirectory(path: string, mode?: string): Q.Promise; + export function makeDirectory(path: string, mode?: number): Q.Promise; + export function makeTree(path: string, mode?: string): Q.Promise; + export function makeTree(path: string, mode?: number): Q.Promise; - export function remove(path:string):Q.Promise; - export function removeTree(path:string):Q.Promise; + export function remove(path: string): Q.Promise; + export function removeTree(path: string): Q.Promise; - export function rename(source:string, target:string):Q.Promise; - export function move(source:string, target:string):Q.Promise; + export function rename(source: string, target: string): Q.Promise; + export function move(source: string, target: string): Q.Promise; - export function link(source:string, target:any):Q.Promise; + export function link(source: string, target: any): Q.Promise; - export function symbolicCopy(source:string, target:string, type:string):Q.Promise; - export function symbolicLink(target:string, link:string, type:string):Q.Promise; + export function symbolicCopy(source: string, target: string, type: string): Q.Promise; + export function symbolicLink(target: string, link: string, type: string): Q.Promise; - export function chown(path:string, uid:number, gid:number):Q.Promise; - export function chmod(path:string, mode?:string):Q.Promise; - export function chmod(path:string, mode?:number):Q.Promise; + export function chown(path: string, uid: number, gid: number): Q.Promise; + export function chmod(path: string, mode?: string): Q.Promise; + export function chmod(path: string, mode?: number): Q.Promise; - export function stat(path:string):Q.Promise; - export function statLink(path:string):Q.Promise; - export function statFd(fd:number):Q.Promise; + export function stat(path: string): Q.Promise; + export function statLink(path: string): Q.Promise; + export function statFd(fd: number): Q.Promise; - export function exists(path:string):Q.Promise; + export function exists(path: string): Q.Promise; - export function isFile(path:string):Q.Promise; - export function isDirectory(path:string):Q.Promise; - export function isSymbolicLink(path:string):Q.Promise; + export function isFile(path: string): Q.Promise; + export function isDirectory(path: string): Q.Promise; + export function isSymbolicLink(path: string): Q.Promise; - export function lastModified(path:string):Q.Promise; - export function lastAccessed(path:string):Q.Promise; + export function lastModified(path: string): Q.Promise; + export function lastAccessed(path: string): Q.Promise; - export function split(path:string):string[]; - export function join(...paths:string[]):string; - export function join(paths:string[]):string; - export function resolve(...path:string[]):string; - export function resolve(paths:string[]):string; - export function normal(...path:string[]):string; - export function normal(paths:string[]):string; - export function absolute(path:string):string; + export function split(path: string): string[]; + export function join(...paths: string[]): string; + export function join(paths: string[]): string; + export function resolve(...path: string[]): string; + export function resolve(paths: string[]): string; + export function normal(...path: string[]): string; + export function normal(paths: string[]): string; + export function absolute(path: string): string; - export function canonical(path:string):Q.Promise; - export function readLink(path:string):Q.Promise; + export function canonical(path: string): Q.Promise; + export function readLink(path: string): Q.Promise; - export function contains(parent:string, child:string):boolean; + export function contains(parent: string, child: string): boolean; - export function relative(source:string, target:string):Q.Promise; + export function relative(source: string, target: string): Q.Promise; - export function relativeFromFile(source:string, target:string):string; - export function relativeFromDirectory(source:string, target:string):string; + export function relativeFromFile(source: string, target: string): string; + export function relativeFromDirectory(source: string, target: string): string; - export function isAbsolute(path:string):boolean; - export function isRelative(path:string):boolean; - export function isRoot(path:string):boolean; + export function isAbsolute(path: string): boolean; + export function isRelative(path: string): boolean; + export function isRoot(path: string): boolean; - export function root(path:string):string; - export function directory(path:string):string; - export function base(path:string, extension:string):string; - export function extension(path:string):string; + export function root(path: string): string; + export function directory(path: string): string; + export function base(path: string, extension: string): string; + export function extension(path: string): string; //this should return a q-io/fs-mock MockFS - export function reroot(path:string):typeof QioFS; + export function reroot(path: string): typeof QioFS; - export function toObject(path:string):{[path:string]:Buffer}; + export function toObject(path: string): { [path: string]: Buffer }; //listed but not implemented by Q-io //export function glob(pattern):Q.Promise; @@ -110,116 +109,116 @@ declare namespace QioFS { //TODO link this to node.js FS module (no lazy clones) interface Stats { - node:NodeStats; - size:number; + node: NodeStats; + size: number; } interface NodeStats { - isFile():boolean; - isDirectory():boolean; - isBlockDevice():boolean; - isCharacterDevice():boolean; - isSymbolicLink():boolean; - isFIFO():boolean; - isSocket():boolean; - node:NodeStats; - dev:number; - ino:number; - mode:number; - nlink:number; - uid:number; - gid:number; - rdev:number; - size:number; - blksize:number; - blocks:number; - atime:Date; - mtime:Date; - ctime:Date; + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + node: NodeStats; + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + blksize: number; + blocks: number; + atime: Date; + mtime: Date; + ctime: Date; } } declare namespace QioHTTP { - export function request(request:Request):Q.Promise; - export function request(url:string):Q.Promise; + export function request(request: Request): Q.Promise; + export function request(url: string): Q.Promise; - export function read(request:Request):Q.Promise; - export function read(url:string):Q.Promise; + export function read(request: Request): Q.Promise; + export function read(url: string): Q.Promise; - export function normalizeRequest(request:Request):Request; - export function normalizeRequest(url:string):Request; - export function normalizeResponse(response:Response):Response; + export function normalizeRequest(request: Request): Request; + export function normalizeRequest(url: string): Request; + export function normalizeResponse(response: Response): Response; interface Request { - url:string; - path:string; - scriptName:string; - pathInfo:string; - version:string[]; - method:string; - scheme:string; + url: string; + path: string; + scriptName: string; + pathInfo: string; + version: string[]; + method: string; + scheme: string; - host:string; - port:number; - remoteHost:string; - remotePort:number; + host: string; + port: number; + remoteHost: string; + remotePort: number; - headers:Headers; - agent:any; - body:any; - node:any; + headers: Headers; + agent: any; + body: any; + node: any; } interface Response { - status:number; - headers:Headers; - body:Qio.Reader - onclose:() => void; - node:any; + status: number; + headers: Headers; + body: Qio.Reader + onclose: () => void; + node: any; } interface Headers { - [name:string]:any; + [name: string]: any; // [name:string]:any[]; } interface Body extends Qio.Stream { } interface Application { - (req:Request):Q.Promise; + (req: Request): Q.Promise; } } declare namespace Qio { interface ForEachCallback { - (chunk:Buffer):Q.Promise; - (chunk:string):Q.Promise; + (chunk: Buffer): Q.Promise; + (chunk: string): Q.Promise; } interface ForEach { - forEach(callback:ForEachCallback):Q.Promise; + forEach(callback: ForEachCallback): Q.Promise; } interface Reader extends ForEach { - read(charset:string):Q.Promise; - read():Q.Promise; - close():void; + read(charset: string): Q.Promise; + read(): Q.Promise; + close(): void; node: NodeJS.ReadableStream; } interface Writer { - write(content:string):void; - write(content:Buffer):void; - flush():Q.Promise; - close():void; - destroy():void; + write(content: string): void; + write(content: Buffer): void; + flush(): Q.Promise; + close(): void; + destroy(): void; node: NodeJS.WritableStream; } interface Stream { - read(charset:string):Q.Promise; - read():Q.Promise; - write(content:string):void; - write(content:Buffer):void; - flush():Q.Promise; - close():void; - destroy():void; - node:any; + read(charset: string): Q.Promise; + read(): Q.Promise; + write(content: string): void; + write(content: Buffer): void; + flush(): Q.Promise; + close(): void; + destroy(): void; + node: any; } interface BufferReader extends QioBufferReader { @@ -227,31 +226,32 @@ declare namespace Qio { } } interface QioBufferReader { - new ():Qio.Reader; - read(stream:Qio.Reader, charset:string):string; - read(stream:Qio.Reader):Buffer; - join(buffers:Buffer[]):Buffer; + new (): Qio.Reader; + read(stream: Qio.Reader, charset: string): string; + read(stream: Qio.Reader): Buffer; + join(buffers: Buffer[]): Buffer; } interface QioBufferWriter { - (writer:Buffer):Qio.Writer; - Writer:Qio.Writer; + (writer: Buffer): Qio.Writer; + Writer: Qio.Writer; } interface QioBufferStream { - (buffer:Buffer, encoding:string):Qio.Stream + (buffer: Buffer, encoding: string): Qio.Stream } declare module "q-io/http" { -export = QioHTTP; + import * as Q from "q"; + export = QioHTTP; } declare module "q-io/fs" { -export = QioFS; + export = QioFS; } declare module "q-io/reader" { -export = QioBufferReader; + export = QioBufferReader; } declare module "q-io/writer" { -export = QioBufferWriter; + export = QioBufferWriter; } declare module "q-io/buffer-stream" { -export = QioBufferStream; + export = QioBufferStream; } diff --git a/q-io/q-io-tests.ts b/q-io/q-io-tests.ts index ae6d14d623..fb5e7e97c2 100644 --- a/q-io/q-io-tests.ts +++ b/q-io/q-io-tests.ts @@ -1,5 +1,3 @@ -import * as Q from 'q'; - var fs:typeof QioFS = require('q-io/fs'); var http:typeof QioHTTP = require('q-io/http'); diff --git a/q-io/tsconfig.json b/q-io/tsconfig.json index a0afa359c6..cccbe944b1 100644 --- a/q-io/tsconfig.json +++ b/q-io/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/q-retry/index.d.ts b/q-retry/index.d.ts index dbdf914b6c..2d06f97f2e 100644 --- a/q-retry/index.d.ts +++ b/q-retry/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: VILIC VANE // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from 'q'; export = Q; diff --git a/q-retry/tsconfig.json b/q-retry/tsconfig.json index 8b9a3250f4..19c7cb8412 100644 --- a/q-retry/tsconfig.json +++ b/q-retry/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/q/index.d.ts b/q/index.d.ts index 6b2deb3161..c4c1af5ec0 100644 --- a/q/index.d.ts +++ b/q/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for Q +// Type definitions for Q 1.0 // Project: https://github.com/kriskowal/q // Definitions by: Barrie Nemetchek , Andrew Gaspar , John Reilly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 export = Q; export as namespace Q; @@ -21,12 +22,12 @@ declare function Q(value: T): Q.Promise; declare function Q(): Q.Promise; declare namespace Q { - type IWhenable = IPromise | T; - interface IPromise { + export type IWhenable = IPromise | T; + export interface IPromise { then(onFulfill?: (value: T) => IWhenable, onReject?: (error: any) => IWhenable): IPromise; } - interface Deferred { + export interface Deferred { promise: Promise; resolve(value?: IWhenable): void; reject(reason: any): void; @@ -34,7 +35,7 @@ declare namespace Q { makeNodeResolver(): (reason: any, value: T) => void; } - interface Promise { + export interface Promise { /** * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object. @@ -167,7 +168,7 @@ declare namespace Q { inspect(): PromiseState; } - interface PromiseState { + export interface PromiseState { state: "fulfilled" | "rejected" | "pending"; value?: T; reason?: any; @@ -182,11 +183,8 @@ declare namespace Q { // If a non-promise value is provided, it will not reject or progress export function when(value: IWhenable, onFulfilled: (val: T) => IWhenable, onRejected?: (reason: any) => IWhenable, onProgress?: (progress: any) => any): Promise; - /** - * Currently "impossible" (and I use the term loosely) to implement due to TypeScript limitations as it is now. - * See: https://github.com/Microsoft/TypeScript/issues/1784 for discussion on it. - */ - // export function try(method: Function, ...args: any[]): Promise; + function _try(method: Function, ...args: any[]): Promise; + export { _try as try }; export function fbind(method: (...args: any[]) => IWhenable, ...args: any[]): (...args: any[]) => Promise; diff --git a/q/q-tests.ts b/q/q-tests.ts index 7ebc35adb3..5f79d7f1e4 100644 --- a/q/q-tests.ts +++ b/q/q-tests.ts @@ -224,3 +224,14 @@ var p2: Q.Promise<[string, number]> = y1.then(val => Q.all(val)); var p3: Q.Promise<[string, number]> = Q.all(y1); var p5: Q.Promise<[string, number]> = y2.then(val => Q.all(val)); var p6: Q.Promise<[string, number]> = Q.all(y2); + + +Q.try(function () { + if (Math.random() % 2) { + throw new Error("The cloud is down!"); + } + return true; +}) +.catch(function (error) { + console.error("Couldn't sync to the cloud", error); +}); \ No newline at end of file diff --git a/q/v0/index.d.ts b/q/v0/index.d.ts new file mode 100644 index 0000000000..6b2deb3161 --- /dev/null +++ b/q/v0/index.d.ts @@ -0,0 +1,357 @@ +// Type definitions for Q +// Project: https://github.com/kriskowal/q +// Definitions by: Barrie Nemetchek , Andrew Gaspar , John Reilly +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = Q; +export as namespace Q; + +/** + * If value is a Q promise, returns the promise. + * If value is a promise from another library it is coerced into a Q promise (where possible). + */ +declare function Q(promise: Q.IPromise): Q.Promise; +/** + * If value is not a promise, returns a promise that is fulfilled with value. + */ +declare function Q(value: T): Q.Promise; +/** + * Calling with nothing at all creates a void promise + */ +declare function Q(): Q.Promise; + +declare namespace Q { + type IWhenable = IPromise | T; + interface IPromise { + then(onFulfill?: (value: T) => IWhenable, onReject?: (error: any) => IWhenable): IPromise; + } + + interface Deferred { + promise: Promise; + resolve(value?: IWhenable): void; + reject(reason: any): void; + notify(value: any): void; + makeNodeResolver(): (reason: any, value: T) => void; + } + + interface Promise { + /** + * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object. + + * finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished. + */ + fin(finallyCallback: () => any): Promise; + /** + * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object. + + * finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished. + */ + finally(finallyCallback: () => any): Promise; + + /** + * The then method from the Promises/A+ specification, with an additional progress handler. + */ + then(onFulfill?: (value: T) => IWhenable, onReject?: (error: any) => IWhenable, onProgress?: Function): Promise; + + /** + * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. + * + * This is especially useful in conjunction with all + */ + spread(onFulfill: (...args: any[]) => IWhenable, onReject?: (reason: any) => IWhenable): Promise; + + fail(onRejected: (reason: any) => IWhenable): Promise; + + /** + * A sugar method, equivalent to promise.then(undefined, onRejected). + */ + catch(onRejected: (reason: any) => IWhenable): Promise; + + /** + * A sugar method, equivalent to promise.then(undefined, undefined, onProgress). + */ + progress(onProgress: (progress: any) => any): Promise; + + /** + * Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection, either because promise is rejected and no onRejected callback was provided, or because onFulfilled or onRejected threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a future turn of the event loop. + * + * This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions thrown in then callbacks are consumed and transformed into rejections, exceptions at the end of the chain are easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the event loop, so that it won't be caught, it causes an onerror event on the browser window, or an uncaughtException event on Node.js's process object. + * + * Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set, exceptions will be delivered there instead of thrown in a future turn. + * + * The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you, call done to terminate it. + */ + done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void; + + /** + * If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason) when/if promise becomes rejected, or as callback(null, fulfillmentValue) when/if promise becomes fulfilled. If callback is not a function, simply returns promise. + */ + nodeify(callback: (reason: any, value: any) => void): Promise; + + /** + * Returns a promise to get the named property of an object. Essentially equivalent to + * + * promise.then(function (o) { + * return o[propertyName]; + * }); + */ + get(propertyName: String): Promise; + set(propertyName: String, value: any): Promise; + delete(propertyName: String): Promise; + /** + * Returns a promise for the result of calling the named method of an object with the given array of arguments. The object itself is this in the function, just like a synchronous method call. Essentially equivalent to + * + * promise.then(function (o) { + * return o[methodName].apply(o, args); + * }); + */ + post(methodName: String, args: any[]): Promise; + /** + * Returns a promise for the result of calling the named method of an object with the given variadic arguments. The object itself is this in the function, just like a synchronous method call. + */ + invoke(methodName: String, ...args: any[]): Promise; + fapply(args: any[]): Promise; + fcall(...args: any[]): Promise; + + /** + * Returns a promise for an array of the property names of an object. Essentially equivalent to + * + * promise.then(function (o) { + * return Object.keys(o); + * }); + */ + keys(): Promise; + + /** + * A sugar method, equivalent to promise.then(function () { return value; }). + */ + thenResolve(value: U): Promise; + /** + * A sugar method, equivalent to promise.then(function () { throw reason; }). + */ + thenReject(reason: any): Promise; + + /** + * Attaches a handler that will observe the value of the promise when it becomes fulfilled, returning a promise for that same value, perhaps deferred but not replaced by the promise returned by the onFulfilled handler. + */ + tap(onFulfilled: (value: T) => any): Promise; + + timeout(ms: number, message?: string): Promise; + /** + * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed. + */ + delay(ms: number): Promise; + + /** + * Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true. + */ + isFulfilled(): boolean; + /** + * Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false. + */ + isRejected(): boolean; + /** + * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false. + */ + isPending(): boolean; + + valueOf(): any; + + /** + * Returns a "state snapshot" object, which will be in one of three forms: + * + * - { state: "pending" } + * - { state: "fulfilled", value: } + * - { state: "rejected", reason: } + */ + inspect(): PromiseState; + } + + interface PromiseState { + state: "fulfilled" | "rejected" | "pending"; + value?: T; + reason?: any; + } + + // If no value provided, returned promise will be of void type + export function when(): Promise; + + // if no fulfill, reject, or progress provided, returned promise will be of same type + export function when(value: IWhenable): Promise; + + // If a non-promise value is provided, it will not reject or progress + export function when(value: IWhenable, onFulfilled: (val: T) => IWhenable, onRejected?: (reason: any) => IWhenable, onProgress?: (progress: any) => any): Promise; + + /** + * Currently "impossible" (and I use the term loosely) to implement due to TypeScript limitations as it is now. + * See: https://github.com/Microsoft/TypeScript/issues/1784 for discussion on it. + */ + // export function try(method: Function, ...args: any[]): Promise; + + export function fbind(method: (...args: any[]) => IWhenable, ...args: any[]): (...args: any[]) => Promise; + + export function fcall(method: (...args: any[]) => T, ...args: any[]): Promise; + + export function send(obj: any, functionName: string, ...args: any[]): Promise; + export function invoke(obj: any, functionName: string, ...args: any[]): Promise; + export function mcall(obj: any, functionName: string, ...args: any[]): Promise; + + export function denodeify(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise; + export function nbind(nodeFunction: Function, thisArg: any, ...args: any[]): (...args: any[]) => Promise; + export function nfbind(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise; + export function nfcall(nodeFunction: Function, ...args: any[]): Promise; + export function nfapply(nodeFunction: Function, args: any[]): Promise; + + export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Promise; + export function npost(nodeModule: any, functionName: string, args: any[]): Promise; + export function nsend(nodeModule: any, functionName: string, ...args: any[]): Promise; + export function nmcall(nodeModule: any, functionName: string, ...args: any[]): Promise; + + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable, IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D, E, F]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D, E]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable]>): Promise<[A, B]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable[]>): Promise; + + /** + * Returns a promise for the first of an array of promises to become settled. + */ + export function race(promises: IWhenable[]): Promise; + + /** + * Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected. + */ + export function allSettled(promises: IWhenable[]>): Promise[]>; + + export function allResolved(promises: IWhenable[]>): Promise[]>; + + /** + * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. + * This is especially useful in conjunction with all. + */ + export function spread(promises: IWhenable[], onFulfilled: (...args: T[]) => IWhenable, onRejected?: (reason: any) => IWhenable): Promise; + + /** + * Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message is not supplied, the message will be "Timed out after " + ms + " ms". + */ + export function timeout(promise: Promise, ms: number, message?: string): Promise; + + /** + * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed. + */ + export function delay(promise: Promise, ms: number): Promise; + /** + * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed. + */ + export function delay(value: T, ms: number): Promise; + /** + * Returns a promise that will be fulfilled with undefined after at least ms milliseconds have passed. + */ + export function delay(ms: number): Promise ; + /** + * Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true. + */ + export function isFulfilled(promise: Promise): boolean; + /** + * Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false. + */ + export function isRejected(promise: Promise): boolean; + /** + * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false. + */ + export function isPending(promise: Promise): boolean; + + /** + * Returns a "deferred" object with a: + * promise property + * resolve(value) method + * reject(reason) method + * notify(value) method + * makeNodeResolver() method + */ + export function defer(): Deferred; + + /** + * Returns a promise that is rejected with reason. + */ + export function reject(reason?: any): Promise; + + export function Promise(resolver: (resolve: (val: IWhenable) => void , reject: (reason: any) => void , notify: (progress: any) => void ) => void ): Promise; + + /** + * Creates a new version of func that accepts any combination of promise and non-promise values, converting them to their fulfillment values before calling the original func. The returned version also always returns a promise: if func does a return or throw, then Q.promised(func) will return fulfilled or rejected promise, respectively. + * + * This can be useful for creating functions that accept either promises or non-promise values, and for ensuring that the function always returns a promise even in the face of unintentional thrown exceptions. + */ + export function promised(callback: (...args: any[]) => T): (...args: any[]) => Promise; + + /** + * Returns whether the given value is a Q promise. + */ + export function isPromise(object: any): boolean; + /** + * Returns whether the given value is a promise (i.e. it's an object with a then function). + */ + export function isPromiseAlike(object: any): boolean; + /** + * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false. + */ + export function isPending(object: any): boolean; + /** + * If an object is not a promise, it is as "near" as possible. + * If a promise is rejected, it is as "near" as possible too. + * If it’s a fulfilled promise, the fulfillment value is nearer. + * If it’s a deferred promise and the deferred has been resolved, the + * resolution is "nearer". + */ + export function nearer(promise: Promise): T; + + /** + * This is an experimental tool for converting a generator function into a deferred function. This has the potential of reducing nested callbacks in engines that support yield. + */ + export function async(generatorFunction: any): (...args: any[]) => Promise; + export function nextTick(callback: Function): void; + + /** + * A settable property that will intercept any uncaught errors that would otherwise be thrown in the next tick of the event loop, usually as a result of done. Can be useful for getting the full stack trace of an error in browsers, which is not usually possible with window.onerror. + */ + export var onerror: (reason: any) => void; + /** + * A settable property that lets you turn on long stack trace support. If turned on, "stack jumps" will be tracked across asynchronous promise operations, so that if an uncaught error is thrown by done or a rejection reason's stack property is inspected in a rejection callback, a long stack trace is produced. + */ + export var longStackSupport: boolean; + + /** + * Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does). + * Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason. + * Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value. + * Calling resolve with a non-promise value causes promise to be fulfilled with that value. + */ + export function resolve(object: IWhenable): Promise; + + /** + * Resets the global "Q" variable to the value it has before Q was loaded. + * This will either be undefined if there was no version or the version of Q which was already loaded before. + * @returns { The last version of Q. } + */ + export function noConflict(): typeof Q; +} diff --git a/q/v0/q-tests.ts b/q/v0/q-tests.ts new file mode 100644 index 0000000000..7ebc35adb3 --- /dev/null +++ b/q/v0/q-tests.ts @@ -0,0 +1,226 @@ +/// + + +import Q = require('q'); + +Q(8).then(x => console.log(x.toExponential())); +Q().then(() => console.log("nothing")); + +var delay = function (delay: number) { + var d = Q.defer(); + setTimeout(d.resolve, delay); + return d.promise; +}; + +Q.when(delay(1000), function (val: void) { + console.log('Hello, World!'); + return; +}); + +// Note from Q documentation: a deferred can be resolved with a value or a promise. +var otherPromise = Q.defer().promise; +Q.defer().resolve(otherPromise); + +Q.timeout(Q(new Date()), 1000, "My dates never arrived. :(").then(d => d.toJSON()); + +Q.delay(Q(8), 1000).then(x => x.toExponential()); +Q.delay(8, 1000).then(x => x.toExponential()); +Q.delay(Q("asdf"), 1000).then(x => x.length); +Q.delay("asdf", 1000).then(x => x.length); + +var eventualAdd = Q.promised((a?: number, b?: number) => a + b); +eventualAdd(Q(1), Q(2)).then(x => x.toExponential()); + +function eventually(eventually: T) { + return Q.delay(eventually, 1000); +}; + +var x = Q.all([1, 2, 3].map(eventually)); +Q.when(x, function (x) { + console.log(x); +}); + +Q.all([ + eventually(10), + eventually(20) +]).spread(function (x: number, y: number) { + console.log(x, y); +}); + +Q.all([ + eventually(10), + eventually(20) +]).then(function (results) { + let [x, y] = results; + console.log(x, y); +}); + + +Q.fcall(function () { }) + .then(function () { }) + .then(function () { }) + .then(function () { }) + .then(function (value4) { + // Do something with value4 + }, function (error) { + // Handle any error from step1 through step4 + }).done(); + +Q.allResolved([]) +.then(function (promises: Q.Promise[]) { + promises.forEach(function (promise) { + if (promise.isFulfilled()) { + var value = promise.valueOf(); + } else { + var exception = promise.valueOf().exception; + } + }) +}); + +Q(42) + .tap(() => "hello") + .tap(x => { + console.log(x); + }) + .then(x => { + console.log("42 == " + x); + }); + +declare var arrayPromise: Q.IPromise; +declare var stringPromise: Q.IPromise; +declare function returnsNumPromise(text: string): Q.Promise; +declare function returnsNumPromise(text: string): JQueryPromise; + +Q(arrayPromise) // type specification required + .then(arr => arr.join(',')) + .then(returnsNumPromise) // requires specification + .then(num => num.toFixed()); + +declare var jPromise: JQueryPromise; + +// if jQuery promises definition supported generics, this could be more interesting example +Q(jPromise).then(str => str.split(',')); +jPromise.then(returnsNumPromise); + +// watch the typing flow through from jQueryPromise to Q.Promise +Q(jPromise).then(str => str.split(',')); + +declare var promiseArray: Q.IPromise[]; +var qPromiseArray = promiseArray.map(p => Q(p)); +var myNums: any[] = [2, 3, Q(4), 5, Q(6), Q(7)]; + +Q.all(promiseArray).then(nums => nums.map(num => num.toPrecision(2)).join(',')); + +Q.all(myNums).then(nums => nums.map(Math.round)); + +Q.fbind((dateString?: string) => new Date(dateString), "11/11/1991")().then(d => d.toLocaleDateString()); + +Q.when(8, num => num + "!"); +Q.when(Q(8), num => num + "!").then(str => str.split(',')); +var voidPromise: Q.Promise = Q.when(); + +declare function saveToDisk(): Q.Promise; +declare function saveToCloud(): Q.Promise; +Q.allSettled([saveToDisk(), saveToCloud()]).spread(function (disk: any, cloud: any) { + console.log("saved to disk:", disk.state === "fulfilled"); + console.log("saved to cloud:", cloud.state === "fulfilled"); + + if (disk.state === "fulfilled") { + console.log("value was " + disk.value); + } + else if (disk.state === "rejected") { + console.log("rejected because " + disk.reason); + } +}).done(); + +var nodeStyle = (input: string, cb: Function) => { + cb(null, input); +}; + +Q.nfapply(nodeStyle, ["foo"]).done((result: string) => {}); +Q.nfcall(nodeStyle, "foo").done((result: string) => {}); +Q.denodeify(nodeStyle)('foo').done((result: string) => {}); +Q.nfbind(nodeStyle)('foo').done((result: string) => {}); + + +class Repo { + private items: any[] = [ + { name: 'Max', cute: false }, + { name: 'Annie', cute: true } + ]; + + find(options: any): Q.Promise { + var result = this.items; + + for (var key in options) { + result = result.filter(i => i[key] == options[key]); + } + + return Q(result); + } +} + +var kitty = new Repo(); +Q.nbind(kitty.find, kitty)({ cute: true }).done((kitties: any[]) => {}); + + +/* + * Test: Can "rethrow" rejected promises + */ +namespace TestCanRethrowRejectedPromises { + + interface Foo { + a: number; + } + + function nestedBar(): Q.Promise { + var deferred = Q.defer(); + + return deferred.promise; + } + + function bar(): Q.Promise { + return nestedBar() + .then((foo:Foo) => { + console.log("Lorem ipsum"); + }) + .fail((error) => { + console.log("Intermediate error handling"); + + /* + * Cannot do this, because: + * error TS2322: Type 'Promise' is not assignable to type 'Promise' + */ + //throw error; + + return Q.reject(error); + }) + ; + } + + bar() + .finally(() => { + console.log("Cleanup") + }) + .done() + ; + +} + +// test Q.Promise.all +var y1 = Q().then(() => { + var s = Q("hello"); + var n = Q(1); + return <[typeof s, typeof n]>[s, n]; +}); + +var y2 = Q().then(() => { + var s = "hello"; + var n = Q(1); + return <[typeof s, typeof n]>[s, n]; +}); + +var p2: Q.Promise<[string, number]> = y1.then(val => Q.all(val)); +var p3: Q.Promise<[string, number]> = Q.all(y1); +var p5: Q.Promise<[string, number]> = y2.then(val => Q.all(val)); +var p6: Q.Promise<[string, number]> = Q.all(y2); diff --git a/q/v0/tsconfig.json b/q/v0/tsconfig.json new file mode 100644 index 0000000000..c44ffeb935 --- /dev/null +++ b/q/v0/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "q": [ "q/v0" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "q-tests.ts" + ] +} \ No newline at end of file diff --git a/qajax/index.d.ts b/qajax/index.d.ts index 3476cb280e..fcfbea6649 100644 --- a/qajax/index.d.ts +++ b/qajax/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Boltmade // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from "q"; export = Qajax; diff --git a/qajax/tsconfig.json b/qajax/tsconfig.json index 8ba8578ef5..17bb7d92b2 100644 --- a/qajax/tsconfig.json +++ b/qajax/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/run-sequence/tsconfig.json b/run-sequence/tsconfig.json index b03e01e277..2d7e6640db 100644 --- a/run-sequence/tsconfig.json +++ b/run-sequence/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/status-bar/tsconfig.json b/status-bar/tsconfig.json index 874ffb81d1..9fe41d5d67 100644 --- a/status-bar/tsconfig.json +++ b/status-bar/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/text-buffer/tsconfig.json b/text-buffer/tsconfig.json index 860c31d7f7..ebee922349 100644 --- a/text-buffer/tsconfig.json +++ b/text-buffer/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/twilio/index.d.ts b/twilio/index.d.ts index d186831e93..358f45ca01 100644 --- a/twilio/index.d.ts +++ b/twilio/index.d.ts @@ -3,9 +3,8 @@ // Definitions by: nickiannone , Ashley Brener // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// -/// + import Express = require("express"); import Http = require("http"); import Q = require("q"); diff --git a/twilio/tsconfig.json b/twilio/tsconfig.json index 997e9d8770..805d02ab2f 100644 --- a/twilio/tsconfig.json +++ b/twilio/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/vso-node-api/index.d.ts b/vso-node-api/index.d.ts index 92b18209c1..51569f75a9 100644 --- a/vso-node-api/index.d.ts +++ b/vso-node-api/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// declare module 'vso-node-api/Serialization' { + import Q = require("q"); /** * Metadata for deserializing an enum field on a contract/type */ diff --git a/vso-node-api/tsconfig.json b/vso-node-api/tsconfig.json index 17db4a2513..feaeda0a61 100644 --- a/vso-node-api/tsconfig.json +++ b/vso-node-api/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From 2844f3c2b3a64bbe2869c8da54931b0871f273b2 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Wed, 15 Mar 2017 07:55:49 +0100 Subject: [PATCH 076/150] Fix generic contstraint --- jasmine/index.d.ts | 4 ++-- jasminewd2/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index f75a9f2127..caa1d12635 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -25,7 +25,7 @@ declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): vo declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void; declare function expect(spy: Function): jasmine.Matchers; -declare function expect>(actual: ArrayLike): jasmine.ArrayLikeMatchers; +declare function expect(actual: ArrayLike): jasmine.ArrayLikeMatchers; declare function expect(actual: T): jasmine.Matchers; declare function fail(e?: any): void; @@ -347,7 +347,7 @@ declare namespace jasmine { Any: Any; } - interface ArrayLikeMatchers> extends Matchers { + interface ArrayLikeMatchers extends Matchers> { toBe(expected: Expected>, expectationFailOutput?: any): boolean; toEqual(expected: Expected>, expectationFailOutput?: any): boolean; toContain(expected: T, expectationFailOutput?: any): boolean; diff --git a/jasminewd2/index.d.ts b/jasminewd2/index.d.ts index a4122c6639..3b8760709c 100644 --- a/jasminewd2/index.d.ts +++ b/jasminewd2/index.d.ts @@ -44,7 +44,7 @@ declare namespace jasmine { toThrowError(expected?: new (...args: any[]) => Error | Promise Error>, message?: string | RegExp | Promise): Promise; } - interface ArrayLikeMatchers> extends Matchers { + interface ArrayLikeMatchers extends Matchers> { toBe(expected: Expected>, expectationFailOutput?: any): Promise; toEqual(expected: Expected>, expectationFailOutput?: any): Promise; toContain(expected: T, expectationFailOutput?: any): Promise; From 03a3f340e457dbb28f5abafc655eaa496afd1720 Mon Sep 17 00:00:00 2001 From: Geert Jansen Date: Wed, 15 Mar 2017 09:49:37 +0100 Subject: [PATCH 077/150] Add name to header --- angular-material/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-material/index.d.ts b/angular-material/index.d.ts index 64441a96be..a8196269a4 100644 --- a/angular-material/index.d.ts +++ b/angular-material/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular Material (angular.material module) 1.1 // Project: https://github.com/angular/material -// Definitions by: Blake Bigelow , Peter Hajdu , Davide Donadello +// Definitions by: Blake Bigelow , Peter Hajdu , Davide Donadello , Geert Jansen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as angular from 'angular'; From e990bd3aeb3c5e31486f487179dae4136c85e07d Mon Sep 17 00:00:00 2001 From: Stanny Nuytkens Date: Mon, 13 Mar 2017 21:28:16 +0100 Subject: [PATCH 078/150] Include inputOptions for bootbox.prompt --- bootbox/bootbox-tests.ts | 24 +++++++++++++++++++++++- bootbox/index.d.ts | 3 ++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bootbox/bootbox-tests.ts b/bootbox/bootbox-tests.ts index b5f32931ae..f5604d5312 100644 --- a/bootbox/bootbox-tests.ts +++ b/bootbox/bootbox-tests.ts @@ -38,7 +38,29 @@ bootbox.prompt({ console.log(result); } }); - +bootbox.prompt({ + title: "This is a prompt with a set of checkbox inputs!", + inputType: 'checkbox', + inputOptions: [ + { + text: 'Choice One', + value: '1', + group: 'Group 1' + }, + { + text: 'Choice Two', + value: '2', + group: 'Group 1' + }, + { + text: 'Choice Three', + value: '3' + } + ], + callback: function (result) { + console.log(result); + } +}); bootbox.dialog({ title: "Wassup?", diff --git a/bootbox/index.d.ts b/bootbox/index.d.ts index d5ceb5ef62..28d30e2ba0 100644 --- a/bootbox/index.d.ts +++ b/bootbox/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Bootbox 4.4.0 // Project: https://github.com/makeusabrew/bootbox -// Definitions by: Vincent Bortone , Kon Pik , Anup Kattel , Dominik Schroeter , Troy McKinnon +// Definitions by: Vincent Bortone , Kon Pik , Anup Kattel , Dominik Schroeter , Troy McKinnon , Stanny Nuytkens // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -44,6 +44,7 @@ interface BootboxPromptOptions extends BootboxBaseOptions { inputType?: "text" | "textarea" | "email" | "select" | "checkbox" | "date" | "time" | "number" | "password"; callback: (result: string) => any; buttons?: BootboxConfirmPromptButtonMap; + inputOptions?: { text: string, value: string, group?: string }[]; } /** Bootbox options available when setting defaults for modals */ From 9b6db1a1561a26ba5644587e1dad420645d112f1 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Wed, 15 Mar 2017 10:29:20 +0100 Subject: [PATCH 079/150] Fix jasmine-query toContain typings --- jasmine-jquery/index.d.ts | 2 +- jasmine-jquery/jasmine-jquery-tests.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jasmine-jquery/index.d.ts b/jasmine-jquery/index.d.ts index ebc14cee75..14eb26b380 100644 --- a/jasmine-jquery/index.d.ts +++ b/jasmine-jquery/index.d.ts @@ -241,7 +241,7 @@ declare namespace jasmine { * // returns true * expect($('
')).toContain('some-class') */ - toContain(selector: T): boolean; + toContain(selector: any): boolean; /** * Check if DOM element exists inside the given parent element. diff --git a/jasmine-jquery/jasmine-jquery-tests.ts b/jasmine-jquery/jasmine-jquery-tests.ts index 40aa9e8f88..440dff1b6c 100644 --- a/jasmine-jquery/jasmine-jquery-tests.ts +++ b/jasmine-jquery/jasmine-jquery-tests.ts @@ -8,7 +8,8 @@ describe("Jasmine jQuery extension", () => { expect($('
')).toHaveCss({ margin: "10px" }); expect($('')).toBeSelected(); expect($('
')).toBeVisible(); - expect($('
')).toContain('span.some-class'); + // NOTE: It is now necessary to explicitly add the generic parameter when using `toContain` + expect($('
')).toContain('span.some-class'); expect($('').addClass('js-something')).toBeMatchedBy('.js-something'); expect($('')).toExist(); expect($('
')).toHaveAttr('id', 'some-id'); From 32a3eb210b95afa9264db68b07ba3a16cf6d32da Mon Sep 17 00:00:00 2001 From: stonio Date: Wed, 15 Mar 2017 16:17:10 +0100 Subject: [PATCH 080/150] Update index.d.ts - Interface SpeakingURLOptions Rename interface `Options` to interface `SpeakingURLOptions` to avoid namespace conflict with other TypeScript definitions. --- speakingurl/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/speakingurl/index.d.ts b/speakingurl/index.d.ts index 289c1eb033..83e38fd7b8 100644 --- a/speakingurl/index.d.ts +++ b/speakingurl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for speakingurl 10.0 +// Type definitions for speakingurl 13.0 // Project: http://pid.github.io/speakingurl/ // Definitions by: Zlatko Andonovski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,7 +7,7 @@ interface Dictionary { [x: string]: T; } -interface Options { +interface SpeakingURLOptions { separator?: string; lang?: string|boolean; symbols?: boolean; @@ -20,10 +20,10 @@ interface Options { custom?: string[]|Dictionary; } -declare function getSlug(input: string, options?: Options|string): string; +declare function getSlug(input: string, options?: SpeakingURLOptions|string): string; declare namespace getSlug { - export function createSlug(options: Options): (input: string) => string; + export function createSlug(options: SpeakingURLOptions): (input: string) => string; } -export = getSlug; \ No newline at end of file +export = getSlug; From bf8c07dd6b5629a029a4ea3e9fe0df30a3846e8b Mon Sep 17 00:00:00 2001 From: Eunchong Yu Date: Thu, 16 Mar 2017 00:35:42 +0900 Subject: [PATCH 081/150] Add IRegisterOptions.invoke for @types/autobahn --- autobahn/autobahn-tests.ts | 2 +- autobahn/index.d.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/autobahn/autobahn-tests.ts b/autobahn/autobahn-tests.ts index 141a43547e..d753e960fe 100644 --- a/autobahn/autobahn-tests.ts +++ b/autobahn/autobahn-tests.ts @@ -34,7 +34,7 @@ function test_client() { session.publish('com.myapp.hello', ['Hello, world!']); // 3) register a procedure for remoting - session.register('com.myapp.add2', myInstance.add2); + session.register('com.myapp.add2', myInstance.add2, { invoke: 'roundrobin' }); // 4) call a remote procedure session.call('com.myapp.add2', [2, 3]).then( diff --git a/autobahn/index.d.ts b/autobahn/index.d.ts index e93d3c065f..bb52fbb91c 100644 --- a/autobahn/index.d.ts +++ b/autobahn/index.d.ts @@ -177,6 +177,7 @@ declare namespace autobahn { interface IRegisterOptions { disclose_caller?: boolean; + invoke?: 'single' | 'roundrobin' | 'random' | 'first' | 'last'; } export class Connection { From b2e6c9b70e732b45a3a394b98593c285da98c4af Mon Sep 17 00:00:00 2001 From: Eunchong Yu Date: Thu, 16 Mar 2017 00:53:48 +0900 Subject: [PATCH 082/150] Increase version of @types/autobahn --- autobahn/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autobahn/index.d.ts b/autobahn/index.d.ts index bb52fbb91c..8a37bdf21b 100644 --- a/autobahn/index.d.ts +++ b/autobahn/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for AutobahnJS v0.9.6 +// Type definitions for AutobahnJS v0.9.7 // Project: http://autobahn.ws/js/ // Definitions by: Elad Zelingher , Andy Hawkins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 2d6f2be00732d109b28c19a9544d7e6088bc9979 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Mar 2017 11:40:55 -0700 Subject: [PATCH 083/150] gapi-tests.ts: Convert to UTF-8 (#15189) --- gapi/gapi-tests.ts | Bin 5944 -> 2971 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/gapi/gapi-tests.ts b/gapi/gapi-tests.ts index e3dc279596d38582ce406ee9bd017cae02d8bab1..3c70b9850d909d6d35ca9cb9828096abb11656ea 100644 GIT binary patch literal 2971 zcmd^BTW`}a6n?MN|8Rtm(m@x~AtY27h)WS=+{8r)AvAgEX=6z2U^``H>VN0haomiu zF$s+qULq?#KK{;kE}t1=a986THOdUZt|~P9R~EbyX@#mP@CvYd{T@5Vtf)<6L}u4u za?DFQX29~VC}FNu3AweE88bG+B^IheZPJBOivrV3m5lD%%?g3i?iS)mbG>3;_>!AU zi^?)%xenjmF9xo$ey`s<>GuHUwalzg61>T1umk=#0AbxrVJd|cybwPqsvO}NxqRzg zLUS2}%TnhHz=z!Iq=JqPf-``G03P5f8AI~%)%!Px4_;3X4<;XzVRMiSX2N7@iF)-| zWrplNC2hnFhap<>V|>I{;{m48*yM9`MbH}z(;09%1M*uTaE+iU7b`D7%z@W72Vp=e z3mU)GLgOriL1HgcJcsp-l$q<_>!0C zu=xUIB_?eq);o8a8x?o=}Tc+~%&k&L0!Y5!;k_91-iC|Fy*TVu@dh(#(<5I6}i{=9R*b zgf(K*Rfd?%m_k;O{;`-UYDe1AymUHnl2GckSB_^Ym&y81V~LvODNW4+-Kg{PihBC2 z8MHC>Glnc3KmA@8Z!;+zLntC10!i8!T7XJg9wMZ{?6F$GDY zGNLLvmA=&b8zjDlw`(l2<`NqF;@7qan_HdXpp$G-RpBvawZ+Zb!jVT2@b7PE5g4T2 z%t%Y!A1CLYJ3kgK57+4jj{|iMmd*nrbVK`8g5N=RG5Ep{E~y{h+WLt2==XjCMaZdi literal 5944 zcmeHL`)|}n5T2ha@jqColCLSTo1jW4Z9xTs8XhSktq?*LI+Du+lJoWKq#RNH^}_ef z+}wKoC<&mp0(A0uz22Rj`R466f9JwqB0tJhMzV{G_pxl_KaomiGQp^npX9Ra$q-Km zlIdK5|3kdHjCHwOmrL@M(t00ihjNTF>XeMy5@@f>E1Y{YKdn@*hVoLmOu+F}3cO8Z zAKX@0Rmz(3v4a&SxDN52GEDI%gA4_Jd&+qRDY-YF%e9Q>L&!(@D_Pd@bL<=9nqk!o zj81TsSU1JG30CEJs&qv>UdC$jx`Y*!h1aS6Cz#!Zyu`Qyl>(!rMrB0?@(pIfYVI&C ztwMrCHn8JB_YRfE*Wj4C+SmKtIhR{CE|W;Iq#;?h;EN{(E!WY=aH5?$XmG|oDbA#2 z+ye(QJgw>66Zutsmq+qUewK&e`WfD@%M-l65}jxicCeqw7OFKOejDR$%o)9>xHol7 zy}BL7x;1{Nao6$J(mo-F9%ef+^*EyJgLIL>>An6Ev#hN{XC1)x%sSjFq-(~5P+Hk*$ zy?xg18aRSkh2x%yL8@(`dR(osqwxafS zAEyu1yFW%m4bhYslkNasQjaL~nK=GC-)E}(^Jk9L&oXm-iP4@Xcu!&d^lrwN&m~5C z2DM1v7mrh5GSpn;xO_-8aUv_oQe9Cz&VbYjqjo)~e~IE_L|V&KmRUZ%D89PLJ|T+J z26A)+|NowbeIR{>)e*glmTr9(Ygf+1olVGc^~`2EW^Efhv+aeXZT(-4%D?GVmK|*u zJFz32ZT@?TyU}K^;68m9v2P!BM+&d|P(QQG@(WI7wa-e)tGZAjQKx5`!7ow=bx{s= zjM4NefKPq+)@uq!(Geq-DXj1!^>^PnPCM@WGqnZwJ=?&Xakon&)I`ihvqnwub>TX& zJ;lYfR-=Ux5n$gv#d}6vcJiz(?_gZ%*_Z!FZ?Eu$kRoSM~aNhriaJieugL3 zd$ez^rOsz^1EX7*9pRLh7&kM<9@cZ$u{;OP-f2F-EWZ#G%I7Xtjcb!l0`oRJZ>MxbQ zfL;ANL9l}nqR|>wa2*l&7@ZMmIZp0@R=Zd~KOHc543=$J(~$9@@?q z9*g?2MZD9kuRmu5D>O+Nt48?dNT25yn-Q#|?R9Q>rh_50^$06VSX69-mN(h|)6;zo zqZjjNuscU7j(X?!%~)z`(lg?}ffvu~`@-W$y&o>I&vv8K)DE)*qwl*>cRhrNA9HE> NVGCBk2ygbm|F^fEt8oAT From 9e1f287385289698d9f672a6ed78a6d5b351b5ea Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Mar 2017 14:30:30 -0700 Subject: [PATCH 084/150] Add additional path mappings for "q" (#15195) --- event-stream/tsconfig.json | 3 +++ gulp-angular-templatecache/tsconfig.json | 3 +++ gulp-autoprefixer/tsconfig.json | 3 +++ gulp-batch/gulp-batch-tests.ts | 2 +- gulp-batch/tsconfig.json | 3 +++ gulp-cache/tsconfig.json | 3 +++ gulp-cached/tsconfig.json | 3 +++ gulp-changed/tsconfig.json | 3 +++ gulp-cheerio/tsconfig.json | 3 +++ gulp-coffeeify/tsconfig.json | 3 +++ gulp-coffeelint/tsconfig.json | 3 +++ gulp-concat/tsconfig.json | 3 +++ gulp-copy/tsconfig.json | 3 +++ gulp-csso/tsconfig.json | 3 +++ gulp-debug/tsconfig.json | 3 +++ gulp-dtsm/tsconfig.json | 3 +++ gulp-espower/tsconfig.json | 3 +++ gulp-file-include/tsconfig.json | 3 +++ gulp-filter/tsconfig.json | 3 +++ gulp-flatten/tsconfig.json | 3 +++ gulp-gh-pages/tsconfig.json | 3 +++ gulp-gzip/tsconfig.json | 3 +++ gulp-html-replace/tsconfig.json | 3 +++ gulp-htmlmin/tsconfig.json | 3 +++ gulp-if/tsconfig.json | 3 +++ gulp-inject/tsconfig.json | 3 +++ gulp-insert/tsconfig.json | 3 +++ gulp-install/tsconfig.json | 3 +++ gulp-istanbul/tsconfig.json | 3 +++ gulp-jade/tsconfig.json | 3 +++ gulp-jasmine-browser/tsconfig.json | 3 +++ gulp-json-editor/tsconfig.json | 3 +++ gulp-jspm/tsconfig.json | 3 +++ gulp-less/tsconfig.json | 3 +++ gulp-load-plugins/tsconfig.json | 3 +++ gulp-minify-css/tsconfig.json | 3 +++ gulp-minify-html/tsconfig.json | 3 +++ gulp-mocha/tsconfig.json | 3 +++ gulp-newer/tsconfig.json | 3 +++ gulp-ng-annotate/tsconfig.json | 3 +++ gulp-nodemon/tsconfig.json | 3 +++ gulp-plumber/tsconfig.json | 3 +++ gulp-remember/tsconfig.json | 3 +++ gulp-rename/tsconfig.json | 3 +++ gulp-replace/tsconfig.json | 3 +++ gulp-rev-replace/tsconfig.json | 3 +++ gulp-rev/tsconfig.json | 3 +++ gulp-ruby-sass/tsconfig.json | 3 +++ gulp-sass/tsconfig.json | 3 +++ gulp-shell/tsconfig.json | 3 +++ gulp-size/tsconfig.json | 3 +++ gulp-sort/tsconfig.json | 3 +++ gulp-sourcemaps/tsconfig.json | 3 +++ gulp-strip-debug/tsconfig.json | 3 +++ gulp-svg-sprite/tsconfig.json | 3 +++ gulp-task-listing/tsconfig.json | 3 +++ gulp-tsd/tsconfig.json | 3 +++ gulp-tslint/tsconfig.json | 3 +++ gulp-typedoc/tsconfig.json | 3 +++ gulp-typescript/tsconfig.json | 3 +++ gulp-uglify/tsconfig.json | 3 +++ gulp-useref/tsconfig.json | 3 +++ gulp-util/tsconfig.json | 3 +++ gulp-watch/tsconfig.json | 3 +++ gulp/index.d.ts | 1 - karma-coverage/tsconfig.json | 3 +++ karma/tsconfig.json | 3 +++ lazypipe/tsconfig.json | 3 +++ main-bower-files/tsconfig.json | 3 +++ merge2/tsconfig.json | 3 +++ vinyl-buffer/tsconfig.json | 3 +++ vinyl-paths/tsconfig.json | 3 +++ vinyl-source-stream/tsconfig.json | 3 +++ wiredep/tsconfig.json | 3 +++ 74 files changed, 217 insertions(+), 2 deletions(-) diff --git a/event-stream/tsconfig.json b/event-stream/tsconfig.json index 208ff51fe0..768497bcd8 100644 --- a/event-stream/tsconfig.json +++ b/event-stream/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-angular-templatecache/tsconfig.json b/gulp-angular-templatecache/tsconfig.json index eda0469b48..869b08da9a 100644 --- a/gulp-angular-templatecache/tsconfig.json +++ b/gulp-angular-templatecache/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-autoprefixer/tsconfig.json b/gulp-autoprefixer/tsconfig.json index 955f890f2b..35ad131268 100644 --- a/gulp-autoprefixer/tsconfig.json +++ b/gulp-autoprefixer/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-batch/gulp-batch-tests.ts b/gulp-batch/gulp-batch-tests.ts index a1e305c03b..c5936eb031 100644 --- a/gulp-batch/gulp-batch-tests.ts +++ b/gulp-batch/gulp-batch-tests.ts @@ -1,7 +1,7 @@ import * as gulp from "gulp"; import * as batch from "gulp-batch"; -gulp.task('default', function() { +gulp.task('default', () => { gulp.watch([ 'lib/**', 'test/**' ], batch((events: any, cb: any) => { events.on('data', console.log).on('end', cb); })); diff --git a/gulp-batch/tsconfig.json b/gulp-batch/tsconfig.json index eb09ea4f9c..1406137b98 100644 --- a/gulp-batch/tsconfig.json +++ b/gulp-batch/tsconfig.json @@ -15,6 +15,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-cache/tsconfig.json b/gulp-cache/tsconfig.json index 3126e1ef38..368718e5d1 100644 --- a/gulp-cache/tsconfig.json +++ b/gulp-cache/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-cached/tsconfig.json b/gulp-cached/tsconfig.json index 32f3759409..77ef9c0aa1 100644 --- a/gulp-cached/tsconfig.json +++ b/gulp-cached/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-changed/tsconfig.json b/gulp-changed/tsconfig.json index 4185d001ef..ab8e90a21d 100644 --- a/gulp-changed/tsconfig.json +++ b/gulp-changed/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-cheerio/tsconfig.json b/gulp-cheerio/tsconfig.json index 254698a94e..d6cdfaac69 100644 --- a/gulp-cheerio/tsconfig.json +++ b/gulp-cheerio/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-coffeeify/tsconfig.json b/gulp-coffeeify/tsconfig.json index 54406ca98a..67e213beda 100644 --- a/gulp-coffeeify/tsconfig.json +++ b/gulp-coffeeify/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-coffeelint/tsconfig.json b/gulp-coffeelint/tsconfig.json index 2cc883884b..f1d388ddb7 100644 --- a/gulp-coffeelint/tsconfig.json +++ b/gulp-coffeelint/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-concat/tsconfig.json b/gulp-concat/tsconfig.json index 1f4acfd285..0d4c2e1c52 100644 --- a/gulp-concat/tsconfig.json +++ b/gulp-concat/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-copy/tsconfig.json b/gulp-copy/tsconfig.json index cc4c620b9f..0111f96820 100644 --- a/gulp-copy/tsconfig.json +++ b/gulp-copy/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-csso/tsconfig.json b/gulp-csso/tsconfig.json index 706fd106af..9519eac9b6 100644 --- a/gulp-csso/tsconfig.json +++ b/gulp-csso/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-debug/tsconfig.json b/gulp-debug/tsconfig.json index accf822a92..dac4ba0725 100644 --- a/gulp-debug/tsconfig.json +++ b/gulp-debug/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-dtsm/tsconfig.json b/gulp-dtsm/tsconfig.json index 6003ac335b..872e75dd19 100644 --- a/gulp-dtsm/tsconfig.json +++ b/gulp-dtsm/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-espower/tsconfig.json b/gulp-espower/tsconfig.json index 1140a956aa..92f4388198 100644 --- a/gulp-espower/tsconfig.json +++ b/gulp-espower/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-file-include/tsconfig.json b/gulp-file-include/tsconfig.json index d166690ec5..d08b25fa2e 100644 --- a/gulp-file-include/tsconfig.json +++ b/gulp-file-include/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-filter/tsconfig.json b/gulp-filter/tsconfig.json index f217497fa9..c48a36bb69 100644 --- a/gulp-filter/tsconfig.json +++ b/gulp-filter/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-flatten/tsconfig.json b/gulp-flatten/tsconfig.json index 484a4e3aef..72d3110eaa 100644 --- a/gulp-flatten/tsconfig.json +++ b/gulp-flatten/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-gh-pages/tsconfig.json b/gulp-gh-pages/tsconfig.json index a6f5d411b1..44cffa6d99 100644 --- a/gulp-gh-pages/tsconfig.json +++ b/gulp-gh-pages/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-gzip/tsconfig.json b/gulp-gzip/tsconfig.json index 07e07f0cf5..4eea3f8d72 100644 --- a/gulp-gzip/tsconfig.json +++ b/gulp-gzip/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-html-replace/tsconfig.json b/gulp-html-replace/tsconfig.json index 25eff60770..e074dcc546 100644 --- a/gulp-html-replace/tsconfig.json +++ b/gulp-html-replace/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-htmlmin/tsconfig.json b/gulp-htmlmin/tsconfig.json index 5d12b48035..964d06a7a1 100644 --- a/gulp-htmlmin/tsconfig.json +++ b/gulp-htmlmin/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-if/tsconfig.json b/gulp-if/tsconfig.json index f9db5297cf..6ea4d6a30b 100644 --- a/gulp-if/tsconfig.json +++ b/gulp-if/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-inject/tsconfig.json b/gulp-inject/tsconfig.json index 0201da00d9..c243f76d43 100644 --- a/gulp-inject/tsconfig.json +++ b/gulp-inject/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-insert/tsconfig.json b/gulp-insert/tsconfig.json index e548f022fa..aa58483b8a 100644 --- a/gulp-insert/tsconfig.json +++ b/gulp-insert/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-install/tsconfig.json b/gulp-install/tsconfig.json index 0b4494f7cd..79ecdd6cf1 100644 --- a/gulp-install/tsconfig.json +++ b/gulp-install/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-istanbul/tsconfig.json b/gulp-istanbul/tsconfig.json index f7ca4e96c7..f860b33143 100644 --- a/gulp-istanbul/tsconfig.json +++ b/gulp-istanbul/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-jade/tsconfig.json b/gulp-jade/tsconfig.json index b746e232bf..6b9c5c22c4 100644 --- a/gulp-jade/tsconfig.json +++ b/gulp-jade/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-jasmine-browser/tsconfig.json b/gulp-jasmine-browser/tsconfig.json index e5b112e90f..c347d86d35 100644 --- a/gulp-jasmine-browser/tsconfig.json +++ b/gulp-jasmine-browser/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-json-editor/tsconfig.json b/gulp-json-editor/tsconfig.json index 85846b46fd..8d6021c6f8 100644 --- a/gulp-json-editor/tsconfig.json +++ b/gulp-json-editor/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-jspm/tsconfig.json b/gulp-jspm/tsconfig.json index fbf318afab..e52189d99a 100644 --- a/gulp-jspm/tsconfig.json +++ b/gulp-jspm/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-less/tsconfig.json b/gulp-less/tsconfig.json index be38992302..4c9110c114 100644 --- a/gulp-less/tsconfig.json +++ b/gulp-less/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-load-plugins/tsconfig.json b/gulp-load-plugins/tsconfig.json index 77238a0e61..4e3ea0ba8c 100644 --- a/gulp-load-plugins/tsconfig.json +++ b/gulp-load-plugins/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-minify-css/tsconfig.json b/gulp-minify-css/tsconfig.json index 2d59793675..0b04647f28 100644 --- a/gulp-minify-css/tsconfig.json +++ b/gulp-minify-css/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-minify-html/tsconfig.json b/gulp-minify-html/tsconfig.json index 3e37896bd2..2b5f377a6c 100644 --- a/gulp-minify-html/tsconfig.json +++ b/gulp-minify-html/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-mocha/tsconfig.json b/gulp-mocha/tsconfig.json index aef5d2d758..3405efd531 100644 --- a/gulp-mocha/tsconfig.json +++ b/gulp-mocha/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-newer/tsconfig.json b/gulp-newer/tsconfig.json index ac02863c9b..53fd3b5fd5 100644 --- a/gulp-newer/tsconfig.json +++ b/gulp-newer/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-ng-annotate/tsconfig.json b/gulp-ng-annotate/tsconfig.json index 16f68955bb..b8b4d4fc6d 100644 --- a/gulp-ng-annotate/tsconfig.json +++ b/gulp-ng-annotate/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-nodemon/tsconfig.json b/gulp-nodemon/tsconfig.json index dc91f8e066..9af358b797 100644 --- a/gulp-nodemon/tsconfig.json +++ b/gulp-nodemon/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-plumber/tsconfig.json b/gulp-plumber/tsconfig.json index 878facc1f7..9f00169b06 100644 --- a/gulp-plumber/tsconfig.json +++ b/gulp-plumber/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-remember/tsconfig.json b/gulp-remember/tsconfig.json index e8ecc18bdc..f8ae755cca 100644 --- a/gulp-remember/tsconfig.json +++ b/gulp-remember/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-rename/tsconfig.json b/gulp-rename/tsconfig.json index 8a3a2c34dd..7276696b70 100644 --- a/gulp-rename/tsconfig.json +++ b/gulp-rename/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-replace/tsconfig.json b/gulp-replace/tsconfig.json index 5624a977d3..8b78b80dcc 100644 --- a/gulp-replace/tsconfig.json +++ b/gulp-replace/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-rev-replace/tsconfig.json b/gulp-rev-replace/tsconfig.json index b3fb130952..dfbd0d502f 100644 --- a/gulp-rev-replace/tsconfig.json +++ b/gulp-rev-replace/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-rev/tsconfig.json b/gulp-rev/tsconfig.json index ea7647e39a..b1f1715d28 100644 --- a/gulp-rev/tsconfig.json +++ b/gulp-rev/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-ruby-sass/tsconfig.json b/gulp-ruby-sass/tsconfig.json index 9465184b37..b6c74a2dd8 100644 --- a/gulp-ruby-sass/tsconfig.json +++ b/gulp-ruby-sass/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-sass/tsconfig.json b/gulp-sass/tsconfig.json index 26e1b2af4c..bec0180414 100644 --- a/gulp-sass/tsconfig.json +++ b/gulp-sass/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-shell/tsconfig.json b/gulp-shell/tsconfig.json index 81356de73d..ac0bc0cf3a 100644 --- a/gulp-shell/tsconfig.json +++ b/gulp-shell/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-size/tsconfig.json b/gulp-size/tsconfig.json index b1be4ca1dc..fe93b09ba6 100644 --- a/gulp-size/tsconfig.json +++ b/gulp-size/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-sort/tsconfig.json b/gulp-sort/tsconfig.json index 87097c7ad2..1921a1884c 100644 --- a/gulp-sort/tsconfig.json +++ b/gulp-sort/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-sourcemaps/tsconfig.json b/gulp-sourcemaps/tsconfig.json index e9c6d80281..9ce9bf808f 100644 --- a/gulp-sourcemaps/tsconfig.json +++ b/gulp-sourcemaps/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-strip-debug/tsconfig.json b/gulp-strip-debug/tsconfig.json index db20e2db69..572113b3cf 100644 --- a/gulp-strip-debug/tsconfig.json +++ b/gulp-strip-debug/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-svg-sprite/tsconfig.json b/gulp-svg-sprite/tsconfig.json index 381d78b150..82b417934a 100644 --- a/gulp-svg-sprite/tsconfig.json +++ b/gulp-svg-sprite/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-task-listing/tsconfig.json b/gulp-task-listing/tsconfig.json index 1f3b796968..fb06f0a926 100644 --- a/gulp-task-listing/tsconfig.json +++ b/gulp-task-listing/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-tsd/tsconfig.json b/gulp-tsd/tsconfig.json index 4252bbc080..813e29fd74 100644 --- a/gulp-tsd/tsconfig.json +++ b/gulp-tsd/tsconfig.json @@ -14,6 +14,9 @@ "paths": { "q": [ "q/v0" ] }, + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-tslint/tsconfig.json b/gulp-tslint/tsconfig.json index 91d3edf8a3..46befdb599 100644 --- a/gulp-tslint/tsconfig.json +++ b/gulp-tslint/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-typedoc/tsconfig.json b/gulp-typedoc/tsconfig.json index 9d0f620269..f60478c1fa 100644 --- a/gulp-typedoc/tsconfig.json +++ b/gulp-typedoc/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-typescript/tsconfig.json b/gulp-typescript/tsconfig.json index fa6cbbc908..120791965a 100644 --- a/gulp-typescript/tsconfig.json +++ b/gulp-typescript/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-uglify/tsconfig.json b/gulp-uglify/tsconfig.json index 43db40e019..d0ae9de799 100644 --- a/gulp-uglify/tsconfig.json +++ b/gulp-uglify/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-useref/tsconfig.json b/gulp-useref/tsconfig.json index 132913f9d8..67e8c2aaed 100644 --- a/gulp-useref/tsconfig.json +++ b/gulp-useref/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-util/tsconfig.json b/gulp-util/tsconfig.json index 06b269e0ed..44b42dbad1 100644 --- a/gulp-util/tsconfig.json +++ b/gulp-util/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-watch/tsconfig.json b/gulp-watch/tsconfig.json index 7062be6f7e..9822101d39 100644 --- a/gulp-watch/tsconfig.json +++ b/gulp-watch/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp/index.d.ts b/gulp/index.d.ts index 9f3e7d96ba..fefd5b0fda 100644 --- a/gulp/index.d.ts +++ b/gulp/index.d.ts @@ -10,7 +10,6 @@ import Orchestrator = require("orchestrator"); import VinylFile = require("vinyl"); - declare type Strings = string|string[]; declare namespace gulp { diff --git a/karma-coverage/tsconfig.json b/karma-coverage/tsconfig.json index 57290fb7be..404aa4ec66 100644 --- a/karma-coverage/tsconfig.json +++ b/karma-coverage/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/karma/tsconfig.json b/karma/tsconfig.json index 2c74d40398..b2d5e469ba 100644 --- a/karma/tsconfig.json +++ b/karma/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/lazypipe/tsconfig.json b/lazypipe/tsconfig.json index 675e6f38cc..801cf4648a 100644 --- a/lazypipe/tsconfig.json +++ b/lazypipe/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/main-bower-files/tsconfig.json b/main-bower-files/tsconfig.json index fcdebedf3d..04b363ffc6 100644 --- a/main-bower-files/tsconfig.json +++ b/main-bower-files/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/merge2/tsconfig.json b/merge2/tsconfig.json index 4fd4d60c3f..64cf45c2a6 100644 --- a/merge2/tsconfig.json +++ b/merge2/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/vinyl-buffer/tsconfig.json b/vinyl-buffer/tsconfig.json index 1208954da6..93296b534b 100644 --- a/vinyl-buffer/tsconfig.json +++ b/vinyl-buffer/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/vinyl-paths/tsconfig.json b/vinyl-paths/tsconfig.json index 4aa2ca1faa..126374df8c 100644 --- a/vinyl-paths/tsconfig.json +++ b/vinyl-paths/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/vinyl-source-stream/tsconfig.json b/vinyl-source-stream/tsconfig.json index 580c625e75..ef3c4de3b7 100644 --- a/vinyl-source-stream/tsconfig.json +++ b/vinyl-source-stream/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/wiredep/tsconfig.json b/wiredep/tsconfig.json index 3794e2a3b2..69ee121ef9 100644 --- a/wiredep/tsconfig.json +++ b/wiredep/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From a15660c3c2bd064d68dd1ce8376ee833996c7671 Mon Sep 17 00:00:00 2001 From: Victor Palomo de Castro Date: Wed, 15 Mar 2017 21:08:41 -0300 Subject: [PATCH 085/150] Change drawerPosition type so it can match with DrawerPosition --- react-native/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-native/index.d.ts b/react-native/index.d.ts index c0d1884a97..62a7091e9f 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -2500,9 +2500,9 @@ declare module "react" { /** * Specifies the side of the screen from which the drawer will slide in. - * enum(DrawerConsts.DrawerPosition.Left, DrawerConsts.DrawerPosition.Right) + * enum(DrawerLayoutAndroid.positions.Left, DrawerLayoutAndroid.positions.Right) */ - drawerPosition?: any; + drawerPosition?: number; /** * Specifies the width of the drawer, more precisely the width of the From 8e76ee411e538cca53544b8621986214e847e132 Mon Sep 17 00:00:00 2001 From: Alessandro Vergani Date: Thu, 23 Feb 2017 10:51:56 +0100 Subject: [PATCH 086/150] Add missing catchReturn and catchThrow --- bluebird-global/index.d.ts | 2 ++ bluebird/bluebird-tests.ts | 9 +++++++++ bluebird/index.d.ts | 31 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/bluebird-global/index.d.ts b/bluebird-global/index.d.ts index e4c4920501..a705222e9d 100644 --- a/bluebird-global/index.d.ts +++ b/bluebird-global/index.d.ts @@ -80,6 +80,8 @@ declare global { // then: typeof Bluebird.prototype.then; thenReturn: typeof Bluebird.prototype.thenReturn; thenThrow: typeof Bluebird.prototype.thenThrow; + catchReturn: typeof Bluebird.prototype.catchReturn; + catchThrow: typeof Bluebird.prototype.catchThrow; throw: typeof Bluebird.prototype.throw; timeout: typeof Bluebird.prototype.timeout; toJSON: typeof Bluebird.prototype.toJSON; diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index c08a7bdc6b..b9fc8d0cef 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -506,6 +506,15 @@ fooProm = fooProm.thenThrow(err); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +barProm = fooProm.catchReturn(bar); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooProm +fooProm = fooProm.catchThrow(err); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + str = fooProm.toString(); obj = fooProm.toJSON(); diff --git a/bluebird/index.d.ts b/bluebird/index.d.ts index ecacedfd0d..3508a4e742 100644 --- a/bluebird/index.d.ts +++ b/bluebird/index.d.ts @@ -248,6 +248,37 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection; thenThrow(reason: Error): Bluebird; + /** + * Convenience method for: + * + * + * .catch(function() { + * return value; + * }); + * + * + * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.catchReturn()` + */ + catchReturn(value: U): Bluebird; + catchReturn(predicate: (error: any) => boolean, value: U): Bluebird; + catchReturn(ErrorClass: new (...args: any[]) => E, value: U): Bluebird; + catchReturn(predicate: Object, value: U): Bluebird; + + /** + * Convenience method for: + * + * + * .catch(function() { + * throw reason; + * }); + * + * Same limitations apply as with `.catchReturn()`. + */ + catchThrow(reason: Error): Bluebird; + catchThrow(predicate: (error: any) => boolean, reason: Error): Bluebird; + catchThrow(ErrorClass: new (...args: any[]) => E, reason: Error): Bluebird; + catchThrow(predicate: Object, reason: Error): Bluebird; + /** * Convert to String. */ From 7daa75b30a414bc7a92595bce2e240d9b57a2fd1 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 16 Mar 2017 07:23:40 -0700 Subject: [PATCH 087/150] Fix typo in regexp (#15204) --- css-modules-require-hook/css-modules-require-hook-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css-modules-require-hook/css-modules-require-hook-tests.ts b/css-modules-require-hook/css-modules-require-hook-tests.ts index ea80474dc5..93da1326bd 100644 --- a/css-modules-require-hook/css-modules-require-hook-tests.ts +++ b/css-modules-require-hook/css-modules-require-hook-tests.ts @@ -62,7 +62,7 @@ hook({ extensions: ['.scss', '.sass'] }); hook({ ignore: (file: string) => false }); hook({ ignore: 'unused' }); -hook({ ignore: /\.test\.(css|scss|sass)/$ }); +hook({ ignore: /\.test\.(css|scss|sass)$/ }); // // https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#preprocesscss-function From c8190f4e646a038824c51bf636ebc45b3852e9f7 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 16 Mar 2017 08:34:30 -0700 Subject: [PATCH 088/150] gapi.calendar-tests.ts: Convert to UTF-8 (#15208) --- gapi.calendar/gapi.calendar-tests.ts | Bin 9070 -> 4534 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/gapi.calendar/gapi.calendar-tests.ts b/gapi.calendar/gapi.calendar-tests.ts index 909e503846a038e58a583b4e930fcdeb0868b805..0438e5dc069b39fe47045aa71d1b9343ad3b7458 100644 GIT binary patch literal 4534 zcmb_g+iu%N5Pc7jf0(pDDLXbPyLY87;>d2J!i`g39?~=j*5pdsnB=m{r5rWzzxT{8 zmy}#NDT)SxC6jYGbDwdtO~>y=QRR}XxRxbNjV|bCt!H>L7P%}lVd(JXgnkhVah@7g zS^BL}>2+;|u{5`~sz*tZ$%V{yB~2aA9CMuNBJp2$MOD>F+6qhl?6{M6HEkykA3S{U z;o$?KB%xQjF*MGVEG14LNixzJ1qGQ$w`8Kq=yx);q)M`L*&=SG90f2m)@7}8 zxzpiH{eyTTUS?mw-0{ie_{GIr063uNhgYYUXK%YlKSoa&uqQkppT0ak2i5D(f+KEj zZdwnBO4ZH_qOtSN{Mbm5=`vq__NEn-Y;UtX+NSYbrq`sVls3k&3z}LQnv0rPgf{9g zxWLX8ey^%rrNSy*#-15&B$_s5%FifeNrzw>Y?1RV(F}NEmg9anVFSks)h!9WQItCG zzg1Z@>K(BYC_zxCh%;V#FvaKAc{0cHBD0c|F7`*=)}Y z!BD=@d3O;GSgjW_Y7_0SQl~6$|3af^yt2;IoI(MqJW>nfN2b%JKt$u2w8y#Rug{i~ zY!G#HyO~-ALebb{5 zd9H6%IdcW-QrT+MtFoLJ9Rweat7T9JF#w%jGh+vnt{Q7Yt^-r|Vk3T4=Bl>UOnk$rWp;)g9{Uazs;s=-qZjdpGGrl+k+|gR#KWn=AE%^X%@#@MyZcqZ3u5 zomChL99L&z-IlB_Q+X#(2`!G(S7sYM#;?{gG9;mMkXIcu(I5&_C)%NC@g;ud0CL&l zaNe!&X+STHLJWDf)J;*KcnBSd{M5^kz*ZG9;V-18j;xgLL65@o)*+o*16f9wu$jxN zsK#vb!!@SKlu8}Agh8*<4OEH1k7jRlWn9%1vaZEUvV-uXwD)=FA6E8*fZLOie>M^k zIq+klby)|=TM)Ca23>u3zMSxAh@hUm5_K6Au}6MYC0-6nc|%9=&0uRQwt8}YdX5QR z&IbLEh-&nTBbiH>01lU5y{H<*xzGN(9U=Y8LcI6gm|yJ;`xn||(mY$@Y2@N`0YH)O zE4LhF|FyL}mhWZS0Ad)L11|oq*8G5PLwVpDL#(VUYF7l@7ZDb0M=y;WL?NNtAdaG5 zoA2epp|YIWIsHh(6+IZ++Ry-=AccSopWx$%R#J={0S6vEe!RxA0uMZ1{Ajg|+_BPPD1h3=EE#_d{cP}}>(!HPrqJf?`SC_MHO@!M9k z)x+&X+#M@xj(&l*yxv57vBb{f9znZGpy%IH*@rH0Bv3&TGt5n6Lc`}ez0%o|uq0Z6 zLDi0~nL<0Kw(=a}ZNg5bY>je9&6hfpZJ%o2hH+54tiKJsbm3Zr=A9O^HpMoFnX`go zW4G)5*+Lkh3vo4dq2fTZl#lEgy0KMb`vrqp7(5nav@C7}-HMW8Lq&$*TrnM{K;I$#8)$EI>>D zH|q9S%m1LxU30 z;qjdju5p_gTqSGJaB4<{#2w~V2oDpR8DwJ;Gv)qQxP!kL_9)jmDqS@d?{YoI-mn`T zZ#-!C`|XqdO#gS=j&CMm-}(5q6Jb}tUm;x7TrXnH-HvhZhT%xNw%s@O=-3?$zVl*% V=PBuEV*iKuh^4Ed)nX|_; zv%5}OT7fLzc4yA@J-6Av{~Ct(LKQZ{v#=A6!$~*_`}#lEzu)w0tltM=8Ya3|g>Upd z35WHX4Xt7IIPB@yRQK1z4`EB+-|GJpz3+rwT_1_+TvvY#r~17sy0b`s8m~Uq=Ugjh zVJ!^x+7rbmdLN0?iN2@0GZ4?jc_13dGc2xN7Qd57XQ=z7WW(@#2k&9{RkSPVKMZe% zH{$zw{H$~pS*q}pIGsk_HYCv~YKtyg;f6lpgM}XHdZktS(gb}?gFRhKw)BS=^YA!Q$!&~ONtPQm-DH_6Y>3iWT1=uR-q-4;J+W0Ae}g4|l`E+5*>fy%)Zaowmcha9h{gtFCLs=L-v?k5jy()!V|%rjSwvXx$HQw={Sf zc$FBy*Q1CG$HI>Mgbmx?A4JdWNOLT46#fv82Mvjcg7+4_2NURvN5CsSI?(5C!~%XE zN6(!~0uYMTcOsTtiixg{!k@Ye3XltFE3E>fAPMZu^^Ht}g0rC!I~|DMIHJVXA%V-Z zUhCTrD_WUw%f7?NXC%5VPx_T4>t|fq)udwA@b7Mh{fClyPuJG8zU}MxTQs54lkWJ5 zc($Fn=Ld>~iKvc4Uw2u(5|+^!DejM>RY%c&PLH@d)pf_L%YG(G<{h#W*~;y9Tfb-8 zb0jaU)M#MWS)}1~x^Qt*oSm9Q{Y;u!l#vHg%)9m7=E>ugc!L}=-L&C<=WQtbQnZOb zvNImqR<`lnai%NIBiDyaY|+rg8T`8DFOEDA?pizboM*pN5>S$7v~_7Sk`7Mcs&dJs zt~9x3ZA^R4aD82~eP!a2>}dIe7$-`>2r)|5AS-W1-}}|ClmoVe2k_RWcUgC!2oB%M zkO4X@4|MBVg?II;w8v@Y_8CM^lli9|5esdrI5)+E8kjs=DYI@x99xZ`;!p#~Xk>)E zF7f+OM9Wk<=H9i4aLJn18we3|?I1#^5o9a!)Q+y1WqYzG7$@Q^n;S*@ba|RRf%%&p zRqg?~)OezxEAN;s?kL+$l>57EL4}9wQ^`7(mo3XeEoJ4o?pu8wNjuLNiJDs>kIP5W zI7OgoXVRFZsRz!nZB2RsA`i}GUVnA_!xjH_`M|OkJTA^(TcXfy4|12;)VmVP6?t|u znM>4Kd_PtG!=kcJ?T+T5a8zMSt?7cX`;TU01uZ+eWlDH2dP} zoXKe4$-8EOBwssY{rf7M$F$YkW!08C;+2&(d0nOQwd*CT4iwiGd(_8dBg1HyE%Hp( zjAbw~mp!KPOinvR{Kc5OC5u`<%c}()M%l@`ryT{&d{?PQC3n$RpDKe{cj)n&yg19W zrq?4{cVjNfZBL%f^C|YEi}P$pcbDhb^D*YTnmVN%+029qLAg|e1%K)nePlj`^k)JR2)(`SEHpR+5x6o10o6)OKGpt(xpUjdr>oF(JBU-@a zzABzy!2@*IPK_M*O#irouc;Oufp`G!3AcFAceZmfRnqenohTS8Z8p%gt;nAm*W`ut z*4GjB^gyOv$=^DA>O1pYsx|02(`zSoB90(ig9Tp}Ll^t9Ya;OO2~C)VkqPTEb1g$z z+e*0)K%vRfZ%iL#kv1;rx2*T?)fRHBfYM}3%RxO!XBhb|`r3B(W&Qow58SAcgsv-! zL8{W0vfsAeHiOd>aJP&0tnMqAsEHl(g7HYXv3sZG5_aYBV|#rH>Dr05&om*Y-g{Qt z<4RcVl#=d*PH-CNSKW3gp6=Eb>J`>ITf}m1)6(w)QGKR2oie)jTNSY%F;5TJu4{P6 z@suON&;%#;4I~}3kM%EA0`o5M!yHUx?`i&L54o(Fp~^^H(+aOWxo*((zC4!)gu>xa zay-_W>w2#)(FYm_!Vt53zs3YqO{Z09VE?|*_i`S#>QcCL4wr808K0c;eR20w3b$JR z?H+g;V(e4-G`Q^_u=utRN=dE02vxpI!b zFW<4ttqQjBSij-#O8JlI`$ZH}#&$HDcAQ713cyM0NGRk)rdux0`w8o*OMRIq7|qjh z$z zZ`7L++x_&V>j{X>J)Do)DT_r35;4!6NCM9SXz)bx(%+63xniv$(|=>#E=}xNj%N$A z5U64b;RG;glICT%TTkoCXHc*D#DU7=^A8B~9@DO-^Cgp$tU%{s`N$%TU7&B%hLX%a9Q^MRM~Y^7FpBhYW>OGPwL-I{zf0WP;GvWzVT-wJz1Bl z*bd(fbv81Q77umZq5@nph2%DGo(T1{hA#beX?JCzi|P1(Ye(GW&-LgFOxOE`UCh$A zHNoAJ9XI8Vul0LVPqnY<3B&T0-KIr$c18FZIsr$3R-~l)R_TsKhLqbW@wfX9rZJ^Qh%$X={W%k0qmN z#MArb$gxwI8`{CtZO`It_4!lyB-ZR{M7Cv!Wgc@~i34gG(QIo=Ym$w6wcIunyWCfm zo$N{6$BM%)Tb{>*lXH5p6H#BzgY4IyIvy1GOZU&}dD{Kp9UYc`U1vLaXVN_1d6l!B zo_q$%$;4A3)MG8pa;{aHZ~RKB-;11KB&zLhJMTZ!3B+bS!%!vio_A02ZWATFZK6Af Vy~DBMkaOp;o)wgxs{b?Z{R2avS2_Ry From ca622833a6a6d975e37ec74beae0b0be63f63f07 Mon Sep 17 00:00:00 2001 From: Wouter Hardeman Date: Thu, 16 Mar 2017 18:34:54 +0100 Subject: [PATCH 089/150] Updated @types/react-paginate to version 4.2.0 --- react-paginate/index.d.ts | 24 +++++++++++++++++------- react-paginate/react-paginate-tests.tsx | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/react-paginate/index.d.ts b/react-paginate/index.d.ts index aaa3931b74..fa1d928ce0 100644 --- a/react-paginate/index.d.ts +++ b/react-paginate/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for react-paginate 2.1.3 +// Type definitions for react-paginate 4.2.0 // Project: https://github.com/AdeleD/react-paginate -// Definitions by: Simon Hartcher +// Definitions by: Simon Hartcher , Wouter Hardeman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -10,7 +10,7 @@ interface ReactPaginateProps { /** * The total number of pages. */ - pageNum: number; + pageCount: number; /** * The range of pages displayed. @@ -43,19 +43,24 @@ interface ReactPaginateProps { breakClassName?: string | JSX.Element; /** - * The method to call when a page is clicked. + * The method to call when a page is clicked. Exposes the current page object as an argument. */ - clickCallback?: Function; + onPageChange?: Function; /** * The initial page selected. */ - initialSelected?: number; + initialPage?: number; /** * To override selected page with parent prop. */ - forceSelected?: number; + forcePage?: number; + + /** + * Disable `onPageChange` callback with initial page. Default: `false` + */ + disableInitialCallback?: boolean /** * The classname of the pagination container. @@ -101,6 +106,11 @@ interface ReactPaginateProps { * The classname for disabled `previous` and `next` buttons. */ disabledClassName?: string; + + /** + * The method is called to generate the `href` attribute value on tag `a` of each page element. + */ + hrefBuilder?: Function; } declare const ReactPaginate: React.ComponentClass; diff --git a/react-paginate/react-paginate-tests.tsx b/react-paginate/react-paginate-tests.tsx index 2ae495eacf..42a7c49c30 100644 --- a/react-paginate/react-paginate-tests.tsx +++ b/react-paginate/react-paginate-tests.tsx @@ -5,7 +5,7 @@ class Test extends React.Component<{}, {}> { public render() { return ( From 366da3f3c3eaff47db425846ef43011fb8e6e66e Mon Sep 17 00:00:00 2001 From: Wouter Hardeman Date: Thu, 16 Mar 2017 18:46:20 +0100 Subject: [PATCH 090/150] Added 'v' before version number to follow the guidelines --- react-paginate/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-paginate/index.d.ts b/react-paginate/index.d.ts index fa1d928ce0..363aeb8ea1 100644 --- a/react-paginate/index.d.ts +++ b/react-paginate/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-paginate 4.2.0 +// Type definitions for react-paginate v4.2.0 // Project: https://github.com/AdeleD/react-paginate // Definitions by: Simon Hartcher , Wouter Hardeman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 8a5f3b9db713fce3c1da6daa71626fca2b42c8aa Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 16 Mar 2017 19:09:45 +0100 Subject: [PATCH 091/150] the click callback accepts an event as its third param See https://github.com/electron/electron/blob/6d45052eeaf57faf239523b1b328cf37281ae030/lib/browser/api/menu-item.js#L52 --- electron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index 0b98ae1944..b5a657ab61 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2492,7 +2492,7 @@ declare namespace Electron { /** * Callback when the menu item is clicked. */ - click?: (menuItem: MenuItem, browserWindow: BrowserWindow) => void; + click?: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event) => void; /** * Can be normal, separator, submenu, checkbox or radio. */ From a207b07344f3720ca65c218a8766d8f7d1379f4b Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 16 Mar 2017 19:10:12 +0100 Subject: [PATCH 092/150] Fix signature for menu item click instance method See https://github.com/electron/electron/blob/6d45052eeaf57faf239523b1b328cf37281ae030/lib/browser/api/menu-item.js#L44 --- electron/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index b5a657ab61..c7ba10f83c 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2455,7 +2455,11 @@ declare namespace Electron { */ constructor(options: MenuItemOptions); - click: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event) => void; + /** + * A Function that is fired when the MenuItem recieves a click event + */ + click: (event: Event, browserWindow: BrowserWindow, webContents: WebContents) => void; + /** * Read-only property. */ From 021ee30fe2aff40307a6cd4f3f00894f9c64c995 Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 16 Mar 2017 19:10:25 +0100 Subject: [PATCH 093/150] Add tests to verify new signatures --- electron/test/main.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/electron/test/main.ts b/electron/test/main.ts index 276a15d851..35a85a81dc 100644 --- a/electron/test/main.ts +++ b/electron/test/main.ts @@ -531,12 +531,19 @@ var winWindows = new BrowserWindow({ // menu-item // https://github.com/atom/electron/blob/master/docs/api/menu-item.md -var menuItem = new MenuItem({}); +var menuItem = new MenuItem({ + click: (menuItem: Electron.MenuItem, browserWindow: Electron.BrowserWindow, event: Electron.Event) => { + console.log('click', menuItem, browserWindow, event); + } +}); + +const fakeEvent: Electron.Event = { + preventDefault: () => { }, + sender: winWindows.webContents, +} menuItem.label = 'Hello World!'; -menuItem.click = (menuItem, browserWindow) => { - console.log('click', menuItem, browserWindow); -}; +menuItem.click(fakeEvent, winWindows, winWindows.webContents) // menu // https://github.com/atom/electron/blob/master/docs/api/menu.md From 262a66c3090af69a4d328bdbe70aae662353206a Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 16 Mar 2017 21:37:31 +0100 Subject: [PATCH 094/150] Add myself to the definitions list --- electron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index c7ba10f83c..3fab5cdf63 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Electron v1.4.8 // Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd , Milan Burda , aliib , Daniel Perez Alvarez +// Definitions by: jedmao , rhysd , Milan Burda , aliib , Daniel Perez Alvarez , Markus Olsson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From a6c1c773a5aca88aa4ef7ecdd64c71af488b4b43 Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Fri, 17 Mar 2017 00:32:16 +0100 Subject: [PATCH 095/150] Spelling --- electron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index 3fab5cdf63..11103b3a18 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2456,7 +2456,7 @@ declare namespace Electron { constructor(options: MenuItemOptions); /** - * A Function that is fired when the MenuItem recieves a click event + * A function that is fired when the MenuItem receives a click event */ click: (event: Event, browserWindow: BrowserWindow, webContents: WebContents) => void; From e3385bf72b718e9f59bc4a1205a266ed15c341c6 Mon Sep 17 00:00:00 2001 From: andy-ms Date: Thu, 16 Mar 2017 20:17:28 -0700 Subject: [PATCH 096/150] Add 'dir-resolve' --- dir-resolve/dir-resolve-tests.ts | 3 +++ dir-resolve/index.d.ts | 7 +++++++ dir-resolve/tsconfig.json | 22 ++++++++++++++++++++++ dir-resolve/tslint.json | 1 + 4 files changed, 33 insertions(+) create mode 100644 dir-resolve/dir-resolve-tests.ts create mode 100644 dir-resolve/index.d.ts create mode 100644 dir-resolve/tsconfig.json create mode 100644 dir-resolve/tslint.json diff --git a/dir-resolve/dir-resolve-tests.ts b/dir-resolve/dir-resolve-tests.ts new file mode 100644 index 0000000000..d84f9d0efc --- /dev/null +++ b/dir-resolve/dir-resolve-tests.ts @@ -0,0 +1,3 @@ +import resolve = require("dir-resolve"); + +resolve("module/package"); diff --git a/dir-resolve/index.d.ts b/dir-resolve/index.d.ts new file mode 100644 index 0000000000..0b8f425b0b --- /dev/null +++ b/dir-resolve/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for dir-resolve 1.0 +// Project: https://github.com/mwinche/dir-resolve +// Definitions by: Andy Hanson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function resolve(path: string): string; +export = resolve; diff --git a/dir-resolve/tsconfig.json b/dir-resolve/tsconfig.json new file mode 100644 index 0000000000..1748792b1d --- /dev/null +++ b/dir-resolve/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dir-resolve-tests.ts" + ] +} \ No newline at end of file diff --git a/dir-resolve/tslint.json b/dir-resolve/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/dir-resolve/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 78d4a9d2962c16b9874399d26c49c97f6f79f0eb Mon Sep 17 00:00:00 2001 From: David Findley Date: Thu, 16 Mar 2017 22:48:35 -0500 Subject: [PATCH 097/150] jwt-simple: Adding optional 'algorithm' param to decode() --- jwt-simple/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jwt-simple/index.d.ts b/jwt-simple/index.d.ts index 1ae8f18519..b70aa8c720 100644 --- a/jwt-simple/index.d.ts +++ b/jwt-simple/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jwt-simple v0.5.0 +// Type definitions for jwt-simple v0.5.1 // Project: https://github.com/hokaccha/node-jwt-simple // Definitions by: Ken Fukuyama , Gael Magnan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,7 +11,7 @@ * @param algorithm default is HS256 * @api public */ -export function decode(token: any, key: string, noVerify?: boolean): any; +export function decode(token: any, key: string, noVerify?: boolean, algorithm?: string): any; /** * Encode jwt * @param payload From ebd423cc3d134a2d061a95e1567cd50f082eae69 Mon Sep 17 00:00:00 2001 From: Alexander Batukhtin Date: Fri, 17 Mar 2017 20:13:28 +0300 Subject: [PATCH 098/150] Speakeasy: added "digits" property to the TotpOptions interface. --- speakeasy/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/speakeasy/index.d.ts b/speakeasy/index.d.ts index 15ec90c09a..4e281f996f 100644 --- a/speakeasy/index.d.ts +++ b/speakeasy/index.d.ts @@ -49,6 +49,7 @@ interface TotpOptions { counter?: number; epoch?: number; secret?: string; + digits?: number; digest?: () => string; algorithm?: string; } From d18dc045edc38ad291d73f5f526d5a71e87db524 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 17 Mar 2017 10:54:51 -0700 Subject: [PATCH 099/150] Overhauled YouTube API typings Added completed docs comments, numeric values, and more informative literal types. Removed deprecated fields. With :heart: from Office Sway! --- youtube/index.d.ts | 1037 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 903 insertions(+), 134 deletions(-) diff --git a/youtube/index.d.ts b/youtube/index.d.ts index ca5d99550a..a45ec6a8c8 100644 --- a/youtube/index.d.ts +++ b/youtube/index.d.ts @@ -1,166 +1,935 @@ // Type definitions for YouTube // Project: https://developers.google.com/youtube/ -// Definitions by: Daz Wilkin , Ian Obermiller +// Definitions by: Daz Wilkin , +// Ian Obermiller , +// Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 -declare namespace YT { - interface EventArgs { - target: Player; - data: any; - } - - interface EventHandler { - (event: EventArgs): void; - } - - export interface Events { - onReady?: EventHandler; - onPlayback?: EventHandler; - onStateChange?: EventHandler; - onError?: EventHandler; - } - - export enum ListType { - search, - user_uploads, - playlist, +/** + * @see https://developers.google.com/youtube/iframe_api_reference + * @see https://developers.google.com/YouTube/player_parameters + */ +declare namespace YT +{ + /** + * State of a video player. + */ + export enum PlayerState + { + UNSTARTED = -1, + ENDED = 0, + PLAYING = 1, + PAUSED = 2, + BUFFERING = 3, + CUED = 5 } - export interface PlayerVars { - autohide?: number; - autoplay?: number; - cc_load_policy?: any; - color?: string; - controls?: number; - disablekb?: number; - enablejsapi?: number; + /** + * Known causes for player errors. + */ + export const enum PlayerError + { + /** + * The request contained an invalid parameter value. + */ + InvalidParam = 2, + + /** + * The requested content cannot be played in an HTML5 player. + */ + Html5Error = 5, + + /** + * The video requested was not found. + */ + VideoNotFound = 100, + + /** + * The owner of the requested video does not allow it to be played in embedded players. + */ + EmbeddingNotAllowed = 101, + + /** + * This error is the same as 101. It's just a 101 error in disguise! + */ + EmbeddingNotAllowed2 = 150 + } + + /** + * Whether to auto-hide video controls. + */ + export const enum AutoHide + { + /** + * Controls are visible throughout the video + */ + AlwaysVisible = 0, + + /** + * Progress bar and player controls slide out of view after a couple of seconds. + */ + HideAllControls = 1, + + /** + * Progress bar fades out while the player controls remain visible. + */ + HideProgressBar = 2 + } + + /** + * Whether to autoplay the video. + */ + export const enum AutoPlay + { + /** + * Video does not autoplay. + */ + NoAutoPlay = 0, + + /** + * Video will autoplay when loaded. + */ + AutoPlay = 1 + } + + /** + * Whether to use user-preferred or forced caption loading. + */ + export const enum ClosedCaptionsLoadPolicy + { + /** + * Defaults to the user's preferences. + */ + UserDefault = 0, + + /** + * For closed captions to be shown. + */ + ForceOn = 1 + } + + /** + * Allowed progress bar colors. + */ + export type ProgressBarColor = "red" | "white"; + + /** + * How video controls are shown. + */ + export const enum Controls + { + /** + * Player controls do not display. + */ + Hide = 0, + + /** + * Player controls display. + */ + ShowLoadPlayer = 1, + + /** + * Player controls display after a delay. + */ + ShowDelayLoadPlayer = 2 + } + + /** + * Whether to allow keyboard controls. + */ + export const enum KeyboardControls + { + /** + * Keyboard controls are enabled. + */ + Enable = 0, + + /** + * Keyboard controls are disabled. + */ + Disable = 1 + } + + /** + * Whether the JavaScript API should be enabled. + */ + export const enum JsApi + { + /** + * JavaScript API will be disabled. + */ + Disable = 0, + + /** + * JavaScript API will be enabled. + */ + Enable = 1 + } + + /** + * Whether to display the full-screen button. + */ + export const enum FullscreenButton + { + /** + * The full screen button is hidden. + */ + Hide = 0, + + /** + * The full screen button is visible. + */ + Show = 1 + } + + /** + * Whether to show video annotations. + */ + export const enum IvLoadPolicy + { + /** + * Video annotations will be shown. + */ + Show = 1, + + /** + * Video annotations will not be shown. + */ + Hide = 3 + } + + /** + * Which type of content loads in the player. + */ + export type ListType = ListTypePlayer | ListTypeSearch | ListTypeUserUploads; + + /** + * The requested video should be shown in the player. + */ + export type ListTypePlayer = "player"; + + /** + * A search area should be shown in the player. + */ + export type ListTypeSearch = "search"; + + /** + * The user's uploads should load in the player. + */ + export type ListTypeUserUploads = "user_uploads"; + + /** + * Whether a single video should be looped. + */ + export const enum Loop + { + /** + * Video or playlist will be played only once. + */ + SinglePlay = 0, + + /** + * Video or playlist will be played over and over again. + */ + Loop = 1 + } + + /** + * Comma separated list of video IDs to play after the URL path's video. + */ + export const enum ModestBranding + { + /** + * Player will contain full YouTube branding. + */ + Full = 0, + + /** + * YouTube logo will not display in the control bar. + */ + Modest = 1 + } + + /** + * Whether to show related videos after the video finishes. + */ + export const enum RelatedVideos + { + /** + * Hide related videos after playback is complete. + */ + Hide = 0, + + /** + * Show related videos after playback is complete. + */ + Show = 1 + } + + /** + * Whether to show video information before playing. + */ + export const enum ShowInfo + { + /** + * Hide video title and uploader before video starts playing. + */ + Hide = 0, + + /** + * Show video title and uploader before video starts playing. + */ + Show = 1 + } + + /** + * Base interface for events triggered by a player. + */ + export interface PlayerEvent + { + /** + * Video player corresponding to the event. + */ + target: Player; + } + + /** + * Event for player state change. + */ + export interface OnStateChangeEvent extends PlayerEvent + { + /** + * New player state. + */ + data: PlayerState; + } + + /** + * Event for playback quality change. + */ + export interface OnPlaybackQualityChangeEvent extends PlayerEvent + { + /** + * New playback quality. + */ + data: string; + } + + /** + * Event for playback rate change. + */ + export interface OnPlaybackRateChangeEvent extends PlayerEvent + { + /** + * New playback rate. + */ + data: number; + } + + /** + * Event for a player error. + */ + export interface OnErrorEvent extends PlayerEvent + { + /** + * Which type of error occurred. + */ + data: PlayerError; + } + + /** + * Handles a player event. + * + * @param event The triggering event. + */ + export interface PlayerEventHandler + { + (event: TEvent): void; + } + + /** + * YouTube player options. + */ + export interface PlayerOptions + { + /** + * Player width. + */ + width?: number; + + /** + * Player height + */ + height?: number; + + /** + * ID of the video to load. + */ + videoId: string; + + /** + * Player parameters. + */ + playerVars?: PlayerVars; + + /** + * Handlers for events fired by the player. + */ + events?: Events; + } + + /** + * Allowed suggested player video qualities. + */ + export type SuggestedVideoQuality = ( + VideoQualityDefault + | VideoQualitySmall + | VideoQualityMedium + | VideoQualityLarge + | VideoQualityHD720 + | VideoQualityHD1080 + | VideoQualityHighRes); + + /** + * Default video quality chosen by YouTube. + */ + export type VideoQualityDefault = "default"; + + /** + * Player height is 240px, and player dimensions are at least 320px by 240px for 4:3 aspect ratio. + */ + export type VideoQualitySmall = "small"; + + /** + * Player height is 360px, and player dimensions are 640px by 360px (for 16:9 aspect ratio) or 480px by 360px (for 4:3 aspect ratio). + */ + export type VideoQualityMedium = "medium"; + + /** + * Player height is 480px, and player dimensions are 853px by 480px (for 16:9 aspect ratio) or 640px by 480px (for 4:3 aspect ratio). + */ + export type VideoQualityLarge = "large"; + + /** + * Player height is 720px, and player dimensions are 1280px by 720px (for 16:9 aspect ratio) or 960px by 720px (for 4:3 aspect ratio). + */ + export type VideoQualityHD720 = "hd720"; + + /** + * Player height is 1080px, and player dimensions are 1920px by 1080px (for 16:9 aspect ratio) or 1440px by 1080px (for 4:3 aspect ratio). + */ + export type VideoQualityHD1080 = "hd1080"; + + /** + * Player height is greater than 1080px, which means that the player's aspect ratio is greater than 1920px by 1080px. + */ + export type VideoQualityHighRes = "highres"; + + /** + * Player parameters. + */ + export interface PlayerVars + { + /** + * Whether to autohide video controls (by default, HideProgressBar). + */ + autohide?: AutoHide; + + /** + * Whether to autoplay the video (by default, NoAutoPlay). + */ + autoplay?: AutoPlay; + + /** + * Whether to use user-preferred or forced caption loading (by default, UserDefault). + */ + cc_load_policy?: ClosedCaptionsLoadPolicy; + + /** + * Player progress bar color + */ + color?: ProgressBarColor; + + /** + * How video controls are shown (by default, ShowLoadPlayer). + */ + controls?: Controls; + + /** + * Whether to allow keyboard controls (by default, Enable). + */ + disablekb?: KeyboardControls; + + /** + * Whether the JavaScript API should be enabled (by default, Disable). + */ + enablejsapi?: JsApi; + + /** + * Time, in seconds from the beginning of the video, when to stop playing. + */ end?: number; - fs?: number; - iv_load_policy?: number; + + /** + * Whether to display the full-screen button (by default, Show). + */ + fs?: FullscreenButton; + + /** + * Player language as an ISO 639-1 two-letter language code or fully-specified locale. + */ + hl?: string; + + /** + * Whether to show video annotations (by default, Show). + */ + iv_load_policy?: IvLoadPolicy; + + /** + * Identifies content that will load. + * If listType is search, this is the search query. + * If listType is user_uploads, this is the YouTube user. + * If listType is playlist, this is the playlist ID, prepended by 'PL'. + */ list?: string; + + /** + * Which type of content loads in the player. + */ listType?: ListType; - loop?: number; - modestbranding?: number; + + /** + * Whether a single video should be looped (by default, SinglePlay). + */ + loop?: Loop; + + /** + * Whether to hide some YouTube branding (by default, Full). + */ + modestbranding?: ModestBranding; + + /** + * Origin domain for additional security if using the JavaScript API. + */ origin?: string; - playerpiid?: string; - playlist?: string[]; - playsinline?: number; - rel?: number; - showinfo?: number; + + /** + * Comma separated list of video IDs to play after the URL path's video. + */ + playlist?: string; + + /** + * Whether to show related videos after the video finishes (by default, Show). + */ + rel?: RelatedVideos; + + /** + * Whether to show video information before playing (by default, Show). + */ + showinfo?: ShowInfo; + + /** + * Time, in seconds from the beginning of the video, when to start playing. + */ start?: number; - theme?: string; - } + } - export interface PlayerOptions { - width?: string | number; - height?: string | number; - videoId?: string; - playerVars?: PlayerVars; - events?: Events; - } + /** + * Handlers for events fired by the player. + */ + export interface Events + { + /** + * Event fired when a player has finished loading and is ready to begin receiving API calls. + */ + onReady?: PlayerEventHandler; - interface VideoByIdParams { - videoId: string; - startSeconds?: number; - endSeconds?: number; - suggestedQuality?: string; - } + /** + * Event fired when the player's state changes. + */ + onStateChange?: PlayerEventHandler; - interface VideoByUrlParams { - mediaContentUrl: string; - startSeconds?: number; - endSeconds?: number; - suggestedQuality?: string; - } + /** + * Event fired when the playback quality of the player changes. + */ + onPlaybackQualityChange?: PlayerEventHandler; - export interface VideoData - { - video_id: string; - author: string; - title: string; - } + /** + * Event fired when the playback rate of the player changes. + */ + onPlaybackRateChange?: PlayerEventHandler; - export class Player { - // Constructor - constructor(id: string, playerOptions: PlayerOptions); - constructor(element: HTMLElement, playerOptions: PlayerOptions); + /** + * Event fired when an error in the player occurs + */ + onError?: PlayerEventHandler; - // Queueing functions - loadVideoById(videoId: string, startSeconds?: number, suggestedQuality?: string): void; - loadVideoById(VideoByIdParams: Object): void; - cueVideoById(videoId: string, startSeconds?: number, suggestedQuality?: string): void; - cueVideoById(VideoByIdParams: Object): void; + /** + * Event fired to indicate thath the player has loaded, or unloaded, a module + * with exposed API methods. This currently only occurs for closed captioning. + */ + onApiChange?: PlayerEventHandler; + } - loadVideoByUrl(mediaContentUrl: string, startSeconds?: number, suggestedQuality?: string): void; - loadVideoByUrl(VideoByUrlParams: Object): void; - cueVideoByUrl(mediaContentUrl: string, startSeconds?: number, suggestedQuality?: string): void; - cueVideoByUrl(VideoByUrlParams: Object): void; + /** + * Settings to load, play, or queue a video or playlist. + */ + export interface VideoOrPlaylistSettings { + /** + * Time, in seconds from the beginning of the (first) video, when to start playing. + */ + startSeconds?: number; - // Properties - size: any; + /** + * Time, in seconds from the end of the (first) video, when to end playing. + */ + endSeconds?: number; - // Playing - playVideo(): void; - pauseVideo(): void; - stopVideo(): void; - seekTo(seconds:number, allowSeekAhead:boolean): void; - clearVideo(): void; + /** + * Suggested video player quality. + */ + suggestedQuality?: SuggestedVideoQuality + } - // Playlist - nextVideo(): void; - previousVideo(): void; - playVideoAt(index: number): void; + /** + * Settings to play or queue a video by ID. + */ + export interface VideoByIdSettings extends VideoOrPlaylistSettings { + /** + * Video ID. + */ + videoId: string; + } - // Volume - mute(): void; - unMute(): void; - isMuted(): boolean; - setVolume(volume: number): void; - getVolume(): number; + /** + * Settings to play or queue a video by media content URL. + */ + export interface VideoByMediaContentUrlSettings extends VideoOrPlaylistSettings { + /** + * Fully qualified player URL. + */ + mediaContentUrl: string; + } - // Sizing - setSize(width: number, height: number): any; + /** + * Settings to load or queue a playlist. + */ + export interface IPlaylistSettings extends VideoOrPlaylistSettings { + /** + * Identifier for the listType videos list. + */ + list: string; - // Playback - getPlaybackRate(): number; - setPlaybackRate(suggestedRate:number): void; - getAvailablePlaybackRates(): number[]; + /** + * Which type of content loads in the player. + */ + listType?: ListType; - // Behavior - setLoop(loopPlaylists: boolean): void; - setShuffle(shufflePlaylist: boolean): void; + /** + * Start index of the playlist, if not 0. + */ + index?: number; + } - // Status - getVideoLoadedFraction(): number; - getPlayerState(): number; - getCurrentTime(): number; - getVideoStartBytes(): number; - getVideoBytesLoaded(): number; - getVideoBytesTotal(): number; + /** + * Creates and controls a YouTube player in an