Skip to content

Commit

Permalink
refactor: updated constructor type + interface intersections
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamorosi committed Dec 30, 2022
1 parent 3323c15 commit 1f4c91e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
13 changes: 9 additions & 4 deletions packages/parameters/src/ssm/SSMProvider.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { BaseProvider, DEFAULT_PROVIDERS, transformValue } from '../BaseProvider';
import { GetParameterError } from '../Exceptions';
import { DEFAULT_MAX_AGE_SECS } from '../constants';
import { SSMClient, GetParameterCommand, paginateGetParametersByPath, GetParametersCommand } from '@aws-sdk/client-ssm';
import {
SSMClient,
GetParameterCommand,
paginateGetParametersByPath,
GetParametersCommand
} from '@aws-sdk/client-ssm';
import type {
SSMClientConfig,
GetParameterCommandInput,
GetParametersByPathCommandInput,
GetParametersCommandInput,
GetParametersCommandOutput,
} from '@aws-sdk/client-ssm';
import type {
SSMProviderOptionsInterface,
SSMGetMultipleOptionsInterface,
SSMGetOptionsInterface,
SSMGetParametersByNameOutputInterface,
Expand All @@ -24,9 +29,9 @@ class SSMProvider extends BaseProvider {
protected errorsKey = '_errors';
protected maxGetParametersItems = 10;

public constructor(config: SSMClientConfig = {}) {
public constructor(config?: SSMProviderOptionsInterface) {
super();
this.client = new SSMClient(config);
this.client = new SSMClient(config?.clientConfig || {});
}

public async get(
Expand Down
15 changes: 12 additions & 3 deletions packages/parameters/src/types/SSMProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import type { GetParameterCommandInput, GetParametersByPathCommandInput } from '@aws-sdk/client-ssm';
import type {
SSMClientConfig,
GetParameterCommandInput,
GetParametersByPathCommandInput
} from '@aws-sdk/client-ssm';
import type { GetOptionsInterface, GetMultipleOptionsInterface, TransformOptions } from './BaseProvider';

interface SSMProviderOptionsInterface {
clientConfig: SSMClientConfig
}

/**
* Options for the SSMProvider get method.
*
Expand Down Expand Up @@ -31,7 +39,7 @@ interface SSMGetParametersByNameOptionsInterface {
type SSMSplitBatchAndDecryptParametersOutputType = {
parametersToFetchInBatch: Record<string, SSMGetParametersByNameOptionsInterface>
parametersToDecrypt: Record<string, SSMGetParametersByNameOptionsInterface>
} & { [key: string]: SSMGetParametersByNameOptionsInterface };
};

interface SSMGetParametersByNameOutputInterface {
response: Record<string, unknown>
Expand All @@ -41,9 +49,10 @@ interface SSMGetParametersByNameOutputInterface {
type SSMGetParametersByNameFromCacheOutputType = {
cached: Record<string, string | Record<string, unknown>>
toFetch: Record<string, SSMGetParametersByNameOptionsInterface>
} & { [key: string]: SSMGetParametersByNameOptionsInterface };
};

export {
SSMProviderOptionsInterface,
SSMGetOptionsInterface,
SSMGetMultipleOptionsInterface,
SSMGetParametersByNameOptionsInterface,
Expand Down

0 comments on commit 1f4c91e

Please sign in to comment.