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

Typescript Support #2

Open
MattNguyen opened this issue Jun 5, 2019 · 13 comments
Open

Typescript Support #2

MattNguyen opened this issue Jun 5, 2019 · 13 comments
Assignees
Labels
enhancement New feature or request

Comments

@MattNguyen
Copy link

It would be great to include a type declaration file.

I'm currently using this for now, but I'm seeing TypeError: config.RDS.executeStatement is not a function when executing query().

declare module 'data-api-client' {
  import RDSDataService from 'aws-sdk/clients/rdsdataservice';
  import {ConfigBase as Config} from 'aws-sdk/lib/config';

  export interface iParams {
    secretArn: string;
    resourceArn: string;
    database: string;
    keepAlive?: boolean;
    hydrateColumnNames?: boolean;
    options?: Config & RDSDataService.Types.ClientConfiguration;
  }

  export interface iDataAPIClient {
    query(...x: any[]): iDataAPIQueryResult;
  }

  export interface iDataAPIQueryResult {
    records: Array<any>;
  }

  export default function (params: iParams): iDataAPIClient
}
@jeremydaly
Copy link
Owner

Hi Matt,

A TypeScript declaration file is on my list of TODOs. The typing will need to be a bit more complex than what you've got. The config object stores a reference to the RDSDataService methods, but also promisifies them under the hood. I'll need to do a bit more research to figure this out. Any help would be greatly appreciated.

Thanks,
Jeremy

@jeremydaly jeremydaly added the enhancement New feature or request label Jun 5, 2019
@cbschuld
Copy link

cbschuld commented Nov 2, 2019

@MattNguyen - I am going implement this lib in TS as well did you get anywhere with it by chance?

@jeremydaly - nice work on this; starting to pull it into a serverless(.com) based project that I have in TypeScript so checking to see if any work has been done in TS yet.

@MarkHerhold
Copy link

@MattNguyen I had to adjust your type definitions to fix settings (likely still incorrect) and make query return a promise. See PR #49.

@cbschuld How is your implementation going?

@cbschuld
Copy link

cbschuld commented Jun 13, 2020

@MarkHerhold my solution is here (https://github.com/cbschuld/rds-data). (https://www.npmjs.com/package/rds-data). Jeremy's library is so good just missing that Typescript ❤️ . I am not sold my adoption is great either, related specifically to how I am typing the return values, but it has been nice to have in a few of my TS projects.

@MarkHerhold
Copy link

@cbschuld Neat! Are you running it in prod? I could give it a try!

@cbschuld
Copy link

@MarkHerhold - yes, on a few different apps. So far so good!

@jeremydaly jeremydaly self-assigned this Jul 9, 2020
@miketeix
Copy link

Would be great to see this come through as this library seems to return data a nicer format than "rds-data" package mentioned above.

@cbschuld
Copy link

Hey @miketeix there is an open PR to change the way the data is returned from rds-data. Interested in your feedback if you want to toss it over there.

@idanlo
Copy link

idanlo commented Jan 7, 2021

Is there an update on this? Could be extremely useful having TypeScript, this seems like a very good library with good potential, because using aws-sdk is a pain with the Data API

@jeremydaly
Copy link
Owner

@ffxsam, any interest in working on this?

@ffxsam
Copy link
Collaborator

ffxsam commented Jan 9, 2021

@jeremydaly I don't have the bandwidth right now, unfortunately! I wish I did because I've been wanting TS support myself. 😄

@idanlo
Copy link

idanlo commented Jan 9, 2021

@jeremydaly Because the PR hasn't been updated in a while I took some of the code there and modified it a bit, it's pretty basic but it does the job, I have created a PR at DefinitelyTyped - DefinitelyTyped/DefinitelyTyped#50495, If you could take a look there and offer improvements that would be great. Having no types for this is pretty annoying for me because I will need to use multiple instances of this library in lambda functions, so I would like it to have types without me needing to modify node_modules every time.
Thank you!

By the way: I noticed that you are using legacy export syntax (module.exports) which means that the TypeScript types cannot export stuff other than the default exported member, which is not ideal, also TypeScript would have to require this module like this import Client = require('data-api-client'), if you could change to ES6 syntax exports I think that is the ideal solution.

@shellscape
Copy link

@jeremydaly ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants