-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typescript): add TypeScript annotations
- Loading branch information
Showing
13 changed files
with
165 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
interface Config { | ||
mockService: { | ||
host: string; | ||
port: number; | ||
}; | ||
logging: boolean; | ||
} | ||
|
||
export = Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function info(msg: string): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function isPortAvailable(port: number, host: string): Promise<void>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS'; | ||
|
||
export class Request { | ||
constructor (); | ||
send (method: HTTPMethod, url: string, body: string): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {HTTPMethod} from '../common/request'; | ||
import {MatcherResult} from './matchers'; | ||
|
||
export class Interaction { | ||
constructor(); | ||
given(providerState: string): Interaction; | ||
uponReceiving(description: string): Interaction; | ||
withRequest(requestOpts: RequestOptions): Interaction; | ||
willRespondWith(responseOpts: ResponseOptions): Interaction; | ||
json(): object; | ||
} | ||
|
||
export interface RequestOptions { | ||
method: HTTPMethod; | ||
path: string | MatcherResult; | ||
query?: any; | ||
headers?: {[name: string]: string | MatcherResult}; | ||
body?: any; | ||
} | ||
|
||
export interface ResponseOptions { | ||
status: number | MatcherResult; | ||
headers?: {[name: string]: string | MatcherResult}; | ||
body?: any; | ||
} | ||
|
||
export interface InteractionObject { | ||
state: string; | ||
uponReceiving: string; | ||
withRequest: RequestOptions; | ||
willRespondWith: ResponseOptions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export interface MatcherResult { | ||
json_class: string; | ||
} | ||
|
||
export function term(opts: {generate: string, matcher: string}): { | ||
json_class: 'Pact::Term', | ||
data: { | ||
generate: string, | ||
matcher: { | ||
json_class: 'Regexp', | ||
o: 0, | ||
s: string, | ||
}, | ||
}, | ||
}; | ||
|
||
export function eachLike<T>(content: T, opts?: {min: number}): { | ||
json_class: 'Pact::ArrayLike', | ||
contents: T, | ||
min: number, | ||
}; | ||
|
||
export function somethingLike<T>(value: T): { | ||
json_class: 'Pact::SomethingLike', | ||
contents: T, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {Interaction} from './interaction'; | ||
|
||
export class MockService { | ||
constructor (consumer: string, provider: string, port?: number, host?: string, ssl?: boolean); | ||
addInteraction(interaction: Interaction): Promise<string>; | ||
removeInteractions(): Promise<string>; | ||
verify(): Promise<string>; | ||
writePact(): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function verifyProvider(opts: any): Promise<void>; | ||
export = verifyProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {InteractionObject} from "./dsl/interaction"; | ||
import * as _Matchers from "./dsl/matchers"; | ||
|
||
declare function pact(opts: pact.PactKarmaOptions): pact.PactKarmaProvider; | ||
|
||
declare namespace pact { | ||
export interface PactKarmaOptions { | ||
consumer: string; | ||
provider: string; | ||
port?: number; | ||
host?: string; | ||
ssl?: boolean; | ||
} | ||
|
||
export interface PactKarmaProvider { | ||
addInteraction(interactionObj: InteractionObject): Promise<string>; | ||
verify(): Promise<void>; | ||
finalize(): Promise<void>; | ||
writePact(): Promise<string>; | ||
removeInteractions(): Promise<string>; | ||
} | ||
|
||
export const Matchers: typeof _Matchers; | ||
} | ||
|
||
export = pact; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {InteractionObject} from "./dsl/interaction"; | ||
import * as _Matchers from "./dsl/matchers"; | ||
import _Verifier = require("./dsl/verifier"); | ||
|
||
declare function pact(opts: pact.PactOptions): pact.PactProvider; | ||
|
||
declare namespace pact { | ||
export interface PactOptions { | ||
consumer: string; | ||
provider: string; | ||
port?: number; | ||
host?: string; | ||
ssl?: boolean; | ||
sslcert?: string; | ||
sslkey?: string; | ||
dir?: string; | ||
log?: string; | ||
logLevel?: string; | ||
spec?: number; | ||
cors?: boolean; | ||
} | ||
|
||
export interface PactProvider { | ||
setup(): Promise<void>; | ||
addInteraction(interactionObj: InteractionObject): Promise<string>; | ||
verify(): Promise<void>; | ||
finalize(): Promise<void>; | ||
writePact(): Promise<string>; | ||
removeInteractions(): Promise<string>; | ||
} | ||
|
||
export const Matchers: typeof _Matchers; | ||
export const Verifier: typeof _Verifier; | ||
} | ||
|
||
export = pact; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"noImplicitReturns": true, | ||
"noImplicitUseStrict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"strictNullChecks": true | ||
} | ||
} |