autoblogger 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -5
- package/dist/index.d.mts +142 -2
- package/dist/index.d.ts +142 -2
- package/dist/index.js +4008 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3996 -129
- package/dist/index.mjs.map +1 -1
- package/dist/lib/rich-text.d.mts +82 -0
- package/dist/lib/rich-text.d.ts +82 -0
- package/dist/lib/rich-text.js +374 -0
- package/dist/lib/rich-text.js.map +1 -0
- package/dist/lib/rich-text.mjs +347 -0
- package/dist/lib/rich-text.mjs.map +1 -0
- package/dist/styles/autoblogger.css +1 -280
- package/dist/styles/standalone.css +1 -1
- package/dist/ui.d.mts +1 -0
- package/dist/ui.d.ts +1 -0
- package/dist/ui.js +289 -17
- package/dist/ui.js.map +1 -1
- package/dist/ui.mjs +289 -17
- package/dist/ui.mjs.map +1 -1
- package/package.json +34 -12
- package/prisma/schema.prisma +10 -0
package/README.md
CHANGED
|
@@ -29,10 +29,13 @@ Visit `/writer` to start writing.
|
|
|
29
29
|
|
|
30
30
|
- **AI Writing** — Generate essays with Claude or GPT. Stream responses in real-time.
|
|
31
31
|
- **Chat Modes** — Ask questions, let AI edit directly (Agent mode), or generate outlines (Plan mode).
|
|
32
|
+
- **Web Search** — Ground AI responses with real-time web search (works with all models).
|
|
33
|
+
- **Thinking Mode** — Extended thinking for more thoughtful Claude responses.
|
|
32
34
|
- **WYSIWYG Editor** — Tiptap-based editor with formatting toolbar. Syncs to markdown.
|
|
33
35
|
- **Revision History** — Every save creates a revision. Browse and restore any version.
|
|
34
36
|
- **Inline Comments** — Highlight text and leave threaded comments.
|
|
35
37
|
- **RSS Auto-Draft** — Subscribe to feeds, filter by keywords, auto-generate drafts.
|
|
38
|
+
- **CMS Integrations** — Sync posts to Prismic, Contentful, Sanity, or custom destinations.
|
|
36
39
|
- **User Roles** — Admin, writer, and drafter with different permissions.
|
|
37
40
|
- **SEO Fields** — Custom title, description, keywords, and OG image per post.
|
|
38
41
|
|
|
@@ -132,16 +135,16 @@ npx autoblogger import ./posts # Import markdown files
|
|
|
132
135
|
| ⌘K | Toggle chat panel |
|
|
133
136
|
| ⌘⇧A | Toggle Ask/Agent mode |
|
|
134
137
|
| ⌘. | Toggle theme |
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
| Esc | Go back |
|
|
138
|
+
| ⌘S | Save draft |
|
|
139
|
+
| Esc | Go back / Stop generation |
|
|
138
140
|
|
|
139
141
|
## Package Exports
|
|
140
142
|
|
|
141
143
|
```typescript
|
|
142
144
|
// Server
|
|
143
|
-
import { createAutoblogger } from 'autoblogger'
|
|
144
|
-
import {
|
|
145
|
+
import { createAutoblogger, runAutoDraft } from 'autoblogger'
|
|
146
|
+
import { createDestinationDispatcher } from 'autoblogger'
|
|
147
|
+
import type { Destination, DestinationResult } from 'autoblogger'
|
|
145
148
|
|
|
146
149
|
// UI
|
|
147
150
|
import { AutobloggerDashboard } from 'autoblogger/ui'
|
|
@@ -151,6 +154,75 @@ import { ChatProvider, ChatPanel, ChatButton } from 'autoblogger/ui'
|
|
|
151
154
|
import { renderMarkdown, htmlToMarkdown } from 'autoblogger/markdown'
|
|
152
155
|
import { getSeoValues } from 'autoblogger/seo'
|
|
153
156
|
import { ARTICLE_CLASSES } from 'autoblogger/styles/article'
|
|
157
|
+
|
|
158
|
+
// Rich text converters (for custom destination adapters)
|
|
159
|
+
import {
|
|
160
|
+
markdownToPrismicRichText,
|
|
161
|
+
markdownToContentfulRichText,
|
|
162
|
+
markdownToPortableText,
|
|
163
|
+
} from 'autoblogger/rich-text'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## CMS Integrations
|
|
167
|
+
|
|
168
|
+
Autoblogger can sync published posts to external CMSs like Prismic, Contentful, or Sanity.
|
|
169
|
+
|
|
170
|
+
### Prismic (Built-in)
|
|
171
|
+
|
|
172
|
+
Configure Prismic integration via the Settings UI or in code:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
export const cms = createAutoblogger({
|
|
176
|
+
// ... other config
|
|
177
|
+
prismic: {
|
|
178
|
+
repository: 'your-repo',
|
|
179
|
+
writeToken: process.env.PRISMIC_WRITE_TOKEN,
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Then enable it in Settings → CMS Integrations → Prismic.
|
|
185
|
+
|
|
186
|
+
**Sync Modes:**
|
|
187
|
+
- **Stub** (default): Only syncs the post slug as UID. Content lives in autoblogger, Prismic stores references for collection slices.
|
|
188
|
+
- **Full**: Syncs complete content as Prismic rich text.
|
|
189
|
+
|
|
190
|
+
### Custom Destinations
|
|
191
|
+
|
|
192
|
+
Create custom adapters for any CMS:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import { createAutoblogger, type Destination } from 'autoblogger'
|
|
196
|
+
|
|
197
|
+
const myDestination: Destination = {
|
|
198
|
+
name: 'my-cms',
|
|
199
|
+
async onPublish(post) {
|
|
200
|
+
// Sync post to your CMS
|
|
201
|
+
return { success: true, externalId: 'doc-123' }
|
|
202
|
+
},
|
|
203
|
+
async onUnpublish(post) {
|
|
204
|
+
return { success: true }
|
|
205
|
+
},
|
|
206
|
+
async onDelete(post) {
|
|
207
|
+
return { success: true }
|
|
208
|
+
},
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export const cms = createAutoblogger({
|
|
212
|
+
// ... other config
|
|
213
|
+
destinations: [myDestination],
|
|
214
|
+
})
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Webhooks
|
|
218
|
+
|
|
219
|
+
Send POST requests to URLs when posts are published/unpublished/deleted:
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
export const cms = createAutoblogger({
|
|
223
|
+
// ... other config
|
|
224
|
+
webhooks: ['https://api.example.com/cms-webhook'],
|
|
225
|
+
})
|
|
154
226
|
```
|
|
155
227
|
|
|
156
228
|
## Styling
|
package/dist/index.d.mts
CHANGED
|
@@ -47,9 +47,126 @@ interface AutoDraftConfig {
|
|
|
47
47
|
*/
|
|
48
48
|
declare function runAutoDraft(config: AutoDraftConfig, topicId?: string, skipFrequencyCheck?: boolean): Promise<GenerationResult[]>;
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Result returned by a destination after handling an event
|
|
52
|
+
*/
|
|
53
|
+
interface DestinationResult {
|
|
54
|
+
/** Whether the operation succeeded */
|
|
55
|
+
success: boolean;
|
|
56
|
+
/** External ID assigned by the destination (e.g., Prismic document ID) */
|
|
57
|
+
externalId?: string;
|
|
58
|
+
/** Error message if the operation failed */
|
|
59
|
+
error?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A destination adapter that syncs posts to an external CMS or service.
|
|
63
|
+
*
|
|
64
|
+
* Implement this interface to create custom adapters for Prismic, Contentful,
|
|
65
|
+
* Sanity, or any other service.
|
|
66
|
+
*/
|
|
67
|
+
interface Destination {
|
|
68
|
+
/** Unique name for this destination (for logging/debugging) */
|
|
69
|
+
name: string;
|
|
70
|
+
/**
|
|
71
|
+
* Called when a post is published.
|
|
72
|
+
* Should create or update the post in the external service.
|
|
73
|
+
*/
|
|
74
|
+
onPublish(post: Post): Promise<DestinationResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Called when a post is unpublished (status changed from 'published' to 'draft').
|
|
77
|
+
* Should archive or unpublish the post in the external service.
|
|
78
|
+
*/
|
|
79
|
+
onUnpublish(post: Post): Promise<DestinationResult>;
|
|
80
|
+
/**
|
|
81
|
+
* Called when a post is deleted.
|
|
82
|
+
* Should remove the post from the external service.
|
|
83
|
+
*/
|
|
84
|
+
onDelete(post: Post): Promise<DestinationResult>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Event payload sent to webhooks
|
|
88
|
+
*/
|
|
89
|
+
interface DestinationEvent {
|
|
90
|
+
/** The type of event that occurred */
|
|
91
|
+
type: 'publish' | 'unpublish' | 'delete';
|
|
92
|
+
/** The post that triggered the event */
|
|
93
|
+
post: Post;
|
|
94
|
+
/** When the event occurred */
|
|
95
|
+
timestamp: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Configuration for the destination system
|
|
99
|
+
*/
|
|
100
|
+
interface DestinationsConfig {
|
|
101
|
+
/** Array of destination adapters to sync posts to */
|
|
102
|
+
destinations?: Destination[];
|
|
103
|
+
/** Webhook URLs to POST event payloads to */
|
|
104
|
+
webhooks?: string[];
|
|
105
|
+
/** Callback fired when a post is published */
|
|
106
|
+
onPublish?: (post: Post) => Promise<void>;
|
|
107
|
+
/** Callback fired when a post is unpublished */
|
|
108
|
+
onUnpublish?: (post: Post) => Promise<void>;
|
|
109
|
+
/** Callback fired when a post is deleted */
|
|
110
|
+
onDelete?: (post: Post) => Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Aggregated results from all destinations
|
|
114
|
+
*/
|
|
115
|
+
interface DispatchResult {
|
|
116
|
+
/** Results from each destination adapter */
|
|
117
|
+
destinations: Array<{
|
|
118
|
+
name: string;
|
|
119
|
+
result: DestinationResult;
|
|
120
|
+
}>;
|
|
121
|
+
/** Results from webhook calls */
|
|
122
|
+
webhooks: Array<{
|
|
123
|
+
url: string;
|
|
124
|
+
success: boolean;
|
|
125
|
+
error?: string;
|
|
126
|
+
}>;
|
|
127
|
+
/** Whether all operations succeeded */
|
|
128
|
+
allSucceeded: boolean;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface DispatcherConfig {
|
|
132
|
+
destinations?: Destination[];
|
|
133
|
+
webhooks?: string[];
|
|
134
|
+
onPublish?: (post: Post) => Promise<void>;
|
|
135
|
+
onUnpublish?: (post: Post) => Promise<void>;
|
|
136
|
+
onDelete?: (post: Post) => Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Creates a destination dispatcher that fires events to adapters, webhooks, and callbacks.
|
|
140
|
+
*/
|
|
141
|
+
declare function createDestinationDispatcher(config: DispatcherConfig): {
|
|
142
|
+
/**
|
|
143
|
+
* Dispatch a publish event to all destinations
|
|
144
|
+
*/
|
|
145
|
+
publish(post: Post): Promise<DispatchResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Dispatch an unpublish event to all destinations
|
|
148
|
+
*/
|
|
149
|
+
unpublish(post: Post): Promise<DispatchResult>;
|
|
150
|
+
/**
|
|
151
|
+
* Dispatch a delete event to all destinations
|
|
152
|
+
*/
|
|
153
|
+
delete(post: Post): Promise<DispatchResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Check if any destinations or webhooks are configured
|
|
156
|
+
*/
|
|
157
|
+
readonly hasDestinations: boolean;
|
|
158
|
+
};
|
|
159
|
+
type DestinationDispatcher = ReturnType<typeof createDestinationDispatcher>;
|
|
160
|
+
|
|
50
161
|
interface PostHooks {
|
|
51
162
|
beforePublish?: (post: Post) => Promise<void>;
|
|
52
163
|
afterSave?: (post: Post) => Promise<void>;
|
|
164
|
+
/** Called when a slug changes on a post that was previously published. Used to create redirects. */
|
|
165
|
+
onSlugChange?: (data: {
|
|
166
|
+
postId: string;
|
|
167
|
+
oldSlug: string;
|
|
168
|
+
newSlug: string;
|
|
169
|
+
}) => Promise<void>;
|
|
53
170
|
}
|
|
54
171
|
interface CreatePostInput {
|
|
55
172
|
title: string;
|
|
@@ -68,7 +185,7 @@ interface UpdatePostInput {
|
|
|
68
185
|
publishedAt?: Date;
|
|
69
186
|
[key: string]: unknown;
|
|
70
187
|
}
|
|
71
|
-
declare function createPostsData(prisma: any, hooks?: PostHooks): {
|
|
188
|
+
declare function createPostsData(prisma: any, hooks?: PostHooks, dispatcher?: DestinationDispatcher, prismicEnvToken?: string): {
|
|
72
189
|
count(where?: {
|
|
73
190
|
status?: string;
|
|
74
191
|
}): Promise<any>;
|
|
@@ -353,6 +470,13 @@ interface AutobloggerServerConfig {
|
|
|
353
470
|
anthropicKey?: string;
|
|
354
471
|
openaiKey?: string;
|
|
355
472
|
};
|
|
473
|
+
/** Prismic integration config (passed from host app) */
|
|
474
|
+
prismic?: {
|
|
475
|
+
/** Repository name (e.g., 'my-repo') - auto-fills the settings UI */
|
|
476
|
+
repository?: string;
|
|
477
|
+
/** Write API token from env */
|
|
478
|
+
writeToken?: string;
|
|
479
|
+
};
|
|
356
480
|
storage?: {
|
|
357
481
|
upload: (file: File) => Promise<{
|
|
358
482
|
url: string;
|
|
@@ -365,6 +489,12 @@ interface AutobloggerServerConfig {
|
|
|
365
489
|
hooks?: {
|
|
366
490
|
beforePublish?: (post: Post) => Promise<void>;
|
|
367
491
|
afterSave?: (post: Post) => Promise<void>;
|
|
492
|
+
/** Called when a slug changes on a post that was previously published. Used to create redirects. */
|
|
493
|
+
onSlugChange?: (data: {
|
|
494
|
+
postId: string;
|
|
495
|
+
oldSlug: string;
|
|
496
|
+
newSlug: string;
|
|
497
|
+
}) => Promise<void>;
|
|
368
498
|
/** Called during auto-draft after generating essay, return extra fields for post creation */
|
|
369
499
|
onAutoDraftPostCreate?: (article: RssArticle, essay: {
|
|
370
500
|
title: string;
|
|
@@ -372,6 +502,16 @@ interface AutobloggerServerConfig {
|
|
|
372
502
|
markdown: string;
|
|
373
503
|
}) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
374
504
|
};
|
|
505
|
+
/** Array of destination adapters to sync posts to (Prismic, Contentful, etc.) */
|
|
506
|
+
destinations?: Destination[];
|
|
507
|
+
/** Webhook URLs to POST event payloads to when posts are published/unpublished/deleted */
|
|
508
|
+
webhooks?: string[];
|
|
509
|
+
/** Callback fired when a post is published */
|
|
510
|
+
onPublish?: (post: Post) => Promise<void>;
|
|
511
|
+
/** Callback fired when a post is unpublished */
|
|
512
|
+
onUnpublish?: (post: Post) => Promise<void>;
|
|
513
|
+
/** Callback fired when a post is deleted */
|
|
514
|
+
onDelete?: (post: Post) => Promise<void>;
|
|
375
515
|
}
|
|
376
516
|
|
|
377
517
|
interface AutobloggerServer {
|
|
@@ -679,4 +819,4 @@ declare function applyCommentMarks(editor: Editor, comments: CommentWithUser[]):
|
|
|
679
819
|
*/
|
|
680
820
|
declare function scrollToComment(editor: Editor, commentId: string): void;
|
|
681
821
|
|
|
682
|
-
export { type AIModel, AI_MODELS, type AutoDraftConfig, type AutobloggerServer as Autoblogger, type AutobloggerServerConfig as AutobloggerConfig, type BaseCrud, CommentMark, type CommentWithUser, type CreateCommentData, type CrudOptions, type CustomFieldConfig, type CustomFieldProps, DEFAULT_AUTO_DRAFT_TEMPLATE, DEFAULT_CHAT_TEMPLATE, DEFAULT_EXPAND_PLAN_TEMPLATE, DEFAULT_GENERATE_TEMPLATE, DEFAULT_PLAN_RULES, DEFAULT_PLAN_TEMPLATE, DEFAULT_REWRITE_TEMPLATE, type GenerationResult, Post, type RssArticle, type SelectionState, type Session, type StylesConfig, addCommentMark, applyCommentMarks, buildAutoDraftPrompt, buildChatPrompt, buildExpandPlanPrompt, buildGeneratePrompt, buildPlanPrompt, buildRewritePrompt, canDeleteComment, canEditComment, createAPIHandler, createAutoblogger, createCommentsClient, createCrudData, fetchRssFeeds, filterByKeywords, formatDate, generate, getDefaultModel, getModel, parseGeneratedContent, removeCommentMark, resolveModel, runAutoDraft, scrollToComment, truncate, validateSchema };
|
|
822
|
+
export { type AIModel, AI_MODELS, type AutoDraftConfig, type AutobloggerServer as Autoblogger, type AutobloggerServerConfig as AutobloggerConfig, type BaseCrud, CommentMark, type CommentWithUser, type CreateCommentData, type CrudOptions, type CustomFieldConfig, type CustomFieldProps, DEFAULT_AUTO_DRAFT_TEMPLATE, DEFAULT_CHAT_TEMPLATE, DEFAULT_EXPAND_PLAN_TEMPLATE, DEFAULT_GENERATE_TEMPLATE, DEFAULT_PLAN_RULES, DEFAULT_PLAN_TEMPLATE, DEFAULT_REWRITE_TEMPLATE, type Destination, type DestinationDispatcher, type DestinationEvent, type DestinationResult, type DestinationsConfig, type DispatchResult, type DispatcherConfig, type GenerationResult, Post, type RssArticle, type SelectionState, type Session, type StylesConfig, addCommentMark, applyCommentMarks, buildAutoDraftPrompt, buildChatPrompt, buildExpandPlanPrompt, buildGeneratePrompt, buildPlanPrompt, buildRewritePrompt, canDeleteComment, canEditComment, createAPIHandler, createAutoblogger, createCommentsClient, createCrudData, createDestinationDispatcher, fetchRssFeeds, filterByKeywords, formatDate, generate, getDefaultModel, getModel, parseGeneratedContent, removeCommentMark, resolveModel, runAutoDraft, scrollToComment, truncate, validateSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,9 +47,126 @@ interface AutoDraftConfig {
|
|
|
47
47
|
*/
|
|
48
48
|
declare function runAutoDraft(config: AutoDraftConfig, topicId?: string, skipFrequencyCheck?: boolean): Promise<GenerationResult[]>;
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Result returned by a destination after handling an event
|
|
52
|
+
*/
|
|
53
|
+
interface DestinationResult {
|
|
54
|
+
/** Whether the operation succeeded */
|
|
55
|
+
success: boolean;
|
|
56
|
+
/** External ID assigned by the destination (e.g., Prismic document ID) */
|
|
57
|
+
externalId?: string;
|
|
58
|
+
/** Error message if the operation failed */
|
|
59
|
+
error?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A destination adapter that syncs posts to an external CMS or service.
|
|
63
|
+
*
|
|
64
|
+
* Implement this interface to create custom adapters for Prismic, Contentful,
|
|
65
|
+
* Sanity, or any other service.
|
|
66
|
+
*/
|
|
67
|
+
interface Destination {
|
|
68
|
+
/** Unique name for this destination (for logging/debugging) */
|
|
69
|
+
name: string;
|
|
70
|
+
/**
|
|
71
|
+
* Called when a post is published.
|
|
72
|
+
* Should create or update the post in the external service.
|
|
73
|
+
*/
|
|
74
|
+
onPublish(post: Post): Promise<DestinationResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Called when a post is unpublished (status changed from 'published' to 'draft').
|
|
77
|
+
* Should archive or unpublish the post in the external service.
|
|
78
|
+
*/
|
|
79
|
+
onUnpublish(post: Post): Promise<DestinationResult>;
|
|
80
|
+
/**
|
|
81
|
+
* Called when a post is deleted.
|
|
82
|
+
* Should remove the post from the external service.
|
|
83
|
+
*/
|
|
84
|
+
onDelete(post: Post): Promise<DestinationResult>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Event payload sent to webhooks
|
|
88
|
+
*/
|
|
89
|
+
interface DestinationEvent {
|
|
90
|
+
/** The type of event that occurred */
|
|
91
|
+
type: 'publish' | 'unpublish' | 'delete';
|
|
92
|
+
/** The post that triggered the event */
|
|
93
|
+
post: Post;
|
|
94
|
+
/** When the event occurred */
|
|
95
|
+
timestamp: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Configuration for the destination system
|
|
99
|
+
*/
|
|
100
|
+
interface DestinationsConfig {
|
|
101
|
+
/** Array of destination adapters to sync posts to */
|
|
102
|
+
destinations?: Destination[];
|
|
103
|
+
/** Webhook URLs to POST event payloads to */
|
|
104
|
+
webhooks?: string[];
|
|
105
|
+
/** Callback fired when a post is published */
|
|
106
|
+
onPublish?: (post: Post) => Promise<void>;
|
|
107
|
+
/** Callback fired when a post is unpublished */
|
|
108
|
+
onUnpublish?: (post: Post) => Promise<void>;
|
|
109
|
+
/** Callback fired when a post is deleted */
|
|
110
|
+
onDelete?: (post: Post) => Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Aggregated results from all destinations
|
|
114
|
+
*/
|
|
115
|
+
interface DispatchResult {
|
|
116
|
+
/** Results from each destination adapter */
|
|
117
|
+
destinations: Array<{
|
|
118
|
+
name: string;
|
|
119
|
+
result: DestinationResult;
|
|
120
|
+
}>;
|
|
121
|
+
/** Results from webhook calls */
|
|
122
|
+
webhooks: Array<{
|
|
123
|
+
url: string;
|
|
124
|
+
success: boolean;
|
|
125
|
+
error?: string;
|
|
126
|
+
}>;
|
|
127
|
+
/** Whether all operations succeeded */
|
|
128
|
+
allSucceeded: boolean;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface DispatcherConfig {
|
|
132
|
+
destinations?: Destination[];
|
|
133
|
+
webhooks?: string[];
|
|
134
|
+
onPublish?: (post: Post) => Promise<void>;
|
|
135
|
+
onUnpublish?: (post: Post) => Promise<void>;
|
|
136
|
+
onDelete?: (post: Post) => Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Creates a destination dispatcher that fires events to adapters, webhooks, and callbacks.
|
|
140
|
+
*/
|
|
141
|
+
declare function createDestinationDispatcher(config: DispatcherConfig): {
|
|
142
|
+
/**
|
|
143
|
+
* Dispatch a publish event to all destinations
|
|
144
|
+
*/
|
|
145
|
+
publish(post: Post): Promise<DispatchResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Dispatch an unpublish event to all destinations
|
|
148
|
+
*/
|
|
149
|
+
unpublish(post: Post): Promise<DispatchResult>;
|
|
150
|
+
/**
|
|
151
|
+
* Dispatch a delete event to all destinations
|
|
152
|
+
*/
|
|
153
|
+
delete(post: Post): Promise<DispatchResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Check if any destinations or webhooks are configured
|
|
156
|
+
*/
|
|
157
|
+
readonly hasDestinations: boolean;
|
|
158
|
+
};
|
|
159
|
+
type DestinationDispatcher = ReturnType<typeof createDestinationDispatcher>;
|
|
160
|
+
|
|
50
161
|
interface PostHooks {
|
|
51
162
|
beforePublish?: (post: Post) => Promise<void>;
|
|
52
163
|
afterSave?: (post: Post) => Promise<void>;
|
|
164
|
+
/** Called when a slug changes on a post that was previously published. Used to create redirects. */
|
|
165
|
+
onSlugChange?: (data: {
|
|
166
|
+
postId: string;
|
|
167
|
+
oldSlug: string;
|
|
168
|
+
newSlug: string;
|
|
169
|
+
}) => Promise<void>;
|
|
53
170
|
}
|
|
54
171
|
interface CreatePostInput {
|
|
55
172
|
title: string;
|
|
@@ -68,7 +185,7 @@ interface UpdatePostInput {
|
|
|
68
185
|
publishedAt?: Date;
|
|
69
186
|
[key: string]: unknown;
|
|
70
187
|
}
|
|
71
|
-
declare function createPostsData(prisma: any, hooks?: PostHooks): {
|
|
188
|
+
declare function createPostsData(prisma: any, hooks?: PostHooks, dispatcher?: DestinationDispatcher, prismicEnvToken?: string): {
|
|
72
189
|
count(where?: {
|
|
73
190
|
status?: string;
|
|
74
191
|
}): Promise<any>;
|
|
@@ -353,6 +470,13 @@ interface AutobloggerServerConfig {
|
|
|
353
470
|
anthropicKey?: string;
|
|
354
471
|
openaiKey?: string;
|
|
355
472
|
};
|
|
473
|
+
/** Prismic integration config (passed from host app) */
|
|
474
|
+
prismic?: {
|
|
475
|
+
/** Repository name (e.g., 'my-repo') - auto-fills the settings UI */
|
|
476
|
+
repository?: string;
|
|
477
|
+
/** Write API token from env */
|
|
478
|
+
writeToken?: string;
|
|
479
|
+
};
|
|
356
480
|
storage?: {
|
|
357
481
|
upload: (file: File) => Promise<{
|
|
358
482
|
url: string;
|
|
@@ -365,6 +489,12 @@ interface AutobloggerServerConfig {
|
|
|
365
489
|
hooks?: {
|
|
366
490
|
beforePublish?: (post: Post) => Promise<void>;
|
|
367
491
|
afterSave?: (post: Post) => Promise<void>;
|
|
492
|
+
/** Called when a slug changes on a post that was previously published. Used to create redirects. */
|
|
493
|
+
onSlugChange?: (data: {
|
|
494
|
+
postId: string;
|
|
495
|
+
oldSlug: string;
|
|
496
|
+
newSlug: string;
|
|
497
|
+
}) => Promise<void>;
|
|
368
498
|
/** Called during auto-draft after generating essay, return extra fields for post creation */
|
|
369
499
|
onAutoDraftPostCreate?: (article: RssArticle, essay: {
|
|
370
500
|
title: string;
|
|
@@ -372,6 +502,16 @@ interface AutobloggerServerConfig {
|
|
|
372
502
|
markdown: string;
|
|
373
503
|
}) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
374
504
|
};
|
|
505
|
+
/** Array of destination adapters to sync posts to (Prismic, Contentful, etc.) */
|
|
506
|
+
destinations?: Destination[];
|
|
507
|
+
/** Webhook URLs to POST event payloads to when posts are published/unpublished/deleted */
|
|
508
|
+
webhooks?: string[];
|
|
509
|
+
/** Callback fired when a post is published */
|
|
510
|
+
onPublish?: (post: Post) => Promise<void>;
|
|
511
|
+
/** Callback fired when a post is unpublished */
|
|
512
|
+
onUnpublish?: (post: Post) => Promise<void>;
|
|
513
|
+
/** Callback fired when a post is deleted */
|
|
514
|
+
onDelete?: (post: Post) => Promise<void>;
|
|
375
515
|
}
|
|
376
516
|
|
|
377
517
|
interface AutobloggerServer {
|
|
@@ -679,4 +819,4 @@ declare function applyCommentMarks(editor: Editor, comments: CommentWithUser[]):
|
|
|
679
819
|
*/
|
|
680
820
|
declare function scrollToComment(editor: Editor, commentId: string): void;
|
|
681
821
|
|
|
682
|
-
export { type AIModel, AI_MODELS, type AutoDraftConfig, type AutobloggerServer as Autoblogger, type AutobloggerServerConfig as AutobloggerConfig, type BaseCrud, CommentMark, type CommentWithUser, type CreateCommentData, type CrudOptions, type CustomFieldConfig, type CustomFieldProps, DEFAULT_AUTO_DRAFT_TEMPLATE, DEFAULT_CHAT_TEMPLATE, DEFAULT_EXPAND_PLAN_TEMPLATE, DEFAULT_GENERATE_TEMPLATE, DEFAULT_PLAN_RULES, DEFAULT_PLAN_TEMPLATE, DEFAULT_REWRITE_TEMPLATE, type GenerationResult, Post, type RssArticle, type SelectionState, type Session, type StylesConfig, addCommentMark, applyCommentMarks, buildAutoDraftPrompt, buildChatPrompt, buildExpandPlanPrompt, buildGeneratePrompt, buildPlanPrompt, buildRewritePrompt, canDeleteComment, canEditComment, createAPIHandler, createAutoblogger, createCommentsClient, createCrudData, fetchRssFeeds, filterByKeywords, formatDate, generate, getDefaultModel, getModel, parseGeneratedContent, removeCommentMark, resolveModel, runAutoDraft, scrollToComment, truncate, validateSchema };
|
|
822
|
+
export { type AIModel, AI_MODELS, type AutoDraftConfig, type AutobloggerServer as Autoblogger, type AutobloggerServerConfig as AutobloggerConfig, type BaseCrud, CommentMark, type CommentWithUser, type CreateCommentData, type CrudOptions, type CustomFieldConfig, type CustomFieldProps, DEFAULT_AUTO_DRAFT_TEMPLATE, DEFAULT_CHAT_TEMPLATE, DEFAULT_EXPAND_PLAN_TEMPLATE, DEFAULT_GENERATE_TEMPLATE, DEFAULT_PLAN_RULES, DEFAULT_PLAN_TEMPLATE, DEFAULT_REWRITE_TEMPLATE, type Destination, type DestinationDispatcher, type DestinationEvent, type DestinationResult, type DestinationsConfig, type DispatchResult, type DispatcherConfig, type GenerationResult, Post, type RssArticle, type SelectionState, type Session, type StylesConfig, addCommentMark, applyCommentMarks, buildAutoDraftPrompt, buildChatPrompt, buildExpandPlanPrompt, buildGeneratePrompt, buildPlanPrompt, buildRewritePrompt, canDeleteComment, canEditComment, createAPIHandler, createAutoblogger, createCommentsClient, createCrudData, createDestinationDispatcher, fetchRssFeeds, filterByKeywords, formatDate, generate, getDefaultModel, getModel, parseGeneratedContent, removeCommentMark, resolveModel, runAutoDraft, scrollToComment, truncate, validateSchema };
|