From d5516d43fa0f14c27383cfc7389e1bca8016850d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Fri, 2 Oct 2026 02:42:26 +0800 Subject: [PATCH] =?UTF-8?q?AGC=E8=AE=A4=E8=AF=81=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E7=94=9F=E6=88=90ts-rs=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ClientAuthError 联合收敛为类别变体 + 类型化 reason,无字段变体仍是 { type } - 新增 AuthNetworkFailure/AuthNetworkReason/AuthResponseInvalid/AuthResponseInvalidReason/ServerAddressRejected/ServerAddressReason - 删除拍平变体后不再生成的 AuthResponseServerRejected 载荷文件 --- .../services/generated/AuthNetworkFailure.ts | 7 +++++++ .../services/generated/AuthNetworkReason.ts | 6 ++++++ .../services/generated/AuthResponseInvalid.ts | 13 ++++++++++++ .../generated/AuthResponseInvalidReason.ts | 11 ++++++++++ .../generated/AuthResponseServerRejected.ts | 6 ------ .../src/services/generated/ClientAuthError.ts | 21 ++++++------------- .../services/generated/ServerAddressReason.ts | 13 ++++++++++++ .../generated/ServerAddressRejected.ts | 7 +++++++ 8 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 apps/ai-game-creator-shell/src/services/generated/AuthNetworkFailure.ts create mode 100644 apps/ai-game-creator-shell/src/services/generated/AuthNetworkReason.ts create mode 100644 apps/ai-game-creator-shell/src/services/generated/AuthResponseInvalid.ts create mode 100644 apps/ai-game-creator-shell/src/services/generated/AuthResponseInvalidReason.ts delete mode 100644 apps/ai-game-creator-shell/src/services/generated/AuthResponseServerRejected.ts create mode 100644 apps/ai-game-creator-shell/src/services/generated/ServerAddressReason.ts create mode 100644 apps/ai-game-creator-shell/src/services/generated/ServerAddressRejected.ts diff --git a/apps/ai-game-creator-shell/src/services/generated/AuthNetworkFailure.ts b/apps/ai-game-creator-shell/src/services/generated/AuthNetworkFailure.ts new file mode 100644 index 000000000..a852d6759 --- /dev/null +++ b/apps/ai-game-creator-shell/src/services/generated/AuthNetworkFailure.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AuthNetworkReason } from './AuthNetworkReason'; + +/** + * 连接登录服务的传输层失败原因。 + */ +export type AuthNetworkFailure = { reason: AuthNetworkReason }; diff --git a/apps/ai-game-creator-shell/src/services/generated/AuthNetworkReason.ts b/apps/ai-game-creator-shell/src/services/generated/AuthNetworkReason.ts new file mode 100644 index 000000000..73f2a73f9 --- /dev/null +++ b/apps/ai-game-creator-shell/src/services/generated/AuthNetworkReason.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * 连接登录服务失败的具体原因。 + */ +export type AuthNetworkReason = 'timeout' | 'unreachable'; diff --git a/apps/ai-game-creator-shell/src/services/generated/AuthResponseInvalid.ts b/apps/ai-game-creator-shell/src/services/generated/AuthResponseInvalid.ts new file mode 100644 index 000000000..3ecbcc333 --- /dev/null +++ b/apps/ai-game-creator-shell/src/services/generated/AuthResponseInvalid.ts @@ -0,0 +1,13 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AuthResponseInvalidReason } from './AuthResponseInvalidReason'; + +/** + * 登录响应契约破损的原因与服务端原文。 + */ +export type AuthResponseInvalid = { + reason: AuthResponseInvalidReason; + /** + * 只有 [`AuthResponseInvalidReason::ServerRejected`] 可能带服务端原文;其余是 `None`。 + */ + serverMessage: string | null; +}; diff --git a/apps/ai-game-creator-shell/src/services/generated/AuthResponseInvalidReason.ts b/apps/ai-game-creator-shell/src/services/generated/AuthResponseInvalidReason.ts new file mode 100644 index 000000000..cd7dd488f --- /dev/null +++ b/apps/ai-game-creator-shell/src/services/generated/AuthResponseInvalidReason.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * 登录响应契约破损的具体原因。 + */ +export type AuthResponseInvalidReason = + | 'notJson' + | 'invalidBody' + | 'missingRefreshCookie' + | 'missingUserIdentity' + | 'serverRejected'; diff --git a/apps/ai-game-creator-shell/src/services/generated/AuthResponseServerRejected.ts b/apps/ai-game-creator-shell/src/services/generated/AuthResponseServerRejected.ts deleted file mode 100644 index 15034b0f3..000000000 --- a/apps/ai-game-creator-shell/src/services/generated/AuthResponseServerRejected.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * 登录服务在响应体里显式拒绝时给的原文。 - */ -export type AuthResponseServerRejected = { serverMessage: string | null }; diff --git a/apps/ai-game-creator-shell/src/services/generated/ClientAuthError.ts b/apps/ai-game-creator-shell/src/services/generated/ClientAuthError.ts index 63ee7887e..6cb924232 100644 --- a/apps/ai-game-creator-shell/src/services/generated/ClientAuthError.ts +++ b/apps/ai-game-creator-shell/src/services/generated/ClientAuthError.ts @@ -1,24 +1,20 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { AuthResponseServerRejected } from './AuthResponseServerRejected'; +import type { AuthNetworkFailure } from './AuthNetworkFailure'; +import type { AuthResponseInvalid } from './AuthResponseInvalid'; import type { AuthServiceUnavailable } from './AuthServiceUnavailable'; import type { ClientSessionPersistFailed } from './ClientSessionPersistFailed'; import type { PasswordLoginRejected } from './PasswordLoginRejected'; import type { PhoneCodeLoginRejected } from './PhoneCodeLoginRejected'; import type { RuntimeSessionInstallFailed } from './RuntimeSessionInstallFailed'; import type { SendCodeRejected } from './SendCodeRejected'; +import type { ServerAddressRejected } from './ServerAddressRejected'; import type { UnexpectedRejection } from './UnexpectedRejection'; /** * 变体名就是线上的分流键(`type`),带载荷的变体持有同名载荷类型。 */ export type ClientAuthError = - | { type: 'serverAddressEmptyOrTooLong' } - | { type: 'serverAddressNotAUrl' } - | { type: 'serverAddressHasCredentials' } - | { type: 'serverAddressHasPathOrQueryOrFragment' } - | { type: 'serverAddressNotHttps' } - | { type: 'serverAddressUnsupportedScheme' } - | { type: 'serverAddressOutsideChannel' } + | ({ type: 'serverAddressRejected' } & ServerAddressRejected) | { type: 'phoneNumberInvalid' } | { type: 'passwordMissing' } | { type: 'loginCodeMissing' } @@ -30,15 +26,10 @@ export type ClientAuthError = | { type: 'smsCodeRejected' } | { type: 'sessionInvalidated' } | { type: 'permissionDenied' } - | { type: 'authNetworkTimeout' } - | { type: 'authNetworkUnreachable' } + | ({ type: 'authNetworkFailure' } & AuthNetworkFailure) | ({ type: 'authServiceUnavailable' } & AuthServiceUnavailable) | ({ type: 'unexpectedRejection' } & UnexpectedRejection) - | { type: 'authResponseNotJson' } - | { type: 'authResponseInvalidBody' } - | { type: 'authResponseMissingRefreshCookie' } - | { type: 'authResponseMissingUserIdentity' } - | ({ type: 'authResponseServerRejected' } & AuthResponseServerRejected) + | ({ type: 'authResponseInvalid' } & AuthResponseInvalid) | ({ type: 'clientSessionPersistFailed' } & ClientSessionPersistFailed) | ({ type: 'runtimeSessionInstallFailed' } & RuntimeSessionInstallFailed) | { type: 'authClientInitFailed' }; diff --git a/apps/ai-game-creator-shell/src/services/generated/ServerAddressReason.ts b/apps/ai-game-creator-shell/src/services/generated/ServerAddressReason.ts new file mode 100644 index 000000000..c60ebb82b --- /dev/null +++ b/apps/ai-game-creator-shell/src/services/generated/ServerAddressReason.ts @@ -0,0 +1,13 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * 服务地址校验失败的具体原因。 + */ +export type ServerAddressReason = + | 'emptyOrTooLong' + | 'notAUrl' + | 'hasCredentials' + | 'hasPathOrQueryOrFragment' + | 'notHttps' + | 'unsupportedScheme' + | 'outsideChannel'; diff --git a/apps/ai-game-creator-shell/src/services/generated/ServerAddressRejected.ts b/apps/ai-game-creator-shell/src/services/generated/ServerAddressRejected.ts new file mode 100644 index 000000000..fdcc96aa0 --- /dev/null +++ b/apps/ai-game-creator-shell/src/services/generated/ServerAddressRejected.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ServerAddressReason } from './ServerAddressReason'; + +/** + * 服务地址被拒的具体原因。 + */ +export type ServerAddressRejected = { reason: ServerAddressReason };