aniql 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +35 -21
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
1
|
+
import type { FieldsSelection, Mutation, MutationGenqlSelection, Query, QueryGenqlSelection } from './genql';
|
|
2
|
+
import { type ClientOptions } from './genql/runtime';
|
|
3
3
|
/** Represents a value that can be awaited. */
|
|
4
4
|
type Awaitable<T> = Promise<T> | T;
|
|
5
5
|
/** A utility type to make an object type more readable by removing excess properties. */
|
|
6
|
-
type Prettify<T> = {
|
|
7
|
-
[K in keyof T]: T[K]
|
|
8
|
-
} & {};
|
|
6
|
+
type Prettify<T> = T extends object ? {
|
|
7
|
+
[K in keyof T]: Prettify<T[K]>;
|
|
8
|
+
} & {} : T;
|
|
9
|
+
interface AniQLAuthBase {
|
|
10
|
+
client_id: number;
|
|
11
|
+
}
|
|
12
|
+
interface AniQLAuthResCode extends AniQLAuthBase {
|
|
13
|
+
response_type: 'code';
|
|
14
|
+
client_secret: string;
|
|
15
|
+
redirect_uri: string;
|
|
16
|
+
}
|
|
17
|
+
interface AniQLAuthResToken extends AniQLAuthBase {
|
|
18
|
+
response_type: 'token';
|
|
19
|
+
}
|
|
20
|
+
type AniQLAuth = Prettify<AniQLAuthResCode | AniQLAuthResToken>;
|
|
9
21
|
/** Options for the AniQL client. */
|
|
10
22
|
type AniQLOptions = ClientOptions & {
|
|
23
|
+
auth: AniQLAuth;
|
|
11
24
|
get_token?: () => Awaitable<string | undefined>;
|
|
12
25
|
};
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
* The client will automatically include the token, if provided via options, in the Authorization header for requests.
|
|
19
|
-
*
|
|
20
|
-
* For documentation on the AniList API, see https://docs.anilist.co/
|
|
21
|
-
*/
|
|
26
|
+
/** Options for the request made by the AniQL client. */
|
|
27
|
+
type RequestOptions = {
|
|
28
|
+
token?: string;
|
|
29
|
+
};
|
|
22
30
|
declare class AniQLClient {
|
|
23
|
-
|
|
24
|
-
client_id: number;
|
|
31
|
+
_opts: AniQLOptions;
|
|
25
32
|
static base_url: string;
|
|
26
|
-
constructor(
|
|
33
|
+
constructor(opts: AniQLOptions);
|
|
27
34
|
query<R extends QueryGenqlSelection>(request: R & {
|
|
28
35
|
__name?: string;
|
|
29
|
-
}): Promise<
|
|
36
|
+
}, opts?: RequestOptions): Promise<Prettify<FieldsSelection<Query, R>>>;
|
|
30
37
|
mutation<R extends MutationGenqlSelection>(request: R & {
|
|
31
38
|
__name?: string;
|
|
32
|
-
}): Promise<
|
|
33
|
-
|
|
39
|
+
}, opts?: RequestOptions): Promise<Prettify<FieldsSelection<Mutation, R>>>;
|
|
40
|
+
_fetcher(_token?: string): import("./genql/runtime/fetcher").Fetcher;
|
|
41
|
+
get auth_url(): string;
|
|
42
|
+
auth_exchange(code: string): Promise<{
|
|
43
|
+
access_token: string;
|
|
44
|
+
token_type: string;
|
|
45
|
+
expires_in: number;
|
|
46
|
+
refresh_token: string;
|
|
47
|
+
}>;
|
|
34
48
|
}
|
|
35
49
|
export * from './genql';
|
|
36
|
-
export { AniQLClient, type AniQLOptions, type Awaitable, type Prettify };
|
|
50
|
+
export { AniQLClient, type AniQLOptions, type Awaitable, type Prettify, type RequestOptions };
|