Skip to content
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

feat: typescript definitions for mysql2 lib #676

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rrhodes
Copy link

@rrhodes rrhodes commented Aug 27, 2024

Closes #387.

Extending the AWS X-Ray MySQL library to support patching of MySQL2 connections, pools, and pool clusters.

Type definitions are derived for the most part from index.d.ts with thanks to @jj22ee for their valuable feedback on this PR.

There's scope to extend this library further to support mysql2/promise, allowing for usage of promises rather than the callbacks that this PR focuses on.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rrhodes

This comment was marked as outdated.

@rrhodes

This comment was marked as outdated.

@rrhodes

This comment was marked as outdated.

@rrhodes

This comment was marked as outdated.

@jj22ee
Copy link
Contributor

jj22ee commented Oct 12, 2024

Hi @rrhodes. The failing workflow is unrelated to your PR (it's affecting other PRs as well). We will look into fixing this issue, which is also described in #688

@rrhodes

This comment was marked as outdated.

@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.56%. Comparing base (e28c1af) to head (3050e6d).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #676   +/-   ##
=======================================
  Coverage   83.56%   83.56%           
=======================================
  Files          36       36           
  Lines        1813     1813           
=======================================
  Hits         1515     1515           
  Misses        298      298           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rrhodes rrhodes requested a review from jj22ee October 20, 2024 16:00
packages/mysql/test-d/index.test-d.ts Outdated Show resolved Hide resolved
};

interface PatchedMySQL2CreateConnectionFunction {
(config: MySQL2.ConnectionOptions | string): Promise<PatchedConnection>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, we should also support mysql2.createConnection that returns a Connection. Our instrumentation does support a return value of a Promise<Connection>, but that requires supporting TS definitions of patched mysql2/promise rather than mysql2, which only the latter is supported by this PR.

Copy link
Author

@rrhodes rrhodes Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've started to de-scope this PR to support return of Connection only, rather than extending it to support Promise<Connection>: 8d4597f

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jj22ee for calling out the distinction between mysql2 and mysql2/promise, which I didn't quite appreciate on the outset.

I'd be happy to explore an extension of X-Ray's type definitions for the latter in future, but I'll keep this PR specific to mysql2 for the time being.

packages/mysql/lib/mysql_p.d.ts Outdated Show resolved Hide resolved
@rrhodes rrhodes marked this pull request as draft November 1, 2024 17:42
@rrhodes rrhodes force-pushed the feat/ts-definitions-for-mysql2 branch from c4851ea to 325bde5 Compare November 11, 2024 21:47
@rrhodes rrhodes requested a review from jj22ee November 11, 2024 21:47
@rrhodes rrhodes marked this pull request as ready for review November 11, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for nodejs mysql2 package in TypeScript definition
3 participants