mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const agentTypeSchema = z.enum(['chat', 'autofill', 'embedding', 'transcription'])
|
||||
export type AgentType = z.infer<typeof agentTypeSchema>
|
||||
|
||||
export const agentSkillSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
skillId: z.string(),
|
||||
skill: z
|
||||
.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
export type AgentSkill = z.infer<typeof agentSkillSchema>
|
||||
|
||||
export const agentInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
type: agentTypeSchema,
|
||||
enabled: z.boolean(),
|
||||
avatar: z.string().optional(),
|
||||
providerId: z.string().optional(),
|
||||
modelId: z.string().optional(),
|
||||
thinkingLevel: z.string().optional().default(''),
|
||||
systemPrompt: z.string().optional(),
|
||||
soul: z.string().optional(),
|
||||
skills: z.array(agentSkillSchema).optional(),
|
||||
})
|
||||
export type AgentInfo = z.infer<typeof agentInfoSchema>
|
||||
|
||||
const baseAgentRequest = z.object({
|
||||
name: z.string().min(1),
|
||||
type: agentTypeSchema,
|
||||
enabled: z.boolean().optional().default(true),
|
||||
avatar: z.string().optional(),
|
||||
providerId: z.string().optional(),
|
||||
modelId: z.string().optional(),
|
||||
thinkingLevel: z.string().optional().default(''),
|
||||
systemPrompt: z.string().optional(),
|
||||
soul: z.string().optional(),
|
||||
skills: z.array(z.string()).optional(),
|
||||
})
|
||||
|
||||
export const createAgentRequestSchema = baseAgentRequest.superRefine((data, ctx) => {
|
||||
if (data.type === 'chat' || data.type === 'autofill') {
|
||||
if (!data.providerId) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'providerId is required for chat/autofill agents',
|
||||
path: ['providerId'],
|
||||
})
|
||||
}
|
||||
if (!data.modelId) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'modelId is required for chat/autofill agents',
|
||||
path: ['modelId'],
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
export type CreateAgentRequest = z.infer<typeof createAgentRequestSchema>
|
||||
|
||||
export const updateAgentRequestSchema = baseAgentRequest.superRefine((data, ctx) => {
|
||||
if (data.type === 'chat' || data.type === 'autofill') {
|
||||
if (!data.providerId) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'providerId is required for chat/autofill agents',
|
||||
path: ['providerId'],
|
||||
})
|
||||
}
|
||||
if (!data.modelId) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'modelId is required for chat/autofill agents',
|
||||
path: ['modelId'],
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
export type UpdateAgentRequest = z.infer<typeof updateAgentRequestSchema>
|
||||
|
||||
export interface CreateAgentParams extends CreateAgentRequest {
|
||||
teamId: string
|
||||
}
|
||||
|
||||
export interface UpdateAgentParams extends UpdateAgentRequest {
|
||||
agentId: string
|
||||
}
|
||||
|
||||
export interface DeleteAgentParams {
|
||||
agentId: string
|
||||
}
|
||||
|
||||
export interface ListAgentsParams {
|
||||
teamId: string
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export enum AiProvider {
|
||||
OpenAi = 'openai',
|
||||
Google = 'google',
|
||||
Anthropic = 'anthropic',
|
||||
ElevenLabs = 'elevenlabs',
|
||||
}
|
||||
|
||||
export const aiProviderSettingsSchema = z.object({
|
||||
apiKey: z.string().optional(),
|
||||
baseUrl: z.string().optional(),
|
||||
chatModels: z.array(z.string()).optional(),
|
||||
transcribeModels: z.array(z.string()).optional(),
|
||||
})
|
||||
|
||||
export type AiProviderSettings = z.infer<typeof aiProviderSettingsSchema>
|
||||
@@ -0,0 +1,261 @@
|
||||
import { z } from 'zod'
|
||||
import { paginationPageInfoSchema, paginationParamsSchema } from './pagination'
|
||||
|
||||
export const assetInfoPaginatedListSchema = z.object({
|
||||
data: z.array(z.lazy(() => assetInfoSchema)),
|
||||
pageInfo: paginationPageInfoSchema,
|
||||
})
|
||||
export type AssetInfoPaginatedList = z.infer<typeof assetInfoPaginatedListSchema>
|
||||
|
||||
export const previewInfoSchema = z.object({
|
||||
mediaType: z.string().nullable(),
|
||||
thumbnailUrl: z.string().optional(),
|
||||
originalHeight: z.number().optional(),
|
||||
originalWidth: z.number().optional(),
|
||||
spriteUrl: z.string().optional(),
|
||||
})
|
||||
export type PreviewInfo = z.infer<typeof previewInfoSchema>
|
||||
|
||||
export const childPreviewSchema = z.object({
|
||||
type: z.string().nullable(),
|
||||
preview: previewInfoSchema.nullable(),
|
||||
})
|
||||
export type ChildPreview = z.infer<typeof childPreviewSchema>
|
||||
|
||||
export const userInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
})
|
||||
export type UserInfo = z.infer<typeof userInfoSchema>
|
||||
|
||||
export const fieldValueInfoSchema = z.object({
|
||||
fieldId: z.string(),
|
||||
|
||||
value: z.any(),
|
||||
})
|
||||
export type FieldValueInfo = z.infer<typeof fieldValueInfoSchema>
|
||||
|
||||
export const ancestorFolderSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
})
|
||||
export type AncestorFolder = z.infer<typeof ancestorFolderSchema>
|
||||
|
||||
export const mediaMetadataSchema = z.object({
|
||||
duration: z.number().optional(),
|
||||
originalWidth: z.number().optional(),
|
||||
originalHeight: z.number().optional(),
|
||||
frameRate: z.number().optional(),
|
||||
})
|
||||
export type MediaMetadata = z.infer<typeof mediaMetadataSchema>
|
||||
|
||||
export const assetInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
sizeByte: z.number(),
|
||||
fileCount: z.number(),
|
||||
type: z.string(),
|
||||
targetType: z.string().optional().nullable(),
|
||||
status: z.string(),
|
||||
mediaType: z.string().nullable(),
|
||||
latestChildren: z.array(childPreviewSchema).optional(),
|
||||
preview: previewInfoSchema.nullable().optional(),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
deletedAt: z.string().nullable().optional(),
|
||||
creator: userInfoSchema.nullable().optional(),
|
||||
fieldValues: z.array(fieldValueInfoSchema).optional(),
|
||||
sortIndex: z.string().optional().nullable(),
|
||||
|
||||
media: z
|
||||
.object({
|
||||
original: z.object({ downloadUrl: z.string(), key: z.string().optional() }).optional(),
|
||||
videoTranscodes: z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
url: z.string(),
|
||||
key: z.string(),
|
||||
width: z.number(),
|
||||
height: z.number(),
|
||||
size: z.number(),
|
||||
isRaw: z.boolean(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
imageTranscodes: z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
url: z.string(),
|
||||
key: z.string(),
|
||||
width: z.number(),
|
||||
height: z.number(),
|
||||
size: z.number(),
|
||||
isRaw: z.boolean(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
videoPreview: z.object({ url: z.string(), key: z.string().optional() }).optional(),
|
||||
mimeType: z.string().optional(),
|
||||
metadata: mediaMetadataSchema.optional(),
|
||||
})
|
||||
.optional(),
|
||||
ancestorFolders: z.array(ancestorFolderSchema).optional(),
|
||||
})
|
||||
export type AssetInfo = z.infer<typeof assetInfoSchema>
|
||||
|
||||
export const createAssetRequestSchema = z.object({
|
||||
name: z.string(),
|
||||
type: z.string(),
|
||||
projectId: z.string().optional(),
|
||||
parentId: z.string().optional(),
|
||||
key: z.string().optional(),
|
||||
sizeByte: z.number().optional(),
|
||||
contentType: z.string().optional(),
|
||||
creatorId: z.string().optional(),
|
||||
})
|
||||
export type CreateAssetRequest = z.infer<typeof createAssetRequestSchema>
|
||||
|
||||
export const getAssetRequestSchema = z.object({
|
||||
assetId: z.string(),
|
||||
})
|
||||
export type GetAssetRequest = z.infer<typeof getAssetRequestSchema>
|
||||
|
||||
export const updateAssetNameRequestSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
})
|
||||
export type UpdateAssetNameRequest = z.infer<typeof updateAssetNameRequestSchema>
|
||||
|
||||
export const listChildrenRequestSchema = z.object({
|
||||
assetId: z.string().optional(),
|
||||
assetType: z.string(),
|
||||
projectId: z.string().optional(),
|
||||
showRemoved: z.boolean().optional(),
|
||||
prefix: z.string().optional(),
|
||||
sort: z.string().optional(),
|
||||
order: z.string().optional(),
|
||||
// pagination props mixed in via merge
|
||||
...paginationParamsSchema.shape,
|
||||
})
|
||||
export type ListChildrenRequest = z.infer<typeof listChildrenRequestSchema>
|
||||
|
||||
export const createCommentRequestSchema = z.object({
|
||||
assetId: z.string(),
|
||||
userId: z.string(),
|
||||
replyToId: z.string().optional(),
|
||||
message: z.string(),
|
||||
|
||||
annotations: z.any().optional(),
|
||||
second: z.number().optional(),
|
||||
attachmentIds: z.array(z.string()),
|
||||
})
|
||||
export type CreateCommentRequest = z.infer<typeof createCommentRequestSchema>
|
||||
|
||||
export const attachmentInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
assetId: z.string(),
|
||||
url: z.string(),
|
||||
mediaType: z.string().nullable(),
|
||||
})
|
||||
export type AttachmentInfo = z.infer<typeof attachmentInfoSchema>
|
||||
|
||||
export type CommentInfo = {
|
||||
id: string
|
||||
assetId: string
|
||||
message: string | null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
annotations: any
|
||||
creator: UserInfo
|
||||
replies: CommentInfo[]
|
||||
attachments: AttachmentInfo[]
|
||||
mentions: UserInfo[]
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
isAi: boolean
|
||||
}
|
||||
|
||||
export const commentInfoSchema: z.ZodType<CommentInfo> = z.object({
|
||||
id: z.string(),
|
||||
assetId: z.string(),
|
||||
message: z.string().nullable(),
|
||||
|
||||
annotations: z.any(),
|
||||
creator: userInfoSchema,
|
||||
replies: z.array(z.lazy(() => commentInfoSchema)),
|
||||
attachments: z.array(attachmentInfoSchema),
|
||||
mentions: z.array(userInfoSchema),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
isAi: z.boolean(),
|
||||
})
|
||||
|
||||
export const reparentAssetsRequestSchema = z.object({
|
||||
newParentId: z.string(),
|
||||
assetIds: z.array(z.string()),
|
||||
creatorId: z.string().optional(),
|
||||
})
|
||||
export type ReparentAssetsRequest = z.infer<typeof reparentAssetsRequestSchema>
|
||||
|
||||
export const updateFileRequestSchema = z.object({
|
||||
name: z.string(),
|
||||
})
|
||||
export type UpdateFileRequest = z.infer<typeof updateFileRequestSchema>
|
||||
|
||||
export const updateAssetOrderRequestSchema = z.object({
|
||||
beforeIndex: z.string().optional(),
|
||||
afterIndex: z.string().optional(),
|
||||
})
|
||||
export type UpdateAssetOrderRequest = z.infer<typeof updateAssetOrderRequestSchema>
|
||||
|
||||
export const deleteFilesRequestSchema = z.object({
|
||||
ids: z.array(z.string()),
|
||||
})
|
||||
export type DeleteFilesRequest = z.infer<typeof deleteFilesRequestSchema>
|
||||
|
||||
export const restoreFilesRequestSchema = z.object({
|
||||
ids: z.array(z.string()),
|
||||
})
|
||||
export type RestoreFilesRequest = z.infer<typeof restoreFilesRequestSchema>
|
||||
|
||||
export const uploadFileRequestSchema = z.object({
|
||||
file: z.instanceof(File),
|
||||
})
|
||||
export type UploadFileRequest = z.infer<typeof uploadFileRequestSchema>
|
||||
|
||||
export const uploadTeamFileResponseSchema = z.object({
|
||||
key: z.string(),
|
||||
})
|
||||
export type UploadTeamFileResponse = z.infer<typeof uploadTeamFileResponseSchema>
|
||||
|
||||
export interface ImageTranscode {
|
||||
id: string
|
||||
url: string
|
||||
width: number
|
||||
height: number
|
||||
size: number
|
||||
isRaw: boolean
|
||||
}
|
||||
|
||||
export interface VideoTranscode {
|
||||
id: string
|
||||
url: string
|
||||
width: number
|
||||
height: number
|
||||
size: number
|
||||
isRaw: boolean
|
||||
}
|
||||
|
||||
export const postAttachmentRequestSchema = z.object({
|
||||
fileName: z.string(),
|
||||
contentType: z.string(),
|
||||
size: z.number(),
|
||||
})
|
||||
export type PostAttachmentRequest = z.infer<typeof postAttachmentRequestSchema>
|
||||
|
||||
export const postAttachmentResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
uploadUrl: z.string(),
|
||||
})
|
||||
export type PostAttachmentResponse = z.infer<typeof postAttachmentResponseSchema>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const signupInfoResponseSchema = z.object({
|
||||
userCount: z.number(),
|
||||
enablePublicSignup: z.boolean(),
|
||||
})
|
||||
|
||||
export type SignupInfoResponse = z.infer<typeof signupInfoResponseSchema>
|
||||
@@ -0,0 +1,22 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const createFolderRequestSchema = z.object({
|
||||
name: z.string(),
|
||||
parentId: z.string(),
|
||||
})
|
||||
export type CreateFolderRequest = z.infer<typeof createFolderRequestSchema>
|
||||
|
||||
export const updateFolderRequestSchema = z.object({
|
||||
name: z.string(),
|
||||
})
|
||||
export type UpdateFolderRequest = z.infer<typeof updateFolderRequestSchema>
|
||||
|
||||
export const deleteFoldersRequestSchema = z.object({
|
||||
ids: z.array(z.string()),
|
||||
})
|
||||
export type DeleteFoldersRequest = z.infer<typeof deleteFoldersRequestSchema>
|
||||
|
||||
export const restoreFoldersRequestSchema = z.object({
|
||||
ids: z.array(z.string()),
|
||||
})
|
||||
export type RestoreFoldersRequest = z.infer<typeof restoreFoldersRequestSchema>
|
||||
@@ -0,0 +1,32 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const inviteInfoSchema = z.object({
|
||||
code: z.string(),
|
||||
role: z.enum(['editor', 'reviewer', 'owner']),
|
||||
teamId: z.string(),
|
||||
teamName: z.string(),
|
||||
projectId: z.string().optional(),
|
||||
projectName: z.string().optional(),
|
||||
inviterName: z.string(),
|
||||
isUsed: z.boolean(),
|
||||
})
|
||||
|
||||
export type InviteInfo = z.infer<typeof inviteInfoSchema>
|
||||
|
||||
export const createTeamInviteRequestSchema = z.object({
|
||||
role: z.enum(['editor', 'reviewer']),
|
||||
})
|
||||
|
||||
export type CreateTeamInviteRequest = z.infer<typeof createTeamInviteRequestSchema>
|
||||
|
||||
export const createProjectInviteRequestSchema = z.object({
|
||||
role: z.enum(['editor', 'reviewer']),
|
||||
})
|
||||
|
||||
export type CreateProjectInviteRequest = z.infer<typeof createProjectInviteRequestSchema>
|
||||
|
||||
export const joinRequestSchema = z.object({
|
||||
code: z.string(),
|
||||
})
|
||||
|
||||
export type JoinRequest = z.infer<typeof joinRequestSchema>
|
||||
@@ -0,0 +1,80 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const FieldType = {
|
||||
text: 'text',
|
||||
longText: 'longText',
|
||||
select: 'select',
|
||||
selectMulti: 'selectMulti',
|
||||
rating: 'rating',
|
||||
number: 'number',
|
||||
toggle: 'toggle',
|
||||
date: 'date',
|
||||
} as const
|
||||
|
||||
export type FieldType = (typeof FieldType)[keyof typeof FieldType]
|
||||
|
||||
export const selectOptionSchema = z.object({
|
||||
id: z.string(),
|
||||
displayName: z.string(),
|
||||
color: z.string().optional(),
|
||||
})
|
||||
export type SelectOption = z.infer<typeof selectOptionSchema>
|
||||
|
||||
export const fieldConfigSchema = z.object({
|
||||
name: z.string(),
|
||||
type: z.enum(['text', 'longText', 'select', 'selectMulti', 'rating', 'number', 'toggle', 'date']),
|
||||
text: z.any().optional(),
|
||||
longText: z.any().optional(),
|
||||
select: z.any().optional(),
|
||||
selectMulti: z.any().optional(),
|
||||
rating: z.any().optional(),
|
||||
number: z.any().optional(),
|
||||
toggle: z.any().optional(),
|
||||
date: z.any().optional(),
|
||||
})
|
||||
|
||||
export const createFieldRequestSchema = z.object({
|
||||
key: z.string().optional(),
|
||||
label: z.string().optional(),
|
||||
scope: z.string().optional(),
|
||||
config: fieldConfigSchema,
|
||||
aiAutofill: z.boolean().default(false),
|
||||
description: z.string().default(''),
|
||||
})
|
||||
export type CreateFieldRequest = z.infer<typeof createFieldRequestSchema>
|
||||
|
||||
export const updateFieldRequestSchema = z.object({
|
||||
label: z.string().optional(),
|
||||
config: fieldConfigSchema,
|
||||
aiAutofill: z.boolean().optional(),
|
||||
description: z.string().optional(),
|
||||
})
|
||||
export type UpdateFieldRequest = z.infer<typeof updateFieldRequestSchema>
|
||||
|
||||
export const projectFieldOrderSchema = z.object({
|
||||
fieldId: z.string(),
|
||||
visible: z.boolean(),
|
||||
})
|
||||
export type ProjectFieldOrder = z.infer<typeof projectFieldOrderSchema>
|
||||
|
||||
export const updateProjectFieldsOrderRequestSchema = z.array(projectFieldOrderSchema)
|
||||
export type UpdateProjectFieldsOrderRequest = z.infer<typeof updateProjectFieldsOrderRequestSchema>
|
||||
|
||||
export const updateAssetMetadataRequestSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.any(),
|
||||
})
|
||||
export type UpdateAssetMetadataRequest = z.infer<typeof updateAssetMetadataRequestSchema>
|
||||
|
||||
export const updateAssetMetadataRequestListSchema = z.array(updateAssetMetadataRequestSchema)
|
||||
|
||||
export const fieldInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
config: fieldConfigSchema,
|
||||
scope: z.string(),
|
||||
readOnly: z.boolean(),
|
||||
visible: z.boolean(),
|
||||
description: z.string(),
|
||||
aiAutofill: z.boolean(),
|
||||
})
|
||||
export type FieldInfo = z.infer<typeof fieldInfoSchema>
|
||||
@@ -0,0 +1,75 @@
|
||||
import { z } from 'zod'
|
||||
import { NotificationType } from '@/generated/prisma/client'
|
||||
|
||||
export const teamUserInfoSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
role: z.string().optional(),
|
||||
})
|
||||
|
||||
export type TeamUserInfo = z.infer<typeof teamUserInfoSchema>
|
||||
|
||||
export const entityInfoSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
})
|
||||
|
||||
export type EntityInfo = z.infer<typeof entityInfoSchema>
|
||||
|
||||
export const assetPreviewSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
mediaType: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
preview: z.string().optional(),
|
||||
})
|
||||
|
||||
export type AssetPreview = z.infer<typeof assetPreviewSchema>
|
||||
|
||||
export const notificationInfoSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
creator: teamUserInfoSchema.optional(),
|
||||
type: z.string().optional(),
|
||||
team: entityInfoSchema.optional(),
|
||||
project: entityInfoSchema.optional(),
|
||||
asset: assetPreviewSchema.optional(),
|
||||
user: teamUserInfoSchema.optional(),
|
||||
createdAt: z.string().optional(),
|
||||
isRead: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export type NotificationInfo = z.infer<typeof notificationInfoSchema>
|
||||
|
||||
export const listNotificationsRequestSchema = z.object({
|
||||
unreadOnly: z
|
||||
.union([z.boolean(), z.string()])
|
||||
.transform((v) => v === true || v === 'true')
|
||||
.optional(),
|
||||
after: z.string().optional(),
|
||||
pageSize: z.coerce.number().optional(),
|
||||
})
|
||||
|
||||
export type ListNotificationsRequest = z.infer<typeof listNotificationsRequestSchema>
|
||||
|
||||
export const markNotificationReadRequestSchema = z.object({
|
||||
notificationId: z.string().min(1),
|
||||
})
|
||||
|
||||
export type MarkNotificationReadRequest = z.infer<typeof markNotificationReadRequestSchema>
|
||||
|
||||
// Service types
|
||||
export interface CreateNotificationRequest {
|
||||
type: NotificationType
|
||||
teamId: string
|
||||
projectId?: string
|
||||
creatorId?: string
|
||||
assetId?: string
|
||||
taskId?: string
|
||||
userId?: string
|
||||
commentMessage?: string // For parsing mentions
|
||||
}
|
||||
|
||||
export interface ListNotificationParams {
|
||||
unreadOnly?: boolean
|
||||
after?: string
|
||||
pageSize?: number
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const paginationPageInfoSchema = z.object({
|
||||
cursor: z.string().optional(),
|
||||
total: z.number().optional(),
|
||||
})
|
||||
|
||||
export type PaginationPageInfo = z.infer<typeof paginationPageInfoSchema>
|
||||
|
||||
export const paginationParamsSchema = z.object({
|
||||
first: z.coerce.number().optional(),
|
||||
after: z.string().optional(),
|
||||
includeCount: z
|
||||
.union([z.boolean(), z.string()])
|
||||
.transform((v) => v === true || v === 'true')
|
||||
.optional(),
|
||||
})
|
||||
|
||||
export type PaginationParams = z.infer<typeof paginationParamsSchema>
|
||||
@@ -0,0 +1,99 @@
|
||||
import { z } from 'zod'
|
||||
import { paginationPageInfoSchema, paginationParamsSchema } from './pagination'
|
||||
|
||||
export const createProjectRequestSchema = z.object({
|
||||
name: z.string(),
|
||||
coverImageKey: z.string().optional(),
|
||||
enableNotification: z.boolean().default(false),
|
||||
})
|
||||
export type CreateProjectRequest = z.infer<typeof createProjectRequestSchema>
|
||||
|
||||
export const updateProjectRequestSchema = z.object({
|
||||
name: z.string().optional(),
|
||||
coverImageKey: z.string().optional(),
|
||||
enableNotification: z.boolean().optional(),
|
||||
})
|
||||
export type UpdateProjectRequest = z.infer<typeof updateProjectRequestSchema>
|
||||
|
||||
export const projectInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
rootFolder: z.string().optional(),
|
||||
coverImage: z.string().optional(),
|
||||
coverImageKey: z.string().optional(),
|
||||
enableNotification: z.boolean(),
|
||||
updatedAt: z.union([z.string(), z.date()]),
|
||||
})
|
||||
export type ProjectInfo = z.infer<typeof projectInfoSchema>
|
||||
|
||||
export const listProjectsRequestSchema = z
|
||||
.object({
|
||||
sortBy: z.string().optional(),
|
||||
sortDirection: z.enum(['asc', 'desc']).optional(),
|
||||
})
|
||||
.merge(paginationParamsSchema)
|
||||
|
||||
export const listProjectsResponseSchema = z.object({
|
||||
data: z.array(projectInfoSchema),
|
||||
pageInfo: paginationPageInfoSchema,
|
||||
})
|
||||
|
||||
export const getProjectTeamResponseSchema = z.object({
|
||||
teamId: z.string(),
|
||||
})
|
||||
export type GetProjectTeamResponse = z.infer<typeof getProjectTeamResponseSchema>
|
||||
|
||||
export const projectUserInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
role: z.string(),
|
||||
})
|
||||
export type ProjectUserInfo = z.infer<typeof projectUserInfoSchema>
|
||||
|
||||
export const botInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
})
|
||||
export type BotInfo = z.infer<typeof botInfoSchema>
|
||||
|
||||
export const recentlyDeletedRequestSchema = z
|
||||
.object({
|
||||
assetType: z.string(),
|
||||
sort: z.enum(['createdAt', 'name', 'size']).optional(),
|
||||
order: z.enum(['asc', 'desc']).optional(),
|
||||
})
|
||||
.merge(paginationParamsSchema)
|
||||
|
||||
// Service Layer Interfaces
|
||||
export interface ServiceCreateProjectRequest {
|
||||
teamId: string
|
||||
name: string
|
||||
coverImageKey?: string
|
||||
enableNotification?: boolean
|
||||
}
|
||||
|
||||
export interface ServiceUpdateProjectRequest {
|
||||
projectId: string
|
||||
name?: string
|
||||
coverImageKey?: string
|
||||
enableNotification?: boolean
|
||||
}
|
||||
|
||||
export interface ServiceListProjectsRequest {
|
||||
teamId: string
|
||||
userId: string
|
||||
sortBy?: string
|
||||
sortDirection?: 'asc' | 'desc'
|
||||
pagination: z.infer<typeof paginationParamsSchema>
|
||||
}
|
||||
|
||||
export interface ServiceAddProjectMemberRequest {
|
||||
projectId: string
|
||||
userId: string
|
||||
role: string
|
||||
}
|
||||
|
||||
export interface ServiceListProjectMembersRequest {
|
||||
projectId: string
|
||||
includeAgents?: boolean
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { z } from 'zod'
|
||||
export { z }
|
||||
|
||||
// We define a serializable version of ProviderConfig for our API and DB
|
||||
// as the original ProviderConfig interface includes non-serializable fields (functions)
|
||||
export const providerModelConfigSchema = z.object({
|
||||
api: z.string().optional(),
|
||||
reasoning: z.boolean().default(false),
|
||||
input: z.array(z.enum(['text', 'image'])).default(['text']),
|
||||
contextWindow: z.number().int().positive().default(128000),
|
||||
maxTokens: z.number().int().positive().default(4096),
|
||||
cost: z.object({
|
||||
input: z.number().nonnegative().default(0),
|
||||
output: z.number().nonnegative().default(0),
|
||||
cacheRead: z.number().nonnegative().default(0),
|
||||
cacheWrite: z.number().nonnegative().default(0),
|
||||
}),
|
||||
})
|
||||
|
||||
export const providerModelSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
modelId: z.string().min(1, 'Model ID is required'),
|
||||
name: z.string().min(0).default(''),
|
||||
config: providerModelConfigSchema,
|
||||
})
|
||||
|
||||
export const providerConfigSchema = z.object({
|
||||
baseUrl: z.string().url('Must be a valid URL').optional().or(z.literal('')),
|
||||
apiKey: z.string().optional().or(z.literal('')),
|
||||
api: z.string().min(1, 'API Protocol is required'),
|
||||
headers: z.record(z.string(), z.string()).optional(),
|
||||
authHeader: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export type ProviderConfigSerializable = z.infer<typeof providerConfigSchema>
|
||||
|
||||
export const createProviderRequestSchema = z.object({
|
||||
name: z.string().min(1, 'Provider name is required'),
|
||||
config: providerConfigSchema,
|
||||
models: z.array(providerModelSchema).min(1, 'At least one model is required'),
|
||||
})
|
||||
|
||||
export const updateProviderRequestSchema = z.object({
|
||||
config: providerConfigSchema,
|
||||
models: z.array(providerModelSchema).min(1, 'At least one model is required'),
|
||||
})
|
||||
|
||||
export const providerResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
isBuiltin: z.boolean(),
|
||||
config: providerConfigSchema,
|
||||
models: z.array(providerModelSchema).optional(),
|
||||
modelsCount: z.number().optional(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
})
|
||||
|
||||
export type ProviderResponse = z.infer<typeof providerResponseSchema>
|
||||
@@ -0,0 +1,7 @@
|
||||
export interface ObjectInfo {
|
||||
key: string
|
||||
size: number
|
||||
lastModified: Date
|
||||
contentType: string
|
||||
eTag: string
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { z } from 'zod'
|
||||
import { paginationParamsSchema } from './pagination'
|
||||
|
||||
export const searchConditionOperatorSchema = z.enum([
|
||||
'is',
|
||||
'eq',
|
||||
'neq',
|
||||
'gt',
|
||||
'gte',
|
||||
'lt',
|
||||
'lte',
|
||||
'contains',
|
||||
'notContains',
|
||||
'isEmpty',
|
||||
'isNotEmpty',
|
||||
'in',
|
||||
'notIn',
|
||||
'hasAny',
|
||||
'hasAll',
|
||||
'hasNone',
|
||||
'isWithin',
|
||||
])
|
||||
export type SearchConditionOperator = z.infer<typeof searchConditionOperatorSchema>
|
||||
|
||||
export const searchConditionSchema = z.object({
|
||||
field: z.string(),
|
||||
operator: searchConditionOperatorSchema,
|
||||
value: z.any(),
|
||||
})
|
||||
export type SearchCondition = z.infer<typeof searchConditionSchema>
|
||||
|
||||
export const searchSortOrderSchema = z.enum(['asc', 'desc'])
|
||||
export type SearchSortOrder = z.infer<typeof searchSortOrderSchema>
|
||||
|
||||
export const searchSortSchema = z.object({
|
||||
field: z.string(),
|
||||
order: searchSortOrderSchema,
|
||||
})
|
||||
export type SearchSort = z.infer<typeof searchSortSchema>
|
||||
|
||||
export const searchOperatorSchema = z.enum(['AND', 'OR'])
|
||||
export type SearchOperator = z.infer<typeof searchOperatorSchema>
|
||||
|
||||
export const searchAssetTypeSchema = z.enum(['file', 'folder'])
|
||||
export type SearchAssetType = z.infer<typeof searchAssetTypeSchema>
|
||||
|
||||
export const searchRequestSchema = z
|
||||
.object({
|
||||
operator: searchOperatorSchema.optional().default('AND'),
|
||||
conditions: z.array(searchConditionSchema).optional().default([]),
|
||||
sort: searchSortSchema.optional(),
|
||||
|
||||
assetType: searchAssetTypeSchema.optional(),
|
||||
showSymlink: z.boolean().optional(),
|
||||
recursively: z.boolean().optional().default(true),
|
||||
query: z.string().optional(),
|
||||
})
|
||||
.merge(paginationParamsSchema)
|
||||
export type SearchRequest = z.infer<typeof searchRequestSchema>
|
||||
@@ -0,0 +1,52 @@
|
||||
import { z } from 'zod'
|
||||
import { paginationParamsSchema } from './pagination'
|
||||
|
||||
export interface ShareLinkInfo {
|
||||
id: string
|
||||
name: string
|
||||
expireAt?: string
|
||||
isDisabled: boolean
|
||||
hasPassword: boolean
|
||||
defaultSortOrder?: string
|
||||
fieldVisibility?: Record<string, boolean>
|
||||
rootFolderId: string
|
||||
projectId: string
|
||||
isExpired: boolean
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export const createShareLinkRequestSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
expireAt: z.string().datetime().optional(),
|
||||
password: z.string().optional(),
|
||||
isDisabled: z.boolean().optional(),
|
||||
defaultSortOrder: z.string().optional(),
|
||||
})
|
||||
|
||||
export type CreateShareLinkRequest = z.infer<typeof createShareLinkRequestSchema>
|
||||
|
||||
export const updateShareLinkRequestSchema = z.object({
|
||||
name: z.string().min(1).optional(),
|
||||
expireAt: z.string().datetime().optional().nullable(),
|
||||
password: z.string().optional().nullable(),
|
||||
isDisabled: z.boolean().optional(),
|
||||
defaultSortOrder: z.string().optional().nullable(),
|
||||
fieldVisibility: z.record(z.string(), z.boolean()).optional().nullable(),
|
||||
})
|
||||
|
||||
export type UpdateShareLinkRequest = z.infer<typeof updateShareLinkRequestSchema>
|
||||
|
||||
export const listShareLinksRequestSchema = paginationParamsSchema.extend({
|
||||
projectId: z.string().optional(), // projectId can come from param
|
||||
})
|
||||
|
||||
export type ListShareLinksRequest = z.infer<typeof listShareLinksRequestSchema> & {
|
||||
projectId: string
|
||||
}
|
||||
|
||||
export const addAssetToShareRequestSchema = z.object({
|
||||
assetIds: z.array(z.string().min(1)).min(1),
|
||||
})
|
||||
|
||||
export type AddAssetToShareRequest = z.infer<typeof addAssetToShareRequestSchema>
|
||||
@@ -0,0 +1,37 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export interface SkillInfo {
|
||||
id: string
|
||||
name: string
|
||||
description: string | null
|
||||
config: PrismaJson.SkillConfig | null
|
||||
assetId: string
|
||||
hash: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export const upsertSkillRequestSchema = z.object({
|
||||
assetId: z.string().optional(),
|
||||
githubUrl: z.string().optional(),
|
||||
override: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export type UpsertSkillRequest = z.infer<typeof upsertSkillRequestSchema>
|
||||
|
||||
export const updateSkillConfigRequestSchema = z.object({
|
||||
config: z.object({
|
||||
environmentVariables: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
default: z.string().optional(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
})
|
||||
|
||||
export type UpdateSkillConfigRequest = z.infer<typeof updateSkillConfigRequestSchema>
|
||||
|
||||
export interface ListSkillsResponse {
|
||||
skills: SkillInfo[]
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import { z } from 'zod'
|
||||
import { paginationPageInfoSchema, paginationParamsSchema } from './pagination'
|
||||
import { UserType } from '@/generated/prisma/enums'
|
||||
|
||||
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.string(),
|
||||
})
|
||||
export type GetMeResponse = z.infer<typeof getMeResponseSchema>
|
||||
|
||||
export const userInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
role: z.string(),
|
||||
email: z.string().optional(),
|
||||
type: z.nativeEnum(UserType).optional(),
|
||||
})
|
||||
export type UserInfo = z.infer<typeof userInfoSchema>
|
||||
|
||||
export const listMembersQuerySchema = z.object({
|
||||
includeAgents: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((v) => v === 'true'),
|
||||
})
|
||||
|
||||
export const updateTeamSettingsRequestSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.any(),
|
||||
})
|
||||
export type UpdateTeamSettingsRequest = z.infer<typeof updateTeamSettingsRequestSchema>
|
||||
|
||||
export const VideoTranscodeStrategy = {
|
||||
disable: 'disable',
|
||||
single: 'single',
|
||||
full: 'full',
|
||||
} as const
|
||||
export type VideoTranscodeStrategy =
|
||||
(typeof VideoTranscodeStrategy)[keyof typeof VideoTranscodeStrategy]
|
||||
|
||||
export const ImageTranscodeStrategy = {
|
||||
disable: 'disable',
|
||||
single: 'single',
|
||||
} as const
|
||||
export type ImageTranscodeStrategy =
|
||||
(typeof ImageTranscodeStrategy)[keyof typeof ImageTranscodeStrategy]
|
||||
|
||||
// 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
|
||||
includeAgents?: boolean
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export type FileNode = {
|
||||
name: string
|
||||
id: string
|
||||
size: number
|
||||
children: FileNode[]
|
||||
type: string
|
||||
mediaType?: string
|
||||
}
|
||||
|
||||
export const fileNodeSchema: z.ZodType<FileNode> = z.lazy(() =>
|
||||
z.object({
|
||||
name: z.string(),
|
||||
id: z.string(),
|
||||
size: z.number(),
|
||||
children: z.array(fileNodeSchema),
|
||||
type: z.string(),
|
||||
mediaType: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
|
||||
export const createUploadTaskRequestSchema = z.object({
|
||||
parentId: z.string(),
|
||||
files: z.array(fileNodeSchema),
|
||||
})
|
||||
export type CreateUploadTaskRequest = z.infer<typeof createUploadTaskRequestSchema>
|
||||
|
||||
export const presignedUrlSchema = z.object({
|
||||
id: z.string(),
|
||||
fileId: z.string(),
|
||||
url: z.string(),
|
||||
})
|
||||
export type PresignedUrl = z.infer<typeof presignedUrlSchema>
|
||||
|
||||
export const createUploadTaskResponseSchema = z.object({
|
||||
taskId: z.string(),
|
||||
presignedUrls: z.array(presignedUrlSchema),
|
||||
})
|
||||
export type CreateUploadTaskResponse = z.infer<typeof createUploadTaskResponseSchema>
|
||||
|
||||
export const confirmFileUploadRequestSchema = z.object({
|
||||
fileId: z.string(),
|
||||
errorMessage: z.string().optional(),
|
||||
})
|
||||
export type ConfirmFileUploadRequest = z.infer<typeof confirmFileUploadRequestSchema>
|
||||
|
||||
export const taskInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
total: z.number(),
|
||||
uploaded: z.number(),
|
||||
createdAt: z.string(),
|
||||
})
|
||||
export type TaskInfo = z.infer<typeof taskInfoSchema>
|
||||
|
||||
export const localUploadQuerySchema = z.object({
|
||||
bucket: z.string(),
|
||||
key: z.string(),
|
||||
Signature: z.string(),
|
||||
})
|
||||
export type LocalUploadQuery = z.infer<typeof localUploadQuerySchema>
|
||||
|
||||
export const localUploadBodySchema = z.object({
|
||||
file: z.instanceof(File),
|
||||
})
|
||||
export type LocalUploadBody = z.infer<typeof localUploadBodySchema>
|
||||
@@ -0,0 +1,15 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const userMetadataItemSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.unknown(),
|
||||
})
|
||||
export type UserMetadataItem = z.infer<typeof userMetadataItemSchema>
|
||||
|
||||
export const updateUserMetadataRequestSchema = z.object({
|
||||
value: z.unknown(),
|
||||
})
|
||||
export type UpdateUserMetadataRequest = z.infer<typeof updateUserMetadataRequestSchema>
|
||||
|
||||
export const listUserMetadataResponseSchema = z.array(userMetadataItemSchema)
|
||||
export type ListUserMetadataResponse = z.infer<typeof listUserMetadataResponseSchema>
|
||||
@@ -0,0 +1,24 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const createVersionStackRequestSchema = z.object({
|
||||
fileIds: z.array(z.string()),
|
||||
})
|
||||
export type CreateVersionStackRequest = z.infer<typeof createVersionStackRequestSchema>
|
||||
|
||||
export interface CreateVersionStackParams {
|
||||
fileIds: string[]
|
||||
projectId: string
|
||||
creatorId: string
|
||||
}
|
||||
|
||||
export const changeStackFileVersionRequestSchema = z.object({
|
||||
fileId: z.string(),
|
||||
beforeId: z.string(),
|
||||
})
|
||||
export type ChangeStackFileVersionRequest = z.infer<typeof changeStackFileVersionRequestSchema>
|
||||
|
||||
export interface ChangeStackFileVersionParams {
|
||||
stackId: string
|
||||
fileId: string
|
||||
beforeId: string
|
||||
}
|
||||
Reference in New Issue
Block a user