|
1 | 1 | import * as _ from 'lodash'; |
2 | 2 | import * as os from 'os'; |
3 | 3 |
|
4 | | -import { ErrorLike, delay } from '@httptoolkit/util'; |
| 4 | +import { type ErrorLike, delay } from '@httptoolkit/util'; |
5 | 5 | import { generateSPKIFingerprint } from 'mockttp'; |
6 | 6 | import { getSystemProxy } from 'os-proxy-config'; |
7 | 7 |
|
8 | | -import { SERVER_VERSION } from "../constants"; |
9 | | -import { logError, addBreadcrumb } from '../error-tracking'; |
| 8 | +import { SERVER_VERSION } from '../constants.ts'; |
| 9 | +import { logError, addBreadcrumb } from '../error-tracking.ts'; |
10 | 10 |
|
11 | | -import { HtkConfig } from "../config"; |
12 | | -import { ActivationError, Interceptor } from "../interceptors"; |
13 | | -import { getDnsServer } from '../dns-server'; |
14 | | -import { getCertExpiry, parseCert } from '../certificates'; |
| 11 | +import type { HtkConfig } from '../config.d.ts'; |
| 12 | +import { ActivationError, Interceptor } from '../interceptors/index.ts'; |
| 13 | +import { getDnsServer } from '../dns-server.ts'; |
| 14 | +import { getCertExpiry, parseCert } from '../certificates.ts'; |
15 | 15 |
|
16 | | -import * as Client from '../client/client-types'; |
17 | | -import { HttpClient } from '../client/http-client'; |
| 16 | +import * as Client from '../client/client-types.ts'; |
| 17 | +import { HttpClient } from '../client/http-client.ts'; |
18 | 18 |
|
19 | 19 | const INTERCEPTOR_TIMEOUT = 1000; |
20 | 20 |
|
21 | 21 | export class ApiModel { |
22 | 22 |
|
| 23 | + private config: HtkConfig; |
| 24 | + private interceptors: _.Dictionary<Interceptor>; |
| 25 | + private getRuleParamKeys: () => string[]; |
| 26 | + private httpClient: HttpClient; |
| 27 | + private callbacks: { |
| 28 | + onTriggerUpdate: () => void, |
| 29 | + onTriggerShutdown: () => void |
| 30 | + }; |
| 31 | + |
23 | 32 | constructor( |
24 | | - private config: HtkConfig, |
25 | | - private interceptors: _.Dictionary<Interceptor>, |
26 | | - private getRuleParamKeys: () => string[], |
27 | | - private httpClient: HttpClient, |
28 | | - private callbacks: { |
| 33 | + config: HtkConfig, |
| 34 | + interceptors: _.Dictionary<Interceptor>, |
| 35 | + getRuleParamKeys: () => string[], |
| 36 | + httpClient: HttpClient, |
| 37 | + callbacks: { |
29 | 38 | onTriggerUpdate: () => void, |
30 | 39 | onTriggerShutdown: () => void |
31 | 40 | } |
32 | | - ) {} |
| 41 | + ) { |
| 42 | + this.config = config; |
| 43 | + this.interceptors = interceptors; |
| 44 | + this.getRuleParamKeys = getRuleParamKeys; |
| 45 | + this.httpClient = httpClient; |
| 46 | + this.callbacks = callbacks; |
| 47 | + } |
33 | 48 |
|
34 | 49 | getVersion() { |
35 | 50 | return SERVER_VERSION; |
|
0 commit comments