forked from aws-powertools/powertools-lambda-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Typescript idempotency initial dev branch #1
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
vgphoenixcampos
merged 20 commits into
main
from
typescript-idempotency-initial-dev-branch
Sep 9, 2022
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
effbf64
feat: initial configuration for idempotency package
vgphoenixcampos 12b1d03
feat: initial idempotency classes
vgphoenixcampos 8bc66e3
feat: inherit tsconfig from base
vgphoenixcampos ea5548d
feat: refactor persistence layer classes into their own folder
vgphoenixcampos 238d6fe
feat: added async types to persistence layer
vgphoenixcampos 11d5633
feat: rename idempotency config to differentiate from idempotency opt…
vgphoenixcampos b0f70c7
feat: added type for a generic function
vgphoenixcampos 83aae62
feat: modified AnyFunction to accept void functions
vgphoenixcampos fe5547e
feat: defined member variables of record
vgphoenixcampos dc2382e
feat: remove idempotency configuration for this FR
vgphoenixcampos 1218fab
feat: removing unused params from options
vgphoenixcampos a8371eb
feat: refactored type of function to accept any combo of parameters
vgphoenixcampos ff331d7
feat: add type for update and add functions for dynamo
608adac
feat: add table name for dynamo constructor
7d82aff
feat: add key attribute for dynamo record
KevenFuentes9 a25e11b
feat: add type for update and add functions for dynamo
KevenFuentes9 4309713
feat: add table name for dynamo constructor
KevenFuentes9 916a252
feat: add key attribute for dynamo record
KevenFuentes9 d90909e
Merge branch 'typescript-idempotency-initial-dev-branch' of https://g…
KevenFuentes9 2d9d377
feat: fixing linting issues
vgphoenixcampos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
@aws-lambda-powertools/commons | ||
0.0.2 <https://github.com/awslabs/aws-lambda-powertools-typescript> | ||
license: MIT* | ||
authors: Amazon Web Services <https://aws.amazon.com> | ||
|
||
****************************** | ||
|
||
@types/aws-lambda | ||
8.10.87 <https://github.com/DefinitelyTyped/DefinitelyTyped> | ||
MIT License | ||
|
||
Copyright (c) Microsoft Corporation. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE | ||
|
||
|
||
****************************** | ||
|
||
lodash | ||
4.17.21 <https://github.com/lodash/lodash> | ||
Copyright OpenJS Foundation and other contributors <https://openjsf.org/> | ||
|
||
Based on Underscore.js, copyright Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
|
||
This software consists of voluntary contributions made by many | ||
individuals. For exact contribution history, see the revision history | ||
available at https://github.com/lodash/lodash | ||
|
||
The following license applies to all parts of this software except as | ||
documented below: | ||
|
||
==== | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
==== | ||
|
||
Copyright and related rights for sample code are waived via CC0. Sample | ||
code is defined as all source code displayed within the prose of the | ||
documentation. | ||
|
||
CC0: http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
==== | ||
|
||
Files located in the node_modules and vendor directories are externally | ||
maintained libraries used by this software which have their own | ||
licenses; we recommend you read them, as their terms may differ from the | ||
terms above. | ||
|
||
|
||
****************************** | ||
|
||
lodash.clonedeep | ||
4.5.0 <https://github.com/lodash/lodash> | ||
Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
|
||
Based on Underscore.js, copyright Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
|
||
This software consists of voluntary contributions made by many | ||
individuals. For exact contribution history, see the revision history | ||
available at https://github.com/lodash/lodash | ||
|
||
The following license applies to all parts of this software except as | ||
documented below: | ||
|
||
==== | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
==== | ||
|
||
Copyright and related rights for sample code are waived via CC0. Sample | ||
code is defined as all source code displayed within the prose of the | ||
documentation. | ||
|
||
CC0: http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
==== | ||
|
||
Files located in the node_modules and vendor directories are externally | ||
maintained libraries used by this software which have their own | ||
licenses; we recommend you read them, as their terms may differ from the | ||
terms above. | ||
|
||
|
||
****************************** | ||
|
||
lodash.merge | ||
4.6.2 <https://github.com/lodash/lodash> | ||
Copyright OpenJS Foundation and other contributors <https://openjsf.org/> | ||
|
||
Based on Underscore.js, copyright Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
|
||
This software consists of voluntary contributions made by many | ||
individuals. For exact contribution history, see the revision history | ||
available at https://github.com/lodash/lodash | ||
|
||
The following license applies to all parts of this software except as | ||
documented below: | ||
|
||
==== | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
==== | ||
|
||
Copyright and related rights for sample code are waived via CC0. Sample | ||
code is defined as all source code displayed within the prose of the | ||
documentation. | ||
|
||
CC0: http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
==== | ||
|
||
Files located in the node_modules and vendor directories are externally | ||
maintained libraries used by this software which have their own | ||
licenses; we recommend you read them, as their terms may differ from the | ||
terms above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# AWS Lambda Powertools for TypeScript | ||
|
||
A suite of utilities for AWS Lambda functions to ease the adoption of best practices such as tracing, structured logging, custom metrics, and more. | ||
|
||
You can use the library in both TypeScript and JavaScript code bases. | ||
|
||
AWS Lambda Powertools for [Python](https://github.com/awslabs/aws-lambda-powertools-python) and AWS Lambda Powertools for [Java](https://github.com/awslabs/aws-lambda-powertools-java) are also available. | ||
|
||
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples)** | **[Serverless TypeScript Demo](https://github.com/aws-samples/serverless-typescript-demo)** | ||
|
||
## Table of contents | ||
|
||
- [Features](#features) | ||
- [Getting started](#getting-started) | ||
- [Installation](#installation) | ||
- [Examples](#examples) | ||
- [Serverless TypeScript Demo](#serverless-typescript-demo-application) | ||
- [Contribute](#contribute) | ||
- [Roadmap](#roadmap) | ||
- [Connect](#connect) | ||
- [Credits](#credits) | ||
- [License](#license) | ||
|
||
## Features | ||
|
||
* **[Tracer](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/tracer/)** - Utilities to trace Lambda function handlers, and both synchronous and asynchronous functions | ||
* **[Logger](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/logger/)** - Structured logging made easier, and a middleware to enrich log items with key details of the Lambda context | ||
* **[Metrics](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/metrics/)** - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) | ||
|
||
## Getting started | ||
|
||
Find the complete project's [documentation here](https://awslabs.github.io/aws-lambda-powertools-typescript). | ||
|
||
### Installation | ||
|
||
The AWS Lambda Powertools for TypeScript utilities follow a modular approach, similar to the official [AWS SDK v3 for JavaScript](https://github.com/aws/aws-sdk-js-v3). | ||
Each TypeScript utility is installed as standalone NPM package. | ||
|
||
Install all three core utilities at once with this single command: | ||
|
||
```shell | ||
npm install @aws-lambda-powertools/logger @aws-lambda-powertools/tracer @aws-lambda-powertools/metrics | ||
``` | ||
|
||
Or refer to the installation guide of each utility: | ||
|
||
👉 [Installation guide for the **Tracer** utility](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/tracer#getting-started) | ||
|
||
👉 [Installation guide for the **Logger** utility](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/logger#getting-started) | ||
|
||
👉 [Installation guide for the **Metrics** utility](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/metrics#getting-started) | ||
|
||
### Examples | ||
|
||
* [CDK](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk) | ||
* [SAM](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/sam) | ||
|
||
### Serverless TypeScript Demo application | ||
|
||
The [Serverless TypeScript Demo](https://github.com/aws-samples/serverless-typescript-demo) shows how to use Lambda Powertools for TypeScript. | ||
You can find instructions on how to deploy and load test this application in the [repository](https://github.com/aws-samples/serverless-typescript-demo). | ||
|
||
## Contribute | ||
|
||
If you are interested in contributing to this project, please refer to our [Contributing Guidelines](https://github.com/awslabs/aws-lambda-powertools-typescript/blob/main/CONTRIBUTING.md). | ||
|
||
## Roadmap | ||
|
||
The roadmap of Powertools is driven by customers’ demand. | ||
Help us prioritize upcoming functionalities or utilities by [upvoting existing RFCs and feature requests](https://github.com/awslabs/aws-lambda-powertools-typescript/issues), or [creating new ones](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/new/choose), in this GitHub repository. | ||
|
||
## Connect | ||
|
||
* **AWS Lambda Powertools on Discord**: `#typescript` - **[Invite link](https://discord.gg/B8zZKbbyET)** | ||
* **Email**: [email protected] | ||
|
||
## Credits | ||
|
||
Credits for the Lambda Powertools idea go to [DAZN](https://github.com/getndazn) and their [DAZN Lambda Powertools](https://github.com/getndazn/dazn-lambda-powertools/). | ||
|
||
## License | ||
|
||
This library is licensed under the MIT-0 License. See the LICENSE file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module.exports = { | ||
displayName: { | ||
name: 'AWS Lambda Powertools utility: IDEMPOTENCY', | ||
color: 'cyan', | ||
}, | ||
'runner': 'groups', | ||
'preset': 'ts-jest', | ||
'transform': { | ||
'^.+\\.ts?$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: [ 'js', 'ts' ], | ||
'collectCoverageFrom': [ | ||
'**/src/**/*.ts', | ||
'!**/node_modules/**', | ||
], | ||
'testMatch': ['**/?(*.)+(spec|test).ts'], | ||
'roots': [ | ||
'<rootDir>/src', | ||
'<rootDir>/tests', | ||
], | ||
'testPathIgnorePatterns': [ | ||
'/node_modules/', | ||
], | ||
'testEnvironment': 'node', | ||
'coveragePathIgnorePatterns': [ | ||
'/node_modules/', | ||
'/types/', | ||
], | ||
'coverageThreshold': { | ||
'global': { | ||
'statements': 100, | ||
'branches': 100, | ||
'functions': 100, | ||
'lines': 100, | ||
}, | ||
}, | ||
'coverageReporters': [ | ||
'json-summary', | ||
'text', | ||
'lcov' | ||
], | ||
'setupFiles': [ | ||
'<rootDir>/tests/helpers/populateEnvironmentVariables.ts' | ||
] | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "@aws-lambda-powertools/idempotency", | ||
"version": "0.0.11", | ||
"description": "TBD", | ||
"author": { | ||
"name": "Amazon Web Services", | ||
"url": "https://aws.amazon.com" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"commit": "commit", | ||
"test": "npm run test:unit", | ||
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose", | ||
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e", | ||
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e", | ||
"test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e", | ||
"test:e2e": "jest --group=e2e", | ||
"watch": "jest --watch --group=unit", | ||
"build": "tsc", | ||
"lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests", | ||
"format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", | ||
"package": "mkdir -p dist/ && npm pack && mv *.tgz dist/", | ||
"package-bundle": "../../package-bundler.sh logger-bundle ./dist", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm test && npm run lint", | ||
"preversion": "npm run lint", | ||
"version": "npm run format && git add -A src", | ||
"postversion": "git push && git push --tags" | ||
}, | ||
"homepage": "https://github.com/awslabs/aws-lambda-powertools-typescript/tree/master/packages/idempotency#readme", | ||
"license": "MIT", | ||
"main": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"typedocMain": "src/index.ts", | ||
"files": [ | ||
"lib" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/awslabs/aws-lambda-powertools-typescript.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/awslabs/aws-lambda-powertools-typescript/issues" | ||
}, | ||
"dependencies": { | ||
"@aws-lambda-powertools/commons": "^1.2.1" | ||
}, | ||
"keywords": [ | ||
"aws", | ||
"lambda", | ||
"powertools", | ||
"serverless", | ||
"nodejs" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { PersistenceLayer } from './persistence/PersistenceLayer'; | ||
|
||
type IdempotencyOptions = { | ||
dataKeywordArgument: string | ||
persistenceStore: PersistenceLayer | ||
}; | ||
|
||
export { IdempotencyOptions }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { AnyFunction } from './types/AnyFunction'; | ||
import { IdempotencyOptions } from './IdempotencyOptions'; | ||
|
||
const makeFunctionIdempotent = <U>( | ||
fn: AnyFunction<U>, | ||
_options: IdempotencyOptions | ||
): (...args: Array<any>) => Promise<U | void> => (...args) => fn(...args); | ||
|
||
export { makeFunctionIdempotent }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.