Skip to content

chore(validation): add workspace pkg #3592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
"packages/tracer",
"packages/parser",
"packages/parameters",
"packages/validation",
"packages/metrics"
]
fail-fast: false
Expand Down
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"packages/jmespath",
"packages/parser",
"packages/event-handler",
"packages/validation",
"examples/app",
"layers",
"examples/snippets"
Expand Down
70 changes: 69 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"examples/snippets",
"layers",
"examples/app",
"packages/event-handler"
"packages/event-handler",
"packages/validation"
],
"scripts": {
"test": "npm t -ws",
Expand Down
74 changes: 74 additions & 0 deletions packages/validation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Powertools for AWS Lambda (TypeScript) - Validation Utility

> [!Warning]
> This feature is currently under development. As such it's considered not stable and we might make significant breaking changes before going before its release. You are welcome to [provide feedback](https://github.com/aws-powertools/powertools-lambda-typescript/discussions/3519) and [contribute to the project](https://docs.powertools.aws.dev/lambda/typescript/latest/contributing/getting_started/).

Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda/typescript/latest/#features).

You can use the library in both TypeScript and JavaScript code bases.

## Intro

This utility provides JSON Schema validation for events and responses, including JMESPath support to unwrap events before validation.

## Usage

To get started, install the library by running:

```sh
npm i @aws-lambda-powertools/validation
```

> [!Note]
> This readme is a work in progress.

## Contribute

If you are interested in contributing to this project, please refer to our [Contributing Guidelines](https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/CONTRIBUTING.md).

## Roadmap

The roadmap of Powertools for AWS Lambda (TypeScript) is driven by customers’ demand.
Help us prioritize upcoming functionalities or utilities by [upvoting existing RFCs and feature requests](https://github.com/aws-powertools/powertools-lambda-typescript/issues), or [creating new ones](https://github.com/aws-powertools/powertools-lambda-typescript/issues/new/choose), in this GitHub repository.

## Connect

- **Powertools for AWS Lambda on Discord**: `#typescript` - **[Invite link](https://discord.gg/B8zZKbbyET)**
- **Email**: <[email protected]>

## How to support Powertools for AWS Lambda (TypeScript)?

### Becoming a reference customer

Knowing which companies are using this library is important to help prioritize the project internally. If your company is using Powertools for AWS Lambda (TypeScript), you can request to have your name and logo added to the README file by raising a [Support Powertools for AWS Lambda (TypeScript) (become a reference)](https://s12d.com/become-reference-pt-ts) issue.

The following companies, among others, use Powertools:

- [Alma Media](https://www.almamedia.fi)
- [AppYourself](https://appyourself.net)
- [Bailey Nelson](https://www.baileynelson.com.au)
- [Banxware](https://www.banxware.com)
- [Caylent](https://caylent.com/)
- [Certible](https://www.certible.com/)
- [Elva](https://elva-group.com)
- [Flyweight](https://flyweight.io/)
- [globaldatanet](https://globaldatanet.com/)
- [Hashnode](https://hashnode.com/)
- [LocalStack](https://localstack.cloud/)
- [Perfect Post](https://www.perfectpost.fr)
- [Sennder](https://sennder.com/)
- [tecRacer GmbH & Co. KG](https://www.tecracer.com/)
- [Trek10](https://www.trek10.com/)
- [WeSchool](https://www.weschool.com)

### Sharing your work

Share what you did with Powertools for AWS Lambda (TypeScript) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (TypeScript) [here](https://docs.powertools.aws.dev/lambda/typescript/latest/we_made_this).

### Using Lambda Layer

This helps us understand who uses Powertools for AWS Lambda (TypeScript) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](https://docs.powertools.aws.dev/lambda/typescript/latest/#lambda-layer), you can add Powertools as a dev dependency to not impact the development process.

## License

This library is licensed under the MIT-0 License. See the LICENSE file.
69 changes: 69 additions & 0 deletions packages/validation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "@aws-lambda-powertools/validation",
"version": "2.14.0",
"description": "An utility to validate events and responses using JSON Schemas",
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com"
},
"private": true,
"scripts": {
"test": "vitest --run",
"test:unit": "vitest --run",
"test:unit:coverage": "vitest --run tests/unit --coverage.enabled --coverage.thresholds.100 --coverage.include='src/**'",
"test:unit:types": "echo 'Not Implemented'",
"test:e2e:nodejs18x": "echo \"Not implemented\"",
"test:e2e:nodejs20x": "echo \"Not implemented\"",
"test:e2e:nodejs22x": "echo \"Not implemented\"",
"test:e2e": "echo \"Not implemented\"",
"build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
"build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json",
"build": "echo \"Not implemented\"",
"lint": "biome lint .",
"lint:fix": "biome check --write .",
"prepack": "node ../../.github/scripts/release_patch_package_json.js ."
},
"homepage": "https://github.com/aws-powertools/powertools-lambda-typescript#readme",
"license": "MIT-0",
"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"
}
}
},
"types": "./lib/cjs/index.d.ts",
"main": "./lib/cjs/index.js",
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/aws-powertools/powertools-lambda-typescript.git"
},
"bugs": {
"url": "https://github.com/aws-powertools/powertools-lambda-typescript/issues"
},
"dependencies": {
"@aws-lambda-powertools/commons": "^2.14.0",
"@aws-lambda-powertools/jmespath": "^2.14.0",
"ajv": "^8.17.1"
},
"keywords": [
"aws",
"lambda",
"powertools",
"json-schema",
"validation",
"event",
"handler",
"nodejs",
"serverless"
]
}
1 change: 1 addition & 0 deletions packages/validation/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = () => true;
8 changes: 8 additions & 0 deletions packages/validation/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../../",
"noEmit": true
},
"include": ["../../testing/src/setupEnv.ts", "../src/**/*", "./**/*"]
}
16 changes: 16 additions & 0 deletions packages/validation/tests/unit/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { foo } from '../../src/index.js';

describe('Validation', () => {
beforeEach(() => {
vi.clearAllMocks();
});

it('should return true', () => {
// Act
const result = foo();

// Assess
expect(result).toBe(true);
});
});
10 changes: 10 additions & 0 deletions packages/validation/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./lib/esm",
"rootDir": "./src",
"tsBuildInfoFile": ".tsbuildinfo/esm.json"
},
"include": ["./src/**/*"]
}
9 changes: 9 additions & 0 deletions packages/validation/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib/cjs/",
"rootDir": "./src",
"tsBuildInfoFile": ".tsbuildinfo/cjs.json"
},
"include": ["./src/**/*"]
}
8 changes: 8 additions & 0 deletions packages/validation/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineProject } from 'vitest/config';

export default defineProject({
test: {
environment: 'node',
setupFiles: ['../testing/src/setupEnv.ts'],
},
});