aniql 1.1.0 → 1.3.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 +46 -14
- package/dist/index.js +4 -4
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { FieldsSelection, Mutation, MutationGenqlSelection, Query, QueryGenqlSelection } from './genql';
|
|
2
2
|
import { type ClientOptions } from './genql/runtime';
|
|
3
3
|
/** Represents a value that can be awaited. */
|
|
4
|
-
type Awaitable<T> = Promise<T> | T;
|
|
5
|
-
/** A utility type to make an object type more readable by removing excess properties. */
|
|
6
|
-
type Prettify<T> = T extends object ? {
|
|
7
|
-
[K in keyof T]: Prettify<T[K]>;
|
|
8
|
-
} & {} : T;
|
|
4
|
+
export type Awaitable<T> = Promise<T> | T;
|
|
9
5
|
interface AniQLAuthBase {
|
|
10
6
|
client_id: number;
|
|
11
7
|
}
|
|
@@ -17,27 +13,64 @@ interface AniQLAuthResCode extends AniQLAuthBase {
|
|
|
17
13
|
interface AniQLAuthResToken extends AniQLAuthBase {
|
|
18
14
|
response_type: 'token';
|
|
19
15
|
}
|
|
20
|
-
type AniQLAuth =
|
|
16
|
+
export type AniQLAuth = AniQLAuthResCode | AniQLAuthResToken;
|
|
21
17
|
/** Options for the AniQL client. */
|
|
22
|
-
type AniQLOptions = ClientOptions & {
|
|
18
|
+
export type AniQLOptions = ClientOptions & {
|
|
23
19
|
auth: AniQLAuth;
|
|
24
20
|
get_token?: () => Awaitable<string | undefined>;
|
|
25
21
|
};
|
|
26
22
|
/** Options for the request made by the AniQL client. */
|
|
27
|
-
type
|
|
23
|
+
export type AniQLRequestOptions = {
|
|
28
24
|
token?: string;
|
|
29
25
|
};
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
/**
|
|
27
|
+
* AniQLClientError is an error class for errors that occur in the AniQL client.
|
|
28
|
+
*
|
|
29
|
+
* It extends the built-in Error class and includes a status code.
|
|
30
|
+
*/
|
|
31
|
+
export declare class AniQLClientError extends Error {
|
|
32
|
+
status: number;
|
|
33
|
+
constructor(status: number, message: string);
|
|
34
|
+
}
|
|
35
|
+
export type RateLimitData = {
|
|
36
|
+
limit: number;
|
|
37
|
+
remaining: number;
|
|
38
|
+
reset: number;
|
|
39
|
+
};
|
|
40
|
+
export interface AniQLClientEvents {
|
|
41
|
+
rate_limit: Array<(data: RateLimitData) => Awaitable<any>>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* AniQLClient is a client for interacting with the AniList GraphQL API.
|
|
45
|
+
* It allows you to perform queries and mutations against the AniList API.
|
|
46
|
+
* You can also get the login URL to authenticate users.
|
|
47
|
+
*
|
|
48
|
+
* The client will automatically include the token, if provided via options, in the Authorization header for requests.
|
|
49
|
+
*
|
|
50
|
+
* For documentation on the AniList API, see https://docs.anilist.co/
|
|
51
|
+
*/
|
|
52
|
+
export declare class AniQLClient {
|
|
53
|
+
#private;
|
|
32
54
|
static base_url: string;
|
|
55
|
+
rate_limit: RateLimitData;
|
|
56
|
+
on<K extends keyof AniQLClientEvents>(event: K, listener: AniQLClientEvents[K][number]): this;
|
|
33
57
|
constructor(opts: AniQLOptions);
|
|
34
58
|
query<R extends QueryGenqlSelection>(request: R & {
|
|
35
59
|
__name?: string;
|
|
36
|
-
}, opts?:
|
|
60
|
+
}, opts?: AniQLRequestOptions): Promise<FieldsSelection<Query, R>>;
|
|
37
61
|
mutation<R extends MutationGenqlSelection>(request: R & {
|
|
38
62
|
__name?: string;
|
|
39
|
-
}, opts?:
|
|
40
|
-
|
|
63
|
+
}, opts?: AniQLRequestOptions): Promise<FieldsSelection<Mutation, R>>;
|
|
64
|
+
make_query: <R extends QueryGenqlSelection>(request: R & {
|
|
65
|
+
__name?: string;
|
|
66
|
+
}) => R & {
|
|
67
|
+
__name?: string;
|
|
68
|
+
};
|
|
69
|
+
make_mutation: <R extends MutationGenqlSelection>(request: R & {
|
|
70
|
+
__name?: string;
|
|
71
|
+
}) => R & {
|
|
72
|
+
__name?: string;
|
|
73
|
+
};
|
|
41
74
|
get auth_url(): string;
|
|
42
75
|
auth_exchange(code: string): Promise<{
|
|
43
76
|
access_token: string;
|
|
@@ -47,4 +80,3 @@ declare class AniQLClient {
|
|
|
47
80
|
}>;
|
|
48
81
|
}
|
|
49
82
|
export * from './genql';
|
|
50
|
-
export { AniQLClient, type AniQLOptions, type Awaitable, type Prettify, type RequestOptions };
|