@adatechnology/content-contracts 0.3.0 → 0.5.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 CHANGED
@@ -21,10 +21,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
+ ActorRequiredError: () => ActorRequiredError,
25
+ BULK_MODERATION_ACTIONS: () => BULK_MODERATION_ACTIONS,
26
+ COMMUNITY_LINK_REL: () => COMMUNITY_LINK_REL,
27
+ COMMUNITY_MODERATION: () => COMMUNITY_MODERATION,
28
+ COMMUNITY_MODERATIONS: () => COMMUNITY_MODERATIONS,
29
+ COMMUNITY_REVISION_STATE: () => COMMUNITY_REVISION_STATE,
24
30
  CONTENT_ERROR_CODES: () => CONTENT_ERROR_CODES,
31
+ CommunityAuthorNotEligibleError: () => CommunityAuthorNotEligibleError,
32
+ CommunityDailyLimitError: () => CommunityDailyLimitError,
33
+ CommunityImageNotAllowedError: () => CommunityImageNotAllowedError,
34
+ CommunityPostReadOnlyError: () => CommunityPostReadOnlyError,
35
+ CommunityTermsRequiredError: () => CommunityTermsRequiredError,
36
+ CommunityTooManyImagesError: () => CommunityTooManyImagesError,
37
+ CommunityUnauthenticatedError: () => CommunityUnauthenticatedError,
25
38
  ConfigMissingError: () => ConfigMissingError,
26
39
  ContentError: () => ContentError,
27
40
  DEFAULT_ADMIN_SCOPES: () => DEFAULT_ADMIN_SCOPES,
41
+ DEFAULT_CONTENT_SETTINGS: () => DEFAULT_CONTENT_SETTINGS,
28
42
  DEFAULT_LINK_REL: () => DEFAULT_LINK_REL,
29
43
  DEFAULT_POST_PATH_TEMPLATE: () => DEFAULT_POST_PATH_TEMPLATE,
30
44
  DEFAULT_PUBLIC_CACHE_CONTROL: () => DEFAULT_PUBLIC_CACHE_CONTROL,
@@ -33,25 +47,33 @@ __export(index_exports, {
33
47
  DuplicateSlugError: () => DuplicateSlugError,
34
48
  ImageStorageDisabledError: () => ImageStorageDisabledError,
35
49
  InvalidCoverImageError: () => InvalidCoverImageError,
50
+ InvalidPostTransitionError: () => InvalidPostTransitionError,
36
51
  InvalidSlugError: () => InvalidSlugError,
37
52
  NotATemplateError: () => NotATemplateError,
38
53
  POST_EVENT: () => POST_EVENT,
39
54
  POST_LIMITS: () => POST_LIMITS,
55
+ POST_ORIGIN: () => POST_ORIGIN,
56
+ POST_ORIGINS: () => POST_ORIGINS,
57
+ POST_ORIGIN_FILTERS: () => POST_ORIGIN_FILTERS,
40
58
  POST_SORT_FIELDS: () => POST_SORT_FIELDS,
41
59
  POST_STATUS: () => POST_STATUS,
42
60
  POST_STATUSES: () => POST_STATUSES,
43
61
  PT_BR_STOP_WORDS: () => PT_BR_STOP_WORDS,
44
62
  PostNotFoundError: () => PostNotFoundError,
45
63
  PostNotPublishedError: () => PostNotPublishedError,
64
+ PostStateChangedError: () => PostStateChangedError,
46
65
  RECURRENCE_FREQUENCIES: () => RECURRENCE_FREQUENCIES,
47
66
  RECURRENCE_FREQUENCY: () => RECURRENCE_FREQUENCY,
67
+ REPORT_STATUSES: () => REPORT_STATUSES,
48
68
  RecurrenceNotFoundError: () => RecurrenceNotFoundError,
69
+ ReportNotFoundError: () => ReportNotFoundError,
49
70
  RepublishDateInFutureError: () => RepublishDateInFutureError,
50
71
  SHORT_ID_LENGTH: () => SHORT_ID_LENGTH,
51
72
  SLUG_MAX_LENGTH: () => SLUG_MAX_LENGTH,
52
73
  TAGS_MAX_COUNT: () => TAGS_MAX_COUNT,
53
74
  TAG_MAX_LENGTH: () => TAG_MAX_LENGTH,
54
75
  TemplateNotPublishableError: () => TemplateNotPublishableError,
76
+ approvePostSchema: () => approvePostSchema,
55
77
  buildAtomFeed: () => buildAtomFeed,
56
78
  buildExcerpt: () => buildExcerpt,
57
79
  buildPostPath: () => buildPostPath,
@@ -61,9 +83,16 @@ __export(index_exports, {
61
83
  buildShortSlug: () => buildShortSlug,
62
84
  buildSitemapXml: () => buildSitemapXml,
63
85
  buildTagLabels: () => buildTagLabels,
86
+ bulkModerationSchema: () => bulkModerationSchema,
87
+ collectImageSources: () => collectImageSources,
88
+ communityDisplayNameSchema: () => communityDisplayNameSchema,
89
+ communityRevisionSchema: () => communityRevisionSchema,
90
+ contentSettingsSchema: () => contentSettingsSchema,
64
91
  countWords: () => countWords,
92
+ createCommunityPostSchema: () => createCommunityPostSchema,
65
93
  createFromTemplateSchema: () => createFromTemplateSchema,
66
94
  createHeadingIdGenerator: () => createHeadingIdGenerator,
95
+ createPostReportSchema: () => createPostReportSchema,
67
96
  createPostSchema: () => createPostSchema,
68
97
  createRecurrenceSchema: () => createRecurrenceSchema,
69
98
  documentToPlainText: () => documentToPlainText,
@@ -76,8 +105,10 @@ __export(index_exports, {
76
105
  isAbsoluteHttpUrl: () => isAbsoluteHttpUrl,
77
106
  isCanonicalPostRef: () => isCanonicalPostRef,
78
107
  isPostStatus: () => isPostStatus,
108
+ isProtocolRelativeUrl: () => isProtocolRelativeUrl,
79
109
  isShortId: () => isShortId,
80
110
  isValidSlug: () => isValidSlug,
111
+ listPostReportsQuerySchema: () => listPostReportsQuerySchema,
81
112
  listPostsQuerySchema: () => listPostsQuerySchema,
82
113
  listPublishedPostsQuerySchema: () => listPublishedPostsQuerySchema,
83
114
  markdownToPlainText: () => markdownToPlainText,
@@ -89,6 +120,7 @@ __export(index_exports, {
89
120
  parsePostRef: () => parsePostRef,
90
121
  postFieldsSchema: () => postFieldsSchema,
91
122
  publishPostSchema: () => publishPostSchema,
123
+ rejectPostSchema: () => rejectPostSchema,
92
124
  renderMarkdownDocument: () => renderMarkdownDocument,
93
125
  renderMarkdownToHtml: () => renderMarkdownToHtml,
94
126
  republishPostSchema: () => republishPostSchema,
@@ -98,6 +130,9 @@ __export(index_exports, {
98
130
  saveAsTemplateSchema: () => saveAsTemplateSchema,
99
131
  slugSchema: () => slugSchema,
100
132
  slugify: () => slugify,
133
+ submitCommunityPostSchema: () => submitCommunityPostSchema,
134
+ unpublishCommunityPostSchema: () => unpublishCommunityPostSchema,
135
+ updateCommunityPostSchema: () => updateCommunityPostSchema,
101
136
  updatePostSchema: () => updatePostSchema,
102
137
  updateRecurrenceSchema: () => updateRecurrenceSchema,
103
138
  withSlugSuffix: () => withSlugSuffix
@@ -109,13 +144,36 @@ var POST_STATUS = {
109
144
  DRAFT: "draft",
110
145
  SCHEDULED: "scheduled",
111
146
  PUBLISHED: "published",
112
- ARCHIVED: "archived"
147
+ ARCHIVED: "archived",
148
+ /** Post da comunidade enviado e aguardando a equipe (moderação `before`). */
149
+ PENDING_REVIEW: "pending_review",
150
+ /** Post da comunidade recusado ou despublicado pela equipe; o autor pode editar e reenviar. */
151
+ REJECTED: "rejected"
113
152
  };
114
153
  var POST_STATUSES = Object.values(POST_STATUS);
115
154
  function isPostStatus(value) {
116
155
  return typeof value === "string" && POST_STATUSES.includes(value);
117
156
  }
118
157
  __name(isPostStatus, "isPostStatus");
158
+ var POST_ORIGIN = {
159
+ STAFF: "staff",
160
+ COMMUNITY: "community"
161
+ };
162
+ var POST_ORIGINS = Object.values(POST_ORIGIN);
163
+ var COMMUNITY_MODERATION = {
164
+ BEFORE: "before",
165
+ AFTER: "after"
166
+ };
167
+ var COMMUNITY_MODERATIONS = Object.values(COMMUNITY_MODERATION);
168
+ var COMMUNITY_REVISION_STATE = {
169
+ PENDING: "pending",
170
+ REJECTED: "rejected"
171
+ };
172
+ var DEFAULT_CONTENT_SETTINGS = {
173
+ communityModeration: COMMUNITY_MODERATION.BEFORE,
174
+ communityDailyLimit: 3,
175
+ maxImagesPerPost: 12
176
+ };
119
177
  var RECURRENCE_FREQUENCY = {
120
178
  WEEKLY: "weekly",
121
179
  MONTHLY: "monthly"
@@ -130,8 +188,9 @@ var ContentError = class extends Error {
130
188
  statusCode;
131
189
  code;
132
190
  details;
133
- constructor(message, statusCode, code, details) {
134
- super(message), this.statusCode = statusCode, this.code = code, this.details = details;
191
+ publicDetails;
192
+ constructor(message, statusCode, code, details, publicDetails) {
193
+ super(message), this.statusCode = statusCode, this.code = code, this.details = details, this.publicDetails = publicDetails;
135
194
  this.name = "ContentError";
136
195
  }
137
196
  };
@@ -146,7 +205,18 @@ var CONTENT_ERROR_CODES = {
146
205
  TEMPLATE_NOT_PUBLISHABLE: "CONTENT_TEMPLATE_NOT_PUBLISHABLE",
147
206
  NOT_PUBLISHED: "CONTENT_NOT_PUBLISHED",
148
207
  REPUBLISH_DATE_IN_FUTURE: "CONTENT_REPUBLISH_DATE_IN_FUTURE",
149
- RECURRENCE_NOT_FOUND: "CONTENT_RECURRENCE_NOT_FOUND"
208
+ RECURRENCE_NOT_FOUND: "CONTENT_RECURRENCE_NOT_FOUND",
209
+ COMMUNITY_UNAUTHENTICATED: "CONTENT_COMMUNITY_UNAUTHENTICATED",
210
+ COMMUNITY_AUTHOR_NOT_ELIGIBLE: "CONTENT_COMMUNITY_AUTHOR_NOT_ELIGIBLE",
211
+ COMMUNITY_DAILY_LIMIT: "CONTENT_COMMUNITY_DAILY_LIMIT",
212
+ COMMUNITY_TERMS_REQUIRED: "CONTENT_COMMUNITY_TERMS_REQUIRED",
213
+ COMMUNITY_TOO_MANY_IMAGES: "CONTENT_COMMUNITY_TOO_MANY_IMAGES",
214
+ COMMUNITY_IMAGE_NOT_ALLOWED: "CONTENT_COMMUNITY_IMAGE_NOT_ALLOWED",
215
+ INVALID_TRANSITION: "CONTENT_INVALID_TRANSITION",
216
+ POST_STATE_CHANGED: "CONTENT_POST_STATE_CHANGED",
217
+ ACTOR_REQUIRED: "CONTENT_ACTOR_REQUIRED",
218
+ COMMUNITY_POST_READ_ONLY: "CONTENT_COMMUNITY_POST_READ_ONLY",
219
+ REPORT_NOT_FOUND: "CONTENT_REPORT_NOT_FOUND"
150
220
  };
151
221
  var PostNotFoundError = class extends ContentError {
152
222
  static {
@@ -263,6 +333,116 @@ var RecurrenceNotFoundError = class extends ContentError {
263
333
  }), this.reference = reference;
264
334
  }
265
335
  };
336
+ var CommunityUnauthenticatedError = class extends ContentError {
337
+ static {
338
+ __name(this, "CommunityUnauthenticatedError");
339
+ }
340
+ constructor() {
341
+ super("Entre na sua conta para continuar.", 401, CONTENT_ERROR_CODES.COMMUNITY_UNAUTHENTICATED);
342
+ }
343
+ };
344
+ var CommunityAuthorNotEligibleError = class extends ContentError {
345
+ static {
346
+ __name(this, "CommunityAuthorNotEligibleError");
347
+ }
348
+ constructor() {
349
+ super("Sua conta ainda n\xE3o pode publicar na comunidade.", 403, CONTENT_ERROR_CODES.COMMUNITY_AUTHOR_NOT_ELIGIBLE);
350
+ }
351
+ };
352
+ var CommunityDailyLimitError = class extends ContentError {
353
+ static {
354
+ __name(this, "CommunityDailyLimitError");
355
+ }
356
+ limit;
357
+ retryAfterSeconds;
358
+ constructor(limit, retryAfterSeconds) {
359
+ super("Limite de posts nas \xFAltimas 24 horas atingido.", 429, CONTENT_ERROR_CODES.COMMUNITY_DAILY_LIMIT, void 0, {
360
+ limit,
361
+ retryAfterSeconds
362
+ }), this.limit = limit, this.retryAfterSeconds = retryAfterSeconds;
363
+ }
364
+ };
365
+ var CommunityTermsRequiredError = class extends ContentError {
366
+ static {
367
+ __name(this, "CommunityTermsRequiredError");
368
+ }
369
+ constructor() {
370
+ super("Aceite os termos para enviar o post.", 422, CONTENT_ERROR_CODES.COMMUNITY_TERMS_REQUIRED);
371
+ }
372
+ };
373
+ var CommunityTooManyImagesError = class extends ContentError {
374
+ static {
375
+ __name(this, "CommunityTooManyImagesError");
376
+ }
377
+ max;
378
+ constructor(max) {
379
+ super("O post tem mais fotos do que o permitido.", 422, CONTENT_ERROR_CODES.COMMUNITY_TOO_MANY_IMAGES, void 0, {
380
+ max
381
+ }), this.max = max;
382
+ }
383
+ };
384
+ var CommunityImageNotAllowedError = class extends ContentError {
385
+ static {
386
+ __name(this, "CommunityImageNotAllowedError");
387
+ }
388
+ constructor() {
389
+ super("Use apenas fotos enviadas por voc\xEA neste site.", 422, CONTENT_ERROR_CODES.COMMUNITY_IMAGE_NOT_ALLOWED);
390
+ }
391
+ };
392
+ var InvalidPostTransitionError = class extends ContentError {
393
+ static {
394
+ __name(this, "InvalidPostTransitionError");
395
+ }
396
+ from;
397
+ action;
398
+ constructor(from, action) {
399
+ super("Esta a\xE7\xE3o n\xE3o \xE9 poss\xEDvel no estado atual do post.", 409, CONTENT_ERROR_CODES.INVALID_TRANSITION, void 0, {
400
+ from,
401
+ action
402
+ }), this.from = from, this.action = action;
403
+ }
404
+ };
405
+ var ActorRequiredError = class extends ContentError {
406
+ static {
407
+ __name(this, "ActorRequiredError");
408
+ }
409
+ constructor() {
410
+ super("Esta a\xE7\xE3o exige um usu\xE1rio da equipe.", 403, CONTENT_ERROR_CODES.ACTOR_REQUIRED);
411
+ }
412
+ };
413
+ var PostStateChangedError = class extends ContentError {
414
+ static {
415
+ __name(this, "PostStateChangedError");
416
+ }
417
+ postId;
418
+ constructor(postId) {
419
+ super("O post mudou desde que voc\xEA o abriu. Recarregue e confira antes de decidir.", 409, CONTENT_ERROR_CODES.POST_STATE_CHANGED, {
420
+ postId
421
+ }), this.postId = postId;
422
+ }
423
+ };
424
+ var CommunityPostReadOnlyError = class extends ContentError {
425
+ static {
426
+ __name(this, "CommunityPostReadOnlyError");
427
+ }
428
+ postId;
429
+ constructor(postId) {
430
+ super("Post da comunidade s\xF3 pode ser moderado, n\xE3o editado.", 409, CONTENT_ERROR_CODES.COMMUNITY_POST_READ_ONLY, {
431
+ postId
432
+ }), this.postId = postId;
433
+ }
434
+ };
435
+ var ReportNotFoundError = class extends ContentError {
436
+ static {
437
+ __name(this, "ReportNotFoundError");
438
+ }
439
+ reference;
440
+ constructor(reference) {
441
+ super("Den\xFAncia n\xE3o encontrada.", 404, CONTENT_ERROR_CODES.REPORT_NOT_FOUND, {
442
+ reference
443
+ }), this.reference = reference;
444
+ }
445
+ };
266
446
 
267
447
  // src/schemas.ts
268
448
  var import_zod = require("zod");
@@ -392,8 +572,20 @@ var POST_LIMITS = {
392
572
  SEO_DESCRIPTION: 320,
393
573
  SEARCH: 120,
394
574
  ADMIN_PAGE_SIZE: 100,
395
- PUBLIC_PAGE_SIZE: 50
575
+ PUBLIC_PAGE_SIZE: 50,
576
+ DISPLAY_NAME_MIN: 2,
577
+ DISPLAY_NAME_MAX: 40,
578
+ REVIEW_NOTE: 500,
579
+ REPORT_REASON_MIN: 3,
580
+ REPORT_REASON_MAX: 300,
581
+ BULK_IDS: 100
396
582
  };
583
+ var POST_ORIGIN_FILTERS = [
584
+ "staff",
585
+ "community",
586
+ "all"
587
+ ];
588
+ var originFilterSchema = import_zod.z.enum(POST_ORIGIN_FILTERS).default("staff");
397
589
  var slugSchema = import_zod.z.string().trim().toLowerCase().max(SLUG_MAX_LENGTH).refine(isValidSlug, {
398
590
  message: "Use letras min\xFAsculas, n\xFAmeros e h\xEDfen."
399
591
  });
@@ -452,12 +644,14 @@ var listPostsQuerySchema = import_zod.z.object({
452
644
  "true",
453
645
  "false"
454
646
  ])
455
- ]).transform((value) => value === true || value === "true").optional()
647
+ ]).transform((value) => value === true || value === "true").optional(),
648
+ origin: originFilterSchema
456
649
  });
457
650
  var listPublishedPostsQuerySchema = import_zod.z.object({
458
651
  page: pageSchema,
459
652
  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()
653
+ tag: import_zod.z.string().trim().min(1).max(TAG_MAX_LENGTH).optional(),
654
+ origin: originFilterSchema
461
655
  });
462
656
  var isoInstant = import_zod.z.string().datetime({
463
657
  offset: true
@@ -482,6 +676,75 @@ var updateRecurrenceSchema = import_zod.z.object({
482
676
  isActive: import_zod.z.boolean().optional(),
483
677
  nextRunAt: isoInstant.optional()
484
678
  }).strict();
679
+ 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), {
680
+ message: "O nome n\xE3o pode ter e-mail, telefone ou endere\xE7o de site."
681
+ });
682
+ var communityFieldsSchema = import_zod.z.object({
683
+ title: import_zod.z.string().trim().min(1).max(POST_LIMITS.TITLE),
684
+ body: import_zod.z.string().max(POST_LIMITS.BODY),
685
+ excerpt: optionalText(POST_LIMITS.EXCERPT),
686
+ displayName: communityDisplayNameSchema.optional()
687
+ });
688
+ var createCommunityPostSchema = communityFieldsSchema.strict();
689
+ var updateCommunityPostSchema = communityFieldsSchema.partial().strict();
690
+ var submitCommunityPostSchema = import_zod.z.object({
691
+ termsAccepted: import_zod.z.boolean()
692
+ }).strict();
693
+ var expectedUpdatedAtSchema = import_zod.z.string().datetime({
694
+ offset: true
695
+ });
696
+ var approvePostSchema = import_zod.z.object({
697
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional()
698
+ }).strict();
699
+ var rejectPostSchema = import_zod.z.object({
700
+ note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE),
701
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional()
702
+ }).strict();
703
+ var unpublishCommunityPostSchema = import_zod.z.object({
704
+ note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional()
705
+ }).strict();
706
+ var BULK_MODERATION_ACTIONS = [
707
+ "approve",
708
+ "reject",
709
+ "unpublish",
710
+ "archive"
711
+ ];
712
+ var bulkModerationSchema = import_zod.z.object({
713
+ action: import_zod.z.enum(BULK_MODERATION_ACTIONS),
714
+ ids: import_zod.z.array(import_zod.z.string().uuid()).min(1).max(POST_LIMITS.BULK_IDS),
715
+ note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional(),
716
+ /** Por id: o `updatedAt` que a tela leu. Id sem entrada decide sem a checagem. */
717
+ expectedUpdatedAt: import_zod.z.record(import_zod.z.string().uuid(), expectedUpdatedAtSchema).optional()
718
+ }).strict();
719
+ var contentSettingsSchema = import_zod.z.object({
720
+ communityModeration: import_zod.z.enum(COMMUNITY_MODERATIONS),
721
+ communityDailyLimit: import_zod.z.number().int().min(1).max(50),
722
+ maxImagesPerPost: import_zod.z.number().int().min(1).max(30)
723
+ }).strict();
724
+ var createPostReportSchema = import_zod.z.object({
725
+ reason: import_zod.z.string().trim().min(POST_LIMITS.REPORT_REASON_MIN).max(POST_LIMITS.REPORT_REASON_MAX)
726
+ }).strict();
727
+ var REPORT_STATUSES = [
728
+ "open",
729
+ "resolved"
730
+ ];
731
+ var listPostReportsQuerySchema = import_zod.z.object({
732
+ page: pageSchema,
733
+ pageSize: import_zod.z.coerce.number().int().min(1).max(POST_LIMITS.ADMIN_PAGE_SIZE).default(20),
734
+ status: import_zod.z.enum(REPORT_STATUSES).default("open")
735
+ });
736
+ var communityRevisionSchema = import_zod.z.object({
737
+ title: import_zod.z.string(),
738
+ excerpt: import_zod.z.string().nullable(),
739
+ body: import_zod.z.string(),
740
+ state: import_zod.z.enum([
741
+ COMMUNITY_REVISION_STATE.PENDING,
742
+ COMMUNITY_REVISION_STATE.REJECTED
743
+ ]),
744
+ submittedAt: import_zod.z.string().datetime({
745
+ offset: true
746
+ })
747
+ });
485
748
 
486
749
  // src/providers.ts
487
750
  var POST_EVENT = {
@@ -576,6 +839,10 @@ function sanitizeImageUrl(url) {
576
839
  return sanitize(url, IMAGE_SCHEMES);
577
840
  }
578
841
  __name(sanitizeImageUrl, "sanitizeImageUrl");
842
+ function isProtocolRelativeUrl(url) {
843
+ return /^[/\\]{2}/.test(url);
844
+ }
845
+ __name(isProtocolRelativeUrl, "isProtocolRelativeUrl");
579
846
  function isAbsoluteHttpUrl(url) {
580
847
  return /^https?:\/\//i.test(url) || url.startsWith("//");
581
848
  }
@@ -1226,6 +1493,7 @@ __name(createHeadingIdGenerator, "createHeadingIdGenerator");
1226
1493
 
1227
1494
  // src/markdown/renderHtml.ts
1228
1495
  var DEFAULT_LINK_REL = "noopener noreferrer";
1496
+ var COMMUNITY_LINK_REL = "noopener noreferrer nofollow ugc";
1229
1497
  var ESCAPES = {
1230
1498
  "&": "&",
1231
1499
  "<": "&lt;",
@@ -1322,6 +1590,45 @@ function renderMarkdownToHtml(markdown, options = {}) {
1322
1590
  }
1323
1591
  __name(renderMarkdownToHtml, "renderMarkdownToHtml");
1324
1592
 
1593
+ // src/markdown/collectImageSources.ts
1594
+ function collectFromInline(nodes, sources) {
1595
+ for (const node of nodes) {
1596
+ if (node.type === "image") sources.push(node.src);
1597
+ else if ("children" in node) collectFromInline(node.children, sources);
1598
+ }
1599
+ }
1600
+ __name(collectFromInline, "collectFromInline");
1601
+ function collectFromBlock(block, sources) {
1602
+ switch (block.type) {
1603
+ case "heading":
1604
+ case "paragraph":
1605
+ collectFromInline(block.children, sources);
1606
+ return;
1607
+ case "blockquote":
1608
+ for (const child of block.children) collectFromBlock(child, sources);
1609
+ return;
1610
+ case "list":
1611
+ for (const item of block.items) for (const child of item) collectFromBlock(child, sources);
1612
+ return;
1613
+ case "figure":
1614
+ sources.push(block.image.src);
1615
+ return;
1616
+ case "gallery":
1617
+ for (const image of block.images) sources.push(image.src);
1618
+ return;
1619
+ case "codeBlock":
1620
+ case "thematicBreak":
1621
+ return;
1622
+ }
1623
+ }
1624
+ __name(collectFromBlock, "collectFromBlock");
1625
+ function collectImageSources(document) {
1626
+ const sources = [];
1627
+ for (const block of document.children) collectFromBlock(block, sources);
1628
+ return sources;
1629
+ }
1630
+ __name(collectImageSources, "collectImageSources");
1631
+
1325
1632
  // src/feed.ts
1326
1633
  var DEFAULT_POST_PATH_TEMPLATE = "/blog/{slug}";
1327
1634
  var XML_ESCAPES = {
@@ -1418,10 +1725,24 @@ function buildSitemapXml(entries) {
1418
1725
  __name(buildSitemapXml, "buildSitemapXml");
1419
1726
  // Annotate the CommonJS export names for ESM import in node:
1420
1727
  0 && (module.exports = {
1728
+ ActorRequiredError,
1729
+ BULK_MODERATION_ACTIONS,
1730
+ COMMUNITY_LINK_REL,
1731
+ COMMUNITY_MODERATION,
1732
+ COMMUNITY_MODERATIONS,
1733
+ COMMUNITY_REVISION_STATE,
1421
1734
  CONTENT_ERROR_CODES,
1735
+ CommunityAuthorNotEligibleError,
1736
+ CommunityDailyLimitError,
1737
+ CommunityImageNotAllowedError,
1738
+ CommunityPostReadOnlyError,
1739
+ CommunityTermsRequiredError,
1740
+ CommunityTooManyImagesError,
1741
+ CommunityUnauthenticatedError,
1422
1742
  ConfigMissingError,
1423
1743
  ContentError,
1424
1744
  DEFAULT_ADMIN_SCOPES,
1745
+ DEFAULT_CONTENT_SETTINGS,
1425
1746
  DEFAULT_LINK_REL,
1426
1747
  DEFAULT_POST_PATH_TEMPLATE,
1427
1748
  DEFAULT_PUBLIC_CACHE_CONTROL,
@@ -1430,25 +1751,33 @@ __name(buildSitemapXml, "buildSitemapXml");
1430
1751
  DuplicateSlugError,
1431
1752
  ImageStorageDisabledError,
1432
1753
  InvalidCoverImageError,
1754
+ InvalidPostTransitionError,
1433
1755
  InvalidSlugError,
1434
1756
  NotATemplateError,
1435
1757
  POST_EVENT,
1436
1758
  POST_LIMITS,
1759
+ POST_ORIGIN,
1760
+ POST_ORIGINS,
1761
+ POST_ORIGIN_FILTERS,
1437
1762
  POST_SORT_FIELDS,
1438
1763
  POST_STATUS,
1439
1764
  POST_STATUSES,
1440
1765
  PT_BR_STOP_WORDS,
1441
1766
  PostNotFoundError,
1442
1767
  PostNotPublishedError,
1768
+ PostStateChangedError,
1443
1769
  RECURRENCE_FREQUENCIES,
1444
1770
  RECURRENCE_FREQUENCY,
1771
+ REPORT_STATUSES,
1445
1772
  RecurrenceNotFoundError,
1773
+ ReportNotFoundError,
1446
1774
  RepublishDateInFutureError,
1447
1775
  SHORT_ID_LENGTH,
1448
1776
  SLUG_MAX_LENGTH,
1449
1777
  TAGS_MAX_COUNT,
1450
1778
  TAG_MAX_LENGTH,
1451
1779
  TemplateNotPublishableError,
1780
+ approvePostSchema,
1452
1781
  buildAtomFeed,
1453
1782
  buildExcerpt,
1454
1783
  buildPostPath,
@@ -1458,9 +1787,16 @@ __name(buildSitemapXml, "buildSitemapXml");
1458
1787
  buildShortSlug,
1459
1788
  buildSitemapXml,
1460
1789
  buildTagLabels,
1790
+ bulkModerationSchema,
1791
+ collectImageSources,
1792
+ communityDisplayNameSchema,
1793
+ communityRevisionSchema,
1794
+ contentSettingsSchema,
1461
1795
  countWords,
1796
+ createCommunityPostSchema,
1462
1797
  createFromTemplateSchema,
1463
1798
  createHeadingIdGenerator,
1799
+ createPostReportSchema,
1464
1800
  createPostSchema,
1465
1801
  createRecurrenceSchema,
1466
1802
  documentToPlainText,
@@ -1473,8 +1809,10 @@ __name(buildSitemapXml, "buildSitemapXml");
1473
1809
  isAbsoluteHttpUrl,
1474
1810
  isCanonicalPostRef,
1475
1811
  isPostStatus,
1812
+ isProtocolRelativeUrl,
1476
1813
  isShortId,
1477
1814
  isValidSlug,
1815
+ listPostReportsQuerySchema,
1478
1816
  listPostsQuerySchema,
1479
1817
  listPublishedPostsQuerySchema,
1480
1818
  markdownToPlainText,
@@ -1486,6 +1824,7 @@ __name(buildSitemapXml, "buildSitemapXml");
1486
1824
  parsePostRef,
1487
1825
  postFieldsSchema,
1488
1826
  publishPostSchema,
1827
+ rejectPostSchema,
1489
1828
  renderMarkdownDocument,
1490
1829
  renderMarkdownToHtml,
1491
1830
  republishPostSchema,
@@ -1495,6 +1834,9 @@ __name(buildSitemapXml, "buildSitemapXml");
1495
1834
  saveAsTemplateSchema,
1496
1835
  slugSchema,
1497
1836
  slugify,
1837
+ submitCommunityPostSchema,
1838
+ unpublishCommunityPostSchema,
1839
+ updateCommunityPostSchema,
1498
1840
  updatePostSchema,
1499
1841
  updateRecurrenceSchema,
1500
1842
  withSlugSuffix