-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
68 lines (60 loc) · 2.64 KB
/
Copy pathindex.ts
File metadata and controls
68 lines (60 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { reactive } from 'vue';
import { TdeiAuthStore, TdeiClient, TdeiUserClient } from '~/services/tdei';
import {
AugmentedDiffCache,
AugmentedDiffDb,
OsmChangeCache,
OsmChangeDb,
ChangesetManager,
} from '~/services/changesets';
import { OsmApiClient } from '~/services/osm';
import { PathwaysEditorManager } from '~/services/pathways';
import { ProjectWizardClient } from '~/services/project-wizard';
import { ReviewManager } from '~/services/review';
import { RapidManager } from '~/services/rapid';
import { Rapid3Manager } from '~/services/rapid3';
import { WorkspaceProjectsClient } from '~/services/projects';
import { WorkspacesClient } from '~/services/workspaces';
const tdeiApiUrl = import.meta.env.VITE_TDEI_API_URL;
const tdeiUserApiUrl = import.meta.env.VITE_TDEI_USER_API_URL;
const apiUrl = import.meta.env.VITE_API_URL;
const newApiUrl = import.meta.env.VITE_NEW_API_URL;
if (!newApiUrl) {
throw new Error('VITE_NEW_API_URL is required');
}
const osmWebUrl = import.meta.env.VITE_OSM_URL;
const osmApiUrl = osmWebUrl + 'api/0.6/';
const rapidUrl = import.meta.env.VITE_RAPID_URL;
const rapid3Url = import.meta.env.VITE_RAPID3_URL;
const pathwaysUrl = import.meta.env.VITE_PATHWAYS_EDITOR_URL;
export const tdeiAuth = reactive(new TdeiAuthStore());
export const tdeiClient = new TdeiClient(tdeiApiUrl, tdeiAuth);
export const tdeiUserClient = new TdeiUserClient(tdeiUserApiUrl, tdeiClient);
tdeiClient.restartAutoAuthRefresh();
export const osmClient = new OsmApiClient(osmWebUrl, osmApiUrl, tdeiClient);
export const workspacesClient = new WorkspacesClient(apiUrl, newApiUrl, tdeiClient, osmClient);
export const workspaceProjectsClient = new WorkspaceProjectsClient(
newApiUrl,
tdeiClient,
);
export const projectWizardClient = new ProjectWizardClient(newApiUrl, tdeiClient);
const oscCacheTtl = 1000 * 60 * 60 * 24 * 45; // 45 days
const adiffCacheTtl = oscCacheTtl;
const oscKeypath = ['workspaceId', 'changesetId'];
const adiffKeypath = oscKeypath;
const oscCacheDb = new OsmChangeDb('osc-cache', oscCacheTtl, oscKeypath);
const adiffCacheDb = new AugmentedDiffDb('adiff-cache', adiffCacheTtl, adiffKeypath);
export const changesetManager = new ChangesetManager(
osmClient,
workspacesClient,
new OsmChangeCache(oscCacheDb),
new AugmentedDiffCache(adiffCacheDb));
export const reviewManager = new ReviewManager(
changesetManager,
osmClient,
tdeiClient,
workspacesClient,
);
export const rapidManager = new RapidManager(rapidUrl, osmWebUrl, tdeiAuth);
export const rapid3Manager = rapid3Url ? new Rapid3Manager(rapid3Url, osmWebUrl, tdeiAuth) : null;
export const pathwaysManager = new PathwaysEditorManager(pathwaysUrl, osmWebUrl, tdeiAuth);