Skip to main content

compmd_host/registry/
resolved.rs

1//! What a resolution gives ([the registry rules], decision 6): the releases for the request, the packs the size cap
2//! refuses, the built modules and the files a frame may load, by place, and what couldn't be got.
3//!
4//! [the registry rules]: https://github.com/comp-markdown/compmd/blob/main/docs/registry-rules.md
5
6use std::collections::BTreeMap;
7
8use compmd_pack::PackName;
9use semver::Version;
10use serde::{Deserialize, Serialize};
11
12/// A release for the request's packs, as the processor takes one (`PackRelease`).
13#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
14pub struct Release {
15    /// Its version.
16    pub version: Version,
17    /// The integrity its registry publishes, `null` for none.
18    pub integrity: Option<String>,
19    /// Its text files, by path; none for a release the processor refuses before it reads a pack.
20    pub files: BTreeMap<String, String>,
21    /// Why its files can't be used: its tarball doesn't match its integrity (F035).
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub broken: Option<String>,
24}
25
26/// A file a frame may load, an image or a font's file, with its media type.
27#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
28#[serde(rename_all = "camelCase")]
29pub struct FrameFile {
30    /// `image/svg+xml`, `font/woff2`.
31    pub media_type: String,
32    /// Its bytes.
33    pub bytes: Vec<u8>,
34}
35
36/// Something that couldn't be got, for the host's logs; the document is told by the processor's diagnostics.
37#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
38pub struct Problem {
39    /// The pack.
40    pub pack: PackName,
41    /// What happened.
42    pub message: String,
43}
44
45/// What a resolution gave.
46#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
47pub struct Resolved {
48    /// Every release it added, by pack.
49    pub releases: BTreeMap<PackName, Vec<Release>>,
50    /// The packs the size cap refuses, each with why.
51    pub refused: BTreeMap<PackName, String>,
52    /// Each built module's checked text, by its place, `@kit/mermaid@1.2.0/dist/mermaid.js`.
53    pub modules: BTreeMap<String, String>,
54    /// Each image and font's file of the packs it fetched, by its place.
55    pub files: BTreeMap<String, FrameFile>,
56    /// What couldn't be got.
57    pub problems: Vec<Problem>,
58}