-
Notifications
You must be signed in to change notification settings - Fork 126
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
[BUG] opensearchtypes export and api/types subpath have been removed from v3, cannot import API inner types anymore ? #955
Comments
Thanks for reporting the issue. The change to how type definitions are accessed is a breaking change from 2.X to 3.X as the types from 3.X are generated from the spec instead of hand written. Check out this upgrading guide on typescript. There 2 ways to access the QueryContainer type. One is directly referencing the location of the type definition like you did, the other is through the the request/response types exposed by the // playground.ts
import { type API } from '@opensearch-project/opensearch';
import type { QueryContainer } from '@opensearch-project/opensearch/api/_types/_common.query_dsl';
const buildQuery = (): QueryContainer => {
return {
wildcard: {}
};
};
const query: NonNullable<API.UpdateByQuery_Request['body']>['query'] = {
span_within: {
big: {},
little: {}
}
}
console.log(buildQuery());
console.log(query); // > ts-node playground.ts
{ wildcard: {} }
{ span_within: { big: {}, little: {} } } |
We can export
We can update the generator to introduce
|
Yes, having the auto-generated types directly accessible via a I understand your perspective regarding accessing types through the API root. However, some types are shared across different APIs. For instance, |
@xfournet want to try a PR along the lines of what you're proposing? |
Indeed I was trying to figure out how to add that in the API generator. First I tried to execute the API generator, but no luck so far i get an error. Is there a precise version of the
|
You should download the spec first. The quickest fix is adding If you opt to create an OpenSearchTypes module, we already generate a very similar module called API that aggregates all request and response types that you can model after. Here's the rendering logic and template. |
I already downloaded the spec. But I had this error during the API generation. I increased the stacktrace limit to have more information if it can help ?
|
Got it (Windows support) i will provide the fix for that |
Signed-off-by: Xavier Fournet <[email protected]>
See PR #957 |
) Signed-off-by: Xavier Fournet <[email protected]>
Signed-off-by: Xavier Fournet <[email protected]>
Generate api/_types/index.d.ts (#955) Signed-off-by: Xavier Fournet <[email protected]>
3.1.0 has been released. |
What is the bug?
In v2 it was possible to access API inner types (QueryDslQueryContainer as an example) directly, either using opensearchtypes export from main index, or since #674 using the api/types subpath
eg with opensearchtypes
and with api/types subpath
How can one reproduce the bug?
After upgrade to v3, opensearchtypes export is no more present and api/types expotred subpath has been removed from package.json
(BTW, I did see mention of these breaking changes in the release note, so i may suspect theses changes are not intentional ?)
The corresponding type in v3 is QueryContainer in api/_types/_common.query_dsl.d.ts but it's not exported by the module
I have tried
it's recognized in the IDE, but, as expected, rejected by typescript
I may have miss something, but so far I didn't found a way to import this type.
What is the expected behavior?
Having a simple way to import API inner types directly
What is your host/environment?
Non relevant
Do you have any screenshots?
Non relevant
Do you have any additional context?
No
The text was updated successfully, but these errors were encountered: