Uniquify exportEntityName and importEntityName

This commit is contained in:
наб 2025-07-16 18:31:19 +02:00
parent a00a3c6841
commit 6abbf955fc
No known key found for this signature in database
GPG key ID: BCFD0B018D2658F1
7 changed files with 84 additions and 53 deletions

View file

@ -224,26 +224,8 @@ const props = withDefaults(defineProps<{
type ExportCompletedNotification = Misskey.entities.Notification & { type: 'exportCompleted' };
type ImportCompletedNotification = Misskey.entities.Notification & { type: 'importCompleted' };
const exportEntityName = {
antenna: i18n.ts.antennas,
blocking: i18n.ts.blockedUsers,
clip: i18n.ts.clips,
customEmoji: i18n.ts.customEmojis,
favorite: i18n.ts.favorites,
following: i18n.ts.following,
muting: i18n.ts.mutedUsers,
note: i18n.ts.notes,
userList: i18n.ts.lists,
} as const satisfies Record<ExportCompletedNotification['exportedEntity'], string>;
const importEntityName = {
antenna: i18n.ts.antennas,
blocking: i18n.ts.blockedUsers,
customEmoji: i18n.ts.customEmojis,
following: i18n.ts.following,
muting: i18n.ts.mutedUsers,
userList: i18n.ts.lists,
} as const satisfies Record<ImportCompletedNotification['importedEntity'], string>;
const exportEntityName = Misskey.entities.exportEntityName(i18n);
const importEntityName = Misskey.entities.importEntityName(i18n);
const followRequestDone = ref(true);
const userDetailed: Ref<Misskey.entities.UserDetailed | null> = ref(null);

View file

@ -164,6 +164,9 @@ type AdminDeleteAccountRequest = operations['admin___delete-account']['requestBo
// @public (undocumented)
type AdminDeleteAllFilesOfAUserRequest = operations['admin___delete-all-files-of-a-user']['requestBody']['content']['application/json'];
// @public (undocumented)
type AdminDriveCleanRemoteFilesRequest = operations['admin___drive___clean-remote-files']['requestBody']['content']['application/json'];
// @public (undocumented)
type AdminDriveFilesRequest = operations['admin___drive___files']['requestBody']['content']['application/json'];
@ -1498,6 +1501,8 @@ declare namespace entities {
SigninWithPasskeyInitResponse,
SigninWithPasskeyResponse,
PartialRolePolicyOverride,
exportEntityName,
importEntityName,
EmptyRequest,
EmptyResponse,
AdminAbuseReportNotificationRecipientCreateRequest,
@ -1541,6 +1546,7 @@ declare namespace entities {
AdminDeclineUserRequest,
AdminDeleteAccountRequest,
AdminDeleteAllFilesOfAUserRequest,
AdminDriveCleanRemoteFilesRequest,
AdminDriveFilesRequest,
AdminDriveFilesResponse,
AdminDriveShowFileRequest,
@ -2230,6 +2236,19 @@ export { entities }
// @public (undocumented)
type Error_2 = components['schemas']['Error'];
// @public (undocumented)
const exportEntityName: (i18n: any) => {
readonly antenna: any;
readonly blocking: any;
readonly clip: any;
readonly customEmoji: any;
readonly favorite: any;
readonly following: any;
readonly muting: any;
readonly note: any;
readonly userList: any;
};
// @public (undocumented)
type FederationFollowersRequest = operations['federation___followers']['requestBody']['content']['application/json'];
@ -2607,6 +2626,19 @@ type IMoveRequest = operations['i___move']['requestBody']['content']['applicatio
// @public (undocumented)
type IMoveResponse = operations['i___move']['responses']['200']['content']['application/json'];
// @public (undocumented)
const importEntityName: (i18n: any) => {
readonly antenna: any;
readonly blocking: any;
readonly clip: any;
readonly customEmoji: any;
readonly favorite: any;
readonly following: any;
readonly muting: any;
readonly note: any;
readonly userList: any;
};
// @public (undocumented)
type INotificationsGroupedRequest = operations['i___notifications-grouped']['requestBody']['content']['application/json'];
@ -3919,7 +3951,7 @@ type V2AdminEmojiListResponse = operations['v2___admin___emoji___list']['respons
// Warnings were encountered during analysis:
//
// src/entities.ts:50:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/entities.ts:51:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/streaming.ts:57:3 - (ae-forgotten-export) The symbol "ReconnectingWebSocket" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:234:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:244:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts

View file

@ -42,6 +42,7 @@ import type {
AdminDeclineUserRequest,
AdminDeleteAccountRequest,
AdminDeleteAllFilesOfAUserRequest,
AdminDriveCleanRemoteFilesRequest,
AdminDriveFilesRequest,
AdminDriveFilesResponse,
AdminDriveShowFileRequest,
@ -691,7 +692,7 @@ export type Endpoints = {
'admin/decline-user': { req: AdminDeclineUserRequest; res: EmptyResponse };
'admin/delete-account': { req: AdminDeleteAccountRequest; res: EmptyResponse };
'admin/delete-all-files-of-a-user': { req: AdminDeleteAllFilesOfAUserRequest; res: EmptyResponse };
'admin/drive/clean-remote-files': { req: EmptyRequest; res: EmptyResponse };
'admin/drive/clean-remote-files': { req: AdminDriveCleanRemoteFilesRequest; res: EmptyResponse };
'admin/drive/cleanup': { req: EmptyRequest; res: EmptyResponse };
'admin/drive/files': { req: AdminDriveFilesRequest; res: AdminDriveFilesResponse };
'admin/drive/show-file': { req: AdminDriveShowFileRequest; res: AdminDriveShowFileResponse };

View file

@ -45,6 +45,7 @@ export type AdminCwUserRequest = operations['admin___cw-user']['requestBody']['c
export type AdminDeclineUserRequest = operations['admin___decline-user']['requestBody']['content']['application/json'];
export type AdminDeleteAccountRequest = operations['admin___delete-account']['requestBody']['content']['application/json'];
export type AdminDeleteAllFilesOfAUserRequest = operations['admin___delete-all-files-of-a-user']['requestBody']['content']['application/json'];
export type AdminDriveCleanRemoteFilesRequest = operations['admin___drive___clean-remote-files']['requestBody']['content']['application/json'];
export type AdminDriveFilesRequest = operations['admin___drive___files']['requestBody']['content']['application/json'];
export type AdminDriveFilesResponse = operations['admin___drive___files']['responses']['200']['content']['application/json'];
export type AdminDriveShowFileRequest = operations['admin___drive___show-file']['requestBody']['content']['application/json'];

View file

@ -4912,6 +4912,17 @@ export type components = {
exportedEntity: 'antenna' | 'blocking' | 'clip' | 'customEmoji' | 'favorite' | 'following' | 'muting' | 'note' | 'userList';
/** Format: id */
fileId: string;
}) | ({
/** Format: id */
id: string;
/** Format: date-time */
createdAt: string;
/** @enum {string} */
type: 'importCompleted';
/** @enum {string} */
importedEntity: 'antenna' | 'blocking' | 'customEmoji' | 'following' | 'muting' | 'userList';
/** Format: id */
fileId: string;
}) | {
/** Format: id */
id: string;
@ -7583,6 +7594,14 @@ export type operations = {
* **Credential required**: *Yes* / **Permission**: *write:admin:drive*
*/
'admin___drive___clean-remote-files': {
requestBody: {
content: {
'application/json': {
olderThanSeconds?: number;
keepFilesInUse?: boolean;
};
};
};
responses: {
/** @description OK (without any results) */
204: {
@ -23881,8 +23900,8 @@ export type operations = {
untilId?: string;
/** @default true */
markAsRead?: boolean;
includeTypes?: ('note' | 'follow' | 'mention' | 'reply' | 'renote' | 'quote' | 'reaction' | 'pollEnded' | 'edited' | 'receiveFollowRequest' | 'followRequestAccepted' | 'roleAssigned' | 'chatRoomInvitationReceived' | 'achievementEarned' | 'exportCompleted' | 'login' | 'createToken' | 'scheduledNoteFailed' | 'scheduledNotePosted' | 'app' | 'test' | 'pollVote' | 'groupInvited')[];
excludeTypes?: ('note' | 'follow' | 'mention' | 'reply' | 'renote' | 'quote' | 'reaction' | 'pollEnded' | 'edited' | 'receiveFollowRequest' | 'followRequestAccepted' | 'roleAssigned' | 'chatRoomInvitationReceived' | 'achievementEarned' | 'exportCompleted' | 'login' | 'createToken' | 'scheduledNoteFailed' | 'scheduledNotePosted' | 'app' | 'test' | 'pollVote' | 'groupInvited')[];
includeTypes?: ('note' | 'follow' | 'mention' | 'reply' | 'renote' | 'quote' | 'reaction' | 'pollEnded' | 'edited' | 'receiveFollowRequest' | 'followRequestAccepted' | 'roleAssigned' | 'chatRoomInvitationReceived' | 'achievementEarned' | 'exportCompleted' | 'importCompleted' | 'login' | 'createToken' | 'scheduledNoteFailed' | 'scheduledNotePosted' | 'app' | 'test' | 'pollVote' | 'groupInvited')[];
excludeTypes?: ('note' | 'follow' | 'mention' | 'reply' | 'renote' | 'quote' | 'reaction' | 'pollEnded' | 'edited' | 'receiveFollowRequest' | 'followRequestAccepted' | 'roleAssigned' | 'chatRoomInvitationReceived' | 'achievementEarned' | 'exportCompleted' | 'importCompleted' | 'login' | 'createToken' | 'scheduledNoteFailed' | 'scheduledNotePosted' | 'app' | 'test' | 'pollVote' | 'groupInvited')[];
};
};
};
@ -23949,8 +23968,8 @@ export type operations = {
untilId?: string;
/** @default true */
markAsRead?: boolean;
includeTypes?: ('note' | 'follow' | 'mention' | 'reply' | 'renote' | 'quote' | 'reaction' | 'pollEnded' | 'edited' | 'receiveFollowRequest' | 'followRequestAccepted' | 'roleAssigned' | 'chatRoomInvitationReceived' | 'achievementEarned' | 'exportCompleted' | 'login' | 'createToken' | 'scheduledNoteFailed' | 'scheduledNotePosted' | 'app' | 'test' | 'pollVote' | 'groupInvited')[];
excludeTypes?: ('note' | 'follow' | 'mention' | 'reply' | 'renote' | 'quote' | 'reaction' | 'pollEnded' | 'edited' | 'receiveFollowRequest' | 'followRequestAccepted' | 'roleAssigned' | 'chatRoomInvitationReceived' | 'achievementEarned' | 'exportCompleted' | 'login' | 'createToken' | 'scheduledNoteFailed' | 'scheduledNotePosted' | 'app' | 'test' | 'pollVote' | 'groupInvited')[];
includeTypes?: ('note' | 'follow' | 'mention' | 'reply' | 'renote' | 'quote' | 'reaction' | 'pollEnded' | 'edited' | 'receiveFollowRequest' | 'followRequestAccepted' | 'roleAssigned' | 'chatRoomInvitationReceived' | 'achievementEarned' | 'exportCompleted' | 'importCompleted' | 'login' | 'createToken' | 'scheduledNoteFailed' | 'scheduledNotePosted' | 'app' | 'test' | 'pollVote' | 'groupInvited')[];
excludeTypes?: ('note' | 'follow' | 'mention' | 'reply' | 'renote' | 'quote' | 'reaction' | 'pollEnded' | 'edited' | 'receiveFollowRequest' | 'followRequestAccepted' | 'roleAssigned' | 'chatRoomInvitationReceived' | 'achievementEarned' | 'exportCompleted' | 'importCompleted' | 'login' | 'createToken' | 'scheduledNoteFailed' | 'scheduledNotePosted' | 'app' | 'test' | 'pollVote' | 'groupInvited')[];
};
};
};

View file

@ -4,6 +4,7 @@ import {
EmojiDetailed,
MeDetailed,
Note,
Notification,
Page,
Role,
RolePolicies,
@ -395,3 +396,20 @@ export type SigninWithPasskeyResponse = {
type Values<T extends Record<PropertyKey, unknown>> = T[keyof T];
export type PartialRolePolicyOverride = Partial<{ [k in keyof RolePolicies]: Omit<Values<Role['policies']>, 'value'> & { value: RolePolicies[k] } }>;
type ExportCompletedNotification = Notification & { type: 'exportCompleted' };
type ImportCompletedNotification = Notification & { type: 'importCompleted' };
export const exportEntityName = (i18n: any) => ({
antenna: i18n.ts.antennas,
blocking: i18n.ts.blockedUsers,
clip: i18n.ts.clips,
customEmoji: i18n.ts.customEmojis,
favorite: i18n.ts.favorites,
following: i18n.ts.following,
muting: i18n.ts.mutedUsers,
note: i18n.ts.notes,
userList: i18n.ts.lists,
} as const satisfies Record<ExportCompletedNotification['exportedEntity'], string>);
export const importEntityName = (i18n: any) => (exportEntityName(i18n) satisfies Record<ImportCompletedNotification['importedEntity'], string>);

View file

@ -6,6 +6,7 @@
/*
* Notification manager for SW
*/
import * as Misskey from 'misskey-js';
import type { BadgeNames, PushNotificationDataMap } from '@/types.js';
import { char2fileName } from '@/scripts/twemoji-base.js';
import { cli } from '@/scripts/operations.js';
@ -216,40 +217,17 @@ async function composeNotification(data: PushNotificationDataMap[keyof PushNotif
data,
}];
case 'exportCompleted': {
const entityName = {
antenna: i18n.ts.antennas,
blocking: i18n.ts.blockedUsers,
clip: i18n.ts.clips,
customEmoji: i18n.ts.customEmojis,
favorite: i18n.ts.favorites,
following: i18n.ts.following,
muting: i18n.ts.mutedUsers,
note: i18n.ts.notes,
userList: i18n.ts.lists,
} as const satisfies Record<typeof data.body.exportedEntity, string>;
return [i18n.tsx._notification.exportOfXCompleted({ x: entityName[data.body.exportedEntity] }), {
case 'exportCompleted':
return [i18n.tsx._notification.exportOfXCompleted({ x: Misskey.entities.exportEntityName(i18n)[data.body.exportedEntity] }), {
badge: iconUrl('circle-check'),
data,
}];
}
case 'importCompleted': {
const entityName = {
antenna: i18n.ts.antennas,
blocking: i18n.ts.blockedUsers,
customEmoji: i18n.ts.customEmojis,
following: i18n.ts.following,
muting: i18n.ts.mutedUsers,
userList: i18n.ts.lists,
} as const satisfies Record<typeof data.body.importedEntity, string>;
return [i18n.tsx._notification.importOfXCompleted({ x: entityName[data.body.importedEntity] }), {
case 'importCompleted':
return [i18n.tsx._notification.importOfXCompleted({ x: Misskey.entities.importEntityName(i18n)[data.body.importedEntity] }), {
badge: iconUrl('circle-check'),
data,
}];
}
case 'pollEnded':
return [i18n.ts._notification.pollEnded, {