@adatechnology/content-contracts 0.1.0 → 0.3.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/dist/index.cjs +336 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +245 -3
- package/dist/index.d.ts +245 -3
- package/dist/index.js +311 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -25,6 +25,8 @@ type Post = {
|
|
|
25
25
|
readonly id: string;
|
|
26
26
|
readonly companyId: string;
|
|
27
27
|
readonly slug: string;
|
|
28
|
+
/** Id curto estável (6 caracteres base36): o endereço público é `<shortId>-<slug>`. */
|
|
29
|
+
readonly shortId: string;
|
|
28
30
|
readonly title: string;
|
|
29
31
|
readonly excerpt: string | null;
|
|
30
32
|
/** Markdown. Nunca HTML: a renderização segura fica em `renderMarkdownToHtml`/`parseMarkdown`. */
|
|
@@ -32,7 +34,11 @@ type Post = {
|
|
|
32
34
|
readonly coverImageUrl: string | null;
|
|
33
35
|
readonly coverImageAlt: string | null;
|
|
34
36
|
readonly tags: readonly string[];
|
|
37
|
+
/** Rótulo de exibição por tag, só das que diferem do slug: `{ cardapio: 'Cardápio' }`. */
|
|
38
|
+
readonly tagLabels: Readonly<Record<string, string>>;
|
|
35
39
|
readonly status: PostStatus;
|
|
40
|
+
/** Modelo de post: nunca vai ao ar, só serve de base para posts novos (e para recorrência). */
|
|
41
|
+
readonly isTemplate: boolean;
|
|
36
42
|
/** ISO 8601. Em `scheduled`, o instante em que o post fica público. */
|
|
37
43
|
readonly publishedAt: string | null;
|
|
38
44
|
readonly authorName: string | null;
|
|
@@ -52,12 +58,16 @@ type PostSummary = Omit<Post, 'body'>;
|
|
|
52
58
|
type PublicPost = {
|
|
53
59
|
readonly id: string;
|
|
54
60
|
readonly slug: string;
|
|
61
|
+
/** Id curto estável (6 caracteres base36): o endereço público é `<shortId>-<slug>`. */
|
|
62
|
+
readonly shortId: string;
|
|
55
63
|
readonly title: string;
|
|
56
64
|
readonly excerpt: string | null;
|
|
57
65
|
readonly body: string;
|
|
58
66
|
readonly coverImageUrl: string | null;
|
|
59
67
|
readonly coverImageAlt: string | null;
|
|
60
68
|
readonly tags: readonly string[];
|
|
69
|
+
/** Rótulo de exibição por tag, só das que diferem do slug: `{ cardapio: 'Cardápio' }`. */
|
|
70
|
+
readonly tagLabels: Readonly<Record<string, string>>;
|
|
61
71
|
readonly publishedAt: string;
|
|
62
72
|
readonly updatedAt: string;
|
|
63
73
|
readonly authorName: string | null;
|
|
@@ -81,6 +91,34 @@ type Paginated<TItem> = {
|
|
|
81
91
|
readonly data: readonly TItem[];
|
|
82
92
|
readonly pagination: Pagination;
|
|
83
93
|
};
|
|
94
|
+
/** Contagem por aba do painel. `scheduled` e `published` seguem o status que o painel MOSTRA. */
|
|
95
|
+
type PostCounts = {
|
|
96
|
+
readonly published: number;
|
|
97
|
+
readonly scheduled: number;
|
|
98
|
+
readonly draft: number;
|
|
99
|
+
readonly archived: number;
|
|
100
|
+
readonly templates: number;
|
|
101
|
+
};
|
|
102
|
+
declare const RECURRENCE_FREQUENCY: {
|
|
103
|
+
readonly WEEKLY: "weekly";
|
|
104
|
+
readonly MONTHLY: "monthly";
|
|
105
|
+
};
|
|
106
|
+
type RecurrenceFrequency = (typeof RECURRENCE_FREQUENCY)[keyof typeof RECURRENCE_FREQUENCY];
|
|
107
|
+
declare const RECURRENCE_FREQUENCIES: readonly RecurrenceFrequency[];
|
|
108
|
+
/** Regra que publica um post novo, copiado de um modelo, a cada semana ou mês. */
|
|
109
|
+
type RecurrenceRule = {
|
|
110
|
+
readonly id: string;
|
|
111
|
+
readonly companyId: string;
|
|
112
|
+
readonly templateId: string;
|
|
113
|
+
readonly templateTitle: string;
|
|
114
|
+
readonly frequency: RecurrenceFrequency;
|
|
115
|
+
readonly isActive: boolean;
|
|
116
|
+
/** ISO 8601. Próxima publicação automática. */
|
|
117
|
+
readonly nextRunAt: string;
|
|
118
|
+
readonly lastRunAt: string | null;
|
|
119
|
+
readonly lastPostId: string | null;
|
|
120
|
+
readonly createdAt: string;
|
|
121
|
+
};
|
|
84
122
|
|
|
85
123
|
/**
|
|
86
124
|
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
@@ -101,6 +139,11 @@ declare const CONTENT_ERROR_CODES: {
|
|
|
101
139
|
readonly CONFIG_MISSING: "CONTENT_CONFIG_MISSING";
|
|
102
140
|
readonly INVALID_IMAGE: "CONTENT_INVALID_IMAGE";
|
|
103
141
|
readonly IMAGE_STORAGE_DISABLED: "CONTENT_IMAGE_STORAGE_DISABLED";
|
|
142
|
+
readonly NOT_A_TEMPLATE: "CONTENT_NOT_A_TEMPLATE";
|
|
143
|
+
readonly TEMPLATE_NOT_PUBLISHABLE: "CONTENT_TEMPLATE_NOT_PUBLISHABLE";
|
|
144
|
+
readonly NOT_PUBLISHED: "CONTENT_NOT_PUBLISHED";
|
|
145
|
+
readonly REPUBLISH_DATE_IN_FUTURE: "CONTENT_REPUBLISH_DATE_IN_FUTURE";
|
|
146
|
+
readonly RECURRENCE_NOT_FOUND: "CONTENT_RECURRENCE_NOT_FOUND";
|
|
104
147
|
};
|
|
105
148
|
type ContentErrorCode = (typeof CONTENT_ERROR_CODES)[keyof typeof CONTENT_ERROR_CODES];
|
|
106
149
|
/** 404 também para post de outra empresa: confirmar a existência já seria vazamento. */
|
|
@@ -130,6 +173,28 @@ declare class InvalidCoverImageError extends ContentError {
|
|
|
130
173
|
declare class ImageStorageDisabledError extends ContentError {
|
|
131
174
|
constructor();
|
|
132
175
|
}
|
|
176
|
+
/** Só modelo serve de base para "novo a partir de modelo" e para recorrência. */
|
|
177
|
+
declare class NotATemplateError extends ContentError {
|
|
178
|
+
readonly postId: string;
|
|
179
|
+
constructor(postId: string);
|
|
180
|
+
}
|
|
181
|
+
/** Modelo no ar apareceria no site com texto de exemplo: publicar modelo é sempre recusado. */
|
|
182
|
+
declare class TemplateNotPublishableError extends ContentError {
|
|
183
|
+
readonly postId: string;
|
|
184
|
+
constructor(postId: string);
|
|
185
|
+
}
|
|
186
|
+
declare class PostNotPublishedError extends ContentError {
|
|
187
|
+
readonly postId: string;
|
|
188
|
+
constructor(postId: string);
|
|
189
|
+
}
|
|
190
|
+
/** Republicar com data futura tiraria o post do ar até lá (404 para leitor e buscador). */
|
|
191
|
+
declare class RepublishDateInFutureError extends ContentError {
|
|
192
|
+
constructor();
|
|
193
|
+
}
|
|
194
|
+
declare class RecurrenceNotFoundError extends ContentError {
|
|
195
|
+
readonly reference: string;
|
|
196
|
+
constructor(reference: string);
|
|
197
|
+
}
|
|
133
198
|
|
|
134
199
|
/**
|
|
135
200
|
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
@@ -162,6 +227,8 @@ declare const postFieldsSchema: z.ZodObject<{
|
|
|
162
227
|
coverImageUrl: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
163
228
|
coverImageAlt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
229
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
230
|
+
/** Rótulo de exibição por tag (chave = tag normalizada). Sem rótulo, vale o texto digitado. */
|
|
231
|
+
tagLabels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
165
232
|
authorName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
233
|
seoTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
167
234
|
seoDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -174,6 +241,7 @@ declare const postFieldsSchema: z.ZodObject<{
|
|
|
174
241
|
coverImageUrl?: string | null | undefined;
|
|
175
242
|
coverImageAlt?: string | null | undefined;
|
|
176
243
|
tags?: string[] | undefined;
|
|
244
|
+
tagLabels?: Record<string, string> | undefined;
|
|
177
245
|
authorName?: string | null | undefined;
|
|
178
246
|
seoTitle?: string | null | undefined;
|
|
179
247
|
seoDescription?: string | null | undefined;
|
|
@@ -186,6 +254,7 @@ declare const postFieldsSchema: z.ZodObject<{
|
|
|
186
254
|
coverImageUrl?: string | null | undefined;
|
|
187
255
|
coverImageAlt?: string | null | undefined;
|
|
188
256
|
tags?: string[] | undefined;
|
|
257
|
+
tagLabels?: Record<string, string> | undefined;
|
|
189
258
|
authorName?: string | null | undefined;
|
|
190
259
|
seoTitle?: string | null | undefined;
|
|
191
260
|
seoDescription?: string | null | undefined;
|
|
@@ -199,6 +268,8 @@ declare const createPostSchema: z.ZodObject<{
|
|
|
199
268
|
coverImageUrl: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
200
269
|
coverImageAlt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
201
270
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
271
|
+
/** Rótulo de exibição por tag (chave = tag normalizada). Sem rótulo, vale o texto digitado. */
|
|
272
|
+
tagLabels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
202
273
|
authorName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
203
274
|
seoTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
204
275
|
seoDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -211,6 +282,7 @@ declare const createPostSchema: z.ZodObject<{
|
|
|
211
282
|
coverImageUrl?: string | null | undefined;
|
|
212
283
|
coverImageAlt?: string | null | undefined;
|
|
213
284
|
tags?: string[] | undefined;
|
|
285
|
+
tagLabels?: Record<string, string> | undefined;
|
|
214
286
|
authorName?: string | null | undefined;
|
|
215
287
|
seoTitle?: string | null | undefined;
|
|
216
288
|
seoDescription?: string | null | undefined;
|
|
@@ -223,6 +295,7 @@ declare const createPostSchema: z.ZodObject<{
|
|
|
223
295
|
coverImageUrl?: string | null | undefined;
|
|
224
296
|
coverImageAlt?: string | null | undefined;
|
|
225
297
|
tags?: string[] | undefined;
|
|
298
|
+
tagLabels?: Record<string, string> | undefined;
|
|
226
299
|
authorName?: string | null | undefined;
|
|
227
300
|
seoTitle?: string | null | undefined;
|
|
228
301
|
seoDescription?: string | null | undefined;
|
|
@@ -236,6 +309,7 @@ declare const updatePostSchema: z.ZodObject<{
|
|
|
236
309
|
coverImageUrl: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>>;
|
|
237
310
|
coverImageAlt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
238
311
|
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
312
|
+
tagLabels: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
239
313
|
authorName: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
240
314
|
seoTitle: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
241
315
|
seoDescription: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
@@ -249,6 +323,7 @@ declare const updatePostSchema: z.ZodObject<{
|
|
|
249
323
|
coverImageUrl?: string | null | undefined;
|
|
250
324
|
coverImageAlt?: string | null | undefined;
|
|
251
325
|
tags?: string[] | undefined;
|
|
326
|
+
tagLabels?: Record<string, string> | undefined;
|
|
252
327
|
authorName?: string | null | undefined;
|
|
253
328
|
seoTitle?: string | null | undefined;
|
|
254
329
|
seoDescription?: string | null | undefined;
|
|
@@ -261,6 +336,7 @@ declare const updatePostSchema: z.ZodObject<{
|
|
|
261
336
|
coverImageUrl?: string | null | undefined;
|
|
262
337
|
coverImageAlt?: string | null | undefined;
|
|
263
338
|
tags?: string[] | undefined;
|
|
339
|
+
tagLabels?: Record<string, string> | undefined;
|
|
264
340
|
authorName?: string | null | undefined;
|
|
265
341
|
seoTitle?: string | null | undefined;
|
|
266
342
|
seoDescription?: string | null | undefined;
|
|
@@ -276,24 +352,38 @@ declare const publishPostSchema: z.ZodObject<{
|
|
|
276
352
|
publishedAt?: string | undefined;
|
|
277
353
|
}>;
|
|
278
354
|
type PublishPostInput = z.input<typeof publishPostSchema>;
|
|
355
|
+
declare const POST_SORT_FIELDS: readonly ["title", "status", "publishedAt", "updatedAt"];
|
|
356
|
+
type PostSortField = (typeof POST_SORT_FIELDS)[number];
|
|
279
357
|
declare const listPostsQuerySchema: z.ZodObject<{
|
|
280
358
|
page: z.ZodDefault<z.ZodNumber>;
|
|
281
359
|
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
282
360
|
status: z.ZodOptional<z.ZodEnum<[PostStatus, ...PostStatus[]]>>;
|
|
361
|
+
/** Uma tag, ou várias separadas por vírgula (basta ter UMA delas). */
|
|
283
362
|
tag: z.ZodOptional<z.ZodString>;
|
|
284
363
|
search: z.ZodOptional<z.ZodString>;
|
|
364
|
+
/** Padrão: `updatedAt` (o que o painel mexeu por último). */
|
|
365
|
+
sort: z.ZodDefault<z.ZodEnum<["title", "status", "publishedAt", "updatedAt"]>>;
|
|
366
|
+
order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
367
|
+
/** `true`: só modelos. Ausente/`false`: só posts (modelo nunca aparece misturado na lista). */
|
|
368
|
+
isTemplate: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodBoolean, z.ZodEnum<["true", "false"]>]>, boolean, boolean | "true" | "false">>;
|
|
285
369
|
}, "strip", z.ZodTypeAny, {
|
|
370
|
+
sort: "title" | "status" | "publishedAt" | "updatedAt";
|
|
286
371
|
page: number;
|
|
287
372
|
pageSize: number;
|
|
373
|
+
order: "asc" | "desc";
|
|
288
374
|
status?: PostStatus | undefined;
|
|
375
|
+
isTemplate?: boolean | undefined;
|
|
289
376
|
tag?: string | undefined;
|
|
290
377
|
search?: string | undefined;
|
|
291
378
|
}, {
|
|
292
379
|
status?: PostStatus | undefined;
|
|
380
|
+
isTemplate?: boolean | "true" | "false" | undefined;
|
|
381
|
+
sort?: "title" | "status" | "publishedAt" | "updatedAt" | undefined;
|
|
293
382
|
page?: number | undefined;
|
|
294
383
|
pageSize?: number | undefined;
|
|
295
384
|
tag?: string | undefined;
|
|
296
385
|
search?: string | undefined;
|
|
386
|
+
order?: "asc" | "desc" | undefined;
|
|
297
387
|
}>;
|
|
298
388
|
type ListPostsQuery = z.output<typeof listPostsQuerySchema>;
|
|
299
389
|
declare const listPublishedPostsQuerySchema: z.ZodObject<{
|
|
@@ -310,6 +400,61 @@ declare const listPublishedPostsQuerySchema: z.ZodObject<{
|
|
|
310
400
|
tag?: string | undefined;
|
|
311
401
|
}>;
|
|
312
402
|
type ListPublishedPostsQuery = z.output<typeof listPublishedPostsQuerySchema>;
|
|
403
|
+
/** `title` ausente: o modelo herda o título do post de origem. */
|
|
404
|
+
declare const saveAsTemplateSchema: z.ZodObject<{
|
|
405
|
+
title: z.ZodOptional<z.ZodString>;
|
|
406
|
+
}, "strict", z.ZodTypeAny, {
|
|
407
|
+
title?: string | undefined;
|
|
408
|
+
}, {
|
|
409
|
+
title?: string | undefined;
|
|
410
|
+
}>;
|
|
411
|
+
type SaveAsTemplateInput = z.input<typeof saveAsTemplateSchema>;
|
|
412
|
+
declare const createFromTemplateSchema: z.ZodObject<{
|
|
413
|
+
title: z.ZodOptional<z.ZodString>;
|
|
414
|
+
slug: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
415
|
+
}, "strict", z.ZodTypeAny, {
|
|
416
|
+
slug?: string | undefined;
|
|
417
|
+
title?: string | undefined;
|
|
418
|
+
}, {
|
|
419
|
+
slug?: string | undefined;
|
|
420
|
+
title?: string | undefined;
|
|
421
|
+
}>;
|
|
422
|
+
type CreateFromTemplateInput = z.input<typeof createFromTemplateSchema>;
|
|
423
|
+
/** Sem `publishedAt`, usa agora. Data futura é recusada: o post sairia do ar até lá. */
|
|
424
|
+
declare const republishPostSchema: z.ZodObject<{
|
|
425
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
426
|
+
}, "strict", z.ZodTypeAny, {
|
|
427
|
+
publishedAt?: string | undefined;
|
|
428
|
+
}, {
|
|
429
|
+
publishedAt?: string | undefined;
|
|
430
|
+
}>;
|
|
431
|
+
type RepublishPostInput = z.input<typeof republishPostSchema>;
|
|
432
|
+
declare const createRecurrenceSchema: z.ZodObject<{
|
|
433
|
+
templateId: z.ZodString;
|
|
434
|
+
frequency: z.ZodEnum<[RecurrenceFrequency, ...RecurrenceFrequency[]]>;
|
|
435
|
+
/** Primeira publicação automática. */
|
|
436
|
+
startsAt: z.ZodString;
|
|
437
|
+
}, "strict", z.ZodTypeAny, {
|
|
438
|
+
templateId: string;
|
|
439
|
+
frequency: RecurrenceFrequency;
|
|
440
|
+
startsAt: string;
|
|
441
|
+
}, {
|
|
442
|
+
templateId: string;
|
|
443
|
+
frequency: RecurrenceFrequency;
|
|
444
|
+
startsAt: string;
|
|
445
|
+
}>;
|
|
446
|
+
type CreateRecurrenceInput = z.input<typeof createRecurrenceSchema>;
|
|
447
|
+
declare const updateRecurrenceSchema: z.ZodObject<{
|
|
448
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
449
|
+
nextRunAt: z.ZodOptional<z.ZodString>;
|
|
450
|
+
}, "strict", z.ZodTypeAny, {
|
|
451
|
+
isActive?: boolean | undefined;
|
|
452
|
+
nextRunAt?: string | undefined;
|
|
453
|
+
}, {
|
|
454
|
+
isActive?: boolean | undefined;
|
|
455
|
+
nextRunAt?: string | undefined;
|
|
456
|
+
}>;
|
|
457
|
+
type UpdateRecurrenceInput = z.input<typeof updateRecurrenceSchema>;
|
|
313
458
|
|
|
314
459
|
/**
|
|
315
460
|
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
@@ -349,6 +494,7 @@ declare const POST_EVENT: {
|
|
|
349
494
|
readonly PUBLISHED: "published";
|
|
350
495
|
readonly UNPUBLISHED: "unpublished";
|
|
351
496
|
readonly ARCHIVED: "archived";
|
|
497
|
+
readonly REPUBLISHED: "republished";
|
|
352
498
|
};
|
|
353
499
|
type PostEventType = (typeof POST_EVENT)[keyof typeof POST_EVENT];
|
|
354
500
|
type PostChangedEvent = {
|
|
@@ -368,7 +514,7 @@ type ContentFeedConfig = {
|
|
|
368
514
|
readonly title: string;
|
|
369
515
|
readonly description?: string;
|
|
370
516
|
readonly language?: string;
|
|
371
|
-
/** Caminho do post no site, com `{slug}
|
|
517
|
+
/** Caminho do post no site, com `{slug}` e, opcional, `{shortId}` (ex.: `/novidades/{shortId}-{slug}`). Padrão: `/blog/{slug}`. */
|
|
372
518
|
readonly postPathTemplate?: string;
|
|
373
519
|
/** Quantos posts recentes entram no feed. Padrão: 20. */
|
|
374
520
|
readonly itemLimit?: number;
|
|
@@ -385,6 +531,11 @@ type ContentModuleConfig = {
|
|
|
385
531
|
readonly publicCacheControl?: string;
|
|
386
532
|
readonly feed?: ContentFeedConfig;
|
|
387
533
|
readonly wordsPerMinute?: number;
|
|
534
|
+
/** Slug automático (quando o autor não informa). Padrão: até 60 caracteres, sem palavras de ligação do pt-BR. */
|
|
535
|
+
readonly slug?: {
|
|
536
|
+
readonly maxLength?: number;
|
|
537
|
+
readonly stopWords?: readonly string[] | false;
|
|
538
|
+
};
|
|
388
539
|
};
|
|
389
540
|
declare const DEFAULT_ADMIN_SCOPES: readonly string[];
|
|
390
541
|
declare const DEFAULT_PUBLIC_CACHE_CONTROL = "public, max-age=60, s-maxage=300, stale-while-revalidate=600";
|
|
@@ -402,6 +553,65 @@ declare function slugify(value: string): string;
|
|
|
402
553
|
declare function isValidSlug(value: string): boolean;
|
|
403
554
|
/** `promocao` → `promocao-2` → `promocao-3`. Respeita o teto de tamanho mesmo com o sufixo. */
|
|
404
555
|
declare function withSlugSuffix(slug: string, attempt: number): string;
|
|
556
|
+
/** Padrão do slug automático: curto o bastante para um link legível em qualquer rede. */
|
|
557
|
+
declare const DEFAULT_SHORT_SLUG_LENGTH = 60;
|
|
558
|
+
/** Artigos, preposições e conjunções do pt-BR que só alongam o endereço. */
|
|
559
|
+
declare const PT_BR_STOP_WORDS: readonly string[];
|
|
560
|
+
type ShortSlugOptions = {
|
|
561
|
+
/** Padrão: 60. */
|
|
562
|
+
readonly maxLength?: number;
|
|
563
|
+
/** Padrão: pt-BR. `false` mantém todas as palavras. */
|
|
564
|
+
readonly stopWords?: readonly string[] | false;
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* Slug automático curto: sem acento, sem palavra de ligação, cortado na fronteira de palavra dentro
|
|
568
|
+
* de `maxLength`. "Novidades de fim de ano: cardápio para as festas" → "novidades-fim-ano-cardapio-festas".
|
|
569
|
+
* Título só de palavras de ligação mantém as palavras (melhor longo que vazio).
|
|
570
|
+
*/
|
|
571
|
+
declare function buildShortSlug(title: string, options?: ShortSlugOptions): string;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
575
|
+
*
|
|
576
|
+
* Endereço público do post: `<base>/<shortId>-<slug>`. O id curto é o que identifica o post; o slug é
|
|
577
|
+
* só legibilidade. Trocar o título ou o slug não quebra link compartilhado: a leitura acha pelo id
|
|
578
|
+
* curto, e o host redireciona (301) para o endereço canônico quando o pedido não for ele.
|
|
579
|
+
*/
|
|
580
|
+
declare const SHORT_ID_LENGTH = 6;
|
|
581
|
+
declare function isShortId(value: string): boolean;
|
|
582
|
+
/** `k3x9ab-novidades-fim-ano`. */
|
|
583
|
+
declare function buildPostRef(params: {
|
|
584
|
+
readonly shortId: string;
|
|
585
|
+
readonly slug: string;
|
|
586
|
+
}): string;
|
|
587
|
+
declare function buildPostPath(params: {
|
|
588
|
+
readonly basePath: string;
|
|
589
|
+
readonly shortId: string;
|
|
590
|
+
readonly slug: string;
|
|
591
|
+
}): string;
|
|
592
|
+
type ParsedPostRef = {
|
|
593
|
+
/** Candidato a id curto (os 6 primeiros caracteres antes do hífen), se o formato bate. */
|
|
594
|
+
readonly shortId?: string;
|
|
595
|
+
/** O texto inteiro, como slug antigo (`/<base>/<slug>`). */
|
|
596
|
+
readonly slug: string;
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* Lê o último trecho do endereço. Um slug antigo que por acaso comece com 6 caracteres e hífen também
|
|
600
|
+
* parece `<id>-<slug>`; por isso a leitura tenta o id curto e, se nenhum post tiver esse id, cai no
|
|
601
|
+
* texto inteiro como slug.
|
|
602
|
+
*/
|
|
603
|
+
declare function parsePostRef(ref: string): ParsedPostRef;
|
|
604
|
+
/** `/novidades/k3x9ab-titulo` com base `/novidades` → ref `k3x9ab-titulo`; `undefined` fora da base. */
|
|
605
|
+
declare function parsePostPath(params: {
|
|
606
|
+
readonly path: string;
|
|
607
|
+
readonly basePath: string;
|
|
608
|
+
}): ParsedPostRef | undefined;
|
|
609
|
+
/** O pedido já é o endereço canônico? Se não, o host redireciona (301) para `buildPostRef`. */
|
|
610
|
+
declare function isCanonicalPostRef(params: {
|
|
611
|
+
readonly ref: string;
|
|
612
|
+
readonly shortId: string;
|
|
613
|
+
readonly slug: string;
|
|
614
|
+
}): boolean;
|
|
405
615
|
|
|
406
616
|
/**
|
|
407
617
|
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
@@ -415,6 +625,19 @@ declare const TAGS_MAX_COUNT = 20;
|
|
|
415
625
|
declare function normalizeTag(value: string): string;
|
|
416
626
|
/** Normaliza, remove vazias e repetidas, preserva a ordem em que o autor digitou. */
|
|
417
627
|
declare function normalizeTags(values: readonly string[]): string[];
|
|
628
|
+
type TagLabels = Readonly<Record<string, string>>;
|
|
629
|
+
/**
|
|
630
|
+
* Rótulo de exibição por tag: a tag guarda a forma de URL ("cardápio"), o rótulo guarda como o autor
|
|
631
|
+
* escreveu ("Cardápio"). Só entra no mapa o que difere da tag; o resto cai no rótulo padrão da UI.
|
|
632
|
+
* `explicit` vence o texto digitado; `previous` mantém o rótulo de tag que continua no post.
|
|
633
|
+
*/
|
|
634
|
+
declare function buildTagLabels(params: {
|
|
635
|
+
readonly typed: readonly string[];
|
|
636
|
+
readonly explicit?: TagLabels | undefined;
|
|
637
|
+
readonly previous?: TagLabels | undefined;
|
|
638
|
+
}): TagLabels;
|
|
639
|
+
/** Rótulo padrão sem rótulo guardado: primeira letra maiúscula e hífen vira espaço ("fim-de-ano" → "Fim de ano"). */
|
|
640
|
+
declare function formatTagLabel(tag: string, labels?: TagLabels): string;
|
|
418
641
|
|
|
419
642
|
/**
|
|
420
643
|
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
@@ -469,6 +692,13 @@ type MarkdownInline = {
|
|
|
469
692
|
} | {
|
|
470
693
|
readonly type: 'break';
|
|
471
694
|
};
|
|
695
|
+
type MarkdownFigureImage = {
|
|
696
|
+
readonly src: string;
|
|
697
|
+
readonly alt: string;
|
|
698
|
+
};
|
|
699
|
+
type MarkdownGalleryImage = MarkdownFigureImage & {
|
|
700
|
+
readonly caption?: string;
|
|
701
|
+
};
|
|
472
702
|
type MarkdownBlock = {
|
|
473
703
|
readonly type: 'heading';
|
|
474
704
|
readonly level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
@@ -494,6 +724,17 @@ type MarkdownBlock = {
|
|
|
494
724
|
readonly value: string;
|
|
495
725
|
} | {
|
|
496
726
|
readonly type: 'thematicBreak';
|
|
727
|
+
}
|
|
728
|
+
/** Parágrafo só com uma imagem que tem título: o título vira a legenda. */
|
|
729
|
+
| {
|
|
730
|
+
readonly type: 'figure';
|
|
731
|
+
readonly image: MarkdownFigureImage;
|
|
732
|
+
readonly caption: string;
|
|
733
|
+
}
|
|
734
|
+
/** Parágrafo só com 2+ imagens. */
|
|
735
|
+
| {
|
|
736
|
+
readonly type: 'gallery';
|
|
737
|
+
readonly images: readonly MarkdownGalleryImage[];
|
|
497
738
|
};
|
|
498
739
|
type MarkdownDocument = {
|
|
499
740
|
readonly type: 'root';
|
|
@@ -614,10 +855,11 @@ type SitemapEntry = {
|
|
|
614
855
|
};
|
|
615
856
|
declare const DEFAULT_POST_PATH_TEMPLATE = "/blog/{slug}";
|
|
616
857
|
declare function escapeXml(value: string): string;
|
|
617
|
-
/** `{slug}` no modelo
|
|
858
|
+
/** `{slug}` (e `{shortId}`) no modelo viram o valor codificado; o modelo é relativo ao `siteUrl`. */
|
|
618
859
|
declare function buildPostUrl(params: {
|
|
619
860
|
readonly siteUrl: string;
|
|
620
861
|
readonly slug: string;
|
|
862
|
+
readonly shortId?: string;
|
|
621
863
|
readonly postPathTemplate?: string;
|
|
622
864
|
}): string;
|
|
623
865
|
declare function buildRssFeed(params: {
|
|
@@ -631,4 +873,4 @@ declare function buildAtomFeed(params: {
|
|
|
631
873
|
}): string;
|
|
632
874
|
declare function buildSitemapXml(entries: readonly SitemapEntry[]): string;
|
|
633
875
|
|
|
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 };
|
|
876
|
+
export { CONTENT_ERROR_CODES, type ClockPort, ConfigMissingError, ContentError, type ContentErrorCode, type ContentFeedConfig, type ContentHooks, type ContentImageStoragePort, type ContentModuleConfig, type CreateFromTemplateInput, type CreatePostInput, type CreateRecurrenceInput, DEFAULT_ADMIN_SCOPES, DEFAULT_LINK_REL, DEFAULT_POST_PATH_TEMPLATE, DEFAULT_PUBLIC_CACHE_CONTROL, DEFAULT_SHORT_SLUG_LENGTH, 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 MarkdownFigureImage, type MarkdownGalleryImage, type MarkdownInline, type MarkdownRenderOptions, NotATemplateError, POST_EVENT, POST_LIMITS, POST_SORT_FIELDS, POST_STATUS, POST_STATUSES, PT_BR_STOP_WORDS, type Paginated, type Pagination, type ParsedPostRef, type Post, type PostChangedEvent, type PostCounts, type PostEventType, PostNotFoundError, PostNotPublishedError, type PostSortField, type PostStatus, type PostSummary, type PublicPost, type PublicPostSummary, type PublishPostInput, RECURRENCE_FREQUENCIES, RECURRENCE_FREQUENCY, type RecurrenceFrequency, RecurrenceNotFoundError, type RecurrenceRule, RepublishDateInFutureError, type RepublishPostInput, SHORT_ID_LENGTH, SLUG_MAX_LENGTH, type SaveAsTemplateInput, type ShortSlugOptions, type SitemapEntry, TAGS_MAX_COUNT, TAG_MAX_LENGTH, type TagCount, type TagLabels, TemplateNotPublishableError, type UpdatePostInput, type UpdateRecurrenceInput, buildAtomFeed, buildExcerpt, buildPostPath, buildPostRef, buildPostUrl, buildRssFeed, buildShortSlug, buildSitemapXml, buildTagLabels, countWords, createFromTemplateSchema, createHeadingIdGenerator, createPostSchema, createRecurrenceSchema, documentToPlainText, escapeHtml, escapeXml, estimateReadingTimeMinutes, formatTagLabel, httpUrlSchema, inlineToPlainText, isAbsoluteHttpUrl, isCanonicalPostRef, isPostStatus, isShortId, isValidSlug, listPostsQuerySchema, listPublishedPostsQuerySchema, markdownToPlainText, normalizeTag, normalizeTags, parseInline, parseMarkdown, parsePostPath, parsePostRef, postFieldsSchema, publishPostSchema, renderMarkdownDocument, renderMarkdownToHtml, republishPostSchema, resolveHeadingLevel, sanitizeImageUrl, sanitizeLinkUrl, saveAsTemplateSchema, slugSchema, slugify, updatePostSchema, updateRecurrenceSchema, withSlugSuffix };
|