From 1f4d2f57b12baf5be531449fb776358e2e7b2dfd Mon Sep 17 00:00:00 2001 From: Astitva Sehgal <69433630+astitva1905@users.noreply.github.com> Date: Thu, 7 Sep 2023 17:24:14 +0530 Subject: [PATCH] Add files via upload --- docs/developer/lib-class.puml | 47 +++++++++++++++ docs/developer/lib-sequence.puml | 98 ++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 docs/developer/lib-class.puml create mode 100644 docs/developer/lib-sequence.puml diff --git a/docs/developer/lib-class.puml b/docs/developer/lib-class.puml new file mode 100644 index 000000000..580fb66ab --- /dev/null +++ b/docs/developer/lib-class.puml @@ -0,0 +1,47 @@ +@startuml +class FilesResolver { + -filesService: IFilesService + +listDirectory(path: string): Promise + +readFile(path: string): Promise +} + +interface IFilesService { + listDirectory(path: string): Promise + readFile(path: string): Promise +} + +class FilesServiceFactory { + -configService: ConfigService + -gitlabFilesService: GitlabFilesService + -localFilesService: LocalFilesService + +create(): IFilesService +} + +class GitlabFilesService { + -configService: ConfigService + -parseArguments(path: string): Promise<{ domain: string; parsedPath: string }> + -sendRequest(query: string): Promise + -executeQuery(path: string, getQuery: QueryFunction): Promise + +listDirectory(path: string): Promise + +readFile(path: string): Promise +} + +class LocalFilesService { + -configService: ConfigService + -getFileStats(fullPath: string, file: string): Promise + +listDirectory(path: string): Promise + +readFile(path: string): Promise +} + +class ConfigService { + +get(propertyPath: string): any +} + +FilesResolver --> IFilesService: uses +IFilesService <|.. GitlabFilesService: implements +IFilesService <|.. LocalFilesService: implements +FilesServiceFactory --> IFilesService: creates +FilesServiceFactory --> ConfigService: uses +GitlabFilesService --> ConfigService: uses +LocalFilesService --> ConfigService: uses +@enduml \ No newline at end of file diff --git a/docs/developer/lib-sequence.puml b/docs/developer/lib-sequence.puml new file mode 100644 index 000000000..a30110611 --- /dev/null +++ b/docs/developer/lib-sequence.puml @@ -0,0 +1,98 @@ +@startuml +actor Client +actor Traefik +box "RAMS" #LightGreen +participant "FilesResolver" as FR +participant "FilesServiceFactory" as FSF +participant "ConfigService" as CS +participant "IFilesService" as IFS +participant "LocalFilesService" as LFS +participant "GitlabFilesService" as GFS +end box +database "Local File System" as FS +database "GitLab API" as GAPI + +Client -> Traefik : HTTP request +Traefik -> FR : GraphQL query +activate FR + +FR -> FSF : create() +activate FSF + +FSF -> CS : getConfiguration("MODE") +activate CS + +CS --> FSF : return configuration value +deactivate CS + +alt MODE = Local + FSF -> FR : return filesService (LFS) + deactivate FSF + + FR -> IFS : listDirectory(path) or readFile(path) + activate IFS + + IFS -> LFS : listDirectory(path) or readFile(path) + activate LFS + + LFS -> CS : getConfiguration("LOCAL_PATH") + activate CS + + CS --> LFS : return local path + deactivate CS + + LFS -> FS : Access filesystem + alt Filesystem error + FS --> LFS : Filesystem error + LFS -> LFS : Throw new InternalServerErrorException + LFS --> IFS : Error + else Successful file operation + FS --> LFS : Return filesystem data + LFS -> IFS : return Promise + end + deactivate LFS +else MODE = GitLab + FSF -> FR : return filesService (GFS) + deactivate FSF + + FR -> IFS : listDirectory(path) or readFile(path) + activate IFS + + IFS -> GFS : listDirectory(path) or readFile(path) + activate GFS + + GFS -> GFS : parseArguments(path) + GFS -> GFS : executeQuery() + + GFS -> CS : getConfiguration("GITLAB_API_URL", "GITLAB_TOKEN") + activate CS + + CS --> GFS : return GitLab API URL and Token + deactivate CS + + GFS -> GAPI : sendRequest() + alt GitLab API error + GAPI --> GFS : API error + GFS -> GFS : Throw new Error("Invalid query") + GFS --> IFS : Error + else Successful GitLab API operation + GAPI --> GFS : Return API response + GFS -> IFS : return Promise + end + deactivate GFS +end + +alt Error thrown + IFS -> FR : return Error + deactivate IFS + FR -> Traefik : return Error + Traefik -> Client : HTTP error response +else Successful operation + IFS -> FR : return Promise + deactivate IFS + FR -> Traefik : return Promise + Traefik -> Client : HTTP response +end + +deactivate FR +@enduml \ No newline at end of file