@webiny/handler-aws 6.4.12-beta.5 → 6.5.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 CHANGED
@@ -6,7 +6,7 @@ const createHandleResponse = (app, resolve)=>(err, result)=>{
6
6
  headers: {}
7
7
  });
8
8
  if (app.__webiny_raw_result) return resolve(app.__webiny_raw_result);
9
- else if (!result) {
9
+ if (!result) {
10
10
  const response = {
11
11
  statusCode: 200,
12
12
  body: "",
package/execute.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sources":["../src/execute.ts"],"sourcesContent":["import type { FastifyInstance } from \"@webiny/handler/types.js\";\nimport type { APIGatewayProxyResult } from \"@webiny/aws-sdk/types/index.js\";\nimport type { LightMyRequestCallback } from \"fastify\";\nimport { Base64EncodeHeader } from \"~/types.js\";\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"],"names":["createHandleResponse","app","resolve","err","result","JSON","response","isBase64Encoded","Base64EncodeHeader","getPayloadProperty","payload","prop","defaults","value","execute","params","url","query","headers","cookies","Promise"],"mappings":";AAQA,MAAMA,uBAAuB,CAACC,KAAsBC,UACzC,CAACC,KAAKC;QACT,IAAID,KACA,OAAOD,QAAQ;YACX,YAAY;YACZ,MAAMG,KAAK,SAAS,CAACF;YACrB,SAAS,CAAC;QACd;QAEJ,IAAIF,IAAI,mBAAmB,EACvB,OAAOC,QAAQD,IAAI,mBAAmB;aACnC,IAAI,CAACG,QAAQ;YAChB,MAAME,WAAkC;gBACpC,YAAY;gBACZ,MAAM;gBACN,SAAS,CAAC;gBACV,iBAAiB;YACrB;YACA,OAAOJ,QAAQI;QACnB;QAEA,MAAMC,kBACF,CAAC,CAACH,OAAO,OAAO,CAACI,mBAAmB,OAAO,CAAC,IAC5C,CAAC,CAACJ,OAAO,OAAO,CAACI,mBAAmB,MAAM,CAAC;QAC/C,MAAMF,WAAkC;YACpC,YAAYF,OAAO,UAAU;YAC7B,MAAMG,kBAAkBH,OAAO,UAAU,CAAC,QAAQ,CAAC,YAAYA,OAAO,OAAO;YAC7E,SAASA,OAAO,OAAO;YACvBG;QACJ;QACA,OAAOL,QAAQI;IACnB;AAGJ,MAAMG,qBAAqB,CACvBC,SACAC,MACAC,WAAgC,CAAC,CAAC;IAElC,IAAIF,WAAW,AAAmB,YAAnB,OAAOA,SAAsB;QACxC,MAAMG,QAAQH,OAAO,CAACC,KAAK,GAAGD,OAAO,CAACC,KAAK,GAAG,CAAC;QAE/C,OAAO;YACH,GAAGC,QAAQ;YACX,GAAGC,KAAK;QACZ;IACJ;IACA,OAAOD;AACX;AAQO,MAAME,UAAU,CAACC;IACpB,MAAM,EAAEd,GAAG,EAAEe,GAAG,EAAEN,OAAO,EAAE,GAAGK;IAE9B,MAAME,QAAQR,mBAAmBC,SAAS,SAAS,CAAC;IACpD,MAAMQ,UAAUT,mBAAmBC,SAAS,WAAW;QACnD,CAAC,eAAe,EAAE;IACtB;IAEA,MAAMS,UAAUV,mBAAmBC,SAAS,WAAW,CAAC;IAExD,OAAO,IAAIU,QAAQlB,CAAAA;QACfD,IAAI,MAAM,CACN;YACI,QAAQ;YACRe;YACA,SAASN,WAAW,CAAC;YACrB,MAAMA,WAAW,CAAC;YAClBO;YACAC;YACAC;QACJ,GACAnB,qBAAqBC,KAAKC;IAElC;AACJ"}
1
+ {"version":3,"file":"execute.js","sources":["../src/execute.ts"],"sourcesContent":["import type { FastifyInstance } from \"@webiny/handler/types.js\";\nimport type { APIGatewayProxyResult } from \"@webiny/aws-sdk/types/index.js\";\nimport type { LightMyRequestCallback } from \"fastify\";\nimport { Base64EncodeHeader } from \"~/types.js\";\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"],"names":["createHandleResponse","app","resolve","err","result","JSON","response","isBase64Encoded","Base64EncodeHeader","getPayloadProperty","payload","prop","defaults","value","execute","params","url","query","headers","cookies","Promise"],"mappings":";AAQA,MAAMA,uBAAuB,CAACC,KAAsBC,UACzC,CAACC,KAAKC;QACT,IAAID,KACA,OAAOD,QAAQ;YACX,YAAY;YACZ,MAAMG,KAAK,SAAS,CAACF;YACrB,SAAS,CAAC;QACd;QAEJ,IAAIF,IAAI,mBAAmB,EACvB,OAAOC,QAAQD,IAAI,mBAAmB;QACnC,IAAI,CAACG,QAAQ;YAChB,MAAME,WAAkC;gBACpC,YAAY;gBACZ,MAAM;gBACN,SAAS,CAAC;gBACV,iBAAiB;YACrB;YACA,OAAOJ,QAAQI;QACnB;QAEA,MAAMC,kBACF,CAAC,CAACH,OAAO,OAAO,CAACI,mBAAmB,OAAO,CAAC,IAC5C,CAAC,CAACJ,OAAO,OAAO,CAACI,mBAAmB,MAAM,CAAC;QAC/C,MAAMF,WAAkC;YACpC,YAAYF,OAAO,UAAU;YAC7B,MAAMG,kBAAkBH,OAAO,UAAU,CAAC,QAAQ,CAAC,YAAYA,OAAO,OAAO;YAC7E,SAASA,OAAO,OAAO;YACvBG;QACJ;QACA,OAAOL,QAAQI;IACnB;AAGJ,MAAMG,qBAAqB,CACvBC,SACAC,MACAC,WAAgC,CAAC,CAAC;IAElC,IAAIF,WAAW,AAAmB,YAAnB,OAAOA,SAAsB;QACxC,MAAMG,QAAQH,OAAO,CAACC,KAAK,GAAGD,OAAO,CAACC,KAAK,GAAG,CAAC;QAE/C,OAAO;YACH,GAAGC,QAAQ;YACX,GAAGC,KAAK;QACZ;IACJ;IACA,OAAOD;AACX;AAQO,MAAME,UAAU,CAACC;IACpB,MAAM,EAAEd,GAAG,EAAEe,GAAG,EAAEN,OAAO,EAAE,GAAGK;IAE9B,MAAME,QAAQR,mBAAmBC,SAAS,SAAS,CAAC;IACpD,MAAMQ,UAAUT,mBAAmBC,SAAS,WAAW;QACnD,CAAC,eAAe,EAAE;IACtB;IAEA,MAAMS,UAAUV,mBAAmBC,SAAS,WAAW,CAAC;IAExD,OAAO,IAAIU,QAAQlB,CAAAA;QACfD,IAAI,MAAM,CACN;YACI,QAAQ;YACRe;YACA,SAASN,WAAW,CAAC;YACrB,MAAMA,WAAW,CAAC;YAClBO;YACAC;YACAC;QACJ,GACAnB,qBAAqBC,KAAKC;IAElC;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler-aws",
3
- "version": "6.4.12-beta.5",
3
+ "version": "6.5.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -16,19 +16,19 @@
16
16
  ],
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@fastify/aws-lambda": "6.4.1",
20
- "@webiny/aws-sdk": "6.4.12-beta.5",
21
- "@webiny/handler": "6.4.12-beta.5",
22
- "@webiny/plugins": "6.4.12-beta.5",
23
- "@webiny/utils": "6.4.12-beta.5",
24
- "fastify": "5.12.5",
19
+ "@fastify/aws-lambda": "6.4.0",
20
+ "@webiny/aws-sdk": "6.5.0-beta.1",
21
+ "@webiny/handler": "6.5.0-beta.1",
22
+ "@webiny/plugins": "6.5.0-beta.1",
23
+ "@webiny/utils": "6.5.0-beta.1",
24
+ "fastify": "5.10.0",
25
25
  "pino-lambda": "4.4.1"
26
26
  },
27
27
  "devDependencies": {
28
- "@webiny/build-tools": "6.4.12-beta.5",
28
+ "@webiny/build-tools": "6.5.0-beta.1",
29
29
  "rimraf": "6.1.3",
30
- "typescript": "6.0.3",
31
- "vitest": "5.0.1"
30
+ "typescript": "7.0.2",
31
+ "vitest": "4.1.10"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
package/plugins/index.js CHANGED
@@ -1,8 +1,5 @@
1
- import { createRequestIdPlugin } from "./requestId.js";
2
1
  const registerDefaultPlugins = (context)=>{
3
- context.plugins.register([
4
- createRequestIdPlugin()
5
- ]);
2
+ context.plugins.register([]);
6
3
  };
7
4
  export { registerDefaultPlugins };
8
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"plugins/index.js","sources":["../../src/plugins/index.ts"],"sourcesContent":["import type { Context } from \"@webiny/handler/types.js\";\nimport { createRequestIdPlugin } from \"./requestId.js\";\n\nexport const registerDefaultPlugins = (context: Context): void => {\n context.plugins.register([createRequestIdPlugin()]);\n};\n"],"names":["registerDefaultPlugins","context","createRequestIdPlugin"],"mappings":";AAGO,MAAMA,yBAAyB,CAACC;IACnCA,QAAQ,OAAO,CAAC,QAAQ,CAAC;QAACC;KAAwB;AACtD"}
1
+ {"version":3,"file":"plugins/index.js","sources":["../../src/plugins/index.ts"],"sourcesContent":["import type { Context } from \"@webiny/handler/types.js\";\n\nexport const registerDefaultPlugins = (context: Context): void => {\n context.plugins.register([\n //\n ]);\n};\n"],"names":["registerDefaultPlugins","context"],"mappings":"AAEO,MAAMA,yBAAyB,CAACC;IACnCA,QAAQ,OAAO,CAAC,QAAQ,CAAC,EAExB;AACL"}
@@ -1,10 +0,0 @@
1
- import type { Context } from "@webiny/handler/types.js";
2
- /**
3
- * Replaces the generated request id with the Lambda invocation's own, so a value reported to a
4
- * client can be matched against CloudWatch and X-Ray.
5
- *
6
- * Registered as a `HandlerOnRequestPlugin` rather than from the handler factory closure: the default
7
- * is registered per request inside `preHandler`, and `registerInstance` appends while `resolve`
8
- * returns the last registration. Registering earlier would mean the generated value always won.
9
- */
10
- export declare const createRequestIdPlugin: () => import("@webiny/handler").HandlerOnRequestPlugin<Context>;
@@ -1,11 +0,0 @@
1
- import { RequestId, createHandlerOnRequest } from "@webiny/handler";
2
- const createRequestIdPlugin = ()=>createHandlerOnRequest(async (request, _reply, context)=>{
3
- const awsRequestId = request.awsLambda?.context?.awsRequestId;
4
- if (!awsRequestId) return;
5
- context.container.registerInstance(RequestId, {
6
- value: awsRequestId
7
- });
8
- });
9
- export { createRequestIdPlugin };
10
-
11
- //# sourceMappingURL=requestId.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins/requestId.js","sources":["../../src/plugins/requestId.ts"],"sourcesContent":["import { createHandlerOnRequest, RequestId } from \"@webiny/handler\";\nimport type { Context } from \"@webiny/handler/types.js\";\n\ninterface RequestWithLambdaContext {\n awsLambda?: {\n context?: {\n awsRequestId?: string;\n };\n };\n}\n\n/**\n * Replaces the generated request id with the Lambda invocation's own, so a value reported to a\n * client can be matched against CloudWatch and X-Ray.\n *\n * Registered as a `HandlerOnRequestPlugin` rather than from the handler factory closure: the default\n * is registered per request inside `preHandler`, and `registerInstance` appends while `resolve`\n * returns the last registration. Registering earlier would mean the generated value always won.\n */\nexport const createRequestIdPlugin = () => {\n return createHandlerOnRequest<Context>(async (request, _reply, context) => {\n const awsRequestId = (request as unknown as RequestWithLambdaContext).awsLambda?.context\n ?.awsRequestId;\n /**\n * Nothing to do without one: `@webiny/handler` has already registered a generated default\n * earlier in the same `preHandler` hook, so the abstraction still resolves.\n */\n if (!awsRequestId) {\n return;\n }\n\n context.container.registerInstance(RequestId, { value: awsRequestId });\n });\n};\n"],"names":["createRequestIdPlugin","createHandlerOnRequest","request","_reply","context","awsRequestId","RequestId"],"mappings":";AAmBO,MAAMA,wBAAwB,IAC1BC,uBAAgC,OAAOC,SAASC,QAAQC;QAC3D,MAAMC,eAAgBH,QAAgD,SAAS,EAAE,SAC3E;QAKN,IAAI,CAACG,cACD;QAGJD,QAAQ,SAAS,CAAC,gBAAgB,CAACE,WAAW;YAAE,OAAOD;QAAa;IACxE"}