Skip to main content

fileManagementService

Workspace API


Workspace API / services/fileManagementService

services/fileManagementService

Interfaces

FileOperationResult

Defined in: services/fileManagementService.ts:17

Type Parameters

T

T = unknown

Properties

success

success: boolean

Defined in: services/fileManagementService.ts:18

error?

optional error: string

Defined in: services/fileManagementService.ts:19

data?

optional data: T

Defined in: services/fileManagementService.ts:20


FileInfo

Defined in: services/fileManagementService.ts:23

Properties

name

name: string

Defined in: services/fileManagementService.ts:24

path

path: string

Defined in: services/fileManagementService.ts:25

size

size: number

Defined in: services/fileManagementService.ts:26

contentType

contentType: string

Defined in: services/fileManagementService.ts:27

created

created: Date

Defined in: services/fileManagementService.ts:28

updated

updated: Date

Defined in: services/fileManagementService.ts:29

isFolder

isFolder: boolean

Defined in: services/fileManagementService.ts:30

metadata?

optional metadata: Record<string, string>

Defined in: services/fileManagementService.ts:31

documentId?

optional documentId: string

Defined in: services/fileManagementService.ts:33

locationId?

optional locationId: string

Defined in: services/fileManagementService.ts:34

status?

optional status: string

Defined in: services/fileManagementService.ts:35

extractionMethod?

optional extractionMethod: string

Defined in: services/fileManagementService.ts:36


FolderInfo

Defined in: services/fileManagementService.ts:39

Properties

name

name: string

Defined in: services/fileManagementService.ts:40

path

path: string

Defined in: services/fileManagementService.ts:41

created

created: Date

Defined in: services/fileManagementService.ts:42

fileCount

fileCount: number

Defined in: services/fileManagementService.ts:43

totalSize

totalSize: number

Defined in: services/fileManagementService.ts:44

folderId?

optional folderId: string

Defined in: services/fileManagementService.ts:46


SignedUrlResult

Defined in: services/fileManagementService.ts:49

Properties

success

success: boolean

Defined in: services/fileManagementService.ts:50

signedUrl?

optional signedUrl: string

Defined in: services/fileManagementService.ts:51

expiresAt?

optional expiresAt: Date

Defined in: services/fileManagementService.ts:52

error?

optional error: string

Defined in: services/fileManagementService.ts:53

Functions

generateFolderPath()

generateFolderPath(subfolders): string

Defined in: services/fileManagementService.ts:61

Generate folder path using only user-created subfolders Format: \{subfolders...\}/ Note: organizationId and projectId are kept for backward compatibility but not used in path generation

Parameters

subfolders

string[] = []

Returns

string


generateFilePath()

generateFilePath(filename, subfolders): string

Defined in: services/fileManagementService.ts:79

Generate file path using only user-created subfolders and filename Format: \{subfolders...\}/filename.extension Note: organizationId and projectId are kept for backward compatibility but not used in path generation

Parameters

filename

string

subfolders

string[] = []

Returns

string


parseFilePath()

parseFilePath(filePath): { subfolders: string[]; filename: string; } | null

Defined in: services/fileManagementService.ts:96

Parse file path to extract components Format: \{subfolders...\}/filename.extension Note: organizationId and projectId are kept for backward compatibility but return empty strings

Parameters

filePath

string

Returns

{ subfolders: string[]; filename: string; } | null


createFolder()

createFolder(organizationId, userId, folderName, parentPath, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:126

Create a new folder (database-driven) Creates a record in app_data_folders table Note: Folders are organization-scoped only. Project associations are tracked via document_locations.

Parameters

organizationId

string

Organization ID

userId

string

User ID

folderName

string

Name of the folder to create

parentPath

string = ''

Optional parent path (e.g., "folder1/folder2/")

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


listFolders()

listFolders(organizationId, projectId, userId, subfolders, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:317

List folders in a project (database-driven)

Parameters

organizationId

string

projectId

string

userId

string

subfolders

string[] = []

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


listFilesForOrganization()

listFilesForOrganization(organizationId, userId, path, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:443

List files in an organization folder (database-driven) Queries document_locations and folders tables instead of object storage

Parameters

organizationId

string

userId

string

path

string[] = []

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


listFiles()

listFiles(organizationId, projectId, userId, subfolders, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:615

List files in a project folder (database-driven) Queries document_locations and folders tables filtered by project_id

Parameters

organizationId

string

projectId

string

userId

string

subfolders

string[] = []

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


renameFile()

renameFile(organizationId, projectId, userId, currentPath, newName, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:785

Rename a file

Parameters

organizationId

string

projectId

string

userId

string

currentPath

string

newName

string

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


moveFile()

moveFile(organizationId, projectId, userId, currentPath, targetSubfolders, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:921

Move a file to another folder

Parameters

organizationId

string

projectId

string

userId

string

currentPath

string

targetSubfolders

string[]

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


createTextFile()

createTextFile(organizationId, projectId, userId, filename, content, subfolders, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:1046

Create a text file and upload it

Parameters

organizationId

string

projectId

string

userId

string

filename

string

content

string

subfolders

string[] = []

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


generateSignedUrl()

generateSignedUrl(organizationId, projectId, userId, filePath, expirationMinutes, log): Promise<SignedUrlResult>

Defined in: services/fileManagementService.ts:1206

Generate a signed URL for file sharing

Parameters

organizationId

string

projectId

string

userId

string

filePath

string

expirationMinutes

number = ...

log

Logger = logger

Returns

Promise<SignedUrlResult>


generateSignedUrlForOrganization()

generateSignedUrlForOrganization(organizationId, userId, filePath, expirationMinutes, log): Promise<SignedUrlResult>

Defined in: services/fileManagementService.ts:1337

Generate a signed URL for file sharing using organization-level access This allows viewing files without requiring a project selection

Parameters

organizationId

string

userId

string

filePath

string

expirationMinutes

number = ...

log

Logger = logger

Returns

Promise<SignedUrlResult>


deleteFileForOrganization()

deleteFileForOrganization(organizationId, userId, displayPath, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:1589

Delete a file or folder from organization (database-driven) For files: soft-deletes location, cleans up document if no remaining locations For folders: soft-deletes folder and all contained file locations

Parameters

organizationId

string

userId

string

displayPath

string

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


deleteFile()

deleteFile(organizationId, projectId, userId, displayPath, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:1810

Delete a file (project-based) Delegates to deleteFileForOrganization after verifying project access

Parameters

organizationId

string

projectId

string

userId

string

displayPath

string

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>


getFileMetadata()

getFileMetadata(organizationId, projectId, userId, filePath, log): Promise<FileOperationResult<unknown>>

Defined in: services/fileManagementService.ts:1833

Get file metadata

Parameters

organizationId

string

projectId

string

userId

string

filePath

string

log

Logger = logger

Returns

Promise<FileOperationResult<unknown>>