@webiny/handler-aws 5.23.1 → 5.25.0-beta.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/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { HandlerHttpOptions } from "@webiny/handler-http/types";
2
2
  import { PluginCollection } from "@webiny/plugins/types";
3
- declare type CreateAwsHandlerOptions = {
3
+ interface CreateAwsHandlerOptions {
4
4
  plugins: PluginCollection;
5
5
  http?: HandlerHttpOptions;
6
- };
6
+ }
7
7
  interface CreateAwsHandler {
8
8
  (...plugins: PluginCollection): Function;
9
9
  (params: CreateAwsHandlerOptions): Function;
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["createHandler","args","plugins","createHandlerOptions","Array","isArray","http","handlerClient","handlerHttp"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAA+B,GAAG,CAAC,GAAGC,IAAJ,KAAkB;AAC7D,MAAIC,OAAO,GAAGD,IAAd;AAEA,QAAME,oBAA6C,GAC/CF,IAAI,CAAC,CAAD,CADR;;AAEA,MAAIE,oBAAoB,IAAIC,KAAK,CAACC,OAAN,CAAcF,oBAAoB,CAACD,OAAnC,CAA5B,EAAyE;AACrEA,IAAAA,OAAO,GAAGC,oBAAoB,CAACD,OAA/B;AACH;;AAED,SAAO,4BACH,6BADG,EAEH,2BAFG,EAGH,0BAAmBC,oBAAoB,IAAIA,oBAAoB,CAACG,IAAhE,CAHG,EAIHC,uBAJG,EAKHC,qBALG,EAMH,GAAGN,OANA,CAAP;AAQH,CAjBM","sourcesContent":["import defaultHandlerClient from \"@webiny/handler-client\";\nimport defaultHandlerHttp from \"@webiny/handler-http\";\nimport { HandlerHttpOptions } from \"@webiny/handler-http/types\";\nimport defaultHandlerArgs from \"@webiny/handler-args\";\nimport { createHandler as createDefaultHandler } from \"@webiny/handler\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport handlerClient from \"./plugins/handlerClient\";\nimport handlerHttp from \"./plugins/handlerHttp\";\n\ninterface CreateAwsHandlerOptions {\n plugins: PluginCollection;\n http?: HandlerHttpOptions;\n}\n\ninterface CreateAwsHandler {\n (...plugins: PluginCollection): Function;\n (params: CreateAwsHandlerOptions): Function;\n}\n\n/**\n * To avoid braking changes, the \"createHandler\" function supports two signature:\n * 1. A list of plugins. (backwards-compatible)\n * 2. A single argument of type `CreateHandlerOptions`.\n *\n * @param {Array | CreateAwsHandlerOptions} args - The list of plugins or object of type `CreateHandlerOptions`.\n */\nexport const createHandler: CreateAwsHandler = (...args: any) => {\n let plugins = args;\n\n const createHandlerOptions: CreateAwsHandlerOptions =\n args[0] as unknown as CreateAwsHandlerOptions;\n if (createHandlerOptions && Array.isArray(createHandlerOptions.plugins)) {\n plugins = createHandlerOptions.plugins;\n }\n\n return createDefaultHandler(\n defaultHandlerClient(),\n defaultHandlerArgs(),\n defaultHandlerHttp(createHandlerOptions && createHandlerOptions.http),\n handlerClient,\n handlerHttp,\n ...plugins\n );\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler-aws",
3
- "version": "5.23.1",
3
+ "version": "5.25.0-beta.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,24 +14,24 @@
14
14
  ],
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@babel/runtime": "7.16.7",
18
- "@webiny/handler": "5.23.1",
19
- "@webiny/handler-args": "5.23.1",
20
- "@webiny/handler-client": "5.23.1",
21
- "@webiny/handler-http": "5.23.1",
22
- "@webiny/plugins": "5.23.1"
17
+ "@babel/runtime": "7.17.2",
18
+ "@webiny/handler": "5.25.0-beta.0",
19
+ "@webiny/handler-args": "5.25.0-beta.0",
20
+ "@webiny/handler-client": "5.25.0-beta.0",
21
+ "@webiny/handler-http": "5.25.0-beta.0",
22
+ "@webiny/plugins": "5.25.0-beta.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@babel/cli": "^7.16.0",
26
26
  "@babel/core": "^7.16.0",
27
27
  "@babel/preset-env": "^7.16.4",
28
28
  "@babel/preset-typescript": "^7.16.0",
29
- "@webiny/cli": "^5.23.1",
30
- "@webiny/project-utils": "^5.23.1",
29
+ "@webiny/cli": "^5.25.0-beta.0",
30
+ "@webiny/project-utils": "^5.25.0-beta.0",
31
31
  "babel-plugin-lodash": "^3.3.4",
32
32
  "merge": "^1.2.1",
33
33
  "rimraf": "^3.0.2",
34
- "typescript": "^4.1.3"
34
+ "typescript": "4.5.5"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public",
@@ -41,5 +41,5 @@
41
41
  "build": "yarn webiny run build",
42
42
  "watch": "yarn webiny run watch"
43
43
  },
44
- "gitHead": "a726d09d2647d13e5a4f376cef23463564ef7ca0"
44
+ "gitHead": "2d3e7833575e88fde77d84e5490e746933a5ec28"
45
45
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["handlerArgs.ts"],"names":["type","apply","context","event","args","invocationArgs"],"mappings":";;;;;;eAGe;AACXA,EAAAA,IAAI,EAAE,SADK;;AAEXC,EAAAA,KAAK,CAACC,OAAD,EAAiC;AAClC,UAAM,CAACC,KAAD,IAAUD,OAAO,CAACE,IAAxB;AACAF,IAAAA,OAAO,CAACG,cAAR,GAAyBF,KAAzB;AACH;;AALU,C","sourcesContent":["import { ArgsContext } from \"@webiny/handler-args/types\";\nimport { Context } from \"@webiny/handler/types\";\n\nexport default {\n type: \"context\",\n apply(context: Context & ArgsContext) {\n const [event] = context.args;\n context.invocationArgs = event;\n }\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["handlerClient.ts"],"names":["plugin","type","name","invoke","payload","await","useAwait","lambdaClient","LambdaClient","region","process","env","AWS_REGION","response","FunctionName","InvocationType","Payload","JSON","stringify","promise","parse"],"mappings":";;;;;;;;;AAAA;;AAGA,MAAMA,MAA2B,GAAG;AAChCC,EAAAA,IAAI,EAAE,gBAD0B;AAEhCC,EAAAA,IAAI,EAAE,gBAF0B;;AAGhC,QAAMC,MAAN,CAAa;AAAED,IAAAA,IAAF;AAAQE,IAAAA,OAAR;AAAiBC,IAAAA,KAAK,EAAEC;AAAxB,GAAb,EAAiD;AAC7C,UAAMC,YAAY,GAAG,IAAIC,eAAJ,CAAiB;AAAEC,MAAAA,MAAM,EAAEC,OAAO,CAACC,GAAR,CAAYC;AAAtB,KAAjB,CAArB;AACA,UAAMC,QAAQ,GAAG,MAAMN,YAAY,CAC9BJ,MADkB,CACX;AACJW,MAAAA,YAAY,EAAEZ,IADV;AAEJa,MAAAA,cAAc,EAAET,QAAQ,KAAK,KAAb,GAAqB,OAArB,GAA+B,iBAF3C;AAGJU,MAAAA,OAAO,EAAEC,IAAI,CAACC,SAAL,CAAed,OAAf;AAHL,KADW,EAMlBe,OANkB,EAAvB;;AAQA,QAAIb,QAAQ,KAAK,KAAjB,EAAwB;AACpB,aAAO,IAAP;AACH;;AAED,UAAMU,OAAO,GAAGH,QAAQ,CAACG,OAAzB;AACA,WAAOC,IAAI,CAACG,KAAL,CAAWJ,OAAX,CAAP;AACH;;AAnB+B,CAApC;eAsBehB,M","sourcesContent":["import LambdaClient from \"aws-sdk/clients/lambda\";\nimport { HandlerClientPlugin } from \"@webiny/handler-client/types\";\n\nconst plugin: HandlerClientPlugin = {\n type: \"handler-client\",\n name: \"handler-client\",\n async invoke({ name, payload, await: useAwait }) {\n const lambdaClient = new LambdaClient({ region: process.env.AWS_REGION });\n const response = await lambdaClient\n .invoke({\n FunctionName: name,\n InvocationType: useAwait === false ? \"Event\" : \"RequestResponse\",\n Payload: JSON.stringify(payload)\n })\n .promise();\n\n if (useAwait === false) {\n return null;\n }\n\n const Payload = response.Payload as string;\n return JSON.parse(Payload);\n }\n};\n\nexport default plugin;\n"]}
@@ -1,5 +1,16 @@
1
1
  import { HttpContext } from "@webiny/handler-http/types";
2
2
  import { ContextPlugin } from "@webiny/handler/types";
3
3
  import { ArgsContext } from "@webiny/handler-args/types";
4
- declare const _default: ContextPlugin<HttpContext & ArgsContext<Record<string, any>>, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context>;
4
+ interface InputArgs {
5
+ httpMethod: string;
6
+ isBase64Encoded?: boolean;
7
+ rawPath: string;
8
+ pathParameters: {
9
+ [key: string]: any;
10
+ };
11
+ queryStringParameters: {
12
+ [key: string]: any;
13
+ };
14
+ }
15
+ declare const _default: ContextPlugin<HttpContext & ArgsContext<InputArgs>, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context, import("@webiny/handler/types").Context>;
5
16
  export default _default;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["handlerHttp.ts"],"names":["lowercaseKeys","obj","Object","keys","reduce","acc","key","toLowerCase","type","apply","context","invocationArgs","httpMethod","isBase64Encoded","request","method","body","headers","cookies","path","base","rawPath","parameters","pathParameters","query","queryStringParameters","http","response","statusCode","Buffer","from","toString"],"mappings":";;;;;;;AAIA,MAAMA,aAAa,GAAIC,GAAD,IAAiC;AACnD,SAAOC,MAAM,CAACC,IAAP,CAAYF,GAAZ,EAAiBG,MAAjB,CAAwB,CAACC,GAAD,EAAMC,GAAN,KAAc;AACzCD,IAAAA,GAAG,CAACC,GAAG,CAACC,WAAJ,EAAD,CAAH,GAAyBN,GAAG,CAACK,GAAD,CAA5B;AACA,WAAOD,GAAP;AACH,GAHM,EAGJ,EAHI,CAAP;AAIH,CALD;;eAmBe;AACXG,EAAAA,IAAI,EAAE,SADK;;AAEXC,EAAAA,KAAK,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De,QAAjD,CACxB,OADwB,CAA5B;AAGH;AACJ;;AAvCU,C","sourcesContent":["import { HttpContext } from \"@webiny/handler-http/types\";\nimport { ContextPlugin } from \"@webiny/handler/types\";\nimport { ArgsContext } from \"@webiny/handler-args/types\";\n\nconst lowercaseKeys = (obj: Record<string, string>) => {\n return Object.keys(obj).reduce((acc, key) => {\n acc[key.toLowerCase()] = obj[key];\n return acc;\n }, {} as Record<string, string>);\n};\n\ninterface InputArgs {\n httpMethod: string;\n isBase64Encoded?: boolean;\n rawPath: string;\n pathParameters: {\n [key: string]: any;\n };\n queryStringParameters: {\n [key: string]: any;\n };\n}\n\nexport default {\n type: \"context\",\n apply(context) {\n const { invocationArgs } = context;\n if (!invocationArgs || !invocationArgs.httpMethod) {\n return;\n }\n\n const { isBase64Encoded } = invocationArgs;\n\n const request = {\n method: invocationArgs.httpMethod,\n body: invocationArgs.body,\n headers: lowercaseKeys(invocationArgs.headers || {}),\n cookies: invocationArgs.cookies,\n path: {\n base: invocationArgs.rawPath,\n parameters: invocationArgs.pathParameters,\n query: invocationArgs.queryStringParameters\n }\n };\n\n context.http = {\n request,\n response({ statusCode = 200, body = \"\", headers = {} }) {\n return {\n statusCode,\n body: isBase64Encoded ? Buffer.from(body).toString(\"base64\") : body,\n headers,\n isBase64Encoded\n };\n }\n };\n\n if (isBase64Encoded) {\n context.http.request.body = Buffer.from(context.http.request.body, \"base64\").toString(\n \"utf-8\"\n );\n }\n }\n} as ContextPlugin<HttpContext & ArgsContext<InputArgs>>;\n"]}