@seayoo-io/combo-sdk-node 0.3.0 → 0.3.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/README.md +11 -9
- package/dist/const.d.ts +10 -8
- package/dist/index.cjs +3 -2
- package/dist/index.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -379,7 +379,7 @@ function gmCommandHandler(command, args, requestId, version) {
|
|
|
379
379
|
// 参数 args 由协议定义,在使用前需要做严格的格式和逻辑校验
|
|
380
380
|
// 返回值需要根据协议定义进行响应,通常是一个包含了多个字段的 object
|
|
381
381
|
return await execSomeCommand(args);
|
|
382
|
-
|
|
382
|
+
case "OtherCmdName":
|
|
383
383
|
// 抛出自定义错误有三种方式:
|
|
384
384
|
// 1. 返回一个 Error 对象,最终响应以 500(internalServerError)作为 http status
|
|
385
385
|
return new Error("自定义错误信息")
|
|
@@ -390,15 +390,15 @@ function gmCommandHandler(command, args, requestId, version) {
|
|
|
390
390
|
throw new Error("some unknown error")
|
|
391
391
|
...
|
|
392
392
|
default: // 不识别的指令进行返回
|
|
393
|
-
|
|
393
|
+
return { error: GMError.InvalidCommand, message: "不识别的指令"+ command }
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
/** GM 预设错误类型枚举 */
|
|
398
398
|
const enum GMError {
|
|
399
|
-
/**
|
|
399
|
+
/** 请求中的 HTTP method 不正确,没有按照预期使用 POST。*/
|
|
400
400
|
InvalidHttpMethod = "invalid_http_method",
|
|
401
|
-
/**
|
|
401
|
+
/** 请求中的 Content-Type 不是 application/json。*/
|
|
402
402
|
InvalidContentType = "invalid_content_type",
|
|
403
403
|
/** 对 HTTP 请求的签名验证不通过。这意味着 HTTP 请求不可信。 */
|
|
404
404
|
InvalidSignature = "invalid_signature",
|
|
@@ -406,18 +406,20 @@ const enum GMError {
|
|
|
406
406
|
InvalidRequest = "invalid_request",
|
|
407
407
|
/** 游戏侧不认识请求中的 GM 命令。 */
|
|
408
408
|
InvalidCommand = "invalid_command",
|
|
409
|
-
/** GM
|
|
409
|
+
/** GM 命令发送频率过高,被游戏侧限流,命令未被处理。 */
|
|
410
|
+
ThrottlingError = "throttling_error",
|
|
411
|
+
/** GM 命令的参数不正确。例如,参数缺少必要的字段,或参数的字段类型不正确。 */
|
|
410
412
|
InvalidArgs = "invalid_args",
|
|
411
413
|
|
|
414
|
+
/** 游戏当前处于停服维护状态,无法处理收到的 GM 命令。*/
|
|
415
|
+
MaintenanceError = "maintenance_error",
|
|
412
416
|
/** 网络通信错误。 */
|
|
413
417
|
NetworkError = "network_error",
|
|
414
|
-
/**
|
|
418
|
+
/** 数据库操作异常导致 GM 命令执行失败。 */
|
|
415
419
|
DatabaseError = "database_error",
|
|
416
420
|
/** GM 命令处理超时。 */
|
|
417
421
|
TimeoutError = "timeout_error",
|
|
418
|
-
/** GM
|
|
419
|
-
ThrottleError = "throttle_error",
|
|
420
|
-
/** 处理 GM 命令时内部出错。可作为通用错误类型。*/
|
|
422
|
+
/** 处理 GM 命令时内部出错。可作为兜底的通用错误类型。*/
|
|
421
423
|
InternalError = "internal_error",
|
|
422
424
|
}
|
|
423
425
|
|
package/dist/const.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** SDK 名称 */
|
|
2
2
|
export declare const SDKName = "combo-sdk-node";
|
|
3
3
|
/** SDK 版本,在编译前会被动态替换 */
|
|
4
|
-
export declare const SDKVersion = "0.3.
|
|
4
|
+
export declare const SDKVersion = "0.3.2";
|
|
5
5
|
/**
|
|
6
6
|
* 世游支持的服务端点列表
|
|
7
7
|
*/
|
|
@@ -43,9 +43,9 @@ export declare enum IdP {
|
|
|
43
43
|
}
|
|
44
44
|
/** GM 错误类型枚举 */
|
|
45
45
|
export declare const enum GMError {
|
|
46
|
-
/**
|
|
46
|
+
/** 请求中的 HTTP method 不正确,没有按照预期使用 POST。*/
|
|
47
47
|
InvalidHttpMethod = "invalid_http_method",
|
|
48
|
-
/**
|
|
48
|
+
/** 请求中的 Content-Type 不是 application/json。*/
|
|
49
49
|
InvalidContentType = "invalid_content_type",
|
|
50
50
|
/** 对 HTTP 请求的签名验证不通过。这意味着 HTTP 请求不可信。 */
|
|
51
51
|
InvalidSignature = "invalid_signature",
|
|
@@ -53,17 +53,19 @@ export declare const enum GMError {
|
|
|
53
53
|
InvalidRequest = "invalid_request",
|
|
54
54
|
/** 游戏侧不认识请求中的 GM 命令。 */
|
|
55
55
|
InvalidCommand = "invalid_command",
|
|
56
|
-
/** GM
|
|
56
|
+
/** GM 命令发送频率过高,被游戏侧限流,命令未被处理。 */
|
|
57
|
+
ThrottlingError = "throttling_error",
|
|
58
|
+
/** GM 命令的参数不正确。例如,参数缺少必要的字段,或参数的字段类型不正确。 */
|
|
57
59
|
InvalidArgs = "invalid_args",
|
|
60
|
+
/** 游戏当前处于停服维护状态,无法处理收到的 GM 命令。*/
|
|
61
|
+
MaintenanceError = "maintenance_error",
|
|
58
62
|
/** 网络通信错误。 */
|
|
59
63
|
NetworkError = "network_error",
|
|
60
|
-
/**
|
|
64
|
+
/** 数据库操作异常导致 GM 命令执行失败。 */
|
|
61
65
|
DatabaseError = "database_error",
|
|
62
66
|
/** GM 命令处理超时。 */
|
|
63
67
|
TimeoutError = "timeout_error",
|
|
64
|
-
/** GM
|
|
65
|
-
ThrottleError = "throttle_error",
|
|
66
|
-
/** 处理 GM 命令时内部出错。可作为通用错误类型。*/
|
|
68
|
+
/** 处理 GM 命令时内部出错。可作为兜底的通用错误类型。*/
|
|
67
69
|
InternalError = "internal_error"
|
|
68
70
|
}
|
|
69
71
|
export declare const enum HttpStatus {
|
package/dist/index.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
|
|
|
12
12
|
/** SDK 名称 */
|
|
13
13
|
const SDKName = "combo-sdk-node";
|
|
14
14
|
/** SDK 版本,在编译前会被动态替换 */
|
|
15
|
-
const SDKVersion = "0.3.
|
|
15
|
+
const SDKVersion = "0.3.2";
|
|
16
16
|
/**
|
|
17
17
|
* 世游支持的服务端点列表
|
|
18
18
|
*/
|
|
@@ -1335,7 +1335,8 @@ const error2httpStatus = {
|
|
|
1335
1335
|
["network_error" /* GMError.NetworkError */]: 500 /* HttpStatus.InternalServerError */,
|
|
1336
1336
|
["database_error" /* GMError.DatabaseError */]: 500 /* HttpStatus.InternalServerError */,
|
|
1337
1337
|
["timeout_error" /* GMError.TimeoutError */]: 500 /* HttpStatus.InternalServerError */,
|
|
1338
|
-
["
|
|
1338
|
+
["maintenance_error" /* GMError.MaintenanceError */]: 503 /* HttpStatus.ServiceUnavailable */,
|
|
1339
|
+
["throttling_error" /* GMError.ThrottlingError */]: 429 /* HttpStatus.TooManyRequests */,
|
|
1339
1340
|
["internal_error" /* GMError.InternalError */]: 500 /* HttpStatus.InternalServerError */
|
|
1340
1341
|
};
|
|
1341
1342
|
/**
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { verify } from 'jsonwebtoken';
|
|
|
7
7
|
/** SDK 名称 */
|
|
8
8
|
const SDKName = "combo-sdk-node";
|
|
9
9
|
/** SDK 版本,在编译前会被动态替换 */
|
|
10
|
-
const SDKVersion = "0.3.
|
|
10
|
+
const SDKVersion = "0.3.2";
|
|
11
11
|
/**
|
|
12
12
|
* 世游支持的服务端点列表
|
|
13
13
|
*/
|
|
@@ -1330,7 +1330,8 @@ const error2httpStatus = {
|
|
|
1330
1330
|
["network_error" /* GMError.NetworkError */]: 500 /* HttpStatus.InternalServerError */,
|
|
1331
1331
|
["database_error" /* GMError.DatabaseError */]: 500 /* HttpStatus.InternalServerError */,
|
|
1332
1332
|
["timeout_error" /* GMError.TimeoutError */]: 500 /* HttpStatus.InternalServerError */,
|
|
1333
|
-
["
|
|
1333
|
+
["maintenance_error" /* GMError.MaintenanceError */]: 503 /* HttpStatus.ServiceUnavailable */,
|
|
1334
|
+
["throttling_error" /* GMError.ThrottlingError */]: 429 /* HttpStatus.TooManyRequests */,
|
|
1334
1335
|
["internal_error" /* GMError.InternalError */]: 500 /* HttpStatus.InternalServerError */
|
|
1335
1336
|
};
|
|
1336
1337
|
/**
|