packages/cli/src/lib/types.ts 4.1 K raw
1
export interface FrontmatterMapping {
2
	title?: string; // Field name for title (default: "title")
3
	description?: string; // Field name for description (default: "description")
4
	publishDate?: string; // Field name for publish date (default: "publishDate", also checks "pubDate", "date", "createdAt", "created_at")
5
	coverImage?: string; // Field name for cover image (default: "ogImage")
6
	tags?: string; // Field name for tags (default: "tags")
7
	draft?: string; // Field name for draft status (default: "draft")
8
	slugField?: string; // Frontmatter field to use for slug (if set, uses frontmatter value; otherwise uses filepath)
9
}
10
11
// Strong reference for Bluesky post (com.atproto.repo.strongRef)
12
export interface StrongRef {
13
	uri: string; // at:// URI format
14
	cid: string; // Content ID
15
}
16
17
// Bluesky posting configuration
18
export interface BlueskyConfig {
19
	enabled: boolean;
20
	maxAgeDays?: number; // Only post if published within N days (default: 7)
21
}
22
23
// UI components configuration
24
export interface UIConfig {
25
	components: string; // Directory to install UI components (default: src/components)
26
}
27
28
export interface PublisherConfig {
29
	siteUrl: string;
30
	contentDir: string;
31
	imagesDir?: string; // Directory containing cover images
32
	publicDir?: string; // Static/public folder for .well-known files (default: public)
33
	outputDir?: string; // Built output directory for inject command
34
	pathPrefix?: string; // URL path prefix for posts (default: /posts)
35
	publicationUri: string;
36
	pdsUrl?: string;
37
	identity?: string; // Which stored identity to use (matches identifier)
38
	frontmatter?: FrontmatterMapping; // Custom frontmatter field mappings
39
	ignore?: string[]; // Glob patterns for files to ignore (e.g., ["_index.md", "**/drafts/**"])
40
	removeIndexFromSlug?: boolean; // Remove "/index" or "/_index" suffix from paths (default: false)
41
	stripDatePrefix?: boolean; // Remove YYYY-MM-DD- prefix from filenames (Jekyll-style, default: false)
42
	textContentField?: string; // Frontmatter field to use for textContent instead of markdown body
43
	bluesky?: BlueskyConfig; // Optional Bluesky posting configuration
44
	ui?: UIConfig; // Optional UI components configuration
45
}
46
47
// Legacy credentials format (for backward compatibility during migration)
48
export interface LegacyCredentials {
49
	pdsUrl: string;
50
	identifier: string;
51
	password: string;
52
}
53
54
// App password credentials (explicit type)
55
export interface AppPasswordCredentials {
56
	type: "app-password";
57
	pdsUrl: string;
58
	identifier: string;
59
	password: string;
60
}
61
62
// OAuth credentials (references stored OAuth session)
63
// Note: pdsUrl is not needed for OAuth - the OAuth client resolves PDS from the DID
64
export interface OAuthCredentials {
65
	type: "oauth";
66
	did: string;
67
	handle: string;
68
}
69
70
// Union type for all credential types
71
export type Credentials = AppPasswordCredentials | OAuthCredentials;
72
73
// Helper to check credential type
74
export function isOAuthCredentials(
75
	creds: Credentials,
76
): creds is OAuthCredentials {
77
	return creds.type === "oauth";
78
}
79
80
export function isAppPasswordCredentials(
81
	creds: Credentials,
82
): creds is AppPasswordCredentials {
83
	return creds.type === "app-password";
84
}
85
86
export interface PostFrontmatter {
87
	title: string;
88
	description?: string;
89
	publishDate: string;
90
	tags?: string[];
91
	ogImage?: string;
92
	atUri?: string;
93
	draft?: boolean;
94
}
95
96
export interface BlogPost {
97
	filePath: string;
98
	slug: string;
99
	frontmatter: PostFrontmatter;
100
	content: string;
101
	rawContent: string;
102
	rawFrontmatter: Record<string, unknown>; // For accessing custom fields like textContentField
103
}
104
105
export interface BlobRef {
106
	$link: string;
107
}
108
109
export interface BlobObject {
110
	$type: "blob";
111
	ref: BlobRef;
112
	mimeType: string;
113
	size: number;
114
}
115
116
export interface PublisherState {
117
	posts: Record<string, PostState>;
118
}
119
120
export interface PostState {
121
	contentHash: string;
122
	atUri?: string;
123
	lastPublished?: string;
124
	slug?: string; // The generated slug for this post (used by inject command)
125
	bskyPostRef?: StrongRef; // Reference to corresponding Bluesky post
126
}
127
128
export interface PublicationRecord {
129
	$type: "site.standard.publication";
130
	url: string;
131
	name: string;
132
	description?: string;
133
	icon?: BlobObject;
134
	createdAt: string;
135
	preferences?: {
136
		showInDiscover?: boolean;
137
	};
138
}