restrict to RATE_LIMIT with package-version-ids

This commit is contained in:
Anupam
2023-01-05 10:25:21 +00:00
parent 79269eb4bf
commit 46653ba3cb
4 changed files with 5 additions and 9 deletions

View File

@@ -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()
})
})

View File

@@ -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.

3
dist/index.js vendored
View File

@@ -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(

View File

@@ -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(