@defra-fish/connectors-lib 1.61.0-rc.17 → 1.61.0-rc.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra-fish/connectors-lib",
3
- "version": "1.61.0-rc.17",
3
+ "version": "1.61.0-rc.19",
4
4
  "description": "Shared connectors",
5
5
  "type": "module",
6
6
  "engines": {
@@ -46,5 +46,5 @@
46
46
  "node-fetch": "^2.7.0",
47
47
  "redlock": "^4.2.0"
48
48
  },
49
- "gitHead": "e35e018372742acfe0cb41e31abd14d3b0c7f742"
49
+ "gitHead": "74d6ad7d56ff5dd9ec7b5567b08d726352dd275a"
50
50
  }
@@ -21,13 +21,38 @@ describe('AWS Special cases', () => {
21
21
  })
22
22
  )
23
23
  })
24
+
25
+ it('exports ListObjectsV2Command from S3 SDK', () => {
26
+ const { ListObjectsV2Command } = AWS()
27
+ expect(ListObjectsV2Command).toBeDefined()
28
+ })
29
+
30
+ describe('AWS connectors for S3Client', () => {
31
+ it('has region set to eu-west-2', async () => {
32
+ const { s3 } = AWS()
33
+ const region = await s3.config.region()
34
+ expect(region).toBe('eu-west-2')
35
+ })
36
+
37
+ it('sets forcePathStyle to true when endpoint is defined', () => {
38
+ Config.aws.s3.endpoint = 'http://localhost:8080'
39
+ const { s3 } = AWS()
40
+ expect(s3.config.forcePathStyle).toBe(true)
41
+ delete Config.aws.s3.endpoint
42
+ })
43
+
44
+ it('does not set forcePathStyle when no endpoint is defined', () => {
45
+ const { s3 } = AWS()
46
+ expect(s3.config.forcePathStyle).not.toBe(true)
47
+ })
48
+ })
24
49
  })
25
50
 
26
51
  describe.each`
27
52
  name | clientName | configName | expectedAPIVersion
28
53
  ${'ddb'} | ${'DynamoDB'} | ${''} | ${'2012-08-10'}
29
54
  ${'sqs'} | ${'SQS'} | ${''} | ${'2012-11-05'}
30
- ${'s3'} | ${'S3'} | ${''} | ${'2006-03-01'}
55
+ ${'s3'} | ${'S3Client'} | ${'s3'} | ${'2006-03-01'}
31
56
  ${'secretsManager'} | ${'SecretsManager'} | ${'secretsManager'} | ${'2017-10-17'}
32
57
  ${'docClient'} | ${'DynamoDBDocument'} | ${'dynamodb'} | ${'2012-08-10'}
33
58
  `('AWS connectors for $clientName', ({ name, clientName, configName, expectedAPIVersion }) => {
package/src/aws.js CHANGED
@@ -2,7 +2,7 @@ import Config from './config.js'
2
2
  import { createDocumentClient } from './documentclient-decorator.js'
3
3
  import { DynamoDB } from '@aws-sdk/client-dynamodb'
4
4
  import { SQS } from '@aws-sdk/client-sqs'
5
- import { S3 } from '@aws-sdk/client-s3'
5
+ import { S3Client, ListObjectsV2Command } from '@aws-sdk/client-s3'
6
6
  import { SecretsManager } from '@aws-sdk/client-secrets-manager'
7
7
 
8
8
  export default function () {
@@ -26,7 +26,8 @@ export default function () {
26
26
  endpoint: Config.aws.sqs.endpoint
27
27
  })
28
28
  }),
29
- s3: new S3({
29
+ s3: new S3Client({
30
+ region: 'eu-west-2',
30
31
  apiVersion: '2006-03-01',
31
32
  ...(Config.aws.s3.endpoint && {
32
33
  endpoint: Config.aws.s3.endpoint,
@@ -38,6 +39,7 @@ export default function () {
38
39
  ...(Config.aws.secretsManager.endpoint && {
39
40
  endpoint: Config.aws.secretsManager.endpoint
40
41
  })
41
- })
42
+ }),
43
+ ListObjectsV2Command
42
44
  }
43
45
  }