file-manager.ts

Overview

The file-manager.ts file defines TypeScript interfaces and types that represent the core data structures for managing files and folders within an application. It primarily focuses on modeling file and folder metadata, including their creation and update timestamps, ownership, hierarchical location, and associated knowledge base (KB) information.

These interfaces serve as the blueprint for the file management domain model and are essential for enforcing type safety and consistency when handling file system entities throughout the application. Additionally, the file defines a type representing the result structure returned by an API or service fetching a list of files along with their parent folder information.


Detailed Descriptions

Interfaces


IFile

Represents a file entity with detailed metadata.

Properties

Property

Type

Description

create_date

string

The date when the file was created (likely in ISO 8601 or a similar date format).

create_time

number

The timestamp or time component of the creation time (e.g., Unix time or milliseconds).

created_by

string

Identifier or name of the user or system that created the file.

id

string

Unique identifier for the file.

kbs_info

{ kb_id: string; kb_name: string }[]

An array of objects representing knowledge bases associated with the file. Each object contains the KB's id and name.

location

string

The file's location path or URI in the storage system.

name

string

The file name, including its extension if applicable.

parent_id

string

The ID of the parent folder containing this file.

size

number

The size of the file in bytes.

tenant_id

string

Identifier for the tenant or organization owning the file (used in multi-tenant systems).

type

string

The MIME type or custom type classification of the file.

update_date

string

The date when the file was last updated.

update_time

number

The time component of the last update timestamp.

source_type

string

The origin or source type of the file (e.g., uploaded, imported).

has_child_folder?

boolean (optional)

Indicates whether this file entry also represents a folder with child folders (possibly for hybrid entries).

Usage Example

const exampleFile: IFile = {
  create_date: "2024-04-01",
  create_time: 1680307200,
  created_by: "user123",
  id: "file_001",
  kbs_info: [{ kb_id: "kb01", kb_name: "Product Docs" }],
  location: "/documents/reports",
  name: "Q1_Report.pdf",
  parent_id: "folder_123",
  size: 1048576,
  tenant_id: "tenant_abc",
  type: "application/pdf",
  update_date: "2024-04-15",
  update_time: 1681545600,
  source_type: "uploaded",
  has_child_folder: false
};

IFolder

Represents a folder entity with metadata similar to files but without knowledge base info and optional child folder flag.

Properties

Property

Type

Description

create_date

string

Date the folder was created.

create_time

number

Creation time component.

created_by

string

Creator identifier.

id

string

Unique folder identifier.

location

string

Path or URI of the folder.

name

string

Folder name.

parent_id

string

ID of the parent folder.

size

number

Total size of the folder contents (may be cumulative).

tenant_id

string

Tenant or organization owner.

type

string

Type classification (likely "folder").

update_date

string

Last update date.

update_time

number

Time component of the last update.

source_type

string

Origin or source type of the folder.

Usage Example

const exampleFolder: IFolder = {
  create_date: "2024-01-01",
  create_time: 1672531200,
  created_by: "admin",
  id: "folder_123",
  location: "/documents",
  name: "Reports",
  parent_id: "root",
  size: 5242880,
  tenant_id: "tenant_abc",
  type: "folder",
  update_date: "2024-04-10",
  update_time: 1681104000,
  source_type: "system"
};

IFetchFileListResult

Defines the structure of a result returned when fetching a list of files along with their parent folder metadata.

Properties

Property

Type

Description

files

IFile[]

Array of file objects retrieved.

parent_folder

IFolder

The folder object representing the parent folder of the files.

total

number

The total number of files in the list (useful for pagination).

Usage Example

const fetchResult: IFetchFileListResult = {
  files: [exampleFile],
  parent_folder: exampleFolder,
  total: 1
};

Important Implementation Details


Interaction with Other Parts of the System


Mermaid Class Diagram

classDiagram
    class IFile {
        +string create_date
        +number create_time
        +string created_by
        +string id
        +Array~{kb_id:string, kb_name:string}~ kbs_info
        +string location
        +string name
        +string parent_id
        +number size
        +string tenant_id
        +string type
        +string update_date
        +number update_time
        +string source_type
        +boolean has_child_folder (optional)
    }
    class IFolder {
        +string create_date
        +number create_time
        +string created_by
        +string id
        +string location
        +string name
        +string parent_id
        +number size
        +string tenant_id
        +string type
        +string update_date
        +number update_time
        +string source_type
    }
    class IFetchFileListResult {
        +Array~IFile~ files
        +IFolder parent_folder
        +number total
    }

Summary

The file-manager.ts file provides foundational TypeScript interfaces defining the metadata and structural shape of file and folder entities within the application. These interfaces are fundamental to the file management subsystem, enabling type-safe handling of file data, integration with knowledge bases, support for multi-tenancy, and consistent data exchange between backend services and frontend components.