mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
- add type definitions for apicalypse package (#43304)
- add type definitions for igdb-api-node package
This commit is contained in:
parent
220266e22c
commit
47dd795052
56
types/apicalypse/apicalypse-tests.ts
Normal file
56
types/apicalypse/apicalypse-tests.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import Apicalypse from 'apicalypse';
|
||||
|
||||
// $ExpectType Apicalypse
|
||||
Apicalypse({
|
||||
baseURL: 'https://my-api.url',
|
||||
queryMethod: 'url',
|
||||
auth: {
|
||||
username: 'user',
|
||||
password: 'pass',
|
||||
},
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
responseType: 'json',
|
||||
timeout: 30000,
|
||||
});
|
||||
|
||||
// $ExpectType Promise<AxiosResponse<any>>
|
||||
Apicalypse()
|
||||
.fields('id,slug,name')
|
||||
.fields(['rating', 'popularity'])
|
||||
.sort('rating desc')
|
||||
.sort('name', 'asc')
|
||||
.limit(10)
|
||||
.offset(20)
|
||||
.where('rating > 0; popularity > 10')
|
||||
.where(['popularity < 100', 'first_release_date > 788918400'])
|
||||
.request('/games');
|
||||
|
||||
// $ExpectType Promise<any[]>
|
||||
Apicalypse()
|
||||
.search('title')
|
||||
.requestAll('/games');
|
||||
|
||||
// $ExpectType Promise<any[]>
|
||||
Apicalypse()
|
||||
.search('title')
|
||||
.requestAll('/games', {});
|
||||
|
||||
// $ExpectType Promise<any[]>
|
||||
Apicalypse()
|
||||
.search('title')
|
||||
.requestAll('/games', {
|
||||
concurrency: 2,
|
||||
delay: 500,
|
||||
});
|
||||
|
||||
// $ExpectType Apicalypse
|
||||
Apicalypse().multi([
|
||||
Apicalypse()
|
||||
.query('/games', 'game')
|
||||
.where('id == 1081'),
|
||||
Apicalypse()
|
||||
.query('/achievements', 'achievements')
|
||||
.where('game_id == 1081'),
|
||||
]);
|
||||
39
types/apicalypse/index.d.ts
vendored
Normal file
39
types/apicalypse/index.d.ts
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
// Type definitions for apicalypse 0.1
|
||||
// Project: https://github.com/igdb/node-apicalypse
|
||||
// Definitions by: Susam <https://github.com/susam-projects>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
|
||||
export interface Apicalypse {
|
||||
request(url: string): Promise<AxiosResponse>;
|
||||
requestAll(url: string, options?: RequestAllConfig): Promise<any[]>;
|
||||
|
||||
multi(queries: ReadonlyArray<Apicalypse>): Apicalypse;
|
||||
query(endpoint: string, name: string): Apicalypse;
|
||||
|
||||
fields(fields: string | ReadonlyArray<string>): Apicalypse;
|
||||
sort(field: string, direction?: SortDirection): Apicalypse;
|
||||
limit(limit: number): Apicalypse;
|
||||
offset(offset: number): Apicalypse;
|
||||
search(search: string): Apicalypse;
|
||||
where(filters: string | ReadonlyArray<string>): Apicalypse;
|
||||
}
|
||||
|
||||
export interface RequestAllConfig {
|
||||
concurrency?: number;
|
||||
delay?: number;
|
||||
}
|
||||
|
||||
export type SortDirection = 'asc' | 'desc';
|
||||
|
||||
declare function apicalypseFactory(options?: ApicalypseConfig): Apicalypse;
|
||||
declare function apicalypseFactory(rawQueryString: string, options?: ApicalypseConfig): Apicalypse;
|
||||
|
||||
export interface ApicalypseConfig extends AxiosRequestConfig {
|
||||
queryMethod?: QueryMethod;
|
||||
}
|
||||
|
||||
export type QueryMethod = 'body' | 'url';
|
||||
|
||||
export default apicalypseFactory;
|
||||
6
types/apicalypse/package.json
Normal file
6
types/apicalypse/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axios": "^0.19.0"
|
||||
}
|
||||
}
|
||||
23
types/apicalypse/tsconfig.json
Normal file
23
types/apicalypse/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"apicalypse-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/apicalypse/tslint.json
Normal file
1
types/apicalypse/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
15
types/igdb-api-node/igdb-api-node-tests.ts
Normal file
15
types/igdb-api-node/igdb-api-node-tests.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import igdb, { getTagNumber } from 'igdb-api-node';
|
||||
import { Apicalypse } from 'apicalypse';
|
||||
|
||||
// $ExpectType number
|
||||
getTagNumber(5, 1234);
|
||||
|
||||
// $ExpectType Apicalypse
|
||||
igdb();
|
||||
// $ExpectType Apicalypse
|
||||
igdb('test-api-key');
|
||||
// $ExpectType Apicalypse
|
||||
igdb('test-api-key', {
|
||||
queryMethod: 'url',
|
||||
method: 'get',
|
||||
});
|
||||
11
types/igdb-api-node/index.d.ts
vendored
Normal file
11
types/igdb-api-node/index.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
// Type definitions for igdb-api-node 4.0
|
||||
// Project: https://github.com/igdb/igdb-api-node
|
||||
// Definitions by: Susam <https://github.com/susam-projects>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Apicalypse, ApicalypseConfig } from 'apicalypse';
|
||||
|
||||
export function getTagNumber(category: number, id: number): number;
|
||||
|
||||
declare function igdb(apiKey?: string, opts?: ApicalypseConfig): Apicalypse;
|
||||
export default igdb;
|
||||
23
types/igdb-api-node/tsconfig.json
Normal file
23
types/igdb-api-node/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"igdb-api-node-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/igdb-api-node/tslint.json
Normal file
1
types/igdb-api-node/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user