Skip to content

Commit f9259eb

Browse files
committed
chore: break down classes in files
1 parent de13951 commit f9259eb

File tree

4 files changed

+61
-40
lines changed

4 files changed

+61
-40
lines changed

Diff for: packages/parameters/src/BaseProvider.ts

+4-40
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,13 @@
11
import { fromBase64 } from '@aws-sdk/util-base64-node';
2+
import { GetOptions } from './GetOptions';
3+
import { GetMultipleOptions } from './GetMultipleOptions';
4+
import { ExpirableValue } from './ExpirableValue';
25
import { GetParameterError, TransformParameterError } from './Exceptions';
3-
import type { BaseProviderInterface, ExpirableValueInterface, GetMultipleOptionsInterface, GetOptionsInterface, TransformOptions } from './types';
6+
import type { BaseProviderInterface, GetMultipleOptionsInterface, GetOptionsInterface, TransformOptions } from './types';
47

5-
const DEFAULT_MAX_AGE_SECS = 5;
68
const TRANSFORM_METHOD_JSON = 'json';
79
const TRANSFORM_METHOD_BINARY = 'binary';
810

9-
class GetOptions implements GetOptionsInterface {
10-
public forceFetch: boolean = false;
11-
public maxAge: number = DEFAULT_MAX_AGE_SECS;
12-
public sdkOptions?: unknown;
13-
public transform?: TransformOptions;
14-
15-
public constructor(options: GetOptionsInterface = {}) {
16-
Object.assign(this, options);
17-
}
18-
}
19-
20-
class GetMultipleOptions implements GetMultipleOptionsInterface {
21-
public forceFetch: boolean = false;
22-
public maxAge: number = DEFAULT_MAX_AGE_SECS;
23-
public sdkOptions?: unknown;
24-
public throwOnTransformError: boolean = false;
25-
public transform?: TransformOptions;
26-
27-
public constructor(options: GetMultipleOptionsInterface) {
28-
Object.assign(this, options);
29-
}
30-
}
31-
32-
class ExpirableValue implements ExpirableValueInterface {
33-
public ttl: number;
34-
public value: string | Record<string, unknown>;
35-
36-
public constructor(value: string | Record<string, unknown>, maxAge: number) {
37-
this.value = value;
38-
const timeNow = new Date();
39-
this.ttl = timeNow.setSeconds(timeNow.getSeconds() + maxAge);
40-
}
41-
42-
public isExpired(): boolean {
43-
return this.ttl < Date.now();
44-
}
45-
}
46-
4711
abstract class BaseProvider implements BaseProviderInterface {
4812
public store: Map<string, ExpirableValue> = new Map;
4913

Diff for: packages/parameters/src/ExpirableValue.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { ExpirableValueInterface } from './types';
2+
3+
class ExpirableValue implements ExpirableValueInterface {
4+
public ttl: number;
5+
public value: string | Record<string, unknown>;
6+
7+
public constructor(value: string | Record<string, unknown>, maxAge: number) {
8+
this.value = value;
9+
const timeNow = new Date();
10+
this.ttl = timeNow.setSeconds(timeNow.getSeconds() + maxAge);
11+
}
12+
13+
public isExpired(): boolean {
14+
return this.ttl < Date.now();
15+
}
16+
}
17+
18+
export {
19+
ExpirableValue
20+
};

Diff for: packages/parameters/src/GetMultipleOptions.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { GetMultipleOptionsInterface, TransformOptions } from './types';
2+
3+
const DEFAULT_MAX_AGE_SECS = 5;
4+
5+
class GetMultipleOptions implements GetMultipleOptionsInterface {
6+
public forceFetch: boolean = false;
7+
public maxAge: number = DEFAULT_MAX_AGE_SECS;
8+
public sdkOptions?: unknown;
9+
public throwOnTransformError: boolean = false;
10+
public transform?: TransformOptions;
11+
12+
public constructor(options: GetMultipleOptionsInterface) {
13+
Object.assign(this, options);
14+
}
15+
}
16+
17+
export {
18+
GetMultipleOptions
19+
};

Diff for: packages/parameters/src/GetOptions.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { GetOptionsInterface, TransformOptions } from './types';
2+
3+
const DEFAULT_MAX_AGE_SECS = 5;
4+
5+
class GetOptions implements GetOptionsInterface {
6+
public forceFetch: boolean = false;
7+
public maxAge: number = DEFAULT_MAX_AGE_SECS;
8+
public sdkOptions?: unknown;
9+
public transform?: TransformOptions;
10+
11+
public constructor(options: GetOptionsInterface = {}) {
12+
Object.assign(this, options);
13+
}
14+
}
15+
16+
export {
17+
GetOptions
18+
};

0 commit comments

Comments
 (0)