@adatechnology/content-contracts 0.4.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.d.cts CHANGED
@@ -251,6 +251,8 @@ declare const CONTENT_ERROR_CODES: {
251
251
  readonly COMMUNITY_TOO_MANY_IMAGES: "CONTENT_COMMUNITY_TOO_MANY_IMAGES";
252
252
  readonly COMMUNITY_IMAGE_NOT_ALLOWED: "CONTENT_COMMUNITY_IMAGE_NOT_ALLOWED";
253
253
  readonly INVALID_TRANSITION: "CONTENT_INVALID_TRANSITION";
254
+ readonly POST_STATE_CHANGED: "CONTENT_POST_STATE_CHANGED";
255
+ readonly ACTOR_REQUIRED: "CONTENT_ACTOR_REQUIRED";
254
256
  readonly COMMUNITY_POST_READ_ONLY: "CONTENT_COMMUNITY_POST_READ_ONLY";
255
257
  readonly REPORT_NOT_FOUND: "CONTENT_REPORT_NOT_FOUND";
256
258
  };
@@ -331,6 +333,15 @@ declare class InvalidPostTransitionError extends ContentError {
331
333
  readonly action: string;
332
334
  constructor(from: string, action: string);
333
335
  }
336
+ /** Moderar post da comunidade grava quem decidiu: credencial de máquina (sem usuário) não decide. */
337
+ declare class ActorRequiredError extends ContentError {
338
+ constructor();
339
+ }
340
+ /** Outra requisição mexeu no post entre a leitura e a gravação: quem decidiu viu um texto que já não é o atual. */
341
+ declare class PostStateChangedError extends ContentError {
342
+ readonly postId: string;
343
+ constructor(postId: string);
344
+ }
334
345
  /** A equipe modera post da comunidade, não o reescreve: editar, agendar ou virar modelo é recusado. */
335
346
  declare class CommunityPostReadOnlyError extends ContentError {
336
347
  readonly postId: string;
@@ -659,12 +670,23 @@ declare const submitCommunityPostSchema: z.ZodObject<{
659
670
  termsAccepted: boolean;
660
671
  }>;
661
672
  type SubmitCommunityPostInput = z.input<typeof submitCommunityPostSchema>;
673
+ declare const approvePostSchema: z.ZodObject<{
674
+ expectedUpdatedAt: z.ZodOptional<z.ZodString>;
675
+ }, "strict", z.ZodTypeAny, {
676
+ expectedUpdatedAt?: string | undefined;
677
+ }, {
678
+ expectedUpdatedAt?: string | undefined;
679
+ }>;
680
+ type ApprovePostInput = z.input<typeof approvePostSchema>;
662
681
  declare const rejectPostSchema: z.ZodObject<{
663
682
  note: z.ZodString;
683
+ expectedUpdatedAt: z.ZodOptional<z.ZodString>;
664
684
  }, "strict", z.ZodTypeAny, {
665
685
  note: string;
686
+ expectedUpdatedAt?: string | undefined;
666
687
  }, {
667
688
  note: string;
689
+ expectedUpdatedAt?: string | undefined;
668
690
  }>;
669
691
  type RejectPostInput = z.input<typeof rejectPostSchema>;
670
692
  declare const unpublishCommunityPostSchema: z.ZodObject<{
@@ -681,13 +703,17 @@ declare const bulkModerationSchema: z.ZodObject<{
681
703
  action: z.ZodEnum<["approve", "reject", "unpublish", "archive"]>;
682
704
  ids: z.ZodArray<z.ZodString, "many">;
683
705
  note: z.ZodOptional<z.ZodString>;
706
+ /** Por id: o `updatedAt` que a tela leu. Id sem entrada decide sem a checagem. */
707
+ expectedUpdatedAt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
684
708
  }, "strict", z.ZodTypeAny, {
685
709
  action: "approve" | "reject" | "unpublish" | "archive";
686
710
  ids: string[];
711
+ expectedUpdatedAt?: Record<string, string> | undefined;
687
712
  note?: string | undefined;
688
713
  }, {
689
714
  action: "approve" | "reject" | "unpublish" | "archive";
690
715
  ids: string[];
716
+ expectedUpdatedAt?: Record<string, string> | undefined;
691
717
  note?: string | undefined;
692
718
  }>;
693
719
  type BulkModerationInput = z.input<typeof bulkModerationSchema>;
@@ -803,6 +829,8 @@ type CommunityPostSubmittedEvent = {
803
829
  readonly authorAccountId: string;
804
830
  readonly kind: CommunitySubmissionKind;
805
831
  readonly moderation: CommunityModeration;
832
+ /** Versão dos termos aceita neste envio (`ContentModuleConfig.termsVersion`), para a auditoria do host. */
833
+ readonly termsVersion?: string;
806
834
  };
807
835
  type CommunityReviewDecision = 'approved' | 'rejected' | 'unpublished' | 'archived';
808
836
  type CommunityReviewTarget = 'post' | 'revision';
@@ -881,6 +909,8 @@ type ContentModuleConfig = {
881
909
  readonly publicCacheControl?: string;
882
910
  readonly feed?: ContentFeedConfig;
883
911
  readonly wordsPerMinute?: number;
912
+ /** Versão dos termos de uso da comunidade, gravada em cada envio. Padrão: `'2'`. Mude ao reescrever os termos. */
913
+ readonly termsVersion?: string;
884
914
  /** Slug automático (quando o autor não informa). Padrão: até 60 caracteres, sem palavras de ligação do pt-BR. */
885
915
  readonly slug?: {
886
916
  readonly maxLength?: number;
@@ -1135,6 +1165,8 @@ type MarkdownRenderOptions = {
1135
1165
  readonly linkRel?: string;
1136
1166
  };
1137
1167
  declare const DEFAULT_LINK_REL = "noopener noreferrer";
1168
+ /** Texto de hóspede: sem herdar reputação de busca e marcado como conteúdo gerado por usuário. */
1169
+ declare const COMMUNITY_LINK_REL = "noopener noreferrer nofollow ugc";
1138
1170
  declare function escapeHtml(value: string): string;
1139
1171
  declare function resolveHeadingLevel(level: number, offset?: number): 1 | 2 | 3 | 4 | 5 | 6;
1140
1172
  declare function renderMarkdownDocument(document: MarkdownDocument, options?: MarkdownRenderOptions): string;
@@ -1160,6 +1192,8 @@ declare function markdownToPlainText(markdown: string): string;
1160
1192
  declare function sanitizeLinkUrl(url: string): string | undefined;
1161
1193
  /** Imagem só por http(s) ou caminho relativo: `data:` permitiria SVG com script embutido. */
1162
1194
  declare function sanitizeImageUrl(url: string): string | undefined;
1195
+ /** `//host` e `/\host`: o navegador resolve como outro site; num texto de hóspede não é "caminho relativo". */
1196
+ declare function isProtocolRelativeUrl(url: string): boolean;
1163
1197
  declare function isAbsoluteHttpUrl(url: string): boolean;
1164
1198
 
1165
1199
  /**
@@ -1230,4 +1264,4 @@ declare function buildAtomFeed(params: {
1230
1264
  }): string;
1231
1265
  declare function buildSitemapXml(entries: readonly SitemapEntry[]): string;
1232
1266
 
1233
- export { BULK_MODERATION_ACTIONS, type BulkModerationAction, type BulkModerationInput, type BulkModerationResult, COMMUNITY_MODERATION, COMMUNITY_MODERATIONS, COMMUNITY_REVISION_STATE, CONTENT_ERROR_CODES, type ClockPort, type CommunityAuthorIdentity, CommunityAuthorNotEligibleError, type CommunityAuthorPort, CommunityDailyLimitError, type CommunityEligibility, CommunityImageNotAllowedError, type CommunityModeration, type CommunityPost, CommunityPostReadOnlyError, type CommunityPostReviewedEvent, type CommunityPostStatus, type CommunityPostSubmittedEvent, type CommunityReviewDecision, type CommunityReviewTarget, type CommunityRevision, type CommunityRevisionState, type CommunitySubmissionKind, CommunityTermsRequiredError, CommunityTooManyImagesError, CommunityUnauthenticatedError, ConfigMissingError, ContentError, type ContentErrorCode, type ContentFeedConfig, type ContentHooks, type ContentImageStoragePort, type ContentModuleConfig, type ContentSettings, type ContentSettingsInput, type CreateCommunityPostInput, type CreateFromTemplateInput, type CreatePostInput, type CreatePostReportInput, type CreateRecurrenceInput, DEFAULT_ADMIN_SCOPES, DEFAULT_CONTENT_SETTINGS, 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, InvalidPostTransitionError, InvalidSlugError, type ListPostReportsQuery, 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_ORIGIN, POST_ORIGINS, POST_ORIGIN_FILTERS, 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 PostOrigin, type PostOriginFilter, type PostReport, type PostReportedEvent, type PostSortField, type PostStatus, type PostSummary, type PublicPost, type PublicPostSummary, type PublishPostInput, RECURRENCE_FREQUENCIES, RECURRENCE_FREQUENCY, REPORT_STATUSES, type RecurrenceFrequency, RecurrenceNotFoundError, type RecurrenceRule, type RejectPostInput, ReportNotFoundError, type ReportStatus, RepublishDateInFutureError, type RepublishPostInput, SHORT_ID_LENGTH, SLUG_MAX_LENGTH, type SaveAsTemplateInput, type ShortSlugOptions, type SitemapEntry, type SubmitCommunityPostInput, TAGS_MAX_COUNT, TAG_MAX_LENGTH, type TagCount, type TagLabels, TemplateNotPublishableError, type UnpublishCommunityPostInput, type UpdateCommunityPostInput, type UpdatePostInput, type UpdateRecurrenceInput, buildAtomFeed, buildExcerpt, buildPostPath, buildPostRef, buildPostUrl, buildRssFeed, buildShortSlug, buildSitemapXml, buildTagLabels, bulkModerationSchema, collectImageSources, communityDisplayNameSchema, communityRevisionSchema, contentSettingsSchema, countWords, createCommunityPostSchema, createFromTemplateSchema, createHeadingIdGenerator, createPostReportSchema, createPostSchema, createRecurrenceSchema, documentToPlainText, escapeHtml, escapeXml, estimateReadingTimeMinutes, formatTagLabel, httpUrlSchema, inlineToPlainText, isAbsoluteHttpUrl, isCanonicalPostRef, isPostStatus, isShortId, isValidSlug, listPostReportsQuerySchema, listPostsQuerySchema, listPublishedPostsQuerySchema, markdownToPlainText, normalizeTag, normalizeTags, parseInline, parseMarkdown, parsePostPath, parsePostRef, postFieldsSchema, publishPostSchema, rejectPostSchema, renderMarkdownDocument, renderMarkdownToHtml, republishPostSchema, resolveHeadingLevel, sanitizeImageUrl, sanitizeLinkUrl, saveAsTemplateSchema, slugSchema, slugify, submitCommunityPostSchema, unpublishCommunityPostSchema, updateCommunityPostSchema, updatePostSchema, updateRecurrenceSchema, withSlugSuffix };
1267
+ export { ActorRequiredError, type ApprovePostInput, BULK_MODERATION_ACTIONS, type BulkModerationAction, type BulkModerationInput, type BulkModerationResult, COMMUNITY_LINK_REL, COMMUNITY_MODERATION, COMMUNITY_MODERATIONS, COMMUNITY_REVISION_STATE, CONTENT_ERROR_CODES, type ClockPort, type CommunityAuthorIdentity, CommunityAuthorNotEligibleError, type CommunityAuthorPort, CommunityDailyLimitError, type CommunityEligibility, CommunityImageNotAllowedError, type CommunityModeration, type CommunityPost, CommunityPostReadOnlyError, type CommunityPostReviewedEvent, type CommunityPostStatus, type CommunityPostSubmittedEvent, type CommunityReviewDecision, type CommunityReviewTarget, type CommunityRevision, type CommunityRevisionState, type CommunitySubmissionKind, CommunityTermsRequiredError, CommunityTooManyImagesError, CommunityUnauthenticatedError, ConfigMissingError, ContentError, type ContentErrorCode, type ContentFeedConfig, type ContentHooks, type ContentImageStoragePort, type ContentModuleConfig, type ContentSettings, type ContentSettingsInput, type CreateCommunityPostInput, type CreateFromTemplateInput, type CreatePostInput, type CreatePostReportInput, type CreateRecurrenceInput, DEFAULT_ADMIN_SCOPES, DEFAULT_CONTENT_SETTINGS, 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, InvalidPostTransitionError, InvalidSlugError, type ListPostReportsQuery, 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_ORIGIN, POST_ORIGINS, POST_ORIGIN_FILTERS, 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 PostOrigin, type PostOriginFilter, type PostReport, type PostReportedEvent, type PostSortField, PostStateChangedError, type PostStatus, type PostSummary, type PublicPost, type PublicPostSummary, type PublishPostInput, RECURRENCE_FREQUENCIES, RECURRENCE_FREQUENCY, REPORT_STATUSES, type RecurrenceFrequency, RecurrenceNotFoundError, type RecurrenceRule, type RejectPostInput, ReportNotFoundError, type ReportStatus, RepublishDateInFutureError, type RepublishPostInput, SHORT_ID_LENGTH, SLUG_MAX_LENGTH, type SaveAsTemplateInput, type ShortSlugOptions, type SitemapEntry, type SubmitCommunityPostInput, TAGS_MAX_COUNT, TAG_MAX_LENGTH, type TagCount, type TagLabels, TemplateNotPublishableError, type UnpublishCommunityPostInput, type UpdateCommunityPostInput, type UpdatePostInput, type UpdateRecurrenceInput, approvePostSchema, buildAtomFeed, buildExcerpt, buildPostPath, buildPostRef, buildPostUrl, buildRssFeed, buildShortSlug, buildSitemapXml, buildTagLabels, bulkModerationSchema, collectImageSources, communityDisplayNameSchema, communityRevisionSchema, contentSettingsSchema, countWords, createCommunityPostSchema, createFromTemplateSchema, createHeadingIdGenerator, createPostReportSchema, createPostSchema, createRecurrenceSchema, documentToPlainText, escapeHtml, escapeXml, estimateReadingTimeMinutes, formatTagLabel, httpUrlSchema, inlineToPlainText, isAbsoluteHttpUrl, isCanonicalPostRef, isPostStatus, isProtocolRelativeUrl, isShortId, isValidSlug, listPostReportsQuerySchema, listPostsQuerySchema, listPublishedPostsQuerySchema, markdownToPlainText, normalizeTag, normalizeTags, parseInline, parseMarkdown, parsePostPath, parsePostRef, postFieldsSchema, publishPostSchema, rejectPostSchema, renderMarkdownDocument, renderMarkdownToHtml, republishPostSchema, resolveHeadingLevel, sanitizeImageUrl, sanitizeLinkUrl, saveAsTemplateSchema, slugSchema, slugify, submitCommunityPostSchema, unpublishCommunityPostSchema, updateCommunityPostSchema, updatePostSchema, updateRecurrenceSchema, withSlugSuffix };
package/dist/index.d.ts CHANGED
@@ -251,6 +251,8 @@ declare const CONTENT_ERROR_CODES: {
251
251
  readonly COMMUNITY_TOO_MANY_IMAGES: "CONTENT_COMMUNITY_TOO_MANY_IMAGES";
252
252
  readonly COMMUNITY_IMAGE_NOT_ALLOWED: "CONTENT_COMMUNITY_IMAGE_NOT_ALLOWED";
253
253
  readonly INVALID_TRANSITION: "CONTENT_INVALID_TRANSITION";
254
+ readonly POST_STATE_CHANGED: "CONTENT_POST_STATE_CHANGED";
255
+ readonly ACTOR_REQUIRED: "CONTENT_ACTOR_REQUIRED";
254
256
  readonly COMMUNITY_POST_READ_ONLY: "CONTENT_COMMUNITY_POST_READ_ONLY";
255
257
  readonly REPORT_NOT_FOUND: "CONTENT_REPORT_NOT_FOUND";
256
258
  };
@@ -331,6 +333,15 @@ declare class InvalidPostTransitionError extends ContentError {
331
333
  readonly action: string;
332
334
  constructor(from: string, action: string);
333
335
  }
336
+ /** Moderar post da comunidade grava quem decidiu: credencial de máquina (sem usuário) não decide. */
337
+ declare class ActorRequiredError extends ContentError {
338
+ constructor();
339
+ }
340
+ /** Outra requisição mexeu no post entre a leitura e a gravação: quem decidiu viu um texto que já não é o atual. */
341
+ declare class PostStateChangedError extends ContentError {
342
+ readonly postId: string;
343
+ constructor(postId: string);
344
+ }
334
345
  /** A equipe modera post da comunidade, não o reescreve: editar, agendar ou virar modelo é recusado. */
335
346
  declare class CommunityPostReadOnlyError extends ContentError {
336
347
  readonly postId: string;
@@ -659,12 +670,23 @@ declare const submitCommunityPostSchema: z.ZodObject<{
659
670
  termsAccepted: boolean;
660
671
  }>;
661
672
  type SubmitCommunityPostInput = z.input<typeof submitCommunityPostSchema>;
673
+ declare const approvePostSchema: z.ZodObject<{
674
+ expectedUpdatedAt: z.ZodOptional<z.ZodString>;
675
+ }, "strict", z.ZodTypeAny, {
676
+ expectedUpdatedAt?: string | undefined;
677
+ }, {
678
+ expectedUpdatedAt?: string | undefined;
679
+ }>;
680
+ type ApprovePostInput = z.input<typeof approvePostSchema>;
662
681
  declare const rejectPostSchema: z.ZodObject<{
663
682
  note: z.ZodString;
683
+ expectedUpdatedAt: z.ZodOptional<z.ZodString>;
664
684
  }, "strict", z.ZodTypeAny, {
665
685
  note: string;
686
+ expectedUpdatedAt?: string | undefined;
666
687
  }, {
667
688
  note: string;
689
+ expectedUpdatedAt?: string | undefined;
668
690
  }>;
669
691
  type RejectPostInput = z.input<typeof rejectPostSchema>;
670
692
  declare const unpublishCommunityPostSchema: z.ZodObject<{
@@ -681,13 +703,17 @@ declare const bulkModerationSchema: z.ZodObject<{
681
703
  action: z.ZodEnum<["approve", "reject", "unpublish", "archive"]>;
682
704
  ids: z.ZodArray<z.ZodString, "many">;
683
705
  note: z.ZodOptional<z.ZodString>;
706
+ /** Por id: o `updatedAt` que a tela leu. Id sem entrada decide sem a checagem. */
707
+ expectedUpdatedAt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
684
708
  }, "strict", z.ZodTypeAny, {
685
709
  action: "approve" | "reject" | "unpublish" | "archive";
686
710
  ids: string[];
711
+ expectedUpdatedAt?: Record<string, string> | undefined;
687
712
  note?: string | undefined;
688
713
  }, {
689
714
  action: "approve" | "reject" | "unpublish" | "archive";
690
715
  ids: string[];
716
+ expectedUpdatedAt?: Record<string, string> | undefined;
691
717
  note?: string | undefined;
692
718
  }>;
693
719
  type BulkModerationInput = z.input<typeof bulkModerationSchema>;
@@ -803,6 +829,8 @@ type CommunityPostSubmittedEvent = {
803
829
  readonly authorAccountId: string;
804
830
  readonly kind: CommunitySubmissionKind;
805
831
  readonly moderation: CommunityModeration;
832
+ /** Versão dos termos aceita neste envio (`ContentModuleConfig.termsVersion`), para a auditoria do host. */
833
+ readonly termsVersion?: string;
806
834
  };
807
835
  type CommunityReviewDecision = 'approved' | 'rejected' | 'unpublished' | 'archived';
808
836
  type CommunityReviewTarget = 'post' | 'revision';
@@ -881,6 +909,8 @@ type ContentModuleConfig = {
881
909
  readonly publicCacheControl?: string;
882
910
  readonly feed?: ContentFeedConfig;
883
911
  readonly wordsPerMinute?: number;
912
+ /** Versão dos termos de uso da comunidade, gravada em cada envio. Padrão: `'2'`. Mude ao reescrever os termos. */
913
+ readonly termsVersion?: string;
884
914
  /** Slug automático (quando o autor não informa). Padrão: até 60 caracteres, sem palavras de ligação do pt-BR. */
885
915
  readonly slug?: {
886
916
  readonly maxLength?: number;
@@ -1135,6 +1165,8 @@ type MarkdownRenderOptions = {
1135
1165
  readonly linkRel?: string;
1136
1166
  };
1137
1167
  declare const DEFAULT_LINK_REL = "noopener noreferrer";
1168
+ /** Texto de hóspede: sem herdar reputação de busca e marcado como conteúdo gerado por usuário. */
1169
+ declare const COMMUNITY_LINK_REL = "noopener noreferrer nofollow ugc";
1138
1170
  declare function escapeHtml(value: string): string;
1139
1171
  declare function resolveHeadingLevel(level: number, offset?: number): 1 | 2 | 3 | 4 | 5 | 6;
1140
1172
  declare function renderMarkdownDocument(document: MarkdownDocument, options?: MarkdownRenderOptions): string;
@@ -1160,6 +1192,8 @@ declare function markdownToPlainText(markdown: string): string;
1160
1192
  declare function sanitizeLinkUrl(url: string): string | undefined;
1161
1193
  /** Imagem só por http(s) ou caminho relativo: `data:` permitiria SVG com script embutido. */
1162
1194
  declare function sanitizeImageUrl(url: string): string | undefined;
1195
+ /** `//host` e `/\host`: o navegador resolve como outro site; num texto de hóspede não é "caminho relativo". */
1196
+ declare function isProtocolRelativeUrl(url: string): boolean;
1163
1197
  declare function isAbsoluteHttpUrl(url: string): boolean;
1164
1198
 
1165
1199
  /**
@@ -1230,4 +1264,4 @@ declare function buildAtomFeed(params: {
1230
1264
  }): string;
1231
1265
  declare function buildSitemapXml(entries: readonly SitemapEntry[]): string;
1232
1266
 
1233
- export { BULK_MODERATION_ACTIONS, type BulkModerationAction, type BulkModerationInput, type BulkModerationResult, COMMUNITY_MODERATION, COMMUNITY_MODERATIONS, COMMUNITY_REVISION_STATE, CONTENT_ERROR_CODES, type ClockPort, type CommunityAuthorIdentity, CommunityAuthorNotEligibleError, type CommunityAuthorPort, CommunityDailyLimitError, type CommunityEligibility, CommunityImageNotAllowedError, type CommunityModeration, type CommunityPost, CommunityPostReadOnlyError, type CommunityPostReviewedEvent, type CommunityPostStatus, type CommunityPostSubmittedEvent, type CommunityReviewDecision, type CommunityReviewTarget, type CommunityRevision, type CommunityRevisionState, type CommunitySubmissionKind, CommunityTermsRequiredError, CommunityTooManyImagesError, CommunityUnauthenticatedError, ConfigMissingError, ContentError, type ContentErrorCode, type ContentFeedConfig, type ContentHooks, type ContentImageStoragePort, type ContentModuleConfig, type ContentSettings, type ContentSettingsInput, type CreateCommunityPostInput, type CreateFromTemplateInput, type CreatePostInput, type CreatePostReportInput, type CreateRecurrenceInput, DEFAULT_ADMIN_SCOPES, DEFAULT_CONTENT_SETTINGS, 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, InvalidPostTransitionError, InvalidSlugError, type ListPostReportsQuery, 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_ORIGIN, POST_ORIGINS, POST_ORIGIN_FILTERS, 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 PostOrigin, type PostOriginFilter, type PostReport, type PostReportedEvent, type PostSortField, type PostStatus, type PostSummary, type PublicPost, type PublicPostSummary, type PublishPostInput, RECURRENCE_FREQUENCIES, RECURRENCE_FREQUENCY, REPORT_STATUSES, type RecurrenceFrequency, RecurrenceNotFoundError, type RecurrenceRule, type RejectPostInput, ReportNotFoundError, type ReportStatus, RepublishDateInFutureError, type RepublishPostInput, SHORT_ID_LENGTH, SLUG_MAX_LENGTH, type SaveAsTemplateInput, type ShortSlugOptions, type SitemapEntry, type SubmitCommunityPostInput, TAGS_MAX_COUNT, TAG_MAX_LENGTH, type TagCount, type TagLabels, TemplateNotPublishableError, type UnpublishCommunityPostInput, type UpdateCommunityPostInput, type UpdatePostInput, type UpdateRecurrenceInput, buildAtomFeed, buildExcerpt, buildPostPath, buildPostRef, buildPostUrl, buildRssFeed, buildShortSlug, buildSitemapXml, buildTagLabels, bulkModerationSchema, collectImageSources, communityDisplayNameSchema, communityRevisionSchema, contentSettingsSchema, countWords, createCommunityPostSchema, createFromTemplateSchema, createHeadingIdGenerator, createPostReportSchema, createPostSchema, createRecurrenceSchema, documentToPlainText, escapeHtml, escapeXml, estimateReadingTimeMinutes, formatTagLabel, httpUrlSchema, inlineToPlainText, isAbsoluteHttpUrl, isCanonicalPostRef, isPostStatus, isShortId, isValidSlug, listPostReportsQuerySchema, listPostsQuerySchema, listPublishedPostsQuerySchema, markdownToPlainText, normalizeTag, normalizeTags, parseInline, parseMarkdown, parsePostPath, parsePostRef, postFieldsSchema, publishPostSchema, rejectPostSchema, renderMarkdownDocument, renderMarkdownToHtml, republishPostSchema, resolveHeadingLevel, sanitizeImageUrl, sanitizeLinkUrl, saveAsTemplateSchema, slugSchema, slugify, submitCommunityPostSchema, unpublishCommunityPostSchema, updateCommunityPostSchema, updatePostSchema, updateRecurrenceSchema, withSlugSuffix };
1267
+ export { ActorRequiredError, type ApprovePostInput, BULK_MODERATION_ACTIONS, type BulkModerationAction, type BulkModerationInput, type BulkModerationResult, COMMUNITY_LINK_REL, COMMUNITY_MODERATION, COMMUNITY_MODERATIONS, COMMUNITY_REVISION_STATE, CONTENT_ERROR_CODES, type ClockPort, type CommunityAuthorIdentity, CommunityAuthorNotEligibleError, type CommunityAuthorPort, CommunityDailyLimitError, type CommunityEligibility, CommunityImageNotAllowedError, type CommunityModeration, type CommunityPost, CommunityPostReadOnlyError, type CommunityPostReviewedEvent, type CommunityPostStatus, type CommunityPostSubmittedEvent, type CommunityReviewDecision, type CommunityReviewTarget, type CommunityRevision, type CommunityRevisionState, type CommunitySubmissionKind, CommunityTermsRequiredError, CommunityTooManyImagesError, CommunityUnauthenticatedError, ConfigMissingError, ContentError, type ContentErrorCode, type ContentFeedConfig, type ContentHooks, type ContentImageStoragePort, type ContentModuleConfig, type ContentSettings, type ContentSettingsInput, type CreateCommunityPostInput, type CreateFromTemplateInput, type CreatePostInput, type CreatePostReportInput, type CreateRecurrenceInput, DEFAULT_ADMIN_SCOPES, DEFAULT_CONTENT_SETTINGS, 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, InvalidPostTransitionError, InvalidSlugError, type ListPostReportsQuery, 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_ORIGIN, POST_ORIGINS, POST_ORIGIN_FILTERS, 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 PostOrigin, type PostOriginFilter, type PostReport, type PostReportedEvent, type PostSortField, PostStateChangedError, type PostStatus, type PostSummary, type PublicPost, type PublicPostSummary, type PublishPostInput, RECURRENCE_FREQUENCIES, RECURRENCE_FREQUENCY, REPORT_STATUSES, type RecurrenceFrequency, RecurrenceNotFoundError, type RecurrenceRule, type RejectPostInput, ReportNotFoundError, type ReportStatus, RepublishDateInFutureError, type RepublishPostInput, SHORT_ID_LENGTH, SLUG_MAX_LENGTH, type SaveAsTemplateInput, type ShortSlugOptions, type SitemapEntry, type SubmitCommunityPostInput, TAGS_MAX_COUNT, TAG_MAX_LENGTH, type TagCount, type TagLabels, TemplateNotPublishableError, type UnpublishCommunityPostInput, type UpdateCommunityPostInput, type UpdatePostInput, type UpdateRecurrenceInput, approvePostSchema, buildAtomFeed, buildExcerpt, buildPostPath, buildPostRef, buildPostUrl, buildRssFeed, buildShortSlug, buildSitemapXml, buildTagLabels, bulkModerationSchema, collectImageSources, communityDisplayNameSchema, communityRevisionSchema, contentSettingsSchema, countWords, createCommunityPostSchema, createFromTemplateSchema, createHeadingIdGenerator, createPostReportSchema, createPostSchema, createRecurrenceSchema, documentToPlainText, escapeHtml, escapeXml, estimateReadingTimeMinutes, formatTagLabel, httpUrlSchema, inlineToPlainText, isAbsoluteHttpUrl, isCanonicalPostRef, isPostStatus, isProtocolRelativeUrl, isShortId, isValidSlug, listPostReportsQuerySchema, listPostsQuerySchema, listPublishedPostsQuerySchema, markdownToPlainText, normalizeTag, normalizeTags, parseInline, parseMarkdown, parsePostPath, parsePostRef, postFieldsSchema, publishPostSchema, rejectPostSchema, renderMarkdownDocument, renderMarkdownToHtml, republishPostSchema, resolveHeadingLevel, sanitizeImageUrl, sanitizeLinkUrl, saveAsTemplateSchema, slugSchema, slugify, submitCommunityPostSchema, unpublishCommunityPostSchema, updateCommunityPostSchema, updatePostSchema, updateRecurrenceSchema, withSlugSuffix };
package/dist/index.js CHANGED
@@ -75,6 +75,8 @@ var CONTENT_ERROR_CODES = {
75
75
  COMMUNITY_TOO_MANY_IMAGES: "CONTENT_COMMUNITY_TOO_MANY_IMAGES",
76
76
  COMMUNITY_IMAGE_NOT_ALLOWED: "CONTENT_COMMUNITY_IMAGE_NOT_ALLOWED",
77
77
  INVALID_TRANSITION: "CONTENT_INVALID_TRANSITION",
78
+ POST_STATE_CHANGED: "CONTENT_POST_STATE_CHANGED",
79
+ ACTOR_REQUIRED: "CONTENT_ACTOR_REQUIRED",
78
80
  COMMUNITY_POST_READ_ONLY: "CONTENT_COMMUNITY_POST_READ_ONLY",
79
81
  REPORT_NOT_FOUND: "CONTENT_REPORT_NOT_FOUND"
80
82
  };
@@ -262,6 +264,25 @@ var InvalidPostTransitionError = class extends ContentError {
262
264
  }), this.from = from, this.action = action;
263
265
  }
264
266
  };
267
+ var ActorRequiredError = class extends ContentError {
268
+ static {
269
+ __name(this, "ActorRequiredError");
270
+ }
271
+ constructor() {
272
+ super("Esta a\xE7\xE3o exige um usu\xE1rio da equipe.", 403, CONTENT_ERROR_CODES.ACTOR_REQUIRED);
273
+ }
274
+ };
275
+ var PostStateChangedError = class extends ContentError {
276
+ static {
277
+ __name(this, "PostStateChangedError");
278
+ }
279
+ postId;
280
+ constructor(postId) {
281
+ super("O post mudou desde que voc\xEA o abriu. Recarregue e confira antes de decidir.", 409, CONTENT_ERROR_CODES.POST_STATE_CHANGED, {
282
+ postId
283
+ }), this.postId = postId;
284
+ }
285
+ };
265
286
  var CommunityPostReadOnlyError = class extends ContentError {
266
287
  static {
267
288
  __name(this, "CommunityPostReadOnlyError");
@@ -531,8 +552,15 @@ var updateCommunityPostSchema = communityFieldsSchema.partial().strict();
531
552
  var submitCommunityPostSchema = z.object({
532
553
  termsAccepted: z.boolean()
533
554
  }).strict();
555
+ var expectedUpdatedAtSchema = z.string().datetime({
556
+ offset: true
557
+ });
558
+ var approvePostSchema = z.object({
559
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional()
560
+ }).strict();
534
561
  var rejectPostSchema = z.object({
535
- note: z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE)
562
+ note: z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE),
563
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional()
536
564
  }).strict();
537
565
  var unpublishCommunityPostSchema = z.object({
538
566
  note: z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional()
@@ -546,7 +574,9 @@ var BULK_MODERATION_ACTIONS = [
546
574
  var bulkModerationSchema = z.object({
547
575
  action: z.enum(BULK_MODERATION_ACTIONS),
548
576
  ids: z.array(z.string().uuid()).min(1).max(POST_LIMITS.BULK_IDS),
549
- note: z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional()
577
+ note: z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional(),
578
+ /** Por id: o `updatedAt` que a tela leu. Id sem entrada decide sem a checagem. */
579
+ expectedUpdatedAt: z.record(z.string().uuid(), expectedUpdatedAtSchema).optional()
550
580
  }).strict();
551
581
  var contentSettingsSchema = z.object({
552
582
  communityModeration: z.enum(COMMUNITY_MODERATIONS),
@@ -671,6 +701,10 @@ function sanitizeImageUrl(url) {
671
701
  return sanitize(url, IMAGE_SCHEMES);
672
702
  }
673
703
  __name(sanitizeImageUrl, "sanitizeImageUrl");
704
+ function isProtocolRelativeUrl(url) {
705
+ return /^[/\\]{2}/.test(url);
706
+ }
707
+ __name(isProtocolRelativeUrl, "isProtocolRelativeUrl");
674
708
  function isAbsoluteHttpUrl(url) {
675
709
  return /^https?:\/\//i.test(url) || url.startsWith("//");
676
710
  }
@@ -1321,6 +1355,7 @@ __name(createHeadingIdGenerator, "createHeadingIdGenerator");
1321
1355
 
1322
1356
  // src/markdown/renderHtml.ts
1323
1357
  var DEFAULT_LINK_REL = "noopener noreferrer";
1358
+ var COMMUNITY_LINK_REL = "noopener noreferrer nofollow ugc";
1324
1359
  var ESCAPES = {
1325
1360
  "&": "&amp;",
1326
1361
  "<": "&lt;",
@@ -1551,7 +1586,9 @@ function buildSitemapXml(entries) {
1551
1586
  }
1552
1587
  __name(buildSitemapXml, "buildSitemapXml");
1553
1588
  export {
1589
+ ActorRequiredError,
1554
1590
  BULK_MODERATION_ACTIONS,
1591
+ COMMUNITY_LINK_REL,
1555
1592
  COMMUNITY_MODERATION,
1556
1593
  COMMUNITY_MODERATIONS,
1557
1594
  COMMUNITY_REVISION_STATE,
@@ -1589,6 +1626,7 @@ export {
1589
1626
  PT_BR_STOP_WORDS,
1590
1627
  PostNotFoundError,
1591
1628
  PostNotPublishedError,
1629
+ PostStateChangedError,
1592
1630
  RECURRENCE_FREQUENCIES,
1593
1631
  RECURRENCE_FREQUENCY,
1594
1632
  REPORT_STATUSES,
@@ -1600,6 +1638,7 @@ export {
1600
1638
  TAGS_MAX_COUNT,
1601
1639
  TAG_MAX_LENGTH,
1602
1640
  TemplateNotPublishableError,
1641
+ approvePostSchema,
1603
1642
  buildAtomFeed,
1604
1643
  buildExcerpt,
1605
1644
  buildPostPath,
@@ -1631,6 +1670,7 @@ export {
1631
1670
  isAbsoluteHttpUrl,
1632
1671
  isCanonicalPostRef,
1633
1672
  isPostStatus,
1673
+ isProtocolRelativeUrl,
1634
1674
  isShortId,
1635
1675
  isValidSlug,
1636
1676
  listPostReportsQuerySchema,