@hestia-earth/pipeline-utils 0.15.5 → 0.16.1

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/src/sns.ts CHANGED
@@ -1,6 +1,5 @@
1
- import * as AWS from 'aws-sdk';
2
- import { from, of, throwError } from 'rxjs';
3
- import { take, map, catchError } from 'rxjs/operators';
1
+ import { SNSClient, PublishCommand } from '@aws-sdk/client-sns';
2
+ import { from, of, throwError, take, map, catchError } from 'rxjs';
4
3
 
5
4
  import { error, info } from './log';
6
5
  import { IFunctionParam, isS3Mode } from './s3';
@@ -18,8 +17,8 @@ export const publishSnsMessage = (
18
17
  ) =>
19
18
  isS3Mode
20
19
  ? from(
21
- new AWS.SNS()
22
- .publish({
20
+ new SNSClient({}).send(
21
+ new PublishCommand({
23
22
  TopicArn: topicArn,
24
23
  Message: JSON.stringify(params),
25
24
  MessageAttributes: {
@@ -38,7 +37,7 @@ export const publishSnsMessage = (
38
37
  )
39
38
  }
40
39
  })
41
- .promise()
40
+ )
42
41
  ).pipe(
43
42
  take(1),
44
43
  map(res => {
package/src/sqs.ts CHANGED
@@ -1,6 +1,5 @@
1
- import * as AWS from 'aws-sdk';
2
- import { from, of } from 'rxjs';
3
- import { take, map } from 'rxjs/operators';
1
+ import { SQSClient, SendMessageCommand, SendMessageCommandInput } from '@aws-sdk/client-sqs';
2
+ import { from, of, take, map } from 'rxjs';
4
3
 
5
4
  import { info } from './log';
6
5
  import { IFunctionParam, isS3Mode, region } from './s3';
@@ -14,12 +13,12 @@ export const sendSqsMessage = (
14
13
  params: IFunctionParam | Record<string, any>,
15
14
  queueUrl = process.env.SQS_URL,
16
15
  extras: attributes = {},
17
- requestParams: Partial<Omit<AWS.SQS.Types.SendMessageRequest, 'QueueUrl' | 'MessageBody' | 'MessageAttributes'>> = {}
16
+ requestParams: Partial<Omit<SendMessageCommandInput, 'QueueUrl' | 'MessageBody' | 'MessageAttributes'>> = {}
18
17
  ) =>
19
18
  isS3Mode
20
19
  ? from(
21
- new AWS.SQS({ region })
22
- .sendMessage({
20
+ new SQSClient({ region }).send(
21
+ new SendMessageCommand({
23
22
  QueueUrl: queueUrl,
24
23
  MessageBody: JSON.stringify(params),
25
24
  MessageAttributes: {
@@ -39,7 +38,7 @@ export const sendSqsMessage = (
39
38
  },
40
39
  ...requestParams
41
40
  })
42
- .promise()
41
+ )
43
42
  ).pipe(
44
43
  take(1),
45
44
  map(res => {
@@ -39,9 +39,9 @@ const stringify = (writeStream: WriteStream, data: any) =>
39
39
  : writeStream.write(JSON.stringify(data), encoding);
40
40
 
41
41
  export const streamJSONToFile = (filepath: string, data: Record<string, any>) =>
42
- new Promise((resolve, reject) => {
42
+ new Promise<void>((resolve, reject) => {
43
43
  const writeStream = createWriteStream(filepath);
44
- writeStream.on('finish', resolve);
44
+ writeStream.on('finish', () => resolve());
45
45
  writeStream.on('error', reject);
46
46
  stringify(writeStream, data);
47
47
  writeStream.end();