@easecation/ecapi-sdk 0.1.0 → 0.1.2

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/types.d.ts CHANGED
@@ -1,8 +1,107 @@
1
+ /** Primitive values accepted by query/body helpers. */
1
2
  export type Primitive = string | number | boolean | null | undefined;
3
+ /** A query field can be a scalar or an array (serialized as repeated keys). */
2
4
  export type QueryValue = Primitive | Primitive[];
3
- export type QueryParams = Record<string, QueryValue>;
5
+ /**
6
+ * Common query keys used by ECAPI endpoints.
7
+ * This keeps object-key autocomplete useful while still allowing any custom key.
8
+ */
9
+ export interface QueryParams {
10
+ action?: QueryValue;
11
+ address?: QueryValue;
12
+ addressee?: QueryValue;
13
+ auth_method?: QueryValue;
14
+ ban_type?: QueryValue;
15
+ bigId?: QueryValue;
16
+ categories?: QueryValue;
17
+ category?: QueryValue;
18
+ client_ip?: QueryValue;
19
+ config_type?: QueryValue;
20
+ csv?: QueryValue;
21
+ current?: QueryValue;
22
+ data?: QueryValue;
23
+ deadline?: QueryValue;
24
+ deadline_type?: QueryValue;
25
+ desc?: QueryValue;
26
+ deviceId?: QueryValue;
27
+ downloadId?: QueryValue;
28
+ duration_range?: QueryValue;
29
+ ecid?: QueryValue;
30
+ enableBanHistoryParse?: QueryValue;
31
+ end?: QueryValue;
32
+ endTime?: QueryValue;
33
+ env?: QueryValue;
34
+ events?: QueryValue;
35
+ filter?: QueryValue;
36
+ frame?: QueryValue;
37
+ from?: QueryValue;
38
+ game?: QueryValue;
39
+ high_risk?: QueryValue;
40
+ id?: QueryValue;
41
+ iditem?: QueryValue;
42
+ idtask?: QueryValue;
43
+ is_ascending?: QueryValue;
44
+ key?: QueryValue;
45
+ lang?: QueryValue;
46
+ limit?: QueryValue;
47
+ map?: QueryValue;
48
+ max?: QueryValue;
49
+ maxPoints?: QueryValue;
50
+ min?: QueryValue;
51
+ name?: QueryValue;
52
+ nick?: QueryValue;
53
+ netease?: QueryValue;
54
+ operation_status?: QueryValue;
55
+ operation_type?: QueryValue;
56
+ operator_id?: QueryValue;
57
+ order?: QueryValue;
58
+ page?: QueryValue;
59
+ pageSize?: QueryValue;
60
+ pattern?: QueryValue;
61
+ permission?: QueryValue;
62
+ permission_type?: QueryValue;
63
+ players?: QueryValue;
64
+ port?: QueryValue;
65
+ record_id?: QueryValue;
66
+ requestid?: QueryValue;
67
+ runtimeid?: QueryValue;
68
+ score_type?: QueryValue;
69
+ search?: QueryValue;
70
+ skipwac?: QueryValue;
71
+ sort?: QueryValue;
72
+ sortBy?: QueryValue;
73
+ sortField?: QueryValue;
74
+ sortOrder?: QueryValue;
75
+ source_nick?: QueryValue;
76
+ start?: QueryValue;
77
+ startTime?: QueryValue;
78
+ state?: QueryValue;
79
+ table?: QueryValue;
80
+ tag?: QueryValue;
81
+ target_nick?: QueryValue;
82
+ target_player_id?: QueryValue;
83
+ to?: QueryValue;
84
+ token?: QueryValue;
85
+ type?: QueryValue;
86
+ types?: QueryValue;
87
+ usetime?: QueryValue;
88
+ uuid?: QueryValue;
89
+ valueType?: QueryValue;
90
+ year?: QueryValue;
91
+ "runtime-id"?: QueryValue;
92
+ [key: string]: QueryValue;
93
+ }
94
+ /** Simple HTTP header map. */
4
95
  export type HeaderMap = Record<string, string>;
96
+ /**
97
+ * Expected response decoding mode.
98
+ * - json: parse JSON (default)
99
+ * - text: return UTF-8 string
100
+ * - arrayBuffer: return binary bytes
101
+ * - raw: return fetch/raw response object (transport dependent)
102
+ */
5
103
  export type ResponseType = "json" | "text" | "arrayBuffer" | "raw";
104
+ /** Supported auth modes for ECAPI requests. */
6
105
  export type AuthCredentials = {
7
106
  type: "apiKey";
8
107
  apiKey: string;
@@ -10,17 +109,29 @@ export type AuthCredentials = {
10
109
  type: "appSessionToken";
11
110
  appSessionToken: string;
12
111
  };
112
+ /** Top-level options used when creating `ECAPIClient`. */
13
113
  export interface ClientOptions {
114
+ /** API base URL, e.g. https://console.easecation.net/apiv2 */
14
115
  baseUrl: string;
116
+ /** Default auth used by all requests unless overridden. */
15
117
  auth?: AuthCredentials;
118
+ /** Request timeout in milliseconds. Default is 15000. */
16
119
  timeoutMs?: number;
120
+ /** Headers merged into every request. */
17
121
  defaultHeaders?: HeaderMap;
18
122
  }
123
+ /** Per-request options for all SDK API methods. */
19
124
  export interface RequestOptions {
125
+ /** Query parameters appended to URL. */
20
126
  query?: QueryParams;
127
+ /** Request payload for POST/PUT/PATCH/DELETE where supported. */
21
128
  body?: unknown;
129
+ /** Additional headers for this request only. */
22
130
  headers?: HeaderMap;
131
+ /** Abort signal for request cancellation. */
23
132
  signal?: AbortSignal;
133
+ /** Response parsing mode for this request. */
24
134
  responseType?: ResponseType;
135
+ /** Override client-level auth. Use null to send no auth header. */
25
136
  auth?: AuthCredentials | null;
26
137
  }
package/package.json CHANGED
@@ -1,15 +1,25 @@
1
1
  {
2
2
  "name": "@easecation/ecapi-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "ECAPI SDK for JavaScript and TypeScript",
5
+ "homepage": "https://github.com/easecation/easecation-api/tree/main/sdk/npm/ecapi-sdk#readme",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/easecation/easecation-api.git",
9
+ "directory": "sdk/npm/ecapi-sdk"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/easecation/easecation-api/issues"
13
+ },
5
14
  "main": "dist/index.js",
6
15
  "types": "dist/index.d.ts",
7
16
  "files": [
8
17
  "dist",
18
+ "src/method-signatures.d.ts",
9
19
  "README.md"
10
20
  ],
11
21
  "scripts": {
12
- "build": "tsc -p tsconfig.json"
22
+ "build": "tsc -p tsconfig.json && mkdir -p dist/src && cp src/method-signatures.d.ts dist/src/method-signatures.d.ts"
13
23
  },
14
24
  "keywords": [
15
25
  "ecapi",