@adatechnology/content-contracts 0.2.0 → 0.4.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 +359 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +377 -2
- package/dist/index.d.ts +377 -2
- package/dist/index.js +329 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,10 +21,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
|
+
BULK_MODERATION_ACTIONS: () => BULK_MODERATION_ACTIONS,
|
|
25
|
+
COMMUNITY_MODERATION: () => COMMUNITY_MODERATION,
|
|
26
|
+
COMMUNITY_MODERATIONS: () => COMMUNITY_MODERATIONS,
|
|
27
|
+
COMMUNITY_REVISION_STATE: () => COMMUNITY_REVISION_STATE,
|
|
24
28
|
CONTENT_ERROR_CODES: () => CONTENT_ERROR_CODES,
|
|
29
|
+
CommunityAuthorNotEligibleError: () => CommunityAuthorNotEligibleError,
|
|
30
|
+
CommunityDailyLimitError: () => CommunityDailyLimitError,
|
|
31
|
+
CommunityImageNotAllowedError: () => CommunityImageNotAllowedError,
|
|
32
|
+
CommunityPostReadOnlyError: () => CommunityPostReadOnlyError,
|
|
33
|
+
CommunityTermsRequiredError: () => CommunityTermsRequiredError,
|
|
34
|
+
CommunityTooManyImagesError: () => CommunityTooManyImagesError,
|
|
35
|
+
CommunityUnauthenticatedError: () => CommunityUnauthenticatedError,
|
|
25
36
|
ConfigMissingError: () => ConfigMissingError,
|
|
26
37
|
ContentError: () => ContentError,
|
|
27
38
|
DEFAULT_ADMIN_SCOPES: () => DEFAULT_ADMIN_SCOPES,
|
|
39
|
+
DEFAULT_CONTENT_SETTINGS: () => DEFAULT_CONTENT_SETTINGS,
|
|
28
40
|
DEFAULT_LINK_REL: () => DEFAULT_LINK_REL,
|
|
29
41
|
DEFAULT_POST_PATH_TEMPLATE: () => DEFAULT_POST_PATH_TEMPLATE,
|
|
30
42
|
DEFAULT_PUBLIC_CACHE_CONTROL: () => DEFAULT_PUBLIC_CACHE_CONTROL,
|
|
@@ -33,10 +45,14 @@ __export(index_exports, {
|
|
|
33
45
|
DuplicateSlugError: () => DuplicateSlugError,
|
|
34
46
|
ImageStorageDisabledError: () => ImageStorageDisabledError,
|
|
35
47
|
InvalidCoverImageError: () => InvalidCoverImageError,
|
|
48
|
+
InvalidPostTransitionError: () => InvalidPostTransitionError,
|
|
36
49
|
InvalidSlugError: () => InvalidSlugError,
|
|
37
50
|
NotATemplateError: () => NotATemplateError,
|
|
38
51
|
POST_EVENT: () => POST_EVENT,
|
|
39
52
|
POST_LIMITS: () => POST_LIMITS,
|
|
53
|
+
POST_ORIGIN: () => POST_ORIGIN,
|
|
54
|
+
POST_ORIGINS: () => POST_ORIGINS,
|
|
55
|
+
POST_ORIGIN_FILTERS: () => POST_ORIGIN_FILTERS,
|
|
40
56
|
POST_SORT_FIELDS: () => POST_SORT_FIELDS,
|
|
41
57
|
POST_STATUS: () => POST_STATUS,
|
|
42
58
|
POST_STATUSES: () => POST_STATUSES,
|
|
@@ -45,7 +61,9 @@ __export(index_exports, {
|
|
|
45
61
|
PostNotPublishedError: () => PostNotPublishedError,
|
|
46
62
|
RECURRENCE_FREQUENCIES: () => RECURRENCE_FREQUENCIES,
|
|
47
63
|
RECURRENCE_FREQUENCY: () => RECURRENCE_FREQUENCY,
|
|
64
|
+
REPORT_STATUSES: () => REPORT_STATUSES,
|
|
48
65
|
RecurrenceNotFoundError: () => RecurrenceNotFoundError,
|
|
66
|
+
ReportNotFoundError: () => ReportNotFoundError,
|
|
49
67
|
RepublishDateInFutureError: () => RepublishDateInFutureError,
|
|
50
68
|
SHORT_ID_LENGTH: () => SHORT_ID_LENGTH,
|
|
51
69
|
SLUG_MAX_LENGTH: () => SLUG_MAX_LENGTH,
|
|
@@ -61,9 +79,16 @@ __export(index_exports, {
|
|
|
61
79
|
buildShortSlug: () => buildShortSlug,
|
|
62
80
|
buildSitemapXml: () => buildSitemapXml,
|
|
63
81
|
buildTagLabels: () => buildTagLabels,
|
|
82
|
+
bulkModerationSchema: () => bulkModerationSchema,
|
|
83
|
+
collectImageSources: () => collectImageSources,
|
|
84
|
+
communityDisplayNameSchema: () => communityDisplayNameSchema,
|
|
85
|
+
communityRevisionSchema: () => communityRevisionSchema,
|
|
86
|
+
contentSettingsSchema: () => contentSettingsSchema,
|
|
64
87
|
countWords: () => countWords,
|
|
88
|
+
createCommunityPostSchema: () => createCommunityPostSchema,
|
|
65
89
|
createFromTemplateSchema: () => createFromTemplateSchema,
|
|
66
90
|
createHeadingIdGenerator: () => createHeadingIdGenerator,
|
|
91
|
+
createPostReportSchema: () => createPostReportSchema,
|
|
67
92
|
createPostSchema: () => createPostSchema,
|
|
68
93
|
createRecurrenceSchema: () => createRecurrenceSchema,
|
|
69
94
|
documentToPlainText: () => documentToPlainText,
|
|
@@ -78,6 +103,7 @@ __export(index_exports, {
|
|
|
78
103
|
isPostStatus: () => isPostStatus,
|
|
79
104
|
isShortId: () => isShortId,
|
|
80
105
|
isValidSlug: () => isValidSlug,
|
|
106
|
+
listPostReportsQuerySchema: () => listPostReportsQuerySchema,
|
|
81
107
|
listPostsQuerySchema: () => listPostsQuerySchema,
|
|
82
108
|
listPublishedPostsQuerySchema: () => listPublishedPostsQuerySchema,
|
|
83
109
|
markdownToPlainText: () => markdownToPlainText,
|
|
@@ -89,6 +115,7 @@ __export(index_exports, {
|
|
|
89
115
|
parsePostRef: () => parsePostRef,
|
|
90
116
|
postFieldsSchema: () => postFieldsSchema,
|
|
91
117
|
publishPostSchema: () => publishPostSchema,
|
|
118
|
+
rejectPostSchema: () => rejectPostSchema,
|
|
92
119
|
renderMarkdownDocument: () => renderMarkdownDocument,
|
|
93
120
|
renderMarkdownToHtml: () => renderMarkdownToHtml,
|
|
94
121
|
republishPostSchema: () => republishPostSchema,
|
|
@@ -98,6 +125,9 @@ __export(index_exports, {
|
|
|
98
125
|
saveAsTemplateSchema: () => saveAsTemplateSchema,
|
|
99
126
|
slugSchema: () => slugSchema,
|
|
100
127
|
slugify: () => slugify,
|
|
128
|
+
submitCommunityPostSchema: () => submitCommunityPostSchema,
|
|
129
|
+
unpublishCommunityPostSchema: () => unpublishCommunityPostSchema,
|
|
130
|
+
updateCommunityPostSchema: () => updateCommunityPostSchema,
|
|
101
131
|
updatePostSchema: () => updatePostSchema,
|
|
102
132
|
updateRecurrenceSchema: () => updateRecurrenceSchema,
|
|
103
133
|
withSlugSuffix: () => withSlugSuffix
|
|
@@ -109,13 +139,36 @@ var POST_STATUS = {
|
|
|
109
139
|
DRAFT: "draft",
|
|
110
140
|
SCHEDULED: "scheduled",
|
|
111
141
|
PUBLISHED: "published",
|
|
112
|
-
ARCHIVED: "archived"
|
|
142
|
+
ARCHIVED: "archived",
|
|
143
|
+
/** Post da comunidade enviado e aguardando a equipe (moderação `before`). */
|
|
144
|
+
PENDING_REVIEW: "pending_review",
|
|
145
|
+
/** Post da comunidade recusado ou despublicado pela equipe; o autor pode editar e reenviar. */
|
|
146
|
+
REJECTED: "rejected"
|
|
113
147
|
};
|
|
114
148
|
var POST_STATUSES = Object.values(POST_STATUS);
|
|
115
149
|
function isPostStatus(value) {
|
|
116
150
|
return typeof value === "string" && POST_STATUSES.includes(value);
|
|
117
151
|
}
|
|
118
152
|
__name(isPostStatus, "isPostStatus");
|
|
153
|
+
var POST_ORIGIN = {
|
|
154
|
+
STAFF: "staff",
|
|
155
|
+
COMMUNITY: "community"
|
|
156
|
+
};
|
|
157
|
+
var POST_ORIGINS = Object.values(POST_ORIGIN);
|
|
158
|
+
var COMMUNITY_MODERATION = {
|
|
159
|
+
BEFORE: "before",
|
|
160
|
+
AFTER: "after"
|
|
161
|
+
};
|
|
162
|
+
var COMMUNITY_MODERATIONS = Object.values(COMMUNITY_MODERATION);
|
|
163
|
+
var COMMUNITY_REVISION_STATE = {
|
|
164
|
+
PENDING: "pending",
|
|
165
|
+
REJECTED: "rejected"
|
|
166
|
+
};
|
|
167
|
+
var DEFAULT_CONTENT_SETTINGS = {
|
|
168
|
+
communityModeration: COMMUNITY_MODERATION.BEFORE,
|
|
169
|
+
communityDailyLimit: 3,
|
|
170
|
+
maxImagesPerPost: 12
|
|
171
|
+
};
|
|
119
172
|
var RECURRENCE_FREQUENCY = {
|
|
120
173
|
WEEKLY: "weekly",
|
|
121
174
|
MONTHLY: "monthly"
|
|
@@ -130,8 +183,9 @@ var ContentError = class extends Error {
|
|
|
130
183
|
statusCode;
|
|
131
184
|
code;
|
|
132
185
|
details;
|
|
133
|
-
|
|
134
|
-
|
|
186
|
+
publicDetails;
|
|
187
|
+
constructor(message, statusCode, code, details, publicDetails) {
|
|
188
|
+
super(message), this.statusCode = statusCode, this.code = code, this.details = details, this.publicDetails = publicDetails;
|
|
135
189
|
this.name = "ContentError";
|
|
136
190
|
}
|
|
137
191
|
};
|
|
@@ -146,7 +200,16 @@ var CONTENT_ERROR_CODES = {
|
|
|
146
200
|
TEMPLATE_NOT_PUBLISHABLE: "CONTENT_TEMPLATE_NOT_PUBLISHABLE",
|
|
147
201
|
NOT_PUBLISHED: "CONTENT_NOT_PUBLISHED",
|
|
148
202
|
REPUBLISH_DATE_IN_FUTURE: "CONTENT_REPUBLISH_DATE_IN_FUTURE",
|
|
149
|
-
RECURRENCE_NOT_FOUND: "CONTENT_RECURRENCE_NOT_FOUND"
|
|
203
|
+
RECURRENCE_NOT_FOUND: "CONTENT_RECURRENCE_NOT_FOUND",
|
|
204
|
+
COMMUNITY_UNAUTHENTICATED: "CONTENT_COMMUNITY_UNAUTHENTICATED",
|
|
205
|
+
COMMUNITY_AUTHOR_NOT_ELIGIBLE: "CONTENT_COMMUNITY_AUTHOR_NOT_ELIGIBLE",
|
|
206
|
+
COMMUNITY_DAILY_LIMIT: "CONTENT_COMMUNITY_DAILY_LIMIT",
|
|
207
|
+
COMMUNITY_TERMS_REQUIRED: "CONTENT_COMMUNITY_TERMS_REQUIRED",
|
|
208
|
+
COMMUNITY_TOO_MANY_IMAGES: "CONTENT_COMMUNITY_TOO_MANY_IMAGES",
|
|
209
|
+
COMMUNITY_IMAGE_NOT_ALLOWED: "CONTENT_COMMUNITY_IMAGE_NOT_ALLOWED",
|
|
210
|
+
INVALID_TRANSITION: "CONTENT_INVALID_TRANSITION",
|
|
211
|
+
COMMUNITY_POST_READ_ONLY: "CONTENT_COMMUNITY_POST_READ_ONLY",
|
|
212
|
+
REPORT_NOT_FOUND: "CONTENT_REPORT_NOT_FOUND"
|
|
150
213
|
};
|
|
151
214
|
var PostNotFoundError = class extends ContentError {
|
|
152
215
|
static {
|
|
@@ -263,6 +326,97 @@ var RecurrenceNotFoundError = class extends ContentError {
|
|
|
263
326
|
}), this.reference = reference;
|
|
264
327
|
}
|
|
265
328
|
};
|
|
329
|
+
var CommunityUnauthenticatedError = class extends ContentError {
|
|
330
|
+
static {
|
|
331
|
+
__name(this, "CommunityUnauthenticatedError");
|
|
332
|
+
}
|
|
333
|
+
constructor() {
|
|
334
|
+
super("Entre na sua conta para continuar.", 401, CONTENT_ERROR_CODES.COMMUNITY_UNAUTHENTICATED);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
var CommunityAuthorNotEligibleError = class extends ContentError {
|
|
338
|
+
static {
|
|
339
|
+
__name(this, "CommunityAuthorNotEligibleError");
|
|
340
|
+
}
|
|
341
|
+
constructor() {
|
|
342
|
+
super("Sua conta ainda n\xE3o pode publicar na comunidade.", 403, CONTENT_ERROR_CODES.COMMUNITY_AUTHOR_NOT_ELIGIBLE);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
var CommunityDailyLimitError = class extends ContentError {
|
|
346
|
+
static {
|
|
347
|
+
__name(this, "CommunityDailyLimitError");
|
|
348
|
+
}
|
|
349
|
+
limit;
|
|
350
|
+
retryAfterSeconds;
|
|
351
|
+
constructor(limit, retryAfterSeconds) {
|
|
352
|
+
super("Limite de posts nas \xFAltimas 24 horas atingido.", 429, CONTENT_ERROR_CODES.COMMUNITY_DAILY_LIMIT, void 0, {
|
|
353
|
+
limit,
|
|
354
|
+
retryAfterSeconds
|
|
355
|
+
}), this.limit = limit, this.retryAfterSeconds = retryAfterSeconds;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var CommunityTermsRequiredError = class extends ContentError {
|
|
359
|
+
static {
|
|
360
|
+
__name(this, "CommunityTermsRequiredError");
|
|
361
|
+
}
|
|
362
|
+
constructor() {
|
|
363
|
+
super("Aceite os termos para enviar o post.", 422, CONTENT_ERROR_CODES.COMMUNITY_TERMS_REQUIRED);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
var CommunityTooManyImagesError = class extends ContentError {
|
|
367
|
+
static {
|
|
368
|
+
__name(this, "CommunityTooManyImagesError");
|
|
369
|
+
}
|
|
370
|
+
max;
|
|
371
|
+
constructor(max) {
|
|
372
|
+
super("O post tem mais fotos do que o permitido.", 422, CONTENT_ERROR_CODES.COMMUNITY_TOO_MANY_IMAGES, void 0, {
|
|
373
|
+
max
|
|
374
|
+
}), this.max = max;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
var CommunityImageNotAllowedError = class extends ContentError {
|
|
378
|
+
static {
|
|
379
|
+
__name(this, "CommunityImageNotAllowedError");
|
|
380
|
+
}
|
|
381
|
+
constructor() {
|
|
382
|
+
super("Use apenas fotos enviadas por voc\xEA neste site.", 422, CONTENT_ERROR_CODES.COMMUNITY_IMAGE_NOT_ALLOWED);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
var InvalidPostTransitionError = class extends ContentError {
|
|
386
|
+
static {
|
|
387
|
+
__name(this, "InvalidPostTransitionError");
|
|
388
|
+
}
|
|
389
|
+
from;
|
|
390
|
+
action;
|
|
391
|
+
constructor(from, action) {
|
|
392
|
+
super("Esta a\xE7\xE3o n\xE3o \xE9 poss\xEDvel no estado atual do post.", 409, CONTENT_ERROR_CODES.INVALID_TRANSITION, void 0, {
|
|
393
|
+
from,
|
|
394
|
+
action
|
|
395
|
+
}), this.from = from, this.action = action;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
var CommunityPostReadOnlyError = class extends ContentError {
|
|
399
|
+
static {
|
|
400
|
+
__name(this, "CommunityPostReadOnlyError");
|
|
401
|
+
}
|
|
402
|
+
postId;
|
|
403
|
+
constructor(postId) {
|
|
404
|
+
super("Post da comunidade s\xF3 pode ser moderado, n\xE3o editado.", 409, CONTENT_ERROR_CODES.COMMUNITY_POST_READ_ONLY, {
|
|
405
|
+
postId
|
|
406
|
+
}), this.postId = postId;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var ReportNotFoundError = class extends ContentError {
|
|
410
|
+
static {
|
|
411
|
+
__name(this, "ReportNotFoundError");
|
|
412
|
+
}
|
|
413
|
+
reference;
|
|
414
|
+
constructor(reference) {
|
|
415
|
+
super("Den\xFAncia n\xE3o encontrada.", 404, CONTENT_ERROR_CODES.REPORT_NOT_FOUND, {
|
|
416
|
+
reference
|
|
417
|
+
}), this.reference = reference;
|
|
418
|
+
}
|
|
419
|
+
};
|
|
266
420
|
|
|
267
421
|
// src/schemas.ts
|
|
268
422
|
var import_zod = require("zod");
|
|
@@ -392,8 +546,20 @@ var POST_LIMITS = {
|
|
|
392
546
|
SEO_DESCRIPTION: 320,
|
|
393
547
|
SEARCH: 120,
|
|
394
548
|
ADMIN_PAGE_SIZE: 100,
|
|
395
|
-
PUBLIC_PAGE_SIZE: 50
|
|
549
|
+
PUBLIC_PAGE_SIZE: 50,
|
|
550
|
+
DISPLAY_NAME_MIN: 2,
|
|
551
|
+
DISPLAY_NAME_MAX: 40,
|
|
552
|
+
REVIEW_NOTE: 500,
|
|
553
|
+
REPORT_REASON_MIN: 3,
|
|
554
|
+
REPORT_REASON_MAX: 300,
|
|
555
|
+
BULK_IDS: 100
|
|
396
556
|
};
|
|
557
|
+
var POST_ORIGIN_FILTERS = [
|
|
558
|
+
"staff",
|
|
559
|
+
"community",
|
|
560
|
+
"all"
|
|
561
|
+
];
|
|
562
|
+
var originFilterSchema = import_zod.z.enum(POST_ORIGIN_FILTERS).default("staff");
|
|
397
563
|
var slugSchema = import_zod.z.string().trim().toLowerCase().max(SLUG_MAX_LENGTH).refine(isValidSlug, {
|
|
398
564
|
message: "Use letras min\xFAsculas, n\xFAmeros e h\xEDfen."
|
|
399
565
|
});
|
|
@@ -452,12 +618,14 @@ var listPostsQuerySchema = import_zod.z.object({
|
|
|
452
618
|
"true",
|
|
453
619
|
"false"
|
|
454
620
|
])
|
|
455
|
-
]).transform((value) => value === true || value === "true").optional()
|
|
621
|
+
]).transform((value) => value === true || value === "true").optional(),
|
|
622
|
+
origin: originFilterSchema
|
|
456
623
|
});
|
|
457
624
|
var listPublishedPostsQuerySchema = import_zod.z.object({
|
|
458
625
|
page: pageSchema,
|
|
459
626
|
pageSize: import_zod.z.coerce.number().int().min(1).max(POST_LIMITS.PUBLIC_PAGE_SIZE).default(10),
|
|
460
|
-
tag: import_zod.z.string().trim().min(1).max(TAG_MAX_LENGTH).optional()
|
|
627
|
+
tag: import_zod.z.string().trim().min(1).max(TAG_MAX_LENGTH).optional(),
|
|
628
|
+
origin: originFilterSchema
|
|
461
629
|
});
|
|
462
630
|
var isoInstant = import_zod.z.string().datetime({
|
|
463
631
|
offset: true
|
|
@@ -482,6 +650,66 @@ var updateRecurrenceSchema = import_zod.z.object({
|
|
|
482
650
|
isActive: import_zod.z.boolean().optional(),
|
|
483
651
|
nextRunAt: isoInstant.optional()
|
|
484
652
|
}).strict();
|
|
653
|
+
var communityDisplayNameSchema = import_zod.z.string().trim().min(POST_LIMITS.DISPLAY_NAME_MIN).max(POST_LIMITS.DISPLAY_NAME_MAX).refine((value) => !value.includes("@") && !/\d{5,}/.test(value) && !/http/i.test(value), {
|
|
654
|
+
message: "O nome n\xE3o pode ter e-mail, telefone ou endere\xE7o de site."
|
|
655
|
+
});
|
|
656
|
+
var communityFieldsSchema = import_zod.z.object({
|
|
657
|
+
title: import_zod.z.string().trim().min(1).max(POST_LIMITS.TITLE),
|
|
658
|
+
body: import_zod.z.string().max(POST_LIMITS.BODY),
|
|
659
|
+
excerpt: optionalText(POST_LIMITS.EXCERPT),
|
|
660
|
+
displayName: communityDisplayNameSchema.optional()
|
|
661
|
+
});
|
|
662
|
+
var createCommunityPostSchema = communityFieldsSchema.strict();
|
|
663
|
+
var updateCommunityPostSchema = communityFieldsSchema.partial().strict();
|
|
664
|
+
var submitCommunityPostSchema = import_zod.z.object({
|
|
665
|
+
termsAccepted: import_zod.z.boolean()
|
|
666
|
+
}).strict();
|
|
667
|
+
var rejectPostSchema = import_zod.z.object({
|
|
668
|
+
note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE)
|
|
669
|
+
}).strict();
|
|
670
|
+
var unpublishCommunityPostSchema = import_zod.z.object({
|
|
671
|
+
note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional()
|
|
672
|
+
}).strict();
|
|
673
|
+
var BULK_MODERATION_ACTIONS = [
|
|
674
|
+
"approve",
|
|
675
|
+
"reject",
|
|
676
|
+
"unpublish",
|
|
677
|
+
"archive"
|
|
678
|
+
];
|
|
679
|
+
var bulkModerationSchema = import_zod.z.object({
|
|
680
|
+
action: import_zod.z.enum(BULK_MODERATION_ACTIONS),
|
|
681
|
+
ids: import_zod.z.array(import_zod.z.string().uuid()).min(1).max(POST_LIMITS.BULK_IDS),
|
|
682
|
+
note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional()
|
|
683
|
+
}).strict();
|
|
684
|
+
var contentSettingsSchema = import_zod.z.object({
|
|
685
|
+
communityModeration: import_zod.z.enum(COMMUNITY_MODERATIONS),
|
|
686
|
+
communityDailyLimit: import_zod.z.number().int().min(1).max(50),
|
|
687
|
+
maxImagesPerPost: import_zod.z.number().int().min(1).max(30)
|
|
688
|
+
}).strict();
|
|
689
|
+
var createPostReportSchema = import_zod.z.object({
|
|
690
|
+
reason: import_zod.z.string().trim().min(POST_LIMITS.REPORT_REASON_MIN).max(POST_LIMITS.REPORT_REASON_MAX)
|
|
691
|
+
}).strict();
|
|
692
|
+
var REPORT_STATUSES = [
|
|
693
|
+
"open",
|
|
694
|
+
"resolved"
|
|
695
|
+
];
|
|
696
|
+
var listPostReportsQuerySchema = import_zod.z.object({
|
|
697
|
+
page: pageSchema,
|
|
698
|
+
pageSize: import_zod.z.coerce.number().int().min(1).max(POST_LIMITS.ADMIN_PAGE_SIZE).default(20),
|
|
699
|
+
status: import_zod.z.enum(REPORT_STATUSES).default("open")
|
|
700
|
+
});
|
|
701
|
+
var communityRevisionSchema = import_zod.z.object({
|
|
702
|
+
title: import_zod.z.string(),
|
|
703
|
+
excerpt: import_zod.z.string().nullable(),
|
|
704
|
+
body: import_zod.z.string(),
|
|
705
|
+
state: import_zod.z.enum([
|
|
706
|
+
COMMUNITY_REVISION_STATE.PENDING,
|
|
707
|
+
COMMUNITY_REVISION_STATE.REJECTED
|
|
708
|
+
]),
|
|
709
|
+
submittedAt: import_zod.z.string().datetime({
|
|
710
|
+
offset: true
|
|
711
|
+
})
|
|
712
|
+
});
|
|
485
713
|
|
|
486
714
|
// src/providers.ts
|
|
487
715
|
var POST_EVENT = {
|
|
@@ -900,6 +1128,47 @@ function parseDestination(text, start) {
|
|
|
900
1128
|
}
|
|
901
1129
|
__name(parseDestination, "parseDestination");
|
|
902
1130
|
|
|
1131
|
+
// src/markdown/paragraphToBlock.ts
|
|
1132
|
+
function isFiller(node) {
|
|
1133
|
+
return node.type === "break" || node.type === "text" && !node.value.trim();
|
|
1134
|
+
}
|
|
1135
|
+
__name(isFiller, "isFiller");
|
|
1136
|
+
function paragraphToBlock(children) {
|
|
1137
|
+
const meaningful = children.filter((node) => !isFiller(node));
|
|
1138
|
+
const images = meaningful.filter((node) => node.type === "image");
|
|
1139
|
+
if (images.length === 0 || images.length !== meaningful.length) return {
|
|
1140
|
+
type: "paragraph",
|
|
1141
|
+
children
|
|
1142
|
+
};
|
|
1143
|
+
const [only] = images;
|
|
1144
|
+
if (images.length === 1 && only?.title) {
|
|
1145
|
+
return {
|
|
1146
|
+
type: "figure",
|
|
1147
|
+
image: {
|
|
1148
|
+
src: only.src,
|
|
1149
|
+
alt: only.alt
|
|
1150
|
+
},
|
|
1151
|
+
caption: only.title
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
if (images.length < 2) return {
|
|
1155
|
+
type: "paragraph",
|
|
1156
|
+
children
|
|
1157
|
+
};
|
|
1158
|
+
const gallery = images.map((image) => ({
|
|
1159
|
+
src: image.src,
|
|
1160
|
+
alt: image.alt,
|
|
1161
|
+
...image.title ? {
|
|
1162
|
+
caption: image.title
|
|
1163
|
+
} : {}
|
|
1164
|
+
}));
|
|
1165
|
+
return {
|
|
1166
|
+
type: "gallery",
|
|
1167
|
+
images: gallery
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
__name(paragraphToBlock, "paragraphToBlock");
|
|
1171
|
+
|
|
903
1172
|
// src/markdown/parseMarkdown.ts
|
|
904
1173
|
var MAX_BLOCK_DEPTH = 6;
|
|
905
1174
|
var FENCE_PATTERN = /^ {0,3}(`{3,}|~{3,})\s*([^\s`]*)[^`]*$/;
|
|
@@ -1021,10 +1290,7 @@ function parseParagraph(lines, index, depth) {
|
|
|
1021
1290
|
cursor += 1;
|
|
1022
1291
|
}
|
|
1023
1292
|
return {
|
|
1024
|
-
block:
|
|
1025
|
-
type: "paragraph",
|
|
1026
|
-
children: parseInline(content.join("\n").trimEnd())
|
|
1027
|
-
},
|
|
1293
|
+
block: paragraphToBlock(parseInline(content.join("\n").trimEnd())),
|
|
1028
1294
|
next: cursor
|
|
1029
1295
|
};
|
|
1030
1296
|
}
|
|
@@ -1136,7 +1402,10 @@ function blockToPlainText(block) {
|
|
|
1136
1402
|
return block.children.map(blockToPlainText).join("\n\n");
|
|
1137
1403
|
case "list":
|
|
1138
1404
|
return block.items.map((item) => item.map(blockToPlainText).join("\n")).join("\n");
|
|
1405
|
+
case "figure":
|
|
1406
|
+
return block.caption;
|
|
1139
1407
|
case "thematicBreak":
|
|
1408
|
+
case "gallery":
|
|
1140
1409
|
return "";
|
|
1141
1410
|
}
|
|
1142
1411
|
}
|
|
@@ -1232,6 +1501,12 @@ function renderInlineNode(node, context) {
|
|
|
1232
1501
|
}
|
|
1233
1502
|
}
|
|
1234
1503
|
__name(renderInlineNode, "renderInlineNode");
|
|
1504
|
+
function renderFigure(image, caption) {
|
|
1505
|
+
const img = `<img src="${escapeHtml(image.src)}" alt="${escapeHtml(image.alt)}" loading="lazy" decoding="async">`;
|
|
1506
|
+
const figcaption = caption ? `<figcaption>${escapeHtml(caption)}</figcaption>` : "";
|
|
1507
|
+
return `<figure class="adc-figure">${img}${figcaption}</figure>`;
|
|
1508
|
+
}
|
|
1509
|
+
__name(renderFigure, "renderFigure");
|
|
1235
1510
|
function renderBlock(block, context, tight = false) {
|
|
1236
1511
|
switch (block.type) {
|
|
1237
1512
|
case "heading": {
|
|
@@ -1249,6 +1524,10 @@ function renderBlock(block, context, tight = false) {
|
|
|
1249
1524
|
}
|
|
1250
1525
|
case "thematicBreak":
|
|
1251
1526
|
return "<hr>";
|
|
1527
|
+
case "figure":
|
|
1528
|
+
return renderFigure(block.image, block.caption);
|
|
1529
|
+
case "gallery":
|
|
1530
|
+
return `<div class="adc-gallery" data-count="${block.images.length}">${block.images.map((image) => renderFigure(image, image.caption)).join("")}</div>`;
|
|
1252
1531
|
case "list": {
|
|
1253
1532
|
const tag = block.ordered ? "ol" : "ul";
|
|
1254
1533
|
const start = block.ordered && block.start !== void 0 && block.start !== 1 ? ` start="${block.start}"` : "";
|
|
@@ -1271,6 +1550,45 @@ function renderMarkdownToHtml(markdown, options = {}) {
|
|
|
1271
1550
|
}
|
|
1272
1551
|
__name(renderMarkdownToHtml, "renderMarkdownToHtml");
|
|
1273
1552
|
|
|
1553
|
+
// src/markdown/collectImageSources.ts
|
|
1554
|
+
function collectFromInline(nodes, sources) {
|
|
1555
|
+
for (const node of nodes) {
|
|
1556
|
+
if (node.type === "image") sources.push(node.src);
|
|
1557
|
+
else if ("children" in node) collectFromInline(node.children, sources);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
__name(collectFromInline, "collectFromInline");
|
|
1561
|
+
function collectFromBlock(block, sources) {
|
|
1562
|
+
switch (block.type) {
|
|
1563
|
+
case "heading":
|
|
1564
|
+
case "paragraph":
|
|
1565
|
+
collectFromInline(block.children, sources);
|
|
1566
|
+
return;
|
|
1567
|
+
case "blockquote":
|
|
1568
|
+
for (const child of block.children) collectFromBlock(child, sources);
|
|
1569
|
+
return;
|
|
1570
|
+
case "list":
|
|
1571
|
+
for (const item of block.items) for (const child of item) collectFromBlock(child, sources);
|
|
1572
|
+
return;
|
|
1573
|
+
case "figure":
|
|
1574
|
+
sources.push(block.image.src);
|
|
1575
|
+
return;
|
|
1576
|
+
case "gallery":
|
|
1577
|
+
for (const image of block.images) sources.push(image.src);
|
|
1578
|
+
return;
|
|
1579
|
+
case "codeBlock":
|
|
1580
|
+
case "thematicBreak":
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
__name(collectFromBlock, "collectFromBlock");
|
|
1585
|
+
function collectImageSources(document) {
|
|
1586
|
+
const sources = [];
|
|
1587
|
+
for (const block of document.children) collectFromBlock(block, sources);
|
|
1588
|
+
return sources;
|
|
1589
|
+
}
|
|
1590
|
+
__name(collectImageSources, "collectImageSources");
|
|
1591
|
+
|
|
1274
1592
|
// src/feed.ts
|
|
1275
1593
|
var DEFAULT_POST_PATH_TEMPLATE = "/blog/{slug}";
|
|
1276
1594
|
var XML_ESCAPES = {
|
|
@@ -1367,10 +1685,22 @@ function buildSitemapXml(entries) {
|
|
|
1367
1685
|
__name(buildSitemapXml, "buildSitemapXml");
|
|
1368
1686
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1369
1687
|
0 && (module.exports = {
|
|
1688
|
+
BULK_MODERATION_ACTIONS,
|
|
1689
|
+
COMMUNITY_MODERATION,
|
|
1690
|
+
COMMUNITY_MODERATIONS,
|
|
1691
|
+
COMMUNITY_REVISION_STATE,
|
|
1370
1692
|
CONTENT_ERROR_CODES,
|
|
1693
|
+
CommunityAuthorNotEligibleError,
|
|
1694
|
+
CommunityDailyLimitError,
|
|
1695
|
+
CommunityImageNotAllowedError,
|
|
1696
|
+
CommunityPostReadOnlyError,
|
|
1697
|
+
CommunityTermsRequiredError,
|
|
1698
|
+
CommunityTooManyImagesError,
|
|
1699
|
+
CommunityUnauthenticatedError,
|
|
1371
1700
|
ConfigMissingError,
|
|
1372
1701
|
ContentError,
|
|
1373
1702
|
DEFAULT_ADMIN_SCOPES,
|
|
1703
|
+
DEFAULT_CONTENT_SETTINGS,
|
|
1374
1704
|
DEFAULT_LINK_REL,
|
|
1375
1705
|
DEFAULT_POST_PATH_TEMPLATE,
|
|
1376
1706
|
DEFAULT_PUBLIC_CACHE_CONTROL,
|
|
@@ -1379,10 +1709,14 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1379
1709
|
DuplicateSlugError,
|
|
1380
1710
|
ImageStorageDisabledError,
|
|
1381
1711
|
InvalidCoverImageError,
|
|
1712
|
+
InvalidPostTransitionError,
|
|
1382
1713
|
InvalidSlugError,
|
|
1383
1714
|
NotATemplateError,
|
|
1384
1715
|
POST_EVENT,
|
|
1385
1716
|
POST_LIMITS,
|
|
1717
|
+
POST_ORIGIN,
|
|
1718
|
+
POST_ORIGINS,
|
|
1719
|
+
POST_ORIGIN_FILTERS,
|
|
1386
1720
|
POST_SORT_FIELDS,
|
|
1387
1721
|
POST_STATUS,
|
|
1388
1722
|
POST_STATUSES,
|
|
@@ -1391,7 +1725,9 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1391
1725
|
PostNotPublishedError,
|
|
1392
1726
|
RECURRENCE_FREQUENCIES,
|
|
1393
1727
|
RECURRENCE_FREQUENCY,
|
|
1728
|
+
REPORT_STATUSES,
|
|
1394
1729
|
RecurrenceNotFoundError,
|
|
1730
|
+
ReportNotFoundError,
|
|
1395
1731
|
RepublishDateInFutureError,
|
|
1396
1732
|
SHORT_ID_LENGTH,
|
|
1397
1733
|
SLUG_MAX_LENGTH,
|
|
@@ -1407,9 +1743,16 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1407
1743
|
buildShortSlug,
|
|
1408
1744
|
buildSitemapXml,
|
|
1409
1745
|
buildTagLabels,
|
|
1746
|
+
bulkModerationSchema,
|
|
1747
|
+
collectImageSources,
|
|
1748
|
+
communityDisplayNameSchema,
|
|
1749
|
+
communityRevisionSchema,
|
|
1750
|
+
contentSettingsSchema,
|
|
1410
1751
|
countWords,
|
|
1752
|
+
createCommunityPostSchema,
|
|
1411
1753
|
createFromTemplateSchema,
|
|
1412
1754
|
createHeadingIdGenerator,
|
|
1755
|
+
createPostReportSchema,
|
|
1413
1756
|
createPostSchema,
|
|
1414
1757
|
createRecurrenceSchema,
|
|
1415
1758
|
documentToPlainText,
|
|
@@ -1424,6 +1767,7 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1424
1767
|
isPostStatus,
|
|
1425
1768
|
isShortId,
|
|
1426
1769
|
isValidSlug,
|
|
1770
|
+
listPostReportsQuerySchema,
|
|
1427
1771
|
listPostsQuerySchema,
|
|
1428
1772
|
listPublishedPostsQuerySchema,
|
|
1429
1773
|
markdownToPlainText,
|
|
@@ -1435,6 +1779,7 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1435
1779
|
parsePostRef,
|
|
1436
1780
|
postFieldsSchema,
|
|
1437
1781
|
publishPostSchema,
|
|
1782
|
+
rejectPostSchema,
|
|
1438
1783
|
renderMarkdownDocument,
|
|
1439
1784
|
renderMarkdownToHtml,
|
|
1440
1785
|
republishPostSchema,
|
|
@@ -1444,6 +1789,9 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1444
1789
|
saveAsTemplateSchema,
|
|
1445
1790
|
slugSchema,
|
|
1446
1791
|
slugify,
|
|
1792
|
+
submitCommunityPostSchema,
|
|
1793
|
+
unpublishCommunityPostSchema,
|
|
1794
|
+
updateCommunityPostSchema,
|
|
1447
1795
|
updatePostSchema,
|
|
1448
1796
|
updateRecurrenceSchema,
|
|
1449
1797
|
withSlugSuffix
|