diff --git a/Makefile b/Makefile index b29d8c04d4..55c711855c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ export .PHONY: pre-commit -pre-commit: format entities index-js +pre-commit: format entities napi-index .PHONY: format format: @@ -14,9 +14,9 @@ entities: pnpm run migrate $(MAKE) -C ./packages/backend-rs regenerate-entities -.PHONY: index-js -index-js: - $(MAKE) -C ./packages/backend-rs index.js +.PHONY: napi-index +napi-index: + $(MAKE) -C ./packages/backend-rs update-index .PHONY: build diff --git a/packages/backend-rs/Makefile b/packages/backend-rs/Makefile index 5379dfcdc9..f91a56aae7 100644 --- a/packages/backend-rs/Makefile +++ b/packages/backend-rs/Makefile @@ -21,8 +21,13 @@ regenerate-entities: src/model/entity/sea_orm_active_enums.rs cargo fmt --all -- -index.js: $(SRC) +.PHONY: update-index +update-index: index.js index.d.ts + +index.js index.d.ts: $(SRC) NODE_OPTIONS='--max_old_space_size=3072' pnpm run build:debug - [ -f built/index.js ] - rm --force index.js + [ -f built/index.js ] && [ -f built/index.d.ts ] + rm --force index.js index.d.ts cp built/index.js index.js + cp built/index.d.ts index.d.ts + sed -i 's/^ \*r"/ */g' index.d.ts diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts new file mode 100644 index 0000000000..44c8aa6660 --- /dev/null +++ b/packages/backend-rs/index.d.ts @@ -0,0 +1,880 @@ +/* tslint:disable */ +/* eslint-disable */ + +/* auto-generated by NAPI-RS */ + +export interface Acct { + username: string + host: string | null +} +export function stringToAcct(acct: string): Acct +export function acctToString(acct: Acct): string +export function nyaify(text: string, lang?: string | undefined | null): string +export interface AbuseUserReport { + id: string + createdAt: Date + targetUserId: string + reporterId: string + assigneeId: string | null + resolved: boolean + comment: string + targetUserHost: string | null + reporterHost: string | null + forwarded: boolean +} +export interface AccessToken { + id: string + createdAt: Date + token: string + hash: string + userId: string + appId: string | null + lastUsedAt: Date | null + session: string | null + name: string | null + description: string | null + iconUrl: string | null + permission: Array + fetched: boolean +} +export interface Ad { + id: string + createdAt: Date + expiresAt: Date + place: string + priority: string + url: string + imageUrl: string + memo: string + ratio: number +} +export interface Announcement { + id: string + createdAt: Date + text: string + title: string + imageUrl: string | null + updatedAt: Date | null + showPopup: boolean + isGoodNews: boolean +} +export interface AnnouncementRead { + id: string + userId: string + announcementId: string + createdAt: Date +} +export interface Antenna { + id: string + createdAt: Date + userId: string + name: string + src: AntennaSrcEnum + userListId: string | null + keywords: Json + withFile: boolean + expression: string | null + notify: boolean + caseSensitive: boolean + withReplies: boolean + userGroupJoiningId: string | null + users: Array + excludeKeywords: Json + instances: Json +} +export interface App { + id: string + createdAt: Date + userId: string | null + secret: string + name: string + description: string + permission: Array + callbackUrl: string | null +} +export interface AttestationChallenge { + id: string + userId: string + challenge: string + createdAt: Date + registrationChallenge: boolean +} +export interface AuthSession { + id: string + createdAt: Date + token: string + userId: string | null + appId: string +} +export interface Blocking { + id: string + createdAt: Date + blockeeId: string + blockerId: string +} +export interface Channel { + id: string + createdAt: Date + lastNotedAt: Date | null + userId: string | null + name: string + description: string | null + bannerId: string | null + notesCount: number + usersCount: number +} +export interface ChannelFollowing { + id: string + createdAt: Date + followeeId: string + followerId: string +} +export interface ChannelNotePining { + id: string + createdAt: Date + channelId: string + noteId: string +} +export interface Clip { + id: string + createdAt: Date + userId: string + name: string + isPublic: boolean + description: string | null +} +export interface ClipNote { + id: string + noteId: string + clipId: string +} +export interface DriveFile { + id: string + createdAt: Date + userId: string | null + userHost: string | null + md5: string + name: string + type: string + size: number + comment: string | null + properties: Json + storedInternal: boolean + url: string + thumbnailUrl: string | null + webpublicUrl: string | null + accessKey: string | null + thumbnailAccessKey: string | null + webpublicAccessKey: string | null + uri: string | null + src: string | null + folderId: string | null + isSensitive: boolean + isLink: boolean + blurhash: string | null + webpublicType: string | null + requestHeaders: Json | null + requestIp: string | null +} +export interface DriveFolder { + id: string + createdAt: Date + name: string + userId: string | null + parentId: string | null +} +export interface Emoji { + id: string + updatedAt: Date | null + name: string + host: string | null + originalUrl: string + uri: string | null + type: string | null + aliases: Array + category: string | null + publicUrl: string + license: string | null + width: number | null + height: number | null +} +export interface FollowRequest { + id: string + createdAt: Date + followeeId: string + followerId: string + requestId: string | null + followerHost: string | null + followerInbox: string | null + followerSharedInbox: string | null + followeeHost: string | null + followeeInbox: string | null + followeeSharedInbox: string | null +} +export interface Following { + id: string + createdAt: Date + followeeId: string + followerId: string + followerHost: string | null + followerInbox: string | null + followerSharedInbox: string | null + followeeHost: string | null + followeeInbox: string | null + followeeSharedInbox: string | null +} +export interface GalleryLike { + id: string + createdAt: Date + userId: string + postId: string +} +export interface GalleryPost { + id: string + createdAt: Date + updatedAt: Date + title: string + description: string | null + userId: string + fileIds: Array + isSensitive: boolean + likedCount: number + tags: Array +} +export interface Hashtag { + id: string + name: string + mentionedUserIds: Array + mentionedUsersCount: number + mentionedLocalUserIds: Array + mentionedLocalUsersCount: number + mentionedRemoteUserIds: Array + mentionedRemoteUsersCount: number + attachedUserIds: Array + attachedUsersCount: number + attachedLocalUserIds: Array + attachedLocalUsersCount: number + attachedRemoteUserIds: Array + attachedRemoteUsersCount: number +} +export interface Instance { + id: string + caughtAt: Date + host: string + usersCount: number + notesCount: number + followingCount: number + followersCount: number + latestRequestSentAt: Date | null + latestStatus: number | null + latestRequestReceivedAt: Date | null + lastCommunicatedAt: Date + isNotResponding: boolean + softwareName: string | null + softwareVersion: string | null + openRegistrations: boolean | null + name: string | null + description: string | null + maintainerName: string | null + maintainerEmail: string | null + infoUpdatedAt: Date | null + isSuspended: boolean + iconUrl: string | null + themeColor: string | null + faviconUrl: string | null +} +export interface MessagingMessage { + id: string + createdAt: Date + userId: string + recipientId: string | null + text: string | null + isRead: boolean + fileId: string | null + groupId: string | null + reads: Array + uri: string | null +} +export interface Meta { + id: string + name: string | null + description: string | null + maintainerName: string | null + maintainerEmail: string | null + disableRegistration: boolean + disableLocalTimeline: boolean + disableGlobalTimeline: boolean + useStarForReactionFallback: boolean + langs: Array + hiddenTags: Array + blockedHosts: Array + mascotImageUrl: string | null + bannerUrl: string | null + errorImageUrl: string | null + iconUrl: string | null + cacheRemoteFiles: boolean + enableRecaptcha: boolean + recaptchaSiteKey: string | null + recaptchaSecretKey: string | null + localDriveCapacityMb: number + remoteDriveCapacityMb: number + summalyProxy: string | null + enableEmail: boolean + email: string | null + smtpSecure: boolean + smtpHost: string | null + smtpPort: number | null + smtpUser: string | null + smtpPass: string | null + enableServiceWorker: boolean + swPublicKey: string | null + swPrivateKey: string | null + pinnedUsers: Array + tosUrl: string | null + repositoryUrl: string + feedbackUrl: string | null + useObjectStorage: boolean + objectStorageBucket: string | null + objectStoragePrefix: string | null + objectStorageBaseUrl: string | null + objectStorageEndpoint: string | null + objectStorageRegion: string | null + objectStorageAccessKey: string | null + objectStorageSecretKey: string | null + objectStoragePort: number | null + objectStorageUseSsl: boolean + proxyAccountId: string | null + objectStorageUseProxy: boolean + enableHcaptcha: boolean + hcaptchaSiteKey: string | null + hcaptchaSecretKey: string | null + objectStorageSetPublicRead: boolean + pinnedPages: Array + backgroundImageUrl: string | null + logoImageUrl: string | null + pinnedClipId: string | null + objectStorageS3ForcePathStyle: boolean + allowedHosts: Array | null + secureMode: boolean | null + privateMode: boolean | null + deeplAuthKey: string | null + deeplIsPro: boolean + emailRequiredForSignup: boolean + themeColor: string | null + defaultLightTheme: string | null + defaultDarkTheme: string | null + enableIpLogging: boolean + enableActiveEmailValidation: boolean + customMotd: Array + customSplashIcons: Array + disableRecommendedTimeline: boolean + recommendedInstances: Array + enableGuestTimeline: boolean + defaultReaction: string + libreTranslateApiUrl: string | null + libreTranslateApiKey: string | null + silencedHosts: Array + experimentalFeatures: Json + enableServerMachineStats: boolean + enableIdenticonGeneration: boolean + donationLink: string | null + moreUrls: Json + markLocalFilesNsfwByDefault: boolean +} +export interface Migrations { + id: number + timestamp: number + name: string +} +export interface ModerationLog { + id: string + createdAt: Date + userId: string + type: string + info: Json +} +export interface MutedNote { + id: string + noteId: string + userId: string + reason: MutedNoteReasonEnum +} +export interface Muting { + id: string + createdAt: Date + muteeId: string + muterId: string + expiresAt: Date | null +} +export interface Note { + id: string + createdAt: Date + replyId: string | null + renoteId: string | null + text: string | null + name: string | null + cw: string | null + userId: string + localOnly: boolean + renoteCount: number + repliesCount: number + reactions: Json + visibility: NoteVisibilityEnum + uri: string | null + score: number + fileIds: Array + attachedFileTypes: Array + visibleUserIds: Array + mentions: Array + mentionedRemoteUsers: string + emojis: Array + tags: Array + hasPoll: boolean + userHost: string | null + replyUserId: string | null + replyUserHost: string | null + renoteUserId: string | null + renoteUserHost: string | null + url: string | null + channelId: string | null + threadId: string | null + updatedAt: Date | null + lang: string | null +} +export interface NoteEdit { + id: string + noteId: string + text: string | null + cw: string | null + fileIds: Array + updatedAt: Date + emojis: Array +} +export interface NoteFavorite { + id: string + createdAt: Date + userId: string + noteId: string +} +export interface NoteFile { + serialNo: number + noteId: string + fileId: string +} +export interface NoteReaction { + id: string + createdAt: Date + userId: string + noteId: string + reaction: string +} +export interface NoteThreadMuting { + id: string + createdAt: Date + userId: string + threadId: string +} +export interface NoteUnread { + id: string + userId: string + noteId: string + noteUserId: string + isSpecified: boolean + isMentioned: boolean + noteChannelId: string | null +} +export interface NoteWatching { + id: string + createdAt: Date + userId: string + noteId: string + noteUserId: string +} +export interface Notification { + id: string + createdAt: Date + notifieeId: string + notifierId: string | null + isRead: boolean + noteId: string | null + reaction: string | null + choice: number | null + followRequestId: string | null + type: NotificationTypeEnum + userGroupInvitationId: string | null + customBody: string | null + customHeader: string | null + customIcon: string | null + appAccessTokenId: string | null +} +export interface Page { + id: string + createdAt: Date + updatedAt: Date + title: string + name: string + summary: string | null + alignCenter: boolean + font: string + userId: string + eyeCatchingImageId: string | null + content: Json + variables: Json + visibility: PageVisibilityEnum + visibleUserIds: Array + likedCount: number + hideTitleWhenPinned: boolean + script: string + isPublic: boolean +} +export interface PageLike { + id: string + createdAt: Date + userId: string + pageId: string +} +export interface PasswordResetRequest { + id: string + createdAt: Date + token: string + userId: string +} +export interface Poll { + noteId: string + expiresAt: Date | null + multiple: boolean + choices: Array + votes: Array + noteVisibility: PollNotevisibilityEnum + userId: string + userHost: string | null +} +export interface PollVote { + id: string + createdAt: Date + userId: string + noteId: string + choice: number +} +export interface PromoNote { + noteId: string + expiresAt: Date + userId: string +} +export interface PromoRead { + id: string + createdAt: Date + userId: string + noteId: string +} +export interface RegistrationTicket { + id: string + createdAt: Date + code: string +} +export interface RegistryItem { + id: string + createdAt: Date + updatedAt: Date + userId: string + key: string + scope: Array + domain: string | null + value: Json | null +} +export interface Relay { + id: string + inbox: string + status: RelayStatusEnum +} +export interface RenoteMuting { + id: string + createdAt: Date + muteeId: string + muterId: string +} +export interface ReplyMuting { + id: string + createdAt: Date + muteeId: string + muterId: string +} +export const enum AntennaSrcEnum { + All = 0, + Group = 1, + Home = 2, + Instances = 3, + List = 4, + Users = 5 +} +export const enum MutedNoteReasonEnum { + Manual = 0, + Other = 1, + Spam = 2, + Word = 3 +} +export const enum NoteVisibilityEnum { + Followers = 0, + Hidden = 1, + Home = 2, + Public = 3, + Specified = 4 +} +export const enum NotificationTypeEnum { + App = 0, + Follow = 1, + FollowRequestAccepted = 2, + GroupInvited = 3, + Mention = 4, + PollEnded = 5, + PollVote = 6, + Quote = 7, + Reaction = 8, + ReceiveFollowRequest = 9, + Renote = 10, + Reply = 11 +} +export const enum PageVisibilityEnum { + Followers = 0, + Public = 1, + Specified = 2 +} +export const enum PollNotevisibilityEnum { + Followers = 0, + Home = 1, + Public = 2, + Specified = 3 +} +export const enum RelayStatusEnum { + Accepted = 0, + Rejected = 1, + Requesting = 2 +} +export const enum UserEmojimodpermEnum { + Add = 0, + Full = 1, + Mod = 2, + Unauthorized = 3 +} +export const enum UserProfileFfvisibilityEnum { + Followers = 0, + Private = 1, + Public = 2 +} +export const enum UserProfileMutingnotificationtypesEnum { + App = 0, + Follow = 1, + FollowRequestAccepted = 2, + GroupInvited = 3, + Mention = 4, + PollEnded = 5, + PollVote = 6, + Quote = 7, + Reaction = 8, + ReceiveFollowRequest = 9, + Renote = 10, + Reply = 11 +} +export interface Signin { + id: string + createdAt: Date + userId: string + ip: string + headers: Json + success: boolean +} +export interface SwSubscription { + id: string + createdAt: Date + userId: string + endpoint: string + auth: string + publickey: string + sendReadMessage: boolean +} +export interface UsedUsername { + username: string + createdAt: Date +} +export interface User { + id: string + createdAt: Date + updatedAt: Date | null + lastFetchedAt: Date | null + username: string + usernameLower: string + name: string | null + followersCount: number + followingCount: number + notesCount: number + avatarId: string | null + bannerId: string | null + tags: Array + isSuspended: boolean + isSilenced: boolean + isLocked: boolean + isBot: boolean + isCat: boolean + isAdmin: boolean + isModerator: boolean + emojis: Array + host: string | null + inbox: string | null + sharedInbox: string | null + featured: string | null + uri: string | null + token: string | null + isExplorable: boolean + followersUri: string | null + lastActiveDate: Date | null + hideOnlineStatus: boolean + isDeleted: boolean + driveCapacityOverrideMb: number | null + movedToUri: string | null + alsoKnownAs: string | null + speakAsCat: boolean + emojiModPerm: UserEmojimodpermEnum + isIndexable: boolean +} +export interface UserGroup { + id: string + createdAt: Date + name: string + userId: string + isPrivate: boolean +} +export interface UserGroupInvitation { + id: string + createdAt: Date + userId: string + userGroupId: string +} +export interface UserGroupInvite { + id: string + createdAt: Date + userId: string + userGroupId: string +} +export interface UserGroupJoining { + id: string + createdAt: Date + userId: string + userGroupId: string +} +export interface UserIp { + id: number + createdAt: Date + userId: string + ip: string +} +export interface UserKeypair { + userId: string + publicKey: string + privateKey: string +} +export interface UserList { + id: string + createdAt: Date + userId: string + name: string +} +export interface UserListJoining { + id: string + createdAt: Date + userId: string + userListId: string +} +export interface UserNotePining { + id: string + createdAt: Date + userId: string + noteId: string +} +export interface UserPending { + id: string + createdAt: Date + code: string + username: string + email: string + password: string +} +export interface UserProfile { + userId: string + location: string | null + birthday: string | null + description: string | null + fields: Json + url: string | null + email: string | null + emailVerifyCode: string | null + emailVerified: boolean + twoFactorTempSecret: string | null + twoFactorSecret: string | null + twoFactorEnabled: boolean + password: string | null + clientData: Json + autoAcceptFollowed: boolean + alwaysMarkNsfw: boolean + carefulBot: boolean + userHost: string | null + securityKeysAvailable: boolean + usePasswordLessLogin: boolean + pinnedPageId: string | null + room: Json + injectFeaturedNote: boolean + enableWordMute: boolean + mutedWords: Json + mutingNotificationTypes: Array + noCrawle: boolean + receiveAnnouncementEmail: boolean + emailNotificationTypes: Json + mutedInstances: Json + publicReactions: boolean + ffVisibility: UserProfileFfvisibilityEnum + moderationNote: string + preventAiLearning: boolean + isIndexable: boolean + mutedPatterns: Array +} +export interface UserPublickey { + userId: string + keyId: string + keyPem: string +} +export interface UserSecurityKey { + id: string + userId: string + publicKey: string + lastUsed: Date + name: string +} +export interface Webhook { + id: string + createdAt: Date + userId: string + name: string + on: Array + url: string + secret: string + active: boolean + latestSentAt: Date | null + latestStatus: number | null +} +/** Initializes Cuid2 generator. Must be called before any [create_id]. */ +export function initIdGenerator(length: number, fingerprint: string): void +export function getTimestamp(id: string): number +/** + * The generated ID results in the form of `[8 chars timestamp] + [cuid2]`. + * The minimum and maximum lengths are 16 and 24, respectively. + * With the length of 16, namely 8 for cuid2, roughly 1427399 IDs are needed + * in the same millisecond to reach 50% chance of collision. + * + * Ref: https://github.com/paralleldrive/cuid2#parameterized-length + */ +export function genId(date?: Date | undefined | null): string +export function secureRndstr(length?: number | undefined | null): string +export const enum IdConvertType { + MastodonId = 0, + FirefishId = 1 +} +export function convertId(inId: string, idConvertType: IdConvertType): string