@webiny/handler-aws 5.42.4-beta.0 → 5.43.0-beta.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/execute.js +1 -0
- package/execute.js.map +1 -1
- package/package.json +11 -12
- package/utils/composedHandler.d.ts +1 -1
package/execute.js
CHANGED
package/execute.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","createHandleResponse","app","resolve","err","result","statusCode","body","JSON","stringify","headers","__webiny_raw_result","response","isBase64Encoded","Base64EncodeHeader","encoded","binary","rawPayload","toString","payload","getPayloadProperty","prop","defaults","value","execute","params","url","query","cookies","Promise","inject","method","exports"],"sources":["execute.ts"],"sourcesContent":["import type { FastifyInstance } from \"@webiny/handler/types\";\nimport type { APIGatewayProxyResult } from \"@webiny/aws-sdk/types\";\nimport type { LightMyRequestCallback } from \"fastify\";\nimport { Base64EncodeHeader } from \"~/types\";\n\ninterface Resolve {\n (response: APIGatewayProxyResult | any): void;\n}\nconst createHandleResponse = (app: FastifyInstance, resolve: Resolve): LightMyRequestCallback => {\n return (err, result) => {\n if (err) {\n return resolve({\n statusCode: 500,\n body: JSON.stringify(err),\n headers: {}\n });\n }\n if (app.__webiny_raw_result) {\n return resolve(app.__webiny_raw_result);\n } else if (!result) {\n const response: APIGatewayProxyResult = {\n statusCode: 200,\n body: \"\",\n headers: {},\n isBase64Encoded: false\n };\n return resolve(response);\n }\n\n const isBase64Encoded =\n !!result.headers[Base64EncodeHeader.encoded] ||\n !!result.headers[Base64EncodeHeader.binary];\n const response: APIGatewayProxyResult = {\n statusCode: result.statusCode,\n body: isBase64Encoded ? result.rawPayload.toString(\"base64\") : result.payload,\n headers: result.headers as APIGatewayProxyResult[\"headers\"],\n isBase64Encoded\n };\n return resolve(response);\n };\n};\n\nconst getPayloadProperty = (\n payload: any,\n prop: string,\n defaults: Record<string, any> = {}\n): Record<string, any> => {\n if (payload && typeof payload === \"object\") {\n const value = payload[prop] ? payload[prop] : {};\n\n return {\n ...defaults,\n ...value\n };\n }\n return defaults;\n};\n\nexport interface ExecuteParams {\n app: FastifyInstance;\n url: string;\n payload: any;\n}\n\nexport const execute = (params: ExecuteParams): Promise<any> => {\n const { app, url, payload } = params;\n\n const query = getPayloadProperty(payload, \"query\", {});\n const headers = getPayloadProperty(payload, \"headers\", {\n [\"content-type\"]: \"application/json\"\n });\n\n const cookies = getPayloadProperty(payload, \"cookies\", {});\n\n return new Promise(resolve => {\n app.inject(\n {\n method: \"POST\",\n url,\n payload: payload || {},\n query,\n headers,\n cookies\n },\n createHandleResponse(app, resolve)\n );\n });\n};\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,MAAMC,oBAAoB,GAAGA,CAACC,GAAoB,EAAEC,OAAgB,KAA6B;EAC7F,OAAO,CAACC,GAAG,EAAEC,MAAM,KAAK;IACpB,IAAID,GAAG,EAAE;MACL,OAAOD,OAAO,CAAC;QACXG,UAAU,EAAE,GAAG;QACfC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACL,GAAG,CAAC;QACzBM,OAAO,EAAE,CAAC;MACd,CAAC,CAAC;IACN;IACA,IAAIR,GAAG,CAACS,mBAAmB,EAAE;MACzB,OAAOR,OAAO,CAACD,GAAG,CAACS,mBAAmB,CAAC;IAC3C,CAAC,MAAM,IAAI,CAACN,MAAM,EAAE;MAChB,MAAMO,QAA+B,GAAG;QACpCN,UAAU,EAAE,GAAG;QACfC,IAAI,EAAE,EAAE;QACRG,OAAO,EAAE,CAAC,CAAC;QACXG,eAAe,EAAE;MACrB,CAAC;MACD,OAAOV,OAAO,CAACS,QAAQ,CAAC;IAC5B;IAEA,MAAMC,eAAe,GACjB,CAAC,CAACR,MAAM,CAACK,OAAO,CAACI,yBAAkB,CAACC,OAAO,CAAC,IAC5C,CAAC,CAACV,MAAM,CAACK,OAAO,CAACI,yBAAkB,CAACE,MAAM,CAAC;IAC/C,MAAMJ,QAA+B,GAAG;MACpCN,UAAU,EAAED,MAAM,CAACC,UAAU;MAC7BC,IAAI,EAAEM,eAAe,GAAGR,MAAM,CAACY,UAAU,CAACC,QAAQ,CAAC,QAAQ,CAAC,GAAGb,MAAM,CAACc,OAAO;MAC7ET,OAAO,EAAEL,MAAM,CAACK,OAA2C;MAC3DG;IACJ,CAAC;IACD,OAAOV,OAAO,CAACS,QAAQ,CAAC;EAC5B,CAAC;AACL,CAAC;AAED,MAAMQ,kBAAkB,GAAGA,CACvBD,OAAY,EACZE,IAAY,EACZC,QAA6B,GAAG,CAAC,CAAC,KACZ;EACtB,IAAIH,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IACxC,MAAMI,KAAK,GAAGJ,OAAO,CAACE,IAAI,CAAC,GAAGF,OAAO,CAACE,IAAI,CAAC,GAAG,CAAC,CAAC;IAEhD,OAAO;MACH,GAAGC,QAAQ;MACX,GAAGC;IACP,CAAC;EACL;EACA,OAAOD,QAAQ;AACnB,CAAC;AAQM,MAAME,OAAO,GAAIC,MAAqB,IAAmB;EAC5D,MAAM;IAAEvB,GAAG;IAAEwB,GAAG;IAAEP;EAAQ,CAAC,GAAGM,MAAM;EAEpC,MAAME,KAAK,GAAGP,kBAAkB,CAACD,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;EACtD,MAAMT,OAAO,GAAGU,kBAAkB,CAACD,OAAO,EAAE,SAAS,EAAE;IACnD,CAAC,cAAc,GAAG;EACtB,CAAC,CAAC;EAEF,MAAMS,OAAO,GAAGR,kBAAkB,CAACD,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;EAE1D,OAAO,IAAIU,OAAO,CAAC1B,OAAO,IAAI;IAC1BD,GAAG,CAAC4B,MAAM,CACN;MACIC,MAAM,EAAE,MAAM;MACdL,GAAG;MACHP,OAAO,EAAEA,OAAO,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"names":["_types","require","createHandleResponse","app","resolve","err","result","statusCode","body","JSON","stringify","headers","__webiny_raw_result","response","isBase64Encoded","Base64EncodeHeader","encoded","binary","rawPayload","toString","payload","getPayloadProperty","prop","defaults","value","execute","params","url","query","cookies","Promise","inject","method","exports"],"sources":["execute.ts"],"sourcesContent":["import type { FastifyInstance } from \"@webiny/handler/types\";\nimport type { APIGatewayProxyResult } from \"@webiny/aws-sdk/types\";\nimport type { LightMyRequestCallback } from \"fastify\";\nimport { Base64EncodeHeader } from \"~/types\";\n\ninterface Resolve {\n (response: APIGatewayProxyResult | any): void;\n}\nconst createHandleResponse = (app: FastifyInstance, resolve: Resolve): LightMyRequestCallback => {\n return (err, result) => {\n if (err) {\n return resolve({\n statusCode: 500,\n body: JSON.stringify(err),\n headers: {}\n });\n }\n if (app.__webiny_raw_result) {\n return resolve(app.__webiny_raw_result);\n } else if (!result) {\n const response: APIGatewayProxyResult = {\n statusCode: 200,\n body: \"\",\n headers: {},\n isBase64Encoded: false\n };\n return resolve(response);\n }\n\n const isBase64Encoded =\n !!result.headers[Base64EncodeHeader.encoded] ||\n !!result.headers[Base64EncodeHeader.binary];\n const response: APIGatewayProxyResult = {\n statusCode: result.statusCode,\n body: isBase64Encoded ? result.rawPayload.toString(\"base64\") : result.payload,\n headers: result.headers as APIGatewayProxyResult[\"headers\"],\n isBase64Encoded\n };\n return resolve(response);\n };\n};\n\nconst getPayloadProperty = (\n payload: any,\n prop: string,\n defaults: Record<string, any> = {}\n): Record<string, any> => {\n if (payload && typeof payload === \"object\") {\n const value = payload[prop] ? payload[prop] : {};\n\n return {\n ...defaults,\n ...value\n };\n }\n return defaults;\n};\n\nexport interface ExecuteParams {\n app: FastifyInstance;\n url: string;\n payload: any;\n}\n\nexport const execute = (params: ExecuteParams): Promise<any> => {\n const { app, url, payload } = params;\n\n const query = getPayloadProperty(payload, \"query\", {});\n const headers = getPayloadProperty(payload, \"headers\", {\n [\"content-type\"]: \"application/json\"\n });\n\n const cookies = getPayloadProperty(payload, \"cookies\", {});\n\n return new Promise(resolve => {\n app.inject(\n {\n method: \"POST\",\n url,\n payload: payload || {},\n body: payload || {},\n query,\n headers,\n cookies\n },\n createHandleResponse(app, resolve)\n );\n });\n};\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,MAAMC,oBAAoB,GAAGA,CAACC,GAAoB,EAAEC,OAAgB,KAA6B;EAC7F,OAAO,CAACC,GAAG,EAAEC,MAAM,KAAK;IACpB,IAAID,GAAG,EAAE;MACL,OAAOD,OAAO,CAAC;QACXG,UAAU,EAAE,GAAG;QACfC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACL,GAAG,CAAC;QACzBM,OAAO,EAAE,CAAC;MACd,CAAC,CAAC;IACN;IACA,IAAIR,GAAG,CAACS,mBAAmB,EAAE;MACzB,OAAOR,OAAO,CAACD,GAAG,CAACS,mBAAmB,CAAC;IAC3C,CAAC,MAAM,IAAI,CAACN,MAAM,EAAE;MAChB,MAAMO,QAA+B,GAAG;QACpCN,UAAU,EAAE,GAAG;QACfC,IAAI,EAAE,EAAE;QACRG,OAAO,EAAE,CAAC,CAAC;QACXG,eAAe,EAAE;MACrB,CAAC;MACD,OAAOV,OAAO,CAACS,QAAQ,CAAC;IAC5B;IAEA,MAAMC,eAAe,GACjB,CAAC,CAACR,MAAM,CAACK,OAAO,CAACI,yBAAkB,CAACC,OAAO,CAAC,IAC5C,CAAC,CAACV,MAAM,CAACK,OAAO,CAACI,yBAAkB,CAACE,MAAM,CAAC;IAC/C,MAAMJ,QAA+B,GAAG;MACpCN,UAAU,EAAED,MAAM,CAACC,UAAU;MAC7BC,IAAI,EAAEM,eAAe,GAAGR,MAAM,CAACY,UAAU,CAACC,QAAQ,CAAC,QAAQ,CAAC,GAAGb,MAAM,CAACc,OAAO;MAC7ET,OAAO,EAAEL,MAAM,CAACK,OAA2C;MAC3DG;IACJ,CAAC;IACD,OAAOV,OAAO,CAACS,QAAQ,CAAC;EAC5B,CAAC;AACL,CAAC;AAED,MAAMQ,kBAAkB,GAAGA,CACvB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
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,19 +12,18 @@
|
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@fastify/aws-lambda": "
|
|
16
|
-
"@webiny/aws-sdk": "5.
|
|
17
|
-
"@webiny/handler": "5.
|
|
18
|
-
"@webiny/handler-client": "5.
|
|
19
|
-
"@webiny/plugins": "5.
|
|
20
|
-
"@webiny/utils": "5.
|
|
21
|
-
"fastify": "4.
|
|
15
|
+
"@fastify/aws-lambda": "4.1.0",
|
|
16
|
+
"@webiny/aws-sdk": "5.43.0-beta.1",
|
|
17
|
+
"@webiny/handler": "5.43.0-beta.1",
|
|
18
|
+
"@webiny/handler-client": "5.43.0-beta.1",
|
|
19
|
+
"@webiny/plugins": "5.43.0-beta.1",
|
|
20
|
+
"@webiny/utils": "5.43.0-beta.1",
|
|
21
|
+
"fastify": "4.29.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@webiny/project-utils": "5.
|
|
24
|
+
"@webiny/project-utils": "5.43.0-beta.1",
|
|
25
25
|
"rimraf": "6.0.1",
|
|
26
|
-
"
|
|
27
|
-
"typescript": "4.9.5"
|
|
26
|
+
"typescript": "5.3.3"
|
|
28
27
|
},
|
|
29
28
|
"publishConfig": {
|
|
30
29
|
"access": "public",
|
|
@@ -34,5 +33,5 @@
|
|
|
34
33
|
"build": "node ../cli/bin.js run build",
|
|
35
34
|
"watch": "node ../cli/bin.js run watch"
|
|
36
35
|
},
|
|
37
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "d47a234b09383cb7ab2d9907300b8eaa89aa64d6"
|
|
38
37
|
}
|
|
@@ -2,5 +2,5 @@ import { Plugin } from "@webiny/plugins/types";
|
|
|
2
2
|
type WrappedInput<TInput, TOutput> = TInput & {
|
|
3
3
|
next: () => Promise<TOutput>;
|
|
4
4
|
};
|
|
5
|
-
export declare const createComposedHandler: <P extends Plugin
|
|
5
|
+
export declare const createComposedHandler: <P extends Plugin, TInput, TOutput>(plugins: P[]) => import("@webiny/utils").NextAsyncProcessor<WrappedInput<TInput, TOutput>, TOutput>;
|
|
6
6
|
export {};
|