/
types.ts
87 lines (78 loc) · 1.7 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import * as MatchersV3 from './matchers';
import { JsonMap } from '../common/jsonTypes';
export enum SpecificationVersion {
SPECIFICATION_VERSION_V2 = 3,
SPECIFICATION_VERSION_V3 = 4,
SPECIFICATION_VERSION_V4 = 5,
}
/**
* Options for the mock server
*/
export interface PactV3Options {
/**
* Directory to write the pact file to
*/
dir: string;
/**
* Consumer name
*/
consumer: string;
/**
* Provider name
*/
provider: string;
/**
* If the mock server should handle CORS pre-flight requests. Defaults to false
*/
cors?: boolean;
/**
* Port to run the mock server on. Defaults to a random port
*/
port?: number;
/**
* Specification version to use
*/
spec?: SpecificationVersion;
/**
* Specification version to use
*/
logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error';
}
export interface V3ProviderState {
description: string;
parameters?: JsonMap;
}
export type TemplateHeaders = {
[header: string]: string | MatchersV3.Matcher<string>;
};
export type TemplateQuery = Record<
string,
| string
| MatchersV3.Matcher<string>
| Array<string | MatchersV3.Matcher<string>>
>;
export interface V3Interaction {
states?: V3ProviderState[];
uponReceiving: string;
withRequest: V3Request;
willRespondWith: V3Response;
}
export interface V3Request {
method: string;
path: string | MatchersV3.Matcher<string>;
query?: TemplateQuery;
headers?: TemplateHeaders;
body?: MatchersV3.AnyTemplate;
contentType?: string;
}
export interface V3Response {
status: number;
headers?: TemplateHeaders;
body?: MatchersV3.AnyTemplate;
contentType?: string;
}
export interface V3MockServer {
port: number;
url: string;
id: string;
}