拆分大文件
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
||||
getAuthLoginOptions,
|
||||
getAuthRiskBlocks,
|
||||
getAuthSessions,
|
||||
getPublicAuthUserById,
|
||||
getCaptchaChallengeFromError,
|
||||
getCurrentAuthUser,
|
||||
liftAuthRiskBlock,
|
||||
@@ -92,6 +93,7 @@ describe('authService', () => {
|
||||
token: 'jwt-entry-token',
|
||||
user: {
|
||||
id: 'user_1',
|
||||
publicUserCode: 'SY-00000001',
|
||||
username: 'guest_abc123abc123',
|
||||
displayName: 'guest_abc123abc123',
|
||||
phoneNumberMasked: null,
|
||||
@@ -130,6 +132,7 @@ describe('authService', () => {
|
||||
token: 'jwt-auto-token',
|
||||
user: {
|
||||
id: 'user_saved',
|
||||
publicUserCode: 'SY-00000002',
|
||||
username: 'guest_saveduser01',
|
||||
displayName: 'guest_saveduser01',
|
||||
phoneNumberMasked: null,
|
||||
@@ -161,6 +164,7 @@ describe('authService', () => {
|
||||
token: 'jwt-auto-shared-token',
|
||||
user: {
|
||||
id: 'user_auto',
|
||||
publicUserCode: 'SY-00000003',
|
||||
username: 'guest_auto',
|
||||
displayName: 'guest_auto',
|
||||
phoneNumberMasked: null,
|
||||
@@ -236,6 +240,7 @@ describe('authService', () => {
|
||||
token: 'jwt-phone-token',
|
||||
user: {
|
||||
id: 'user_phone',
|
||||
publicUserCode: 'SY-00000004',
|
||||
username: '138****8000',
|
||||
displayName: '138****8000',
|
||||
phoneNumberMasked: '138****8000',
|
||||
@@ -271,6 +276,7 @@ describe('authService', () => {
|
||||
token: 'jwt-wechat-bind-token',
|
||||
user: {
|
||||
id: 'user_wechat',
|
||||
publicUserCode: 'SY-00000005',
|
||||
username: '138****8000',
|
||||
displayName: '138****8000',
|
||||
phoneNumberMasked: '138****8000',
|
||||
@@ -291,6 +297,7 @@ describe('authService', () => {
|
||||
apiClientMocks.requestJson.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user_phone',
|
||||
publicUserCode: 'SY-00000006',
|
||||
username: '139****9000',
|
||||
displayName: '139****9000',
|
||||
phoneNumberMasked: '139****9000',
|
||||
@@ -415,6 +422,35 @@ describe('authService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('loads public user summary by internal user id', async () => {
|
||||
apiClientMocks.requestJson.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user_00000001',
|
||||
publicUserCode: 'SY-00000001',
|
||||
displayName: '旅人一号',
|
||||
},
|
||||
});
|
||||
|
||||
const user = await getPublicAuthUserById(' user_00000001 ');
|
||||
|
||||
expect(user).toEqual({
|
||||
id: 'user_00000001',
|
||||
publicUserCode: 'SY-00000001',
|
||||
displayName: '旅人一号',
|
||||
});
|
||||
expect(apiClientMocks.requestJson).toHaveBeenCalledWith(
|
||||
'/api/auth/public-users/by-id/user_00000001',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
}),
|
||||
'读取用户信息失败',
|
||||
{
|
||||
skipAuth: true,
|
||||
skipRefresh: true,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('loads auth sessions from account center endpoint', async () => {
|
||||
apiClientMocks.requestJson.mockResolvedValue({
|
||||
sessions: [
|
||||
|
||||
@@ -16,6 +16,7 @@ import type {
|
||||
AuthRiskBlockSummary,
|
||||
AuthSessionsResponse,
|
||||
AuthSessionSummary,
|
||||
PublicUserSearchResponse,
|
||||
AuthUser,
|
||||
AuthWechatBindPhoneResponse,
|
||||
AuthWechatStartResponse,
|
||||
@@ -347,6 +348,32 @@ export async function getCurrentAuthUser(): Promise<AuthSessionSnapshot> {
|
||||
};
|
||||
}
|
||||
|
||||
export async function getPublicAuthUserByCode(code: string) {
|
||||
const response = await requestJson<PublicUserSearchResponse>(
|
||||
`/api/auth/public-users/by-code/${encodeURIComponent(code.trim())}`,
|
||||
{
|
||||
method: 'GET',
|
||||
},
|
||||
'读取用户信息失败',
|
||||
PUBLIC_AUTH_REQUEST_OPTIONS,
|
||||
);
|
||||
|
||||
return response.user;
|
||||
}
|
||||
|
||||
export async function getPublicAuthUserById(userId: string) {
|
||||
const response = await requestJson<PublicUserSearchResponse>(
|
||||
`/api/auth/public-users/by-id/${encodeURIComponent(userId.trim())}`,
|
||||
{
|
||||
method: 'GET',
|
||||
},
|
||||
'读取用户信息失败',
|
||||
PUBLIC_AUTH_REQUEST_OPTIONS,
|
||||
);
|
||||
|
||||
return response.user;
|
||||
}
|
||||
|
||||
export async function getAuthSessions() {
|
||||
const response = await requestJson<AuthSessionsResponse>(
|
||||
'/api/auth/sessions',
|
||||
|
||||
@@ -62,6 +62,22 @@ export async function getRpgEntryWorldGalleryDetail(
|
||||
return response.entry;
|
||||
}
|
||||
|
||||
export async function getRpgEntryWorldGalleryDetailByCode(
|
||||
code: string,
|
||||
options: RuntimeRequestOptions = {},
|
||||
) {
|
||||
const response = await requestPublicRpgRuntimeJson<
|
||||
CustomWorldGalleryDetailResponse<CustomWorldProfile>
|
||||
>(
|
||||
`/custom-world-gallery/by-code/${encodeURIComponent(code)}`,
|
||||
{ method: 'GET' },
|
||||
'读取作品详情失败',
|
||||
options,
|
||||
);
|
||||
|
||||
return response.entry;
|
||||
}
|
||||
|
||||
export async function upsertRpgEntryWorldProfile(
|
||||
profile: CustomWorldProfile,
|
||||
options: RuntimeRequestOptions = {},
|
||||
@@ -145,6 +161,7 @@ export const rpgEntryLibraryClient = {
|
||||
listWorldLibrary: listRpgEntryWorldLibrary,
|
||||
listWorldGallery: listRpgEntryWorldGallery,
|
||||
getWorldGalleryDetail: getRpgEntryWorldGalleryDetail,
|
||||
getWorldGalleryDetailByCode: getRpgEntryWorldGalleryDetailByCode,
|
||||
upsertWorldProfile: upsertRpgEntryWorldProfile,
|
||||
deleteWorldProfile: deleteRpgEntryWorldProfile,
|
||||
publishWorldProfile: publishRpgEntryWorldProfile,
|
||||
|
||||
Reference in New Issue
Block a user