// @requirements REQ-PRODUCT-RETAINED-RELEASES
import {readFile} from 'node:fs/promises';
import {compileLegalDocuments,createRetainedReleaseFiles} from 'notabenda/content';
import {renderLegalLinks} from 'notabenda';
export async function retainedReleaseExample(){
const config=JSON.parse(await readFile(new URL('../static/notabenda.config.json',import.meta.url),'utf8'));config.site.id='juniper-releases';
for(const [kind,document] of Object.entries(config.documents))document.route=`/releases/${kind}`;
const first=compileLegalDocuments(config,{mode:'preview'});
config.documents.terms.version='draft-2';config.documents.terms.sections[1].paragraphs.push('This fictional revision clarifies that you can export your notes before leaving.');
const latest=compileLegalDocuments(config,{mode:'preview'});
const pinned=createRetainedReleaseFiles([first.artifact,latest.artifact],{siteId:config.site.id,mode:'preview'});
const oldId=first.manifest.artifactId,newId=latest.manifest.artifactId;
const files={...latest.files,...pinned,'releases/index.html':`
Notabenda · Retained releases
Retained document versions
A new deployment can serve your current terms while keeping the exact earlier version available to records that reference it.
Previous · draft-1
Previous version
The original HTML remains unchanged at its release URL. It is retained explicitly, even when the output directory starts empty.
Read the retained terms →
Compare the versions
Compare the two releases and inspect their wording in the host-authorized history workspace.
Review the terms comparison →
Build references
Previous release: ${oldId}
Current release: ${newId}
The build uses createRetainedReleaseFiles with public artifacts. Private Markdown/MDX source archives remain separate. The original HTML and links are preserved; linked assets and route redirects remain host responsibilities.
`};
const releases=[{artifact:first.artifact,metadata:{recordedAt:'2026-10-18T10:15:00Z',changeNote:'Initial fictional retained-release example.'}},{artifact:latest.artifact,metadata:{recordedAt:'2026-10-18T10:45:00Z',changeNote:'Clarify the fictional export provision; retain the previous public terms.'}}];
return {files,releases,first,latest};
}