@dmptool/utils 1.0.33 → 1.0.35
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/sqs.d.ts +3 -1
- package/dist/sqs.js +10 -2
- package/dist/ssm.d.ts +4 -1
- package/dist/ssm.js +8 -3
- package/package.json +1 -1
package/dist/sqs.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export interface SendMessageResponse {
|
|
|
13
13
|
* @param detailType The type of message
|
|
14
14
|
* @param detail The payload of the message (will be accessible to the invoked resource)
|
|
15
15
|
* @param region The region to publish the message in. Defaults to 'us-west-2'.
|
|
16
|
+
* @param useTLS Whether to use TLS when sending the message. Defaults to true.
|
|
17
|
+
* Should be false when running in a local development environment.
|
|
16
18
|
* @returns A SendMessageResponse object containing the status code and message info.
|
|
17
19
|
* @throws Error if there was an error sending the message
|
|
18
20
|
*/
|
|
19
|
-
export declare const sendMessage: (logger: Logger, queueURL: string, source: string, detailType: string, details: Record<string, unknown>, region?: string) => Promise<SendMessageResponse>;
|
|
21
|
+
export declare const sendMessage: (logger: Logger, queueURL: string, source: string, detailType: string, details: Record<string, unknown>, region?: string, useTLS?: boolean) => Promise<SendMessageResponse>;
|
package/dist/sqs.js
CHANGED
|
@@ -12,15 +12,23 @@ const general_1 = require("./general");
|
|
|
12
12
|
* @param detailType The type of message
|
|
13
13
|
* @param detail The payload of the message (will be accessible to the invoked resource)
|
|
14
14
|
* @param region The region to publish the message in. Defaults to 'us-west-2'.
|
|
15
|
+
* @param useTLS Whether to use TLS when sending the message. Defaults to true.
|
|
16
|
+
* Should be false when running in a local development environment.
|
|
15
17
|
* @returns A SendMessageResponse object containing the status code and message info.
|
|
16
18
|
* @throws Error if there was an error sending the message
|
|
17
19
|
*/
|
|
18
|
-
const sendMessage = async (logger, queueURL, source, detailType, details, region = 'us-west-2'
|
|
20
|
+
const sendMessage = async (logger, queueURL, source, detailType, details, region = 'us-west-2', useTLS = true // Should be false when running in a local dev environment
|
|
21
|
+
) => {
|
|
19
22
|
var _a, _b;
|
|
20
23
|
let errMsg = '';
|
|
21
24
|
if (logger && queueURL) {
|
|
22
25
|
// Create a new SQS client instance
|
|
23
|
-
const client = new client_sqs_1.SQSClient({
|
|
26
|
+
const client = new client_sqs_1.SQSClient({
|
|
27
|
+
region,
|
|
28
|
+
// These should be false when running in a local dev environment
|
|
29
|
+
useQueueUrlAsEndpoint: useTLS || true,
|
|
30
|
+
tls: useTLS || true,
|
|
31
|
+
});
|
|
24
32
|
logger.debug({ queueURL, source, detailType, details }, 'Sending message');
|
|
25
33
|
try {
|
|
26
34
|
// Send the message
|
package/dist/ssm.d.ts
CHANGED
|
@@ -6,7 +6,10 @@ import { Logger } from 'pino';
|
|
|
6
6
|
* @param logger The logger to use for logging.
|
|
7
7
|
* @param key The name of the variable to retrieve.
|
|
8
8
|
* @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
|
+
* Should be false when running in a local development environment.
|
|
9
12
|
* @returns The value of the variable, or undefined if the variable could not be found.
|
|
10
13
|
* @throws
|
|
11
14
|
*/
|
|
12
|
-
export declare const getSSMParameter: (logger: Logger, key: string, env?: EnvironmentEnum) => Promise<string | undefined>;
|
|
15
|
+
export declare const getSSMParameter: (logger: Logger, key: string, env?: EnvironmentEnum, endpoint?: string, region?: string, useTLS?: boolean) => Promise<string | undefined>;
|
package/dist/ssm.js
CHANGED
|
@@ -9,14 +9,19 @@ const client_ssm_1 = require("@aws-sdk/client-ssm");
|
|
|
9
9
|
* @param logger The logger to use for logging.
|
|
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
|
+
* Should be false when running in a local development environment.
|
|
12
15
|
* @returns The value of the variable, or undefined if the variable could not be found.
|
|
13
16
|
* @throws
|
|
14
17
|
*/
|
|
15
|
-
const getSSMParameter = async (logger, key, env = general_1.EnvironmentEnum.DEV) => {
|
|
18
|
+
const getSSMParameter = async (logger, key, env = general_1.EnvironmentEnum.DEV, endpoint, region = 'us-west-2', useTLS = true) => {
|
|
16
19
|
var _a;
|
|
17
20
|
if (logger && key && key.trim() !== '') {
|
|
18
|
-
// Create an SSM client
|
|
19
|
-
const client =
|
|
21
|
+
// Create an SSM client (use the endpoint if we are not using TLS - local dev)
|
|
22
|
+
const client = useTLS
|
|
23
|
+
? new client_ssm_1.SSMClient()
|
|
24
|
+
: new client_ssm_1.SSMClient({ endpoint, region, tls: false });
|
|
20
25
|
const keyPrefix = `/uc3/dmp/tool/${env.toLowerCase()}/`;
|
|
21
26
|
logger.debug(`Fetching parameter ${keyPrefix}${key}`);
|
|
22
27
|
try {
|
package/package.json
CHANGED