Skip to content

Commit

Permalink
restrict to RATE_LIMIT with package-version-ids
Browse files Browse the repository at this point in the history
  • Loading branch information
s-anupam committed Jan 5, 2023
1 parent 79269eb commit 46653ba
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion __tests__/delete.test.ts
Expand Up @@ -24,7 +24,7 @@ describe('index tests -- call rest', () => {
it('finalIds test - supplied package version id', done => {
const suppliedIds = ['123', '456', '789']
finalIds(getInput({packageVersionIds: suppliedIds})).subscribe(ids => {
expect(ids).toBe(suppliedIds)
expect(ids).toStrictEqual(suppliedIds)
done()
})
})
Expand Down
6 changes: 0 additions & 6 deletions action.yml
Expand Up @@ -15,12 +15,6 @@ inputs:
Defaults to the owner of the repo running the action.
required: false

repo:
description: >
Repo containing the package version to delete.
Defaults to the repo running the action.
required: false

package-name:
description: >
Name of the package containing the version to delete.
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js
Expand Up @@ -22,7 +22,8 @@ function getVersionIds(owner, packageName, packageType, numVersions, page, token
exports.getVersionIds = getVersionIds;
function finalIds(input) {
if (input.packageVersionIds.length > 0) {
return (0, rxjs_1.of)(input.packageVersionIds);
const toDelete = Math.min(input.packageVersionIds.length, exports.RATE_LIMIT);
return (0, rxjs_1.of)(input.packageVersionIds.slice(0, toDelete));
}
if (input.hasOldestVersionQueryInfo()) {
return getVersionIds(input.owner, input.packageName, input.packageType, exports.RATE_LIMIT, 1, input.token).pipe(
Expand Down
3 changes: 2 additions & 1 deletion src/delete.ts
Expand Up @@ -47,7 +47,8 @@ export function getVersionIds(

export function finalIds(input: Input): Observable<string[]> {
if (input.packageVersionIds.length > 0) {
return of(input.packageVersionIds)
const toDelete = Math.min(input.packageVersionIds.length, RATE_LIMIT)
return of(input.packageVersionIds.slice(0, toDelete))
}
if (input.hasOldestVersionQueryInfo()) {
return getVersionIds(
Expand Down

0 comments on commit 46653ba

Please sign in to comment.