@takaro/apiclient 0.0.0-dev.a498dc6
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/README.md +32 -0
- package/dist/generated/api.d.ts +21285 -0
- package/dist/generated/api.d.ts.map +1 -0
- package/dist/generated/api.js +14416 -0
- package/dist/generated/api.js.map +1 -0
- package/dist/generated/base.d.ts +67 -0
- package/dist/generated/base.d.ts.map +1 -0
- package/dist/generated/base.js +59 -0
- package/dist/generated/base.js.map +1 -0
- package/dist/generated/common.d.ts +66 -0
- package/dist/generated/common.d.ts.map +1 -0
- package/dist/generated/common.js +135 -0
- package/dist/generated/common.js.map +1 -0
- package/dist/generated/configuration.d.ts +92 -0
- package/dist/generated/configuration.d.ts.map +1 -0
- package/dist/generated/configuration.js +46 -0
- package/dist/generated/configuration.js.map +1 -0
- package/dist/generated/index.d.ts +14 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +16 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/lib/adminClient.d.ts +13 -0
- package/dist/lib/adminClient.d.ts.map +1 -0
- package/dist/lib/adminClient.js +23 -0
- package/dist/lib/adminClient.js.map +1 -0
- package/dist/lib/baseClient.d.ts +31 -0
- package/dist/lib/baseClient.d.ts.map +1 -0
- package/dist/lib/baseClient.js +113 -0
- package/dist/lib/baseClient.js.map +1 -0
- package/dist/lib/client.d.ts +43 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +154 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +5 -0
- package/dist/main.js.map +1 -0
- package/package.json +23 -0
- package/src/__tests__/main.integration.test.ts +39 -0
- package/src/generated/.openapi-generator-ignore +23 -0
- package/src/generated/api.ts +32740 -0
- package/src/generated/base.ts +91 -0
- package/src/generated/common.ts +164 -0
- package/src/generated/configuration.ts +123 -0
- package/src/generated/git_push.sh +57 -0
- package/src/generated/index.ts +16 -0
- package/src/lib/adminClient.ts +37 -0
- package/src/lib/baseClient.ts +153 -0
- package/src/lib/client.ts +308 -0
- package/src/main.ts +9 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +8 -0
- package/typedoc.json +3 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CronJobApi,
|
|
3
|
+
FunctionApi,
|
|
4
|
+
GameServerApi,
|
|
5
|
+
RoleApi,
|
|
6
|
+
UserApi,
|
|
7
|
+
ModuleApi,
|
|
8
|
+
HookApi,
|
|
9
|
+
PlayerApi,
|
|
10
|
+
SettingsApi,
|
|
11
|
+
CommandApi,
|
|
12
|
+
VariableApi,
|
|
13
|
+
DiscordApi,
|
|
14
|
+
EventApi,
|
|
15
|
+
PlayerOnGameServerApi,
|
|
16
|
+
ItemApi,
|
|
17
|
+
StatsApi,
|
|
18
|
+
ShopOrderApi,
|
|
19
|
+
ShopListingApi,
|
|
20
|
+
ShopCategoryApi,
|
|
21
|
+
TrackingApi,
|
|
22
|
+
EntityApi,
|
|
23
|
+
AnalyticsApi,
|
|
24
|
+
} from '../generated/api.js';
|
|
25
|
+
import { BaseApiClient, IBaseApiClientConfig } from './baseClient.js';
|
|
26
|
+
|
|
27
|
+
export interface IApiClientConfig extends IBaseApiClientConfig {
|
|
28
|
+
auth: {
|
|
29
|
+
username?: string;
|
|
30
|
+
password?: string;
|
|
31
|
+
token?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class Client extends BaseApiClient<IApiClientConfig> {
|
|
36
|
+
public token: string | null;
|
|
37
|
+
constructor(config: IApiClientConfig) {
|
|
38
|
+
super(config);
|
|
39
|
+
|
|
40
|
+
if (this.config.auth.token) {
|
|
41
|
+
this.axios.defaults.headers.common['x-takaro-token'] = `${this.config.auth.token}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set username(username: string) {
|
|
46
|
+
this.config.auth.username = username;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
set password(password: string) {
|
|
50
|
+
this.config.auth.password = password;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public async login() {
|
|
54
|
+
if (!this.config.auth.username || !this.config.auth.password) {
|
|
55
|
+
throw new Error('No username or password provided');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const loginRes = await this.user.userControllerLogin({
|
|
59
|
+
password: this.config.auth.password,
|
|
60
|
+
username: this.config.auth.username,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
this.config.auth.token = loginRes.data.data.token;
|
|
64
|
+
this.token = loginRes.data.data.token;
|
|
65
|
+
|
|
66
|
+
this.axios.defaults.headers.common['Authorization'] = `Bearer ${loginRes.data.data.token}`;
|
|
67
|
+
|
|
68
|
+
return loginRes.data.data.token;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public logout() {
|
|
72
|
+
delete this.axios.defaults.headers.common['Authorization'];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public async permissionCodesToInputs(permissions: string[]) {
|
|
76
|
+
const permissionsRes = await this.role.roleControllerGetPermissions();
|
|
77
|
+
const records = permissionsRes.data.data
|
|
78
|
+
.filter((p) => permissions.includes(p.permission))
|
|
79
|
+
.map((p) => ({
|
|
80
|
+
permissionId: p.id,
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
if (records.length !== permissions.length)
|
|
84
|
+
throw new Error(`Not all permissions were found: ${permissions.join(', ')}`);
|
|
85
|
+
|
|
86
|
+
return records;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get item() {
|
|
90
|
+
return new ItemApi(
|
|
91
|
+
{
|
|
92
|
+
isJsonMime: this.isJsonMime,
|
|
93
|
+
},
|
|
94
|
+
'',
|
|
95
|
+
this.axios,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get user() {
|
|
100
|
+
return new UserApi(
|
|
101
|
+
{
|
|
102
|
+
isJsonMime: this.isJsonMime,
|
|
103
|
+
},
|
|
104
|
+
'',
|
|
105
|
+
this.axios,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get role() {
|
|
110
|
+
return new RoleApi(
|
|
111
|
+
{
|
|
112
|
+
isJsonMime: this.isJsonMime,
|
|
113
|
+
},
|
|
114
|
+
'',
|
|
115
|
+
this.axios,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get gameserver() {
|
|
120
|
+
return new GameServerApi(
|
|
121
|
+
{
|
|
122
|
+
isJsonMime: this.isJsonMime,
|
|
123
|
+
},
|
|
124
|
+
'',
|
|
125
|
+
this.axios,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get cronjob() {
|
|
130
|
+
return new CronJobApi(
|
|
131
|
+
{
|
|
132
|
+
isJsonMime: this.isJsonMime,
|
|
133
|
+
},
|
|
134
|
+
'',
|
|
135
|
+
this.axios,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
get function() {
|
|
140
|
+
return new FunctionApi(
|
|
141
|
+
{
|
|
142
|
+
isJsonMime: this.isJsonMime,
|
|
143
|
+
},
|
|
144
|
+
'',
|
|
145
|
+
this.axios,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get module() {
|
|
150
|
+
return new ModuleApi(
|
|
151
|
+
{
|
|
152
|
+
isJsonMime: this.isJsonMime,
|
|
153
|
+
},
|
|
154
|
+
'',
|
|
155
|
+
this.axios,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
get hook() {
|
|
160
|
+
return new HookApi(
|
|
161
|
+
{
|
|
162
|
+
isJsonMime: this.isJsonMime,
|
|
163
|
+
},
|
|
164
|
+
'',
|
|
165
|
+
this.axios,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
get command() {
|
|
170
|
+
return new CommandApi(
|
|
171
|
+
{
|
|
172
|
+
isJsonMime: this.isJsonMime,
|
|
173
|
+
},
|
|
174
|
+
'',
|
|
175
|
+
this.axios,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
get player() {
|
|
180
|
+
return new PlayerApi(
|
|
181
|
+
{
|
|
182
|
+
isJsonMime: this.isJsonMime,
|
|
183
|
+
},
|
|
184
|
+
'',
|
|
185
|
+
this.axios,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
get settings() {
|
|
190
|
+
return new SettingsApi(
|
|
191
|
+
{
|
|
192
|
+
isJsonMime: this.isJsonMime,
|
|
193
|
+
},
|
|
194
|
+
'',
|
|
195
|
+
this.axios,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
get variable() {
|
|
200
|
+
return new VariableApi(
|
|
201
|
+
{
|
|
202
|
+
isJsonMime: this.isJsonMime,
|
|
203
|
+
},
|
|
204
|
+
'',
|
|
205
|
+
this.axios,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
get discord() {
|
|
210
|
+
return new DiscordApi(
|
|
211
|
+
{
|
|
212
|
+
isJsonMime: this.isJsonMime,
|
|
213
|
+
},
|
|
214
|
+
'',
|
|
215
|
+
this.axios,
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
get event() {
|
|
220
|
+
return new EventApi(
|
|
221
|
+
{
|
|
222
|
+
isJsonMime: this.isJsonMime,
|
|
223
|
+
},
|
|
224
|
+
'',
|
|
225
|
+
this.axios,
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
get playerOnGameserver() {
|
|
230
|
+
return new PlayerOnGameServerApi(
|
|
231
|
+
{
|
|
232
|
+
isJsonMime: this.isJsonMime,
|
|
233
|
+
},
|
|
234
|
+
'',
|
|
235
|
+
this.axios,
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
get stats() {
|
|
240
|
+
return new StatsApi(
|
|
241
|
+
{
|
|
242
|
+
isJsonMime: this.isJsonMime,
|
|
243
|
+
},
|
|
244
|
+
'',
|
|
245
|
+
this.axios,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
get shopListing() {
|
|
250
|
+
return new ShopListingApi(
|
|
251
|
+
{
|
|
252
|
+
isJsonMime: this.isJsonMime,
|
|
253
|
+
},
|
|
254
|
+
'',
|
|
255
|
+
this.axios,
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
get shopCategory() {
|
|
260
|
+
return new ShopCategoryApi(
|
|
261
|
+
{
|
|
262
|
+
isJsonMime: this.isJsonMime,
|
|
263
|
+
},
|
|
264
|
+
'',
|
|
265
|
+
this.axios,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
get shopOrder() {
|
|
270
|
+
return new ShopOrderApi(
|
|
271
|
+
{
|
|
272
|
+
isJsonMime: this.isJsonMime,
|
|
273
|
+
},
|
|
274
|
+
'',
|
|
275
|
+
this.axios,
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
get tracking() {
|
|
280
|
+
return new TrackingApi(
|
|
281
|
+
{
|
|
282
|
+
isJsonMime: this.isJsonMime,
|
|
283
|
+
},
|
|
284
|
+
'',
|
|
285
|
+
this.axios,
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
get entity() {
|
|
290
|
+
return new EntityApi(
|
|
291
|
+
{
|
|
292
|
+
isJsonMime: this.isJsonMime,
|
|
293
|
+
},
|
|
294
|
+
'',
|
|
295
|
+
this.axios,
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
get analytics() {
|
|
300
|
+
return new AnalyticsApi(
|
|
301
|
+
{
|
|
302
|
+
isJsonMime: this.isJsonMime,
|
|
303
|
+
},
|
|
304
|
+
'',
|
|
305
|
+
this.axios,
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
|
|
3
|
+
export { AxiosResponse } from 'axios';
|
|
4
|
+
export { isAxiosError } from 'axios';
|
|
5
|
+
export { AdminClient } from './lib/adminClient.js';
|
|
6
|
+
export { Client } from './lib/client.js';
|
|
7
|
+
|
|
8
|
+
export type ITakaroAPIAxiosResponse<T> = AxiosResponse<T>;
|
|
9
|
+
export * from './generated/api.js';
|
package/tsconfig.json
ADDED
package/typedoc.json
ADDED