idea-aws 3.16.7 → 4.0.0

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/src/s3.js CHANGED
@@ -1,7 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.GetObjectTypes = exports.S3 = void 0;
4
- const aws_sdk_1 = require("aws-sdk");
27
+ const AWSS3 = __importStar(require("@aws-sdk/client-s3"));
28
+ const lib_storage_1 = require("@aws-sdk/lib-storage");
29
+ const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
5
30
  const idea_toolbox_1 = require("idea-toolbox");
6
31
  const logger_1 = require("./logger");
7
32
  /**
@@ -14,7 +39,7 @@ class S3 {
14
39
  this.DEFAULT_DOWNLOAD_BUCKET_SEC_TO_EXP = 180;
15
40
  this.DEFAULT_UPLOAD_BUCKET_SEC_TO_EXP = 300;
16
41
  this.logger = new logger_1.Logger();
17
- this.s3 = new aws_sdk_1.S3({ apiVersion: '2006-03-01', signatureVersion: 'v4' });
42
+ this.s3 = new AWSS3.S3Client();
18
43
  this.logger.level = options.debug ? 'DEBUG' : 'INFO';
19
44
  }
20
45
  /**
@@ -24,59 +49,59 @@ class S3 {
24
49
  async createDownloadURLFromData(data, options = {}) {
25
50
  // if needed, randomly generates the key
26
51
  if (!options.key)
27
- options.key = new Date().getTime().toString().concat(Math.random().toString(36).slice(2));
52
+ options.key = Date.now().toString().concat(Math.random().toString(36).slice(2));
28
53
  options.key = `${options.prefix || this.DEFAULT_DOWNLOAD_BUCKET_PREFIX}/${options.key}`;
29
54
  options.bucket = options.bucket || this.DEFAULT_DOWNLOAD_BUCKET;
30
55
  options.secToExp = options.secToExp || this.DEFAULT_DOWNLOAD_BUCKET_SEC_TO_EXP;
31
- await this.s3
32
- .upload({ Bucket: options.bucket, Key: options.key, Body: data, ContentType: options.contentType })
33
- .promise();
56
+ const params = { Bucket: options.bucket, Key: options.key, Body: data, ContentType: options.contentType };
57
+ const upload = new lib_storage_1.Upload({ client: this.s3, params });
58
+ await upload.done();
34
59
  return this.signedURLGet(options.bucket, options.key, options.secToExp);
35
60
  }
36
61
  /**
37
62
  * Get a signed URL to put a file on a S3 bucket.
38
63
  * @param expires seconds after which the signed URL expires
39
64
  */
40
- signedURLPut(bucket, key, expires) {
41
- return new idea_toolbox_1.SignedURL({
42
- url: this.s3.getSignedUrl('putObject', {
43
- Bucket: bucket,
44
- Key: key,
45
- Expires: expires || this.DEFAULT_UPLOAD_BUCKET_SEC_TO_EXP
46
- })
47
- });
65
+ async signedURLPut(bucket, key, expires) {
66
+ const putCommand = new AWSS3.PutObjectCommand({ Bucket: bucket, Key: key });
67
+ const expiresIn = expires || this.DEFAULT_UPLOAD_BUCKET_SEC_TO_EXP;
68
+ const url = await (0, s3_request_presigner_1.getSignedUrl)(this.s3, putCommand, { expiresIn });
69
+ return new idea_toolbox_1.SignedURL({ url });
48
70
  }
49
71
  /**
50
72
  * Get a signed URL to get a file on a S3 bucket.
51
73
  * @param expires seconds after which the signed URL expires
52
74
  */
53
- signedURLGet(bucket, key, expires) {
54
- return new idea_toolbox_1.SignedURL({
55
- url: this.s3.getSignedUrl('getObject', {
56
- Bucket: bucket,
57
- Key: key,
58
- Expires: expires || this.DEFAULT_DOWNLOAD_BUCKET_SEC_TO_EXP
59
- })
60
- });
75
+ async signedURLGet(bucket, key, expires) {
76
+ const getCommand = new AWSS3.GetObjectCommand({ Bucket: bucket, Key: key });
77
+ const expiresIn = expires || this.DEFAULT_UPLOAD_BUCKET_SEC_TO_EXP;
78
+ const url = await (0, s3_request_presigner_1.getSignedUrl)(this.s3, getCommand, { expiresIn });
79
+ return new idea_toolbox_1.SignedURL({ url });
61
80
  }
62
81
  /**
63
82
  * Make a copy of an object of the bucket.
64
83
  */
65
84
  async copyObject(options) {
66
85
  this.logger.debug(`S3 copy object: ${options.key}`);
67
- await this.s3.copyObject({ CopySource: options.copySource, Bucket: options.bucket, Key: options.key }).promise();
86
+ const command = new AWSS3.CopyObjectCommand({
87
+ CopySource: options.copySource,
88
+ Bucket: options.bucket,
89
+ Key: options.key
90
+ });
91
+ await this.s3.send(command);
68
92
  }
69
93
  /**
70
94
  * Get an object from a S3 bucket.
71
95
  */
72
96
  async getObject(options) {
73
97
  this.logger.debug(`S3 get object: ${options.key}`);
74
- const result = await this.s3.getObject({ Bucket: options.bucket, Key: options.key }).promise();
98
+ const command = new AWSS3.GetObjectCommand({ Bucket: options.bucket, Key: options.key });
99
+ const result = await this.s3.send(command);
75
100
  switch (options.type) {
76
101
  case GetObjectTypes.JSON:
77
- return JSON.parse(result.Body.toString('utf-8'));
102
+ return JSON.parse(await result.Body.transformToString('utf-8'));
78
103
  case GetObjectTypes.TEXT:
79
- return result.Body.toString('utf-8');
104
+ return await result.Body.transformToString('utf-8');
80
105
  default:
81
106
  return result;
82
107
  }
@@ -93,21 +118,23 @@ class S3 {
93
118
  if (options.metadata)
94
119
  params.Metadata = options.metadata;
95
120
  this.logger.debug(`S3 put object: ${options.key}`);
96
- return await this.s3.putObject(params).promise();
121
+ return await this.s3.send(new AWSS3.PutObjectCommand(params));
97
122
  }
98
123
  /**
99
124
  * Delete an object from an S3 bucket.
100
125
  */
101
126
  async deleteObject(options) {
102
127
  this.logger.debug(`S3 delete object: ${options.key}`);
103
- return await this.s3.deleteObject({ Bucket: options.bucket, Key: options.key }).promise();
128
+ const deleteCommand = new AWSS3.DeleteObjectCommand({ Bucket: options.bucket, Key: options.key });
129
+ return await this.s3.send(deleteCommand);
104
130
  }
105
131
  /**
106
132
  * List the objects of an S3 bucket.
107
133
  */
108
134
  async listObjects(options) {
109
135
  this.logger.debug(`S3 list object: ${options.prefix}`);
110
- return await this.s3.listObjects({ Bucket: options.bucket, Prefix: options.prefix }).promise();
136
+ const command = new AWSS3.ListObjectsCommand({ Bucket: options.bucket, Prefix: options.prefix });
137
+ return await this.s3.send(command);
111
138
  }
112
139
  /**
113
140
  * List the objects keys of an S3 bucket.
@@ -121,7 +148,8 @@ class S3 {
121
148
  */
122
149
  async doesObjectExist(options) {
123
150
  try {
124
- await this.s3.headObject({ Bucket: options.bucket, Key: options.key }).promise();
151
+ const command = new AWSS3.HeadObjectCommand({ Bucket: options.bucket, Key: options.key });
152
+ await this.s3.send(command);
125
153
  return true;
126
154
  }
127
155
  catch (err) {
@@ -137,4 +165,4 @@ var GetObjectTypes;
137
165
  (function (GetObjectTypes) {
138
166
  GetObjectTypes["JSON"] = "JSON";
139
167
  GetObjectTypes["TEXT"] = "TEXT";
140
- })(GetObjectTypes = exports.GetObjectTypes || (exports.GetObjectTypes = {}));
168
+ })(GetObjectTypes || (exports.GetObjectTypes = GetObjectTypes = {}));
@@ -1,9 +1,9 @@
1
- import { SecretsManager as AWSSecretsManager } from 'aws-sdk';
1
+ import * as AWSSecretsManager from '@aws-sdk/client-secrets-manager';
2
2
  /**
3
3
  * A wrapper for AWS Secrets manager.
4
4
  */
5
5
  export declare class SecretsManager {
6
- protected sm: AWSSecretsManager;
6
+ protected sm: AWSSecretsManager.SecretsManagerClient;
7
7
  constructor();
8
8
  /**
9
9
  * Get a secret string from the Secret Manager by its id.
@@ -1,19 +1,43 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.SecretsManager = void 0;
4
- const aws_sdk_1 = require("aws-sdk");
27
+ const AWSSecretsManager = __importStar(require("@aws-sdk/client-secrets-manager"));
5
28
  /**
6
29
  * A wrapper for AWS Secrets manager.
7
30
  */
8
31
  class SecretsManager {
9
32
  constructor() {
10
- this.sm = new aws_sdk_1.SecretsManager();
33
+ this.sm = new AWSSecretsManager.SecretsManagerClient();
11
34
  }
12
35
  /**
13
36
  * Get a secret string from the Secret Manager by its id.
14
37
  */
15
38
  async getStringById(secretId) {
16
- const result = await this.sm.getSecretValue({ SecretId: secretId }).promise();
39
+ const command = new AWSSecretsManager.GetSecretValueCommand({ SecretId: secretId });
40
+ const result = await this.sm.send(command);
17
41
  return result.SecretString;
18
42
  }
19
43
  }
package/dist/src/ses.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { SES as AWSSES } from 'aws-sdk';
2
+ import * as AWSSES from '@aws-sdk/client-sesv2';
3
3
  import { SentMessageInfo as NodemailerSentMessageInfo } from 'nodemailer';
4
4
  import { Headers } from 'nodemailer/lib/mailer';
5
5
  import { Logger } from './logger';
@@ -7,22 +7,22 @@ import { Logger } from './logger';
7
7
  * A wrapper for AWS Simple Email Service.
8
8
  */
9
9
  export declare class SES {
10
- protected ses: AWSSES;
10
+ protected ses: AWSSES.SESv2Client;
11
11
  logger: Logger;
12
12
  constructor(options?: {
13
13
  region?: string;
14
14
  debug: boolean;
15
15
  });
16
- getTemplate(templateName: string): Promise<AWSSES.Template>;
16
+ getTemplate(templateName: string): Promise<AWSSES.EmailTemplateContent>;
17
17
  setTemplate(templateName: string, subject: string, content: string, isHTML?: boolean): Promise<void>;
18
18
  deleteTemplate(templateName: string): Promise<void>;
19
19
  testTemplate(templateName: string, data: {
20
20
  [variable: string]: any;
21
- }): Promise<AWSSES.RenderedTemplate>;
21
+ }): Promise<string>;
22
22
  /**
23
23
  * Send a templated email through AWS Simple Email Service.
24
24
  */
25
- sendTemplatedEmail(emailData: TemplatedEmailData, sesParams: SESParams): Promise<AWSSES.SendTemplatedEmailResponse>;
25
+ sendTemplatedEmail(emailData: TemplatedEmailData, sesParams: SESParams): Promise<AWSSES.SendEmailCommandOutput>;
26
26
  /**
27
27
  * Send an email through AWS Simple Email Service.
28
28
  * It supports IDEA's teams custom configuration.
package/dist/src/ses.js CHANGED
@@ -1,7 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.SES = void 0;
4
- const aws_sdk_1 = require("aws-sdk");
27
+ const AWSSES = __importStar(require("@aws-sdk/client-sesv2"));
5
28
  const nodemailer_1 = require("nodemailer");
6
29
  const dynamoDB_1 = require("./dynamoDB");
7
30
  const logger_1 = require("./logger");
@@ -11,38 +34,52 @@ const logger_1 = require("./logger");
11
34
  class SES {
12
35
  constructor(options = { debug: true }) {
13
36
  this.logger = new logger_1.Logger();
14
- this.ses = new aws_sdk_1.SES({ region: options.region });
37
+ this.ses = new AWSSES.SESv2Client({ region: options.region });
15
38
  this.logger.level = options.debug ? 'DEBUG' : 'INFO';
16
39
  }
17
40
  //
18
41
  // CONFIG
19
42
  //
20
43
  async getTemplate(templateName) {
21
- return (await this.ses.getTemplate({ TemplateName: templateName }).promise()).Template;
44
+ const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName });
45
+ const { TemplateContent } = await this.ses.send(command);
46
+ return TemplateContent;
22
47
  }
23
48
  async setTemplate(templateName, subject, content, isHTML) {
24
- const template = { TemplateName: templateName, SubjectPart: subject };
25
- if (isHTML)
26
- template.HtmlPart = content;
27
- else
28
- template.TextPart = content;
29
49
  let isNew = false;
30
50
  try {
31
- await this.ses.getTemplate({ TemplateName: templateName }).promise();
51
+ const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName });
52
+ await this.ses.send(command);
32
53
  }
33
54
  catch (notFound) {
34
55
  isNew = true;
35
56
  }
57
+ const template = {
58
+ TemplateName: templateName,
59
+ TemplateContent: { Subject: subject }
60
+ };
61
+ if (isHTML)
62
+ template.TemplateContent.Html = content;
63
+ else
64
+ template.TemplateContent.Text = content;
65
+ let command;
36
66
  if (isNew)
37
- await this.ses.createTemplate({ Template: template }).promise();
67
+ command = new AWSSES.CreateEmailTemplateCommand(template);
38
68
  else
39
- await this.ses.updateTemplate({ Template: template }).promise();
69
+ command = new AWSSES.UpdateEmailTemplateCommand(template);
70
+ await this.ses.send(command);
40
71
  }
41
72
  async deleteTemplate(templateName) {
42
- await this.ses.deleteTemplate({ TemplateName: templateName }).promise();
73
+ const command = new AWSSES.DeleteEmailTemplateCommand({ TemplateName: templateName });
74
+ await this.ses.send(command);
43
75
  }
44
76
  async testTemplate(templateName, data) {
45
- return (await this.ses.testRenderTemplate({ TemplateName: templateName, TemplateData: JSON.stringify(data) }).promise()).RenderedTemplate;
77
+ const command = new AWSSES.TestRenderEmailTemplateCommand({
78
+ TemplateName: templateName,
79
+ TemplateData: JSON.stringify(data)
80
+ });
81
+ const { RenderedTemplate } = await this.ses.send(command);
82
+ return RenderedTemplate;
46
83
  }
47
84
  //
48
85
  // SENDING
@@ -51,22 +88,26 @@ class SES {
51
88
  * Send a templated email through AWS Simple Email Service.
52
89
  */
53
90
  async sendTemplatedEmail(emailData, sesParams) {
54
- const request = {
91
+ const command = new AWSSES.SendEmailCommand({
55
92
  Destination: this.prepareEmailDestination(emailData),
56
- Template: emailData.template,
57
- TemplateData: JSON.stringify(emailData.templateData ?? {}),
93
+ Content: {
94
+ Template: {
95
+ TemplateName: emailData.template,
96
+ TemplateData: JSON.stringify(emailData.templateData ?? {})
97
+ }
98
+ },
58
99
  ConfigurationSetName: emailData.configurationSet,
59
100
  ReplyToAddresses: emailData.replyToAddresses,
60
- Source: sesParams.sourceName ? `${sesParams.sourceName} <${sesParams.source}>` : sesParams.source,
61
- SourceArn: sesParams.sourceArn
62
- };
101
+ FromEmailAddress: sesParams.sourceName ? `${sesParams.sourceName} <${sesParams.source}>` : sesParams.source,
102
+ FromEmailAddressIdentityArn: sesParams.sourceArn
103
+ });
63
104
  let ses;
64
105
  if (this.ses.config.region === sesParams.region)
65
106
  ses = this.ses;
66
107
  else
67
- ses = new aws_sdk_1.SES({ region: sesParams.region });
108
+ ses = new AWSSES.SESv2Client({ region: sesParams.region });
68
109
  this.logger.debug('SES send templated email');
69
- return await ses.sendTemplatedEmail(request).promise();
110
+ return await ses.send(command);
70
111
  }
71
112
  /**
72
113
  * Send an email through AWS Simple Email Service.
@@ -86,27 +127,27 @@ class SES {
86
127
  if (!teamId)
87
128
  return null;
88
129
  try {
89
- return await new dynamoDB_1.DynamoDB().get({ TableName: 'idea_teamsSES', Key: { teamId } });
130
+ return (await new dynamoDB_1.DynamoDB().get({ TableName: 'idea_teamsSES', Key: { teamId } }));
90
131
  }
91
132
  catch (err) {
92
133
  return null;
93
134
  }
94
135
  }
95
136
  async sendEmailWithSES(emailData, sesParams) {
96
- const request = {
137
+ const command = new AWSSES.SendEmailCommand({
97
138
  Destination: this.prepareEmailDestination(emailData),
98
- Message: this.prepareEmailMessage(emailData),
139
+ Content: { Simple: this.prepareEmailMessage(emailData) },
99
140
  ReplyToAddresses: emailData.replyToAddresses,
100
- Source: sesParams.sourceName ? `${sesParams.sourceName} <${sesParams.source}>` : sesParams.source,
101
- SourceArn: sesParams.sourceArn
102
- };
141
+ FromEmailAddress: sesParams.sourceName ? `${sesParams.sourceName} <${sesParams.source}>` : sesParams.source,
142
+ FromEmailAddressIdentityArn: sesParams.sourceArn
143
+ });
103
144
  let ses;
104
145
  if (this.ses.config.region === sesParams.region)
105
146
  ses = this.ses;
106
147
  else
107
- ses = new aws_sdk_1.SES({ region: sesParams.region });
148
+ ses = new AWSSES.SESv2Client({ region: sesParams.region });
108
149
  this.logger.debug('SES send email');
109
- return await ses.sendEmail(request).promise();
150
+ return await ses.send(command);
110
151
  }
111
152
  async sendEmailWithNodemailer(emailData, sesParams) {
112
153
  const mailOptions = {};
@@ -128,7 +169,7 @@ class SES {
128
169
  if (this.ses.config.region === sesParams.region)
129
170
  ses = this.ses;
130
171
  else
131
- ses = new aws_sdk_1.SES({ region: sesParams.region });
172
+ ses = new AWSSES.SESv2Client({ region: sesParams.region });
132
173
  this.logger.debug('SES send email (Nodemailer)');
133
174
  return await (0, nodemailer_1.createTransport)({ SES: ses }).sendMail(mailOptions);
134
175
  }
package/dist/src/sns.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as AWSSNS from '@aws-sdk/client-sns';
1
2
  import { PushNotificationsPlatforms } from 'idea-toolbox';
2
3
  import { Logger } from './logger';
3
4
  /**
@@ -16,7 +17,7 @@ export declare class SNS {
16
17
  /**
17
18
  * Publish a message to a SNS endpoint.
18
19
  */
19
- publish(snsParams: SNSPublishParams): Promise<AWS.SNS.PublishResponse>;
20
+ publish(snsParams: SNSPublishParams): Promise<AWSSNS.PublishCommandOutput>;
20
21
  }
21
22
  /**
22
23
  * SNS configuration.
package/dist/src/sns.js CHANGED
@@ -1,7 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.SNS = void 0;
4
- const aws_sdk_1 = require("aws-sdk");
27
+ const AWSSNS = __importStar(require("@aws-sdk/client-sns"));
5
28
  const idea_toolbox_1 = require("idea-toolbox");
6
29
  const logger_1 = require("./logger");
7
30
  /**
@@ -32,10 +55,10 @@ class SNS {
32
55
  throw new Error('Unsupported platform');
33
56
  }
34
57
  this.logger.debug('SNS ADD PLATFORM ENDPOINT');
35
- const result = await new aws_sdk_1.SNS({ apiVersion: '2010-03-31', region: snsParams.region })
36
- .createPlatformEndpoint({ PlatformApplicationArn: platformARN, Token: token })
37
- .promise();
38
- return result.EndpointArn;
58
+ const client = new AWSSNS.SNSClient({ region: snsParams.region });
59
+ const command = new AWSSNS.CreatePlatformEndpointCommand({ PlatformApplicationArn: platformARN, Token: token });
60
+ const { EndpointArn } = await client.send(command);
61
+ return EndpointArn;
39
62
  }
40
63
  /**
41
64
  * Publish a message to a SNS endpoint.
@@ -61,9 +84,13 @@ class SNS {
61
84
  throw new Error('Unsupported platform');
62
85
  }
63
86
  this.logger.debug('SNS PUBLISH IN TOPIC');
64
- return await new aws_sdk_1.SNS({ apiVersion: '2010-03-31', region: snsParams.region })
65
- .publish({ MessageStructure: 'json', Message: JSON.stringify(structuredMessage), TargetArn: snsParams.endpoint })
66
- .promise();
87
+ const client = new AWSSNS.SNSClient({ region: snsParams.region });
88
+ const command = new AWSSNS.PublishCommand({
89
+ MessageStructure: 'json',
90
+ Message: JSON.stringify(structuredMessage),
91
+ TargetArn: snsParams.endpoint
92
+ });
93
+ return await client.send(command);
67
94
  }
68
95
  }
69
96
  exports.SNS = SNS;
@@ -1,4 +1,4 @@
1
- import { Translate as AWSTranslate } from 'aws-sdk';
1
+ import * as AWSTranslate from '@aws-sdk/client-translate';
2
2
  import { Languages, PDFEntity, PDFTemplateSection } from 'idea-toolbox';
3
3
  /**
4
4
  * A wrapper for Amazon Translate.
@@ -7,7 +7,7 @@ export declare class Translate {
7
7
  /**
8
8
  * The instance of Amazon Translate.
9
9
  */
10
- protected translate: AWSTranslate;
10
+ protected translate: AWSTranslate.TranslateClient;
11
11
  /**
12
12
  * Default input language code.
13
13
  */
@@ -36,9 +36,7 @@ export declare class Translate {
36
36
  * if the latter isn't between the ones already available.
37
37
  * @return an object that maps original texts with their translations (or nothing).
38
38
  */
39
- pdfTemplate(entity: PDFEntity, template: PDFTemplateSection[], language: string, languages: Languages): Promise<{
40
- [original: string]: string;
41
- }>;
39
+ pdfTemplate(entity: PDFEntity, template: PDFTemplateSection[], language: string, languages: Languages): Promise<Record<string, string>>;
42
40
  /**
43
41
  * Analyse a PDFTemplate to extract terms to translate based on a PDFEntity (using a sourceLanguage as reference).
44
42
  */
@@ -1,7 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.Translate = void 0;
4
- const aws_sdk_1 = require("aws-sdk");
27
+ const AWSTranslate = __importStar(require("@aws-sdk/client-translate"));
5
28
  const idea_toolbox_1 = require("idea-toolbox");
6
29
  /**
7
30
  * A wrapper for Amazon Translate.
@@ -11,7 +34,7 @@ class Translate {
11
34
  * Initialize a new Translate helper object.
12
35
  */
13
36
  constructor(options = {}) {
14
- this.translate = new aws_sdk_1.Translate({ apiVersion: '2017-07-01', region: options.region });
37
+ this.translate = new AWSTranslate.TranslateClient({ region: options.region });
15
38
  this.sourceLanguageCode = 'en';
16
39
  this.targetLanguageCode = 'en';
17
40
  this.terminologyNames = new Array();
@@ -29,15 +52,14 @@ class Translate {
29
52
  this.terminologyNames = params.terminologyNames;
30
53
  if (!this.sourceLanguageCode || !this.targetLanguageCode || !params.text)
31
54
  throw new Error('Bad parameters');
32
- const result = await this.translate
33
- .translateText({
55
+ const command = new AWSTranslate.TranslateTextCommand({
34
56
  Text: params.text,
35
57
  SourceLanguageCode: this.sourceLanguageCode,
36
58
  TargetLanguageCode: this.targetLanguageCode,
37
59
  TerminologyNames: this.terminologyNames
38
- })
39
- .promise();
40
- return result.TranslatedText;
60
+ });
61
+ const { TranslatedText } = await this.translate.send(command);
62
+ return TranslatedText;
41
63
  }
42
64
  /**
43
65
  * Get the contents of a PDF template (against a PDFEntity) translated in the desired language,