Skip to content

Commit 2c9adab

Browse files
authored
Preserve multi-source provider provenance (#17)
1 parent c82595e commit 2c9adab

17 files changed

Lines changed: 346 additions & 41 deletions

File tree

‎Cargo.lock‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ serde_json = "=1.0.151"
1515
sha2 = "=0.11.0"
1616
stack-compiler = { git = "https://github.com/stack-sh/compiler.git", rev = "4a18fac42afc2256a1bb3a6ff13d12d732a391e7" }
1717
stack-formatter = { path = "crates/stack-formatter" }
18-
stack-theme = { git = "https://github.com/stack-sh/theme.git", rev = "2347315e6e86ab9d2708e05fd3f9b5f3d87e1241" }
18+
stack-theme = { git = "https://github.com/stack-sh/theme.git", rev = "7e208d6a3c90d255799f390a4e8b86248c73caee" }

‎crates/stack-engine-wasm/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stack-engine-wasm"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
edition.workspace = true
55
rust-version.workspace = true
66
license.workspace = true

‎crates/stack-engine-wasm/src/lib.rs‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ pub struct ProviderNotice {
7070
pub archive_sha256: String,
7171
/// Provider terms URL.
7272
pub terms_url: String,
73+
/// Every audited archive that contributed to this pack.
74+
pub sources: Vec<ProviderNoticeSource>,
7375
/// User-visible attribution.
7476
pub attribution: String,
7577
/// User-visible terms summary.
@@ -88,6 +90,30 @@ pub struct ProviderNoticeIcon {
8890
pub id: String,
8991
/// Official provider product name.
9092
pub product_name: String,
93+
/// Rights-owner source for this brand icon, when the archive is multi-brand.
94+
#[serde(skip_serializing_if = "Option::is_none")]
95+
pub brand_source_url: Option<String>,
96+
/// Rights-owner usage guidelines for this brand icon, when available.
97+
#[serde(skip_serializing_if = "Option::is_none")]
98+
pub brand_guidelines_url: Option<String>,
99+
/// Pack-local source ID, or `primary` for the primary source.
100+
pub source_id: String,
101+
}
102+
103+
/// JavaScript-facing audited provider source.
104+
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
105+
#[serde(rename_all = "camelCase")]
106+
pub struct ProviderNoticeSource {
107+
/// Pack-local source ID.
108+
pub id: String,
109+
/// Official source page.
110+
pub page_url: String,
111+
/// Audited upstream release identifier.
112+
pub release: String,
113+
/// Complete official source archive SHA-256.
114+
pub archive_sha256: String,
115+
/// Terms reviewed for this source.
116+
pub terms_url: String,
91117
}
92118

93119
#[derive(Deserialize)]
@@ -305,6 +331,11 @@ impl From<stack_engine::ProviderNotice> for ProviderNotice {
305331
source_release: notice.source_release,
306332
archive_sha256: notice.archive_sha256,
307333
terms_url: notice.terms_url,
334+
sources: notice
335+
.sources
336+
.into_iter()
337+
.map(ProviderNoticeSource::from)
338+
.collect(),
308339
attribution: notice.attribution,
309340
terms_summary: notice.terms_summary,
310341
non_endorsement: notice.non_endorsement,
@@ -322,6 +353,21 @@ impl From<stack_engine::ProviderNoticeIcon> for ProviderNoticeIcon {
322353
Self {
323354
id: icon.id,
324355
product_name: icon.product_name,
356+
brand_source_url: icon.brand_source_url,
357+
brand_guidelines_url: icon.brand_guidelines_url,
358+
source_id: icon.source_id,
359+
}
360+
}
361+
}
362+
363+
impl From<stack_engine::ProviderNoticeSource> for ProviderNoticeSource {
364+
fn from(source: stack_engine::ProviderNoticeSource) -> Self {
365+
Self {
366+
id: source.id,
367+
page_url: source.page_url,
368+
release: source.release,
369+
archive_sha256: source.archive_sha256,
370+
terms_url: source.terms_url,
325371
}
326372
}
327373
}
@@ -466,6 +512,17 @@ export interface RenderResult {
466512
export interface ProviderNoticeIcon {
467513
readonly id: string;
468514
readonly productName: string;
515+
readonly brandSourceUrl?: string;
516+
readonly brandGuidelinesUrl?: string;
517+
readonly sourceId: string;
518+
}
519+
520+
export interface ProviderNoticeSource {
521+
readonly id: string;
522+
readonly pageUrl: string;
523+
readonly release: string;
524+
readonly archiveSha256: string;
525+
readonly termsUrl: string;
469526
}
470527
471528
export interface ProviderNotice {
@@ -476,6 +533,7 @@ export interface ProviderNotice {
476533
readonly sourceRelease: string;
477534
readonly archiveSha256: string;
478535
readonly termsUrl: string;
536+
readonly sources: readonly ProviderNoticeSource[];
479537
readonly attribution: string;
480538
readonly termsSummary: string;
481539
readonly nonEndorsement: string;
@@ -631,6 +689,17 @@ fn provider_notices_to_js(notices: Vec<ProviderNotice>) -> Result<JsValue, JsVal
631689
set(&item, "sourceRelease", notice.source_release.into())?;
632690
set(&item, "archiveSha256", notice.archive_sha256.into())?;
633691
set(&item, "termsUrl", notice.terms_url.into())?;
692+
let sources = Array::new();
693+
for source in notice.sources {
694+
let source_item = Object::new();
695+
set(&source_item, "id", source.id.into())?;
696+
set(&source_item, "pageUrl", source.page_url.into())?;
697+
set(&source_item, "release", source.release.into())?;
698+
set(&source_item, "archiveSha256", source.archive_sha256.into())?;
699+
set(&source_item, "termsUrl", source.terms_url.into())?;
700+
sources.push(&source_item);
701+
}
702+
set(&item, "sources", sources.into())?;
634703
set(&item, "attribution", notice.attribution.into())?;
635704
set(&item, "termsSummary", notice.terms_summary.into())?;
636705
set(&item, "nonEndorsement", notice.non_endorsement.into())?;
@@ -639,6 +708,17 @@ fn provider_notices_to_js(notices: Vec<ProviderNotice>) -> Result<JsValue, JsVal
639708
let icon_item = Object::new();
640709
set(&icon_item, "id", icon.id.into())?;
641710
set(&icon_item, "productName", icon.product_name.into())?;
711+
if let Some(brand_source_url) = icon.brand_source_url {
712+
set(&icon_item, "brandSourceUrl", brand_source_url.into())?;
713+
}
714+
if let Some(brand_guidelines_url) = icon.brand_guidelines_url {
715+
set(
716+
&icon_item,
717+
"brandGuidelinesUrl",
718+
brand_guidelines_url.into(),
719+
)?;
720+
}
721+
set(&icon_item, "sourceId", icon.source_id.into())?;
642722
icons.push(&icon_item);
643723
}
644724
set(&item, "icons", icons.into())?;

‎crates/stack-engine/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stack-engine"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
edition.workspace = true
55
rust-version.workspace = true
66
license.workspace = true

‎crates/stack-engine/src/lib.rs‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ pub struct ProviderNotice {
448448
pub archive_sha256: String,
449449
/// Provider terms reviewed for this pack.
450450
pub terms_url: String,
451+
/// Every audited archive that contributed an icon to this pack.
452+
pub sources: Vec<ProviderNoticeSource>,
451453
/// User-visible attribution text.
452454
pub attribution: String,
453455
/// User-visible terms summary.
@@ -465,6 +467,27 @@ pub struct ProviderNoticeIcon {
465467
pub id: String,
466468
/// Official provider product name.
467469
pub product_name: String,
470+
/// Rights-owner source for this brand icon, when the archive is multi-brand.
471+
pub brand_source_url: Option<String>,
472+
/// Rights-owner usage guidelines for this brand icon, when available.
473+
pub brand_guidelines_url: Option<String>,
474+
/// Pack-local source ID, or `primary` for the primary source.
475+
pub source_id: String,
476+
}
477+
478+
/// One audited archive listed in a rendered-artifact notice.
479+
#[derive(Debug, Clone, PartialEq, Eq)]
480+
pub struct ProviderNoticeSource {
481+
/// Pack-local source ID. The primary source always uses `primary`.
482+
pub id: String,
483+
/// Official source page.
484+
pub page_url: String,
485+
/// Audited upstream release identifier.
486+
pub release: String,
487+
/// Complete official source archive SHA-256.
488+
pub archive_sha256: String,
489+
/// Terms reviewed for this source.
490+
pub terms_url: String,
468491
}
469492

470493
/// Engine-owned portable diagnostic shared by native and future WASM outputs.
@@ -614,7 +637,7 @@ mod tests {
614637
output.metadata.language_version,
615638
Some(LanguageVersion { major: 1, minor: 0 })
616639
);
617-
assert_eq!(output.metadata.theme_catalog_version, "0.4.0");
640+
assert_eq!(output.metadata.theme_catalog_version, "0.5.0");
618641
assert_eq!(
619642
output.metadata.theme_catalog_revision,
620643
stack_theme::CATALOG_REVISION
@@ -658,10 +681,10 @@ mod tests {
658681
("ai", "Artificial intelligence system"),
659682
];
660683
let catalog = stack_theme::catalog();
661-
assert_eq!(catalog.catalog_version, "0.4.0");
684+
assert_eq!(catalog.catalog_version, "0.5.0");
662685
assert_eq!(
663686
stack_theme::CATALOG_REVISION,
664-
"sha256:9cb3de8b504acbf22c93cea5fbea66be50f38734dc1dee18b9cab7084082cc1f"
687+
"sha256:3bfd66e1a96628b29b95b7273b54373bcce952f7285aefa506b4255a629eaf53"
665688
);
666689
for theme in &catalog.themes {
667690
for (identifier, subject) in expected_icons {
@@ -680,7 +703,7 @@ mod tests {
680703
let rendered = Engine::bundled().render(source)?;
681704
assert!(checked.diagnostics.is_empty());
682705
assert!(rendered.diagnostics.is_empty());
683-
assert_eq!(rendered.metadata.theme_catalog_version, "0.4.0");
706+
assert_eq!(rendered.metadata.theme_catalog_version, "0.5.0");
684707
assert_eq!(
685708
rendered.metadata.theme_catalog_revision,
686709
stack_theme::CATALOG_REVISION

0 commit comments

Comments
 (0)