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

[GMS-1127] chore: Export api types from blockchain data package #971

Merged
merged 15 commits into from
Oct 12, 2023

Conversation

allan-almeida
Copy link
Contributor

@allan-almeida allan-almeida commented Oct 11, 2023

Summary

This PR adds custom generator templates to our internal openapi package for MR API, in order that API request and response types can be re-exported from our public blockchain data package.

The internal package exports types for every API, whilst the public blockchain data package exports types only for relevant API's (not Orders or Passport).

Read more about generator templates

See the sample app files for example usage.

Why the changes

Existing generators mix request/response types with other interfaces that we do not want to expose. Additional generators were required to be able to export only what we need.

Things worth calling out

Before submitting the PR, please consider the following:

  • Prefix your PR title with feat: , fix: , chore: , docs:, or refactor:.

@allan-almeida allan-almeida requested a review from a team as a code owner October 11, 2023 03:30
@allan-almeida allan-almeida requested a review from a team as a code owner October 11, 2023 04:33
"apiPackage": "domain",
"useSingleRequestParameter": true,
"templateDir": "app/src/templates",
"files": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here is where the custom generators are allowed to be configured, we are doing this for mr only at the moment, hence the seperate config files

@@ -1,5 +1,16 @@
export * as imx from './imx';
export * as mr from './multi-rollup';

export * as ActivitiesApi from './multi-rollup/domain/activities-api-types';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I experimented with auto-generating a combined namespace for all these types, but it proved to be a hinderance later on when trying to re-export selected api types from the public blockchain data package. For now we are exporting all the api domains, and choosing to re-export only relevant ones from blockchain data (not passport or orders api)

7.0.1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was required to upgrade the generator library version in order to resolve compile issues with the generated types. I went through the consuming packages of the generated clients internal package in the SDK and checked they all still compiled

@@ -0,0 +1,79 @@
{{#withSeparateModelsAndApi}}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These templates house additional generators that are run on top of existing generators. This api-types one, of type 'API' (see config file above), generates a -type file per API.

allan-almeida

This comment was marked as duplicate.

@allan-almeida allan-almeida changed the title [GMS-1127] Export api types from blockchain data package [GMS-1127] chore: Export api types from blockchain data package Oct 11, 2023
@@ -405,7 +406,9 @@ const endpointDomains = {
};

export default function Home() {
const [response, setResponse] = useState('');
const [response, setResponse] = useState<ChainsApi.ListChainsResult | null>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

example usage

@allan-almeida allan-almeida enabled auto-merge (squash) October 12, 2023 22:29
@allan-almeida allan-almeida merged commit 1c3ba10 into main Oct 12, 2023
6 checks passed
@allan-almeida allan-almeida deleted the feature/GMS-1127/api-types branch October 12, 2023 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants