packages/cli/src/lib/types.ts 4.2 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
	pathTemplate?: string; // URL path template with tokens like {year}/{month}/{day}/{slug} (overrides pathPrefix + slug)
43
	textContentField?: string; // Frontmatter field to use for textContent instead of markdown body
44
	bluesky?: BlueskyConfig; // Optional Bluesky posting configuration
45
	ui?: UIConfig; // Optional UI components configuration
46
}
47
48
// Legacy credentials format (for backward compatibility during migration)
49
export interface LegacyCredentials {
50
	pdsUrl: string;
51
	identifier: string;
52
	password: string;
53
}
54
55
// App password credentials (explicit type)
56
export interface AppPasswordCredentials {
57
	type: "app-password";
58
	pdsUrl: string;
59
	identifier: string;
60
	password: string;
61
}
62
63
// OAuth credentials (references stored OAuth session)
64
// Note: pdsUrl is not needed for OAuth - the OAuth client resolves PDS from the DID
65
export interface OAuthCredentials {
66
	type: "oauth";
67
	did: string;
68
	handle: string;
69
}
70
71
// Union type for all credential types
72
export type Credentials = AppPasswordCredentials | OAuthCredentials;
73
74
// Helper to check credential type
75
export function isOAuthCredentials(
76
	creds: Credentials,
77
): creds is OAuthCredentials {
78
	return creds.type === "oauth";
79
}
80
81
export function isAppPasswordCredentials(
82
	creds: Credentials,
83
): creds is AppPasswordCredentials {
84
	return creds.type === "app-password";
85
}
86
87
export interface PostFrontmatter {
88
	title: string;
89
	description?: string;
90
	bskyPost?: string;
91
	publishDate: string;
92
	tags?: string[];
93
	ogImage?: string;
94
	atUri?: string;
95
	draft?: boolean;
96
}
97
98
export interface BlogPost {
99
	filePath: string;
100
	slug: string;
101
	frontmatter: PostFrontmatter;
102
	content: string;
103
	rawContent: string;
104
	rawFrontmatter: Record<string, unknown>; // For accessing custom fields like textContentField
105
}
106
107
export interface BlobRef {
108
	$link: string;
109
}
110
111
export interface BlobObject {
112
	$type: "blob";
113
	ref: BlobRef;
114
	mimeType: string;
115
	size: number;
116
}
117
118
export interface PublisherState {
119
	posts: Record<string, PostState>;
120
}
121
122
export interface PostState {
123
	contentHash: string;
124
	atUri?: string;
125
	lastPublished?: string;
126
	slug?: string; // The generated slug for this post (used by inject command)
127
	bskyPostRef?: StrongRef; // Reference to corresponding Bluesky post
128
}
129
130
export interface PublicationRecord {
131
	$type: "site.standard.publication";
132
	url: string;
133
	name: string;
134
	description?: string;
135
	icon?: BlobObject;
136
	createdAt: string;
137
	preferences?: {
138
		showInDiscover?: boolean;
139
	};
140
}