@adatechnology/content-contracts 0.0.0-stage → 0.1.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.
- package/README.md +54 -2
- package/dist/index.cjs +1175 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +634 -0
- package/dist/index.d.ts +634 -0
- package/dist/index.js +1096 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
5
|
+
*
|
|
6
|
+
* Tipos do trio de conteúdo (blog, novidades, notícias). Nada aqui conhece o app que consome:
|
|
7
|
+
* o vocabulário é "post", e o host decide se chama isso de blog, novidades ou artigos.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* `scheduled` é publicação com data futura. O post vira público no instante de `publishedAt`
|
|
11
|
+
* sem cron nenhum: a leitura pública compara com o relógio, e a projeção para o contrato já
|
|
12
|
+
* devolve `published` quando o instante passou.
|
|
13
|
+
*/
|
|
14
|
+
declare const POST_STATUS: {
|
|
15
|
+
readonly DRAFT: "draft";
|
|
16
|
+
readonly SCHEDULED: "scheduled";
|
|
17
|
+
readonly PUBLISHED: "published";
|
|
18
|
+
readonly ARCHIVED: "archived";
|
|
19
|
+
};
|
|
20
|
+
type PostStatus = (typeof POST_STATUS)[keyof typeof POST_STATUS];
|
|
21
|
+
declare const POST_STATUSES: readonly PostStatus[];
|
|
22
|
+
declare function isPostStatus(value: unknown): value is PostStatus;
|
|
23
|
+
/** Visão do painel: tudo, inclusive rascunho e campos de operação. */
|
|
24
|
+
type Post = {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly companyId: string;
|
|
27
|
+
readonly slug: string;
|
|
28
|
+
readonly title: string;
|
|
29
|
+
readonly excerpt: string | null;
|
|
30
|
+
/** Markdown. Nunca HTML: a renderização segura fica em `renderMarkdownToHtml`/`parseMarkdown`. */
|
|
31
|
+
readonly body: string;
|
|
32
|
+
readonly coverImageUrl: string | null;
|
|
33
|
+
readonly coverImageAlt: string | null;
|
|
34
|
+
readonly tags: readonly string[];
|
|
35
|
+
readonly status: PostStatus;
|
|
36
|
+
/** ISO 8601. Em `scheduled`, o instante em que o post fica público. */
|
|
37
|
+
readonly publishedAt: string | null;
|
|
38
|
+
readonly authorName: string | null;
|
|
39
|
+
readonly seoTitle: string | null;
|
|
40
|
+
readonly seoDescription: string | null;
|
|
41
|
+
readonly canonicalUrl: string | null;
|
|
42
|
+
readonly readingTimeMinutes: number;
|
|
43
|
+
readonly createdAt: string;
|
|
44
|
+
readonly updatedAt: string;
|
|
45
|
+
};
|
|
46
|
+
/** Item de listagem do painel: sem o corpo, que pode ter dezenas de KB por post. */
|
|
47
|
+
type PostSummary = Omit<Post, 'body'>;
|
|
48
|
+
/**
|
|
49
|
+
* Visão pública: sem `companyId`, sem status e sem nada de operação. Só existe post publicado
|
|
50
|
+
* aqui, então status seria sempre o mesmo valor.
|
|
51
|
+
*/
|
|
52
|
+
type PublicPost = {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly slug: string;
|
|
55
|
+
readonly title: string;
|
|
56
|
+
readonly excerpt: string | null;
|
|
57
|
+
readonly body: string;
|
|
58
|
+
readonly coverImageUrl: string | null;
|
|
59
|
+
readonly coverImageAlt: string | null;
|
|
60
|
+
readonly tags: readonly string[];
|
|
61
|
+
readonly publishedAt: string;
|
|
62
|
+
readonly updatedAt: string;
|
|
63
|
+
readonly authorName: string | null;
|
|
64
|
+
readonly seoTitle: string | null;
|
|
65
|
+
readonly seoDescription: string | null;
|
|
66
|
+
readonly canonicalUrl: string | null;
|
|
67
|
+
readonly readingTimeMinutes: number;
|
|
68
|
+
};
|
|
69
|
+
type PublicPostSummary = Omit<PublicPost, 'body'>;
|
|
70
|
+
type TagCount = {
|
|
71
|
+
readonly tag: string;
|
|
72
|
+
readonly count: number;
|
|
73
|
+
};
|
|
74
|
+
type Pagination = {
|
|
75
|
+
readonly total: number;
|
|
76
|
+
readonly page: number;
|
|
77
|
+
readonly pageSize: number;
|
|
78
|
+
readonly totalPages: number;
|
|
79
|
+
};
|
|
80
|
+
type Paginated<TItem> = {
|
|
81
|
+
readonly data: readonly TItem[];
|
|
82
|
+
readonly pagination: Pagination;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
87
|
+
*
|
|
88
|
+
* Hierarquia autocontida: pacote publicado não importa o `DomainError` do host. Mesmo molde de
|
|
89
|
+
* `catalog-contracts/src/errors.ts` — o `module-http` reconhece pela forma (`statusCode`, `code`).
|
|
90
|
+
*/
|
|
91
|
+
declare class ContentError extends Error {
|
|
92
|
+
readonly statusCode: number;
|
|
93
|
+
readonly code: string;
|
|
94
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
95
|
+
constructor(message: string, statusCode: number, code: string, details?: Record<string, unknown> | undefined);
|
|
96
|
+
}
|
|
97
|
+
declare const CONTENT_ERROR_CODES: {
|
|
98
|
+
readonly POST_NOT_FOUND: "CONTENT_POST_NOT_FOUND";
|
|
99
|
+
readonly DUPLICATE_SLUG: "CONTENT_DUPLICATE_SLUG";
|
|
100
|
+
readonly INVALID_SLUG: "CONTENT_INVALID_SLUG";
|
|
101
|
+
readonly CONFIG_MISSING: "CONTENT_CONFIG_MISSING";
|
|
102
|
+
readonly INVALID_IMAGE: "CONTENT_INVALID_IMAGE";
|
|
103
|
+
readonly IMAGE_STORAGE_DISABLED: "CONTENT_IMAGE_STORAGE_DISABLED";
|
|
104
|
+
};
|
|
105
|
+
type ContentErrorCode = (typeof CONTENT_ERROR_CODES)[keyof typeof CONTENT_ERROR_CODES];
|
|
106
|
+
/** 404 também para post de outra empresa: confirmar a existência já seria vazamento. */
|
|
107
|
+
declare class PostNotFoundError extends ContentError {
|
|
108
|
+
readonly reference: string;
|
|
109
|
+
constructor(reference: string);
|
|
110
|
+
}
|
|
111
|
+
/** O slug é a URL pública; dois posts com o mesmo slug na mesma empresa tornariam um inalcançável. */
|
|
112
|
+
declare class DuplicateSlugError extends ContentError {
|
|
113
|
+
readonly slug: string;
|
|
114
|
+
constructor(slug: string);
|
|
115
|
+
}
|
|
116
|
+
declare class InvalidSlugError extends ContentError {
|
|
117
|
+
readonly slug: string;
|
|
118
|
+
constructor(slug: string);
|
|
119
|
+
}
|
|
120
|
+
declare class ConfigMissingError extends ContentError {
|
|
121
|
+
readonly field: string;
|
|
122
|
+
constructor(field: string);
|
|
123
|
+
}
|
|
124
|
+
type InvalidImageReason = 'unsupported_type' | 'empty' | 'too_large';
|
|
125
|
+
declare class InvalidCoverImageError extends ContentError {
|
|
126
|
+
readonly reason: InvalidImageReason;
|
|
127
|
+
constructor(reason: InvalidImageReason);
|
|
128
|
+
}
|
|
129
|
+
/** Sem porta de storage a rota de upload nem sobe; isto só dispara se o use-case for chamado direto. */
|
|
130
|
+
declare class ImageStorageDisabledError extends ContentError {
|
|
131
|
+
constructor();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
136
|
+
*
|
|
137
|
+
* Schemas de fronteira. `.strict()` em todo corpo: campo desconhecido é recusado, para que um
|
|
138
|
+
* `status` ou `companyId` enviado no corpo nunca passe calado por cima da regra do use-case.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
declare const POST_LIMITS: {
|
|
142
|
+
readonly TITLE: 200;
|
|
143
|
+
readonly EXCERPT: 500;
|
|
144
|
+
readonly BODY: 100000;
|
|
145
|
+
readonly URL: 2048;
|
|
146
|
+
readonly IMAGE_ALT: 300;
|
|
147
|
+
readonly AUTHOR_NAME: 120;
|
|
148
|
+
readonly SEO_TITLE: 200;
|
|
149
|
+
readonly SEO_DESCRIPTION: 320;
|
|
150
|
+
readonly SEARCH: 120;
|
|
151
|
+
readonly ADMIN_PAGE_SIZE: 100;
|
|
152
|
+
readonly PUBLIC_PAGE_SIZE: 50;
|
|
153
|
+
};
|
|
154
|
+
declare const slugSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
155
|
+
/** Só http(s): `javascript:` numa capa ou no canonical viraria `<a href>` ou `<link>` no site. */
|
|
156
|
+
declare const httpUrlSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
157
|
+
declare const postFieldsSchema: z.ZodObject<{
|
|
158
|
+
title: z.ZodString;
|
|
159
|
+
slug: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
160
|
+
excerpt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
161
|
+
body: z.ZodDefault<z.ZodString>;
|
|
162
|
+
coverImageUrl: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
163
|
+
coverImageAlt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
165
|
+
authorName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
seoTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
167
|
+
seoDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
canonicalUrl: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
169
|
+
}, "strip", z.ZodTypeAny, {
|
|
170
|
+
body: string;
|
|
171
|
+
title: string;
|
|
172
|
+
slug?: string | undefined;
|
|
173
|
+
excerpt?: string | null | undefined;
|
|
174
|
+
coverImageUrl?: string | null | undefined;
|
|
175
|
+
coverImageAlt?: string | null | undefined;
|
|
176
|
+
tags?: string[] | undefined;
|
|
177
|
+
authorName?: string | null | undefined;
|
|
178
|
+
seoTitle?: string | null | undefined;
|
|
179
|
+
seoDescription?: string | null | undefined;
|
|
180
|
+
canonicalUrl?: string | null | undefined;
|
|
181
|
+
}, {
|
|
182
|
+
title: string;
|
|
183
|
+
body?: string | undefined;
|
|
184
|
+
slug?: string | undefined;
|
|
185
|
+
excerpt?: string | null | undefined;
|
|
186
|
+
coverImageUrl?: string | null | undefined;
|
|
187
|
+
coverImageAlt?: string | null | undefined;
|
|
188
|
+
tags?: string[] | undefined;
|
|
189
|
+
authorName?: string | null | undefined;
|
|
190
|
+
seoTitle?: string | null | undefined;
|
|
191
|
+
seoDescription?: string | null | undefined;
|
|
192
|
+
canonicalUrl?: string | null | undefined;
|
|
193
|
+
}>;
|
|
194
|
+
declare const createPostSchema: z.ZodObject<{
|
|
195
|
+
title: z.ZodString;
|
|
196
|
+
slug: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
197
|
+
excerpt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
198
|
+
body: z.ZodDefault<z.ZodString>;
|
|
199
|
+
coverImageUrl: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
200
|
+
coverImageAlt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
201
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
202
|
+
authorName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
203
|
+
seoTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
204
|
+
seoDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
205
|
+
canonicalUrl: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
206
|
+
}, "strict", z.ZodTypeAny, {
|
|
207
|
+
body: string;
|
|
208
|
+
title: string;
|
|
209
|
+
slug?: string | undefined;
|
|
210
|
+
excerpt?: string | null | undefined;
|
|
211
|
+
coverImageUrl?: string | null | undefined;
|
|
212
|
+
coverImageAlt?: string | null | undefined;
|
|
213
|
+
tags?: string[] | undefined;
|
|
214
|
+
authorName?: string | null | undefined;
|
|
215
|
+
seoTitle?: string | null | undefined;
|
|
216
|
+
seoDescription?: string | null | undefined;
|
|
217
|
+
canonicalUrl?: string | null | undefined;
|
|
218
|
+
}, {
|
|
219
|
+
title: string;
|
|
220
|
+
body?: string | undefined;
|
|
221
|
+
slug?: string | undefined;
|
|
222
|
+
excerpt?: string | null | undefined;
|
|
223
|
+
coverImageUrl?: string | null | undefined;
|
|
224
|
+
coverImageAlt?: string | null | undefined;
|
|
225
|
+
tags?: string[] | undefined;
|
|
226
|
+
authorName?: string | null | undefined;
|
|
227
|
+
seoTitle?: string | null | undefined;
|
|
228
|
+
seoDescription?: string | null | undefined;
|
|
229
|
+
canonicalUrl?: string | null | undefined;
|
|
230
|
+
}>;
|
|
231
|
+
type CreatePostInput = z.input<typeof createPostSchema>;
|
|
232
|
+
declare const updatePostSchema: z.ZodObject<{
|
|
233
|
+
title: z.ZodOptional<z.ZodString>;
|
|
234
|
+
slug: z.ZodOptional<z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>>;
|
|
235
|
+
excerpt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
236
|
+
coverImageUrl: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>>;
|
|
237
|
+
coverImageAlt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
238
|
+
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
239
|
+
authorName: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
240
|
+
seoTitle: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
241
|
+
seoDescription: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
242
|
+
canonicalUrl: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>>;
|
|
243
|
+
body: z.ZodOptional<z.ZodString>;
|
|
244
|
+
}, "strict", z.ZodTypeAny, {
|
|
245
|
+
body?: string | undefined;
|
|
246
|
+
slug?: string | undefined;
|
|
247
|
+
title?: string | undefined;
|
|
248
|
+
excerpt?: string | null | undefined;
|
|
249
|
+
coverImageUrl?: string | null | undefined;
|
|
250
|
+
coverImageAlt?: string | null | undefined;
|
|
251
|
+
tags?: string[] | undefined;
|
|
252
|
+
authorName?: string | null | undefined;
|
|
253
|
+
seoTitle?: string | null | undefined;
|
|
254
|
+
seoDescription?: string | null | undefined;
|
|
255
|
+
canonicalUrl?: string | null | undefined;
|
|
256
|
+
}, {
|
|
257
|
+
body?: string | undefined;
|
|
258
|
+
slug?: string | undefined;
|
|
259
|
+
title?: string | undefined;
|
|
260
|
+
excerpt?: string | null | undefined;
|
|
261
|
+
coverImageUrl?: string | null | undefined;
|
|
262
|
+
coverImageAlt?: string | null | undefined;
|
|
263
|
+
tags?: string[] | undefined;
|
|
264
|
+
authorName?: string | null | undefined;
|
|
265
|
+
seoTitle?: string | null | undefined;
|
|
266
|
+
seoDescription?: string | null | undefined;
|
|
267
|
+
canonicalUrl?: string | null | undefined;
|
|
268
|
+
}>;
|
|
269
|
+
type UpdatePostInput = z.input<typeof updatePostSchema>;
|
|
270
|
+
/** Sem `publishedAt`, publica agora. Com data futura, agenda; com data passada, publica retroativo. */
|
|
271
|
+
declare const publishPostSchema: z.ZodObject<{
|
|
272
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
273
|
+
}, "strict", z.ZodTypeAny, {
|
|
274
|
+
publishedAt?: string | undefined;
|
|
275
|
+
}, {
|
|
276
|
+
publishedAt?: string | undefined;
|
|
277
|
+
}>;
|
|
278
|
+
type PublishPostInput = z.input<typeof publishPostSchema>;
|
|
279
|
+
declare const listPostsQuerySchema: z.ZodObject<{
|
|
280
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
281
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
282
|
+
status: z.ZodOptional<z.ZodEnum<[PostStatus, ...PostStatus[]]>>;
|
|
283
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
284
|
+
search: z.ZodOptional<z.ZodString>;
|
|
285
|
+
}, "strip", z.ZodTypeAny, {
|
|
286
|
+
page: number;
|
|
287
|
+
pageSize: number;
|
|
288
|
+
status?: PostStatus | undefined;
|
|
289
|
+
tag?: string | undefined;
|
|
290
|
+
search?: string | undefined;
|
|
291
|
+
}, {
|
|
292
|
+
status?: PostStatus | undefined;
|
|
293
|
+
page?: number | undefined;
|
|
294
|
+
pageSize?: number | undefined;
|
|
295
|
+
tag?: string | undefined;
|
|
296
|
+
search?: string | undefined;
|
|
297
|
+
}>;
|
|
298
|
+
type ListPostsQuery = z.output<typeof listPostsQuerySchema>;
|
|
299
|
+
declare const listPublishedPostsQuerySchema: z.ZodObject<{
|
|
300
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
301
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
302
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
303
|
+
}, "strip", z.ZodTypeAny, {
|
|
304
|
+
page: number;
|
|
305
|
+
pageSize: number;
|
|
306
|
+
tag?: string | undefined;
|
|
307
|
+
}, {
|
|
308
|
+
page?: number | undefined;
|
|
309
|
+
pageSize?: number | undefined;
|
|
310
|
+
tag?: string | undefined;
|
|
311
|
+
}>;
|
|
312
|
+
type ListPublishedPostsQuery = z.output<typeof listPublishedPostsQuerySchema>;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
316
|
+
*
|
|
317
|
+
* Portas e configuração do módulo. Tudo opcional: sem storage, a capa é só URL; sem feed, as rotas
|
|
318
|
+
* de RSS/Atom/sitemap não sobem. Capacidade por ausência, nunca por flag.
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Mesma forma do `ProductImageStoragePort` do catálogo, de propósito: o storage S3 que o host já
|
|
323
|
+
* usa para produto (`catalog-image-storage-provider`) encaixa aqui sem adaptador.
|
|
324
|
+
*/
|
|
325
|
+
interface ContentImageStoragePort {
|
|
326
|
+
upload(params: {
|
|
327
|
+
readonly buffer: Uint8Array;
|
|
328
|
+
readonly mimeType: string;
|
|
329
|
+
readonly key: string;
|
|
330
|
+
}): Promise<{
|
|
331
|
+
readonly url: string;
|
|
332
|
+
readonly key: string;
|
|
333
|
+
}>;
|
|
334
|
+
delete?(key: string): Promise<void>;
|
|
335
|
+
}
|
|
336
|
+
interface ClockPort {
|
|
337
|
+
now(): Date;
|
|
338
|
+
}
|
|
339
|
+
type LogMeta = Readonly<Record<string, unknown>>;
|
|
340
|
+
interface LoggerPort {
|
|
341
|
+
debug(message: string, meta?: LogMeta): void;
|
|
342
|
+
info(message: string, meta?: LogMeta): void;
|
|
343
|
+
warn(message: string, meta?: LogMeta): void;
|
|
344
|
+
error(message: string, meta?: LogMeta): void;
|
|
345
|
+
}
|
|
346
|
+
declare const POST_EVENT: {
|
|
347
|
+
readonly CREATED: "created";
|
|
348
|
+
readonly UPDATED: "updated";
|
|
349
|
+
readonly PUBLISHED: "published";
|
|
350
|
+
readonly UNPUBLISHED: "unpublished";
|
|
351
|
+
readonly ARCHIVED: "archived";
|
|
352
|
+
};
|
|
353
|
+
type PostEventType = (typeof POST_EVENT)[keyof typeof POST_EVENT];
|
|
354
|
+
type PostChangedEvent = {
|
|
355
|
+
readonly type: PostEventType;
|
|
356
|
+
readonly post: Post;
|
|
357
|
+
};
|
|
358
|
+
type ContentHooks = {
|
|
359
|
+
/**
|
|
360
|
+
* Depois de cada escrita. Uso típico: purgar cache de CDN, revalidar a página estática do post,
|
|
361
|
+
* avisar assinantes. Erro aqui é logado e não desfaz a escrita.
|
|
362
|
+
*/
|
|
363
|
+
readonly onPostChanged?: (event: PostChangedEvent) => void | Promise<void>;
|
|
364
|
+
};
|
|
365
|
+
type ContentFeedConfig = {
|
|
366
|
+
/** Endereço público do site, absoluto (`https://exemplo.com`). */
|
|
367
|
+
readonly siteUrl: string;
|
|
368
|
+
readonly title: string;
|
|
369
|
+
readonly description?: string;
|
|
370
|
+
readonly language?: string;
|
|
371
|
+
/** Caminho do post no site, com `{slug}`. Padrão: `/blog/{slug}`. */
|
|
372
|
+
readonly postPathTemplate?: string;
|
|
373
|
+
/** Quantos posts recentes entram no feed. Padrão: 20. */
|
|
374
|
+
readonly itemLimit?: number;
|
|
375
|
+
/** Inclui o corpo renderizado no feed (`content:encoded`). Padrão: `true`. */
|
|
376
|
+
readonly includeContent?: boolean;
|
|
377
|
+
};
|
|
378
|
+
type ContentModuleConfig = {
|
|
379
|
+
/**
|
|
380
|
+
* Escopos aceitos nas rotas de administração. Padrão: `['content:admin']`. Lista vazia aceita
|
|
381
|
+
* qualquer identidade autenticada que traga ao menos um escopo (regra do `module-http`).
|
|
382
|
+
*/
|
|
383
|
+
readonly adminScopes?: readonly string[];
|
|
384
|
+
/** Cabeçalho `Cache-Control` das respostas públicas. */
|
|
385
|
+
readonly publicCacheControl?: string;
|
|
386
|
+
readonly feed?: ContentFeedConfig;
|
|
387
|
+
readonly wordsPerMinute?: number;
|
|
388
|
+
};
|
|
389
|
+
declare const DEFAULT_ADMIN_SCOPES: readonly string[];
|
|
390
|
+
declare const DEFAULT_PUBLIC_CACHE_CONTROL = "public, max-age=60, s-maxage=300, stale-while-revalidate=600";
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
394
|
+
*/
|
|
395
|
+
declare const SLUG_MAX_LENGTH = 120;
|
|
396
|
+
/**
|
|
397
|
+
* Título para endereço: "Promoção de Verão!" → "promocao-de-verao". Acento sai pela decomposição
|
|
398
|
+
* Unicode (NFD) em vez de tabela fixa, então funciona para qualquer idioma latino, não só pt-BR.
|
|
399
|
+
* Pode devolver string vazia (título só de emoji ou ideogramas): o chamador decide o substituto.
|
|
400
|
+
*/
|
|
401
|
+
declare function slugify(value: string): string;
|
|
402
|
+
declare function isValidSlug(value: string): boolean;
|
|
403
|
+
/** `promocao` → `promocao-2` → `promocao-3`. Respeita o teto de tamanho mesmo com o sufixo. */
|
|
404
|
+
declare function withSlugSuffix(slug: string, attempt: number): string;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
408
|
+
*/
|
|
409
|
+
declare const TAG_MAX_LENGTH = 40;
|
|
410
|
+
declare const TAGS_MAX_COUNT = 20;
|
|
411
|
+
/**
|
|
412
|
+
* Tag vira filtro de URL (`?tag=`), então guarda-se uma forma só: minúscula, sem espaço sobrando.
|
|
413
|
+
* "Novidades" e "novidades " seriam duas tags no filtro e uma só na cabeça de quem escreve.
|
|
414
|
+
*/
|
|
415
|
+
declare function normalizeTag(value: string): string;
|
|
416
|
+
/** Normaliza, remove vazias e repetidas, preserva a ordem em que o autor digitou. */
|
|
417
|
+
declare function normalizeTags(values: readonly string[]): string[];
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
421
|
+
*/
|
|
422
|
+
/** Média de leitura silenciosa de texto corrido em português e inglês. */
|
|
423
|
+
declare const DEFAULT_WORDS_PER_MINUTE = 200;
|
|
424
|
+
declare function countWords(text: string): number;
|
|
425
|
+
/** Minutos de leitura, sempre ao menos 1: "0 min de leitura" num post curto soa como erro. */
|
|
426
|
+
declare function estimateReadingTimeMinutes(markdown: string, wordsPerMinute?: number): number;
|
|
427
|
+
/**
|
|
428
|
+
* Resumo a partir do corpo, para quando o autor não escreveu um. Corta em fronteira de palavra:
|
|
429
|
+
* "promoção válida at…" no card parece defeito.
|
|
430
|
+
*/
|
|
431
|
+
declare function buildExcerpt(markdown: string, maxLength?: number): string;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
435
|
+
*
|
|
436
|
+
* AST do Markdown aceito no corpo do post. É fechado de propósito: não existe nó de HTML cru, então
|
|
437
|
+
* nenhum renderizador (string no servidor, React no navegador) tem como emitir marcação digitada
|
|
438
|
+
* pelo autor — `<script>` no corpo vira texto, não tag.
|
|
439
|
+
*/
|
|
440
|
+
type MarkdownInline = {
|
|
441
|
+
readonly type: 'text';
|
|
442
|
+
readonly value: string;
|
|
443
|
+
} | {
|
|
444
|
+
readonly type: 'strong';
|
|
445
|
+
readonly children: readonly MarkdownInline[];
|
|
446
|
+
} | {
|
|
447
|
+
readonly type: 'emphasis';
|
|
448
|
+
readonly children: readonly MarkdownInline[];
|
|
449
|
+
} | {
|
|
450
|
+
readonly type: 'strikethrough';
|
|
451
|
+
readonly children: readonly MarkdownInline[];
|
|
452
|
+
} | {
|
|
453
|
+
readonly type: 'inlineCode';
|
|
454
|
+
readonly value: string;
|
|
455
|
+
}
|
|
456
|
+
/** `href` já passou por `sanitizeLinkUrl`: link inseguro nem vira nó de link. */
|
|
457
|
+
| {
|
|
458
|
+
readonly type: 'link';
|
|
459
|
+
readonly href: string;
|
|
460
|
+
readonly title?: string;
|
|
461
|
+
readonly children: readonly MarkdownInline[];
|
|
462
|
+
}
|
|
463
|
+
/** `src` já passou por `sanitizeImageUrl`: imagem insegura vira texto com o `alt`. */
|
|
464
|
+
| {
|
|
465
|
+
readonly type: 'image';
|
|
466
|
+
readonly src: string;
|
|
467
|
+
readonly alt: string;
|
|
468
|
+
readonly title?: string;
|
|
469
|
+
} | {
|
|
470
|
+
readonly type: 'break';
|
|
471
|
+
};
|
|
472
|
+
type MarkdownBlock = {
|
|
473
|
+
readonly type: 'heading';
|
|
474
|
+
readonly level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
475
|
+
readonly children: readonly MarkdownInline[];
|
|
476
|
+
} | {
|
|
477
|
+
readonly type: 'paragraph';
|
|
478
|
+
readonly children: readonly MarkdownInline[];
|
|
479
|
+
} | {
|
|
480
|
+
readonly type: 'list';
|
|
481
|
+
readonly ordered: boolean;
|
|
482
|
+
readonly start?: number;
|
|
483
|
+
/** Lista sem linha em branco entre itens: o item é renderizado sem `<p>` em volta. */
|
|
484
|
+
readonly tight: boolean;
|
|
485
|
+
readonly items: readonly (readonly MarkdownBlock[])[];
|
|
486
|
+
} | {
|
|
487
|
+
readonly type: 'blockquote';
|
|
488
|
+
readonly children: readonly MarkdownBlock[];
|
|
489
|
+
}
|
|
490
|
+
/** `language` restrita a `[a-z0-9+#-]` — vira classe CSS, e classe não carrega aspas nem espaço. */
|
|
491
|
+
| {
|
|
492
|
+
readonly type: 'codeBlock';
|
|
493
|
+
readonly language?: string;
|
|
494
|
+
readonly value: string;
|
|
495
|
+
} | {
|
|
496
|
+
readonly type: 'thematicBreak';
|
|
497
|
+
};
|
|
498
|
+
type MarkdownDocument = {
|
|
499
|
+
readonly type: 'root';
|
|
500
|
+
readonly children: readonly MarkdownBlock[];
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
505
|
+
*
|
|
506
|
+
* Markdown → AST seguro. Blocos aceitos: título (`#`), parágrafo, lista (com aninhamento),
|
|
507
|
+
* citação (`>`), código cercado (```), separador (`---`). Não existe HTML cru: uma linha
|
|
508
|
+
* `<script>` é parágrafo de texto. Isomórfico — roda igual no servidor e no navegador.
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
declare function parseMarkdown(source: string): MarkdownDocument;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
515
|
+
*
|
|
516
|
+
* Parser de trechos em linha: ênfase, negrito, tachado, código, link, imagem e quebra de linha.
|
|
517
|
+
* Subconjunto do CommonMark escolhido para texto de blog — não há HTML em linha nem referência de
|
|
518
|
+
* link. Todo texto sai como nó `text`, e quem renderiza escapa.
|
|
519
|
+
*
|
|
520
|
+
* Custo linear na prática: cada busca de fechamento que falha fica memorizada, então um parágrafo
|
|
521
|
+
* com mil `*` soltos não vira mil varreduras até o fim do texto.
|
|
522
|
+
*/
|
|
523
|
+
|
|
524
|
+
declare function parseInline(text: string, depth?: number): MarkdownInline[];
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
528
|
+
*
|
|
529
|
+
* AST → HTML com TODO texto e atributo escapados. Não há caminho para HTML do autor chegar cru à
|
|
530
|
+
* saída: o AST não tem nó de HTML, e as URLs já chegam saneadas pelo parser. Serve feed, e-mail e
|
|
531
|
+
* renderização no servidor; no navegador, o `content-ui` monta elementos React a partir do mesmo
|
|
532
|
+
* AST e nem usa string.
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
type MarkdownRenderOptions = {
|
|
536
|
+
/** Soma ao nível do título: com 1, `#` vira `<h2>` (a página já tem o `<h1>` do post). */
|
|
537
|
+
readonly headingLevelOffset?: number;
|
|
538
|
+
/** Âncora nos títulos. Padrão: `true`. */
|
|
539
|
+
readonly headingIds?: boolean;
|
|
540
|
+
readonly headingIdPrefix?: string;
|
|
541
|
+
/** Link absoluto abre em nova aba. Padrão: `true`. */
|
|
542
|
+
readonly externalLinksInNewTab?: boolean;
|
|
543
|
+
/** Padrão `noopener noreferrer`; o host pode acrescentar `nofollow ugc`. */
|
|
544
|
+
readonly linkRel?: string;
|
|
545
|
+
};
|
|
546
|
+
declare const DEFAULT_LINK_REL = "noopener noreferrer";
|
|
547
|
+
declare function escapeHtml(value: string): string;
|
|
548
|
+
declare function resolveHeadingLevel(level: number, offset?: number): 1 | 2 | 3 | 4 | 5 | 6;
|
|
549
|
+
declare function renderMarkdownDocument(document: MarkdownDocument, options?: MarkdownRenderOptions): string;
|
|
550
|
+
/** Markdown do autor → HTML seguro para injetar como está (feed, e-mail, SSR). */
|
|
551
|
+
declare function renderMarkdownToHtml(markdown: string, options?: MarkdownRenderOptions): string;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
555
|
+
*/
|
|
556
|
+
|
|
557
|
+
declare function inlineToPlainText(nodes: readonly MarkdownInline[]): string;
|
|
558
|
+
declare function documentToPlainText(document: MarkdownDocument): string;
|
|
559
|
+
/** Texto corrido do Markdown, sem marcação: base do tempo de leitura, do resumo e do feed. */
|
|
560
|
+
declare function markdownToPlainText(markdown: string): string;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
564
|
+
*
|
|
565
|
+
* Lista de permissão, não de bloqueio: o que não for http(s), mailto, tel ou caminho relativo é
|
|
566
|
+
* recusado. Bloquear só `javascript:` deixaria passar `vbscript:`, `data:` e o próximo esquema.
|
|
567
|
+
*/
|
|
568
|
+
/** `undefined` quando o destino não é seguro — o chamador renderiza só o texto do link. */
|
|
569
|
+
declare function sanitizeLinkUrl(url: string): string | undefined;
|
|
570
|
+
/** Imagem só por http(s) ou caminho relativo: `data:` permitiria SVG com script embutido. */
|
|
571
|
+
declare function sanitizeImageUrl(url: string): string | undefined;
|
|
572
|
+
declare function isAbsoluteHttpUrl(url: string): boolean;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
576
|
+
*/
|
|
577
|
+
/**
|
|
578
|
+
* Gera âncoras estáveis para títulos (`#como-funciona`), com sufixo para repetidos. Compartilhado
|
|
579
|
+
* pelos dois renderizadores para o link de âncora ser o mesmo no HTML do servidor e no React.
|
|
580
|
+
*/
|
|
581
|
+
declare function createHeadingIdGenerator(prefix?: string): (text: string) => string;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
585
|
+
*
|
|
586
|
+
* RSS 2.0, Atom 1.0 e sitemap como funções puras: o host pode servir pelas rotas do
|
|
587
|
+
* `content-module` ou gerar no build do site estático, com a mesma saída.
|
|
588
|
+
*/
|
|
589
|
+
type FeedChannel = {
|
|
590
|
+
/** Endereço do site, absoluto: `https://exemplo.com`. */
|
|
591
|
+
readonly siteUrl: string;
|
|
592
|
+
readonly title: string;
|
|
593
|
+
readonly description?: string;
|
|
594
|
+
/** `pt-BR`, `en` … */
|
|
595
|
+
readonly language?: string;
|
|
596
|
+
/** URL do próprio feed, para o `<atom:link rel="self">` que os leitores exigem. */
|
|
597
|
+
readonly feedUrl?: string;
|
|
598
|
+
};
|
|
599
|
+
type FeedItem = {
|
|
600
|
+
readonly title: string;
|
|
601
|
+
readonly url: string;
|
|
602
|
+
readonly publishedAt: string;
|
|
603
|
+
readonly updatedAt?: string;
|
|
604
|
+
readonly summary?: string;
|
|
605
|
+
/** HTML já seguro (saída de `renderMarkdownToHtml`). Vai escapado dentro do XML. */
|
|
606
|
+
readonly contentHtml?: string;
|
|
607
|
+
readonly authorName?: string;
|
|
608
|
+
readonly categories?: readonly string[];
|
|
609
|
+
readonly imageUrl?: string;
|
|
610
|
+
};
|
|
611
|
+
type SitemapEntry = {
|
|
612
|
+
readonly loc: string;
|
|
613
|
+
readonly lastmod?: string;
|
|
614
|
+
};
|
|
615
|
+
declare const DEFAULT_POST_PATH_TEMPLATE = "/blog/{slug}";
|
|
616
|
+
declare function escapeXml(value: string): string;
|
|
617
|
+
/** `{slug}` no modelo vira o slug codificado; o modelo é relativo ao `siteUrl`. */
|
|
618
|
+
declare function buildPostUrl(params: {
|
|
619
|
+
readonly siteUrl: string;
|
|
620
|
+
readonly slug: string;
|
|
621
|
+
readonly postPathTemplate?: string;
|
|
622
|
+
}): string;
|
|
623
|
+
declare function buildRssFeed(params: {
|
|
624
|
+
readonly channel: FeedChannel;
|
|
625
|
+
readonly items: readonly FeedItem[];
|
|
626
|
+
}): string;
|
|
627
|
+
declare function buildAtomFeed(params: {
|
|
628
|
+
readonly channel: FeedChannel;
|
|
629
|
+
readonly items: readonly FeedItem[];
|
|
630
|
+
readonly now?: Date;
|
|
631
|
+
}): string;
|
|
632
|
+
declare function buildSitemapXml(entries: readonly SitemapEntry[]): string;
|
|
633
|
+
|
|
634
|
+
export { CONTENT_ERROR_CODES, type ClockPort, ConfigMissingError, ContentError, type ContentErrorCode, type ContentFeedConfig, type ContentHooks, type ContentImageStoragePort, type ContentModuleConfig, type CreatePostInput, DEFAULT_ADMIN_SCOPES, DEFAULT_LINK_REL, DEFAULT_POST_PATH_TEMPLATE, DEFAULT_PUBLIC_CACHE_CONTROL, DEFAULT_WORDS_PER_MINUTE, DuplicateSlugError, type FeedChannel, type FeedItem, ImageStorageDisabledError, InvalidCoverImageError, type InvalidImageReason, InvalidSlugError, type ListPostsQuery, type ListPublishedPostsQuery, type LogMeta, type LoggerPort, type MarkdownBlock, type MarkdownDocument, type MarkdownInline, type MarkdownRenderOptions, POST_EVENT, POST_LIMITS, POST_STATUS, POST_STATUSES, type Paginated, type Pagination, type Post, type PostChangedEvent, type PostEventType, PostNotFoundError, type PostStatus, type PostSummary, type PublicPost, type PublicPostSummary, type PublishPostInput, SLUG_MAX_LENGTH, type SitemapEntry, TAGS_MAX_COUNT, TAG_MAX_LENGTH, type TagCount, type UpdatePostInput, buildAtomFeed, buildExcerpt, buildPostUrl, buildRssFeed, buildSitemapXml, countWords, createHeadingIdGenerator, createPostSchema, documentToPlainText, escapeHtml, escapeXml, estimateReadingTimeMinutes, httpUrlSchema, inlineToPlainText, isAbsoluteHttpUrl, isPostStatus, isValidSlug, listPostsQuerySchema, listPublishedPostsQuerySchema, markdownToPlainText, normalizeTag, normalizeTags, parseInline, parseMarkdown, postFieldsSchema, publishPostSchema, renderMarkdownDocument, renderMarkdownToHtml, resolveHeadingLevel, sanitizeImageUrl, sanitizeLinkUrl, slugSchema, slugify, updatePostSchema, withSlugSuffix };
|