e77b5d3aa89b18a5fa8d4e1f3b2de2826f93f523
[arvados-workbench2.git] / src / services / services.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { AuthService } from "./auth-service/auth-service";
6 import { GroupsService } from "./groups-service/groups-service";
7 import { ProjectService } from "./project-service/project-service";
8 import { LinkService } from "./link-service/link-service";
9 import { FavoriteService } from "./favorite-service/favorite-service";
10 import { AxiosInstance } from "axios";
11 import { CollectionService } from "./collection-service/collection-service";
12 import { TagService } from "./tag-service/tag-service";
13 import Axios from "axios";
14 import { CollectionFilesService } from "./collection-files-service/collection-files-service";
15 import { KeepService } from "./keep-service/keep-service";
16
17 export interface ServiceRepository {
18     apiClient: AxiosInstance;
19
20     authService: AuthService;
21     keepService: KeepService;
22     groupsService: GroupsService;
23     projectService: ProjectService;
24     linkService: LinkService;
25     favoriteService: FavoriteService;
26     tagService: TagService;
27     collectionService: CollectionService;
28     collectionFilesService: CollectionFilesService;
29 }
30
31 export const createServices = (baseUrl: string): ServiceRepository => {
32     const apiClient = Axios.create();
33     apiClient.defaults.baseURL = `${baseUrl}/arvados/v1`;
34
35     const authService = new AuthService(apiClient, baseUrl);
36     const keepService = new KeepService(apiClient);
37     const groupsService = new GroupsService(apiClient);
38     const projectService = new ProjectService(apiClient);
39     const linkService = new LinkService(apiClient);
40     const favoriteService = new FavoriteService(linkService, groupsService);
41     const collectionService = new CollectionService(apiClient, keepService);
42     const tagService = new TagService(linkService);
43     const collectionFilesService = new CollectionFilesService(collectionService);
44
45     return {
46         apiClient,
47         authService,
48         keepService,
49         groupsService,
50         projectService,
51         linkService,
52         favoriteService,
53         collectionService,
54         tagService,
55         collectionFilesService
56     };
57 };