mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 05:17:39 +00:00
* feat(team): add integrations settings with turntable and gotenberg * fix(upload): pass teamId to gotenberg availability check during upload preflight
246 lines
7.0 KiB
TypeScript
246 lines
7.0 KiB
TypeScript
import { z } from 'zod'
|
|
import { UserType, TeamMemberScope } from '@shumai/db/enums'
|
|
import { paginationPageInfoSchema, paginationParamsSchema } from './pagination'
|
|
|
|
export { UserType, TeamMemberScope }
|
|
|
|
export const createTeamRequestSchema = z.object({
|
|
name: z.string(),
|
|
})
|
|
export type CreateTeamRequest = z.infer<typeof createTeamRequestSchema>
|
|
|
|
export const teamInfoSchema = z.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
rootFolder: z.string().optional(),
|
|
updatedAt: z.union([z.string(), z.date()]),
|
|
})
|
|
export type TeamInfo = z.infer<typeof teamInfoSchema>
|
|
|
|
export const getUserTeamsRequestSchema = paginationParamsSchema
|
|
export type GetUserTeamsRequest = z.infer<typeof getUserTeamsRequestSchema>
|
|
|
|
export const getUserTeamsResponseSchema = z.object({
|
|
data: z.array(teamInfoSchema),
|
|
pageInfo: paginationPageInfoSchema,
|
|
})
|
|
export type GetUserTeamsResponse = z.infer<typeof getUserTeamsResponseSchema>
|
|
|
|
export const joinTeamRequestSchema = z.object({
|
|
teamId: z.string(),
|
|
userId: z.string(),
|
|
})
|
|
export type JoinTeamRequest = z.infer<typeof joinTeamRequestSchema>
|
|
|
|
export const getMeResponseSchema = z.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
email: z.string().optional(),
|
|
role: z.enum(['owner', 'editor', 'reviewer', 'bot', 'unknown']),
|
|
image: z.string().optional(),
|
|
unreadNotificationCount: z.number().optional(),
|
|
})
|
|
export type GetMeResponse = z.infer<typeof getMeResponseSchema>
|
|
|
|
export const updateMeRequestSchema = z.object({
|
|
name: z.string().optional(),
|
|
imageKey: z.string().nullable().optional(),
|
|
})
|
|
export type UpdateMeRequest = z.infer<typeof updateMeRequestSchema>
|
|
|
|
export const userInfoSchema = z.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
role: z.enum(['owner', 'editor', 'reviewer', 'bot', 'unknown']),
|
|
email: z.string().optional(),
|
|
type: z.nativeEnum(UserType).optional(),
|
|
image: z.string().optional(),
|
|
scope: z.nativeEnum(TeamMemberScope).optional(),
|
|
})
|
|
export type UserInfo = z.infer<typeof userInfoSchema>
|
|
|
|
export const listMembersQuerySchema = z.object({
|
|
includeAgents: z
|
|
.string()
|
|
.optional()
|
|
.transform((v) => v === 'true'),
|
|
})
|
|
|
|
export const VideoTranscodeStrategy = {
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
best_match: 'best_match',
|
|
multi: 'multi',
|
|
all: 'all',
|
|
} as const
|
|
export type VideoTranscodeStrategy =
|
|
(typeof VideoTranscodeStrategy)[keyof typeof VideoTranscodeStrategy]
|
|
|
|
export const VideoResolutionLadder = {
|
|
r480p: '480p',
|
|
r720p: '720p',
|
|
r1080p: '1080p',
|
|
r1440p: '1440p',
|
|
r2160p: '2160p',
|
|
} as const
|
|
export type VideoResolutionLadder =
|
|
(typeof VideoResolutionLadder)[keyof typeof VideoResolutionLadder]
|
|
|
|
export const DEFAULT_VIDEO_RESOLUTIONS: VideoResolutionLadder[] = [
|
|
'480p',
|
|
'720p',
|
|
'1080p',
|
|
'1440p',
|
|
'2160p',
|
|
]
|
|
|
|
export const HardwareAcceleration = {
|
|
off: 'off',
|
|
auto: 'auto',
|
|
} as const
|
|
export type HardwareAcceleration = (typeof HardwareAcceleration)[keyof typeof HardwareAcceleration]
|
|
|
|
export const HlsResolutionLadder = {
|
|
r480p: '480p',
|
|
r720p: '720p',
|
|
r1080p: '1080p',
|
|
r1440p: '1440p',
|
|
r2160p: '2160p',
|
|
} as const
|
|
export type HlsResolutionLadder = (typeof HlsResolutionLadder)[keyof typeof HlsResolutionLadder]
|
|
|
|
export const DEFAULT_HLS_RESOLUTIONS: HlsResolutionLadder[] = ['480p', '720p', '1080p']
|
|
|
|
export const updateTeamSettingsRequestSchema = z.union([
|
|
z.object({
|
|
key: z.literal('transcode.videoStrategy'),
|
|
value: z.nativeEnum(VideoTranscodeStrategy),
|
|
}),
|
|
z.object({
|
|
key: z.literal('transcode.videoResolutions'),
|
|
value: z.array(z.nativeEnum(VideoResolutionLadder)),
|
|
}),
|
|
z.object({
|
|
key: z.literal('transcode.hardwareAcceleration'),
|
|
value: z.nativeEnum(HardwareAcceleration),
|
|
}),
|
|
z.object({
|
|
key: z.literal('transcode.threads'),
|
|
value: z.number().int().min(0).max(32),
|
|
}),
|
|
z.object({
|
|
key: z.literal('transcode.hlsEnabled'),
|
|
value: z.boolean(),
|
|
}),
|
|
z.object({
|
|
key: z.literal('transcode.hlsResolutions'),
|
|
value: z.array(z.nativeEnum(HlsResolutionLadder)),
|
|
}),
|
|
z.object({
|
|
key: z.literal('appearance.hideAgent'),
|
|
value: z.boolean(),
|
|
}),
|
|
])
|
|
export type UpdateTeamSettingsRequest = z.infer<typeof updateTeamSettingsRequestSchema>
|
|
|
|
export const turntableSettingsResponseSchema = z.object({
|
|
url: z.string().optional(),
|
|
username: z.string().optional(),
|
|
hasPassword: z.boolean(),
|
|
isEnvConfigured: z.boolean(),
|
|
})
|
|
export type TurntableSettingsResponse = z.infer<typeof turntableSettingsResponseSchema>
|
|
|
|
export const updateTurntableSettingsRequestSchema = z.object({
|
|
url: z.string().optional(),
|
|
username: z.string().optional(),
|
|
password: z.string().optional(),
|
|
})
|
|
export type UpdateTurntableSettingsRequest = z.infer<typeof updateTurntableSettingsRequestSchema>
|
|
|
|
export const gotenbergSettingsResponseSchema = z.object({
|
|
url: z.string().optional(),
|
|
username: z.string().optional(),
|
|
hasPassword: z.boolean(),
|
|
isEnvConfigured: z.boolean(),
|
|
})
|
|
export type GotenbergSettingsResponse = z.infer<typeof gotenbergSettingsResponseSchema>
|
|
|
|
export const updateGotenbergSettingsRequestSchema = z.object({
|
|
url: z.string().optional(),
|
|
username: z.string().optional(),
|
|
password: z.string().optional(),
|
|
})
|
|
export type UpdateGotenbergSettingsRequest = z.infer<typeof updateGotenbergSettingsRequestSchema>
|
|
|
|
export interface TeamAppearanceSettings {
|
|
hideAgent?: boolean
|
|
}
|
|
|
|
export interface TeamSettingsResponse {
|
|
transcode?: {
|
|
videoStrategy?: VideoTranscodeStrategy
|
|
videoResolutions?: VideoResolutionLadder[]
|
|
hardwareAcceleration?: HardwareAcceleration
|
|
threads?: number
|
|
hlsEnabled?: boolean
|
|
hlsResolutions?: HlsResolutionLadder[]
|
|
}
|
|
turntable?: TurntableSettingsResponse
|
|
gotenberg?: GotenbergSettingsResponse
|
|
appearance?: TeamAppearanceSettings
|
|
semanticSearchEnabled?: boolean
|
|
[key: string]: unknown
|
|
}
|
|
|
|
export const sandboxSettingsSchema = z.object({
|
|
networkSandboxEnabled: z.boolean(),
|
|
allowedDomains: z.array(z.string()),
|
|
pendingDomains: z.array(z.string()).default([]),
|
|
})
|
|
export type SandboxSettings = z.infer<typeof sandboxSettingsSchema>
|
|
|
|
export const updateSandboxSettingsRequestSchema = z.object({
|
|
networkSandboxEnabled: z.boolean().optional(),
|
|
allowedDomains: z.array(z.string()).optional(),
|
|
pendingDomains: z.array(z.string()).optional(),
|
|
})
|
|
export type UpdateSandboxSettingsRequest = z.infer<typeof updateSandboxSettingsRequestSchema>
|
|
|
|
export const updateTeamMemberRoleRequestSchema = z.object({
|
|
role: z.enum(['editor', 'reviewer']),
|
|
})
|
|
export type UpdateTeamMemberRoleRequest = z.infer<typeof updateTeamMemberRoleRequestSchema>
|
|
|
|
// Service Layer Interfaces
|
|
export interface ServiceCreateTeamRequest {
|
|
name: string
|
|
}
|
|
|
|
export interface ServiceGetUserTeamsRequest {
|
|
userId: string
|
|
pagination: z.infer<typeof paginationParamsSchema>
|
|
}
|
|
|
|
export interface ServiceJoinTeamRequest {
|
|
teamId: string
|
|
userId: string
|
|
}
|
|
|
|
export interface ServiceGetMeRequest {
|
|
teamId: string
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
user: any
|
|
}
|
|
|
|
export interface ServiceGetTeamMembersRequest {
|
|
teamId: string
|
|
userId: string
|
|
includeAgents?: boolean
|
|
}
|
|
|
|
export interface ServiceUpdateTeamMemberRoleRequest {
|
|
teamId: string
|
|
userId: string
|
|
role: 'editor' | 'reviewer'
|
|
}
|