tkhq / sdk

Turnkey TypeScript SDK
Apache License 2.0
48 stars 13 forks source link

Reworked SDK Base HTTP Client #221

Closed AlwaysBCoding closed 5 months ago

AlwaysBCoding commented 6 months ago

Summary & Motivation

Motivation is to begin aggregating our javascript SDK libraries into a single importable SDK with nicer user abstractions for calling common Turnkey API functionality

Structure

This PR introduces a new package called sdk-js into the packages/ folder. The package requires two __inputs__ which are the copied public_api.swagger.json file and the public_api.types.json from the mono repo.

There is a single script node scripts/codegen.js which will generate the base sdk client and associated types and save it in the __generated__ folder.

Finally there is a top-level sdk-client.ts file that will contain the exported SDK client and the ability to create synthetic methods for users to interact with that are abstractions on top of just calling the underlying generated API methods.

What is different than the existing base HTTP Client

  1. The syntax for calling methods on the Turnkey client is nicer (you don't need to pass an activity type, timestamp and organizationId into every function call)
  2. The TurnkeyClient is initialized with a single config object which can be used to configure anything about the http client functionality (i.e. activity poller polling duration or base api url)
  3. Any commands automatically poll for the activity creation before returning a result to the user, you don't need to use an activity poller
  4. There is a workflow for extending the existing base client with custom methods
codesandbox-ci[bot] commented 6 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

socket-security[bot] commented 5 months ago

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@types/elliptic@6.4.18 None +1 25.9 kB types
npm/@types/express@4.17.21 None +10 111 kB types
npm/@types/react@18.2.75 None +2 1.65 MB types
npm/elliptic@6.5.5 None +7 295 kB indutny
npm/glob@8.1.0 filesystem Transitive: environment +8 139 kB isaacs

View full report↗︎