@shirokasoke/webapi-sdk 2.9.0-bete2-0.6-pre

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.
Files changed (83) hide show
  1. package/dist/client.d.ts +400 -0
  2. package/dist/client.js +462 -0
  3. package/dist/esm/client.js +457 -0
  4. package/dist/esm/index.js +3 -0
  5. package/dist/esm/package.json +1 -0
  6. package/dist/esm/test.js +6 -0
  7. package/dist/esm/types/ae2.js +1 -0
  8. package/dist/esm/types/block.js +1 -0
  9. package/dist/esm/types/chunk.js +1 -0
  10. package/dist/esm/types/common.js +1 -0
  11. package/dist/esm/types/entity.js +1 -0
  12. package/dist/esm/types/fluid.js +1 -0
  13. package/dist/esm/types/fmp.js +1 -0
  14. package/dist/esm/types/gt5.js +1 -0
  15. package/dist/esm/types/index.js +11 -0
  16. package/dist/esm/types/item.js +1 -0
  17. package/dist/esm/types/rawInfo.js +1 -0
  18. package/dist/esm/types/world.js +1 -0
  19. package/dist/esm/validators/ae2.js +138 -0
  20. package/dist/esm/validators/block.js +85 -0
  21. package/dist/esm/validators/chunk.js +58 -0
  22. package/dist/esm/validators/common.js +28 -0
  23. package/dist/esm/validators/entity.js +117 -0
  24. package/dist/esm/validators/fluid.js +24 -0
  25. package/dist/esm/validators/fmp.js +34 -0
  26. package/dist/esm/validators/gt5.js +186 -0
  27. package/dist/esm/validators/index.js +11 -0
  28. package/dist/esm/validators/item.js +32 -0
  29. package/dist/esm/validators/rawInfo.js +25 -0
  30. package/dist/esm/validators/world.js +59 -0
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.js +22 -0
  33. package/dist/test.d.ts +1 -0
  34. package/dist/test.js +8 -0
  35. package/dist/types/ae2.d.ts +142 -0
  36. package/dist/types/ae2.js +2 -0
  37. package/dist/types/block.d.ts +87 -0
  38. package/dist/types/block.js +2 -0
  39. package/dist/types/chunk.d.ts +57 -0
  40. package/dist/types/chunk.js +2 -0
  41. package/dist/types/common.d.ts +27 -0
  42. package/dist/types/common.js +2 -0
  43. package/dist/types/entity.d.ts +114 -0
  44. package/dist/types/entity.js +2 -0
  45. package/dist/types/fluid.d.ts +23 -0
  46. package/dist/types/fluid.js +2 -0
  47. package/dist/types/fmp.d.ts +33 -0
  48. package/dist/types/fmp.js +2 -0
  49. package/dist/types/gt5.d.ts +210 -0
  50. package/dist/types/gt5.js +2 -0
  51. package/dist/types/index.d.ts +11 -0
  52. package/dist/types/index.js +27 -0
  53. package/dist/types/item.d.ts +39 -0
  54. package/dist/types/item.js +2 -0
  55. package/dist/types/rawInfo.d.ts +25 -0
  56. package/dist/types/rawInfo.js +2 -0
  57. package/dist/types/world.d.ts +58 -0
  58. package/dist/types/world.js +2 -0
  59. package/dist/validators/ae2.d.ts +55 -0
  60. package/dist/validators/ae2.js +144 -0
  61. package/dist/validators/block.d.ts +12 -0
  62. package/dist/validators/block.js +91 -0
  63. package/dist/validators/chunk.d.ts +9 -0
  64. package/dist/validators/chunk.js +64 -0
  65. package/dist/validators/common.d.ts +8 -0
  66. package/dist/validators/common.js +36 -0
  67. package/dist/validators/entity.d.ts +9 -0
  68. package/dist/validators/entity.js +123 -0
  69. package/dist/validators/fluid.d.ts +4 -0
  70. package/dist/validators/fluid.js +30 -0
  71. package/dist/validators/fmp.d.ts +4 -0
  72. package/dist/validators/fmp.js +40 -0
  73. package/dist/validators/gt5.d.ts +24 -0
  74. package/dist/validators/gt5.js +192 -0
  75. package/dist/validators/index.d.ts +11 -0
  76. package/dist/validators/index.js +27 -0
  77. package/dist/validators/item.d.ts +14 -0
  78. package/dist/validators/item.js +38 -0
  79. package/dist/validators/rawInfo.d.ts +6 -0
  80. package/dist/validators/rawInfo.js +31 -0
  81. package/dist/validators/world.d.ts +5 -0
  82. package/dist/validators/world.js +65 -0
  83. package/package.json +48 -0
package/dist/client.js ADDED
@@ -0,0 +1,462 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebApiError = exports.WebApiClient = void 0;
4
+ function buildQuery(params) {
5
+ const record = params;
6
+ const qs = Object.entries(record)
7
+ .filter(([, v]) => v !== undefined)
8
+ .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
9
+ .join("&");
10
+ return qs ? `?${qs}` : "";
11
+ }
12
+ class WebApiClient {
13
+ constructor(options) {
14
+ this.baseUrl = options.baseUrl.replace(/\/$/, "");
15
+ this.authToken = options.authToken;
16
+ const globalFetch = typeof globalThis !== "undefined" ? globalThis.fetch : undefined;
17
+ this.fetchImpl = options.fetch || globalFetch || undefined;
18
+ if (!this.fetchImpl) {
19
+ throw new Error("No fetch implementation provided. Pass one via options.fetch or run in an environment with global fetch.");
20
+ }
21
+ }
22
+ async request(path, init) {
23
+ const req = new Request(`${this.baseUrl}${path}`, init);
24
+ if (this.authToken) {
25
+ req.headers.set("Authorization", this.authToken);
26
+ }
27
+ const res = await this.fetchImpl(req);
28
+ const contentType = res.headers.get("content-type") || "";
29
+ if (!res.ok) {
30
+ if (contentType.includes("application/json")) {
31
+ const body = await res.json().catch(() => ({ message: res.statusText }));
32
+ throw new WebApiError(body.message || res.statusText, res.status, body);
33
+ }
34
+ throw new WebApiError(res.statusText, res.status);
35
+ }
36
+ if (contentType.includes("application/json")) {
37
+ const body = await res.json();
38
+ if (body.success) {
39
+ return body.data;
40
+ }
41
+ else {
42
+ throw new WebApiError(body.message, res.status, body);
43
+ }
44
+ }
45
+ return res.arrayBuffer();
46
+ }
47
+ // ========== Root / Status ==========
48
+ /**
49
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/RootHandler.java)
50
+ * @returns 使用 {@link RootInfoSchema} 验证
51
+ */
52
+ getRoot() {
53
+ return this.request("/version");
54
+ }
55
+ // ========== TPS / Performance ==========
56
+ /**
57
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/TPSHandler.java)
58
+ * @returns 使用 `Joi.object().pattern(Joi.string(), {@link TPSInfoSchema})` 验证
59
+ */
60
+ getTPS() {
61
+ return this.request("/tps");
62
+ }
63
+ /**
64
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ProfilerHandler.java)
65
+ * @returns 使用 {@link ProfilerDataSchema} 验证
66
+ */
67
+ getProfiler() {
68
+ return this.request("/profiler");
69
+ }
70
+ /**
71
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/LagAnalyzerHandler.java)
72
+ * @returns 使用 {@link LagAnalyzerDataSchema} 验证
73
+ */
74
+ getLagAnalyzer() {
75
+ return this.request("/lag-analyzer");
76
+ }
77
+ // ========== World ==========
78
+ /**
79
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/WorldInfoHandler.java)
80
+ * @returns 使用 `Joi.object().pattern(Joi.string(), {@link WorldInfoDataSchema})` 验证
81
+ */
82
+ getWorldInfo() {
83
+ return this.request("/WorldInfo");
84
+ }
85
+ // ========== Blocks ==========
86
+ /**
87
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/block/BlocksHandler.java)
88
+ * @returns 使用 `Joi.array().items(`{@link BlockSchema}`)` 验证
89
+ */
90
+ getBlocks() {
91
+ return this.request("/blocks");
92
+ }
93
+ /**
94
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/block/BlockHandler.java)
95
+ * @returns 使用 {@link BlockDetailSchema} 验证
96
+ */
97
+ getBlock(params) {
98
+ return this.request(`/block${buildQuery(params)}`);
99
+ }
100
+ /**
101
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/block/SetBlockHandler.java)
102
+ * @param body 使用 {@link SetBlockBodySchema} 验证
103
+ * @returns 使用 {@link SetBlockResultSchema} 验证
104
+ */
105
+ setBlock(params, body) {
106
+ return this.request(`/setblock${buildQuery(params)}`, {
107
+ method: "POST",
108
+ headers: { "Content-Type": "application/json" },
109
+ body: JSON.stringify(body),
110
+ });
111
+ }
112
+ /**
113
+ * 提交批量 setblock 任务到慢队列,异步执行。
114
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/block/BatchSetBlockHandler.java)
115
+ * @param tasks 使用 `Joi.array().items(`{@link BatchSetBlockTaskSchema} ) 验证
116
+ * @returns 使用 {@link BatchSetBlockSubmitResultSchema} 验证
117
+ */
118
+ batchSetBlock(tasks) {
119
+ return this.request("/batchsetblock", {
120
+ method: "POST",
121
+ headers: { "Content-Type": "application/json" },
122
+ body: JSON.stringify(tasks),
123
+ });
124
+ }
125
+ /**
126
+ * 查询批量 setblock 任务执行结果。
127
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/block/BatchSetBlockHandler.java)
128
+ * @returns 使用 {@link BatchSetBlockJobResultSchema} 验证
129
+ */
130
+ getBatchSetBlockJob(params) {
131
+ return this.request(`/batchsetblock${buildQuery(params)}`);
132
+ }
133
+ /**
134
+ * 轮询等待批量 setblock 任务完成。
135
+ * @param jobId 任务 ID(由 batchSetBlock 返回)
136
+ * @param intervalMs 轮询间隔 (ms),默认 100
137
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/block/BatchSetBlockHandler.java)
138
+ * @returns 使用 {@link BatchSetBlockJobResultSchema} 验证
139
+ */
140
+ async waitForBatchSetBlockJob(jobId, intervalMs = 100) {
141
+ while (true) {
142
+ const job = await this.getBatchSetBlockJob({ id: jobId });
143
+ if (job.status === "completed")
144
+ return job;
145
+ await new Promise(r => setTimeout(r, intervalMs));
146
+ }
147
+ }
148
+ /**
149
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/block/FMPHandler.java)
150
+ * @returns 使用 `Joi.array().items(`{@link FMPPartSchema}`)` 验证
151
+ */
152
+ getBlockFMP(params) {
153
+ return this.request(`/block/fmp${buildQuery(params)}`);
154
+ }
155
+ /**
156
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/block/BlockTileHandler.java)
157
+ * @returns 二进制数据,无 JSON Schema
158
+ */
159
+ getBlockTile(params) {
160
+ return this.request(`/block/tile${buildQuery(params)}`);
161
+ }
162
+ // ========== Items ==========
163
+ /**
164
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/item/ItemsHandler.java)
165
+ * @returns 使用 `Joi.array().items(`{@link ItemSchema}`)` 验证
166
+ */
167
+ getItems() {
168
+ return this.request("/items");
169
+ }
170
+ /**
171
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/item/ItemHandler.java)
172
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/item/ItemStaticHandler.java)
173
+ * @returns 使用 {@link ItemDetailSchema} 验证
174
+ */
175
+ getItem(params) {
176
+ return this.request(`/item${buildQuery(params)}`);
177
+ }
178
+ /**
179
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/item/ItemIconHandler.java)
180
+ * @param params.id 物品 ID(对应 ItemStack 的 id)
181
+ * @param params.damage 物品损伤值/元数据(可选,默认 0)
182
+ * @param params.tag Base64 编码的 NBTTagCompound(可选)
183
+ * @returns 二进制 PNG 图片数据 (ArrayBuffer)
184
+ */
185
+ getItemIcon(params) {
186
+ return this.request(`/item/icon${buildQuery(params)}`);
187
+ }
188
+ /**
189
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/item/AEHandler.java)
190
+ * @returns 使用 {@link AEItemDefinitionsSchema} 验证
191
+ */
192
+ getAEItems() {
193
+ return this.request("/items/ae");
194
+ }
195
+ // ========== Fluids ==========
196
+ /**
197
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/fluid/FluidsHandler.java)
198
+ * @returns 使用 `Joi.array().items(`{@link FluidSchema}`)` 验证
199
+ */
200
+ getFluids() {
201
+ return this.request("/fluids");
202
+ }
203
+ /**
204
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/fluid/FluidContainersHandler.java)
205
+ * @returns 使用 `Joi.array().items(`{@link FluidContainerSchema}`)` 验证
206
+ */
207
+ getFluidContainers() {
208
+ return this.request("/fluidContainers");
209
+ }
210
+ /**
211
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/fluid/FluidIconHandler.java)
212
+ * @param params.id 流体 ID(对应 Fluid 的 id)
213
+ * @param params.name 流体名称(对应 Fluid 的 name)
214
+ * @returns 二进制 PNG 图片数据 (ArrayBuffer)
215
+ */
216
+ getFluidIcon(params) {
217
+ return this.request(`/fluid/icon${buildQuery(params)}`);
218
+ }
219
+ // ========== Entities ==========
220
+ /**
221
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/entity/EntitiesHandler.java)
222
+ * @returns 使用 `Joi.object().pattern(Joi.string(),`{@link EntitiesByDimensionSchema}`)` 验证
223
+ *
224
+ * 其中实体为 {@link EntitySummarySchema} 精简结构
225
+ */
226
+ getEntities() {
227
+ return this.request("/entities");
228
+ }
229
+ /**
230
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/entity/EntityHandler.java)
231
+ * @returns 使用 {@link EntitySchema} 验证
232
+ */
233
+ getEntity(params) {
234
+ return this.request(`/entity${buildQuery(params)}`);
235
+ }
236
+ // ========== Chunks ==========
237
+ /**
238
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/chunk/ChunksHandler.java)
239
+ * @returns 使用 `Joi.object().pattern(Joi.string(),`{@link ChunksByDimensionSchema}`)` 验证
240
+ */
241
+ getChunks() {
242
+ return this.request("/chunks");
243
+ }
244
+ /**
245
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/chunk/ChunkHandler.java)
246
+ * @returns 使用 {@link ChunkWithDimensionSchema} 验证
247
+ */
248
+ getChunk(params) {
249
+ return this.request(`/chunk${buildQuery(params)}`);
250
+ }
251
+ /**
252
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/chunk/ChunkMapHandler.java)
253
+ * @returns JSON 模式使用 `Joi.array().items(Joi.array().items(`{@link ChunkMapCellSchema}`)` 验证;raw 模式为 ArrayBuffer
254
+ */
255
+ getChunkMap(params, raw) {
256
+ const q = buildQuery({
257
+ ...params,
258
+ raw: raw == true ? String(raw) : undefined,
259
+ });
260
+ return this.request(`/chunk/map${q}`);
261
+ }
262
+ /**
263
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/chunk/ChunkForceHandler.java)
264
+ * @returns 使用 {@link ChunkForceListSchema} 验证
265
+ */
266
+ getChunkForceList() {
267
+ return this.request("/chunk/force");
268
+ }
269
+ /**
270
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/chunk/ChunkForceHandler.java)
271
+ * @returns 使用 {@link ChunkLoadResultSchema} 验证
272
+ */
273
+ loadChunk(params) {
274
+ return this.request(`/chunk/force${buildQuery({ action: "load", ...params })}`, {
275
+ method: "POST",
276
+ });
277
+ }
278
+ /**
279
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/chunk/ChunkForceHandler.java)
280
+ * @returns 使用 {@link ChunkLoadResultSchema} 验证
281
+ */
282
+ unloadChunk(params) {
283
+ return this.request(`/chunk/force${buildQuery({ action: "unload", ...params })}`, {
284
+ method: "POST",
285
+ });
286
+ }
287
+ // ========== GT5 ==========
288
+ /**
289
+ * 查询单个 GT5 机器信息。
290
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/gt5/GT5BaseHandler.java)
291
+ * @returns 使用 {@link GT5MachineInfoSchema} 验证
292
+ */
293
+ getGT5Machine(params) {
294
+ return this.request(`/gt5${buildQuery(params)}`);
295
+ }
296
+ /**
297
+ * 提交批量 GT5 机器查询任务。
298
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/gt5/GT5BatchHandler.java)
299
+ * @param machines 使用 `Joi.array().items(`{@link GT5BatchMachineCoordSchema}`)` 验证
300
+ * @returns 使用 {@link GT5BatchSubmitResultSchema} 验证
301
+ */
302
+ submitGT5Batch(machines) {
303
+ return this.request("/gt5/batch", {
304
+ method: "POST",
305
+ headers: { "Content-Type": "application/json" },
306
+ body: JSON.stringify(machines),
307
+ });
308
+ }
309
+ /**
310
+ * 查询批量 GT5 机器任务状态。
311
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/gt5/GT5BatchHandler.java)
312
+ * @returns 使用 {@link GT5BatchJobResultSchema} 验证
313
+ */
314
+ getGT5BatchJob(params) {
315
+ return this.request(`/gt5/batch${buildQuery(params)}`);
316
+ }
317
+ /**
318
+ * 重新执行已有的批量 GT5 机器查询任务。
319
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/gt5/GT5BatchHandler.java)
320
+ * @returns 使用 {@link GT5BatchRerunResultSchema} 验证
321
+ */
322
+ rerunGT5Batch(params) {
323
+ return this.request(`/gt5/batch${buildQuery(params)}`, {
324
+ method: "PATCH",
325
+ });
326
+ }
327
+ /**
328
+ * 轮询等待批量 GT5 机器任务完成。
329
+ * @param jobId 任务 ID(由 submitGT5Batch 返回)
330
+ * @param intervalMs 轮询间隔 (ms),默认 100
331
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/gt5/GT5BatchHandler.java)
332
+ * @returns 使用 {@link GT5BatchJobResultSchema} 验证
333
+ */
334
+ async waitForGT5BatchJob(jobId, intervalMs = 100) {
335
+ while (true) {
336
+ const job = await this.getGT5BatchJob({ id: jobId });
337
+ if (job.status === "completed")
338
+ return job;
339
+ await new Promise(r => setTimeout(r, intervalMs));
340
+ }
341
+ }
342
+ /**
343
+ * 提交区块扫描任务,异步扫描指定区块内所有 GT5 机器。
344
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/gt5/GT5ChunkScanHandler.java)
345
+ * @returns 使用 {@link GT5ScanSubmitResultSchema} 验证
346
+ */
347
+ submitGT5ChunkScan(params) {
348
+ return this.request(`/gt5/scan${buildQuery(params)}`, {
349
+ method: "POST",
350
+ });
351
+ }
352
+ /**
353
+ * 查询区块扫描任务状态。
354
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/gt5/GT5ChunkScanHandler.java)
355
+ * @returns 使用 {@link GT5ScanJobResultSchema} 验证
356
+ */
357
+ getGT5ScanJob(params) {
358
+ return this.request(`/gt5/scan${buildQuery(params)}`);
359
+ }
360
+ /**
361
+ * 轮询等待区块扫描任务完成。
362
+ * @param jobId 任务 ID(由 submitGT5ChunkScan 返回)
363
+ * @param intervalMs 轮询间隔 (ms),默认 100
364
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/gt5/GT5ChunkScanHandler.java)
365
+ * @returns 使用 {@link GT5ScanJobResultSchema} 验证
366
+ */
367
+ async waitForGT5ScanJob(jobId, intervalMs = 100) {
368
+ while (true) {
369
+ const job = await this.getGT5ScanJob({ id: jobId });
370
+ if (job.status === "completed")
371
+ return job;
372
+ await new Promise(r => setTimeout(r, intervalMs));
373
+ }
374
+ }
375
+ // ========== AE2 ==========
376
+ /**
377
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AEBaseHandler.java)
378
+ * @returns 使用 {@link AEHitResultSchema} 验证
379
+ */
380
+ aeHit(params) {
381
+ return this.request(`/ae${buildQuery(params)}`);
382
+ }
383
+ /**
384
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AENodesHandler.java)
385
+ * @returns 使用 `Joi.array().items(`{@link AENodeSchema}`)` 验证
386
+ */
387
+ aeNodes(params) {
388
+ return this.request(`/ae/nodes${buildQuery(params)}`);
389
+ }
390
+ /**
391
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AECPUHandler.java)
392
+ * @returns 使用 `Joi.array().items(`{@link AECPUSchema}`)` 验证
393
+ */
394
+ aeCPUs(params) {
395
+ return this.request(`/ae/cpu${buildQuery(params)}`);
396
+ }
397
+ /**
398
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AEMEHandler.java)
399
+ * @returns 使用 `Joi.array().items(`{@link AE2PatternSchema}`.append({ slot: Joi.number().required(), direction: Joi.string().optional() }))` 验证
400
+ */
401
+ aeME(params) {
402
+ return this.request(`/ae/me${buildQuery(params)}`);
403
+ }
404
+ /**
405
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AEMEsHandler.java)
406
+ * @returns 使用 `Joi.array().items(`{@link AEMEInterfaceSchema}`)` 验证
407
+ */
408
+ aeMEs(params) {
409
+ if (params.load || params.world) {
410
+ params.pattern = true;
411
+ }
412
+ return this.request(`/ae/mes${buildQuery(params)}`);
413
+ }
414
+ /**
415
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AEMEsupportHandler.java)
416
+ * @returns 字符串数组,无专用 Schema
417
+ */
418
+ aeMESupport() {
419
+ return this.request("/ae/me/support");
420
+ }
421
+ /**
422
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AEItemHandler.java)
423
+ * @returns 使用 {@link AEItemsResultSchema} 验证
424
+ */
425
+ aeItems(params) {
426
+ return this.request(`/ae/item${buildQuery(params)}`);
427
+ }
428
+ /**
429
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AECPUTaskHandler.java)
430
+ * @param body 使用 {@link AECraftingTaskBodySchema} 验证
431
+ * @returns 使用 {@link AECraftingTaskResultSchema} 验证
432
+ */
433
+ aeCraft(params, body) {
434
+ return this.request(`/ae/cpu/task${buildQuery(params)}`, {
435
+ method: "POST",
436
+ headers: { "Content-Type": "application/json" },
437
+ body: JSON.stringify(body),
438
+ });
439
+ }
440
+ /**
441
+ * @java [java](../../../src/main/java/love/shirokasoke/webapi/webserver/handlers/ae2/AECPUCancelHandler.java)
442
+ * @param body 使用 {@link AECPUCancelBodySchema} 验证
443
+ * @returns 使用 {@link AECPUCancelResultSchema} 验证
444
+ */
445
+ aeCancel(params, body) {
446
+ return this.request(`/ae/cpu/cancel${buildQuery(params)}`, {
447
+ method: "DELETE",
448
+ headers: { "Content-Type": "application/json" },
449
+ body: JSON.stringify(body),
450
+ });
451
+ }
452
+ }
453
+ exports.WebApiClient = WebApiClient;
454
+ class WebApiError extends Error {
455
+ constructor(message, status, body) {
456
+ super(message);
457
+ this.name = "WebApiError";
458
+ this.status = status;
459
+ this.body = body;
460
+ }
461
+ }
462
+ exports.WebApiError = WebApiError;