sensedeep / dynamodb-onetable

DynamoDB access and management for one table designs with NodeJS
https://doc.onetable.io/
MIT License
689 stars 109 forks source link

Metrics.d.ts should not include function interfaces declared as 'async' #499

Closed rpfeil closed 1 year ago

rpfeil commented 1 year ago

ISSUES will not receive priority that do not complete this template. They will be flagged as "Insufficient Information" and may be closed without any action.

Describe the bug

I am installing OneTable into an AWS Lambda function project generated by SAM. Compilation complains about the async references in the Metrics.d.ts file. 'error TS1040: 'async' modifier cannot be used in an ambient context'. Editing the file directly, and removing all the asyncs, makes everything work. This kills deployment though.

https://stackoverflow.com/questions/48448151/how-can-i-add-an-async-function-to-a-type-def-file

I'm sorry there is no proper repro. I've been trying for 7 days to get OneTable to work. I don't have any more time for this. I'd rather just remove it.

package.json { "name": "hello_world", "version": "1.0.0", "description": "Gaylord Claims API Lambda", "main": "app.js", "repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs", "author": "SAM CLI", "license": "MIT", "dependencies": { "aws-sdk": "^2.1458.0", "axios": ">=0.21.1", "dynamodb-onetable": "^2.7.0" }, "scripts": { "build": "tsc", "clean": "rm -rf build" }, "devDependencies": { "@types/aws-lambda": "^8.10.119", "@types/node": "^20.6.0", "chai": "^4.3.6", "mocha": "^10.1.0", "typescript": "^5.2.2" } }

Sincerely, Rick Pfeil - rpfeil@gmail.com

mobsense commented 1 year ago

Hi, thanks for your comment.

What do you mean "kills deployment though"?

I can understand removing async, as the return type is Promise<>. Does just removing async work?

Michael

rpfeil commented 1 year ago

Yes, it does work :-). It kills deployment because I can't include my changes. It pulls fresh code from npm.

mobsense commented 1 year ago

Okay, understand. We'll push out a fix today.

rpfeil commented 1 year ago

I super appreciate this! I love what this package does :-). But I made the mistake of trying to run it client side first.

mobsense commented 1 year ago

Thank you. Why was client side a mistake? We do that in one of our apps.

rpfeil commented 1 year ago

How?!?! The Node.js modules (crypto, process, ect) are no longer provided for clients. I couldn't get any polyfill to work.

mobsense commented 1 year ago

SenseDeep uses the AWS SDK in the client and OneTable. We use some 3rd party polyfills and we created the others.