@bernierllc/content-management-nextjs 0.0.1 → 0.2.0

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.
@@ -0,0 +1,363 @@
1
+ /**
2
+ * Local type stubs matching the content management suite's interface contracts.
3
+ * These will be replaced by imports from @bernierllc/content-management-suite at merge time.
4
+ */
5
+ interface ContentItem {
6
+ id: string;
7
+ type: string;
8
+ createdAt: string;
9
+ title?: string;
10
+ body?: string;
11
+ data?: Record<string, unknown>;
12
+ status?: string;
13
+ channels?: string[];
14
+ metadata?: Record<string, unknown>;
15
+ updatedAt?: string;
16
+ publishedAt?: string;
17
+ scheduledFor?: Date;
18
+ workflowId?: string;
19
+ workflowStage?: string;
20
+ sourceType?: string | null;
21
+ sourceId?: string | null;
22
+ }
23
+ interface CreateContentInput {
24
+ type: string;
25
+ title?: string;
26
+ body?: string;
27
+ data?: Record<string, unknown>;
28
+ channels?: string[];
29
+ metadata?: Record<string, unknown>;
30
+ }
31
+ interface UpdateContentInput {
32
+ title?: string;
33
+ body?: string;
34
+ data?: Record<string, unknown>;
35
+ channels?: string[];
36
+ metadata?: Record<string, unknown>;
37
+ status?: string;
38
+ }
39
+ interface ContentFilters {
40
+ type?: string;
41
+ status?: string;
42
+ page?: number;
43
+ limit?: number;
44
+ }
45
+ interface PaginatedResult<T> {
46
+ items: T[];
47
+ total: number;
48
+ page: number;
49
+ limit: number;
50
+ totalPages: number;
51
+ }
52
+ interface AIReview {
53
+ id: string;
54
+ contentId: string;
55
+ score: number;
56
+ suggestions: AIReviewSuggestion[];
57
+ passesThreshold: boolean;
58
+ rawResult: Record<string, unknown>;
59
+ createdAt: string;
60
+ }
61
+ interface AIReviewSuggestion {
62
+ category: string;
63
+ severity: 'info' | 'warning' | 'error';
64
+ message: string;
65
+ originalText?: string;
66
+ suggestedFix?: string;
67
+ }
68
+ interface SocialPost {
69
+ id: string;
70
+ contentId: string;
71
+ platform: string;
72
+ body: string;
73
+ status: 'draft' | 'published' | 'failed';
74
+ platformPostId?: string | null;
75
+ publishedAt?: string | null;
76
+ workflowId?: string;
77
+ workflowStage?: string;
78
+ createdAt: string;
79
+ }
80
+ interface Workflow {
81
+ id: string;
82
+ name: string;
83
+ stages: WorkflowStage[];
84
+ contentType?: string;
85
+ description?: string;
86
+ createdAt?: string;
87
+ updatedAt?: string;
88
+ }
89
+ interface WorkflowStage {
90
+ id: string;
91
+ name: string;
92
+ order: number;
93
+ isPublishStage?: boolean;
94
+ allowsScheduling?: boolean;
95
+ description?: string;
96
+ permissions?: string[];
97
+ conditions?: StageConditions;
98
+ }
99
+ interface StageConditions {
100
+ autoAdvance?: boolean;
101
+ minScore?: number;
102
+ requiresHumanReview?: boolean;
103
+ }
104
+ interface User {
105
+ id: string;
106
+ name: string;
107
+ email: string;
108
+ role?: string;
109
+ permissions?: string[];
110
+ createdAt?: string;
111
+ updatedAt?: string;
112
+ }
113
+ interface ContentTypeDefinition {
114
+ id: string;
115
+ name: string;
116
+ schema?: unknown;
117
+ defaults?: Record<string, unknown>;
118
+ description?: string;
119
+ }
120
+ interface PublishResult {
121
+ channelId: string;
122
+ success: boolean;
123
+ url?: string;
124
+ error?: string;
125
+ }
126
+ interface ContentPublishResult {
127
+ item: ContentItem;
128
+ results: PublishResult[];
129
+ }
130
+ interface IngestResult {
131
+ created: boolean;
132
+ content: ContentItem;
133
+ }
134
+ interface PlatformPublishResult {
135
+ platform: string;
136
+ success: boolean;
137
+ platformPostId?: string;
138
+ url?: string;
139
+ error?: string;
140
+ }
141
+ interface ContentSource {
142
+ id: string;
143
+ name: string;
144
+ outputTypes: string[];
145
+ }
146
+ interface ContentPublisher {
147
+ id: string;
148
+ name: string;
149
+ acceptedTypes: string[];
150
+ }
151
+ interface EnhancedContent {
152
+ original: string;
153
+ enhanced: string;
154
+ changes: Array<{
155
+ type: string;
156
+ description: string;
157
+ }>;
158
+ }
159
+ interface Suggestion {
160
+ category: string;
161
+ severity: 'info' | 'warning' | 'error';
162
+ message: string;
163
+ suggestedFix?: string;
164
+ }
165
+ interface EnhanceOptions {
166
+ tone?: string;
167
+ style?: string;
168
+ instructions?: string;
169
+ }
170
+ interface PlatformInfo {
171
+ id: string;
172
+ name: string;
173
+ acceptedTypes: string[];
174
+ hasPreview: boolean;
175
+ hasMetrics: boolean;
176
+ }
177
+ interface PreviewResult {
178
+ html?: string;
179
+ url?: string;
180
+ text?: string;
181
+ }
182
+ interface SocialMetrics {
183
+ platform: string;
184
+ platformPostId: string;
185
+ impressions?: number;
186
+ engagement?: number;
187
+ clicks?: number;
188
+ shares?: number;
189
+ raw?: Record<string, unknown>;
190
+ }
191
+ interface ContentNamespace {
192
+ list(filters?: ContentFilters): Promise<PaginatedResult<ContentItem>>;
193
+ get(id: string): Promise<ContentItem | null>;
194
+ create(input: CreateContentInput): Promise<ContentItem>;
195
+ update(id: string, input: UpdateContentInput): Promise<ContentItem>;
196
+ delete(id: string): Promise<void>;
197
+ publish(id: string, options?: {
198
+ channels?: string[];
199
+ }): Promise<ContentPublishResult>;
200
+ }
201
+ interface ContentTypesNamespace {
202
+ register(definition: ContentTypeDefinition): void;
203
+ unregister(id: string): void;
204
+ list(): ContentTypeDefinition[];
205
+ get(id: string): ContentTypeDefinition | undefined;
206
+ }
207
+ interface WorkflowsNamespace {
208
+ list(): Promise<Workflow[]>;
209
+ get(id: string): Promise<Workflow>;
210
+ create(input: Partial<Workflow>): Promise<Workflow>;
211
+ update(id: string, input: Partial<Workflow>): Promise<Workflow>;
212
+ delete(id: string): Promise<void>;
213
+ }
214
+ interface PublishersNamespace {
215
+ register(publisher: ContentPublisher): void;
216
+ unregister(id: string): void;
217
+ list(): ContentPublisher[];
218
+ get(id: string): ContentPublisher | undefined;
219
+ }
220
+ interface SourcesNamespace {
221
+ register(source: ContentSource): void;
222
+ unregister(id: string): void;
223
+ list(): ContentSource[];
224
+ get(id: string): ContentSource | undefined;
225
+ ingest(sourceId: string, rawPayload: unknown): Promise<IngestResult>;
226
+ }
227
+ interface AINamespace {
228
+ review(contentId: string): Promise<AIReview>;
229
+ generateSocialPosts(contentId: string, platforms: string[]): Promise<SocialPost[]>;
230
+ enhance(contentId: string, opts?: EnhanceOptions): Promise<EnhancedContent>;
231
+ suggest(contentId: string): Promise<Suggestion[]>;
232
+ }
233
+ interface SocialNamespace {
234
+ registerPlatform(adapter: unknown): void;
235
+ unregisterPlatform(id: string): void;
236
+ listPlatforms(): PlatformInfo[];
237
+ publish(contentId: string, platforms: string[]): Promise<PlatformPublishResult[]>;
238
+ preview(contentId: string, platform: string): Promise<PreviewResult>;
239
+ getMetrics(contentId: string, platform: string): Promise<SocialMetrics>;
240
+ }
241
+ interface UsersNamespace {
242
+ list(): Promise<User[]>;
243
+ get(id: string): Promise<User | null>;
244
+ create(input: Partial<User>): Promise<User>;
245
+ update(id: string, input: Partial<User>): Promise<User>;
246
+ delete(id: string): Promise<void>;
247
+ }
248
+ interface PermissionsNamespace {
249
+ check(userId: string, permission: string): Promise<boolean>;
250
+ grant(userId: string, permission: string): Promise<void>;
251
+ revoke(userId: string, permission: string): Promise<void>;
252
+ list(userId: string): Promise<string[]>;
253
+ }
254
+ interface ConfigNamespace {
255
+ get<T = unknown>(key: string): T | undefined;
256
+ set<T = unknown>(key: string, value: T): void;
257
+ getAll(): Record<string, unknown>;
258
+ }
259
+ interface PluginsNamespace {
260
+ register(plugin: unknown): void;
261
+ unregister(id: string): void;
262
+ list(): unknown[];
263
+ get(id: string): unknown | undefined;
264
+ }
265
+ interface ContentManagementSuite {
266
+ readonly content: ContentNamespace;
267
+ readonly contentTypes: ContentTypesNamespace;
268
+ readonly workflows: WorkflowsNamespace;
269
+ readonly publishers: PublishersNamespace;
270
+ readonly sources: SourcesNamespace;
271
+ readonly ai: AINamespace;
272
+ readonly social: SocialNamespace;
273
+ readonly users: UsersNamespace;
274
+ readonly permissions: PermissionsNamespace;
275
+ readonly config: ConfigNamespace;
276
+ readonly plugins: PluginsNamespace;
277
+ initialize(): Promise<void>;
278
+ dispose(): Promise<void>;
279
+ }
280
+ declare class ContentManagementError extends Error {
281
+ readonly code: string;
282
+ readonly context: Record<string, unknown> | undefined;
283
+ constructor(message: string, options?: {
284
+ cause?: Error;
285
+ code?: string;
286
+ context?: Record<string, unknown>;
287
+ });
288
+ }
289
+ declare class ValidationError extends ContentManagementError {
290
+ constructor(message: string, options?: {
291
+ cause?: Error;
292
+ code?: string;
293
+ context?: Record<string, unknown>;
294
+ });
295
+ }
296
+ declare class NotFoundError extends ContentManagementError {
297
+ constructor(message: string, options?: {
298
+ cause?: Error;
299
+ code?: string;
300
+ context?: Record<string, unknown>;
301
+ });
302
+ }
303
+ declare class UnauthorizedError extends ContentManagementError {
304
+ constructor(message: string, options?: {
305
+ cause?: Error;
306
+ code?: string;
307
+ context?: Record<string, unknown>;
308
+ });
309
+ }
310
+ declare class ForbiddenError extends ContentManagementError {
311
+ constructor(message: string, options?: {
312
+ cause?: Error;
313
+ code?: string;
314
+ context?: Record<string, unknown>;
315
+ });
316
+ }
317
+ declare class ConflictError extends ContentManagementError {
318
+ constructor(message: string, options?: {
319
+ cause?: Error;
320
+ code?: string;
321
+ context?: Record<string, unknown>;
322
+ });
323
+ }
324
+ declare class InternalError extends ContentManagementError {
325
+ constructor(message: string, options?: {
326
+ cause?: Error;
327
+ code?: string;
328
+ context?: Record<string, unknown>;
329
+ });
330
+ }
331
+ interface RouteHandlerOptions {
332
+ auth: (request: Request) => Promise<{
333
+ userId: string;
334
+ } | null>;
335
+ basePath?: string;
336
+ }
337
+ interface AuthUser {
338
+ userId: string;
339
+ }
340
+
341
+ interface RouteHandlers {
342
+ GET: (request: Request) => Promise<Response>;
343
+ POST: (request: Request) => Promise<Response>;
344
+ PUT: (request: Request) => Promise<Response>;
345
+ DELETE: (request: Request) => Promise<Response>;
346
+ }
347
+ /**
348
+ * Create Next.js App Router route handlers for the content management suite.
349
+ *
350
+ * Returns GET, POST, PUT, DELETE functions that internally route based on the URL path.
351
+ */
352
+ declare function createContentRouteHandlers(suite: ContentManagementSuite, options: RouteHandlerOptions): RouteHandlers;
353
+
354
+ /**
355
+ * Map error instances to HTTP status codes.
356
+ */
357
+ declare function errorToStatusCode(error: unknown): number;
358
+ /**
359
+ * Extract an error message suitable for HTTP responses.
360
+ */
361
+ declare function errorToMessage(error: unknown): string;
362
+
363
+ export { type AIReview, type AIReviewSuggestion, type AuthUser, ConflictError, type ContentFilters, type ContentItem, ContentManagementError, type ContentManagementSuite, type ContentPublishResult, type ContentPublisher, type ContentSource, type ContentTypeDefinition, type CreateContentInput, ForbiddenError, type IngestResult, InternalError, NotFoundError, type PaginatedResult, type PlatformPublishResult, type PublishResult, type RouteHandlerOptions, type RouteHandlers, type SocialPost, type StageConditions, UnauthorizedError, type UpdateContentInput, type User, ValidationError, type Workflow, type WorkflowStage, createContentRouteHandlers, errorToMessage, errorToStatusCode };