mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 21:04:59 +00:00
refactor: establish workspaces and extract db and dtos packages
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { type SessionTreeEntry } from '@earendil-works/pi-agent-core'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { ulid } from 'ulid'
|
||||
import {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { createReadSkillTool } from './read-skill'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import * as fs from 'fs'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { Type } from '@sinclair/typebox'
|
||||
import { type AgentTool } from '@earendil-works/pi-agent-core'
|
||||
import { agentService } from '@/services/agent/agent'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { workflowService } from '@/workflow/workflow'
|
||||
import { WorkflowTaskType, WorkflowTaskStatus } from '@/generated/prisma/client'
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import {
|
||||
updateAgentRequestSchema,
|
||||
AgentInfo,
|
||||
AgentType,
|
||||
} from '@/dtos/agent'
|
||||
} from '@shumai/dtos'
|
||||
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Hono } from 'hono'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { postAttachmentRequestSchema } from '@/dtos/asset'
|
||||
import { postAttachmentRequestSchema } from '@shumai/dtos'
|
||||
import { assetService } from '@/services/asset/asset'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { AssetType } from '@/generated/prisma/client'
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { teamService } from '@/services/team/team'
|
||||
import { auth } from '@/services/auth/auth'
|
||||
import { z } from 'zod'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { ulid } from 'ulid'
|
||||
|
||||
const app = new Hono()
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
listCollectionsRequestSchema,
|
||||
CollectionInfo,
|
||||
CollectionFilter,
|
||||
} from '@/dtos/collection'
|
||||
} from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { Hono, type Context, type Next } from 'hono'
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import fileRoute from './file'
|
||||
import { assetService } from '@/services/asset/asset'
|
||||
import { metadataService } from '@/services/metadata/metadata'
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
import { Hono } from 'hono'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { authzService, Permission, ResourceType } from '@/services/authz/authz'
|
||||
import { assetService } from '@/services/asset/asset'
|
||||
import { metadataService } from '@/services/metadata/metadata'
|
||||
@@ -13,9 +13,9 @@ import {
|
||||
restoreFilesRequestSchema,
|
||||
createCommentRequestSchema,
|
||||
uploadFileRequestSchema,
|
||||
} from '@/dtos/asset'
|
||||
import { updateAssetMetadataRequestSchema } from '@/dtos/metadata'
|
||||
import { paginationParamsSchema } from '@/dtos/pagination'
|
||||
} from '@shumai/dtos'
|
||||
import { updateAssetMetadataRequestSchema } from '@shumai/dtos'
|
||||
import { paginationParamsSchema } from '@shumai/dtos'
|
||||
import { ulid } from 'ulid'
|
||||
import { z } from 'zod'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ import {
|
||||
updateFolderRequestSchema,
|
||||
deleteFoldersRequestSchema,
|
||||
restoreFoldersRequestSchema,
|
||||
} from '@/dtos/folder'
|
||||
import { listChildrenRequestSchema, updateAssetOrderRequestSchema } from '@/dtos/asset'
|
||||
import { searchRequestSchema } from '@/dtos/search'
|
||||
} from '@shumai/dtos'
|
||||
import { listChildrenRequestSchema, updateAssetOrderRequestSchema } from '@shumai/dtos'
|
||||
import { searchRequestSchema } from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
createTeamInviteRequestSchema,
|
||||
joinRequestSchema,
|
||||
InviteInfo,
|
||||
} from '@/dtos/invite'
|
||||
} from '@shumai/dtos'
|
||||
import { authzService, Permission, ResourceType } from '@/services/authz/authz'
|
||||
import { inviteService } from '@/services/invite/invite'
|
||||
import { notificationService } from '@/services/notification/notification'
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import {
|
||||
updateFieldRequestSchema,
|
||||
updateProjectFieldsOrderRequestSchema,
|
||||
FieldInfo,
|
||||
} from '@/dtos/metadata'
|
||||
} from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
import { auth } from '@/services/auth/auth'
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { createMiddleware } from 'hono/factory'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
listNotificationsRequestSchema,
|
||||
markNotificationReadRequestSchema,
|
||||
notificationSettingsSchema,
|
||||
} from '@/dtos/notification'
|
||||
} from '@shumai/dtos'
|
||||
import { userMetadataService } from '@/services/user-metadata/user-metadata'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
|
||||
+3
-3
@@ -3,14 +3,14 @@ import { zValidator } from '@hono/zod-validator'
|
||||
import { authzService, Permission, ResourceType } from '@/services/authz/authz'
|
||||
import { projectService } from '@/services/project/project'
|
||||
import { assetService } from '@/services/asset/asset'
|
||||
import { reparentAssetsRequestSchema, copyAssetsRequestSchema } from '@/dtos/asset'
|
||||
import { reparentAssetsRequestSchema, copyAssetsRequestSchema } from '@shumai/dtos'
|
||||
import {
|
||||
createProjectRequestSchema,
|
||||
updateProjectRequestSchema,
|
||||
listProjectsRequestSchema,
|
||||
recentlyDeletedRequestSchema,
|
||||
} from '@/dtos/project'
|
||||
import { listMembersQuerySchema } from '@/dtos/team'
|
||||
} from '@shumai/dtos'
|
||||
import { listMembersQuerySchema } from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { zValidator } from '@hono/zod-validator'
|
||||
import { Hono } from 'hono'
|
||||
import { authzService, Permission, ResourceType } from '@/services/authz/authz'
|
||||
import { providerService } from '@/services/provider/provider'
|
||||
import { createProviderRequestSchema, updateProviderRequestSchema } from '@/dtos/provider'
|
||||
import { createProviderRequestSchema, updateProviderRequestSchema } from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Hono } from 'hono'
|
||||
import { inviteService } from '@/services/invite/invite'
|
||||
import { InviteInfo } from '@/dtos/invite'
|
||||
import { InviteInfo } from '@shumai/dtos'
|
||||
|
||||
const app = new Hono()
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ import { Hono } from 'hono'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { shareService } from '@/services/share/share'
|
||||
import { assetService } from '@/services/asset/asset'
|
||||
import { paginationParamsSchema } from '@/dtos/pagination'
|
||||
import { paginationParamsSchema } from '@shumai/dtos'
|
||||
import { z } from 'zod'
|
||||
import { metadataService } from '@/services/metadata/metadata'
|
||||
import { FieldInfo } from '@/dtos/metadata'
|
||||
import { FieldInfo } from '@shumai/dtos'
|
||||
import type { Prisma as PrismaType } from '@/generated/prisma/client'
|
||||
import { auth } from '@/services/auth/auth'
|
||||
import { prisma } from '@/db'
|
||||
import { createCommentRequestSchema } from '@/dtos/asset'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { createCommentRequestSchema } from '@shumai/dtos'
|
||||
import { notificationService } from '@/services/notification/notification'
|
||||
|
||||
const app = new Hono()
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import {
|
||||
updateShareLinkRequestSchema,
|
||||
listShareLinksRequestSchema,
|
||||
addAssetToShareRequestSchema,
|
||||
} from '@/dtos/share'
|
||||
} from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { Hono } from 'hono'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { authzService, Permission, ResourceType } from '@/services/authz/authz'
|
||||
import { skillService } from '@/services/skill/skill'
|
||||
import { upsertSkillRequestSchema, updateSkillConfigRequestSchema } from '@/dtos/skill'
|
||||
import { upsertSkillRequestSchema, updateSkillConfigRequestSchema } from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ import {
|
||||
updateTeamSettingsRequestSchema,
|
||||
listMembersQuerySchema,
|
||||
updateSandboxSettingsRequestSchema,
|
||||
} from '@/dtos/team'
|
||||
import { updateUserMetadataRequestSchema } from '@/dtos/user-metadata'
|
||||
} from '@shumai/dtos'
|
||||
import { updateUserMetadataRequestSchema } from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Hono } from 'hono'
|
||||
import uploadRoute from './upload'
|
||||
import { authMiddleware } from '@/api/middleware/auth'
|
||||
import { uploadService } from '@/services/upload/upload'
|
||||
import type { CreateUploadTaskResponse, TaskInfo } from '@/dtos/upload'
|
||||
import type { CreateUploadTaskResponse, TaskInfo } from '@shumai/dtos'
|
||||
import type { PaginatedData } from '@/services/pagination'
|
||||
import { authzService, ResourceType, Permission } from '@/services/authz/authz'
|
||||
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ import {
|
||||
confirmFileUploadRequestSchema,
|
||||
createUploadTaskRequestSchema,
|
||||
localUploadQuerySchema,
|
||||
} from '@/dtos/upload'
|
||||
import { paginationParamsSchema } from '@/dtos/pagination'
|
||||
} from '@shumai/dtos'
|
||||
import { paginationParamsSchema } from '@shumai/dtos'
|
||||
import { authzService, Permission, ResourceType } from '@/services/authz/authz'
|
||||
import { notificationService } from '@/services/notification/notification'
|
||||
import { NotificationType } from '@/generated/prisma/client'
|
||||
|
||||
@@ -3,10 +3,7 @@ import { zValidator } from '@hono/zod-validator'
|
||||
import { versionStackService } from '@/services/versionStack/versionStack'
|
||||
import { assetService } from '@/services/asset/asset'
|
||||
import { authzService, Permission, ResourceType } from '@/services/authz/authz'
|
||||
import {
|
||||
createVersionStackRequestSchema,
|
||||
changeStackFileVersionRequestSchema,
|
||||
} from '@/dtos/versionStack'
|
||||
import { createVersionStackRequestSchema, changeStackFileVersionRequestSchema } from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { afterEach, beforeEach } from 'vitest'
|
||||
import { getPrismaTestingHelper } from '@/db'
|
||||
|
||||
export function setupTestDbHooks() {
|
||||
beforeEach(async () => {
|
||||
await getPrismaTestingHelper().startNewTransaction()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
getPrismaTestingHelper().rollbackCurrentTransaction()
|
||||
})
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
import { PrismaClient } from '@/generated/prisma/client'
|
||||
import { PrismaTestingHelper } from '@/test-utils'
|
||||
import { PrismaPg } from '@prisma/adapter-pg'
|
||||
import { Pool } from 'pg'
|
||||
import { generateNgrams } from '@/utils/ngram'
|
||||
|
||||
const isTest = process.env.NODE_ENV === 'test'
|
||||
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined
|
||||
}
|
||||
|
||||
// We use any here because PrismaTestingHelper is generic and the extended client type is complex
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let prismaTestingHelper: PrismaTestingHelper<any> | null = null
|
||||
|
||||
function createPrismaClient() {
|
||||
const connectionString = process.env.DATABASE_URL
|
||||
const pool = new Pool({ connectionString })
|
||||
const adapter = new PrismaPg(pool)
|
||||
const client = new PrismaClient({ adapter, log: ['error'] })
|
||||
return client.$extends({
|
||||
query: {
|
||||
workflowTask: {
|
||||
async create({ args, query }) {
|
||||
const result = await query(args)
|
||||
// Lazy load workflowService to avoid circular dependency
|
||||
import('@/workflow/workflow').then((mod) => {
|
||||
const service = mod?.workflowService
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const task = result as any
|
||||
if (service && task.status === 'pending') {
|
||||
// result is the created task, but the extension types are complex
|
||||
service.submit(task).catch(console.error)
|
||||
}
|
||||
})
|
||||
return result
|
||||
},
|
||||
},
|
||||
asset: {
|
||||
async create({ args, query }) {
|
||||
if (typeof args.data.name === 'string') {
|
||||
args.data.nameNgram = generateNgrams(args.data.name)
|
||||
}
|
||||
return query(args)
|
||||
},
|
||||
async update({ args, query }) {
|
||||
if (typeof args.data.name === 'string') {
|
||||
args.data.nameNgram = generateNgrams(args.data.name)
|
||||
}
|
||||
return query(args)
|
||||
},
|
||||
async upsert({ args, query }) {
|
||||
if (typeof args.create.name === 'string') {
|
||||
args.create.nameNgram = generateNgrams(args.create.name)
|
||||
}
|
||||
if (typeof args.update.name === 'string') {
|
||||
args.update.nameNgram = generateNgrams(args.update.name)
|
||||
}
|
||||
return query(args)
|
||||
},
|
||||
async updateMany({ args, query }) {
|
||||
if (typeof args.data.name === 'string') {
|
||||
args.data.nameNgram = generateNgrams(args.data.name)
|
||||
}
|
||||
return query(args)
|
||||
},
|
||||
async createMany({ args, query }) {
|
||||
if (Array.isArray(args.data)) {
|
||||
for (const item of args.data) {
|
||||
if (typeof item.name === 'string') {
|
||||
item.nameNgram = generateNgrams(item.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return query(args)
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const prisma = (isTest
|
||||
? getPrismaTestingHelper().getProxyClient()
|
||||
: (globalForPrisma.prisma ?? createPrismaClient())) as unknown as PrismaClient
|
||||
|
||||
if (!isTest && process.env.NODE_ENV !== 'production') {
|
||||
globalForPrisma.prisma = prisma
|
||||
}
|
||||
|
||||
export function getPrismaTestingHelper() {
|
||||
if (!prismaTestingHelper) {
|
||||
prismaTestingHelper = new PrismaTestingHelper(createPrismaClient())
|
||||
}
|
||||
return prismaTestingHelper
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const agentTypeSchema = z.enum(['chat', 'autofill', 'embedding'])
|
||||
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
|
||||
}
|
||||
|
||||
export const agentSessionEntrySchema = z.object({
|
||||
id: z.string(),
|
||||
sessionId: z.string(),
|
||||
entry: z.unknown(),
|
||||
})
|
||||
export type AgentSessionEntryInfo = z.infer<typeof agentSessionEntrySchema>
|
||||
@@ -1,16 +0,0 @@
|
||||
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(),
|
||||
})
|
||||
|
||||
export type AiProviderSettings = z.infer<typeof aiProviderSettingsSchema>
|
||||
@@ -1,295 +0,0 @@
|
||||
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(),
|
||||
startTime: z.number().optional().nullable(),
|
||||
endTime: z.number().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(),
|
||||
versionStack: z
|
||||
.object({
|
||||
id: z.string(),
|
||||
versions: z.array(
|
||||
z.object({
|
||||
version: z.number(),
|
||||
current: z.boolean(),
|
||||
id: z.string(),
|
||||
name: z.string().optional().nullable(),
|
||||
previewUrl: z.string().optional().nullable(),
|
||||
creator: z
|
||||
.object({
|
||||
id: z.string(),
|
||||
name: z.string().nullable(),
|
||||
})
|
||||
.nullable()
|
||||
.optional(),
|
||||
}),
|
||||
),
|
||||
})
|
||||
.optional()
|
||||
.nullable(),
|
||||
})
|
||||
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(),
|
||||
showDeleted: 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
|
||||
second: number | null
|
||||
creator: UserInfo
|
||||
replies: CommentInfo[]
|
||||
attachments: AttachmentInfo[]
|
||||
mentions: UserInfo[]
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
sessionId: string | null
|
||||
}
|
||||
|
||||
export const commentInfoSchema: z.ZodType<CommentInfo> = z.object({
|
||||
id: z.string(),
|
||||
assetId: z.string(),
|
||||
message: z.string().nullable(),
|
||||
|
||||
annotations: z.any(),
|
||||
second: z.number().nullable(),
|
||||
creator: userInfoSchema,
|
||||
replies: z.array(z.lazy(() => commentInfoSchema)),
|
||||
attachments: z.array(attachmentInfoSchema),
|
||||
mentions: z.array(userInfoSchema),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
sessionId: z.string().nullable(),
|
||||
})
|
||||
|
||||
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 copyAssetsRequestSchema = z.object({
|
||||
newParentId: z.string(),
|
||||
assetIds: z.array(z.string()),
|
||||
withComments: z.boolean().default(false),
|
||||
creatorId: z.string().optional(),
|
||||
})
|
||||
export type CopyAssetsRequest = z.infer<typeof copyAssetsRequestSchema>
|
||||
|
||||
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>
|
||||
@@ -1,8 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const signupInfoResponseSchema = z.object({
|
||||
userCount: z.number(),
|
||||
enablePublicSignup: z.boolean(),
|
||||
})
|
||||
|
||||
export type SignupInfoResponse = z.infer<typeof signupInfoResponseSchema>
|
||||
@@ -1,49 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { searchFilterSchema } from './search'
|
||||
import { paginationParamsSchema } from './pagination'
|
||||
|
||||
export const collectionFilterSchema = z.object({
|
||||
sourceFolderId: z.string(),
|
||||
searchFilter: searchFilterSchema,
|
||||
})
|
||||
|
||||
export type CollectionFilter = z.infer<typeof collectionFilterSchema>
|
||||
|
||||
export const collectionSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
filter: collectionFilterSchema,
|
||||
projectId: z.string(),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
})
|
||||
|
||||
export type CollectionInfo = z.infer<typeof collectionSchema>
|
||||
|
||||
export const createCollectionRequestSchema = z.object({
|
||||
name: z.string(),
|
||||
filter: collectionFilterSchema,
|
||||
})
|
||||
|
||||
export type CreateCollectionRequest = z.infer<typeof createCollectionRequestSchema>
|
||||
|
||||
export const updateCollectionRequestSchema = z.object({
|
||||
name: z.string().optional(),
|
||||
filter: collectionFilterSchema.optional(),
|
||||
})
|
||||
|
||||
export type UpdateCollectionRequest = z.infer<typeof updateCollectionRequestSchema>
|
||||
|
||||
export const listCollectionsRequestSchema = paginationParamsSchema
|
||||
|
||||
export type ListCollectionsRequest = z.infer<typeof listCollectionsRequestSchema>
|
||||
|
||||
export const collectionListSchema = z.object({
|
||||
data: z.array(collectionSchema),
|
||||
pageInfo: z.object({
|
||||
cursor: z.string().optional(),
|
||||
total: z.number().optional(),
|
||||
}),
|
||||
})
|
||||
|
||||
export type CollectionList = z.infer<typeof collectionListSchema>
|
||||
@@ -1,22 +0,0 @@
|
||||
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>
|
||||
@@ -1,32 +0,0 @@
|
||||
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>
|
||||
@@ -1,80 +0,0 @@
|
||||
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>
|
||||
@@ -1,86 +0,0 @@
|
||||
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
|
||||
}
|
||||
|
||||
export const notificationSettingsSchema = z.object({
|
||||
comments: z.boolean().default(true),
|
||||
replies: z.boolean().default(true),
|
||||
mentions: z.boolean().default(true),
|
||||
yourUploads: z.boolean().default(false),
|
||||
otherUploads: z.boolean().default(true),
|
||||
statusUpdates: z.boolean().default(true),
|
||||
})
|
||||
|
||||
export type NotificationSettings = z.infer<typeof notificationSettingsSchema>
|
||||
@@ -1,19 +0,0 @@
|
||||
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>
|
||||
@@ -1,99 +0,0 @@
|
||||
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(true),
|
||||
})
|
||||
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
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
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>
|
||||
@@ -1,7 +0,0 @@
|
||||
export interface ObjectInfo {
|
||||
key: string
|
||||
size: number
|
||||
lastModified: Date
|
||||
contentType: string
|
||||
eTag: string
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
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 searchFilterSchema = 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(),
|
||||
isSemantic: z.boolean().optional().default(false),
|
||||
})
|
||||
export type SearchFilter = z.infer<typeof searchFilterSchema>
|
||||
|
||||
export const searchRequestSchema = searchFilterSchema.extend(paginationParamsSchema.shape)
|
||||
export type SearchRequest = z.infer<typeof searchRequestSchema>
|
||||
@@ -1,52 +0,0 @@
|
||||
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>
|
||||
@@ -1,37 +0,0 @@
|
||||
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[]
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
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(),
|
||||
unreadNotificationCount: z.number().optional(),
|
||||
})
|
||||
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 = {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
best_match: 'best_match',
|
||||
all: 'all',
|
||||
} as const
|
||||
export type VideoTranscodeStrategy =
|
||||
(typeof VideoTranscodeStrategy)[keyof typeof VideoTranscodeStrategy]
|
||||
|
||||
export const sandboxSettingsSchema = z.object({
|
||||
allowedDomains: z.array(z.string()),
|
||||
})
|
||||
export type SandboxSettings = z.infer<typeof sandboxSettingsSchema>
|
||||
|
||||
export const updateSandboxSettingsRequestSchema = sandboxSettingsSchema
|
||||
export type UpdateSandboxSettingsRequest = z.infer<typeof updateSandboxSettingsRequestSchema>
|
||||
|
||||
// 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
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
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>
|
||||
@@ -1,15 +0,0 @@
|
||||
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>
|
||||
@@ -1,24 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
export {}
|
||||
|
||||
import { SessionTreeEntry } from '@earendil-works/pi-agent-core'
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace PrismaJson {
|
||||
// ----------------------------------------------------------------------
|
||||
// Agent Session Entry
|
||||
// ----------------------------------------------------------------------
|
||||
export type PiSessionEntry = SessionTreeEntry
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// User Agent Settings
|
||||
// ----------------------------------------------------------------------
|
||||
export interface AgentSettings {
|
||||
role: string
|
||||
provider: string
|
||||
model: string
|
||||
thinkingLevel: string
|
||||
enableWebSearch: boolean
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Agent Config
|
||||
// ----------------------------------------------------------------------
|
||||
export interface AgentConfig {
|
||||
provider: string
|
||||
model: string
|
||||
thinkingLevel?: string
|
||||
systemPrompt?: string
|
||||
appendSystemPrompt?: string[]
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Team Ai Settings
|
||||
// ----------------------------------------------------------------------
|
||||
export type AiProvider = 'openai' | 'google' | 'elevenlabs'
|
||||
|
||||
export interface AiProviderSettings {
|
||||
apiKey?: string
|
||||
baseUrl?: string
|
||||
chatModels?: string[]
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Team Settings
|
||||
// ----------------------------------------------------------------------
|
||||
export type VideoTranscodeStrategy = 'best_match' | 'all'
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Collection Filter
|
||||
// ----------------------------------------------------------------------
|
||||
export type CollectionFilter = import('./dtos/collection').CollectionFilter
|
||||
|
||||
export interface TranscodeSettings {
|
||||
videoStrategy: VideoTranscodeStrategy
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
transcode: TranscodeSettings
|
||||
enablePublicSignup: boolean
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Project Metadata Overrides
|
||||
// ----------------------------------------------------------------------
|
||||
export type MetadataOverrides = Record<string, unknown>
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Asset Media Info
|
||||
// ----------------------------------------------------------------------
|
||||
export interface VideoTranscode {
|
||||
key?: string
|
||||
url?: string
|
||||
width: number
|
||||
height: number
|
||||
resolution?: string
|
||||
isRaw?: boolean
|
||||
}
|
||||
|
||||
export interface ImageTranscode {
|
||||
key?: string
|
||||
url?: string
|
||||
width: number
|
||||
height: number
|
||||
quality: number
|
||||
format: string
|
||||
isRaw?: boolean
|
||||
}
|
||||
|
||||
export interface SpriteInfo {
|
||||
frames: number
|
||||
tileX: number
|
||||
tileY: number
|
||||
key: string
|
||||
}
|
||||
|
||||
export interface PosterInfo {
|
||||
key: string
|
||||
}
|
||||
|
||||
export interface Metadata {
|
||||
originalHeight: number
|
||||
originalWidth: number
|
||||
hasAudio: boolean
|
||||
duration: number
|
||||
bitRate: number
|
||||
frameRate: number
|
||||
videoCodec?: string
|
||||
audioCodec?: string
|
||||
audioChannels?: number
|
||||
audioSampleRate?: number
|
||||
audioBitDepth?: number
|
||||
format: unknown
|
||||
}
|
||||
|
||||
export interface OriginalInfo {
|
||||
key: string
|
||||
downloadUrl: string
|
||||
filesizeInBytes: number
|
||||
codec: string
|
||||
}
|
||||
|
||||
export interface MediaInfo {
|
||||
duration: number
|
||||
filesize: number
|
||||
fps: number
|
||||
frames: number
|
||||
imageTranscodes: ImageTranscode[]
|
||||
videoTranscodes: VideoTranscode[]
|
||||
videoPreview: VideoTranscode
|
||||
sprite?: SpriteInfo
|
||||
poster?: PosterInfo
|
||||
thumbnail?: ImageTranscode
|
||||
finishedAt: string
|
||||
metadata: Metadata | null
|
||||
mimeType: string
|
||||
original: OriginalInfo | null
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Share Link Field Visibility
|
||||
// ----------------------------------------------------------------------
|
||||
export type ShareLinkFieldVisibility = Record<string, boolean>
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Asset Metadata Data
|
||||
// ----------------------------------------------------------------------
|
||||
export type AssetMetadataData = Record<string, unknown>
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Asset Comment Annotation
|
||||
// ----------------------------------------------------------------------
|
||||
export type AnnotationType = 'arrow' | 'line' | 'box' | 'freehand'
|
||||
|
||||
export interface Annotation {
|
||||
type: AnnotationType
|
||||
color: string
|
||||
points: number[][]
|
||||
}
|
||||
|
||||
export type AnnotationList = Annotation[]
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Metadata Field Config
|
||||
// ----------------------------------------------------------------------
|
||||
export type FieldType =
|
||||
| 'text'
|
||||
| 'longText'
|
||||
| 'select'
|
||||
| 'selectMulti'
|
||||
| 'rating'
|
||||
| 'number'
|
||||
| 'toggle'
|
||||
| 'date'
|
||||
|
||||
export interface SelectOption {
|
||||
id: string
|
||||
displayName: string
|
||||
color: string
|
||||
}
|
||||
|
||||
export type TextConfig = Record<string, never>
|
||||
export type LongTextConfig = Record<string, never>
|
||||
|
||||
export interface SelectConfig {
|
||||
options: SelectOption[]
|
||||
}
|
||||
|
||||
export interface SelectMultiConfig {
|
||||
options: SelectOption[]
|
||||
}
|
||||
|
||||
export interface RatingConfig {
|
||||
maxValue: number // 2-6
|
||||
}
|
||||
|
||||
export interface NumberConfig {
|
||||
scale: number // 0-3 decimal places
|
||||
}
|
||||
|
||||
export type ToggleConfig = Record<string, never>
|
||||
|
||||
export interface DateConfig {
|
||||
displayFormat: string // 'local' | 'friendly' | 'usa' | 'euro' | 'iso'
|
||||
displayTimezone: boolean
|
||||
includeTime: boolean
|
||||
timeFormat: string // 'twelve_hour' | 'twenty_four_hour'
|
||||
}
|
||||
|
||||
export interface FieldConfig {
|
||||
name: string
|
||||
type: FieldType
|
||||
text?: TextConfig
|
||||
longText?: LongTextConfig
|
||||
select?: SelectConfig
|
||||
selectMulti?: SelectMultiConfig
|
||||
rating?: RatingConfig
|
||||
number?: NumberConfig
|
||||
toggle?: ToggleConfig
|
||||
date?: DateConfig
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// System Settings Value
|
||||
// ----------------------------------------------------------------------
|
||||
export type SystemSettingsValue = unknown
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Provider Config
|
||||
// ----------------------------------------------------------------------
|
||||
export type ModelConfig = import('zod').z.infer<
|
||||
typeof import('@/dtos/provider').providerModelConfigSchema
|
||||
>
|
||||
export type ProviderConfig = import('@/dtos/provider').ProviderConfigSerializable
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Workflow Task Payload
|
||||
// ----------------------------------------------------------------------
|
||||
export interface WorkflowTaskPayload {
|
||||
projectId: string
|
||||
transcode?: TaskSpec
|
||||
agent?: AgentTaskPayload
|
||||
queryEmbeddingForSearch?: {
|
||||
text: string
|
||||
}
|
||||
agentToolCall?: AgentToolCallPayload
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Task Spec & Payload
|
||||
// ----------------------------------------------------------------------
|
||||
export interface AgentToolCallPayload {
|
||||
toolName: string
|
||||
args: Record<string, unknown>
|
||||
userId: string
|
||||
}
|
||||
|
||||
export interface TaskSpec {
|
||||
videoStrategy?: VideoTranscodeStrategy
|
||||
thumbnail?: boolean
|
||||
sprite?: boolean
|
||||
poster?: boolean
|
||||
}
|
||||
|
||||
export interface AgentTaskPayload {
|
||||
agentId?: string
|
||||
userId?: string
|
||||
sessionId?: string
|
||||
userCommentId?: string
|
||||
explicitMention?: boolean
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// User Metadata Value
|
||||
// ----------------------------------------------------------------------
|
||||
// This is a generic metadata store that can hold any JSON-serializable value.
|
||||
// We use any here because the structure of the metadata is determined by the
|
||||
// keys used by different parts of the application.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type UserMetadataValue = any
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Skill Config
|
||||
// ----------------------------------------------------------------------
|
||||
export interface SkillEnvironmentVariable {
|
||||
name: string
|
||||
default?: string
|
||||
}
|
||||
|
||||
export interface SkillConfig {
|
||||
environmentVariables: SkillEnvironmentVariable[]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, test } from 'vitest'
|
||||
import { AgentService } from './agent'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
|
||||
describe('AgentService', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import {
|
||||
CreateAgentParams,
|
||||
DeleteAgentParams,
|
||||
ListAgentsParams,
|
||||
UpdateAgentParams,
|
||||
} from '@/dtos/agent'
|
||||
import '@/prisma-json-types'
|
||||
} from '@shumai/dtos'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import AdmZip from 'adm-zip'
|
||||
import * as fs from 'fs'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
|
||||
import { AssetType, AssetStatus, Prisma } from '@/generated/prisma/client.ts'
|
||||
import { AssetService } from './asset'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import {
|
||||
AncestorFolder,
|
||||
AssetInfo,
|
||||
@@ -15,8 +15,8 @@ import {
|
||||
ReparentAssetsRequest,
|
||||
UpdateAssetNameRequest,
|
||||
UpdateAssetOrderRequest,
|
||||
UserInfo,
|
||||
} from '@/dtos/asset'
|
||||
AssetUserInfo,
|
||||
} from '@shumai/dtos'
|
||||
import { Asset, AssetStatus, AssetType, Prisma, StorageKey } from '@/generated/prisma/client.ts'
|
||||
import { logger } from '@/logger'
|
||||
import { PaginatedData, paginateQuery, PaginationParams } from '@/services/pagination'
|
||||
@@ -1670,7 +1670,7 @@ export class AssetService {
|
||||
}
|
||||
}
|
||||
|
||||
const mentions: UserInfo[] = []
|
||||
const mentions: AssetUserInfo[] = []
|
||||
const botMentionMatch = (c.message || '').match(/<@([^>]+)>/g)
|
||||
if (botMentionMatch) {
|
||||
const userIds = botMentionMatch.map((m: string) => m.replace('<@', '').replace('>', ''))
|
||||
@@ -1682,7 +1682,7 @@ export class AssetService {
|
||||
}
|
||||
}
|
||||
|
||||
const creator: UserInfo = { id: '', name: '' }
|
||||
const creator: AssetUserInfo = { id: '', name: '' }
|
||||
if (c.sessionId) {
|
||||
creator.id = c.creatorId || ''
|
||||
creator.name = c.creator?.name || 'Ai Bot'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { betterAuth } from 'better-auth'
|
||||
import { prismaAdapter } from 'better-auth/adapters/prisma'
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { teamService } from '@/services/team/team'
|
||||
import { inviteService } from '@/services/invite/invite'
|
||||
import { createAuthMiddleware } from 'better-auth/api'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { authzService, Permission, ResourceType } from '@/services/authz/authz'
|
||||
|
||||
describe('AuthzService', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import type { Prisma } from '@/generated/prisma/client.ts'
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { collectionService } from './collection'
|
||||
import { projectService } from '../project/project'
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { paginateQuery } from '../pagination'
|
||||
import {
|
||||
CreateCollectionRequest,
|
||||
UpdateCollectionRequest,
|
||||
ListCollectionsRequest,
|
||||
} from '@/dtos/collection'
|
||||
} from '@shumai/dtos'
|
||||
|
||||
export class CollectionService {
|
||||
async createCollection(projectId: string, req: CreateCollectionRequest) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { inviteService } from '@/services/invite/invite'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { InviteRole, ProjectMemberRole, TeamMemberRole } from '@/generated/prisma/client'
|
||||
import { ulid } from 'ulid'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { MetadataService } from './metadata'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
|
||||
describe('MetadataService', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import {
|
||||
CreateFieldRequest,
|
||||
ProjectFieldOrder,
|
||||
UpdateAssetMetadataRequest,
|
||||
UpdateFieldRequest,
|
||||
} from '@/dtos/metadata'
|
||||
} from '@shumai/dtos'
|
||||
import type { Prisma } from '@/generated/prisma/client.ts'
|
||||
import { ulid } from 'ulid'
|
||||
import { assetService } from '../asset/asset'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Prisma } from '@/generated/prisma/client.ts'
|
||||
import '@/prisma-json-types'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
|
||||
export const systemFields: Prisma.MetadataFieldCreateInput[] = [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { NotificationType } from '@/generated/prisma/client'
|
||||
import { notificationService } from './notification'
|
||||
import { userMetadataService } from '@/services/user-metadata/user-metadata'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import type { Prisma } from '@/generated/prisma/client'
|
||||
import { NotificationType } from '@/generated/prisma/client'
|
||||
import {
|
||||
@@ -6,9 +6,9 @@ import {
|
||||
CreateNotificationRequest,
|
||||
ListNotificationParams,
|
||||
NotificationSettings,
|
||||
} from '@/dtos/notification'
|
||||
} from '@shumai/dtos'
|
||||
import { paginateQuery, PaginatedData } from '@/services/pagination'
|
||||
import '@/prisma-json-types'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { userMetadataService } from '@/services/user-metadata/user-metadata'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { ProjectService } from './project'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { assetService } from '@/services/asset/asset'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { Prisma } from '@/generated/prisma/client'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { paginateQuery, PaginatedData } from '@/services/pagination'
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
ServiceListProjectMembersRequest,
|
||||
ProjectInfo,
|
||||
ProjectUserInfo,
|
||||
} from '@/dtos/project'
|
||||
} from '@shumai/dtos'
|
||||
|
||||
export class ProjectService {
|
||||
async createProject(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { teamService } from '@/services/team/team'
|
||||
import { providerService } from './provider'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { ProviderConfigSerializable, providerModelSchema } from '@/dtos/provider'
|
||||
import { ProviderConfigSerializable, providerModelSchema } from '@shumai/dtos'
|
||||
import { builtinProviders } from '@/generated/providers.generated'
|
||||
import { z } from 'zod'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/db'
|
||||
import { ProviderConfigSerializable, providerModelSchema } from '@/dtos/provider'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { ProviderConfigSerializable, providerModelSchema } from '@shumai/dtos'
|
||||
import { builtinProviders } from '@/generated/providers.generated'
|
||||
import { z } from 'zod'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ObjectInfo } from '@/dtos/s3'
|
||||
import { ObjectInfo } from '@shumai/dtos'
|
||||
import {
|
||||
CopyObjectCommand,
|
||||
DeleteObjectCommand,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, beforeEach } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { SearchService } from './search'
|
||||
import { AssetType } from '@/generated/prisma/client.ts'
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { describe, expect, it, beforeEach, vi } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { SearchService } from './search'
|
||||
import { SearchConditionOperator } from '@/dtos/search'
|
||||
import { SearchConditionOperator } from '@shumai/dtos'
|
||||
import { metadataService } from '@/services/metadata/metadata'
|
||||
import { workflowService } from '@/workflow/workflow'
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { Prisma, AssetType, WorkflowTaskType } from '@/generated/prisma/client.ts'
|
||||
import { AssetService, assetService } from '@/services/asset/asset'
|
||||
import { AssetInfo } from '@/dtos/asset'
|
||||
import { SearchRequest } from '@/dtos/search'
|
||||
import { AssetInfo } from '@shumai/dtos'
|
||||
import { SearchRequest } from '@shumai/dtos'
|
||||
import { PaginatedData, decodeCursor, encodeCursor, PageInfo } from '@/services/pagination'
|
||||
import { generateSearchNgrams } from '@/utils/ngram'
|
||||
import { workflowService } from '@/workflow/workflow'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Prisma } from '@/generated/prisma/client.ts'
|
||||
import { SearchCondition } from '@/dtos/search'
|
||||
import { SearchCondition } from '@shumai/dtos'
|
||||
|
||||
export class SqlQueryBuilder {
|
||||
private selectSql: Prisma.Sql = Prisma.sql`*`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { shareService } from './share'
|
||||
import { assetService } from '@/services/asset/asset'
|
||||
import { projectService } from '@/services/project/project'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { AssetType, Prisma } from '@/generated/prisma/client'
|
||||
import {
|
||||
ShareLinkInfo,
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
UpdateShareLinkRequest,
|
||||
ListShareLinksRequest,
|
||||
AddAssetToShareRequest,
|
||||
} from '@/dtos/share'
|
||||
} from '@shumai/dtos'
|
||||
import { PaginatedData, paginateQuery } from '@/services/pagination'
|
||||
|
||||
export class ShareService {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { skillService } from '@/services/skill/skill'
|
||||
import AdmZip from 'adm-zip'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/db'
|
||||
import { SkillInfo, UpsertSkillRequest } from '@/dtos/skill'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { SkillInfo, UpsertSkillRequest } from '@shumai/dtos'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import AdmZip from 'adm-zip'
|
||||
import * as crypto from 'crypto'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { teamService } from '@/services/team/team'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { Prisma } from '@/generated/prisma/client'
|
||||
import { PaginatedData, paginateQuery } from '@/services/pagination'
|
||||
import { ProviderService, providerService } from '@/services/provider/provider'
|
||||
@@ -13,11 +13,13 @@ import {
|
||||
GetMeResponse,
|
||||
UserInfo,
|
||||
SandboxSettings,
|
||||
} from '@/dtos/team'
|
||||
} from '@shumai/dtos'
|
||||
|
||||
export class TeamService {
|
||||
async ensureDefaultTeam() {
|
||||
let team = await prisma.team.findFirst()
|
||||
let team = await prisma.team.findFirst({
|
||||
where: { name: 'Default Team' },
|
||||
})
|
||||
|
||||
if (!team) {
|
||||
team = await prisma.team.create({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { uploadService } from './upload'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { AssetStatus, AssetType, WorkflowTaskType } from '@/generated/prisma/client'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { ulid } from 'ulid'
|
||||
import { generateKeyBetween } from 'jittered-fractional-indexing'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
FileNode,
|
||||
PresignedUrl,
|
||||
TaskInfo,
|
||||
} from '@/dtos/upload'
|
||||
} from '@shumai/dtos'
|
||||
import {
|
||||
AssetStatus,
|
||||
AssetType,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { userMetadataService } from './user-metadata'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/db'
|
||||
import { UserMetadataItem } from '@/dtos/user-metadata'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { UserMetadataItem } from '@shumai/dtos'
|
||||
|
||||
export class UserMetadataService {
|
||||
async upsertMetadata(userId: string, teamId: string, key: string, value: unknown) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { VersionStackService } from './versionStack'
|
||||
import { AssetType } from '@/generated/prisma/client.ts'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { generateKeyBetween } from 'jittered-fractional-indexing'
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { Asset, AssetType } from '@/generated/prisma/client.ts'
|
||||
import { ChangeStackFileVersionParams, CreateVersionStackParams } from '@/dtos/versionStack'
|
||||
import { ChangeStackFileVersionParams, CreateVersionStackParams } from '@shumai/dtos'
|
||||
|
||||
function generateSortIndex(previous?: string | null): string {
|
||||
if (!previous) return generateKeyBetween(null, null)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { prisma } from '@/db'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { getMediaInfoActivity, transcodeVideoActivity, updateAssetMediaActivity } from './transcode'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { transcodeService } from '@/transcode/transcode'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { s3Service } from '@/services/s3/s3'
|
||||
import { transcodeService } from '@/transcode/transcode'
|
||||
import { metadataService } from '@/services/metadata/metadata'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { WorkflowTaskStatus, WorkflowTaskType } from '@/generated/prisma/client'
|
||||
import '@/prisma-json-types'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import { exec } from 'child_process'
|
||||
import * as fs from 'fs'
|
||||
import * as os from 'os'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { prisma } from '@/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { WorkflowTaskType, WorkflowTaskStatus } from '@/generated/prisma/client'
|
||||
import '@/prisma-json-types'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
|
||||
type TransactionClient = Omit<
|
||||
typeof prisma,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AncestorFolder } from '@/dtos/asset'
|
||||
import type { AncestorFolder } from '@shumai/dtos'
|
||||
import { Badge } from '@/ui/components/ui/badge'
|
||||
import {
|
||||
DropdownMenu,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { AttachmentInfo, CommentInfo } from '@/dtos/asset'
|
||||
import type { UserInfo } from '@/dtos/team'
|
||||
import type { AttachmentInfo, CommentInfo } from '@shumai/dtos'
|
||||
import type { UserInfo } from '@shumai/dtos'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CommentInfo, PostAttachmentRequest, PostAttachmentResponse } from '@/dtos/asset'
|
||||
import type { BotInfo } from '@/dtos/project'
|
||||
import type { UserInfo } from '@/dtos/team'
|
||||
import type { CommentInfo, PostAttachmentRequest, PostAttachmentResponse } from '@shumai/dtos'
|
||||
import type { BotInfo } from '@shumai/dtos'
|
||||
import type { UserInfo } from '@shumai/dtos'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useAnnotationStore } from '@/ui/stores/annotation-store'
|
||||
import type { Annotation } from '@/ui/types'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { FieldInfo as FieldInfo } from '@/dtos/metadata'
|
||||
import type { FieldInfo as FieldInfo } from '@shumai/dtos'
|
||||
import React from 'react'
|
||||
import DateField from './fields/date-field'
|
||||
import LongTextField from './fields/long-text-field'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FieldType, type FieldInfo, type FieldInfo as MetadataFieldInfo } from '@/dtos/metadata'
|
||||
import { FieldType, type FieldInfo, type FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useFieldStore } from '@/ui/stores/fields'
|
||||
import { DragDropProvider, KeyboardSensor, PointerSensor, type DragEndEvent } from '@dnd-kit/react'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { FieldInfo as MetadataFieldInfo } from '@/dtos/metadata'
|
||||
import type { FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
|
||||
|
||||
export type FieldConfig = MetadataFieldInfo['config']
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SelectOption } from '@/dtos/metadata'
|
||||
import type { SelectOption } from '@shumai/dtos'
|
||||
import { ChevronDown, X } from 'lucide-react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import type { FieldProps } from './field-types'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Check } from 'lucide-react'
|
||||
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import type { FieldProps } from './field-types'
|
||||
import type { SelectOption } from '@/dtos/metadata'
|
||||
import type { SelectOption } from '@shumai/dtos'
|
||||
|
||||
const SelectMultiField: React.FC<FieldProps<string[]>> = ({
|
||||
value = [],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { FieldInfo as MetadataFieldInfo } from '@/dtos/metadata'
|
||||
import type { FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
|
||||
import React from 'react'
|
||||
|
||||
interface FieldProps {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { AssetInfo } from '@/dtos/asset'
|
||||
import type { ShareLinkInfo } from '@/dtos/share'
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
import type { ShareLinkInfo } from '@shumai/dtos'
|
||||
import {
|
||||
ContextMenuContent,
|
||||
ContextMenuItem,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user