diff --git a/package-lock.json b/package-lock.json index 7a50e591d9..eefa6cdd40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16560,12 +16560,18 @@ "packages/batch": { "name": "@aws-lambda-powertools/batch", "version": "1.14.0", - "license": "MIT-0" + "license": "MIT-0", + "devDependencies": { + "@aws-lambda-powertools/testing-utils": "file:../testing" + } }, "packages/commons": { "name": "@aws-lambda-powertools/commons", "version": "1.14.0", - "license": "MIT-0" + "license": "MIT-0", + "devDependencies": { + "@aws-lambda-powertools/testing-utils": "file:../testing" + } }, "packages/idempotency": { "name": "@aws-lambda-powertools/idempotency", @@ -16653,6 +16659,7 @@ "@aws-sdk/util-base64-node": "^3.209.0" }, "devDependencies": { + "@aws-lambda-powertools/testing-utils": "file:../testing", "@aws-sdk/client-appconfigdata": "^3.413.0", "@aws-sdk/client-dynamodb": "^3.413.0", "@aws-sdk/client-secrets-manager": "^3.413.0", diff --git a/packages/batch/package.json b/packages/batch/package.json index e47578e9f1..1ff802cdf4 100644 --- a/packages/batch/package.json +++ b/packages/batch/package.json @@ -74,5 +74,8 @@ "batch-processing", "serverless", "nodejs" - ] -} \ No newline at end of file + ], + "devDependencies": { + "@aws-lambda-powertools/testing-utils": "file:../testing" + } +} diff --git a/packages/batch/tests/unit/BatchProcessor.test.ts b/packages/batch/tests/unit/BatchProcessor.test.ts index 4588e62099..1b1114ca86 100644 --- a/packages/batch/tests/unit/BatchProcessor.test.ts +++ b/packages/batch/tests/unit/BatchProcessor.test.ts @@ -4,7 +4,7 @@ * @group unit/batch/class/batchprocessor */ import type { Context } from 'aws-lambda'; -import { ContextExamples as dummyContext } from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { BatchProcessor, EventType, @@ -27,7 +27,7 @@ import { describe('Class: AsyncBatchProcessor', () => { const ENVIRONMENT_VARIABLES = process.env; const options: BatchProcessingOptions = { - context: dummyContext.helloworldContext, + context, }; beforeEach(() => { diff --git a/packages/batch/tests/unit/BatchProcessorSync.test.ts b/packages/batch/tests/unit/BatchProcessorSync.test.ts index 31a5315431..bf93f590a0 100644 --- a/packages/batch/tests/unit/BatchProcessorSync.test.ts +++ b/packages/batch/tests/unit/BatchProcessorSync.test.ts @@ -4,7 +4,7 @@ * @group unit/batch/class/batchprocessorsync */ import type { Context } from 'aws-lambda'; -import { ContextExamples as dummyContext } from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { BatchProcessorSync, EventType, @@ -27,7 +27,7 @@ import { describe('Class: BatchProcessor', () => { const ENVIRONMENT_VARIABLES = process.env; const options: BatchProcessingOptions = { - context: dummyContext.helloworldContext, + context, }; beforeEach(() => { diff --git a/packages/batch/tests/unit/processPartialResponse.test.ts b/packages/batch/tests/unit/processPartialResponse.test.ts index 66d97177a5..732d40ee3b 100644 --- a/packages/batch/tests/unit/processPartialResponse.test.ts +++ b/packages/batch/tests/unit/processPartialResponse.test.ts @@ -9,10 +9,7 @@ import type { KinesisStreamEvent, SQSEvent, } from 'aws-lambda'; -import { - ContextExamples as dummyContext, - Events as dummyEvent, -} from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { BatchProcessor, processPartialResponse, @@ -38,9 +35,8 @@ import assert from 'node:assert'; describe('Function: processPartialResponse()', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext; const options: BatchProcessingOptions = { - context: dummyContext.helloworldContext, + context, }; beforeEach(() => { @@ -114,7 +110,7 @@ describe('Function: processPartialResponse()', () => { }; // Act - const result = await handler(event, context.helloworldContext); + const result = await handler(event, context); // Assess expect(result).toStrictEqual({ batchItemFailures: [] }); @@ -141,7 +137,7 @@ describe('Function: processPartialResponse()', () => { }; // Act - const result = await handler(event, context.helloworldContext); + const result = await handler(event, context); // Assess expect(result).toStrictEqual({ batchItemFailures: [] }); @@ -168,7 +164,7 @@ describe('Function: processPartialResponse()', () => { }; // Act - const result = await handler(event, context.helloworldContext); + const result = await handler(event, context); // Assess expect(result).toStrictEqual({ batchItemFailures: [] }); @@ -177,7 +173,6 @@ describe('Function: processPartialResponse()', () => { test('Process partial response through handler for SQS records with incorrect event type', async () => { // Prepare const processor = new BatchProcessor(EventType.SQS); - const event = dummyEvent.Custom; const handler = async ( event: SQSEvent, @@ -192,7 +187,7 @@ describe('Function: processPartialResponse()', () => { try { // Act - await handler(event as unknown as SQSEvent, context.helloworldContext); + await handler({} as unknown as SQSEvent, context); } catch (error) { // Assess assert(error instanceof UnexpectedBatchTypeError); @@ -228,7 +223,7 @@ describe('Function: processPartialResponse()', () => { }; // Act - const result = await handler(event, context.helloworldContext); + const result = await handler(event, context); // Assess expect(result).toStrictEqual({ batchItemFailures: [] }); diff --git a/packages/batch/tests/unit/processPartialResponseSync.test.ts b/packages/batch/tests/unit/processPartialResponseSync.test.ts index e6700d8959..4fe7da8609 100644 --- a/packages/batch/tests/unit/processPartialResponseSync.test.ts +++ b/packages/batch/tests/unit/processPartialResponseSync.test.ts @@ -9,10 +9,7 @@ import type { KinesisStreamEvent, SQSEvent, } from 'aws-lambda'; -import { - ContextExamples as dummyContext, - Events as dummyEvent, -} from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { BatchProcessorSync, processPartialResponseSync, @@ -38,9 +35,8 @@ import assert from 'node:assert'; describe('Function: processPartialResponse()', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext; const options: BatchProcessingOptions = { - context: dummyContext.helloworldContext, + context, }; beforeEach(() => { @@ -114,7 +110,7 @@ describe('Function: processPartialResponse()', () => { }; // Act - const result = handler(event, context.helloworldContext); + const result = handler(event, context); // Assess expect(result).toStrictEqual({ batchItemFailures: [] }); @@ -141,7 +137,7 @@ describe('Function: processPartialResponse()', () => { }; // Act - const result = handler(event, context.helloworldContext); + const result = handler(event, context); // Assess expect(result).toStrictEqual({ batchItemFailures: [] }); @@ -168,7 +164,7 @@ describe('Function: processPartialResponse()', () => { }; // Act - const result = handler(event, context.helloworldContext); + const result = handler(event, context); // Assess expect(result).toStrictEqual({ batchItemFailures: [] }); @@ -177,7 +173,6 @@ describe('Function: processPartialResponse()', () => { test('Process partial response through handler for SQS records with incorrect event type', () => { // Prepare const processor = new BatchProcessorSync(EventType.SQS); - const event = dummyEvent.Custom; const handler = ( event: SQSEvent, @@ -188,7 +183,7 @@ describe('Function: processPartialResponse()', () => { try { // Act - handler(event as unknown as SQSEvent, context.helloworldContext); + handler({} as unknown as SQSEvent, context); } catch (error) { // Assess assert(error instanceof UnexpectedBatchTypeError); @@ -224,7 +219,7 @@ describe('Function: processPartialResponse()', () => { }; // Act - const result = handler(event, context.helloworldContext); + const result = handler(event, context); // Assess expect(result).toStrictEqual({ batchItemFailures: [] }); diff --git a/packages/commons/package.json b/packages/commons/package.json index d7a3bab71c..a3e0e47296 100644 --- a/packages/commons/package.json +++ b/packages/commons/package.json @@ -25,7 +25,7 @@ "lint-staged": { "*.{js,ts}": "npm run lint-fix" }, - "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/metrics#readme", + "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/commons#readme", "license": "MIT-0", "type": "module", "exports": { @@ -70,5 +70,8 @@ "powertools", "serverless", "nodejs" - ] -} \ No newline at end of file + ], + "devDependencies": { + "@aws-lambda-powertools/testing-utils": "file:../testing" + } +} diff --git a/packages/commons/src/index.ts b/packages/commons/src/index.ts index f6ff7df34e..cdf0815bad 100644 --- a/packages/commons/src/index.ts +++ b/packages/commons/src/index.ts @@ -1,8 +1,6 @@ export { isRecord, isString, isTruthy, isNullOrUndefined } from './guards.js'; export { Utility } from './Utility.js'; export { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js'; -export * as ContextExamples from './samples/resources/contexts/index.js'; -export * as Events from './samples/resources/events/index.js'; export { addUserAgentMiddleware, isSdkClient } from './awsSdkUtils.js'; export { cleanupMiddlewares } from './middleware/cleanupMiddlewares.js'; export { diff --git a/packages/commons/src/samples/resources/contexts/index.ts b/packages/commons/src/samples/resources/contexts/index.ts deleted file mode 100644 index 910f356d2c..0000000000 --- a/packages/commons/src/samples/resources/contexts/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './hello-world.js'; diff --git a/packages/commons/src/samples/resources/events/aws/apigateway-authorizer.json b/packages/commons/src/samples/resources/events/aws/apigateway-authorizer.json deleted file mode 100644 index 2bbf060353..0000000000 --- a/packages/commons/src/samples/resources/events/aws/apigateway-authorizer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "TOKEN", - "authorizationToken": "incoming-client-token", - "methodArn": "arn:aws:execute-api:eu-central-1:123456789012:example/prod/POST/{proxy+}" -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/apigateway-aws-proxy.json b/packages/commons/src/samples/resources/events/aws/apigateway-aws-proxy.json deleted file mode 100644 index fb46b342eb..0000000000 --- a/packages/commons/src/samples/resources/events/aws/apigateway-aws-proxy.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "body": "eyJ0ZXN0IjoiYm9keSJ9", - "resource": "/{proxy+}", - "path": "/path/to/resource", - "httpMethod": "POST", - "isBase64Encoded": true, - "queryStringParameters": { - "foo": "bar" - }, - "multiValueQueryStringParameters": { - "foo": [ - "bar" - ] - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.eu-central-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "multiValueHeaders": { - "Accept": [ - "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" - ], - "Accept-Encoding": [ - "gzip, deflate, sdch" - ], - "Accept-Language": [ - "en-US,en;q=0.8" - ], - "Cache-Control": [ - "max-age=0" - ], - "CloudFront-Forwarded-Proto": [ - "https" - ], - "CloudFront-Is-Desktop-Viewer": [ - "true" - ], - "CloudFront-Is-Mobile-Viewer": [ - "false" - ], - "CloudFront-Is-SmartTV-Viewer": [ - "false" - ], - "CloudFront-Is-Tablet-Viewer": [ - "false" - ], - "CloudFront-Viewer-Country": [ - "US" - ], - "Host": [ - "0123456789.execute-api.eu-central-1.amazonaws.com" - ], - "Upgrade-Insecure-Requests": [ - "1" - ], - "User-Agent": [ - "Custom User Agent String" - ], - "Via": [ - "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)" - ], - "X-Amz-Cf-Id": [ - "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==" - ], - "X-Forwarded-For": [ - "127.0.0.1, 127.0.0.2" - ], - "X-Forwarded-Port": [ - "443" - ], - "X-Forwarded-Proto": [ - "https" - ] - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/prod/path/to/resource", - "resourcePath": "/{proxy+}", - "httpMethod": "POST", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/appsync-resolver.json b/packages/commons/src/samples/resources/events/aws/appsync-resolver.json deleted file mode 100644 index 94960dd1ed..0000000000 --- a/packages/commons/src/samples/resources/events/aws/appsync-resolver.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "arguments": { - "id": "my identifier" - }, - "identity": { - "claims": { - "sub": "192879fc-a240-4bf1-ab5a-d6a00f3063f9", - "email_verified": true, - "iss": "https://cognito-idp.us-west-2.amazonaws.com/us-west-xxxxxxxxxxx", - "phone_number_verified": false, - "cognito:username": "jdoe", - "aud": "7471s60os7h0uu77i1tk27sp9n", - "event_id": "bc334ed8-a938-4474-b644-9547e304e606", - "token_use": "id", - "auth_time": 1599154213, - "phone_number": "+19999999999", - "exp": 1599157813, - "iat": 1599154213, - "email": "jdoe@email.com" - }, - "defaultAuthStrategy": "ALLOW", - "groups": null, - "issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-xxxxxxxxxxx", - "sourceIp": [ - "1.1.1.1" - ], - "sub": "192879fc-a240-4bf1-ab5a-d6a00f3063f9", - "username": "jdoe" - }, - "source": null, - "request": { - "headers": { - "x-forwarded-for": "1.1.1.1, 2.2.2.2", - "cloudfront-viewer-country": "US", - "cloudfront-is-tablet-viewer": "false", - "via": "2.0 xxxxxxxxxxxxxxxx.cloudfront.net (CloudFront)", - "cloudfront-forwarded-proto": "https", - "origin": "https://us-west-1.console.aws.amazon.com", - "content-length": "217", - "accept-language": "en-US,en;q=0.9", - "host": "xxxxxxxxxxxxxxxx.appsync-api.us-west-1.amazonaws.com", - "x-forwarded-proto": "https", - "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36", - "accept": "*/*", - "cloudfront-is-mobile-viewer": "false", - "cloudfront-is-smarttv-viewer": "false", - "accept-encoding": "gzip, deflate, br", - "referer": "https://us-west-1.console.aws.amazon.com/appsync/home?region=us-west-1", - "content-type": "application/json", - "sec-fetch-mode": "cors", - "x-amz-cf-id": "3aykhqlUwQeANU-HGY7E_guV5EkNeMMtwyOgiA==", - "x-amzn-trace-id": "Root=1-5f512f51-fac632066c5e848ae714", - "authorization": "eyJraWQiOiJScWFCSlJqYVJlM0hrSnBTUFpIcVRXazNOW...", - "sec-fetch-dest": "empty", - "x-amz-user-agent": "AWS-Console-AppSync/", - "cloudfront-is-desktop-viewer": "true", - "sec-fetch-site": "cross-site", - "x-forwarded-port": "443" - } - }, - "prev": null, - "info": { - "selectionSetList": [ - "id", - "field1", - "field2" - ], - "selectionSetGraphQL": "{\n id\n field1\n field2\n}", - "parentTypeName": "Mutation", - "fieldName": "createSomething", - "variables": {} - }, - "stash": {} -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/batch-get-job.json b/packages/commons/src/samples/resources/events/aws/batch-get-job.json deleted file mode 100644 index cf95238fc4..0000000000 --- a/packages/commons/src/samples/resources/events/aws/batch-get-job.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "jobName": "hello_world", - "jobQueue": "default", - "jobDefinition": "hello_world" -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/batch-submit-job.json b/packages/commons/src/samples/resources/events/aws/batch-submit-job.json deleted file mode 100644 index cf95238fc4..0000000000 --- a/packages/commons/src/samples/resources/events/aws/batch-submit-job.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "jobName": "hello_world", - "jobQueue": "default", - "jobDefinition": "hello_world" -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudformation-create-request.json b/packages/commons/src/samples/resources/events/aws/cloudformation-create-request.json deleted file mode 100644 index 461752bb16..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudformation-create-request.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "RequestType": "Create", - "ResponseURL": "http://pre-signed-S3-url-for-response", - "StackId": "arn:aws:cloudformation:eu-central-1:123456789012:stack/MyStack/guid", - "RequestId": "unique id for this create request", - "ResourceType": "Custom::TestResource", - "LogicalResourceId": "MyTestResource", - "ResourceProperties": { - "StackName": "MyStack", - "List": [ - "1", - "2", - "3" - ] - } -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-ab-test.json b/packages/commons/src/samples/resources/events/aws/cloudfront-ab-test.json deleted file mode 100644 index bdc6b76e2d..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-ab-test.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "user-agent": [ - { - "key": "User-Agent", - "value": "Test Agent" - } - ], - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ], - "cookie": [ - { - "key": "Cookie", - "value": "SomeCookie=1; AnotherOne=A; X-Experiment-Name=B" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-access-request-in-response.json b/packages/commons/src/samples/resources/events/aws/cloudfront-access-request-in-response.json deleted file mode 100644 index ecb1240549..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-access-request-in-response.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ], - "user-name": [ - { - "key": "User-Name", - "value": "CloudFront" - } - ] - }, - "clientIp": "2001:cdba::3257:9652", - "uri": "/test", - "method": "GET" - }, - "response": { - "status": "200", - "statusDescription": "OK", - "headers": { - "x-cache": [ - { - "key": "X-Cache", - "value": "Hello from Cloudfront" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-http-direct.json b/packages/commons/src/samples/resources/events/aws/cloudfront-http-direct.json deleted file mode 100644 index 1f13e53dd1..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-http-direct.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "user-agent": [ - { - "key": "User-Agent", - "value": "test-agent" - } - ], - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-modify-querystring.json b/packages/commons/src/samples/resources/events/aws/cloudfront-modify-querystring.json deleted file mode 100644 index 7485310e94..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-modify-querystring.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "querystring": "auth=test&foo=bar", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ], - "user-agent": [ - { - "key": "User-Agent", - "value": "Test Agent" - } - ], - "user-name": [ - { - "key": "User-Name", - "value": "aws-cloudfront" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-modify-response-header.json b/packages/commons/src/samples/resources/events/aws/cloudfront-modify-response-header.json deleted file mode 100644 index 8ac2b4bc0f..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-modify-response-header.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "response": { - "status": "200", - "statusDescription": "OK", - "headers": { - "vary": [ - { - "key": "Vary", - "value": "*" - } - ], - "last-modified": [ - { - "key": "Last-Modified", - "value": "2016-11-25" - } - ], - "x-amz-meta-last-modified": [ - { - "key": "X-Amz-Meta-Last-Modified", - "value": "2016-01-01" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-multiple-remote-calls-aggregate-response.json b/packages/commons/src/samples/resources/events/aws/cloudfront-multiple-remote-calls-aggregate-response.json deleted file mode 100644 index 1360629d73..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-multiple-remote-calls-aggregate-response.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/forecast/Seattle:NewYork:Chicago:SanFrancisco", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ], - "user-agent": [ - { - "key": "User-Agent", - "value": "Test Agent" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-normalize-querystring-to-improve-cache-hit.json b/packages/commons/src/samples/resources/events/aws/cloudfront-normalize-querystring-to-improve-cache-hit.json deleted file mode 100644 index 21100c997a..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-normalize-querystring-to-improve-cache-hit.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "querystring": "size=LARGE&color=RED", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ], - "user-agent": [ - { - "key": "User-Agent", - "value": "Test Agent" - } - ], - "user-name": [ - { - "key": "User-Name", - "value": "aws-cloudfront" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-redirect-on-viewer-country.json b/packages/commons/src/samples/resources/events/aws/cloudfront-redirect-on-viewer-country.json deleted file mode 100644 index 2d24b0cb43..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-redirect-on-viewer-country.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ], - "cloudfront-viewer-country": [ - { - "key": "CloudFront-Viewer-Country", - "value": "TW" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-redirect-unauthenticated-users.json b/packages/commons/src/samples/resources/events/aws/cloudfront-redirect-unauthenticated-users.json deleted file mode 100644 index 4d064cfd0c..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-redirect-unauthenticated-users.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "method": "GET", - "querystring": "foo=bar", - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-response-generation.json b/packages/commons/src/samples/resources/events/aws/cloudfront-response-generation.json deleted file mode 100644 index 2bfde0f0d6..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-response-generation.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-serve-object-on-viewer-device.json b/packages/commons/src/samples/resources/events/aws/cloudfront-serve-object-on-viewer-device.json deleted file mode 100644 index f1f50a8980..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-serve-object-on-viewer-device.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ], - "cloudfront-is-desktop-viewer": [ - { - "key": "CloudFront-Is-Desktop-Viewer", - "value": "true" - } - ], - "cloudfront-is-mobile-viewer": [ - { - "key": "CloudFront-Is-Mobile-Viewer", - "value": "false" - } - ], - "cloudfront-is-smarttv-viewer": [ - { - "key": "CloudFront-Is-SmartTV-Viewer", - "value": "false" - } - ], - "cloudfront-is-tablet-viewer": [ - { - "key": "CloudFront-Is-Tablet-Viewer", - "value": "false" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudfront-simple-remote-call.json b/packages/commons/src/samples/resources/events/aws/cloudfront-simple-remote-call.json deleted file mode 100644 index bf4625d06d..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudfront-simple-remote-call.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EXAMPLE" - }, - "request": { - "uri": "/test", - "method": "GET", - "clientIp": "2001:cdba::3257:9652", - "headers": { - "host": [ - { - "key": "Host", - "value": "d123.cf.net" - } - ], - "user-agent": [ - { - "key": "User-Agent", - "value": "Test Agent" - } - ], - "user-name": [ - { - "key": "User-Name", - "value": "aws-cloudfront" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudwatch-logs.json b/packages/commons/src/samples/resources/events/aws/cloudwatch-logs.json deleted file mode 100644 index 2b455b9bc4..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudwatch-logs.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "awslogs": { - "data": "H4sIAAAAAAAAAHWPwQqCQBCGX0Xm7EFtK+smZBEUgXoLCdMhFtKV3akI8d0bLYmibvPPN3wz00CJxmQnTO41whwWQRIctmEcB6sQbFC3CjW3XW8kxpOpP+OC22d1Wml1qZkQGtoMsScxaczKN3plG8zlaHIta5KqWsozoTYw3/djzwhpLwivWFGHGpAFe7DL68JlBUk+l7KSN7tCOEJ4M3/qOI49vMHj+zCKdlFqLaU2ZHV2a4Ct/an0/ivdX8oYc1UVX860fQDQiMdxRQEAAA==" - } -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cloudwatch-scheduled-event.json b/packages/commons/src/samples/resources/events/aws/cloudwatch-scheduled-event.json deleted file mode 100644 index dfa0a04b5a..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cloudwatch-scheduled-event.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "cdc73f9d-aea9-11e3-9d5a-835b769c0d9c", - "detail-type": "Scheduled Event", - "source": "aws.events", - "account": "123456789012", - "time": "1970-01-01T00:00:00Z", - "region": "eu-central-1", - "resources": [ - "arn:aws:events:eu-central-1:123456789012:rule/ExampleRule" - ], - "detail": {} -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/codecommit-repository.json b/packages/commons/src/samples/resources/events/aws/codecommit-repository.json deleted file mode 100644 index 227cac73bf..0000000000 --- a/packages/commons/src/samples/resources/events/aws/codecommit-repository.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Records": [ - { - "awsRegion": "eu-central-1", - "codecommit": { - "references": [ - { - "commit": "5c4ef1049f1d27deadbeeff313e0730018be182b", - "ref": "refs/heads/master" - } - ] - }, - "customData": "this is custom data", - "eventId": "5a824061-17ca-46a9-bbf9-114edeadbeef", - "eventName": "TriggerEventTest", - "eventPartNumber": 1, - "eventSource": "aws:codecommit", - "eventSourceARN": "arn:aws:codecommit:eu-central-1:123456789012:my-repo", - "eventTime": "2016-01-01T23:59:59.000+0000", - "eventTotalParts": 1, - "eventTriggerConfigId": "5a824061-17ca-46a9-bbf9-114edeadbeef", - "eventTriggerName": "my-trigger", - "eventVersion": "1.0", - "userIdentityARN": "arn:aws:iam::123456789012:root" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/codepipeline-job.json b/packages/commons/src/samples/resources/events/aws/codepipeline-job.json deleted file mode 100644 index 1ebc6ccb9e..0000000000 --- a/packages/commons/src/samples/resources/events/aws/codepipeline-job.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "CodePipeline.job": { - "data": { - "artifactCredentials": { - "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", - "sessionToken": "token", - "accessKeyId": "AKIAIOSFODNN7EXAMPLE" - }, - "actionConfiguration": { - "configuration": { - "FunctionName": "my-function", - "UserParameters": "user-parameter-string" - } - }, - "inputArtifacts": [ - { - "revision": "ca2bdeadbeef7d1932acb4977e08c803295d9896", - "name": "input-artifact", - "location": { - "type": "S3", - "s3Location": { - "objectKey": "test/key", - "bucketName": "example-bucket" - } - } - } - ], - "outputArtifacts": [ - { - "revision": null, - "name": "output-artifact", - "location": { - "type": "S3", - "s3Location": { - "objectKey": "test/key2", - "bucketName": "example-bucket2" - } - } - } - ] - }, - "id": "c968ef10-6415-4127-80b1-42502218a8c7", - "accountId": "123456789012" - } -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/cognito-sync-trigger.json b/packages/commons/src/samples/resources/events/aws/cognito-sync-trigger.json deleted file mode 100644 index e9c7a0ddd0..0000000000 --- a/packages/commons/src/samples/resources/events/aws/cognito-sync-trigger.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": 2, - "eventType": "SyncTrigger", - "region": "eu-central-1", - "identityPoolId": "identityPoolId", - "identityId": "identityId", - "datasetName": "datasetName", - "datasetRecords": { - "SampleKey1": { - "oldValue": "oldValue1", - "newValue": "newValue1", - "op": "replace" - }, - "SampleKey2": { - "oldValue": "oldValue2", - "newValue": "newValue2", - "op": "replace" - } - } -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/config-oversized-item-change-notification.json b/packages/commons/src/samples/resources/events/aws/config-oversized-item-change-notification.json deleted file mode 100644 index fb20d98bb7..0000000000 --- a/packages/commons/src/samples/resources/events/aws/config-oversized-item-change-notification.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "invokingEvent": "{\"configurationItemSummary\": {\"changeType\": \"UPDATE\",\"configurationItemVersion\": \"1.2\",\"configurationItemCaptureTime\":\"2016-10-06T16:46:16.261Z\",\"configurationStateId\": 0,\"awsAccountId\":\"123456789012\",\"configurationItemStatus\": \"OK\",\"resourceType\": \"AWS::EC2::Instance\",\"resourceId\":\"i-00000000\",\"resourceName\":null,\"ARN\":\"arn:aws:ec2:eu-central-1:123456789012:instance/i-00000000\",\"awsRegion\": \"eu-central-1\",\"availabilityZone\":\"eu-central-1\",\"configurationStateMd5Hash\":\"8f1ee69b287895a0f8bc5753eca68e96\",\"resourceCreationTime\":\"2016-10-06T16:46:10.489Z\"},\"messageType\":\"OversizedConfigurationItemChangeNotification\"}", - "ruleParameters": "{\"\":\"\"}", - "resultToken": "myResultToken", - "eventLeftScope": false, - "executionRoleArn": "arn:aws:iam::123456789012:role/config-role", - "configRuleArn": "arn:aws:config:eu-central-1:123456789012:config-rule/config-rule-0123456", - "configRuleName": "change-triggered-config-rule", - "configRuleId": "config-rule-0123456", - "accountId": "123456789012", - "version": "1.0" -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/config-periodic-rule.json b/packages/commons/src/samples/resources/events/aws/config-periodic-rule.json deleted file mode 100644 index 03322a8b12..0000000000 --- a/packages/commons/src/samples/resources/events/aws/config-periodic-rule.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "invokingEvent": "{\"awsAccountId\":\"123456789012\",\"notificationCreationTime\":\"1970-01-01T00:00:00.0Z\",\"messageType\":\"ScheduledNotification\",\"recordVersion\":\"1.0\"}", - "ruleParameters": "{\"myParameterKey\":\"myParameterValue\"}", - "resultToken": "myResultToken", - "eventLeftScope": false, - "executionRoleArn": "arn:aws:iam::123456789012:role/config-role", - "configRuleArn": "arn:aws:config:eu-central-1:123456789012:config-rule/config-rule-0123456", - "configRuleName": "periodic-config-rule", - "configRuleId": "config-rule-0123456", - "accountId": "123456789012", - "version": "1.0" -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/confit-item-change-notification.json b/packages/commons/src/samples/resources/events/aws/confit-item-change-notification.json deleted file mode 100644 index cf79568736..0000000000 --- a/packages/commons/src/samples/resources/events/aws/confit-item-change-notification.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "invokingEvent": "{\"configurationItem\":{\"configurationItemCaptureTime\":\"2016-10-06T16:46:16.261Z\",\"awsAccountId\":\"123456789012\",\"configurationItemStatus\":\"OK\",\"resourceId\":\"i-00000000\",\"resourceName\":\"foo\",\"configurationStateMd5Hash\":\"8f1ee69b297895a0f8bc5753eca68e96\",\"resourceCreationTime\":\"2016-10-06T16:46:10.489Z\",\"configurationStateId\":0,\"configurationItemVersion\":\"1.2\",\"ARN\":\"arn:aws:ec2:eu-central-1:123456789012:instance/i-00000000\",\"awsRegion\":\"eu-central-1\",\"availabilityZone\":\"eu-central-1\",\"resourceType\":\"AWS::EC2::Instance\",\"tags\":{\"\":\"\"},\"relationships\":[{\"resourceId\":\"eipalloc-00000000\",\"resourceType\":\"AWS::EC2::EIP\",\"name\":\"Is attached to ElasticIp\"}],\"configuration\":{\"\":\"\"}},\"messageType\":\"ConfigurationItemChangeNotification\"}", - "ruleParameters": "{\"\":\"\"}", - "resultToken": "myResultToken", - "eventLeftScope": false, - "executionRoleArn": "arn:aws:iam::123456789012:role/config-role", - "configRuleArn": "arn:aws:config:eu-central-1:123456789012:config-rule/config-rule-0123456", - "configRuleName": "change-triggered-config-rule", - "configRuleId": "config-rule-0123456", - "accountId": "123456789012", - "version": "1.0" -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/connect-contact-flow-event.json b/packages/commons/src/samples/resources/events/aws/connect-contact-flow-event.json deleted file mode 100644 index b192be3150..0000000000 --- a/packages/commons/src/samples/resources/events/aws/connect-contact-flow-event.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "Name": "ContactFlowEvent", - "Details": { - "ContactData": { - "Attributes": {}, - "Channel": "VOICE", - "ContactId": "5ca32fbd-8f92-46af-92a5-6b0f970f0efe", - "CustomerEndpoint": { - "Address": "+11234567890", - "Type": "TELEPHONE_NUMBER" - }, - "InitialContactId": "5ca32fbd-8f92-46af-92a5-6b0f970f0efe", - "InitiationMethod": "API", - "InstanceARN": "arn:aws:connect:eu-central-1:123456789012:instance/9308c2a1-9bc6-4cea-8290-6c0b4a6d38fa", - "MediaStreams": { - "Customer": { - "Audio": { - "StartFragmentNumber": "91343852333181432392682062622220590765191907586", - "StartTimestamp": "1565781909613", - "StreamARN": "arn:aws:kinesisvideo:eu-central-1:123456789012:stream/connect-contact-a3d73b84-ce0e-479a-a9dc-5637c9d30ac9/1565272947806" - } - } - }, - "PreviousContactId": "5ca32fbd-8f92-46af-92a5-6b0f970f0efe", - "Queue": null, - "SystemEndpoint": { - "Address": "+11234567890", - "Type": "TELEPHONE_NUMBER" - } - }, - "Parameters": {} - } -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/dynamodb-update-2.json b/packages/commons/src/samples/resources/events/aws/dynamodb-update-2.json deleted file mode 100644 index c7f8ca2795..0000000000 --- a/packages/commons/src/samples/resources/events/aws/dynamodb-update-2.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "Records": [ - { - "eventID": "1", - "eventVersion": "1.0", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "NewImage": { - "Message": { - "S": "New item!" - }, - "Id": { - "N": "101" - } - }, - "StreamViewType": "NEW_AND_OLD_IMAGES", - "SequenceNumber": "111", - "SizeBytes": 26 - }, - "awsRegion": "eu-central-1", - "eventName": "INSERT", - "eventSourceARN": "arn:aws:dynamodb:eu-central-1:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" - }, - { - "eventID": "2", - "eventVersion": "1.0", - "dynamodb": { - "OldImage": { - "Message": { - "S": "New item!" - }, - "Id": { - "N": "101" - } - }, - "SequenceNumber": "222", - "Keys": { - "Id": { - "N": "101" - } - }, - "SizeBytes": 59, - "NewImage": { - "Message": { - "S": "This item has changed" - }, - "Id": { - "N": "101" - } - }, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "awsRegion": "eu-central-1", - "eventName": "MODIFY", - "eventSourceARN": "arn:aws:dynamodb:eu-central-1:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" - }, - { - "eventID": "3", - "eventVersion": "1.0", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "SizeBytes": 38, - "SequenceNumber": "333", - "OldImage": { - "Message": { - "S": "This item has changed" - }, - "Id": { - "N": "101" - } - }, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "awsRegion": "eu-central-1", - "eventName": "REMOVE", - "eventSourceARN": "arn:aws:dynamodb:eu-central-1:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/dynamodb-update.json b/packages/commons/src/samples/resources/events/aws/dynamodb-update.json deleted file mode 100644 index f59d46c645..0000000000 --- a/packages/commons/src/samples/resources/events/aws/dynamodb-update.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "Records": [ - { - "eventID": "c4ca4238a0b923820dcc509a6f75849b", - "eventName": "INSERT", - "eventVersion": "1.1", - "eventSource": "aws:dynamodb", - "awsRegion": "eu-central-1", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "NewImage": { - "Message": { - "S": "New item!" - }, - "Id": { - "N": "101" - } - }, - "ApproximateCreationDateTime": 1428537600, - "SequenceNumber": "4421584500000000017450439091", - "SizeBytes": 26, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "eventSourceARN": "arn:aws:dynamodb:eu-central-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899" - }, - { - "eventID": "c81e728d9d4c2f636f067f89cc14862c", - "eventName": "MODIFY", - "eventVersion": "1.1", - "eventSource": "aws:dynamodb", - "awsRegion": "eu-central-1", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "NewImage": { - "Message": { - "S": "This item has changed" - }, - "Id": { - "N": "101" - } - }, - "OldImage": { - "Message": { - "S": "New item!" - }, - "Id": { - "N": "101" - } - }, - "ApproximateCreationDateTime": 1428537600, - "SequenceNumber": "4421584500000000017450439092", - "SizeBytes": 59, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "eventSourceARN": "arn:aws:dynamodb:eu-central-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899" - }, - { - "eventID": "eccbc87e4b5ce2fe28308fd9f2a7baf3", - "eventName": "REMOVE", - "eventVersion": "1.1", - "eventSource": "aws:dynamodb", - "awsRegion": "eu-central-1", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "OldImage": { - "Message": { - "S": "This item has changed" - }, - "Id": { - "N": "101" - } - }, - "ApproximateCreationDateTime": 1428537600, - "SequenceNumber": "4421584500000000017450439093", - "SizeBytes": 38, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "eventSourceARN": "arn:aws:dynamodb:eu-central-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-analytics-compressed.json b/packages/commons/src/samples/resources/events/aws/kinesis-analytics-compressed.json deleted file mode 100644 index b6c3a539d5..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-analytics-compressed.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "invocationId": "invocationIdExample", - "applicationArn": "arn:aws:kinesisanalytics:eu-central-1:123456789012:application/example-application", - "streamArn": "arn:aws:kinesis:eu-central-1:123456789012:stream/example-stream", - "records": [ - { - "recordId": "49571347871967966406409637155186850213682522142927749122", - "data": "H4sIAAAAAAAA/6vmUspLzE1VslLKTsxNzFHS4VJKTEkpSi0uBgol5SRmKHHVAgDd1tysJAAAAA==" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-analytics-dynamodb.json b/packages/commons/src/samples/resources/events/aws/kinesis-analytics-dynamodb.json deleted file mode 100644 index 8d45307cac..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-analytics-dynamodb.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "invocationId": "invocationIdExample", - "applicationArn": "arn:aws:kinesisanalytics:eu-central-1:123456789012:application/example-application", - "streamArn": "arn:aws:kinesis:eu-central-1:123456789012:stream/example-stream", - "records": [ - { - "recordId": "49571347871967966406409637155186850213682522142927749122", - "data": "eyJST1dUSU1FX1RJTUVTVEFNUCI6IjIwMTctMTItMTUgMDE6MDk6NTAuMDAwIiwiVkVISUNMRUlEIjoiNSIsIlZFSElDTEVDT1VOVCI6MTh9" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-analytics-kpl.json b/packages/commons/src/samples/resources/events/aws/kinesis-analytics-kpl.json deleted file mode 100644 index 807467ead1..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-analytics-kpl.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "invocationId": "invocationIdExample", - "applicationArn": "arn:aws:kinesisanalytics:eu-central-1:123456789012:application/example-application", - "streamArn": "arn:aws:kinesis:eu-central-1:123456789012:stream/example-stream", - "records": [ - { - "recordId": "49571347871967966406409637155186850213682522142927749122", - "kinesisStreamRecordMetadata": { - "shardId": "shardId-000000000001", - "partitionKey": "partitionKey-01", - "approximateArrivalTimestamp": 1505169657117, - "sequenceNumber": "49571347871967966406409637155186850213682522142927749122" - }, - "data": "84mawgoNMTUwNTE2OTY0NTI1MBIlODYwOTcwOTY1NTE0NjQwMzU1MjIwNTI5MjgyNDk2MzU3MTUzNxImNzk1MTM3MTQxMzM4MTE5NTU1OTExMzA1ODMxNDEyOTg2NTM2OTgaiAEIABAAGoEBNDAsYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWEKGogBCAAQARqBATQxLGFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhCkU/elbPye5g1wGkAmxGCNg=" - }, - { - "recordId": "49571347871967966406409637141563465152445265354688561154", - "kinesisStreamRecordMetadata": { - "shardId": "shardId-000000000002", - "partitionKey": "partitionKey-02", - "approximateArrivalTimestamp": 1505169647777, - "sequenceNumber": "49571347871967966406409637141563465152445265354688561154" - }, - "data": "NCxhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWEK" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-analytics.json b/packages/commons/src/samples/resources/events/aws/kinesis-analytics.json deleted file mode 100644 index 7f1db565b1..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-analytics.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "invocationId": "invocationIdExample", - "applicationArn": "arn:aws:kinesisanalytics:eu-central-1:123456789012:application/example-application", - "streamArn": "arn:aws:kinesis:eu-central-1:123456789012:stream/example-stream", - "records": [ - { - "recordId": "49571347871967966406409637155186850213682522142927749122", - "data": "VGhpcyBpcyBhIHRlc3QgZnJvbSBLaW5lc2lzIEFuYWx5dGljcw==" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-apachelog.json b/packages/commons/src/samples/resources/events/aws/kinesis-apachelog.json deleted file mode 100644 index 3f917a1613..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-apachelog.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "invocationId": "invocationIdExample", - "region": "eu-central-1", - "records": [ - { - "recordId": "49546986683135544286507457936321625675700192471156785154", - "approximateArrivalTimestamp": 1495072949453, - "data": "NjQuMjQyLjg4LjEwIC0gLSBbMDcvTWFyLzIwMDQ6MTY6MTA6MDIgLTA4MDBdICJHRVQgL21haWxtYW4vbGlzdGluZm8vaHNkaXZpc2lvbiBIVFRQLzEuMSIgMjAwIDYyOTE==" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-cloudwatch-logs-processor.json b/packages/commons/src/samples/resources/events/aws/kinesis-cloudwatch-logs-processor.json deleted file mode 100644 index c7978af868..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-cloudwatch-logs-processor.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "records": [ - { - "recordId": "49578734086442259037497492980620233840400173390482112514000000", - "data": "H4sIAAAAAAAAADWO0QqCMBiFX2XsWiJFi7wLUW8sIYUuQmLpnxvpJttMQnz3Ztrlxzmc8424BaVIDfmnA+zjID3nlzS5n8IsO8YhtrAYOMg5aURfDUSXNBG1MkEj6liKvjPZQpmWQNoFVf9QpWSdZoJHrNEgFfZvxa8XvoHrGUfMqqWumdHQpDVjtmdvHc91dwdn71p/vVngmqBVD616PgoolC/Ga0SBNJoi8USVWWKczM8oYhKoULDBUzF9Aeua5yHsAAAA", - "approximateArrivalTimestamp": 1510254469499 - }, - { - "recordId": "49578734086442259037497492980621442766219788363254202370000000", - "data": "H4sIAAAAAAAAAJWRTWsbMRCG/8ueLZjRjL5yc9NNLnZDapemlFAkrTYstb3Lep0Qgv97x00KgTSHnAQzmkeP3nmqtmW/j3dl/TiU6qz6PF/Pfy3r1Wp+WVezqn/YlVHK2pK3Hr0Jxkt5099djv1hkE7uh0eVHzZqE7epiarb3fe/ixzDYVJoELRhssYQqsXLlEJ3jd8//biy4QYWz7jVNJa4/TDveQwV+qsada0v/HnthLg/pH0eu2Hq+t1Ft5nKuK/Ofn4EvnpDUAu7Xi6/LL9en3/z1e1f7fq+7KYT+qnqGrEnsi54AGS2wbHWxjCjoWAYGawmzawByIG3Dp0JzjOxsaI8dbKJKW4l1BcTdgg+zP5tSPCeQ/Bso/I+o+I2kUptjgrRlQyasslUHWdvZRwGJ4+HYJGCtiKgQTYKSJ4gODLgAkpFk3f0rkyA1zLGSsvoVsVCRTFakUkNqKxt1IyFc8T/y0gEmoHZo5a/W9HhU0TeWHMyIJaoQC6zDvC+DL6WSW3MqZSkiolJcWoalWybJSNIJTXcRgjV8fb4BwwLrNzwAgAA", - "approximateArrivalTimestamp": 1510254473773 - }, - { - "recordId": "49578734086442259037497492980622651692039402992428908546000000", - "data": "H4sIAAAAAAAAAJWRbWsbMQyA/8t9jkGSJdnut2zLCiXZyJKyZaMM352vHEty4e7SUkr++9yXwUbXD8Vgg2w9eizdF7s0DPE6re8OqTgrPkzX05+L2Wo1PZ8Vk6K73ac+h0mtV49egvgc3nbX5313POSbqjvcmep2a7ZxV9bRtPub7lfKx+E4GhQEErYqYtHMn7MMuiV+fbf5rOEbzJ9wq7FPcfdm3lOaNReXyws/3cw2fvk9A4djOVR9exjbbv+x3Y6pH4qzH29hr14QzFzXi8WnxZfl+0tfXD1az27SfnxA3xdtneWtVRc8ADJrcEwkwoxigzAyiBNxzkJuIxGrei+g3gbgrDy2eRBj3OWePpuwQ/Bh8mdAGR+J69pJMFXKihwTGJ+aYJArpkjYQB2K0+SljMPgyFIIijaQgs2BAMEyexbns1NeoqpsCV+VCfCPTOVLLgUMU4h5S5UpE4BRm6ROqCEF/r8MExBDro3ED0XBMigFVM0iQlkRvZLml9a/LoN/yzSYKoIKTOmVTf6VNTHZxkjTIElkqlCL09XpN5PgkxrvAgAA", - "approximateArrivalTimestamp": 1510254474027 - }, - { - "recordId": "49578734086442259037497492980623860617859017621603614722000000", - "data": "H4sIAAAAAAAAAJWRW28aQQyF/8s+M9J47LHHeaMtzUOhEQXSVlVUDctstCqwCJZEUcR/r3OpFCnNQ17mcjw+8+n4vtqUwyFfl/ndrlRn1afhfPh7MprNhuejalB1t9uyNzkwJk6QosZk8rq7Pt93x51V6m535+rbtVvnzXKVXbu96f4U23bH3kEEHyIhx4jgxs9dDmQK3z/8vGD94cdPdrN+X/Lm3X5PbcHp5QLkYrqYLC6/mOHhuDzU+3bXt932c7vuy/5Qnf16j/fslYMb83wy+Tr5Nv24SNXVI/Xopmz7B+v7ql0ZPCKLJu+BiFUohBiJIKJGAvIkSTgpsU8aVBNangymsCH3rQ2izxvL9JmEBOzh4N+AzL6gX3JD7CLn4kg8OiVduahNkIa0BtbqNHgNI6AS0P5kQA3sUcA4IDCElCBKwgdgiCoI+CaM+pcwbAVfN8F5r2owGV0OdpWkS8kp52a1/D8MBR8sDUoQKDIbDnqlhAgQLTMWz8YbRQT92zDwEkbIQ10YHUZbKGfvUmrAIWodih2btKpOV6e/zXGIX+8CAAA=", - "approximateArrivalTimestamp": 1510254474388 - } - ], - "region": "eu-central-1", - "deliveryStreamArn": "arn:aws:firehose:eu-central-1:123456789012:deliverystream/copy-cwl-lambda-invoke-input-151025436553-Firehose-8KILJ01Q5OBN", - "invocationId": "a7234216-12b6-4bc0-96d7-82606c0e80cf" -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-get-records.json b/packages/commons/src/samples/resources/events/aws/kinesis-get-records.json deleted file mode 100644 index 12abdabd3c..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-get-records.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "Records": [ - { - "kinesis": { - "partitionKey": "partitionKey-03", - "kinesisSchemaVersion": "1.0", - "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=", - "sequenceNumber": "49545115243490985018280067714973144582180062593244200961", - "approximateArrivalTimestamp": 1428537600 - }, - "eventSource": "aws:kinesis", - "eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", - "invokeIdentityArn": "arn:aws:iam::EXAMPLE", - "eventVersion": "1.0", - "eventName": "aws:kinesis:record", - "eventSourceARN": "arn:aws:kinesis:EXAMPLE", - "awsRegion": "eu-central-1" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-kinesis-firehose.json b/packages/commons/src/samples/resources/events/aws/kinesis-kinesis-firehose.json deleted file mode 100644 index df23583934..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-kinesis-firehose.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "invocationId": "invocationIdExample", - "deliveryStreamArn": "arn:aws:kinesis:EXAMPLE", - "region": "eu-central-1", - "records": [ - { - "recordId": "49546986683135544286507457936321625675700192471156785154", - "approximateArrivalTimestamp": 1495072949453, - "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-streams-source.json b/packages/commons/src/samples/resources/events/aws/kinesis-streams-source.json deleted file mode 100644 index a462dc7e07..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-streams-source.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "invocationId": "invocationIdExample", - "deliverySteamArn": "arn:aws:kinesis:EXAMPLE", - "region": "eu-central-1", - "records": [ - { - "recordId": "49546986683135544286507457936321625675700192471156785154", - "approximateArrivalTimestamp": 1495072949453, - "kinesisRecordMetadata": { - "sequenceNumber": "49545115243490985018280067714973144582180062593244200961", - "subsequenceNumber": "123456", - "partitionKey": "partitionKey-03", - "shardId": "shardId-000000000000", - "approximateArrivalTimestamp": 1495072949453 - }, - "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/kinesis-syslog.json b/packages/commons/src/samples/resources/events/aws/kinesis-syslog.json deleted file mode 100644 index bac8ff5567..0000000000 --- a/packages/commons/src/samples/resources/events/aws/kinesis-syslog.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "invocationId": "fir", - "region": "eu-central-1", - "records": [ - { - "recordId": "49546986683135544286507457936321625675700192471156785154", - "approximateArrivalTimestamp": 1495072949453, - "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=" - }, - { - "recordId": "49546986683135544286507457936321625675700192471156785154", - "approximateArrivalTimestamp": "2012-04-23T18:25:43.511Z", - "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/rekognition-s3-request.json b/packages/commons/src/samples/resources/events/aws/rekognition-s3-request.json deleted file mode 100644 index 89e0bd312c..0000000000 --- a/packages/commons/src/samples/resources/events/aws/rekognition-s3-request.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "Records": [ - { - "eventVersion": "2.0", - "eventSource": "aws:s3", - "awsRegion": "eu-central-1", - "eventTime": "1970-01-01T00:00:00.000Z", - "eventName": "ObjectCreated:Put", - "userIdentity": { - "principalId": "EXAMPLE" - }, - "requestParameters": { - "sourceIPAddress": "127.0.0.1" - }, - "responseElements": { - "x-amz-request-id": "EXAMPLE123456789", - "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH" - }, - "s3": { - "s3SchemaVersion": "1.0", - "configurationId": "testConfigRule", - "bucket": { - "name": "example-bucket", - "ownerIdentity": { - "principalId": "EXAMPLE" - }, - "arn": "arn:aws:s3:::example-bucket" - }, - "object": { - "key": "test/key", - "size": 1024, - "eTag": "0123456789abcdef0123456789abcdef", - "sequencer": "0A1B2C3D4E5F678901" - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/s3-delete.json b/packages/commons/src/samples/resources/events/aws/s3-delete.json deleted file mode 100644 index fd30611694..0000000000 --- a/packages/commons/src/samples/resources/events/aws/s3-delete.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "Records": [ - { - "eventVersion": "2.0", - "eventSource": "aws:s3", - "awsRegion": "eu-central-1", - "eventTime": "1970-01-01T00:00:00.000Z", - "eventName": "ObjectRemoved:Delete", - "userIdentity": { - "principalId": "EXAMPLE" - }, - "requestParameters": { - "sourceIPAddress": "127.0.0.1" - }, - "responseElements": { - "x-amz-request-id": "EXAMPLE123456789", - "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH" - }, - "s3": { - "s3SchemaVersion": "1.0", - "configurationId": "testConfigRule", - "bucket": { - "name": "example-bucket", - "ownerIdentity": { - "principalId": "EXAMPLE" - }, - "arn": "arn:aws:s3:::example-bucket" - }, - "object": { - "key": "test/key", - "sequencer": "0A1B2C3D4E5F678901" - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/s3-put.json b/packages/commons/src/samples/resources/events/aws/s3-put.json deleted file mode 100644 index 89e0bd312c..0000000000 --- a/packages/commons/src/samples/resources/events/aws/s3-put.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "Records": [ - { - "eventVersion": "2.0", - "eventSource": "aws:s3", - "awsRegion": "eu-central-1", - "eventTime": "1970-01-01T00:00:00.000Z", - "eventName": "ObjectCreated:Put", - "userIdentity": { - "principalId": "EXAMPLE" - }, - "requestParameters": { - "sourceIPAddress": "127.0.0.1" - }, - "responseElements": { - "x-amz-request-id": "EXAMPLE123456789", - "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH" - }, - "s3": { - "s3SchemaVersion": "1.0", - "configurationId": "testConfigRule", - "bucket": { - "name": "example-bucket", - "ownerIdentity": { - "principalId": "EXAMPLE" - }, - "arn": "arn:aws:s3:::example-bucket" - }, - "object": { - "key": "test/key", - "size": 1024, - "eTag": "0123456789abcdef0123456789abcdef", - "sequencer": "0A1B2C3D4E5F678901" - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/sagemaker-ground-truth-annotation-consolidation.json b/packages/commons/src/samples/resources/events/aws/sagemaker-ground-truth-annotation-consolidation.json deleted file mode 100644 index 2aeb4fbbce..0000000000 --- a/packages/commons/src/samples/resources/events/aws/sagemaker-ground-truth-annotation-consolidation.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "version": "2018-10-16", - "labelingJobArn": "arn:aws:sagemaker:eu-central-1:123456789012:labeling-job/example-job", - "labelAttributeName": "example-attribute", - "roleArn": "aws:aws:iam::{{account_id}}:role/sagemaker-role", - "payload": { - "s3Uri": "s3://sagemakerexample/output/example-job/annotations/worker_response/iteration-1/0/2019-09-06_18:35:03.json" - } -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/sagemaker-ground-truth-pre-human.json b/packages/commons/src/samples/resources/events/aws/sagemaker-ground-truth-pre-human.json deleted file mode 100644 index 26c9755d2c..0000000000 --- a/packages/commons/src/samples/resources/events/aws/sagemaker-ground-truth-pre-human.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": "2018-10-16", - "labelingJobArn": "arn:aws:sagemaker:eu-central-1:123456789012:labeling-job/example-job", - "dataObject": { - "source-ref": "s3://sagemakerexample/object_to_annotate.jpg" - } -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/ses-email-receiving.json b/packages/commons/src/samples/resources/events/aws/ses-email-receiving.json deleted file mode 100644 index 3a80dfe175..0000000000 --- a/packages/commons/src/samples/resources/events/aws/ses-email-receiving.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "Records": [ - { - "eventSource": "aws:ses", - "eventVersion": "1.0", - "ses": { - "mail": { - "commonHeaders": { - "date": "Wed, 7 Oct 2015 12:34:56 -0700", - "from": [ - "Jane Doe " - ], - "messageId": "<0123456789example.com>", - "returnPath": "janedoe@example.com", - "subject": "Test Subject", - "to": [ - "johndoe@example.com" - ] - }, - "destination": [ - "johndoe@example.com" - ], - "headers": [ - { - "name": "Return-Path", - "value": "" - }, - { - "name": "Received", - "value": "from mailer.example.com (mailer.example.com [203.0.113.1]) by inbound-smtp.eu-central-1.amazonaws.com with SMTP id o3vrnil0e2ic28trm7dfhrc2v0cnbeccl4nbp0g1 for johndoe@example.com; Wed, 07 Oct 2015 12:34:56 +0000 (UTC)" - }, - { - "name": "DKIM-Signature", - "value": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=example; h=mime-version:from:date:message-id:subject:to:content-type; bh=jX3F0bCAI7sIbkHyy3mLYO28ieDQz2R0P8HwQkklFj4=; b=sQwJ+LMe9RjkesGu+vqU56asvMhrLRRYrWCbVt6WJulueecwfEwRf9JVWgkBTKiL6m2hr70xDbPWDhtLdLO+jB3hzjVnXwK3pYIOHw3vxG6NtJ6o61XSUwjEsp9tdyxQjZf2HNYee873832l3K1EeSXKzxYk9Pwqcpi3dMC74ct9GukjIevf1H46hm1L2d9VYTL0LGZGHOAyMnHmEGB8ZExWbI+k6khpurTQQ4sp4PZPRlgHtnj3Zzv7nmpTo7dtPG5z5S9J+L+Ba7dixT0jn3HuhaJ9b+VThboo4YfsX9PMNhWWxGjVksSFOcGluPO7QutCPyoY4gbxtwkN9W69HA==" - }, - { - "name": "MIME-Version", - "value": "1.0" - }, - { - "name": "From", - "value": "Jane Doe " - }, - { - "name": "Date", - "value": "Wed, 7 Oct 2015 12:34:56 -0700" - }, - { - "name": "Message-ID", - "value": "<0123456789example.com>" - }, - { - "name": "Subject", - "value": "Test Subject" - }, - { - "name": "To", - "value": "johndoe@example.com" - }, - { - "name": "Content-Type", - "value": "text/plain; charset=UTF-8" - } - ], - "headersTruncated": false, - "messageId": "o3vrnil0e2ic28trm7dfhrc2v0clambda4nbp0g1", - "source": "janedoe@example.com", - "timestamp": "1970-01-01T00:00:00.000Z" - }, - "receipt": { - "action": { - "functionArn": "arn:aws:lambda:eu-central-1:123456789012:function:Example", - "invocationType": "Event", - "type": "Lambda" - }, - "dkimVerdict": { - "status": "PASS" - }, - "processingTimeMillis": 574, - "recipients": [ - "johndoe@example.com" - ], - "spamVerdict": { - "status": "PASS" - }, - "spfVerdict": { - "status": "PASS" - }, - "timestamp": "1970-01-01T00:00:00.000Z", - "virusVerdict": { - "status": "PASS" - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/sns-notification.json b/packages/commons/src/samples/resources/events/aws/sns-notification.json deleted file mode 100644 index 4bb79dee1e..0000000000 --- a/packages/commons/src/samples/resources/events/aws/sns-notification.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "Records": [ - { - "EventSource": "aws:sns", - "EventVersion": "1.0", - "EventSubscriptionArn": "arn:aws:sns:eu-central-1:{{{accountId}}}:ExampleTopic", - "Sns": { - "Type": "Notification", - "MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e", - "TopicArn": "arn:aws:sns:eu-central-1:123456789012:ExampleTopic", - "Subject": "example subject", - "Message": "example message", - "Timestamp": "1970-01-01T00:00:00.000Z", - "SignatureVersion": "1", - "Signature": "EXAMPLE", - "SigningCertUrl": "EXAMPLE", - "UnsubscribeUrl": "EXAMPLE", - "MessageAttributes": { - "Test": { - "Type": "String", - "Value": "TestString" - }, - "TestBinary": { - "Type": "Binary", - "Value": "TestBinary" - } - } - } - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/sqs-receive-message.json b/packages/commons/src/samples/resources/events/aws/sqs-receive-message.json deleted file mode 100644 index a24697a237..0000000000 --- a/packages/commons/src/samples/resources/events/aws/sqs-receive-message.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "Records": [ - { - "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78", - "receiptHandle": "MessageReceiptHandle", - "body": "Hello from SQS!", - "attributes": { - "ApproximateReceiveCount": "1", - "SentTimestamp": "1523232000000", - "SenderId": "123456789012", - "ApproximateFirstReceiveTimestamp": "1523232000001" - }, - "messageAttributes": {}, - "md5OfBody": "{{{md5_of_body}}}", - "eventSource": "aws:sqs", - "eventSourceARN": "arn:aws:sqs:eu-central-1:123456789012:MyQueue", - "awsRegion": "eu-central-1" - } - ] -} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/aws/stepfunctions-error.json b/packages/commons/src/samples/resources/events/aws/stepfunctions-error.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/packages/commons/src/samples/resources/events/aws/stepfunctions-error.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/packages/commons/src/samples/resources/events/custom/index.ts b/packages/commons/src/samples/resources/events/custom/index.ts deleted file mode 100644 index bf173e958f..0000000000 --- a/packages/commons/src/samples/resources/events/custom/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const CustomEvent = { - key1: 'value1', - key2: 'value2', - key3: 'value3', -}; diff --git a/packages/commons/src/samples/resources/events/index.ts b/packages/commons/src/samples/resources/events/index.ts deleted file mode 100644 index 94b087e514..0000000000 --- a/packages/commons/src/samples/resources/events/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * as Custom from './custom/index.js'; diff --git a/packages/commons/tests/unit/EnvironmentVariablesService.test.ts b/packages/commons/tests/unit/EnvironmentVariablesService.test.ts index c9592374d1..c7b4c75d19 100644 --- a/packages/commons/tests/unit/EnvironmentVariablesService.test.ts +++ b/packages/commons/tests/unit/EnvironmentVariablesService.test.ts @@ -3,7 +3,6 @@ * * @group unit/commons/environmentService */ - import { EnvironmentVariablesService } from '../../src/index.js'; describe('Class: EnvironmentVariablesService', () => { diff --git a/packages/commons/tests/unit/LambdaInterface.test.ts b/packages/commons/tests/unit/LambdaInterface.test.ts index 376d35bf52..7d7decc5a0 100644 --- a/packages/commons/tests/unit/LambdaInterface.test.ts +++ b/packages/commons/tests/unit/LambdaInterface.test.ts @@ -5,7 +5,7 @@ */ import { Handler } from 'aws-lambda'; import { Callback, Context } from 'aws-lambda'; -import { helloworldContext as context } from '../../src/samples/resources/contexts/hello-world'; +import context from '@aws-lambda-powertools/testing-utils/context'; import type { SyncHandler, AsyncHandler, diff --git a/packages/commons/tests/unit/cleanupMiddlewares.test.ts b/packages/commons/tests/unit/cleanupMiddlewares.test.ts index c3f92f965f..15295a0396 100644 --- a/packages/commons/tests/unit/cleanupMiddlewares.test.ts +++ b/packages/commons/tests/unit/cleanupMiddlewares.test.ts @@ -10,7 +10,7 @@ import { LOGGER_KEY, IDEMPOTENCY_KEY, } from '../../src/index.js'; -import { helloworldContext as context } from '../../src/samples/resources/contexts/hello-world'; +import context from '@aws-lambda-powertools/testing-utils/context'; describe('Function: cleanupMiddlewares', () => { it('calls the cleanup function that are present', async () => { diff --git a/packages/idempotency/tests/helpers/resources.ts b/packages/idempotency/tests/helpers/resources.ts index 75bc4276ed..3a732f5ba0 100644 --- a/packages/idempotency/tests/helpers/resources.ts +++ b/packages/idempotency/tests/helpers/resources.ts @@ -1,14 +1,14 @@ +import { + type TestStack, + concatenateResourceName, +} from '@aws-lambda-powertools/testing-utils'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; +import { TestDynamodbTable } from '@aws-lambda-powertools/testing-utils/resources/dynamodb'; import type { ExtraTestProps, TestDynamodbTableProps, TestNodejsFunctionProps, - TestStack, -} from '@aws-lambda-powertools/testing-utils'; -import { - concatenateResourceName, - TestDynamodbTable, - TestNodejsFunction, -} from '@aws-lambda-powertools/testing-utils'; +} from '@aws-lambda-powertools/testing-utils/types'; import { Construct } from 'constructs'; import { randomUUID } from 'node:crypto'; diff --git a/packages/idempotency/tests/unit/IdempotencyConfig.test.ts b/packages/idempotency/tests/unit/IdempotencyConfig.test.ts index 17b6252947..f531972135 100644 --- a/packages/idempotency/tests/unit/IdempotencyConfig.test.ts +++ b/packages/idempotency/tests/unit/IdempotencyConfig.test.ts @@ -3,13 +3,12 @@ * * @group unit/idempotency/config */ -import { ContextExamples as dummyContext } from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { IdempotencyConfig } from '../../src'; import type { IdempotencyConfigOptions } from '../../src/types'; describe('Class: IdempotencyConfig', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext.helloworldContext; beforeEach(() => { jest.clearAllMocks(); diff --git a/packages/idempotency/tests/unit/idempotencyDecorator.test.ts b/packages/idempotency/tests/unit/idempotencyDecorator.test.ts index f12b9ae6d3..acbee6e3bc 100644 --- a/packages/idempotency/tests/unit/idempotencyDecorator.test.ts +++ b/packages/idempotency/tests/unit/idempotencyDecorator.test.ts @@ -15,7 +15,7 @@ import { } from '../../src/errors'; import { IdempotencyConfig } from '../../src'; import { Context } from 'aws-lambda'; -import { ContextExamples as context } from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { IdempotencyRecordStatus } from '../../src/constants'; const mockSaveInProgress = jest @@ -28,8 +28,6 @@ const mockGetRecord = jest .spyOn(BasePersistenceLayer.prototype, 'getRecord') .mockImplementation(); -const dummyContext = context.helloworldContext; - const mockConfig: IdempotencyConfig = new IdempotencyConfig({}); class PersistenceLayerTestClass extends BasePersistenceLayer { @@ -81,13 +79,13 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = describe('When wrapping a function with no previous executions', () => { beforeEach(async () => { - await classWithFunctionDecorator.handler(inputRecord, dummyContext); + await classWithFunctionDecorator.handler(inputRecord, context); }); test('Then it will save the record to INPROGRESS', () => { expect(mockSaveInProgress).toBeCalledWith( inputRecord, - dummyContext.getRemainingTimeInMillis() + context.getRemainingTimeInMillis() ); }); @@ -101,13 +99,13 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = }); describe('When wrapping a handler function with no previous executions', () => { beforeEach(async () => { - await classWithLambdaHandler.testing(inputRecord, dummyContext); + await classWithLambdaHandler.testing(inputRecord, context); }); test('Then it will save the record to INPROGRESS', () => { expect(mockSaveInProgress).toBeCalledWith( inputRecord, - dummyContext.getRemainingTimeInMillis() + context.getRemainingTimeInMillis() ); }); @@ -134,7 +132,7 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = new IdempotencyRecord(idempotencyOptions) ); try { - await classWithLambdaHandler.testing(inputRecord, dummyContext); + await classWithLambdaHandler.testing(inputRecord, context); } catch (e) { resultingError = e as Error; } @@ -143,7 +141,7 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = test('Then it will attempt to save the record to INPROGRESS', () => { expect(mockSaveInProgress).toBeCalledWith( inputRecord, - dummyContext.getRemainingTimeInMillis() + context.getRemainingTimeInMillis() ); }); @@ -174,7 +172,7 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = new IdempotencyRecord(idempotencyOptions) ); try { - await classWithLambdaHandler.testing(inputRecord, dummyContext); + await classWithLambdaHandler.testing(inputRecord, context); } catch (e) { resultingError = e as Error; } @@ -183,7 +181,7 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = test('Then it will attempt to save the record to INPROGRESS', () => { expect(mockSaveInProgress).toBeCalledWith( inputRecord, - dummyContext.getRemainingTimeInMillis() + context.getRemainingTimeInMillis() ); }); @@ -214,13 +212,13 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = mockGetRecord.mockResolvedValue( new IdempotencyRecord(idempotencyOptions) ); - await classWithLambdaHandler.testing(inputRecord, dummyContext); + await classWithLambdaHandler.testing(inputRecord, context); }); test('Then it will attempt to save the record to INPROGRESS', () => { expect(mockSaveInProgress).toBeCalledWith( inputRecord, - dummyContext.getRemainingTimeInMillis() + context.getRemainingTimeInMillis() ); }); @@ -237,7 +235,7 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = class TestinClassWithLambdaHandlerWithConfig { @idempotent({ persistenceStore: new PersistenceLayerTestClass(), - config: new IdempotencyConfig({ lambdaContext: dummyContext }), + config: new IdempotencyConfig({ lambdaContext: context }), }) public testing(record: Record): string { functionalityToDecorate(record); @@ -261,7 +259,7 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = test('Then it will attempt to save the record to INPROGRESS', () => { expect(mockSaveInProgress).toBeCalledWith( inputRecord, - dummyContext.getRemainingTimeInMillis() + context.getRemainingTimeInMillis() ); }); @@ -276,7 +274,7 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = class TestingClassWithIdempotencyDisabled { @idempotent({ persistenceStore: new PersistenceLayerTestClass(), - config: new IdempotencyConfig({ lambdaContext: dummyContext }), + config: new IdempotencyConfig({ lambdaContext: context }), }) public testing( record: Record, @@ -289,7 +287,7 @@ describe('Given a class with a function to decorate', (classWithLambdaHandler = } const classWithoutIdempotencyDisabled = new TestingClassWithIdempotencyDisabled(); - await classWithoutIdempotencyDisabled.testing(inputRecord, dummyContext); + await classWithoutIdempotencyDisabled.testing(inputRecord, context); }); test('Then it will skip ipdemotency', async () => { diff --git a/packages/idempotency/tests/unit/makeHandlerIdempotent.test.ts b/packages/idempotency/tests/unit/makeHandlerIdempotent.test.ts index ae628dd121..a761a0f527 100644 --- a/packages/idempotency/tests/unit/makeHandlerIdempotent.test.ts +++ b/packages/idempotency/tests/unit/makeHandlerIdempotent.test.ts @@ -4,10 +4,7 @@ * @group unit/idempotency/makeHandlerIdempotent */ import { makeHandlerIdempotent } from '../../src/middleware'; -import { - ContextExamples as dummyContext, - Events as dummyEvent, -} from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { IdempotencyRecord } from '../../src/persistence'; import { IdempotencyInconsistentStateError, @@ -27,8 +24,10 @@ const remainingTImeInMillis = 1234; describe('Middleware: makeHandlerIdempotent', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext.helloworldContext; - const event = dummyEvent.Custom; + const event = { + foo: 'bar', + bar: 'baz', + }; beforeEach(() => { jest.clearAllMocks(); diff --git a/packages/idempotency/tests/unit/makeIdempotent.test.ts b/packages/idempotency/tests/unit/makeIdempotent.test.ts index da7b3ef194..d7737e16fd 100644 --- a/packages/idempotency/tests/unit/makeIdempotent.test.ts +++ b/packages/idempotency/tests/unit/makeIdempotent.test.ts @@ -11,10 +11,7 @@ import { IdempotencyPersistenceLayerError, } from '../../src/errors'; import { IdempotencyConfig } from '../../src'; -import { - ContextExamples as dummyContext, - Events as dummyEvent, -} from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { MAX_RETRIES, IdempotencyRecordStatus } from '../../src/constants'; import { PersistenceLayerTestClass } from '../helpers/idempotencyUtils'; import type { Context } from 'aws-lambda'; @@ -26,8 +23,10 @@ const remainingTImeInMillis = 1234; describe('Function: makeIdempotent', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext.helloworldContext; - const event = dummyEvent.Custom; + const event = { + foo: 'bar', + bar: 'baz', + }; beforeEach(() => { jest.clearAllMocks(); diff --git a/packages/idempotency/tests/unit/persistence/BasePersistenceLayer.test.ts b/packages/idempotency/tests/unit/persistence/BasePersistenceLayer.test.ts index 3224c0661b..6f78207d85 100644 --- a/packages/idempotency/tests/unit/persistence/BasePersistenceLayer.test.ts +++ b/packages/idempotency/tests/unit/persistence/BasePersistenceLayer.test.ts @@ -3,7 +3,7 @@ * * @group unit/idempotency/persistence/base */ -import { ContextExamples as dummyContext } from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import { IdempotencyConfig, IdempotencyRecordStatus } from '../../../src'; import { BasePersistenceLayer, @@ -24,7 +24,6 @@ jest.mock('node:crypto', () => ({ describe('Class: BasePersistenceLayer', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext.helloworldContext; class PersistenceLayerTestClass extends BasePersistenceLayer { public _deleteRecord = jest.fn(); diff --git a/packages/logger/tests/e2e/basicFeatures.middy.test.FunctionCode.ts b/packages/logger/tests/e2e/basicFeatures.middy.test.FunctionCode.ts index 9107bf5453..01c3b11804 100644 --- a/packages/logger/tests/e2e/basicFeatures.middy.test.FunctionCode.ts +++ b/packages/logger/tests/e2e/basicFeatures.middy.test.FunctionCode.ts @@ -1,6 +1,7 @@ -import { injectLambdaContext, Logger } from '../../src'; -import { Context, APIGatewayAuthorizerResult } from 'aws-lambda'; -import { TestEvent, TestOutput } from '../helpers/types'; +import { Logger } from '../../src/index.js'; +import { injectLambdaContext } from '../../src/middleware/middy.js'; +import type { Context, APIGatewayAuthorizerResult } from 'aws-lambda'; +import type { TestEvent, TestOutput } from '../helpers/types.js'; import middy from '@middy/core'; const PERSISTENT_KEY = process.env.PERSISTENT_KEY || 'persistentKey'; diff --git a/packages/logger/tests/e2e/basicFeatures.middy.test.ts b/packages/logger/tests/e2e/basicFeatures.middy.test.ts index 8a66abaac9..6ec5719206 100644 --- a/packages/logger/tests/e2e/basicFeatures.middy.test.ts +++ b/packages/logger/tests/e2e/basicFeatures.middy.test.ts @@ -10,7 +10,7 @@ import { } from '@aws-lambda-powertools/testing-utils'; import type { APIGatewayAuthorizerResult } from 'aws-lambda'; import { join } from 'node:path'; -import { LoggerTestNodejsFunction } from '../helpers/resources'; +import { LoggerTestNodejsFunction } from '../helpers/resources.js'; import { RESOURCE_NAME_PREFIX, SETUP_TIMEOUT, @@ -19,7 +19,7 @@ import { TEST_CASE_TIMEOUT, XRAY_TRACE_ID_REGEX, commonEnvironmentVars, -} from './constants'; +} from './constants.js'; describe(`Logger E2E tests, basic functionalities middy usage`, () => { const testStack = new TestStack({ diff --git a/packages/logger/tests/e2e/childLogger.manual.test.FunctionCode.ts b/packages/logger/tests/e2e/childLogger.manual.test.FunctionCode.ts index f2d32e36f0..82c2b3f0c2 100644 --- a/packages/logger/tests/e2e/childLogger.manual.test.FunctionCode.ts +++ b/packages/logger/tests/e2e/childLogger.manual.test.FunctionCode.ts @@ -1,7 +1,7 @@ -import { Logger } from '../../src'; -import { Context } from 'aws-lambda'; -import { LogLevel } from '../../src/types'; -import { TestEvent, TestOutput } from '../helpers/types'; +import { Logger } from '../../src/index.js'; +import type { Context } from 'aws-lambda'; +import type { LogLevel } from '../../src/types/index.js'; +import { TestEvent, TestOutput } from '../helpers/types.js'; const PERSISTENT_KEY = process.env.PERSISTENT_KEY || 'persistentKey'; const PERSISTENT_VALUE = process.env.ERSISTENT_VALUE || 'persistentValue'; diff --git a/packages/logger/tests/e2e/childLogger.manual.test.ts b/packages/logger/tests/e2e/childLogger.manual.test.ts index 454eab8a81..037b3ac81d 100644 --- a/packages/logger/tests/e2e/childLogger.manual.test.ts +++ b/packages/logger/tests/e2e/childLogger.manual.test.ts @@ -9,7 +9,7 @@ import { TestStack, } from '@aws-lambda-powertools/testing-utils'; import { join } from 'node:path'; -import { LoggerTestNodejsFunction } from '../helpers/resources'; +import { LoggerTestNodejsFunction } from '../helpers/resources.js'; import { commonEnvironmentVars, RESOURCE_NAME_PREFIX, @@ -17,7 +17,7 @@ import { STACK_OUTPUT_LOG_GROUP, TEARDOWN_TIMEOUT, TEST_CASE_TIMEOUT, -} from './constants'; +} from './constants.js'; describe(`Logger E2E tests, child logger`, () => { const testStack = new TestStack({ diff --git a/packages/logger/tests/e2e/logEventEnvVarSetting.middy.test.FunctionCode.ts b/packages/logger/tests/e2e/logEventEnvVarSetting.middy.test.FunctionCode.ts index 3f816ff4e1..2d10943d61 100644 --- a/packages/logger/tests/e2e/logEventEnvVarSetting.middy.test.FunctionCode.ts +++ b/packages/logger/tests/e2e/logEventEnvVarSetting.middy.test.FunctionCode.ts @@ -1,6 +1,7 @@ -import { injectLambdaContext, Logger } from '../../src'; -import { TestEvent, TestOutput } from '../helpers/types'; -import { Context } from 'aws-lambda'; +import { Logger } from '../../src/index.js'; +import { injectLambdaContext } from '../../src/middleware/middy.js'; +import type { TestEvent, TestOutput } from '../helpers/types.js'; +import type { Context } from 'aws-lambda'; import middy from '@middy/core'; const logger = new Logger(); diff --git a/packages/logger/tests/e2e/logEventEnvVarSetting.middy.test.ts b/packages/logger/tests/e2e/logEventEnvVarSetting.middy.test.ts index 5b87f0675f..902c41c09e 100644 --- a/packages/logger/tests/e2e/logEventEnvVarSetting.middy.test.ts +++ b/packages/logger/tests/e2e/logEventEnvVarSetting.middy.test.ts @@ -9,14 +9,14 @@ import { TestStack, } from '@aws-lambda-powertools/testing-utils'; import { join } from 'node:path'; -import { LoggerTestNodejsFunction } from '../helpers/resources'; +import { LoggerTestNodejsFunction } from '../helpers/resources.js'; import { RESOURCE_NAME_PREFIX, SETUP_TIMEOUT, STACK_OUTPUT_LOG_GROUP, TEARDOWN_TIMEOUT, TEST_CASE_TIMEOUT, -} from './constants'; +} from './constants.js'; describe(`Logger E2E tests, log event via env var setting with middy`, () => { const testStack = new TestStack({ diff --git a/packages/logger/tests/e2e/sampleRate.decorator.test.FunctionCode.ts b/packages/logger/tests/e2e/sampleRate.decorator.test.FunctionCode.ts index 32256a17ae..89c7e4833f 100644 --- a/packages/logger/tests/e2e/sampleRate.decorator.test.FunctionCode.ts +++ b/packages/logger/tests/e2e/sampleRate.decorator.test.FunctionCode.ts @@ -1,6 +1,6 @@ -import { Logger } from '../../src'; -import { TestEvent, TestOutput } from '../helpers/types'; -import { Context } from 'aws-lambda'; +import { Logger } from '../../src/index.js'; +import type { TestEvent, TestOutput } from '../helpers/types'; +import type { Context } from 'aws-lambda'; import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; const SAMPLE_RATE = parseFloat(process.env.SAMPLE_RATE || '0.1'); diff --git a/packages/logger/tests/e2e/sampleRate.decorator.test.ts b/packages/logger/tests/e2e/sampleRate.decorator.test.ts index 67c803dd58..e87f661a56 100644 --- a/packages/logger/tests/e2e/sampleRate.decorator.test.ts +++ b/packages/logger/tests/e2e/sampleRate.decorator.test.ts @@ -10,14 +10,14 @@ import { } from '@aws-lambda-powertools/testing-utils'; import { randomUUID } from 'node:crypto'; import { join } from 'node:path'; -import { LoggerTestNodejsFunction } from '../helpers/resources'; +import { LoggerTestNodejsFunction } from '../helpers/resources.js'; import { RESOURCE_NAME_PREFIX, SETUP_TIMEOUT, STACK_OUTPUT_LOG_GROUP, TEARDOWN_TIMEOUT, TEST_CASE_TIMEOUT, -} from './constants'; +} from './constants.js'; describe(`Logger E2E tests, sample rate and injectLambdaContext()`, () => { const testStack = new TestStack({ diff --git a/packages/logger/tests/helpers/resources.ts b/packages/logger/tests/helpers/resources.ts index 95e7a34074..deef695c0a 100644 --- a/packages/logger/tests/helpers/resources.ts +++ b/packages/logger/tests/helpers/resources.ts @@ -1,10 +1,10 @@ -import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import type { TestStack } from '@aws-lambda-powertools/testing-utils'; import { CfnOutput } from 'aws-cdk-lib'; import type { - TestNodejsFunctionProps, ExtraTestProps, -} from '@aws-lambda-powertools/testing-utils'; + TestNodejsFunctionProps, +} from '@aws-lambda-powertools/testing-utils/types'; import { commonEnvironmentVars } from '../e2e/constants'; interface LoggerExtraTestProps extends ExtraTestProps { diff --git a/packages/logger/tests/unit/Logger.test.ts b/packages/logger/tests/unit/Logger.test.ts index 1bcbc0fe4b..f1a5474de0 100644 --- a/packages/logger/tests/unit/Logger.test.ts +++ b/packages/logger/tests/unit/Logger.test.ts @@ -3,10 +3,7 @@ * * @group unit/logger/all */ -import { - ContextExamples as dummyContext, - Events as dummyEvent, -} from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; import { Logger, LogFormatter } from '../../src/index.js'; import { ConfigServiceInterface } from '../../src/config/ConfigServiceInterface.js'; @@ -32,8 +29,10 @@ const getConsoleMethod = ( describe('Class: Logger', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext.helloworldContext; - const event = dummyEvent.Custom.CustomEvent; + const event = { + foo: 'bar', + bar: 'baz', + }; const logLevelThresholds: LogLevelThresholds = { DEBUG: 8, INFO: 12, @@ -1744,9 +1743,8 @@ describe('Class: Logger', () => { timestamp: '2016-06-20T12:08:10.000Z', xray_trace_id: '1-5759e988-bd862e3fe1be46a994272793', event: { - key1: 'value1', - key2: 'value2', - key3: 'value3', + foo: 'bar', + bar: 'baz', }, }) ); @@ -1794,9 +1792,8 @@ describe('Class: Logger', () => { timestamp: '2016-06-20T12:08:10.000Z', xray_trace_id: '1-5759e988-bd862e3fe1be46a994272793', event: { - key1: 'value1', - key2: 'value2', - key3: 'value3', + foo: 'bar', + bar: 'baz', }, }) ); diff --git a/packages/logger/tests/unit/formatter/PowertoolsLogFormatter.test.ts b/packages/logger/tests/unit/formatter/PowertoolsLogFormatter.test.ts index 1d66414797..b7d5e3334a 100644 --- a/packages/logger/tests/unit/formatter/PowertoolsLogFormatter.test.ts +++ b/packages/logger/tests/unit/formatter/PowertoolsLogFormatter.test.ts @@ -3,7 +3,7 @@ * * @group unit/logger/all */ -import { AssertionError, strictEqual } from 'assert'; +import { AssertionError, strictEqual } from 'node:assert'; import { PowertoolsLogFormatter } from '../../../src/formatter/PowertoolsLogFormatter.js'; import { LogItem } from '../../../src/index.js'; import { UnformattedAttributes } from '../../../src/types/Logger.js'; diff --git a/packages/logger/tests/unit/middleware/middy.test.ts b/packages/logger/tests/unit/middleware/middy.test.ts index c5c32eab4a..cea1597f8e 100644 --- a/packages/logger/tests/unit/middleware/middy.test.ts +++ b/packages/logger/tests/unit/middleware/middy.test.ts @@ -3,11 +3,8 @@ * * @group unit/logger/all */ -import { - ContextExamples as dummyContext, - Events as dummyEvent, - cleanupMiddlewares, -} from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; +import { cleanupMiddlewares } from '@aws-lambda-powertools/commons'; import { ConfigServiceInterface } from '../../../src/config/ConfigServiceInterface.js'; import { EnvironmentVariablesService } from '../../../src/config/EnvironmentVariablesService.js'; import { injectLambdaContext } from '../../../src/middleware/middy.js'; @@ -15,15 +12,17 @@ import { Logger } from './../../../src/Logger.js'; import middy from '@middy/core'; import { PowertoolsLogFormatter } from '../../../src/formatter/PowertoolsLogFormatter.js'; import { Console } from 'node:console'; -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; const mockDate = new Date(1466424490000); const dateSpy = jest.spyOn(global, 'Date').mockImplementation(() => mockDate); describe('Middy middleware', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext.helloworldContext; - const event = dummyEvent.Custom.CustomEvent; + const event = { + foo: 'bar', + bar: 'baz', + }; beforeEach(() => { jest.resetModules(); @@ -222,9 +221,7 @@ describe('Middy middleware', () => { }; }; const handler = middy( - ( - event: typeof dummyEvent.Custom.CustomEvent & { idx: number } - ): void => { + (event: { foo: string; bar: string } & { idx: number }): void => { // Add a key only at the first invocation, so we can check that it's cleared if (event.idx === 0) { logger.appendKeys({ @@ -287,9 +284,8 @@ describe('Middy middleware', () => { timestamp: '2016-06-20T12:08:10.000Z', xray_trace_id: '1-5759e988-bd862e3fe1be46a994272793', event: { - key1: 'value1', - key2: 'value2', - key3: 'value3', + foo: 'bar', + bar: 'baz', }, }) ); @@ -354,9 +350,8 @@ describe('Middy middleware', () => { timestamp: '2016-06-20T12:08:10.000Z', xray_trace_id: '1-5759e988-bd862e3fe1be46a994272793', event: { - key1: 'value1', - key2: 'value2', - key3: 'value3', + foo: 'bar', + bar: 'baz', }, }) ); @@ -393,9 +388,8 @@ describe('Middy middleware', () => { timestamp: '2016-06-20T12:08:10.000Z', xray_trace_id: '1-5759e988-bd862e3fe1be46a994272793', event: { - key1: 'value1', - key2: 'value2', - key3: 'value3', + foo: 'bar', + bar: 'baz', }, }) ); diff --git a/packages/metrics/tests/e2e/basicFeatures.decorator.test.functionCode.ts b/packages/metrics/tests/e2e/basicFeatures.decorator.test.functionCode.ts index 9016a01cbe..db74836afd 100644 --- a/packages/metrics/tests/e2e/basicFeatures.decorator.test.functionCode.ts +++ b/packages/metrics/tests/e2e/basicFeatures.decorator.test.functionCode.ts @@ -1,6 +1,6 @@ -import { Metrics, MetricUnits } from '../../src'; +import { Metrics, MetricUnits } from '../../src/index.js'; import type { Context } from 'aws-lambda'; -import type { LambdaInterface } from '@aws-lambda-powertools/commons'; +import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; const namespace = process.env.EXPECTED_NAMESPACE ?? 'CdkExample'; const serviceName = diff --git a/packages/metrics/tests/e2e/basicFeatures.decorators.test.ts b/packages/metrics/tests/e2e/basicFeatures.decorators.test.ts index 332636210e..bdaa6b750d 100644 --- a/packages/metrics/tests/e2e/basicFeatures.decorators.test.ts +++ b/packages/metrics/tests/e2e/basicFeatures.decorators.test.ts @@ -12,8 +12,8 @@ import { GetMetricStatisticsCommand, } from '@aws-sdk/client-cloudwatch'; import { join } from 'node:path'; -import { getMetrics } from '../helpers/metricsUtils'; -import { MetricsTestNodejsFunction } from '../helpers/resources'; +import { getMetrics } from '../helpers/metricsUtils.js'; +import { MetricsTestNodejsFunction } from '../helpers/resources.js'; import { commonEnvironmentVars, ONE_MINUTE, @@ -21,7 +21,7 @@ import { SETUP_TIMEOUT, TEARDOWN_TIMEOUT, TEST_CASE_TIMEOUT, -} from './constants'; +} from './constants.js'; describe(`Metrics E2E tests, basic features decorator usage`, () => { const testStack = new TestStack({ diff --git a/packages/metrics/tests/e2e/basicFeatures.manual.test.functionCode.ts b/packages/metrics/tests/e2e/basicFeatures.manual.test.functionCode.ts index 67ea224083..b4996dcf32 100644 --- a/packages/metrics/tests/e2e/basicFeatures.manual.test.functionCode.ts +++ b/packages/metrics/tests/e2e/basicFeatures.manual.test.functionCode.ts @@ -1,4 +1,4 @@ -import { Metrics, MetricUnits } from '../../src'; +import { Metrics, MetricUnits } from '../../src/index.js'; import type { Context } from 'aws-lambda'; const namespace = process.env.EXPECTED_NAMESPACE ?? 'CdkExample'; diff --git a/packages/metrics/tests/e2e/basicFeatures.manual.test.ts b/packages/metrics/tests/e2e/basicFeatures.manual.test.ts index b22861ab16..6cb286c708 100644 --- a/packages/metrics/tests/e2e/basicFeatures.manual.test.ts +++ b/packages/metrics/tests/e2e/basicFeatures.manual.test.ts @@ -12,8 +12,8 @@ import { GetMetricStatisticsCommand, } from '@aws-sdk/client-cloudwatch'; import { join } from 'node:path'; -import { getMetrics } from '../helpers/metricsUtils'; -import { MetricsTestNodejsFunction } from '../helpers/resources'; +import { getMetrics } from '../helpers/metricsUtils.js'; +import { MetricsTestNodejsFunction } from '../helpers/resources.js'; import { commonEnvironmentVars, ONE_MINUTE, @@ -21,7 +21,7 @@ import { SETUP_TIMEOUT, TEARDOWN_TIMEOUT, TEST_CASE_TIMEOUT, -} from './constants'; +} from './constants.js'; describe(`Metrics E2E tests, manual usage`, () => { const testStack = new TestStack({ diff --git a/packages/metrics/tests/e2e/constants.ts b/packages/metrics/tests/e2e/constants.ts index bb6068f56d..0f05997a51 100644 --- a/packages/metrics/tests/e2e/constants.ts +++ b/packages/metrics/tests/e2e/constants.ts @@ -1,5 +1,5 @@ import { randomUUID } from 'node:crypto'; -import { MetricUnits } from '../../src'; +import { MetricUnits } from '../../src/index.js'; const RESOURCE_NAME_PREFIX = 'Metrics'; const ONE_MINUTE = 60 * 1000; diff --git a/packages/metrics/tests/helpers/resources.ts b/packages/metrics/tests/helpers/resources.ts index ebb111984b..f071d2c8b2 100644 --- a/packages/metrics/tests/helpers/resources.ts +++ b/packages/metrics/tests/helpers/resources.ts @@ -1,9 +1,9 @@ +import type { TestStack } from '@aws-lambda-powertools/testing-utils'; import type { ExtraTestProps, TestNodejsFunctionProps, - TestStack, -} from '@aws-lambda-powertools/testing-utils'; -import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils'; +} from '@aws-lambda-powertools/testing-utils/types'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { commonEnvironmentVars } from '../e2e/constants'; class MetricsTestNodejsFunction extends TestNodejsFunction { diff --git a/packages/metrics/tests/unit/Metrics.test.ts b/packages/metrics/tests/unit/Metrics.test.ts index 286f618d65..e8077f78e7 100644 --- a/packages/metrics/tests/unit/Metrics.test.ts +++ b/packages/metrics/tests/unit/Metrics.test.ts @@ -3,13 +3,10 @@ * * @group unit/metrics/class */ -import { - ContextExamples as dummyContext, - Events as dummyEvent, -} from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; -import { MetricResolution, MetricUnits, Metrics } from '../../src/'; -import { Context, Handler } from 'aws-lambda'; +import { MetricResolution, MetricUnits, Metrics } from '../../src'; +import type { Context, Handler } from 'aws-lambda'; import { Dimensions, EmfOutput, MetricsOptions } from '../../src/types'; import { COLD_START_METRIC, @@ -36,8 +33,10 @@ interface LooseObject { describe('Class: Metrics', () => { const ENVIRONMENT_VARIABLES = process.env; const TEST_NAMESPACE = 'test'; - const context = dummyContext.helloworldContext; - const event = dummyEvent.Custom.CustomEvent; + const event = { + foo: 'bar', + bar: 'baz', + }; beforeEach(() => { jest.clearAllMocks(); diff --git a/packages/metrics/tests/unit/middleware/middy.test.ts b/packages/metrics/tests/unit/middleware/middy.test.ts index 1c5b83e6f5..5363566dfd 100644 --- a/packages/metrics/tests/unit/middleware/middy.test.ts +++ b/packages/metrics/tests/unit/middleware/middy.test.ts @@ -11,11 +11,8 @@ import { } from '../../../../metrics/src'; import middy from '@middy/core'; import { ExtraOptions } from '../../../src/types'; -import { - cleanupMiddlewares, - ContextExamples as dummyContext, - Events as dummyEvent, -} from '@aws-lambda-powertools/commons'; +import { cleanupMiddlewares } from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; const consoleSpy = jest.spyOn(console, 'log').mockImplementation(); const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(); @@ -28,6 +25,11 @@ describe('Middy middleware', () => { jest.clearAllMocks(); }); + const event = { + foo: 'bar', + bar: 'baz', + }; + describe('throwOnEmptyMetrics', () => { test('should throw on empty metrics if set to true', async () => { // Prepare @@ -45,9 +47,7 @@ describe('Middy middleware', () => { ); try { - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); + await handler(event, context, () => console.log('Lambda invoked!')); } catch (e) { expect((e).message).toBe( 'The number of metrics recorded must be higher than zero' @@ -71,9 +71,7 @@ describe('Middy middleware', () => { ); try { - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); + await handler(event, context, () => console.log('Lambda invoked!')); } catch (e) { fail(`Should not throw but got the following Error: ${e}`); } @@ -91,9 +89,7 @@ describe('Middy middleware', () => { const handler = middy(lambdaHandler).use(logMetrics(metrics)); // Act & Assess - await expect( - handler(dummyEvent, dummyContext.helloworldContext) - ).resolves.not.toThrowError(); + await expect(handler(event, context)).resolves.not.toThrowError(); expect(consoleWarnSpy).toBeCalledTimes(1); expect(consoleWarnSpy).toBeCalledWith( 'No application metrics to publish. The cold-start metric may be published if enabled. If application metrics should never be empty, consider using `throwOnEmptyMetrics`' @@ -117,12 +113,8 @@ describe('Middy middleware', () => { logMetrics(metrics, { captureColdStartMetric: true }) ); - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked! again') - ); + await handler(event, context, () => console.log('Lambda invoked!')); + await handler(event, context, () => console.log('Lambda invoked! again')); const loggedData = [ JSON.parse(consoleSpy.mock.calls[0][0]), JSON.parse(consoleSpy.mock.calls[1][0]), @@ -154,12 +146,8 @@ describe('Middy middleware', () => { logMetrics(metrics, { captureColdStartMetric: false }) ); - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked! again') - ); + await handler(event, context, () => console.log('Lambda invoked!')); + await handler(event, context, () => console.log('Lambda invoked! again')); const loggedData = [ JSON.parse(consoleSpy.mock.calls[0][0]), JSON.parse(consoleSpy.mock.calls[1][0]), @@ -181,12 +169,8 @@ describe('Middy middleware', () => { const handler = middy(lambdaHandler).use(logMetrics(metrics)); - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked! again') - ); + await handler(event, context, () => console.log('Lambda invoked!')); + await handler(event, context, () => console.log('Lambda invoked! again')); const loggedData = [ JSON.parse(consoleSpy.mock.calls[0][0]), JSON.parse(consoleSpy.mock.calls[1][0]), @@ -212,9 +196,7 @@ describe('Middy middleware', () => { const handler = middy(lambdaHandler).use(logMetrics(metrics)); // Act - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); + await handler(event, context, () => console.log('Lambda invoked!')); // Assess expect(console.log).toHaveBeenNthCalledWith( @@ -256,9 +238,7 @@ describe('Middy middleware', () => { ); // Act - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); + await handler(event, context, () => console.log('Lambda invoked!')); // Assess expect(console.log).toHaveBeenNthCalledWith( @@ -318,9 +298,7 @@ describe('Middy middleware', () => { const handler = middy(lambdaHandler).use(logMetrics(metrics)); // Act - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); + await handler(event, context, () => console.log('Lambda invoked!')); // Assess expect(console.log).toHaveBeenNthCalledWith( @@ -360,9 +338,7 @@ describe('Middy middleware', () => { ); // Act - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); + await handler(event, context, () => console.log('Lambda invoked!')); // Assess expect(console.log).toHaveBeenNthCalledWith( @@ -413,7 +389,7 @@ describe('Middy middleware', () => { }; }; const handler = middy( - (_event: typeof dummyEvent & { idx: number }): void => { + (_event: { foo: string; bar: string } & { idx: number }): void => { metrics.addMetric('successfulBooking', MetricUnits.Count, 1); } ) @@ -421,8 +397,8 @@ describe('Middy middleware', () => { .use(myCustomMiddleware()); // Act - await handler({ ...dummyEvent, idx: 0 }, dummyContext.helloworldContext); - await handler({ ...dummyEvent, idx: 1 }, dummyContext.helloworldContext); + await handler({ ...event, idx: 0 }, context); + await handler({ ...event, idx: 1 }, context); // Assess expect(publishStoredMetricsSpy).toBeCalledTimes(2); @@ -448,9 +424,7 @@ describe('Middy middleware', () => { const handler = middy(lambdaHandler).use(logMetrics(metrics)); // Act - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); + await handler(event, context, () => console.log('Lambda invoked!')); // Assess expect(console.log).toHaveBeenCalledWith( @@ -495,9 +469,7 @@ describe('Middy middleware', () => { const handler = middy(lambdaHandler).use(logMetrics(metrics)); // Act - await handler(dummyEvent, dummyContext.helloworldContext, () => - console.log('Lambda invoked!') - ); + await handler(event, context, () => console.log('Lambda invoked!')); // Assess expect(console.log).toHaveBeenCalledWith( diff --git a/packages/parameters/package.json b/packages/parameters/package.json index 94fc4e5cba..9089020fca 100644 --- a/packages/parameters/package.json +++ b/packages/parameters/package.json @@ -155,6 +155,7 @@ "nodejs" ], "devDependencies": { + "@aws-lambda-powertools/testing-utils": "file:../testing", "@aws-sdk/client-appconfigdata": "^3.413.0", "@aws-sdk/client-dynamodb": "^3.413.0", "@aws-sdk/client-secrets-manager": "^3.413.0", @@ -195,4 +196,4 @@ "optional": true } } -} \ No newline at end of file +} diff --git a/packages/parameters/tests/e2e/appConfigProvider.class.test.ts b/packages/parameters/tests/e2e/appConfigProvider.class.test.ts index 35c150840c..69bb52ae17 100644 --- a/packages/parameters/tests/e2e/appConfigProvider.class.test.ts +++ b/packages/parameters/tests/e2e/appConfigProvider.class.test.ts @@ -6,9 +6,9 @@ import { invokeFunctionOnce, TestInvocationLogs, - TestNodejsFunction, TestStack, } from '@aws-lambda-powertools/testing-utils'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { toBase64 } from '@aws-sdk/util-base64-node'; import { join } from 'node:path'; import { TestAppConfigWithProfiles } from '../helpers/resources.js'; diff --git a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts index 391d215f76..8f1748246a 100644 --- a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts +++ b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts @@ -6,9 +6,9 @@ import { invokeFunctionOnce, TestInvocationLogs, - TestNodejsFunction, TestStack, } from '@aws-lambda-powertools/testing-utils'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { AttributeType } from 'aws-cdk-lib/aws-dynamodb'; import { join } from 'node:path'; import { TestDynamodbTableWithItems } from '../helpers/resources.js'; diff --git a/packages/parameters/tests/e2e/secretsProvider.class.test.ts b/packages/parameters/tests/e2e/secretsProvider.class.test.ts index a5f0c539b3..9a8bffa9b7 100644 --- a/packages/parameters/tests/e2e/secretsProvider.class.test.ts +++ b/packages/parameters/tests/e2e/secretsProvider.class.test.ts @@ -6,9 +6,9 @@ import { invokeFunctionOnce, TestInvocationLogs, - TestNodejsFunction, TestStack, } from '@aws-lambda-powertools/testing-utils'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { SecretValue } from 'aws-cdk-lib'; import { join } from 'node:path'; import { TestSecret } from '../helpers/resources.js'; diff --git a/packages/parameters/tests/e2e/ssmProvider.class.test.ts b/packages/parameters/tests/e2e/ssmProvider.class.test.ts index 9af29e8315..f6fb8ed858 100644 --- a/packages/parameters/tests/e2e/ssmProvider.class.test.ts +++ b/packages/parameters/tests/e2e/ssmProvider.class.test.ts @@ -6,9 +6,9 @@ import { invokeFunctionOnce, TestInvocationLogs, - TestNodejsFunction, TestStack, } from '@aws-lambda-powertools/testing-utils'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { join } from 'node:path'; import { TestSecureStringParameter, diff --git a/packages/parameters/tests/helpers/resources.ts b/packages/parameters/tests/helpers/resources.ts index 0be54d8db4..424065961c 100644 --- a/packages/parameters/tests/helpers/resources.ts +++ b/packages/parameters/tests/helpers/resources.ts @@ -1,15 +1,15 @@ import type { ExtraTestProps, TestDynamodbTableProps, - TestStack, -} from '@aws-lambda-powertools/testing-utils'; +} from '@aws-lambda-powertools/testing-utils/types'; import { concatenateResourceName, getRuntimeKey, getArchitectureKey, - TestDynamodbTable, - TestNodejsFunction, + type TestStack, } from '@aws-lambda-powertools/testing-utils'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; +import { TestDynamodbTable } from '@aws-lambda-powertools/testing-utils/resources/dynamodb'; import { marshall } from '@aws-sdk/util-dynamodb'; import { CfnOutput, Stack } from 'aws-cdk-lib'; import { diff --git a/packages/testing/jest.config.js b/packages/testing/jest.config.cjs similarity index 93% rename from packages/testing/jest.config.js rename to packages/testing/jest.config.cjs index 6d6c2fecf2..f13ab92dfd 100644 --- a/packages/testing/jest.config.js +++ b/packages/testing/jest.config.cjs @@ -5,6 +5,9 @@ module.exports = { }, runner: 'groups', preset: 'ts-jest', + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, transform: { '^.+\\.ts?$': 'ts-jest', }, diff --git a/packages/testing/package.json b/packages/testing/package.json index d73426de50..7c28586b3a 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -12,11 +12,13 @@ "test:unit": "jest --group=unit --detectOpenHandles --verbose", "test:e2e": "echo 'Not implemented'", "watch": "jest --watch", - "build": "tsc --build --force", + "build:cjs": "tsc --build --force && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", + "build:esm": "tsc --project tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", + "build": "npm run build:esm & npm run build:cjs", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", - "prepack": "node ../../.github/scripts/release_patch_package_json.js ." + "prepack": "rimraf ./lib/*.tsbuildinfo && node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { "*.{js,ts}": "npm run lint-fix" @@ -28,8 +30,57 @@ "files": [ "lib" ], - "main": "./lib/index.js", - "types": "./lib/index.d.ts", + "type": "module", + "exports": { + ".": { + "require": { + "types": "./lib/cjs/index.d.ts", + "default": "./lib/cjs/index.js" + }, + "import": { + "types": "./lib/esm/index.d.ts", + "default": "./lib/esm/index.js" + } + }, + "./resources/lambda": { + "import": "./lib/esm/resources/TestNodejsFunction.js", + "require": "./lib/cjs/resources/TestNodejsFunction.js" + }, + "./resources/dynamodb": { + "import": "./lib/esm/resources/TestDynamodbTable.js", + "require": "./lib/cjs/resources/TestDynamodbTable.js" + }, + "./context": { + "import": "./lib/esm/context.js", + "require": "./lib/cjs/context.js" + }, + "./types": { + "import": "./lib/esm/types.js", + "require": "./lib/cjs/types.js" + } + }, + "typesVersions": { + "*": { + "resources/lambda": [ + "lib/cjs/resources/TestNodejsFunction.d.ts", + "lib/esm/resources/TestNodejsFunction.d.ts" + ], + "resources/dynamodb": [ + "lib/cjs/resources/TestDynamodbTable.d.ts", + "lib/esm/resources/TestDynamodbTable.d.ts" + ], + "types": [ + "lib/cjs/types.d.ts", + "lib/esm/types.d.ts" + ], + "context": [ + "lib/cjs/context.d.ts", + "lib/esm/context.d.ts" + ] + } + }, + "types": "./lib/cjs/index.d.ts", + "main": "./lib/cjs/index.js", "keywords": [ "aws", "lambda", diff --git a/packages/testing/src/TestInvocationLogs.ts b/packages/testing/src/TestInvocationLogs.ts index fa396c98eb..8c37d73a56 100644 --- a/packages/testing/src/TestInvocationLogs.ts +++ b/packages/testing/src/TestInvocationLogs.ts @@ -1,26 +1,8 @@ -/** - * Log level. used for filtering the log - */ -const Level = { - DEBUG: 'DEBUG', - INFO: 'INFO', - WARN: 'WARN', - ERROR: 'ERROR', -} as const; - -type ErrorField = { - name: string; - message: string; - stack: string; -}; - -type FunctionLog = { - level: keyof typeof Level; - error: ErrorField; -} & { [key: string]: unknown }; +import { LogLevel } from './constants.js'; +import type { FunctionLog } from './types.js'; class TestInvocationLogs { - public static LEVEL = Level; + public static LEVEL = LogLevel; /** * Array of logs from invocation. @@ -51,7 +33,7 @@ class TestInvocationLogs { */ public doesAnyFunctionLogsContains( text: string, - levelToFilter?: keyof typeof Level + levelToFilter?: keyof typeof LogLevel ): boolean { const filteredLogs = this.getFunctionLogs(levelToFilter).filter((log) => log.includes(text) @@ -81,10 +63,10 @@ class TestInvocationLogs { * Return only logs from function, exclude START, END, REPORT, * and X-Ray log generated by the Lambda service. * - * @param {typeof Level} [levelToFilter] - Level to filter the logs + * @param {typeof LogLevel} [levelToFilter] - Level to filter the logs * @returns Array of function logs, filtered by level if provided */ - public getFunctionLogs(levelToFilter?: keyof typeof Level): string[] { + public getFunctionLogs(levelToFilter?: keyof typeof LogLevel): string[] { const startLogIndex = TestInvocationLogs.getStartLogIndex(this.logs); const endLogIndex = TestInvocationLogs.getEndLogIndex(this.logs); let filteredLogs = this.logs.slice(startLogIndex + 1, endLogIndex); @@ -97,7 +79,9 @@ class TestInvocationLogs { return parsedLog.level == levelToFilter; } catch (error) { // If log is not from structured logging : such as metrics one. - return (log.split('\t')[2] as keyof typeof Level) === levelToFilter; + return ( + (log.split('\t')[2] as keyof typeof LogLevel) === levelToFilter + ); } }); } diff --git a/packages/testing/src/TestStack.ts b/packages/testing/src/TestStack.ts index 952f00a5a4..3e5d32da20 100644 --- a/packages/testing/src/TestStack.ts +++ b/packages/testing/src/TestStack.ts @@ -4,35 +4,8 @@ import { readFile } from 'node:fs/promises'; import { App, Stack } from 'aws-cdk-lib'; import { AwsCdkCli, RequireApproval } from '@aws-cdk/cli-lib-alpha'; import type { ICloudAssemblyDirectoryProducer } from '@aws-cdk/cli-lib-alpha'; -import { generateTestUniqueName } from './helpers'; - -type StackNameProps = { - /** - * Prefix for the stack name. - */ - stackNamePrefix: string; - /** - * Name of the test. - */ - testName: string; -}; - -interface TestStackProps { - /** - * Name of the test stack. - */ - stackNameProps: StackNameProps; - /** - * Reference to the AWS CDK App object. - * @default new App() - */ - app?: App; - /** - * Reference to the AWS CDK Stack object. - * @default new Stack(this.app, stackName) - */ - stack?: Stack; -} +import { generateTestUniqueName } from './helpers.js'; +import type { TestStackProps } from './types.js'; /** * Test stack that can be deployed to the selected environment. diff --git a/packages/testing/src/constants.ts b/packages/testing/src/constants.ts index 4c4f8cb511..66b7bb2466 100644 --- a/packages/testing/src/constants.ts +++ b/packages/testing/src/constants.ts @@ -26,9 +26,20 @@ const TEST_ARCHITECTURES = { arm64: Architecture.ARM_64, } as const; +/** + * Log level. used for filtering the log + */ +const LogLevel = { + DEBUG: 'DEBUG', + INFO: 'INFO', + WARN: 'WARN', + ERROR: 'ERROR', +} as const; + export { TEST_RUNTIMES, defaultRuntime, TEST_ARCHITECTURES, defaultArchitecture, + LogLevel, }; diff --git a/packages/commons/src/samples/resources/contexts/hello-world.ts b/packages/testing/src/context.ts similarity index 89% rename from packages/commons/src/samples/resources/contexts/hello-world.ts rename to packages/testing/src/context.ts index 2dccd0cc8b..59ebe833d8 100644 --- a/packages/commons/src/samples/resources/contexts/hello-world.ts +++ b/packages/testing/src/context.ts @@ -1,6 +1,6 @@ import type { Context } from 'aws-lambda'; -const helloworldContext: Context = { +export default { callbackWaitsForEmptyEventLoop: true, functionVersion: '$LATEST', functionName: 'foo-bar-function', @@ -14,6 +14,4 @@ const helloworldContext: Context = { done: () => console.log('Done!'), fail: () => console.log('Failed!'), succeed: () => console.log('Succeeded!'), -}; - -export { helloworldContext }; +} as const as Context; diff --git a/packages/testing/src/helpers.ts b/packages/testing/src/helpers.ts index ab1a0222e5..10d584d242 100644 --- a/packages/testing/src/helpers.ts +++ b/packages/testing/src/helpers.ts @@ -4,7 +4,7 @@ import { defaultRuntime, TEST_ARCHITECTURES, defaultArchitecture, -} from './constants'; +} from './constants.js'; const isValidRuntimeKey = ( runtime: string diff --git a/packages/testing/src/index.ts b/packages/testing/src/index.ts index 7c8276c774..89341279d2 100644 --- a/packages/testing/src/index.ts +++ b/packages/testing/src/index.ts @@ -1,6 +1,18 @@ -export * from './TestStack'; -export * from './constants'; -export * from './helpers'; -export * from './resources'; -export * from './invokeTestFunction'; -export * from './TestInvocationLogs'; +export { TestStack } from './TestStack.js'; +export { + TEST_RUNTIMES, + defaultRuntime, + TEST_ARCHITECTURES, + defaultArchitecture, + LogLevel, +} from './constants.js'; +export { + isValidRuntimeKey, + getRuntimeKey, + generateTestUniqueName, + concatenateResourceName, + findAndGetStackOutputValue, + getArchitectureKey, +} from './helpers.js'; +export { invokeFunction, invokeFunctionOnce } from './invokeTestFunction.js'; +export { TestInvocationLogs } from './TestInvocationLogs.js'; diff --git a/packages/testing/src/invokeTestFunction.ts b/packages/testing/src/invokeTestFunction.ts index 4b333d756d..8ff4099109 100644 --- a/packages/testing/src/invokeTestFunction.ts +++ b/packages/testing/src/invokeTestFunction.ts @@ -1,13 +1,7 @@ import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda'; import { fromUtf8 } from '@smithy/util-utf8'; -import { TestInvocationLogs } from './TestInvocationLogs'; - -type InvokeTestFunctionOptions = { - functionName: string; - times?: number; - invocationMode?: 'PARALLEL' | 'SEQUENTIAL'; - payload?: Record | Array>; -}; +import { TestInvocationLogs } from './TestInvocationLogs.js'; +import type { InvokeTestFunctionOptions } from './types.js'; const lambdaClient = new LambdaClient({}); diff --git a/packages/testing/src/resources/TestDynamodbTable.ts b/packages/testing/src/resources/TestDynamodbTable.ts index 2aa663639a..3717f54ad1 100644 --- a/packages/testing/src/resources/TestDynamodbTable.ts +++ b/packages/testing/src/resources/TestDynamodbTable.ts @@ -1,9 +1,9 @@ import { CfnOutput, RemovalPolicy } from 'aws-cdk-lib'; import { AttributeType, BillingMode, Table } from 'aws-cdk-lib/aws-dynamodb'; import { randomUUID } from 'node:crypto'; -import { concatenateResourceName } from '../helpers'; -import type { TestStack } from '../TestStack'; -import type { TestDynamodbTableProps, ExtraTestProps } from './types'; +import { concatenateResourceName } from '../helpers.js'; +import type { TestStack } from '../TestStack.js'; +import type { TestDynamodbTableProps, ExtraTestProps } from '../types.js'; /** * A DynamoDB Table that can be used in tests. @@ -36,4 +36,4 @@ class TestDynamodbTable extends Table { } } -export { TestDynamodbTable, TestDynamodbTableProps }; +export { TestDynamodbTable }; diff --git a/packages/testing/src/resources/TestNodejsFunction.ts b/packages/testing/src/resources/TestNodejsFunction.ts index 8ee0ed2f6b..5be3597caa 100644 --- a/packages/testing/src/resources/TestNodejsFunction.ts +++ b/packages/testing/src/resources/TestNodejsFunction.ts @@ -3,14 +3,14 @@ import { Tracing } from 'aws-cdk-lib/aws-lambda'; import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'; import { RetentionDays } from 'aws-cdk-lib/aws-logs'; import { randomUUID } from 'node:crypto'; -import { TEST_RUNTIMES, TEST_ARCHITECTURES } from '../constants'; +import { TEST_RUNTIMES, TEST_ARCHITECTURES } from '../constants.js'; import { concatenateResourceName, getRuntimeKey, getArchitectureKey, -} from '../helpers'; -import type { TestStack } from '../TestStack'; -import type { ExtraTestProps, TestNodejsFunctionProps } from './types'; +} from '../helpers.js'; +import type { TestStack } from '../TestStack.js'; +import type { ExtraTestProps, TestNodejsFunctionProps } from '../types.js'; /** * A NodejsFunction that can be used in tests. @@ -43,4 +43,4 @@ class TestNodejsFunction extends NodejsFunction { } } -export { ExtraTestProps, TestNodejsFunction, TestNodejsFunctionProps }; +export { TestNodejsFunction }; diff --git a/packages/testing/src/resources/index.ts b/packages/testing/src/resources/index.ts deleted file mode 100644 index ce4b5bbc26..0000000000 --- a/packages/testing/src/resources/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './TestNodejsFunction'; -export * from './TestDynamodbTable'; diff --git a/packages/testing/src/resources/types.ts b/packages/testing/src/resources/types.ts deleted file mode 100644 index 5596a08f31..0000000000 --- a/packages/testing/src/resources/types.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { TableProps, AttributeType } from 'aws-cdk-lib/aws-dynamodb'; -import type { NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs'; - -interface ExtraTestProps { - /** - * The suffix to be added to the resource name. - * - * For example, if the resource name is `fn-12345` and the suffix is `BasicFeatures`, - * the output will be `fn-12345-BasicFeatures`. - * - * Note that the maximum length of the name is 64 characters, so the suffix might be truncated. - */ - nameSuffix: string; -} - -type TestDynamodbTableProps = Omit< - TableProps, - 'removalPolicy' | 'tableName' | 'billingMode' | 'partitionKey' -> & { - partitionKey?: { - name: string; - type: AttributeType; - }; -}; - -type TestNodejsFunctionProps = Omit< - NodejsFunctionProps, - 'logRetention' | 'runtime' | 'functionName' ->; - -export { ExtraTestProps, TestDynamodbTableProps, TestNodejsFunctionProps }; diff --git a/packages/testing/src/types.ts b/packages/testing/src/types.ts new file mode 100644 index 0000000000..ef38cb5347 --- /dev/null +++ b/packages/testing/src/types.ts @@ -0,0 +1,88 @@ +import type { TableProps, AttributeType } from 'aws-cdk-lib/aws-dynamodb'; +import type { NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs'; +import type { App, Stack } from 'aws-cdk-lib'; +import { LogLevel } from './constants.js'; + +interface ExtraTestProps { + /** + * The suffix to be added to the resource name. + * + * For example, if the resource name is `fn-12345` and the suffix is `BasicFeatures`, + * the output will be `fn-12345-BasicFeatures`. + * + * Note that the maximum length of the name is 64 characters, so the suffix might be truncated. + */ + nameSuffix: string; +} + +type TestDynamodbTableProps = Omit< + TableProps, + 'removalPolicy' | 'tableName' | 'billingMode' | 'partitionKey' +> & { + partitionKey?: { + name: string; + type: AttributeType; + }; +}; + +type TestNodejsFunctionProps = Omit< + NodejsFunctionProps, + 'logRetention' | 'runtime' | 'functionName' +>; + +type InvokeTestFunctionOptions = { + functionName: string; + times?: number; + invocationMode?: 'PARALLEL' | 'SEQUENTIAL'; + payload?: Record | Array>; +}; + +type ErrorField = { + name: string; + message: string; + stack: string; +}; + +type FunctionLog = { + level: keyof typeof LogLevel; + error: ErrorField; +} & { [key: string]: unknown }; + +type StackNameProps = { + /** + * Prefix for the stack name. + */ + stackNamePrefix: string; + /** + * Name of the test. + */ + testName: string; +}; + +interface TestStackProps { + /** + * Name of the test stack. + */ + stackNameProps: StackNameProps; + /** + * Reference to the AWS CDK App object. + * @default new App() + */ + app?: App; + /** + * Reference to the AWS CDK Stack object. + * @default new Stack(this.app, stackName) + */ + stack?: Stack; +} + +export { + ExtraTestProps, + TestDynamodbTableProps, + TestNodejsFunctionProps, + InvokeTestFunctionOptions, + ErrorField, + FunctionLog, + StackNameProps, + TestStackProps, +}; diff --git a/packages/testing/tests/unit/TestInvocationLogs.test.ts b/packages/testing/tests/unit/TestInvocationLogs.test.ts index c81a05b0b0..33c4e46968 100644 --- a/packages/testing/tests/unit/TestInvocationLogs.test.ts +++ b/packages/testing/tests/unit/TestInvocationLogs.test.ts @@ -5,7 +5,7 @@ * */ -import { TestInvocationLogs } from '../../src/TestInvocationLogs'; +import { TestInvocationLogs } from '../../src/TestInvocationLogs.js'; const exampleLogs = `START RequestId: c6af9ac6-7b61-11e6-9a41-93e812345678 Version: $LATEST {"cold_start":true,"function_arn":"arn:aws:lambda:eu-west-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"DEBUG","message":"This is a DEBUG log but contains the word INFO some context and persistent key","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works"} diff --git a/packages/testing/tsconfig.esm.json b/packages/testing/tsconfig.esm.json new file mode 100644 index 0000000000..9bed8e4da4 --- /dev/null +++ b/packages/testing/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.esm.json", + "compilerOptions": { + "baseUrl": ".", + "outDir": "./lib/esm", + "rootDir": "./src" + }, + "include": [ + "./src/**/*" + ] +} \ No newline at end of file diff --git a/packages/testing/tsconfig.json b/packages/testing/tsconfig.json index 1cb9d72773..a30fdead42 100644 --- a/packages/testing/tsconfig.json +++ b/packages/testing/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "./lib", + "outDir": "./lib/cjs", "rootDir": "./src", }, "include": [ diff --git a/packages/tracer/tests/e2e/allFeatures.decorator.test.ts b/packages/tracer/tests/e2e/allFeatures.decorator.test.ts index 2ec65d83b3..7c9d3fb251 100644 --- a/packages/tracer/tests/e2e/allFeatures.decorator.test.ts +++ b/packages/tracer/tests/e2e/allFeatures.decorator.test.ts @@ -3,10 +3,8 @@ * * @group e2e/tracer/decorator */ -import { - TestStack, - TestDynamodbTable, -} from '@aws-lambda-powertools/testing-utils'; +import { TestStack } from '@aws-lambda-powertools/testing-utils'; +import { TestDynamodbTable } from '@aws-lambda-powertools/testing-utils/resources/dynamodb'; import { join } from 'node:path'; import { TracerTestNodejsFunction } from '../helpers/resources'; import { diff --git a/packages/tracer/tests/e2e/allFeatures.manual.test.ts b/packages/tracer/tests/e2e/allFeatures.manual.test.ts index 3374205e67..98f4767501 100644 --- a/packages/tracer/tests/e2e/allFeatures.manual.test.ts +++ b/packages/tracer/tests/e2e/allFeatures.manual.test.ts @@ -3,10 +3,8 @@ * * @group e2e/tracer/manual */ -import { - TestDynamodbTable, - TestStack, -} from '@aws-lambda-powertools/testing-utils'; +import { TestStack } from '@aws-lambda-powertools/testing-utils'; +import { TestDynamodbTable } from '@aws-lambda-powertools/testing-utils/resources/dynamodb'; import { join } from 'path'; import { TracerTestNodejsFunction } from '../helpers/resources'; import { diff --git a/packages/tracer/tests/e2e/allFeatures.middy.test.ts b/packages/tracer/tests/e2e/allFeatures.middy.test.ts index 5f8f965d8c..cb7603928e 100644 --- a/packages/tracer/tests/e2e/allFeatures.middy.test.ts +++ b/packages/tracer/tests/e2e/allFeatures.middy.test.ts @@ -3,10 +3,8 @@ * * @group e2e/tracer/middy */ -import { - TestStack, - TestDynamodbTable, -} from '@aws-lambda-powertools/testing-utils'; +import { TestStack } from '@aws-lambda-powertools/testing-utils'; +import { TestDynamodbTable } from '@aws-lambda-powertools/testing-utils/resources/dynamodb'; import { join } from 'node:path'; import { TracerTestNodejsFunction } from '../helpers/resources'; import { diff --git a/packages/tracer/tests/e2e/asyncHandler.decorator.test.ts b/packages/tracer/tests/e2e/asyncHandler.decorator.test.ts index f97f9d2f77..dcd4982616 100644 --- a/packages/tracer/tests/e2e/asyncHandler.decorator.test.ts +++ b/packages/tracer/tests/e2e/asyncHandler.decorator.test.ts @@ -3,10 +3,8 @@ * * @group e2e/tracer/decorator-async-handler */ -import { - TestStack, - TestDynamodbTable, -} from '@aws-lambda-powertools/testing-utils'; +import { TestStack } from '@aws-lambda-powertools/testing-utils'; +import { TestDynamodbTable } from '@aws-lambda-powertools/testing-utils/resources/dynamodb'; import { join } from 'node:path'; import { TracerTestNodejsFunction } from '../helpers/resources'; import { diff --git a/packages/tracer/tests/helpers/resources.ts b/packages/tracer/tests/helpers/resources.ts index 6f46cb98d6..4dc61ead4b 100644 --- a/packages/tracer/tests/helpers/resources.ts +++ b/packages/tracer/tests/helpers/resources.ts @@ -1,9 +1,9 @@ +import type { TestStack } from '@aws-lambda-powertools/testing-utils'; import type { ExtraTestProps, TestNodejsFunctionProps, - TestStack, -} from '@aws-lambda-powertools/testing-utils'; -import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils'; +} from '@aws-lambda-powertools/testing-utils/types'; +import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { commonEnvironmentVars } from '../e2e/constants'; class TracerTestNodejsFunction extends TestNodejsFunction { diff --git a/packages/tracer/tests/unit/Tracer.test.ts b/packages/tracer/tests/unit/Tracer.test.ts index f83aaf9240..a6381d4fac 100644 --- a/packages/tracer/tests/unit/Tracer.test.ts +++ b/packages/tracer/tests/unit/Tracer.test.ts @@ -3,10 +3,7 @@ * * @group unit/tracer/all */ -import { - ContextExamples as dummyContext, - Events as dummyEvent, -} from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; import { Tracer } from './../../src'; import type { Callback, Context } from 'aws-lambda/handler'; @@ -48,8 +45,10 @@ jest.spyOn(console, 'error').mockImplementation(() => null); describe('Class: Tracer', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = dummyContext.helloworldContext; - const event = dummyEvent.Custom.CustomEvent; + const event = { + foo: 'bar', + bar: 'baz', + }; beforeEach(() => { jest.clearAllMocks(); diff --git a/packages/tracer/tests/unit/middy.test.ts b/packages/tracer/tests/unit/middy.test.ts index fe717e656b..8195d89392 100644 --- a/packages/tracer/tests/unit/middy.test.ts +++ b/packages/tracer/tests/unit/middy.test.ts @@ -13,6 +13,7 @@ import { Subsegment, } from 'aws-xray-sdk-core'; import { cleanupMiddlewares } from '@aws-lambda-powertools/commons'; +import context from '@aws-lambda-powertools/testing-utils/context'; jest.spyOn(console, 'debug').mockImplementation(() => null); jest.spyOn(console, 'warn').mockImplementation(() => null); @@ -20,21 +21,6 @@ jest.spyOn(console, 'error').mockImplementation(() => null); describe('Middy middleware', () => { const ENVIRONMENT_VARIABLES = process.env; - const context = { - callbackWaitsForEmptyEventLoop: true, - functionVersion: '$LATEST', - functionName: 'foo-bar-function', - memoryLimitInMB: '128', - logGroupName: '/aws/lambda/foo-bar-function-123456abcdef', - logStreamName: '2021/03/09/[$LATEST]abcdef123456abcdef123456abcdef123456', - invokedFunctionArn: - 'arn:aws:lambda:eu-west-1:123456789012:function:Example', - awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e8deadbeef', - getRemainingTimeInMillis: () => 1234, - done: () => console.log('Done!'), - fail: () => console.log('Failed!'), - succeed: () => console.log('Succeeded!'), - }; beforeEach(() => { jest.clearAllMocks();