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