@colyseus/sdk 0.17.22 → 0.17.24
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/build/3rd_party/discord.cjs +1 -1
- package/build/3rd_party/discord.mjs +1 -1
- package/build/Auth.cjs +1 -1
- package/build/Auth.mjs +1 -1
- package/build/Client.cjs +1 -1
- package/build/Client.mjs +1 -1
- package/build/Connection.cjs +1 -1
- package/build/Connection.mjs +1 -1
- package/build/HTTP.cjs +3 -1
- package/build/HTTP.cjs.map +1 -1
- package/build/HTTP.d.ts +15 -10
- package/build/HTTP.mjs +3 -1
- package/build/HTTP.mjs.map +1 -1
- package/build/Room.cjs +1 -1
- package/build/Room.mjs +1 -1
- package/build/Storage.cjs +1 -1
- package/build/Storage.mjs +1 -1
- package/build/core/nanoevents.cjs +1 -1
- package/build/core/nanoevents.mjs +1 -1
- package/build/core/signal.cjs +1 -1
- package/build/core/signal.mjs +1 -1
- package/build/core/utils.cjs +1 -1
- package/build/core/utils.mjs +1 -1
- package/build/debug.cjs +1 -1
- package/build/debug.mjs +1 -1
- package/build/errors/Errors.cjs +1 -1
- package/build/errors/Errors.mjs +1 -1
- package/build/index.cjs +1 -1
- package/build/index.mjs +1 -1
- package/build/legacy.cjs +1 -1
- package/build/legacy.mjs +1 -1
- package/build/serializer/NoneSerializer.cjs +1 -1
- package/build/serializer/NoneSerializer.mjs +1 -1
- package/build/serializer/SchemaSerializer.cjs +1 -1
- package/build/serializer/SchemaSerializer.mjs +1 -1
- package/build/serializer/Serializer.cjs +1 -1
- package/build/serializer/Serializer.mjs +1 -1
- package/build/transport/H3Transport.cjs +1 -1
- package/build/transport/H3Transport.mjs +1 -1
- package/build/transport/WebSocketTransport.cjs +1 -1
- package/build/transport/WebSocketTransport.mjs +1 -1
- package/dist/colyseus-cocos-creator.js +3 -1
- package/dist/colyseus-cocos-creator.js.map +1 -1
- package/dist/colyseus.js +3 -1
- package/dist/colyseus.js.map +1 -1
- package/dist/debug.js +3 -1
- package/dist/debug.js.map +1 -1
- package/package.json +1 -1
- package/src/HTTP.ts +19 -10
package/package.json
CHANGED
package/src/HTTP.ts
CHANGED
|
@@ -243,11 +243,20 @@ type InferredAPI<R> = R extends { endpoints: Record<string, Endpoint> }
|
|
|
243
243
|
? WithoutServerOnly<R["endpoints"]>
|
|
244
244
|
: WithoutServerOnly<R & Record<string, Endpoint>>;
|
|
245
245
|
|
|
246
|
+
// Helper type to resolve return type, returning 'any' when R is untyped
|
|
247
|
+
type InferReturnType<R, OPT, K extends keyof OPT> =
|
|
248
|
+
IsAnyOrAnyIndexed<R> extends true
|
|
249
|
+
? any
|
|
250
|
+
: Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>;
|
|
251
|
+
|
|
246
252
|
export class HTTP<R extends Router | Router["endpoints"]> {
|
|
247
253
|
public authToken: string | undefined;
|
|
248
254
|
public options: FetchRequestOptions;
|
|
249
255
|
|
|
250
256
|
private sdk: ColyseusSDK;
|
|
257
|
+
|
|
258
|
+
// alias "del()" to "delete()"
|
|
259
|
+
public del = this.delete;
|
|
251
260
|
|
|
252
261
|
constructor(sdk: ColyseusSDK, baseOptions: FetchRequestOptions) {
|
|
253
262
|
this.sdk = sdk;
|
|
@@ -282,7 +291,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
282
291
|
? FetchRequestOptions<any, any, any>
|
|
283
292
|
: WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
|
|
284
293
|
): Promise<
|
|
285
|
-
FetchResponse<
|
|
294
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
286
295
|
>;
|
|
287
296
|
|
|
288
297
|
// Overload for endpoints WITHOUT required fields (permissive when R is 'any')
|
|
@@ -297,7 +306,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
297
306
|
? FetchRequestOptions<any, any, any>
|
|
298
307
|
: FetchRequestOptions<C["body"], C["query"], C["params"]>
|
|
299
308
|
): Promise<
|
|
300
|
-
FetchResponse<
|
|
309
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
301
310
|
>;
|
|
302
311
|
|
|
303
312
|
get(path: any, options?: any): Promise<any> {
|
|
@@ -316,7 +325,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
316
325
|
? FetchRequestOptions<any, any, any>
|
|
317
326
|
: WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>)
|
|
318
327
|
): Promise<
|
|
319
|
-
FetchResponse<
|
|
328
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
320
329
|
>;
|
|
321
330
|
|
|
322
331
|
// Overload for endpoints WITHOUT required fields (permissive when R is 'any')
|
|
@@ -331,7 +340,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
331
340
|
? FetchRequestOptions<any, any, any>
|
|
332
341
|
: FetchRequestOptions<C["body"], C["query"], C["params"]>)
|
|
333
342
|
): Promise<
|
|
334
|
-
FetchResponse<
|
|
343
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
335
344
|
>;
|
|
336
345
|
|
|
337
346
|
post(path: any, options?: any): Promise<any> {
|
|
@@ -350,7 +359,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
350
359
|
? FetchRequestOptions<any, any, any>
|
|
351
360
|
: WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
|
|
352
361
|
): Promise<
|
|
353
|
-
FetchResponse<
|
|
362
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
354
363
|
>;
|
|
355
364
|
|
|
356
365
|
// Overload for endpoints WITHOUT required fields (permissive when R is 'any')
|
|
@@ -365,7 +374,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
365
374
|
? FetchRequestOptions<any, any, any>
|
|
366
375
|
: FetchRequestOptions<C["body"], C["query"], C["params"]>
|
|
367
376
|
): Promise<
|
|
368
|
-
FetchResponse<
|
|
377
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
369
378
|
>;
|
|
370
379
|
|
|
371
380
|
delete(path: any, options?: any): Promise<any> {
|
|
@@ -384,7 +393,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
384
393
|
? FetchRequestOptions<any, any, any>
|
|
385
394
|
: WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
|
|
386
395
|
): Promise<
|
|
387
|
-
FetchResponse<
|
|
396
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
388
397
|
>;
|
|
389
398
|
|
|
390
399
|
// Overload for endpoints WITHOUT required fields (permissive when R is 'any')
|
|
@@ -399,7 +408,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
399
408
|
? FetchRequestOptions<any, any, any>
|
|
400
409
|
: FetchRequestOptions<C["body"], C["query"], C["params"]>
|
|
401
410
|
): Promise<
|
|
402
|
-
FetchResponse<
|
|
411
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
403
412
|
>;
|
|
404
413
|
|
|
405
414
|
patch(path: any, options?: any): Promise<any> {
|
|
@@ -418,7 +427,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
418
427
|
? FetchRequestOptions<any, any, any>
|
|
419
428
|
: WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
|
|
420
429
|
): Promise<
|
|
421
|
-
FetchResponse<
|
|
430
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
422
431
|
>;
|
|
423
432
|
|
|
424
433
|
// Overload for endpoints WITHOUT required fields (permissive when R is 'any')
|
|
@@ -433,7 +442,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
|
|
|
433
442
|
? FetchRequestOptions<any, any, any>
|
|
434
443
|
: FetchRequestOptions<C["body"], C["query"], C["params"]>
|
|
435
444
|
): Promise<
|
|
436
|
-
FetchResponse<
|
|
445
|
+
FetchResponse<InferReturnType<R, OPT, K>>
|
|
437
446
|
>;
|
|
438
447
|
|
|
439
448
|
put(path: any, options?: any): Promise<any> {
|