Something went wrong. Try again.
My website. cameron.stream
Something went wrong. Try again.
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import { readFileSync } from "node:fs";import { resolve } from "node:path";import { TID } from "@atproto/common-web";import { isValidTid } from "@atproto/syntax";
export interface KnowledgeAtprotoManifestEntry { uri: string; cid: string; recordDigest: string; reviewedContentDigest: string; reviewReceiptDigest: string; pds: string; syncedAt: string;}
export interface KnowledgeAtprotoManifest { version: 2; publication: null | { uri: string; cid: string; recordDigest: string; showInDiscover: false; pds: string; syncedAt: string; }; entries: Record<string, KnowledgeAtprotoManifestEntry>;}
const MANIFEST_PATH = resolve(process.cwd(), "knowledge/atproto-manifest.json");
export function nextStandardSiteRkey(): string { return TID.nextStr();}
export function shouldValidateStandardSiteWrite(options: { collection: string; action: "create" | "update"; rkey: string;}): boolean { return !( options.collection === "site.standard.document" && options.action === "update" && !isValidTid(options.rkey) );}
export function loadKnowledgeAtprotoManifest(): KnowledgeAtprotoManifest { const manifest = JSON.parse(readFileSync(MANIFEST_PATH, "utf8")) as KnowledgeAtprotoManifest; if (manifest.version !== 2) { throw new Error(`Unsupported Knowledge ATProto manifest version: ${String(manifest.version)}`); } if (manifest.publication && manifest.publication.showInDiscover !== false) { throw new Error("Knowledge publication must explicitly remain out of discovery feeds"); } return manifest;}
export function getKnowledgePublicationUri(): string | undefined { return loadKnowledgeAtprotoManifest().publication?.uri;}
export function getKnowledgeDocumentUri(slug: string): string | undefined { return loadKnowledgeAtprotoManifest().entries[slug]?.uri;}