Files
FastGPT/packages/service/support/user/team/teamMemberSchema.ts
T
Archer 2e18f1ebc2 next 15 (#6457)
* next 15

* lock

* feat: rename .d.ts to .ts for Next 15 compatibility

- Rename 104 .d.ts files to .ts (Next 15 no longer supports .d.ts in src)
- Remove 5 redundant .d.ts files that had .ts counterparts
- Update all import paths: remove .d suffix from 100 import statements
- Update tsconfig.json include patterns across all packages
- Add pnpm overrides to unify react@18.3.1 across monorepo
- Fix react version mismatch (packages/global and packages/service were resolving to react@19.1.1)

* fix: resolve 61 TypeScript errors from .d.ts to .ts migration

- Fix broken imports using non-relative module paths (e.g. 'support/user/team/type' → relative paths)
- Remove unused/dead imports referencing deleted modules
- Fix duplicate identifiers (show_emptyChat, concatMd, TrainingModeEnum)
- Add missing imports (BoxProps, GroupMemberRole, UsageSourceEnum, dashboard_evaluation)
- Fix generic type constraints (OutLinkEditType, createShareChat)
- Replace removed types with correct alternatives (ChatModelItemType → LLMModelItemType)
- Delete 5 dead code files with 0 references
- Add global type declaration for countTrackQueue
- Fix nullable type narrowing (sourceMember, ParentIdType, optional app fields)

* refactor: replace as ClientSession assertion with proper type narrowing via Omit & intersection

* fix: remove experimental.workerThreads to fix DataCloneError in Next 15 static generation

Next 15 worker threads attempt to structuredClone the config object,
which fails on the webpack function. workerThreads is not needed for
the build to work correctly.

* Update document/content/docs/upgrading/4-14/4148.mdx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: ts

* update next config

* update next

* fix: dockerfile

* fix: comment

---------

Co-authored-by: Archer <c121914yu@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-25 18:28:16 +08:00

82 lines
2.0 KiB
TypeScript

import { connectionMongo, getMongoModel } from '../../../common/mongo';
const { Schema } = connectionMongo;
import { type TeamMemberSchema as TeamMemberType } from '@fastgpt/global/support/user/team/type';
import { userCollectionName } from '../../user/schema';
import {
TeamMemberStatusMap,
TeamMemberCollectionName,
TeamCollectionName
} from '@fastgpt/global/support/user/team/constant';
import { getRandomUserAvatar } from '@fastgpt/global/support/user/utils';
import { getLogger, LogCategories } from '../../../common/logger';
const TeamMemberSchema = new Schema({
teamId: {
type: Schema.Types.ObjectId,
ref: TeamCollectionName,
required: true
},
userId: {
type: Schema.Types.ObjectId,
ref: userCollectionName,
required: true
},
avatar: {
type: String,
default: () => getRandomUserAvatar()
},
name: {
type: String,
default: 'Member'
},
status: {
type: String,
enum: Object.keys(TeamMemberStatusMap)
},
createTime: {
type: Date,
default: () => new Date()
},
updateTime: {
type: Date
},
/** @deprecated
* But some code still use this to judge whether the member is a owner.
* TODO: Remove this field and replace it with a more appropriate way to determine ownership.
*/
role: {
type: String
},
/** @deprecated */
defaultTeam: {
type: Boolean
}
});
TeamMemberSchema.virtual('team', {
ref: TeamCollectionName,
localField: 'teamId',
foreignField: '_id',
justOne: true
});
TeamMemberSchema.virtual('user', {
ref: userCollectionName,
localField: 'userId',
foreignField: '_id',
justOne: true
});
try {
TeamMemberSchema.index({ teamId: 1 }, { background: true });
TeamMemberSchema.index({ userId: 1 }, { background: true });
} catch (error) {
const logger = getLogger(LogCategories.INFRA.MONGO);
logger.error('Failed to build team member indexes', { error });
}
export const MongoTeamMember = getMongoModel<TeamMemberType>(
TeamMemberCollectionName,
TeamMemberSchema
);