-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 4040-gitea
- Loading branch information
Showing
16 changed files
with
577 additions
and
447 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
services/galaxytoolshed/galaxytoolshed-version.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { NotFound, pathParams } from '../index.js' | ||
import { renderVersionBadge } from '../version.js' | ||
import GalaxyToolshedService from './galaxytoolshed-base.js' | ||
|
||
export class GalaxyToolshedVersion extends GalaxyToolshedService { | ||
static category = 'version' | ||
static route = { | ||
base: 'galaxytoolshed/v', | ||
pattern: ':repository/:owner/:tool?/:requirement?', | ||
} | ||
|
||
static openApi = { | ||
'/galaxytoolshed/v/{repository}/{owner}': { | ||
get: { | ||
summary: 'Galaxy Toolshed - Repository Version', | ||
parameters: pathParams( | ||
{ | ||
name: 'repository', | ||
example: 'sra_tools', | ||
}, | ||
{ | ||
name: 'owner', | ||
example: 'iuc', | ||
}, | ||
), | ||
}, | ||
}, | ||
'/galaxytoolshed/v/{repository}/{owner}/{tool}': { | ||
get: { | ||
summary: 'Galaxy Toolshed - Tool Version', | ||
parameters: pathParams( | ||
{ | ||
name: 'repository', | ||
example: 'sra_tools', | ||
}, | ||
{ | ||
name: 'owner', | ||
example: 'iuc', | ||
}, | ||
{ | ||
name: 'tool', | ||
example: 'fastq_dump', | ||
}, | ||
), | ||
}, | ||
}, | ||
'/galaxytoolshed/v/{repository}/{owner}/{tool}/{requirement}': { | ||
get: { | ||
summary: 'Galaxy Toolshed - Tool Requirement Version', | ||
parameters: pathParams( | ||
{ | ||
name: 'repository', | ||
example: 'sra_tools', | ||
}, | ||
{ | ||
name: 'owner', | ||
example: 'iuc', | ||
}, | ||
{ | ||
name: 'tool', | ||
example: 'fastq_dump', | ||
}, | ||
{ | ||
name: 'requirement', | ||
example: 'perl', | ||
}, | ||
), | ||
}, | ||
}, | ||
} | ||
|
||
static transform({ response, tool, requirement }) { | ||
if (tool !== undefined) { | ||
const dataTool = response[1].valid_tools.find(x => x.id === tool) | ||
if (dataTool === undefined) { | ||
throw new NotFound({ prettyMessage: 'tool not found' }) | ||
} | ||
// Requirement version | ||
if (requirement !== undefined) { | ||
const dataRequirement = dataTool.requirements.find( | ||
x => x.name === requirement, | ||
) | ||
if (dataRequirement === undefined) { | ||
throw new NotFound({ prettyMessage: 'requirement not found' }) | ||
} | ||
return dataRequirement.version | ||
} | ||
// Tool version | ||
return dataTool.version | ||
} | ||
// Repository version | ||
return response[1].changeset_revision | ||
} | ||
|
||
async handle({ repository, owner, tool, requirement }) { | ||
const response = await this.fetchLastOrderedInstallableRevisionsSchema({ | ||
repository, | ||
owner, | ||
}) | ||
const version = this.constructor.transform({ | ||
response, | ||
tool, | ||
requirement, | ||
}) | ||
return renderVersionBadge({ version }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { withRegex, isVPlusTripleDottedVersion } from '../test-validators.js' | ||
import { createServiceTester } from '../tester.js' | ||
|
||
export const t = await createServiceTester() | ||
|
||
t.create('version - repository') | ||
.get('/sra_tools/iuc.json') | ||
.expectBadge({ | ||
label: 'galaxytoolshed', | ||
message: withRegex(/^([\w\d]+)$/), | ||
}) | ||
t.create('version - tool').get('/sra_tools/iuc/fastq_dump.json').expectBadge({ | ||
label: 'galaxytoolshed', | ||
message: isVPlusTripleDottedVersion, | ||
}) | ||
t.create('version - requirement') | ||
.get('/sra_tools/iuc/fastq_dump/perl.json') | ||
.expectBadge({ | ||
label: 'galaxytoolshed', | ||
message: isVPlusTripleDottedVersion, | ||
}) | ||
|
||
// Not found | ||
t.create('version - changesetRevision not found') | ||
.get('/bioqc/badilla.json') | ||
.expectBadge({ | ||
label: 'galaxytoolshed', | ||
message: 'changesetRevision not found', | ||
}) | ||
t.create('version - repository not found') | ||
.get('/sra_too/iuc.json') | ||
.expectBadge({ | ||
label: 'galaxytoolshed', | ||
message: 'not found', | ||
}) | ||
t.create('version - owner not found').get('/sra_tool/iu.json').expectBadge({ | ||
label: 'galaxytoolshed', | ||
message: 'not found', | ||
}) | ||
t.create('version - tool not found') | ||
.get('/sra_tools/iuc/fastq_dum.json') | ||
.expectBadge({ | ||
label: 'galaxytoolshed', | ||
message: 'tool not found', | ||
}) | ||
t.create('version - requirement not found') | ||
.get('/sra_tools/iuc/fastq_dump/per.json') | ||
.expectBadge({ | ||
label: 'galaxytoolshed', | ||
message: 'requirement not found', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.