This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
{
"name": "tailchat-types",
"version": "1.0.4",
"description": "Tailchat model types",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/cjs/index.d.ts",
"scripts": {
"prepare": "pnpm build",
"build": "concurrently npm:build-cjs npm:build-esm",
"build-cjs": "rimraf ./dist/cjs && tsc --outDir dist/cjs",
"build-esm": "rimraf ./dist/esm && tsc --outDir dist/esm --module es2015",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"concurrently": "^7.6.0",
"rimraf": "^3.0.2",
"typescript": "4.9.4"
}
}

View File

@@ -0,0 +1,4 @@
export * from './model/inbox';
export * from './model/user';
export * from './model/message';
export * from './model/group';

View File

@@ -0,0 +1,103 @@
export interface GroupInfo {
_id: string;
name: string;
avatar?: string;
owner: string;
description: string;
members: GroupMember[];
panels: GroupPanel[];
roles: GroupRole[];
/**
* 所有人的权限列表
* 为群组中的最低权限
*/
fallbackPermissions: string[];
/**
* 群组的配置信息
*/
config: object;
}
export interface GroupRole {
_id: string;
/**
* 权限组名
*/
name: string;
/**
* 拥有的权限, 是一段字符串
*/
permissions: string[];
}
export interface GroupMember {
roles?: string[]; // 角色权限组id
userId: string;
/**
* 禁言到xxx 为止
*/
muteUntil?: string;
}
export enum GroupPanelType {
TEXT = 0,
GROUP = 1,
PLUGIN = 2,
}
export interface GroupPanel {
id: string; // 在群组中唯一, 可以用任意方式进行生成。这里使用ObjectId, 但不是ObjectId类型
name: string; // 用于显示的名称
parentId?: string; // 父节点id
/**
* 面板类型:
* 0 文本频道
* 1 面板分组
* 2 插件
*
* Reference: https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*/
type: GroupPanelType;
provider?: string; // 面板提供者,为插件的标识,仅面板类型为插件时有效
pluginPanelName?: string; // 插件面板名, 如 com.msgbyte.webview/grouppanel
/**
* 面板的其他数据
*/
meta?: Record<string, any>;
/**
* 身份组或者用户的权限
* 如果没有设定则应用群组权限
*
* key 为身份组id或者用户id
* value 为权限字符串列表
*/
permissionMap?: Record<string, string[]>;
/**
* 所有人的权限列表
* 如果没有设定则应用群组权限
*/
fallbackPermissions?: string[];
}
/**
* 访客级别获取群组信息
*/
export interface GroupBasicInfo {
name: string;
avatar?: string;
owner: string;
memberCount: number;
backgroundImage?: string;
}
export interface GroupInvite {
code: string;
groupId: string;
creator: string;
expiredAt?: string;
usage: number;
usageLimit?: number;
}

View File

@@ -0,0 +1,54 @@
/**
* 收件箱记录项类型
*/
export interface BasicInboxItem {
_id: string;
/**
* 用户id
*/
userId: string;
/**
* 是否已读
*/
readed: boolean;
type: string;
payload?: Record<string, any>;
createdAt: string;
updatedAt: string;
}
export interface MessageInboxItem extends BasicInboxItem {
type: 'message';
/**
* @deprecated ALl info should move into payload
*/
message?: {
groupId?: string;
converseId: string;
messageId: string;
messageSnippet: string;
};
payload: {
groupId?: string;
converseId: string;
messageId: string;
messageAuthor: string;
messageSnippet: string;
messagePlainContent?: string;
};
}
export interface MarkdownInboxItem extends BasicInboxItem {
type: 'markdown';
payload: {
title?: string;
content: string;
/**
* 消息来源
*/
source?: string;
};
}
export type InboxItem = MessageInboxItem | MarkdownInboxItem;

View File

@@ -0,0 +1,44 @@
export interface ChatMessageReaction {
name: string;
author: string;
}
export interface ChatMessage {
_id: string;
content: string;
author?: string;
groupId?: string;
converseId: string;
reactions?: ChatMessageReaction[];
hasRecall?: boolean;
meta?: Record<string, unknown>;
createdAt?: string;
updatedAt?: string;
}
export const chatConverseType = [
'DM', // 私信
'Multi', // 多人会话
'Group', // 群组
] as const;
export type ChatConverseType = (typeof chatConverseType)[number];
export interface ChatConverse {
_id: string;
name?: string;
type: ChatConverseType;
members: string[];
}

View File

@@ -0,0 +1,46 @@
export const userType = ['normalUser', 'pluginBot', 'openapiBot'] as const;
export type UserType = (typeof userType)[number];
export interface UserBaseInfo {
_id: string;
/**
* Username cannot modify
*
* There must be one with email
*/
username?: string;
/**
* E-mail cannot be modified
* required
*/
email: string;
/**
* display name that can be modified
*/
nickname: string;
/**
* Identifier, together with username constitutes a globally unique username
* use for search
* <username>#<discriminator>
*/
discriminator: string;
avatar: string | null;
/**
* Is it a temporary user
* @default false
*/
temporary: boolean;
type: UserType;
emailVerified: boolean;
banned: boolean;
extra?: Record<string, unknown>;
}
export interface UserInfoWithPassword extends UserBaseInfo {
password: string;
}
export interface UserInfoWithToken extends UserBaseInfo {
token: string;
}

View File

@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"target": "ES5",
"lib": ["ES2015"],
"module": "CommonJS"
},
"include": ["src"]
}