gitbeaker
gitbeaker copied to clipboard
showExpanded option not working on Projects.all
Description
on Projects.all
method, adding showExpanded: true
does not show the expanded results as stated in the docs, meaning that there is no way to track if all the results have been returned.
Steps to reproduce
Heres my code:
const projects = new Projects({token: xxxxx})
const resp = await projects.all({
showExpanded: true,
perPage: 20,
maxPages: 2,
minAccessLevel: 40,
})
console.log(resp.data) // undefined
console.log(resp.paginationInfo) // undefined
console.log(resp) // array of repos
There are 98 repos in total if that helps.
Expected behaviour
The response object is supposed to contain both data
and paginationInfo
keys
Actual behaviour
Only repos are returned.
Weird, Ill give it a look and follow up!
Testing this with the latest release without an issue. Is there any other information you could provide to aid me in narrowing down the problem?
Note that your code needs to be run within a function, and that await cannot be used at the root level.
async function test(){
const projects = new Projects({token: xxxxx})
const { data, paginationInfo } = await projects.all({
showExpanded: true,
perPage: 20,
maxPages: 2,
minAccessLevel: 40,
})
}
test()
Closing due to inactivity
I have this issue too, and the ts type is unexpected.
It only occurs when I enable token
, without token
, there are data/paginationInfo
.
And I'm using a custom hosted GitLab service, I don't know if it is related.
@jdalrymple
OK, I just found showExpanded
is actually unavailable in ts options. So this should a bug.
Ill give it a look! Thanks for the extra info
Hmm, it looks like the typing is not being picked up when its that nested. Not sure why
Damn, this is a bigger problem. Gonna need to dig deeper https://github.com/microsoft/TypeScript/issues/33369
Function overload can be used for typings.
haha easier said than done. Using overloads results in many many many more functions. Thats what lead me to use conditional types. Im going to spend a bit of time looking at what these limitations are and if there is a way to work around them.
It looks like the only solution (besides writing many many many overload functions) is to add generic variables to each function like:
function fnname<P extends 'keyset' | 'offset' = 'offset', E extends boolean = false>(o?: ShowExpanded<E> & PaginatedRequestOptions<P>)
Kind of annoying, but until i can think of a better way of doing it, ill implement this where needed
not to put pressure onto this but whats your status on this? would be highly appreciated because i could need the information provided by showExpanded. :)
This is the next thing ill be jumping on! Just been swamped lately. I did try to implement what i came up with earlier (see previous comment), but i ran into an issue when actually putting it into practice. I should have some free time by the end of this week, ill follow up then :pray:
:rocket: Issue was released in 37.0.0
:rocket: