|
1 | 1 | import { DASHBOARD_CONTENT_TYPE } from '@/lib/dashboards/resource' |
2 | | -import { type FileDiscovery, fileDiscoveryCondition } from '@/lib/workspace-files/discovery' |
3 | 2 | /** |
4 | 3 | * Workspace file storage system |
5 | 4 | * Files uploaded at workspace level persist indefinitely and are accessible across all workflows |
@@ -103,6 +102,7 @@ import { getWorkspaceFileSize, MAX_WORKSPACE_FILE_SIZE } from '@/lib/uploads/sha |
103 | 102 | import { isMarkdownFile } from '@/lib/uploads/utils/file-utils' |
104 | 103 | import type { ServableFile } from '@/lib/uploads/utils/file-utils.server' |
105 | 104 | import { SIM_PAGE_CONTENT_TYPE } from '@/lib/workspace-files/page-compile' |
| 105 | +import { workspaceFileContentTypeCondition } from '@/lib/workspace-files/query-scope' |
106 | 106 | import { |
107 | 107 | MAX_SIM_PAGE_UPLOAD_SNIFF_BYTES, |
108 | 108 | restoreSimPageSourceBuffer, |
@@ -207,7 +207,6 @@ export interface ActiveWorkspaceContext { |
207 | 207 | } |
208 | 208 |
|
209 | 209 | interface ListWorkspaceFilesOptions { |
210 | | - discovery?: FileDiscovery |
211 | 210 | contentType?: string |
212 | 211 |
|
213 | 212 | scope?: WorkspaceFileScope |
@@ -277,7 +276,6 @@ const MAX_NUMBERED_COPY_SUFFIX = 20 |
277 | 276 | const MAX_UPLOAD_UNIQUE_RETRIES = 8 |
278 | 277 |
|
279 | 278 | interface WorkspaceFileMetadataInsert { |
280 | | - discovery?: FileDiscovery |
281 | 279 | id: string |
282 | 280 | key: string |
283 | 281 | userId: string |
@@ -444,7 +442,6 @@ export async function uploadWorkspaceFile( |
444 | 442 | folderId?: string | null |
445 | 443 | folderPath?: string |
446 | 444 | exactName?: boolean |
447 | | - discovery?: FileDiscovery |
448 | 445 | /** Only the workspace dashboard use case writes dashboard content; it lives at the root. */ |
449 | 446 | dashboard?: true |
450 | 447 | secretProvenance?: WorkspaceFileSecretProvenance |
@@ -554,7 +551,6 @@ export async function uploadWorkspaceFile( |
554 | 551 | originalName: uniqueName, |
555 | 552 | contentType: effectiveContentType, |
556 | 553 | size: effectiveBuffer.length, |
557 | | - discovery: options?.discovery ?? 'listed', |
558 | 554 | }) |
559 | 555 | if (!inserted) { |
560 | 556 | throw new FileConflictError(uniqueName) |
@@ -1067,7 +1063,6 @@ export async function trackChatUpload( |
1067 | 1063 | chatId, |
1068 | 1064 | messageId: messageId ?? null, |
1069 | 1065 | context: 'mothership', |
1070 | | - discovery: 'unlisted', |
1071 | 1066 | displayName: candidate, |
1072 | 1067 | }) |
1073 | 1068 | .where( |
@@ -1115,7 +1110,6 @@ export async function trackChatUpload( |
1115 | 1110 | userId, |
1116 | 1111 | workspaceId, |
1117 | 1112 | context: 'mothership', |
1118 | | - discovery: 'unlisted', |
1119 | 1113 | chatId, |
1120 | 1114 | messageId: messageId ?? null, |
1121 | 1115 | originalName: fileName, |
@@ -1400,8 +1394,7 @@ export async function listWorkspaceFiles( |
1400 | 1394 | .where( |
1401 | 1395 | and( |
1402 | 1396 | workspaceFileScopeCondition(workspaceId, scope), |
1403 | | - fileDiscoveryCondition(options?.discovery), |
1404 | | - options?.contentType ? eq(workspaceFiles.contentType, options.contentType) : undefined |
| 1397 | + workspaceFileContentTypeCondition(options?.contentType) |
1405 | 1398 | ) |
1406 | 1399 | ) |
1407 | 1400 | .orderBy(workspaceFiles.uploadedAt) |
@@ -1437,7 +1430,6 @@ const WORKSPACE_FILE_SORTS = { |
1437 | 1430 | } satisfies Record<V2FileSortBy, readonly KeysetKey<WorkspaceFileRecord>[]> |
1438 | 1431 |
|
1439 | 1432 | export interface QueryWorkspaceFilesOptions { |
1440 | | - discovery?: FileDiscovery |
1441 | 1433 | contentType?: string |
1442 | 1434 |
|
1443 | 1435 | scope?: WorkspaceFileScope |
@@ -1529,8 +1521,7 @@ export async function queryWorkspaceFiles( |
1529 | 1521 |
|
1530 | 1522 | const conditions = [ |
1531 | 1523 | workspaceFileScopeCondition(workspaceId, scope), |
1532 | | - fileDiscoveryCondition(options.discovery), |
1533 | | - options.contentType ? eq(workspaceFiles.contentType, options.contentType) : undefined, |
| 1524 | + workspaceFileContentTypeCondition(options.contentType), |
1534 | 1525 | workspaceFileFolderCondition(folderId), |
1535 | 1526 | workspaceFileFolderScopeCondition(folderScope), |
1536 | 1527 | searchFilter(workspaceFiles.originalName, search), |
|
0 commit comments