@middy/s3-object-response 3.1.0 → 3.2.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.
Files changed (3) hide show
  1. package/index.cjs +12 -10
  2. package/index.d.ts +22 -4
  3. package/package.json +6 -4
package/index.cjs CHANGED
@@ -2,11 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- module.exports = void 0;
6
- var _https = _interopRequireDefault(require("https"));
7
- var _url = require("url");
8
- var _util = require("@middy/util");
9
- var _s3Js = _interopRequireDefault(require("aws-sdk/clients/s3.js"));
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
9
+ const _https = _interopRequireDefault(require("https"));
10
+ const _url = require("url");
11
+ const _util = require("@middy/util");
12
+ const _s3Js = _interopRequireDefault(require("aws-sdk/clients/s3.js"));
10
13
  function _interopRequireDefault(obj) {
11
14
  return obj && obj.__esModule ? obj : {
12
15
  default: obj
@@ -39,8 +42,8 @@ const s3ObjectResponseMiddleware = (opts = {})=>{
39
42
  https = options.httpsCapture(options.__https);
40
43
  }
41
44
  let client;
42
- if ((0, _util).canPrefetch(options)) {
43
- client = (0, _util).createPrefetchClient(options);
45
+ if ((0, _util.canPrefetch)(options)) {
46
+ client = (0, _util.createPrefetchClient)(options);
44
47
  }
45
48
  const s3ObjectResponseMiddlewareBefore = async (request)=>{
46
49
  const { inputS3Url , outputRoute , outputToken } = request.event.getObjectContext;
@@ -58,7 +61,7 @@ const s3ObjectResponseMiddleware = (opts = {})=>{
58
61
  };
59
62
  const s3ObjectResponseMiddlewareAfter = async (request)=>{
60
63
  if (!client) {
61
- client = await (0, _util).createClient(options, request);
64
+ client = await (0, _util.createClient)(options, request);
62
65
  }
63
66
  (_response = request.response).Body ?? (_response.Body = request.response.body);
64
67
  delete request.response.body;
@@ -96,8 +99,7 @@ const fetchPromise = (fetchOptions)=>{
96
99
  stream.on('error', (error)=>reject(error));
97
100
  });
98
101
  };
99
- var _default = s3ObjectResponseMiddleware;
100
- module.exports = _default;
102
+ const _default = s3ObjectResponseMiddleware;
101
103
 
102
104
 
103
105
  //# sourceMappingURL=index.cjs.map
package/index.d.ts CHANGED
@@ -1,13 +1,31 @@
1
- import { S3 } from 'aws-sdk'
2
1
  import middy from '@middy/core'
3
2
  import { Options as MiddyOptions } from '@middy/util'
3
+ import { Context as LambdaContext } from 'aws-lambda'
4
+ import S3 from 'aws-sdk/clients/s3'
5
+ import { ClientRequest } from 'http'
4
6
 
5
7
  interface Options<S = S3>
6
- extends Pick<MiddyOptions<S, S3.Types.ClientConfiguration>,
7
- 'AwsClient' | 'awsClientOptions' | 'awsClientAssumeRole' | 'awsClientCapture' | 'disablePrefetch'> {
8
+ extends Pick<
9
+ MiddyOptions<S, S3.Types.ClientConfiguration>,
10
+ | 'AwsClient'
11
+ | 'awsClientOptions'
12
+ | 'awsClientAssumeRole'
13
+ | 'awsClientCapture'
14
+ | 'disablePrefetch'
15
+ > {
8
16
  bodyType?: 'stream' | 'promise'
9
17
  }
10
18
 
11
- declare function s3ObjectResponse (options?: Options): middy.MiddlewareObj
19
+ export type Context<TOptions extends Options | undefined> = LambdaContext & {
20
+ s3Object: TOptions extends { bodyType: 'stream' }
21
+ ? ClientRequest
22
+ : TOptions extends { bodyType: 'promise' }
23
+ ? Promise<any>
24
+ : never
25
+ }
26
+
27
+ declare function s3ObjectResponse<TOptions extends Options | undefined> (
28
+ options?: TOptions
29
+ ): middy.MiddlewareObj<unknown, any, Error, Context<TOptions>>
12
30
 
13
31
  export default s3ObjectResponse
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/s3-object-response",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "description": "S3 object response handling middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -11,6 +11,7 @@
11
11
  "access": "public"
12
12
  },
13
13
  "main": "./index.cjs",
14
+ "module": "./index.js",
14
15
  "exports": {
15
16
  ".": {
16
17
  "import": {
@@ -61,12 +62,13 @@
61
62
  },
62
63
  "homepage": "https://middy.js.org",
63
64
  "dependencies": {
64
- "@middy/util": "3.1.0"
65
+ "@middy/util": "3.2.1"
65
66
  },
66
67
  "devDependencies": {
67
- "@middy/core": "3.1.0",
68
+ "@middy/core": "3.2.1",
69
+ "@types/aws-lambda": "^8.10.101",
68
70
  "aws-sdk": "^2.939.0",
69
71
  "aws-xray-sdk": "^3.3.3"
70
72
  },
71
- "gitHead": "d5284fd11c175516c189b6061fee7312106d9709"
73
+ "gitHead": "b4169ec20b798650e934a7c25ee80ae98d11e03a"
72
74
  }