Merge pull request #18 from shumaiOne/feat/collection-feature

feat(collection): implement saved search results as collections
This commit is contained in:
Yiling-J
2026-05-25 22:37:09 +08:00
committed by GitHub
28 changed files with 2784 additions and 186 deletions
@@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "collections" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"filter" JSONB NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"project_id" TEXT NOT NULL,
CONSTRAINT "collections_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "collections_project_id_created_at_idx" ON "collections"("project_id", "created_at" DESC);
-- AddForeignKey
ALTER TABLE "collections" ADD CONSTRAINT "collections_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+16
View File
@@ -306,6 +306,7 @@ model Project {
invites Invite[] @relation("ProjectToInvite")
notifications Notification[] @relation("ProjectToNotification")
shareLinks ShareLink[] @relation("ProjectToShareLink")
collections Collection[] @relation("ProjectToCollection")
@@map("projects")
@@index([createdAt])
@@ -746,3 +747,18 @@ model Provider {
@@unique([teamId, name])
@@map("providers")
}
model Collection {
id String @id @default(ulid())
name String
/// [CollectionFilter]
filter Json
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
projectId String @map("project_id")
project Project @relation("ProjectToCollection", fields: [projectId], references: [id], onDelete: Cascade)
@@index([projectId, createdAt(sort: Desc)])
@@map("collections")
}
+164
View File
@@ -0,0 +1,164 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { collectionService } from '@/services/collection/collection'
import { authzService } from '@/services/authz/authz'
import app from './collection'
vi.mock('@/api/middleware/auth', () => ({
authMiddleware: vi.fn(async (c, next) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
c.set('user', { id: 'user-1', name: 'Test User' } as any)
await next()
}),
}))
describe('Collection API', () => {
const teamId = 'team-1'
const projectId = 'project-1'
const collectionId = 'col-1'
beforeEach(() => {
vi.restoreAllMocks()
})
it('POST /teams/:teamId/projects/:projectId/collections', async () => {
const mockCreate = vi.spyOn(collectionService, 'createCollection').mockResolvedValue({
id: collectionId,
name: 'New Collection',
filter: {
sourceFolderId: 'root-1',
searchFilter: { conditions: [], operator: 'AND', recursively: true },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
projectId,
createdAt: new Date(),
updatedAt: new Date(),
})
const mockAuthz = vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
const res = await app.request(
`/teams/${teamId}/projects/${projectId}/collections`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'New Collection',
filter: {
sourceFolderId: 'root-1',
searchFilter: { conditions: [], operator: 'AND', recursively: true },
},
}),
},
{
user: { id: 'user-1' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
)
expect(res.status).toBe(200)
expect(mockCreate).toHaveBeenCalledWith(projectId, expect.any(Object))
expect(mockAuthz).toHaveBeenCalled()
})
it('GET /teams/:teamId/projects/:projectId/collections', async () => {
const mockList = vi.spyOn(collectionService, 'listCollections').mockResolvedValue({
data: [
{
id: collectionId,
name: 'Col 1',
filter: {
sourceFolderId: 'root-1',
searchFilter: { conditions: [], operator: 'AND', recursively: true },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
projectId,
createdAt: new Date(),
updatedAt: new Date(),
},
],
pageInfo: { total: 1 },
})
const mockAuthz = vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
const res = await app.request(`/teams/${teamId}/projects/${projectId}/collections`)
expect(res.status).toBe(200)
const json = await res.json()
expect(json.data).toHaveLength(1)
expect(mockList).toHaveBeenCalled()
expect(mockAuthz).toHaveBeenCalled()
})
it('GET /teams/:teamId/projects/:projectId/collections/:collectionId', async () => {
const mockGet = vi.spyOn(collectionService, 'getCollection').mockResolvedValue({
id: collectionId,
name: 'Col 1',
filter: {
sourceFolderId: 'root-1',
searchFilter: { conditions: [], operator: 'AND', recursively: true },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
projectId,
createdAt: new Date(),
updatedAt: new Date(),
})
const mockAuthz = vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
const res = await app.request(
`/teams/${teamId}/projects/${projectId}/collections/${collectionId}`,
)
expect(res.status).toBe(200)
expect(mockGet).toHaveBeenCalledWith(collectionId)
expect(mockAuthz).toHaveBeenCalled()
})
it('PATCH /teams/:teamId/projects/:projectId/collections/:collectionId', async () => {
const mockUpdate = vi.spyOn(collectionService, 'updateCollection').mockResolvedValue({
id: collectionId,
name: 'Updated Name',
filter: {
sourceFolderId: 'root-1',
searchFilter: { conditions: [], operator: 'AND', recursively: true },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
projectId,
createdAt: new Date(),
updatedAt: new Date(),
})
const mockAuthz = vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
const res = await app.request(
`/teams/${teamId}/projects/${projectId}/collections/${collectionId}`,
{
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'Updated Name' }),
},
)
expect(res.status).toBe(200)
expect(mockUpdate).toHaveBeenCalledWith(collectionId, { name: 'Updated Name' })
expect(mockAuthz).toHaveBeenCalled()
})
it('DELETE /teams/:teamId/projects/:projectId/collections/:collectionId', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mockDelete = vi.spyOn(collectionService, 'deleteCollection').mockResolvedValue({} as any)
const mockAuthz = vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
const res = await app.request(
`/teams/${teamId}/projects/${projectId}/collections/${collectionId}`,
{
method: 'DELETE',
},
)
expect(res.status).toBe(200)
expect(mockDelete).toHaveBeenCalledWith(collectionId)
expect(mockAuthz).toHaveBeenCalled()
})
})
+122
View File
@@ -0,0 +1,122 @@
import { zValidator } from '@hono/zod-validator'
import { Hono } from 'hono'
import { collectionService } from '@/services/collection/collection'
import { authzService, Permission } from '@/services/authz/authz'
import {
createCollectionRequestSchema,
updateCollectionRequestSchema,
listCollectionsRequestSchema,
CollectionInfo,
CollectionFilter,
} from '@/dtos/collection'
import type { Prisma } from '@/generated/prisma/client'
type User = Prisma.UserGetPayload<Record<string, never>>
function toCollectionInfo(c: Prisma.CollectionGetPayload<Record<string, never>>): CollectionInfo {
return {
id: c.id,
name: c.name,
filter: c.filter as unknown as CollectionFilter,
projectId: c.projectId,
createdAt: c.createdAt.toISOString(),
updatedAt: c.updatedAt.toISOString(),
}
}
const route = new Hono<{ Variables: { user: User } }>()
.post(
'/teams/:teamId/projects/:projectId/collections',
zValidator('json', createCollectionRequestSchema),
async (c) => {
const { teamId, projectId } = c.req.param()
const req = c.req.valid('json')
const user = c.get('user')
await authzService.hasPermission({
teamId,
projectId,
user,
permission: Permission.Edit,
})
const collection = await collectionService.createCollection(projectId, req)
return c.json(toCollectionInfo(collection))
},
)
.get(
'/teams/:teamId/projects/:projectId/collections',
zValidator('query', listCollectionsRequestSchema),
async (c) => {
const { teamId, projectId } = c.req.param()
const req = c.req.valid('query')
const user = c.get('user')
await authzService.hasPermission({
teamId,
projectId,
user,
permission: Permission.Read,
})
const collections = await collectionService.listCollections(projectId, req)
return c.json({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: collections.data.map((c: any) => toCollectionInfo(c)),
pageInfo: collections.pageInfo,
})
},
)
.get('/teams/:teamId/projects/:projectId/collections/:collectionId', async (c) => {
const { teamId, projectId, collectionId } = c.req.param()
const user = c.get('user')
await authzService.hasPermission({
teamId,
projectId,
user,
permission: Permission.Read,
})
const collection = await collectionService.getCollection(collectionId)
if (!collection) {
return c.json({ error: 'Collection not found' }, 404)
}
return c.json(toCollectionInfo(collection))
})
.patch(
'/teams/:teamId/projects/:projectId/collections/:collectionId',
zValidator('json', updateCollectionRequestSchema),
async (c) => {
const { teamId, projectId, collectionId } = c.req.param()
const req = c.req.valid('json')
const user = c.get('user')
await authzService.hasPermission({
teamId,
projectId,
user,
permission: Permission.Edit,
})
const collection = await collectionService.updateCollection(collectionId, req)
return c.json(toCollectionInfo(collection))
},
)
.delete('/teams/:teamId/projects/:projectId/collections/:collectionId', async (c) => {
const { teamId, projectId, collectionId } = c.req.param()
const user = c.get('user')
await authzService.hasPermission({
teamId,
projectId,
user,
permission: Permission.Edit,
})
await collectionService.deleteCollection(collectionId)
return c.json({ success: true })
})
export default route
+2
View File
@@ -5,6 +5,7 @@ import { Hono } from 'hono'
import agentRoute from '@/api/agent'
import attachmentRoute from '@/api/attachment'
import authnRoute from '@/api/authn'
import collectionRoute from '@/api/collection'
import fileRoute from '@/api/file'
import folderRoute from '@/api/folder'
import inviteRoute from '@/api/invite'
@@ -42,6 +43,7 @@ const apiRoute = new Hono<{ Variables: { user: User } }>()
.route('/', notificationRoute)
.route('/', metadataRoute)
.route('/', projectRoute)
.route('/', collectionRoute)
.route('/', teamRoute)
.route('/', versionStackRoute)
.route('/', fileRoute)
+49
View File
@@ -0,0 +1,49 @@
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>
+12 -11
View File
@@ -44,16 +44,17 @@ 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(),
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(),
})
.merge(paginationParamsSchema)
assetType: searchAssetTypeSchema.optional(),
showSymlink: z.boolean().optional(),
recursively: z.boolean().optional().default(true),
query: z.string().optional(),
})
export type SearchFilter = z.infer<typeof searchFilterSchema>
export const searchRequestSchema = searchFilterSchema.extend(paginationParamsSchema.shape)
export type SearchRequest = z.infer<typeof searchRequestSchema>
+5
View File
@@ -172,3 +172,8 @@ export type Model = Prisma.ModelModel
*
*/
export type Provider = Prisma.ProviderModel
/**
* Model Collection
*
*/
export type Collection = Prisma.CollectionModel
+5
View File
@@ -196,3 +196,8 @@ export type Model = Prisma.ModelModel
*
*/
export type Provider = Prisma.ProviderModel
/**
* Model Collection
*
*/
export type Collection = Prisma.CollectionModel
File diff suppressed because one or more lines are too long
+90 -2
View File
@@ -414,7 +414,8 @@ export const ModelName = {
AgentSessionEntry: 'AgentSessionEntry',
UserMetadata: 'UserMetadata',
Model: 'Model',
Provider: 'Provider'
Provider: 'Provider',
Collection: 'Collection'
} as const
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
@@ -430,7 +431,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
omit: GlobalOmitOptions
}
meta: {
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "asset" | "storageKey" | "assetMetadataValue" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider"
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "asset" | "storageKey" | "assetMetadataValue" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection"
txIsolationLevel: TransactionIsolationLevel
}
model: {
@@ -2728,6 +2729,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
}
}
}
Collection: {
payload: Prisma.$CollectionPayload<ExtArgs>
fields: Prisma.CollectionFieldRefs
operations: {
findUnique: {
args: Prisma.CollectionFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload> | null
}
findUniqueOrThrow: {
args: Prisma.CollectionFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>
}
findFirst: {
args: Prisma.CollectionFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload> | null
}
findFirstOrThrow: {
args: Prisma.CollectionFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>
}
findMany: {
args: Prisma.CollectionFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>[]
}
create: {
args: Prisma.CollectionCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>
}
createMany: {
args: Prisma.CollectionCreateManyArgs<ExtArgs>
result: BatchPayload
}
createManyAndReturn: {
args: Prisma.CollectionCreateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>[]
}
delete: {
args: Prisma.CollectionDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>
}
update: {
args: Prisma.CollectionUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>
}
deleteMany: {
args: Prisma.CollectionDeleteManyArgs<ExtArgs>
result: BatchPayload
}
updateMany: {
args: Prisma.CollectionUpdateManyArgs<ExtArgs>
result: BatchPayload
}
updateManyAndReturn: {
args: Prisma.CollectionUpdateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>[]
}
upsert: {
args: Prisma.CollectionUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$CollectionPayload>
}
aggregate: {
args: Prisma.CollectionAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateCollection>
}
groupBy: {
args: Prisma.CollectionGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.CollectionGroupByOutputType>[]
}
count: {
args: Prisma.CollectionCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.CollectionCountAggregateOutputType> | number
}
}
}
}
} & {
other: {
@@ -3206,6 +3281,18 @@ export const ProviderScalarFieldEnum = {
export type ProviderScalarFieldEnum = (typeof ProviderScalarFieldEnum)[keyof typeof ProviderScalarFieldEnum]
export const CollectionScalarFieldEnum = {
id: 'id',
name: 'name',
filter: 'filter',
createdAt: 'createdAt',
updatedAt: 'updatedAt',
projectId: 'projectId'
} as const
export type CollectionScalarFieldEnum = (typeof CollectionScalarFieldEnum)[keyof typeof CollectionScalarFieldEnum]
export const SortOrder = {
asc: 'asc',
desc: 'desc'
@@ -3672,6 +3759,7 @@ export type GlobalOmitConfig = {
userMetadata?: Prisma.UserMetadataOmit
model?: Prisma.ModelOmit
provider?: Prisma.ProviderOmit
collection?: Prisma.CollectionOmit
}
/* Types for Logging */
+14 -1
View File
@@ -81,7 +81,8 @@ export const ModelName = {
AgentSessionEntry: 'AgentSessionEntry',
UserMetadata: 'UserMetadata',
Model: 'Model',
Provider: 'Provider'
Provider: 'Provider',
Collection: 'Collection'
} as const
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
@@ -539,6 +540,18 @@ export const ProviderScalarFieldEnum = {
export type ProviderScalarFieldEnum = (typeof ProviderScalarFieldEnum)[keyof typeof ProviderScalarFieldEnum]
export const CollectionScalarFieldEnum = {
id: 'id',
name: 'name',
filter: 'filter',
createdAt: 'createdAt',
updatedAt: 'updatedAt',
projectId: 'projectId'
} as const
export type CollectionScalarFieldEnum = (typeof CollectionScalarFieldEnum)[keyof typeof CollectionScalarFieldEnum]
export const SortOrder = {
asc: 'asc',
desc: 'desc'
+1
View File
@@ -39,4 +39,5 @@ export type * from './models/AgentSessionEntry.ts'
export type * from './models/UserMetadata.ts'
export type * from './models/Model.ts'
export type * from './models/Provider.ts'
export type * from './models/Collection.ts'
export type * from './commonInputTypes.ts'
File diff suppressed because it is too large Load Diff
+186
View File
@@ -229,6 +229,7 @@ export type ProjectWhereInput = {
invites?: Prisma.InviteListRelationFilter
notifications?: Prisma.NotificationListRelationFilter
shareLinks?: Prisma.ShareLinkListRelationFilter
collections?: Prisma.CollectionListRelationFilter
}
export type ProjectOrderByWithRelationInput = {
@@ -251,6 +252,7 @@ export type ProjectOrderByWithRelationInput = {
invites?: Prisma.InviteOrderByRelationAggregateInput
notifications?: Prisma.NotificationOrderByRelationAggregateInput
shareLinks?: Prisma.ShareLinkOrderByRelationAggregateInput
collections?: Prisma.CollectionOrderByRelationAggregateInput
}
export type ProjectWhereUniqueInput = Prisma.AtLeast<{
@@ -276,6 +278,7 @@ export type ProjectWhereUniqueInput = Prisma.AtLeast<{
invites?: Prisma.InviteListRelationFilter
notifications?: Prisma.NotificationListRelationFilter
shareLinks?: Prisma.ShareLinkListRelationFilter
collections?: Prisma.CollectionListRelationFilter
}, "id" | "rootFolderId" | "shareRootId">
export type ProjectOrderByWithAggregationInput = {
@@ -327,6 +330,7 @@ export type ProjectCreateInput = {
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateInput = {
@@ -346,6 +350,7 @@ export type ProjectUncheckedCreateInput = {
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectUpdateInput = {
@@ -365,6 +370,7 @@ export type ProjectUpdateInput = {
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateInput = {
@@ -384,6 +390,7 @@ export type ProjectUncheckedUpdateInput = {
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateManyInput = {
@@ -677,6 +684,20 @@ export type ProjectUpdateOneWithoutNotificationsNestedInput = {
update?: Prisma.XOR<Prisma.XOR<Prisma.ProjectUpdateToOneWithWhereWithoutNotificationsInput, Prisma.ProjectUpdateWithoutNotificationsInput>, Prisma.ProjectUncheckedUpdateWithoutNotificationsInput>
}
export type ProjectCreateNestedOneWithoutCollectionsInput = {
create?: Prisma.XOR<Prisma.ProjectCreateWithoutCollectionsInput, Prisma.ProjectUncheckedCreateWithoutCollectionsInput>
connectOrCreate?: Prisma.ProjectCreateOrConnectWithoutCollectionsInput
connect?: Prisma.ProjectWhereUniqueInput
}
export type ProjectUpdateOneRequiredWithoutCollectionsNestedInput = {
create?: Prisma.XOR<Prisma.ProjectCreateWithoutCollectionsInput, Prisma.ProjectUncheckedCreateWithoutCollectionsInput>
connectOrCreate?: Prisma.ProjectCreateOrConnectWithoutCollectionsInput
upsert?: Prisma.ProjectUpsertWithoutCollectionsInput
connect?: Prisma.ProjectWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.ProjectUpdateToOneWithWhereWithoutCollectionsInput, Prisma.ProjectUpdateWithoutCollectionsInput>, Prisma.ProjectUncheckedUpdateWithoutCollectionsInput>
}
export type ProjectCreateWithoutTeamInput = {
id?: string
name: string
@@ -693,6 +714,7 @@ export type ProjectCreateWithoutTeamInput = {
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutTeamInput = {
@@ -711,6 +733,7 @@ export type ProjectUncheckedCreateWithoutTeamInput = {
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutTeamInput = {
@@ -771,6 +794,7 @@ export type ProjectCreateWithoutMembersInput = {
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutMembersInput = {
@@ -789,6 +813,7 @@ export type ProjectUncheckedCreateWithoutMembersInput = {
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutMembersInput = {
@@ -823,6 +848,7 @@ export type ProjectUpdateWithoutMembersInput = {
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutMembersInput = {
@@ -841,6 +867,7 @@ export type ProjectUncheckedUpdateWithoutMembersInput = {
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutShareLinksInput = {
@@ -859,6 +886,7 @@ export type ProjectCreateWithoutShareLinksInput = {
metadataFields?: Prisma.MetadataFieldCreateNestedManyWithoutProjectInput
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutShareLinksInput = {
@@ -877,6 +905,7 @@ export type ProjectUncheckedCreateWithoutShareLinksInput = {
metadataFields?: Prisma.MetadataFieldUncheckedCreateNestedManyWithoutProjectInput
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutShareLinksInput = {
@@ -911,6 +940,7 @@ export type ProjectUpdateWithoutShareLinksInput = {
metadataFields?: Prisma.MetadataFieldUpdateManyWithoutProjectNestedInput
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutShareLinksInput = {
@@ -929,6 +959,7 @@ export type ProjectUncheckedUpdateWithoutShareLinksInput = {
metadataFields?: Prisma.MetadataFieldUncheckedUpdateManyWithoutProjectNestedInput
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutAssetsInput = {
@@ -947,6 +978,7 @@ export type ProjectCreateWithoutAssetsInput = {
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutAssetsInput = {
@@ -965,6 +997,7 @@ export type ProjectUncheckedCreateWithoutAssetsInput = {
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutAssetsInput = {
@@ -988,6 +1021,7 @@ export type ProjectCreateWithoutRootFolderInput = {
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutRootFolderInput = {
@@ -1006,6 +1040,7 @@ export type ProjectUncheckedCreateWithoutRootFolderInput = {
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutRootFolderInput = {
@@ -1029,6 +1064,7 @@ export type ProjectCreateWithoutShareRootInput = {
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutShareRootInput = {
@@ -1047,6 +1083,7 @@ export type ProjectUncheckedCreateWithoutShareRootInput = {
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutShareRootInput = {
@@ -1081,6 +1118,7 @@ export type ProjectUpdateWithoutAssetsInput = {
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutAssetsInput = {
@@ -1099,6 +1137,7 @@ export type ProjectUncheckedUpdateWithoutAssetsInput = {
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectUpsertWithoutRootFolderInput = {
@@ -1128,6 +1167,7 @@ export type ProjectUpdateWithoutRootFolderInput = {
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutRootFolderInput = {
@@ -1146,6 +1186,7 @@ export type ProjectUncheckedUpdateWithoutRootFolderInput = {
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectUpsertWithoutShareRootInput = {
@@ -1175,6 +1216,7 @@ export type ProjectUpdateWithoutShareRootInput = {
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutShareRootInput = {
@@ -1193,6 +1235,7 @@ export type ProjectUncheckedUpdateWithoutShareRootInput = {
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutInvitesInput = {
@@ -1211,6 +1254,7 @@ export type ProjectCreateWithoutInvitesInput = {
metadataFields?: Prisma.MetadataFieldCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutInvitesInput = {
@@ -1229,6 +1273,7 @@ export type ProjectUncheckedCreateWithoutInvitesInput = {
metadataFields?: Prisma.MetadataFieldUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutInvitesInput = {
@@ -1263,6 +1308,7 @@ export type ProjectUpdateWithoutInvitesInput = {
metadataFields?: Prisma.MetadataFieldUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutInvitesInput = {
@@ -1281,6 +1327,7 @@ export type ProjectUncheckedUpdateWithoutInvitesInput = {
metadataFields?: Prisma.MetadataFieldUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutMetadataFieldsInput = {
@@ -1299,6 +1346,7 @@ export type ProjectCreateWithoutMetadataFieldsInput = {
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutMetadataFieldsInput = {
@@ -1317,6 +1365,7 @@ export type ProjectUncheckedCreateWithoutMetadataFieldsInput = {
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutMetadataFieldsInput = {
@@ -1351,6 +1400,7 @@ export type ProjectUpdateWithoutMetadataFieldsInput = {
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutMetadataFieldsInput = {
@@ -1369,6 +1419,7 @@ export type ProjectUncheckedUpdateWithoutMetadataFieldsInput = {
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutNotificationsInput = {
@@ -1387,6 +1438,7 @@ export type ProjectCreateWithoutNotificationsInput = {
metadataFields?: Prisma.MetadataFieldCreateNestedManyWithoutProjectInput
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutNotificationsInput = {
@@ -1405,6 +1457,7 @@ export type ProjectUncheckedCreateWithoutNotificationsInput = {
metadataFields?: Prisma.MetadataFieldUncheckedCreateNestedManyWithoutProjectInput
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutNotificationsInput = {
@@ -1439,6 +1492,7 @@ export type ProjectUpdateWithoutNotificationsInput = {
metadataFields?: Prisma.MetadataFieldUpdateManyWithoutProjectNestedInput
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutNotificationsInput = {
@@ -1457,6 +1511,99 @@ export type ProjectUncheckedUpdateWithoutNotificationsInput = {
metadataFields?: Prisma.MetadataFieldUncheckedUpdateManyWithoutProjectNestedInput
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutCollectionsInput = {
id?: string
name: string
coverImageKey?: string | null
metadataOverrides?:PrismaJson.MetadataOverrides | Prisma.NullableJsonNullValueInput
enableNotification?: boolean
createdAt?: Date | string
updatedAt?: Date | string
team: Prisma.TeamCreateNestedOneWithoutProjectsInput
rootFolder?: Prisma.AssetCreateNestedOneWithoutProjectRootFolderInput
shareRoot?: Prisma.AssetCreateNestedOneWithoutProjectShareRootInput
members?: Prisma.ProjectMemberCreateNestedManyWithoutProjectInput
assets?: Prisma.AssetCreateNestedManyWithoutProjectInput
metadataFields?: Prisma.MetadataFieldCreateNestedManyWithoutProjectInput
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutCollectionsInput = {
id?: string
name: string
coverImageKey?: string | null
metadataOverrides?:PrismaJson.MetadataOverrides | Prisma.NullableJsonNullValueInput
enableNotification?: boolean
createdAt?: Date | string
updatedAt?: Date | string
teamId: string
rootFolderId?: string | null
shareRootId?: string | null
members?: Prisma.ProjectMemberUncheckedCreateNestedManyWithoutProjectInput
assets?: Prisma.AssetUncheckedCreateNestedManyWithoutProjectInput
metadataFields?: Prisma.MetadataFieldUncheckedCreateNestedManyWithoutProjectInput
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutCollectionsInput = {
where: Prisma.ProjectWhereUniqueInput
create: Prisma.XOR<Prisma.ProjectCreateWithoutCollectionsInput, Prisma.ProjectUncheckedCreateWithoutCollectionsInput>
}
export type ProjectUpsertWithoutCollectionsInput = {
update: Prisma.XOR<Prisma.ProjectUpdateWithoutCollectionsInput, Prisma.ProjectUncheckedUpdateWithoutCollectionsInput>
create: Prisma.XOR<Prisma.ProjectCreateWithoutCollectionsInput, Prisma.ProjectUncheckedCreateWithoutCollectionsInput>
where?: Prisma.ProjectWhereInput
}
export type ProjectUpdateToOneWithWhereWithoutCollectionsInput = {
where?: Prisma.ProjectWhereInput
data: Prisma.XOR<Prisma.ProjectUpdateWithoutCollectionsInput, Prisma.ProjectUncheckedUpdateWithoutCollectionsInput>
}
export type ProjectUpdateWithoutCollectionsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
coverImageKey?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
metadataOverrides?:PrismaJson.MetadataOverrides | Prisma.NullableJsonNullValueInput
enableNotification?: Prisma.BoolFieldUpdateOperationsInput | boolean
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
team?: Prisma.TeamUpdateOneRequiredWithoutProjectsNestedInput
rootFolder?: Prisma.AssetUpdateOneWithoutProjectRootFolderNestedInput
shareRoot?: Prisma.AssetUpdateOneWithoutProjectShareRootNestedInput
members?: Prisma.ProjectMemberUpdateManyWithoutProjectNestedInput
assets?: Prisma.AssetUpdateManyWithoutProjectNestedInput
metadataFields?: Prisma.MetadataFieldUpdateManyWithoutProjectNestedInput
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutCollectionsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
coverImageKey?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
metadataOverrides?:PrismaJson.MetadataOverrides | Prisma.NullableJsonNullValueInput
enableNotification?: Prisma.BoolFieldUpdateOperationsInput | boolean
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
teamId?: Prisma.StringFieldUpdateOperationsInput | string
rootFolderId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
shareRootId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
members?: Prisma.ProjectMemberUncheckedUpdateManyWithoutProjectNestedInput
assets?: Prisma.AssetUncheckedUpdateManyWithoutProjectNestedInput
metadataFields?: Prisma.MetadataFieldUncheckedUpdateManyWithoutProjectNestedInput
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateManyTeamInput = {
@@ -1487,6 +1634,7 @@ export type ProjectUpdateWithoutTeamInput = {
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutTeamInput = {
@@ -1505,6 +1653,7 @@ export type ProjectUncheckedUpdateWithoutTeamInput = {
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateManyWithoutTeamInput = {
@@ -1531,6 +1680,7 @@ export type ProjectCountOutputType = {
invites: number
notifications: number
shareLinks: number
collections: number
}
export type ProjectCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
@@ -1540,6 +1690,7 @@ export type ProjectCountOutputTypeSelect<ExtArgs extends runtime.Types.Extension
invites?: boolean | ProjectCountOutputTypeCountInvitesArgs
notifications?: boolean | ProjectCountOutputTypeCountNotificationsArgs
shareLinks?: boolean | ProjectCountOutputTypeCountShareLinksArgs
collections?: boolean | ProjectCountOutputTypeCountCollectionsArgs
}
/**
@@ -1594,6 +1745,13 @@ export type ProjectCountOutputTypeCountShareLinksArgs<ExtArgs extends runtime.Ty
where?: Prisma.ShareLinkWhereInput
}
/**
* ProjectCountOutputType without action
*/
export type ProjectCountOutputTypeCountCollectionsArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
where?: Prisma.CollectionWhereInput
}
export type ProjectSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
@@ -1615,6 +1773,7 @@ export type ProjectSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs
invites?: boolean | Prisma.Project$invitesArgs<ExtArgs>
notifications?: boolean | Prisma.Project$notificationsArgs<ExtArgs>
shareLinks?: boolean | Prisma.Project$shareLinksArgs<ExtArgs>
collections?: boolean | Prisma.Project$collectionsArgs<ExtArgs>
_count?: boolean | Prisma.ProjectCountOutputTypeDefaultArgs<ExtArgs>
}, ExtArgs["result"]["project"]>
@@ -1674,6 +1833,7 @@ export type ProjectInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs
invites?: boolean | Prisma.Project$invitesArgs<ExtArgs>
notifications?: boolean | Prisma.Project$notificationsArgs<ExtArgs>
shareLinks?: boolean | Prisma.Project$shareLinksArgs<ExtArgs>
collections?: boolean | Prisma.Project$collectionsArgs<ExtArgs>
_count?: boolean | Prisma.ProjectCountOutputTypeDefaultArgs<ExtArgs>
}
export type ProjectIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
@@ -1699,6 +1859,7 @@ export type $ProjectPayload<ExtArgs extends runtime.Types.Extensions.InternalArg
invites: Prisma.$InvitePayload<ExtArgs>[]
notifications: Prisma.$NotificationPayload<ExtArgs>[]
shareLinks: Prisma.$ShareLinkPayload<ExtArgs>[]
collections: Prisma.$CollectionPayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
@@ -2117,6 +2278,7 @@ export interface Prisma__ProjectClient<T, Null = never, ExtArgs extends runtime.
invites<T extends Prisma.Project$invitesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Project$invitesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$InvitePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
notifications<T extends Prisma.Project$notificationsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Project$notificationsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$NotificationPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
shareLinks<T extends Prisma.Project$shareLinksArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Project$shareLinksArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$ShareLinkPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
collections<T extends Prisma.Project$collectionsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Project$collectionsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$CollectionPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
@@ -2738,6 +2900,30 @@ export type Project$shareLinksArgs<ExtArgs extends runtime.Types.Extensions.Inte
distinct?: Prisma.ShareLinkScalarFieldEnum | Prisma.ShareLinkScalarFieldEnum[]
}
/**
* Project.collections
*/
export type Project$collectionsArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the Collection
*/
select?: Prisma.CollectionSelect<ExtArgs> | null
/**
* Omit specific fields from the Collection
*/
omit?: Prisma.CollectionOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.CollectionInclude<ExtArgs> | null
where?: Prisma.CollectionWhereInput
orderBy?: Prisma.CollectionOrderByWithRelationInput | Prisma.CollectionOrderByWithRelationInput[]
cursor?: Prisma.CollectionWhereUniqueInput
take?: number
skip?: number
distinct?: Prisma.CollectionScalarFieldEnum | Prisma.CollectionScalarFieldEnum[]
}
/**
* Project without action
*/
+5
View File
@@ -48,6 +48,11 @@ declare global {
// Team Settings
// ----------------------------------------------------------------------
export type VideoTranscodeStrategy = 'disable' | 'single' | 'full'
// ----------------------------------------------------------------------
// Collection Filter
// ----------------------------------------------------------------------
export type CollectionFilter = import('./dtos/collection').CollectionFilter
export type ImageTranscodeStrategy = 'disable' | 'single'
export interface TranscodeSettings {
+17 -17
View File
@@ -1,21 +1,21 @@
import { prisma } from '@/db'
import {
AncestorFolder,
AssetInfo,
AttachmentInfo,
ChildPreview,
CommentInfo,
CopyAssetsRequest,
CreateAssetRequest,
CreateCommentRequest,
FieldValueInfo,
GetAssetRequest,
ListChildrenRequest,
PreviewInfo,
ReparentAssetsRequest,
UpdateAssetNameRequest,
UpdateAssetOrderRequest,
UserInfo,
AncestorFolder,
AssetInfo,
AttachmentInfo,
ChildPreview,
CommentInfo,
CopyAssetsRequest,
CreateAssetRequest,
CreateCommentRequest,
FieldValueInfo,
GetAssetRequest,
ListChildrenRequest,
PreviewInfo,
ReparentAssetsRequest,
UpdateAssetNameRequest,
UpdateAssetOrderRequest,
UserInfo,
} from '@/dtos/asset'
import { Asset, AssetStatus, AssetType, Prisma, StorageKey } from '@/generated/prisma/client.ts'
import { logger } from '@/logger'
@@ -1086,7 +1086,7 @@ export class AssetService {
WITH to_purge AS (
SELECT id FROM storage_keys sk
WHERE NOT EXISTS (SELECT 1 FROM assets a WHERE a.storage_key_id = sk.id)
AND sk.created_at < NOW() - INTERVAL '24 hours'
AND sk.created_at < NOW() - INTERVAL '20 seconds'
AND (sk.status = 'active' OR (sk.status = 'purging' AND sk.updated_at < NOW() - INTERVAL '1 hour'))
LIMIT 100
FOR UPDATE SKIP LOCKED
+147
View File
@@ -0,0 +1,147 @@
import { describe, it, expect } from 'vitest'
import { prisma } from '@/db'
import { setupTestDbHooks } from '@/db-test-hooks'
import { collectionService } from './collection'
import { projectService } from '../project/project'
describe('CollectionService', () => {
setupTestDbHooks()
async function setupProject() {
const user = await prisma.user.create({
data: { name: 'Test User', email: 'test@example.com' },
})
const team = await prisma.team.create({
data: {
name: 'Test Team',
settings: {
enablePublicSignup: true,
transcode: { videoStrategy: 'disable', imageStrategy: 'disable' },
},
sandbox: { create: {} },
},
})
await prisma.teamMember.create({
data: {
teamId: team.id,
userId: user.id,
role: 'owner',
scope: 'team',
},
})
const project = await projectService.createProject(user, {
teamId: team.id,
name: 'Test Project',
})
return { team, project }
}
it('can create, get, update, and delete a collection', async () => {
const { project } = await setupProject()
// Create
const collection = await collectionService.createCollection(project.id, {
name: 'Test Collection',
filter: {
sourceFolderId: project.rootFolder!,
searchFilter: {
operator: 'AND',
conditions: [{ field: 'name', operator: 'contains', value: 'test' }],
recursively: true,
},
},
})
expect(collection.name).toBe('Test Collection')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((collection.filter as any).searchFilter.conditions[0].value).toBe('test')
// Get
const fetched = await collectionService.getCollection(collection.id)
expect(fetched?.id).toBe(collection.id)
// Update
const updated = await collectionService.updateCollection(collection.id, {
name: 'Updated Name',
filter: {
sourceFolderId: project.rootFolder!,
searchFilter: {
operator: 'AND',
conditions: [{ field: 'rating', operator: 'eq', value: 5 }],
recursively: true,
},
},
})
expect(updated.name).toBe('Updated Name')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((updated.filter as any).searchFilter.conditions[0].field).toBe('rating')
// Delete
await collectionService.deleteCollection(collection.id)
const deleted = await collectionService.getCollection(collection.id)
expect(deleted).toBeNull()
})
it('can list collections for a project with pagination', async () => {
const { project } = await setupProject()
// Create multiple collections
for (let i = 0; i < 5; i++) {
await collectionService.createCollection(project.id, {
name: `Collection ${i}`,
filter: {
sourceFolderId: project.rootFolder!,
searchFilter: { operator: 'AND', conditions: [], recursively: true },
},
})
}
// List first page
const list1 = await collectionService.listCollections(project.id, {
first: 2,
includeCount: true,
})
expect(list1.data.length).toBe(2)
expect(list1.pageInfo.total).toBe(5)
expect(list1.pageInfo.cursor).toBeDefined()
// List second page
const list2 = await collectionService.listCollections(project.id, {
first: 2,
after: list1.pageInfo.cursor,
})
expect(list2.data.length).toBe(2)
expect(list2.data[0].name).not.toBe(list1.data[0].name)
// List last page
const list3 = await collectionService.listCollections(project.id, {
first: 2,
after: list2.pageInfo.cursor,
})
expect(list3.data.length).toBe(1)
expect(list3.pageInfo.cursor).toBeUndefined()
})
it('cascades delete when project is deleted', async () => {
const { project } = await setupProject()
await collectionService.createCollection(project.id, {
name: 'To be deleted',
filter: {
sourceFolderId: project.rootFolder!,
searchFilter: { operator: 'AND', conditions: [], recursively: true },
},
})
const countBefore = await prisma.collection.count({
where: { projectId: project.id },
})
expect(countBefore).toBe(1)
await projectService.deleteProject(project.id)
const countAfter = await prisma.collection.count({
where: { projectId: project.id },
})
expect(countAfter).toBe(0)
})
})
+59
View File
@@ -0,0 +1,59 @@
import { prisma } from '@/db'
import { paginateQuery } from '../pagination'
import {
CreateCollectionRequest,
UpdateCollectionRequest,
ListCollectionsRequest,
} from '@/dtos/collection'
export class CollectionService {
async createCollection(projectId: string, req: CreateCollectionRequest) {
return await prisma.collection.create({
data: {
name: req.name,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
filter: req.filter as any,
projectId,
},
})
}
async updateCollection(collectionId: string, req: UpdateCollectionRequest) {
return await prisma.collection.update({
where: { id: collectionId },
data: {
...(req.name && { name: req.name }),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...(req.filter && { filter: req.filter as any }),
},
})
}
async deleteCollection(collectionId: string) {
return await prisma.collection.delete({
where: { id: collectionId },
})
}
async getCollection(collectionId: string) {
return await prisma.collection.findUnique({
where: { id: collectionId },
})
}
async listCollections(projectId: string, req: ListCollectionsRequest) {
return await paginateQuery(
(skip, take) =>
prisma.collection.findMany({
where: { projectId },
orderBy: { id: 'desc' },
skip,
take,
}),
() => prisma.collection.count({ where: { projectId } }),
req,
)
}
}
export const collectionService = new CollectionService()
@@ -6,6 +6,7 @@ import type { AssetInfo } from '@/dtos/asset'
import type { SearchCondition, SearchSort } from '@/dtos/search'
import type { CreateUploadTaskRequest } from '@/dtos/upload'
import type { ShareLinkInfo } from '@/dtos/share'
import type { CollectionInfo } from '@/dtos/collection'
import { useFieldStore } from '@/ui/stores/fields'
import { useUploadStore } from '@/ui/stores/upload'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
@@ -70,6 +71,10 @@ interface FileBrowserProps {
isPublic?: boolean
onRemoveFromShare?: (items: AssetInfo[]) => void
fieldVisibility?: Record<string, boolean>
collection?: CollectionInfo
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onUpdateCollection?: (updates: { name?: string; filter?: any }) => void
rootFolderId?: string
}
type FileWithId = {
@@ -110,6 +115,9 @@ export function FileBrowser({
isPublic,
onRemoveFromShare,
fieldVisibility,
collection,
onUpdateCollection,
rootFolderId,
}: FileBrowserProps) {
const [contextMenuItem, setContextMenuItem] = useState<AssetInfo | null>(null)
const [moveCopyMode, setMoveCopyMode] = useState<'move' | 'copy' | null>(null)
@@ -745,6 +753,9 @@ export function FileBrowser({
sort={sort}
onSortChange={onSortChange}
isRecentlyDeleted={isRecentlyDeleted}
collection={collection}
onUpdateCollection={onUpdateCollection}
rootFolderId={rootFolderId}
/>
)}
{displayStyle === 'list' ? (
+123 -14
View File
@@ -1,3 +1,5 @@
import type { AssetInfo } from '@/dtos/asset'
import type { CollectionInfo } from '@/dtos/collection'
import { type FieldInfo as MetadataFieldInfo } from '@/dtos/metadata'
import type { SearchCondition, SearchSort } from '@/dtos/search'
import { client } from '@/ui/api/client'
@@ -5,8 +7,10 @@ import { useMutation, useQuery } from '@tanstack/react-query'
import type { InferRequestType, InferResponseType } from 'hono/client'
import { useState } from 'react'
import { FieldsManager } from '../fields-manager'
import { FolderTree } from '../folder-tree'
import { ManageFieldsDialog } from '../manage-fields-dialog'
import { MembersDialog } from '../members-dialog'
import { FilterPanel } from '../search/filter-panel'
import { SearchFilterDialog } from '../search/search-filter-dialog'
import { SortControl } from '../search/sort-control'
import { Avatar, AvatarFallback } from '../ui/avatar'
@@ -24,6 +28,10 @@ type FileBrowserToolbarProps = {
sort?: SearchSort
onSortChange: (sort?: SearchSort) => void
isRecentlyDeleted?: boolean
collection?: CollectionInfo
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onUpdateCollection?: (updates: { name?: string; filter?: any }) => void
rootFolderId?: string
}
export function FileBrowserToolbar({
@@ -36,13 +44,30 @@ export function FileBrowserToolbar({
sort,
onSortChange,
isRecentlyDeleted,
collection,
onUpdateCollection,
rootFolderId,
}: FileBrowserToolbarProps) {
const [popoverOpen, setPopoverOpen] = useState(false)
const [searchDialogOpen, setSearchDialogOpen] = useState(false)
const [manageDialogOpen, setManageDialogOpen] = useState(false)
const [isMembersDialogOpen, setIsMembersDialogOpen] = useState(false)
const [isFolderSelectorOpen, setIsFolderSelectorOpen] = useState(false)
const activeFiltersCount = filterConditions.length
const isCollection = !!collection
const { data: folderInfo } = useQuery({
queryKey: ['folders', teamId, assetId],
queryFn: async () => {
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
param: { teamId: teamId, folderId: assetId },
})
if (!res.ok) throw new Error('failed to fetch folder')
return (await res.json()) as unknown as AssetInfo
},
enabled: isCollection && !!teamId && !!assetId,
})
const { data: members } = useQuery({
queryKey: ['projects', projectId, 'members'],
@@ -147,20 +172,104 @@ export function FileBrowserToolbar({
<Separator orientation="vertical" />
<Button
onClick={() => setSearchDialogOpen(true)}
disabled={isRecentlyDeleted}
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
size="sm"
className="inline-flex items-center gap-2 px-4 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8"
>
<span>Search</span>
{activeFiltersCount > 0 && (
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
{activeFiltersCount}
</span>
)}
</Button>
{isCollection ? (
<>
<Popover open={isFolderSelectorOpen} onOpenChange={setIsFolderSelectorOpen}>
<PopoverTrigger asChild>
<Button
variant="ghost"
size="sm"
className="inline-flex items-center gap-2 px-3 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8 text-muted-foreground"
>
<span className="truncate max-w-[150px]">{folderInfo?.name || 'Loading...'}</span>
</Button>
</PopoverTrigger>
<PopoverContent className="w-[300px] p-0" align="start">
<div className="h-[400px] flex flex-col">
<div className="p-2 border-b text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Select Source Folder
</div>
<div className="flex-1 overflow-y-auto">
<FolderTree
teamId={teamId}
projectId={projectId}
projectName="Assets"
rootFolderId={rootFolderId!}
onSelect={(folder: AssetInfo) => {
onUpdateCollection?.({
filter: {
...collection.filter,
sourceFolderId: folder.id,
},
})
setIsFolderSelectorOpen(false)
}}
selectedFolderId={collection.filter.sourceFolderId}
hideCollections
hideShares
/>
</div>
</div>
</PopoverContent>
</Popover>
<Separator orientation="vertical" />
<Popover>
<PopoverTrigger asChild>
<Button
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
size="sm"
className="inline-flex items-center gap-2 px-4 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8"
>
<span>Filter</span>
{activeFiltersCount > 0 && (
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
{activeFiltersCount}
</span>
)}
</Button>
</PopoverTrigger>
<PopoverContent className="w-[500px] p-0 overflow-hidden" align="start">
<div className="max-h-[80vh] overflow-y-auto">
<FilterPanel
fields={fields}
conditions={filterConditions}
onChange={(newConditions) => {
onFilterChange(newConditions)
onUpdateCollection?.({
filter: {
...collection.filter,
searchFilter: {
...collection.filter.searchFilter,
conditions: newConditions,
},
},
})
}}
excludeFields={[]}
hidePrefix
/>
</div>
</PopoverContent>
</Popover>
</>
) : (
<Button
onClick={() => setSearchDialogOpen(true)}
disabled={isRecentlyDeleted}
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
size="sm"
className="inline-flex items-center gap-2 px-4 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8"
>
<span>Search</span>
{activeFiltersCount > 0 && (
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
{activeFiltersCount}
</span>
)}
</Button>
)}
</div>
<div className="flex items-center gap-2">
+42 -17
View File
@@ -1,6 +1,7 @@
import type { AssetInfo, AssetInfoPaginatedList } from '@/dtos/asset'
import { type FieldInfo as MetadataFieldInfo } from '@/dtos/metadata'
import type { SearchCondition, SearchSort } from '@/dtos/search'
import type { CollectionInfo } from '@/dtos/collection'
import { client } from '@/ui/api/client'
import { useMutation } from '@tanstack/react-query'
import { InferRequestType, InferResponseType } from 'hono/client'
@@ -29,6 +30,9 @@ type FileSystemManagerProps = {
projectName: string
assetId: string
rootFolderId: string
collection?: CollectionInfo
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onUpdateCollection?: (updates: { name?: string; filter?: any }) => void
}
export default function FileSystemManager({
@@ -37,6 +41,8 @@ export default function FileSystemManager({
projectName,
assetId,
rootFolderId,
collection,
onUpdateCollection,
}: FileSystemManagerProps) {
const navigate = useNavigate()
const queryClient = useQueryClient()
@@ -89,7 +95,17 @@ export default function FileSystemManager({
}
}, [teamId, fetchMembers, fetchMetadata])
const [filterConditions, setFilterConditions] = useState<SearchCondition[]>([])
const initialFilterConditions = useMemo(() => {
return collection?.filter?.searchFilter?.conditions || []
}, [collection])
const [filterConditions, setFilterConditions] =
useState<SearchCondition[]>(initialFilterConditions)
useEffect(() => {
setFilterConditions(initialFilterConditions)
}, [initialFilterConditions])
const sortKey = `project:${projectId}:sort`
const sort = (metadata[sortKey] as SearchSort | undefined) || { field: 'custom', order: 'asc' }
const setSort = (newSort: SearchSort | undefined) => {
@@ -98,7 +114,8 @@ export default function FileSystemManager({
}
}
const isFiltering = filterConditions.length > 0
const isCollection = !!collection
const isFiltering = filterConditions.length > 0 || isCollection
const {
fileListLeftSidebarCollapsed: isLeftSidebarCollapsed,
@@ -135,8 +152,10 @@ export default function FileSystemManager({
ancestorFolders: folderInfo?.ancestorFolders ?? [],
currentAsset: isRecentlyDeleted
? { name: 'Recently Deleted', type: 'folder' }
: { name: folderInfo?.name, type: 'folder' },
isRootFolder: !isRecentlyDeleted && assetId === rootFolderId,
: isCollection
? { name: collection.name, type: 'folder' }
: { name: folderInfo?.name, type: 'folder' },
isRootFolder: !isRecentlyDeleted && !isCollection && assetId === rootFolderId,
onFolderClick: (id: string) => {
navigate({
to: '/projects/$projectId/folders/$folderId',
@@ -167,18 +186,21 @@ export default function FileSystemManager({
} = useInfiniteQuery<AssetInfoPaginatedList>({
queryKey: isRecentlyDeleted
? ['projects', projectId, 'recently-deleted', 'folder']
: ['search', teamId, assetId, 'folder', filterConditions, sort],
: ['search', teamId, assetId, 'folder', filterConditions, sort, isCollection],
queryFn: async ({ pageParam }) => {
if (isRecentlyDeleted) {
const res = await client.api.projects[':projectId']['recently-deleted'].$get({
param: { projectId: projectId },
query: {
assetType: 'folder',
after: pageParam as string,
},
})
if (!res.ok) throw new Error('failed to fetch recently deleted folders')
return (await res.json()) as unknown as AssetInfoPaginatedList
if (isRecentlyDeleted || isCollection) {
if (isRecentlyDeleted) {
const res = await client.api.projects[':projectId']['recently-deleted'].$get({
param: { projectId: projectId },
query: {
assetType: 'folder',
after: pageParam as string,
},
})
if (!res.ok) throw new Error('failed to fetch recently deleted folders')
return (await res.json()) as unknown as AssetInfoPaginatedList
}
return { data: [], pageInfo: { total: 0 } }
}
if (isFiltering) {
return { data: [], pageInfo: { total: 0 } }
@@ -212,7 +234,7 @@ export default function FileSystemManager({
} = useInfiniteQuery<AssetInfoPaginatedList>({
queryKey: isRecentlyDeleted
? ['projects', projectId, 'recently-deleted', 'file']
: ['search', teamId, assetId, 'file', filterConditions, sort],
: ['search', teamId, assetId, 'file', filterConditions, sort, isCollection],
queryFn: async ({ pageParam }) => {
if (isRecentlyDeleted) {
const res = await client.api.projects[':projectId']['recently-deleted'].$get({
@@ -231,7 +253,7 @@ export default function FileSystemManager({
json: {
assetType: 'file',
after: pageParam as string,
recursively: isFiltering,
recursively: isFiltering || isCollection,
conditions: filterConditions,
sort,
},
@@ -450,6 +472,9 @@ export default function FileSystemManager({
sort={sort}
onSortChange={setSort}
dragState={dragState}
collection={collection}
onUpdateCollection={onUpdateCollection}
rootFolderId={rootFolderId}
/>
{!isRightSidebarCollapsed && (
+115 -42
View File
@@ -11,9 +11,9 @@ import {
Loader2,
Trash2,
Plus,
MoreHorizontal,
Share2,
LayoutGrid,
Bookmark,
} from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
import { useInView } from 'react-intersection-observer'
@@ -21,6 +21,7 @@ import { useDraggable, useDroppable } from '@dnd-kit/react'
import type { DragState } from './dnd-types'
import { toast } from 'sonner'
import type { ShareLinkInfo } from '@/dtos/share'
import type { CollectionInfo } from '@/dtos/collection'
interface FolderTreeProps {
teamId: string
@@ -30,6 +31,8 @@ interface FolderTreeProps {
dragState?: DragState
onSelect?: (folder: AssetInfo) => void
selectedFolderId?: string
hideCollections?: boolean
hideShares?: boolean
}
export function FolderTree({
@@ -40,6 +43,8 @@ export function FolderTree({
dragState,
onSelect,
selectedFolderId,
hideCollections,
hideShares,
}: FolderTreeProps) {
const navigate = useNavigate()
const queryClient = useQueryClient()
@@ -61,6 +66,50 @@ export function FolderTree({
enabled: !!teamId && !!projectId,
})
const { data: collectionsData } = useQuery({
queryKey: ['collections', teamId, projectId],
queryFn: async () => {
const res = await client.api.teams[':teamId'].projects[':projectId'].collections.$get({
param: { teamId, projectId },
query: { first: '100' },
})
if (!res.ok) throw new Error('Failed to fetch collections')
return (await res.json()) as unknown as { data: CollectionInfo[] }
},
enabled: !!teamId && !!projectId,
})
const { mutate: createCollection } = useMutation({
mutationFn: async () => {
const res = await client.api.teams[':teamId'].projects[':projectId'].collections.$post({
param: { teamId, projectId },
json: {
name: 'Untitled Collection',
filter: {
sourceFolderId: rootFolderId,
searchFilter: {
conditions: [],
recursively: true,
},
},
},
})
if (!res.ok) throw new Error('Failed to create collection')
return await res.json()
},
onSuccess: (data) => {
queryClient.invalidateQueries({ queryKey: ['collections', teamId, projectId] })
toast.success('Collection created')
navigate({
to: '/projects/$projectId/collections/$collectionId',
params: { projectId, collectionId: data.id },
})
},
onError: (err) => {
toast.error(`Error: ${err.message}`)
},
})
const { mutate: createShareLink } = useMutation({
mutationFn: async () => {
const res = await client.api.teams[':teamId'].projects[':projectId'].shares.$post({
@@ -143,55 +192,79 @@ export function FolderTree({
</div>
</div>
<div>
<header className="flex items-center justify-between px-2 mb-1">
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Collections
</h3>
<button className="text-muted-foreground hover:text-foreground">
<Plus className="h-3.5 w-3.5" />
</button>
</header>
</div>
<div>
<header className="flex items-center justify-between px-2 mb-1">
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Share Links
</h3>
<div className="flex items-center gap-1">
<button className="text-muted-foreground hover:text-foreground">
<MoreHorizontal className="h-3.5 w-3.5" />
</button>
{!hideCollections && (
<div>
<header className="flex items-center justify-between px-2 mb-1">
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Collections
</h3>
<button
onClick={() => createShareLink()}
onClick={() => createCollection()}
className="text-muted-foreground hover:text-foreground"
>
<Plus className="h-3.5 w-3.5" />
</button>
</div>
</header>
</header>
<div className="space-y-0.5">
<div className="group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground">
<div className="flex h-4 w-4 items-center justify-center">
<LayoutGrid className="h-4 w-4 text-sidebar-primary" />
</div>
<span className="flex-1 truncate text-sidebar-foreground">
All Share Links ({shareLinks.length})
</span>
<div className="space-y-0.5">
{collectionsData?.data.map((collection) => (
<div
key={collection.id}
className="group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
onClick={() =>
navigate({
to: '/projects/$projectId/collections/$collectionId',
params: { projectId, collectionId: collection.id },
})
}
>
<div className="flex h-4 w-4 items-center justify-center">
<Bookmark className="h-4 w-4 text-sidebar-primary" />
</div>
<span className="flex-1 truncate text-sidebar-foreground">{collection.name}</span>
</div>
))}
</div>
{shareLinks.map((link) => (
<ShareLinkItem
key={link.id}
link={link}
projectId={projectId}
dragState={dragState}
/>
))}
</div>
</div>
)}
{!hideShares && (
<div>
<header className="flex items-center justify-between px-2 mb-1">
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Share Links
</h3>
<div className="flex items-center gap-1">
<button
onClick={() => createShareLink()}
className="text-muted-foreground hover:text-foreground"
>
<Plus className="h-3.5 w-3.5" />
</button>
</div>
</header>
<div className="space-y-0.5">
<div className="group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground">
<div className="flex h-4 w-4 items-center justify-center">
<LayoutGrid className="h-4 w-4 text-sidebar-primary" />
</div>
<span className="flex-1 truncate text-sidebar-foreground">
All Share Links ({shareLinks.length})
</span>
</div>
{shareLinks.map((link) => (
<ShareLinkItem
key={link.id}
link={link}
projectId={projectId}
dragState={dragState}
/>
))}
</div>
</div>
)}
</div>
</div>
)
@@ -7,17 +7,18 @@ import { Dialog, DialogContent } from '@/ui/components/ui/dialog'
import { Input } from '@/ui/components/ui/input'
import { formatSize } from '@/ui/lib/format'
import { cn } from '@/ui/lib/utils'
import { useQuery } from '@tanstack/react-query'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router'
import { toast } from 'sonner'
import {
AlertCircle,
ChevronDown,
ChevronUp,
FileIcon,
FolderIcon,
Loader2,
Search,
X,
AlertCircle,
ChevronDown,
ChevronUp,
FileIcon,
FolderIcon,
Loader2,
Search,
X,
} from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
import { FilterPanel } from './filter-panel'
@@ -44,6 +45,7 @@ export function SearchFilterDialog({
onApply,
}: SearchFilterDialogProps) {
const navigate = useNavigate()
const queryClient = useQueryClient()
const initialKeyword = useMemo(() => {
const cond = initialConditions.find((c) => c.field === 'name' && c.operator === 'contains')
@@ -95,6 +97,47 @@ export function SearchFilterDialog({
)
}, [debouncedSearchInput, conditions])
const { mutate: saveAsCollection, isPending: isSaving } = useMutation({
mutationFn: async () => {
let name = debouncedSearchInput.trim()
if (!name && conditions.length > 0) {
const first = conditions[0]
const field = fields.find((f) => f.id === first.field)
const fieldName = field?.config?.name || first.field
name = `${fieldName} ${first.operator} ${first.value}`
}
if (!name) name = 'Untitled Collection'
const res = await client.api.teams[':teamId'].projects[':projectId'].collections.$post({
param: { teamId, projectId },
json: {
name,
filter: {
sourceFolderId: assetId,
searchFilter: {
conditions: combinedConditions,
recursively: true,
},
},
},
})
if (!res.ok) throw new Error('Failed to save collection')
return await res.json()
},
onSuccess: (data) => {
queryClient.invalidateQueries({ queryKey: ['collections', teamId, projectId] })
toast.success('Collection saved')
onOpenChange(false)
navigate({
to: '/projects/$projectId/collections/$collectionId',
params: { projectId, collectionId: data.id },
})
},
onError: (err) => {
toast.error(`Error: ${err.message}`)
},
})
const { data: searchResults, isLoading } = useQuery({
queryKey: ['search-preview', teamId, assetId, combinedConditions],
queryFn: async () => {
@@ -343,11 +386,17 @@ export function SearchFilterDialog({
variant="outline"
size="xs"
className="h-8 text-[10px] font-semibold uppercase tracking-wider"
onClick={() => {
// Future implementation for saving collections
}}
disabled={!hasActiveCriteria || isSaving}
onClick={() => saveAsCollection()}
>
Save as collection
{isSaving ? (
<>
<Loader2 className="mr-2 h-3 w-3 animate-spin" />
Saving...
</>
) : (
'Save as collection'
)}
</Button>
</div>
</div>
+22
View File
@@ -23,6 +23,7 @@ import { Route as ShareShareIdFilesFileIdRouteImport } from './routes/share/$sha
import { Route as ProjectsProjectIdSharesShareIdRouteImport } from './routes/projects/$projectId/shares/$shareId'
import { Route as ProjectsProjectIdFoldersFolderIdRouteImport } from './routes/projects/$projectId/folders/$folderId'
import { Route as ProjectsProjectIdFilesFileIdRouteImport } from './routes/projects/$projectId/files/$fileId'
import { Route as ProjectsProjectIdCollectionsCollectionIdRouteImport } from './routes/projects/$projectId/collections/$collectionId'
const SignupRoute = SignupRouteImport.update({
id: '/signup',
@@ -94,6 +95,12 @@ const ProjectsProjectIdFilesFileIdRoute = ProjectsProjectIdFilesFileIdRouteImpor
path: '/projects/$projectId/files/$fileId',
getParentRoute: () => rootRouteImport,
} as any)
const ProjectsProjectIdCollectionsCollectionIdRoute =
ProjectsProjectIdCollectionsCollectionIdRouteImport.update({
id: '/projects/$projectId/collections/$collectionId',
path: '/projects/$projectId/collections/$collectionId',
getParentRoute: () => rootRouteImport,
} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
@@ -105,6 +112,7 @@ export interface FileRoutesByFullPath {
'/projects/$projectId/': typeof ProjectsProjectIdIndexRoute
'/share/$shareId/': typeof ShareShareIdIndexRoute
'/teams/$teamId/': typeof TeamsTeamIdIndexRoute
'/projects/$projectId/collections/$collectionId': typeof ProjectsProjectIdCollectionsCollectionIdRoute
'/projects/$projectId/files/$fileId': typeof ProjectsProjectIdFilesFileIdRoute
'/projects/$projectId/folders/$folderId': typeof ProjectsProjectIdFoldersFolderIdRoute
'/projects/$projectId/shares/$shareId': typeof ProjectsProjectIdSharesShareIdRoute
@@ -120,6 +128,7 @@ export interface FileRoutesByTo {
'/projects/$projectId': typeof ProjectsProjectIdIndexRoute
'/share/$shareId': typeof ShareShareIdIndexRoute
'/teams/$teamId': typeof TeamsTeamIdIndexRoute
'/projects/$projectId/collections/$collectionId': typeof ProjectsProjectIdCollectionsCollectionIdRoute
'/projects/$projectId/files/$fileId': typeof ProjectsProjectIdFilesFileIdRoute
'/projects/$projectId/folders/$folderId': typeof ProjectsProjectIdFoldersFolderIdRoute
'/projects/$projectId/shares/$shareId': typeof ProjectsProjectIdSharesShareIdRoute
@@ -137,6 +146,7 @@ export interface FileRoutesById {
'/projects/$projectId/': typeof ProjectsProjectIdIndexRoute
'/share/$shareId/': typeof ShareShareIdIndexRoute
'/teams/$teamId/': typeof TeamsTeamIdIndexRoute
'/projects/$projectId/collections/$collectionId': typeof ProjectsProjectIdCollectionsCollectionIdRoute
'/projects/$projectId/files/$fileId': typeof ProjectsProjectIdFilesFileIdRoute
'/projects/$projectId/folders/$folderId': typeof ProjectsProjectIdFoldersFolderIdRoute
'/projects/$projectId/shares/$shareId': typeof ProjectsProjectIdSharesShareIdRoute
@@ -155,6 +165,7 @@ export interface FileRouteTypes {
| '/projects/$projectId/'
| '/share/$shareId/'
| '/teams/$teamId/'
| '/projects/$projectId/collections/$collectionId'
| '/projects/$projectId/files/$fileId'
| '/projects/$projectId/folders/$folderId'
| '/projects/$projectId/shares/$shareId'
@@ -170,6 +181,7 @@ export interface FileRouteTypes {
| '/projects/$projectId'
| '/share/$shareId'
| '/teams/$teamId'
| '/projects/$projectId/collections/$collectionId'
| '/projects/$projectId/files/$fileId'
| '/projects/$projectId/folders/$folderId'
| '/projects/$projectId/shares/$shareId'
@@ -186,6 +198,7 @@ export interface FileRouteTypes {
| '/projects/$projectId/'
| '/share/$shareId/'
| '/teams/$teamId/'
| '/projects/$projectId/collections/$collectionId'
| '/projects/$projectId/files/$fileId'
| '/projects/$projectId/folders/$folderId'
| '/projects/$projectId/shares/$shareId'
@@ -202,6 +215,7 @@ export interface RootRouteChildren {
TeamsTeamIdSettingsRoute: typeof TeamsTeamIdSettingsRoute
ProjectsProjectIdIndexRoute: typeof ProjectsProjectIdIndexRoute
TeamsTeamIdIndexRoute: typeof TeamsTeamIdIndexRoute
ProjectsProjectIdCollectionsCollectionIdRoute: typeof ProjectsProjectIdCollectionsCollectionIdRoute
ProjectsProjectIdFilesFileIdRoute: typeof ProjectsProjectIdFilesFileIdRoute
ProjectsProjectIdFoldersFolderIdRoute: typeof ProjectsProjectIdFoldersFolderIdRoute
ProjectsProjectIdSharesShareIdRoute: typeof ProjectsProjectIdSharesShareIdRoute
@@ -307,6 +321,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProjectsProjectIdFilesFileIdRouteImport
parentRoute: typeof rootRouteImport
}
'/projects/$projectId/collections/$collectionId': {
id: '/projects/$projectId/collections/$collectionId'
path: '/projects/$projectId/collections/$collectionId'
fullPath: '/projects/$projectId/collections/$collectionId'
preLoaderRoute: typeof ProjectsProjectIdCollectionsCollectionIdRouteImport
parentRoute: typeof rootRouteImport
}
}
}
@@ -333,6 +354,7 @@ const rootRouteChildren: RootRouteChildren = {
TeamsTeamIdSettingsRoute: TeamsTeamIdSettingsRoute,
ProjectsProjectIdIndexRoute: ProjectsProjectIdIndexRoute,
TeamsTeamIdIndexRoute: TeamsTeamIdIndexRoute,
ProjectsProjectIdCollectionsCollectionIdRoute: ProjectsProjectIdCollectionsCollectionIdRoute,
ProjectsProjectIdFilesFileIdRoute: ProjectsProjectIdFilesFileIdRoute,
ProjectsProjectIdFoldersFolderIdRoute: ProjectsProjectIdFoldersFolderIdRoute,
ProjectsProjectIdSharesShareIdRoute: ProjectsProjectIdSharesShareIdRoute,
@@ -0,0 +1,103 @@
import { client } from '@/ui/api/client'
import FileSystemManager from '@/ui/components/file-system-manager'
import { useTeamContextStore } from '@/ui/stores/team-context'
import { useMutation, useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { createFileRoute } from '@tanstack/react-router'
import { useEffect } from 'react'
const projectInfoQueryOptions = (projectId: string) => ({
queryKey: ['projects', projectId],
queryFn: async () => {
const res = await client.api.projects[':projectId'].$get({
param: { projectId: projectId },
})
if (!res.ok) throw new Error('Failed to fetch project')
return await res.json()
},
})
const collectionInfoQueryOptions = (teamId: string, projectId: string, collectionId: string) => ({
queryKey: ['collections', teamId, projectId, collectionId],
queryFn: async () => {
const res = await client.api.teams[':teamId'].projects[':projectId'].collections[
':collectionId'
].$get({
param: { teamId, projectId, collectionId },
})
if (!res.ok) throw new Error('Failed to fetch collection')
return await res.json()
},
})
function CollectionPage() {
const { projectId, collectionId } = Route.useParams()
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
useEffect(() => {
ensureTeamIdForProject(projectId)
}, [projectId, ensureTeamIdForProject])
const { data: projectInfo } = useSuspenseQuery(projectInfoQueryOptions(projectId))
const { data: collection, refetch: refetchCollection } = useQuery({
...collectionInfoQueryOptions(teamId || '', projectId, collectionId),
enabled: !!teamId,
})
const { mutate: updateCollection } = useMutation({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mutationFn: async (updates: { name?: string; filter?: any }) => {
const res = await client.api.teams[':teamId'].projects[':projectId'].collections[
':collectionId'
].$patch({
param: { teamId: teamId!, projectId, collectionId },
json: updates,
})
if (!res.ok) throw new Error('Failed to update collection')
return await res.json()
},
onSuccess: () => {
refetchCollection()
},
})
const rootFolderId = projectInfo?.rootFolder
const { data: rootFolder } = useQuery({
queryKey: ['folders', teamId!, rootFolderId!],
queryFn: async () => {
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
param: { teamId: teamId!, folderId: rootFolderId! },
})
if (!res.ok) throw new Error('Failed to fetch folder')
return await res.json()
},
enabled: !!teamId && !!rootFolderId,
})
if (!teamId || !rootFolderId || !rootFolder || !collection) {
return <div>Loading collection...</div>
}
const sourceFolderId = collection.filter.sourceFolderId || rootFolderId
return (
<FileSystemManager
teamId={teamId}
projectId={projectId}
projectName={projectInfo.name ?? ''}
assetId={sourceFolderId}
rootFolderId={rootFolderId}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
collection={collection as any}
onUpdateCollection={updateCollection}
/>
)
}
export const Route = createFileRoute('/projects/$projectId/collections/$collectionId')({
component: CollectionPage,
loader: ({ context: { queryClient }, params: { projectId } }) =>
queryClient.ensureQueryData(projectInfoQueryOptions(projectId)),
pendingComponent: () => <div>Loading collection...</div>,
})
-61
View File
@@ -1,61 +0,0 @@
import { prisma } from '@/db'
import { s3Service } from '@/services/s3/s3'
import { logger } from '@/logger'
export async function purgeUnreferencedStorageKeysActivity(): Promise<{
purgedCount: number
physicalFilesDeleted: number
}> {
const bucket = process.env.S3_BUCKET || 'shumai'
let purgedCount = 0
let physicalFilesDeleted = 0
// 1. Find storage keys with no associated assets and older than 24 hours
// We use 24 hours to avoid race conditions with ongoing uploads or copies.
const twentyFourHoursAgo = new Date()
twentyFourHoursAgo.setDate(twentyFourHoursAgo.getDate() - 1)
const unreferencedKeys = await prisma.storageKey.findMany({
where: {
assets: { none: {} },
createdAt: { lt: twentyFourHoursAgo },
},
take: 100,
})
for (const sk of unreferencedKeys) {
try {
// Physically delete from S3
// Handle complex keys (directories) same as before
const parts = sk.key.split('/')
if (parts.length > 2) {
const prefix = parts.slice(0, parts.length - 1).join('/') + '/'
const count = await s3Service.deletePrefix(bucket, prefix)
physicalFilesDeleted += count
} else {
const count = await s3Service.deleteObject(bucket, sk.key)
physicalFilesDeleted += count
}
// Delete from database
await prisma.storageKey.delete({
where: { id: sk.id },
})
purgedCount++
} catch (e: unknown) {
logger.error(
{ key: sk.key, error: e instanceof Error ? e.message : String(e) },
'Failed to purge unreferenced storage key',
)
}
}
if (purgedCount > 0) {
logger.info(
{ purgedCount, physicalFilesDeleted },
`Garbage collection: purged ${purgedCount} storage keys and ${physicalFilesDeleted} physical files`,
)
}
return { purgedCount, physicalFilesDeleted }
}
+2 -4
View File
@@ -1,9 +1,8 @@
import * as taskActivities from './task'
import * as aiActivities from './ai'
import * as transcodeActivities from '@/transcode/activities/transcode'
import * as agentActivities from './agent'
import * as aiActivities from './ai'
import * as dbActivities from './db'
import * as gcActivities from './gc'
import * as taskActivities from './task'
export const activities = {
...taskActivities,
@@ -11,5 +10,4 @@ export const activities = {
...transcodeActivities,
...agentActivities,
...dbActivities,
...gcActivities,
}