@dmptool/utils 1.0.35 → 1.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dynamo.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface DynamoConnectionParams {
6
6
  logger: Logger;
7
7
  region: string;
8
8
  tableName: string;
9
+ endpoint?: string;
9
10
  maxAttempts: number;
10
11
  }
11
12
  export interface DMPVersionType {
package/dist/dynamo.js CHANGED
@@ -46,8 +46,11 @@ class DMPToolDynamoError extends Error {
46
46
  }
47
47
  // Initialize AWS SDK clients (outside the handler function)
48
48
  const getDynamoDBClient = (dynamoConfigParams) => {
49
- const { region, maxAttempts } = dynamoConfigParams;
50
- return new client_dynamodb_1.DynamoDBClient({ region, maxAttempts });
49
+ const { region, maxAttempts, endpoint } = dynamoConfigParams;
50
+ // If an endpoint was specified, we are running in a local environment
51
+ return endpoint === undefined
52
+ ? new client_dynamodb_1.DynamoDBClient({ region, maxAttempts })
53
+ : new client_dynamodb_1.DynamoDBClient({ region, maxAttempts, endpoint });
51
54
  };
52
55
  /**
53
56
  * Lightweight query just to check if the DMP exists.
package/dist/ssm.d.ts CHANGED
@@ -1,15 +1,19 @@
1
1
  import { EnvironmentEnum } from "./general";
2
2
  import { Logger } from 'pino';
3
+ export interface SsmConnectionParams {
4
+ logger: Logger;
5
+ region: string;
6
+ useTLS?: boolean;
7
+ endpoint?: string;
8
+ }
3
9
  /**
4
10
  * Retrieve a variable from the SSM Parameter store.
5
11
  *
6
- * @param logger The logger to use for logging.
12
+ * @param connectionParams The connection parameters to use for the SSM client.
7
13
  * @param key The name of the variable to retrieve.
8
14
  * @param env The environment to retrieve the variable from. Defaults to `EnvironmentEnum.DEV`.
9
- * @param region The region to retrieve the variable from. Defaults to 'us-west-2'.
10
- * @param useTLS Whether to use TLS when connecting to the SSM Parameter store. Defaults to true.
11
15
  * Should be false when running in a local development environment.
12
16
  * @returns The value of the variable, or undefined if the variable could not be found.
13
17
  * @throws
14
18
  */
15
- export declare const getSSMParameter: (logger: Logger, key: string, env?: EnvironmentEnum, endpoint?: string, region?: string, useTLS?: boolean) => Promise<string | undefined>;
19
+ export declare const getSSMParameter: (connectionParams: SsmConnectionParams, key: string, env?: EnvironmentEnum) => Promise<string | undefined>;
package/dist/ssm.js CHANGED
@@ -6,24 +6,22 @@ const client_ssm_1 = require("@aws-sdk/client-ssm");
6
6
  /**
7
7
  * Retrieve a variable from the SSM Parameter store.
8
8
  *
9
- * @param logger The logger to use for logging.
9
+ * @param connectionParams The connection parameters to use for the SSM client.
10
10
  * @param key The name of the variable to retrieve.
11
11
  * @param env The environment to retrieve the variable from. Defaults to `EnvironmentEnum.DEV`.
12
- * @param region The region to retrieve the variable from. Defaults to 'us-west-2'.
13
- * @param useTLS Whether to use TLS when connecting to the SSM Parameter store. Defaults to true.
14
12
  * Should be false when running in a local development environment.
15
13
  * @returns The value of the variable, or undefined if the variable could not be found.
16
14
  * @throws
17
15
  */
18
- const getSSMParameter = async (logger, key, env = general_1.EnvironmentEnum.DEV, endpoint, region = 'us-west-2', useTLS = true) => {
16
+ const getSSMParameter = async (connectionParams, key, env = general_1.EnvironmentEnum.DEV) => {
19
17
  var _a;
20
- if (logger && key && key.trim() !== '') {
18
+ if (connectionParams.logger && key && key.trim() !== '') {
21
19
  // Create an SSM client (use the endpoint if we are not using TLS - local dev)
22
- const client = useTLS
20
+ const client = connectionParams.useTLS
23
21
  ? new client_ssm_1.SSMClient()
24
- : new client_ssm_1.SSMClient({ endpoint, region, tls: false });
22
+ : new client_ssm_1.SSMClient(connectionParams);
25
23
  const keyPrefix = `/uc3/dmp/tool/${env.toLowerCase()}/`;
26
- logger.debug(`Fetching parameter ${keyPrefix}${key}`);
24
+ connectionParams.logger.debug(`Fetching parameter ${keyPrefix}${key}`);
27
25
  try {
28
26
  const command = new client_ssm_1.GetParameterCommand({
29
27
  Name: `${keyPrefix}${key}`,
@@ -33,10 +31,10 @@ const getSSMParameter = async (logger, key, env = general_1.EnvironmentEnum.DEV,
33
31
  if (!(0, general_1.isNullOrUndefined)(response) && !(0, general_1.isNullOrUndefined)(response.Parameter)) {
34
32
  return (_a = response.Parameter) === null || _a === void 0 ? void 0 : _a.Value;
35
33
  }
36
- logger.warn(`Parameter ${keyPrefix}${key} not found.`);
34
+ connectionParams.logger.warn(`Parameter ${keyPrefix}${key} not found.`);
37
35
  }
38
36
  catch (error) {
39
- logger.fatal(`Error fetching parameter ${keyPrefix}${key}: ${error}`);
37
+ connectionParams.logger.fatal(`Error fetching parameter ${keyPrefix}${key}: ${error}`);
40
38
  }
41
39
  }
42
40
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmptool/utils",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Helper/Utility functions for use in the DMP Tool services. Particularly AWS tooling and maDMP serialization",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,14 +41,14 @@
41
41
  "pino-lambda": "^4.4.1"
42
42
  },
43
43
  "peerDependencies": {
44
- "@aws-sdk/client-cloudformation": "^3.966.0",
45
- "@aws-sdk/client-dynamodb": "^3.966.0",
46
- "@aws-sdk/client-sqs": "^3.968.0",
47
- "@aws-sdk/client-s3": "^3.966.0",
48
- "@aws-sdk/client-sns": "^3.967.0",
49
- "@aws-sdk/client-ssm": "^3.966.0",
50
- "@aws-sdk/s3-request-presigner": "^3.966.0",
51
- "@aws-sdk/util-dynamodb": "^3.966.0"
44
+ "@aws-sdk/client-cloudformation": "^3.980.0",
45
+ "@aws-sdk/client-dynamodb": "^3.980.0",
46
+ "@aws-sdk/client-sqs": "^3.980.0",
47
+ "@aws-sdk/client-s3": "^3.980.0",
48
+ "@aws-sdk/client-sns": "^3.980.0",
49
+ "@aws-sdk/client-ssm": "^3.980.0",
50
+ "@aws-sdk/s3-request-presigner": "^3.980.0",
51
+ "@aws-sdk/util-dynamodb": "^3.980.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@aws-sdk/util-stream-node": "^3.370.0",