-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type definitions for new label system
- Loading branch information
1 parent
8c64297
commit 531a6bf
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
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,30 @@ | ||
import { array, defaulted, number, object, record, string, type Infer } from 'superstruct'; | ||
import { Label } from './label'; | ||
|
||
export const Classifier = object({ | ||
/** User-facing name of the classifier */ | ||
name: string(), | ||
|
||
/** Short description of the classifier */ | ||
description: string(), | ||
|
||
/** Ordering - higher values are placed earlier in lists */ | ||
sort: defaulted(number(), 0), | ||
|
||
// Components not from info.json (added during load) | ||
// ================================================== | ||
|
||
/** Slug of classifier, added during parsing */ | ||
slug: string(), | ||
|
||
/** `README.md` of classifier, added during parsing */ | ||
readme: string(), | ||
|
||
/** Labels within this classifier */ | ||
labels: record(string(), Label), | ||
|
||
/** Sort order for labels within this classifier */ | ||
labelOrder: array(string()), | ||
}); | ||
|
||
export type TClassifier = Infer<typeof Classifier>; |
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,80 @@ | ||
import { | ||
defaulted, | ||
number, | ||
object, | ||
string, | ||
record, | ||
array, | ||
optional, | ||
boolean, | ||
type Infer, | ||
} from 'superstruct'; | ||
|
||
export const Label = object({ | ||
/** User-facing name of the label */ | ||
name: string(), | ||
|
||
/** Short description of the label */ | ||
description: string(), | ||
|
||
/** Ordering - higher values are placed earlier in lists */ | ||
sort: defaulted(number(), 0), | ||
|
||
/** Color to use when representing the label */ | ||
color: string(), | ||
|
||
/** | ||
* Used to associate this label with other categories. | ||
* | ||
* * Each key should be a classifier within the project. | ||
* * Each value should be an array of labels within that classifier, which | ||
* should be associated with this label. | ||
*/ | ||
associations: defaulted( | ||
record(string(), array(string())), | ||
{}, | ||
), | ||
|
||
/** URLs associated with the label */ | ||
links: defaulted( | ||
object({ | ||
/** URL of the source repository of the label */ | ||
repo: optional(string()), | ||
|
||
/** URL of the site demonstrating the label */ | ||
site: optional(string()), | ||
|
||
/** URL of the documentation site for the label */ | ||
docs: optional(string()), | ||
}), | ||
{}, | ||
), | ||
|
||
/** Information about the package distribution of the label */ | ||
package: optional(object({ | ||
/** Installation command */ | ||
command: string(), | ||
/** URL for viewing the label's package listing */ | ||
url: string(), | ||
})), | ||
|
||
// Components not from info.json (added during load) | ||
// ================================================== | ||
|
||
/** Slug of label, added during loading */ | ||
slug: string(), | ||
|
||
/** `README.md` of label, added during loading */ | ||
readme: string(), | ||
|
||
/** Whether the label has an asciinema demo in `demo.cast` */ | ||
hasDemo: boolean(), | ||
|
||
/** Whether the label has an icon in `icon.png` */ | ||
hasIcon: boolean(), | ||
|
||
/** Whether the label has a banner image in `banner.png` */ | ||
hasBanner: boolean(), | ||
}); | ||
|
||
export type TLabel = Infer<typeof Label>; |