Skip to content

Commit a01c9cf

Browse files
authored
chore: add ts_api_guardian (#5494)
1 parent ae59558 commit a01c9cf

File tree

18 files changed

+1172
-33
lines changed

18 files changed

+1172
-33
lines changed

.circleci/config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ jobs:
5858
- attach_workspace: *attach_options
5959
- run: npm run dtslint
6060

61+
api_guardian:
62+
<<: *defaults
63+
steps:
64+
- attach_workspace: *attach_options
65+
- run: npm run api_guardian
66+
6167
typescript3:
6268
<<: *defaults
6369
steps:

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
# Installed libs
1010
node_modules/
11-
typings/
11+
/typings/
1212

1313
# Generated
14-
dist/
15-
dist-compat/
14+
/dist/
15+
/dist-compat/
1616
tmp/
1717
coverage/
1818
img/
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
export declare const ajax: AjaxCreationMethod;
2+
3+
export interface AjaxError extends Error {
4+
request: AjaxRequest;
5+
response: any;
6+
responseType: string;
7+
status: number;
8+
xhr: XMLHttpRequest;
9+
}
10+
11+
export declare const AjaxError: AjaxErrorCtor;
12+
13+
export interface AjaxRequest {
14+
async?: boolean;
15+
body?: any;
16+
createXHR?: () => XMLHttpRequest;
17+
crossDomain?: boolean;
18+
hasContent?: boolean;
19+
headers?: Object;
20+
method?: string;
21+
password?: string;
22+
progressSubscriber?: Subscriber<any>;
23+
responseType?: string;
24+
timeout?: number;
25+
url?: string;
26+
user?: string;
27+
withCredentials?: boolean;
28+
}
29+
30+
export declare class AjaxResponse {
31+
originalEvent: Event;
32+
request: AjaxRequest;
33+
response: any;
34+
responseText: string;
35+
responseType: string;
36+
status: number;
37+
xhr: XMLHttpRequest;
38+
constructor(originalEvent: Event, xhr: XMLHttpRequest, request: AjaxRequest);
39+
}
40+
41+
export interface AjaxTimeoutError extends AjaxError {
42+
}
43+
44+
export declare const AjaxTimeoutError: AjaxTimeoutErrorCtor;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export declare function fromFetch<T>(input: string | Request, init: RequestInit & {
2+
selector: (response: Response) => ObservableInput<T>;
3+
}): Observable<T>;
4+
export declare function fromFetch(input: string | Request, init?: RequestInit): Observable<Response>;

api_guard/dist/typings/index.d.ts

Lines changed: 614 additions & 0 deletions
Large diffs are not rendered by default.

api_guard/dist/typings/operators/index.d.ts

Lines changed: 368 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export declare class TestScheduler extends VirtualTimeScheduler {
2+
assertDeepEqual: (actual: any, expected: any) => boolean | void;
3+
readonly coldObservables: ColdObservable<any>[];
4+
readonly hotObservables: HotObservable<any>[];
5+
constructor(assertDeepEqual: (actual: any, expected: any) => boolean | void);
6+
createColdObservable<T = string>(marbles: string, values?: {
7+
[marble: string]: T;
8+
}, error?: any): ColdObservable<T>;
9+
createHotObservable<T = string>(marbles: string, values?: {
10+
[marble: string]: T;
11+
}, error?: any): HotObservable<T>;
12+
createTime(marbles: string): number;
13+
expectObservable(observable: Observable<any>, subscriptionMarbles?: string): ({
14+
toBe: observableToBeFn;
15+
});
16+
expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): ({
17+
toBe: subscriptionLogsToBeFn;
18+
});
19+
flush(): void;
20+
run<T>(callback: (helpers: RunHelpers) => T): T;
21+
static parseMarbles(marbles: string, values?: any, errorValue?: any, materializeInnerObservables?: boolean, runMode?: boolean): TestMessage[];
22+
static parseMarblesAsSubscriptions(marbles: string, runMode?: boolean): SubscriptionLog;
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export declare function webSocket<T>(urlConfigOrSource: string | WebSocketSubjectConfig<T>): WebSocketSubject<T>;
2+
3+
export declare class WebSocketSubject<T> extends AnonymousSubject<T> {
4+
_output: Subject<T>;
5+
constructor(urlConfigOrSource: string | WebSocketSubjectConfig<T> | Observable<T>, destination?: Observer<T>);
6+
_subscribe(subscriber: Subscriber<T>): Subscription;
7+
lift<R>(operator: Operator<T, R>): WebSocketSubject<R>;
8+
multiplex(subMsg: () => any, unsubMsg: () => any, messageFilter: (value: T) => boolean): Observable<any>;
9+
unsubscribe(): void;
10+
}
11+
12+
export interface WebSocketSubjectConfig<T> {
13+
WebSocketCtor?: {
14+
new (url: string, protocols?: string | string[]): WebSocket;
15+
};
16+
binaryType?: 'blob' | 'arraybuffer';
17+
closeObserver?: NextObserver<CloseEvent>;
18+
closingObserver?: NextObserver<void>;
19+
deserializer?: (e: MessageEvent) => T;
20+
openObserver?: NextObserver<Event>;
21+
protocol?: string | Array<string>;
22+
resultSelector?: (e: MessageEvent) => T;
23+
serializer?: (value: T) => WebSocketMessage;
24+
url: string;
25+
}

package-lock.json

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
]
4141
},
4242
"ignore": [
43-
"spec-dtslint/**/*.{js,ts}"
43+
"spec-dtslint/**/*.{js,ts}",
44+
"api_guard/**/*.{js,ts}"
4445
]
4546
},
4647
"scripts": {
@@ -122,7 +123,9 @@
122123
"compat_compile_dist_esm5_for_rollup": "tsc -p ./tsconfig/compat/tsconfig.esm5.rollup.json",
123124
"compat_compile_dist_esm2015": "tsc -p ./tsconfig/compat/tsconfig.esm2015.json",
124125
"compat_copy_sources": "mkdirp dist-compat && shx cp -r ./compat/ ./dist-compat/",
125-
"compat_generate_packages": "node .make-compat-package.js"
126+
"compat_generate_packages": "node .make-compat-package.js",
127+
"api_guardian:update": "ts-api-guardian --outDir api_guard dist/typings/index.d.ts dist/typings/ajax/index.d.ts dist/typings/fetch/index.d.ts dist/typings/operators/index.d.ts dist/typings/testing/index.d.ts dist/typings/webSocket/index.d.ts",
128+
"api_guardian": "ts-api-guardian --verifyDir api_guard dist/typings/index.d.ts dist/typings/ajax/index.d.ts dist/typings/fetch/index.d.ts dist/typings/operators/index.d.ts dist/typings/testing/index.d.ts dist/types/webSocket/index.d.ts"
126129
},
127130
"repository": {
128131
"type": "git",
@@ -238,6 +241,7 @@
238241
"source-map-support": "0.5.3",
239242
"symbol-observable": "1.0.1",
240243
"systemjs": "^0.21.0",
244+
"ts-api-guardian": "^0.5.0",
241245
"ts-node": "6.1.0",
242246
"tsconfig-paths": "3.2.0",
243247
"tslint": "5.9.1",

0 commit comments

Comments
 (0)