moneyhub / moneyhub-api-client

Node.JS Client for the Moneyhub API
10 stars 7 forks source link

Add TypeScript Types #25

Closed jamiehaywood closed 2 years ago

jamiehaywood commented 2 years ago

Adding a TypeScript declaration file would be very useful to consumers to get intellisense on the params and return types.

jamiehaywood commented 2 years ago

hi guys, just wanted to follow up to see where you'd got to with the types? currently having to add types to our project like so:

// moneyhub.d.ts
declare module '@mft/moneyhub-api-client' {
  import type { JWK } from 'jose'
  import type { GotBodyOptions, GotJSONOptions, GotFormOptions } from 'got'
  import type { TokenSet } from 'openid-client'

  function Factory(apiClientConfig: APIClientConfig): Promise<MoneyHub>
  export default Factory
  export interface MoneyHub {
    getAuthorizeUrl: (params: {
      state: string
      scope: string
      nonce: string
      claims?: Record<string, unknown>
      permissions: string[]
    }) => Promise<string>

    exchangeCodeForTokens: (params: {
      paramsFromCallback: Record<string, unknown>
      localParams: Record<string, unknown>
    }) => Promise<TokenSet>

// etc...
}

would be great if you could take a look at my PR and merge / rewrite stuff you think is relevant.

Very happy to give some of my time to help with toolchain / build / release process