import Joi from 'joi'
import { BaseJsonService } from '../index.js'
import { nonNegativeInteger } from '../validators.js'
const packageMetricsSchema = Joi.object({
downloads: nonNegativeInteger,
rating_score: nonNegativeInteger,
latest_version: Joi.string().required(),
})
const description = `
The Thunderstore badges require a package's namespace and name.
Everything can be discerned from your package's URL. Thunderstore package URLs have a mostly consistent format:
https://thunderstore.io/c/[community]/p/[namespace]/[packageName]
For example: https://thunderstore.io/c/lethal-company/p/notnotnotswipez/MoreCompany/.
namespace = "notnotnotswipez"packageName = "MoreCompany"https://thunderstore.io/package/[namespace]/[packageName]
:::
:::info[Subdomain Communities]
Some communities use a 'subdomain' alternative URL, for example, Valheim:
https://valheim.thunderstore.io/package/[namespace]/[packageName]
:::
`
/**
* Services which query Thunderstore endpoints should extend BaseThunderstoreService
*
* @abstract
*/
class BaseThunderstoreService extends BaseJsonService {
static thunderstoreGreen = '23FFB0'
/**
* Fetches package metrics from the Thunderstore API.
*
* @param {object} pkg - Package specifier
* @param {string} pkg.namespace - the package namespace
* @param {string} pkg.packageName - the package name
* @returns {Promise