@headless-lms/core 0.7.0 → 0.8.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.
Files changed (35) hide show
  1. package/dist/assets/file-urls.d.ts +5 -19
  2. package/dist/assets/file-urls.js +2 -23
  3. package/dist/assets/file-urls.js.map +1 -1
  4. package/dist/assets/index.d.ts +3 -3
  5. package/dist/assets/ports.d.ts +9 -10
  6. package/dist/assets/service.d.ts +10 -13
  7. package/dist/assets/service.js +41 -62
  8. package/dist/assets/service.js.map +1 -1
  9. package/dist/content/events.d.ts +13 -13
  10. package/dist/content/service.d.ts +4 -1
  11. package/dist/content/service.js +52 -29
  12. package/dist/content/service.js.map +1 -1
  13. package/dist/discussion/chats.d.ts +1 -2
  14. package/dist/discussion/chats.js +8 -17
  15. package/dist/discussion/chats.js.map +1 -1
  16. package/dist/discussion/ports.d.ts +0 -6
  17. package/dist/discussion/ports.js.map +1 -1
  18. package/dist/discussion/posts.d.ts +1 -4
  19. package/dist/discussion/posts.js +8 -21
  20. package/dist/discussion/posts.js.map +1 -1
  21. package/dist/entitlements/events.d.ts +33 -33
  22. package/dist/identity/events.d.ts +2 -2
  23. package/dist/integrations/events.d.ts +3 -3
  24. package/dist/organizations/events.d.ts +2 -2
  25. package/dist/reporting/member/ports.d.ts +1 -10
  26. package/dist/reporting/member/service.d.ts +2 -11
  27. package/dist/reporting/member/service.js +12 -62
  28. package/dist/reporting/member/service.js.map +1 -1
  29. package/dist/types/ports.d.ts +4 -2
  30. package/dist/types/ports.js.map +1 -1
  31. package/dist/types/schemas/content.d.ts +4 -4
  32. package/dist/types/schemas/discussion.d.ts +14 -14
  33. package/dist/types/schemas/entitlements.d.ts +8 -8
  34. package/dist/types/schemas/notifications.d.ts +3 -3
  35. package/package.json +1 -1
@@ -557,24 +557,6 @@ var PostServiceImpl = class {
557
557
  rows: await this.viewsOf(actor, page.rows)
558
558
  };
559
559
  }
560
- async coverFile(postId, actor) {
561
- const post = await this.repo.find(actor.orgId, postId);
562
- return this.signShown(actor, post, post?.coverAssetId ?? null, "Post cover", postId);
563
- }
564
- async assetFile(postId, assetId, actor) {
565
- const post = await this.repo.find(actor.orgId, postId);
566
- const [upload] = post !== null && this.bodies.parse(post.body).assetIds.includes(assetId) ? await this.images.memberUploads(actor.orgId, [assetId]) : [];
567
- return this.signShown(actor, post, upload ? assetId : null, "Post file", assetId, upload && !INLINE_TYPES.test(upload.contentType) ? upload.filename : void 0);
568
- }
569
- async signShown(actor, post, assetId, label, id, saveAs) {
570
- const orgId = actor.orgId;
571
- if (!post || !assetId || !this.canSee(actor, post)) throw new NotFoundError(label, id);
572
- const space = await this.content.getSpace(post.spaceId, this.authors.systemActor(orgId));
573
- if (!space || !await this.access.canOpen(space, actor)) throw new NotFoundError(label, id);
574
- const url = await this.images.signFile(orgId, assetId, saveAs ? { saveAs } : {});
575
- if (!url) throw new NotFoundError(label, id);
576
- return url;
577
- }
578
560
  async getPost(postId, actor) {
579
561
  const { post } = await this.loadVisible(actor, postId);
580
562
  this.logger.debug("post read", {
@@ -669,6 +651,10 @@ var PostServiceImpl = class {
669
651
  this.images.memberUploads(orgId, [...new Set([...bodyAssets.values()].flat())])
670
652
  ]);
671
653
  const uploadOf = new Map(uploads.map((upload) => [upload.id, upload]));
654
+ const links = await this.images.fileLinks(orgId, [...posts.flatMap((post) => post.coverAssetId && post.status !== "published" ? [{ assetId: post.coverAssetId }] : []), ...uploads.map((upload) => INLINE_TYPES.test(upload.contentType) ? { assetId: upload.id } : {
655
+ assetId: upload.id,
656
+ saveAs: upload.filename
657
+ })]);
672
658
  const subscriptionOf = new Map(subscribed.map((row) => [row.itemId, row]));
673
659
  const saved = new Set(bookmarked);
674
660
  return posts.map((post) => {
@@ -677,11 +663,12 @@ var PostServiceImpl = class {
677
663
  const counts = reactions[post.id];
678
664
  return {
679
665
  ...post,
680
- coverUrl: !post.coverAssetId ? null : post.status === "published" ? this.fileUrls.publicImage(orgId, post.id, post.coverAssetId) : this.fileUrls.postCover(post.id),
666
+ coverUrl: !post.coverAssetId ? null : post.status === "published" ? this.fileUrls.publicImage(orgId, post.id, post.coverAssetId) : links[post.coverAssetId] ?? null,
681
667
  assets: Object.fromEntries((bodyAssets.get(post.id) ?? []).flatMap((assetId) => {
682
668
  const upload = uploadOf.get(assetId);
683
- return upload ? [[assetId, {
684
- url: this.fileUrls.postAsset(post.id, assetId),
669
+ const url = links[assetId];
670
+ return upload && url ? [[assetId, {
671
+ url,
685
672
  kind: upload.kind,
686
673
  filename: upload.filename,
687
674
  size: upload.size
@@ -1 +1 @@
1
- {"version":3,"file":"posts.js","names":[],"sources":["../../src/discussion/posts.ts"],"sourcesContent":["import { genId } from '../shared/id.js';\nimport {\n ConflictError,\n ForbiddenError,\n InvalidInputError,\n NotFoundError,\n UnavailableError,\n} from '../shared/errors.js';\nimport type { BodyParser, Logger, Scheduler } from '../shared/ports.js';\nimport { noopLogger } from '../shared/logger.js';\nimport type { SpaceDetail } from '../content/index.js';\nimport type {\n AssetFiles,\n FileUrls,\n MemberImageReader,\n MemberUploadReader,\n} from '../assets/index.js';\nimport type {\n FlaggedComment,\n FlaggedCommentView,\n Post,\n PostFlag,\n PostFlagResolution,\n PostStatus,\n PostView,\n} from '../types/index.js';\nimport type { Actor, EffectivePermissions } from '../shared/actor.js';\nimport type { NewDiscussionEvent } from './events.js';\nimport { discussionEvents } from './events.js';\nimport { authorView } from './authors.js';\nimport { POST_PUBLISH_JOB } from './jobs.js';\nimport { activeSubscription } from './subscriptions.js';\nimport { keepAllowed, mentionTokens, mentionViews } from './mentions.js';\nimport { skipsReview, teamBadge } from './rules.js';\nimport type {\n AuthorPermissionReader,\n AuthorProfileReader,\n CommunityAccess,\n CreatePostInput,\n FeedQuery,\n MentionsRepository,\n PageQuery,\n PostPatch,\n PostCommentReader,\n PostReactions,\n PostRepository,\n PostService,\n PostUnitOfWork,\n SpaceModerationQueue,\n SpaceReader,\n SubscriptionsRepository,\n UpdatePostInput,\n PublishedPost,\n} from './ports.js';\nimport { MODERATION_QUEUE_LIMIT } from './ports.js';\nimport type { Page, ReactionEmoji } from './types.js';\n\nexport type PostServiceParams = {\n repo: PostRepository;\n access: CommunityAccess;\n content: Pick<SpaceReader, 'getSpace'>;\n authors: AuthorPermissionReader;\n profiles: AuthorProfileReader;\n comments: PostCommentReader;\n subscriptions: SubscriptionsRepository;\n mentions: MentionsRepository;\n images: MemberImageReader &\n MemberUploadReader &\n Pick<AssetFiles, 'signFile' | 'syncPublicImages'>;\n fileUrls: FileUrls;\n bodies: BodyParser;\n uow: PostUnitOfWork;\n scheduler: Pick<Scheduler, 'at' | 'cancel'>;\n logger?: Logger;\n};\n\ntype EventMeta = { actorId?: string; previousStatus?: PostStatus | null };\n\nconst MAX_BODY_ASSETS = 20;\nconst INLINE_TYPES = /^(image\\/(png|jpeg|gif|webp|avif)|video\\/.+|audio\\/.+|application\\/pdf)$/i;\nconst PUBLISHED_ONLY: PostStatus[] = ['published'];\nconst MODERATOR_VISIBLE: PostStatus[] = ['published', 'pending', 'removed'];\nconst DRAFT = {\n status: 'draft' as const,\n scheduledAt: null,\n publishedAt: null,\n removedBy: null,\n};\n\nexport class PostServiceImpl implements PostService {\n private readonly repo: PostRepository;\n private readonly access: CommunityAccess;\n private readonly content: Pick<SpaceReader, 'getSpace'>;\n private readonly authors: AuthorPermissionReader;\n private readonly profiles: AuthorProfileReader;\n private readonly comments: PostCommentReader;\n private readonly subscriptions: SubscriptionsRepository;\n private readonly mentions: MentionsRepository;\n private readonly images: MemberImageReader &\n MemberUploadReader &\n Pick<AssetFiles, 'signFile' | 'syncPublicImages'>;\n private readonly fileUrls: FileUrls;\n private readonly bodies: BodyParser;\n private readonly uow: PostUnitOfWork;\n private readonly scheduler: Pick<Scheduler, 'at' | 'cancel'>;\n private readonly logger: Logger;\n\n constructor(params: PostServiceParams) {\n this.repo = params.repo;\n this.access = params.access;\n this.content = params.content;\n this.authors = params.authors;\n this.profiles = params.profiles;\n this.comments = params.comments;\n this.subscriptions = params.subscriptions;\n this.mentions = params.mentions;\n this.images = params.images;\n this.fileUrls = params.fileUrls;\n this.bodies = params.bodies;\n this.uow = params.uow;\n this.scheduler = params.scheduler;\n this.logger = params.logger ?? noopLogger;\n }\n\n async visibleTitles(postIds: string[], actor: Actor): Promise<Record<string, string>> {\n const orgId = actor.orgId;\n const found = await this.repo.findMany(orgId, [...new Set(postIds)]);\n const communityIds = [...new Set(found.map((post) => post.communityId))];\n const open = new Set(\n (\n await Promise.all(\n communityIds.map((communityId) => this.access.openSpaceIds(communityId, actor)),\n )\n ).flat(),\n );\n return Object.fromEntries(\n found\n .filter((post) => open.has(post.spaceId) && this.canSee(actor, post))\n .map((post) => [post.id, post.title]),\n );\n }\n\n publishedBetween(\n orgId: string,\n communityId: string,\n from: Date,\n to: Date,\n ): Promise<PublishedPost[]> {\n return this.repo.publishedBetween(orgId, communityId, from, to);\n }\n\n async create(input: CreatePostInput, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const space = await this.requireOpen(actor, input.spaceId, input.communityId);\n await this.requireOwnedImage(orgId, actor.id, input.coverAssetId);\n const parsed = this.bodies.parse(input.body);\n await this.requireBodyAssets(orgId, actor.id, parsed.assetIds);\n this.assertTopic(space, input.topicId);\n const now = new Date();\n const landing = this.initial(input, space, actor, now);\n const post: Post = {\n orgId,\n id: genId('post'),\n communityId: space.communityId,\n spaceId: space.id,\n orgUserId: actor.id,\n topicId: input.topicId,\n title: input.title,\n body: input.body,\n extra: input.extra,\n coverAssetId: input.coverAssetId,\n pinned: false,\n commentsClosed: null,\n reactionsEnabled: null,\n createdAt: now,\n updatedAt: now,\n ...landing,\n };\n const mentioned = await this.mentionable(orgId, space.id, post.title, parsed.mentions);\n const saved = await this.uow.run(async ({ posts, mentions, outbox }) => {\n const created = await posts.insert(orgId, post);\n await mentions.sync(orgId, 'post', created.id, mentioned, now);\n const events: NewDiscussionEvent[] = [\n discussionEvents.postCreated.make({\n orgId,\n data: created,\n metadata: this.meta(actor, created.status === 'pending' ? null : undefined),\n }),\n ];\n if (created.status === 'published') {\n events.push(this.published(orgId, created, this.meta(actor, null), mentioned));\n }\n await outbox.append(events);\n return created;\n });\n this.logger.info('post created', {\n orgId,\n postId: saved.id,\n status: saved.status,\n actorId: actor.id,\n });\n if (saved.status === 'scheduled') {\n await this.arm(orgId, actor, saved, null);\n }\n await this.syncCover(saved);\n return this.viewOf(actor, saved);\n }\n\n async update(postId: string, patch: UpdatePostInput, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post, space } = await this.loadVisible(actor, postId);\n this.assertAuthor(actor, post);\n if (post.status === 'removed') {\n throw new ConflictError('This post was removed');\n }\n if (patch.topicId !== undefined) {\n this.assertTopic(space, patch.topicId);\n }\n if (typeof patch.coverAssetId === 'string') {\n await this.requireOwnedImage(orgId, actor.id, patch.coverAssetId);\n }\n const parsed = this.bodies.parse(patch.body ?? post.body);\n if (patch.body !== undefined) {\n await this.requireBodyAssets(orgId, actor.id, parsed.assetIds);\n }\n if (!this.patchChanges(post, patch)) {\n return this.viewOf(actor, post);\n }\n const retext = patch.title !== undefined || patch.body !== undefined;\n const candidates = retext\n ? await this.mentionable(orgId, post.spaceId, patch.title ?? post.title, parsed.mentions)\n : [];\n const updated = await this.uow.run(async ({ posts, mentions, outbox }) => {\n const next = await this.mustUpdate(posts, orgId, postId, patch);\n const added = retext\n ? await mentions.sync(orgId, 'post', postId, candidates, new Date())\n : [];\n await outbox.append([\n this.updated(\n orgId,\n next,\n this.meta(actor, next.status === 'pending' ? post.status : undefined),\n next.status === 'published' ? keepAllowed(candidates, added) : [],\n ),\n ]);\n return next;\n });\n this.logger.info('post updated', {\n orgId,\n postId,\n fields: Object.keys(patch),\n actorId: actor.id,\n });\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async submit(postId: string, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post, space } = await this.loadVisible(actor, postId);\n this.assertAuthor(actor, post);\n if (post.status !== 'draft' && post.status !== 'scheduled') {\n throw new ConflictError('This post cannot be submitted');\n }\n this.assertTopic(space, post.topicId);\n const saved = await this.commitSubmission(\n orgId,\n post,\n space,\n skipsReview(actor.permissions, { communityId: post.communityId }),\n actor,\n new Date(),\n );\n this.logger.info('post submitted', { orgId, postId, status: saved.status, actorId: actor.id });\n if (post.status === 'scheduled') {\n await this.disarm(orgId, postId);\n }\n await this.syncCover(saved);\n return this.viewOf(actor, saved);\n }\n\n async schedule(postId: string, scheduledAt: Date, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId);\n this.assertAuthor(actor, post);\n if (post.status === 'published' || post.status === 'removed' || post.status === 'pending') {\n throw new ConflictError('This post cannot be scheduled');\n }\n if (scheduledAt <= new Date()) {\n throw new InvalidInputError('A scheduled time must be in the future');\n }\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await posts.updateIf(\n orgId,\n postId,\n { status: post.status },\n { status: 'scheduled', scheduledAt, publishedAt: null, removedBy: null },\n );\n if (!next) {\n throw new ConflictError('This post cannot be scheduled');\n }\n await outbox.append([this.updated(orgId, next, this.meta(actor, post.status))]);\n return next;\n });\n this.logger.info('post scheduled', {\n orgId,\n postId,\n scheduledAt: scheduledAt.toISOString(),\n actorId: actor.id,\n });\n await this.arm(orgId, actor, updated, post.status === 'scheduled' ? post.scheduledAt : null);\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async unschedule(postId: string, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId);\n this.assertAuthor(actor, post);\n if (post.status !== 'scheduled') {\n throw new ConflictError('This post is not scheduled');\n }\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await posts.updateIf(orgId, postId, { status: 'scheduled' }, DRAFT);\n if (!next) {\n throw new ConflictError('This post is not scheduled');\n }\n await outbox.append([this.updated(orgId, next, this.meta(actor, post.status))]);\n return next;\n });\n this.logger.info('post unscheduled', { orgId, postId, actorId: actor.id });\n await this.disarm(orgId, postId);\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async publishScheduled(orgId: string, postId: string, now: Date): Promise<void> {\n const post = await this.repo.find(orgId, postId);\n if (!post || post.status !== 'scheduled' || post.scheduledAt === null) {\n this.logger.debug('scheduled post no longer scheduled', { orgId, postId });\n return;\n }\n if (post.scheduledAt > now) {\n await this.scheduler.at(POST_PUBLISH_JOB, post.scheduledAt, postId, { orgId, postId });\n this.logger.info('scheduled post timer moved', {\n orgId,\n postId,\n scheduledAt: post.scheduledAt.toISOString(),\n });\n return;\n }\n const space = await this.content.getSpace(post.spaceId, this.authors.systemActor(orgId));\n if (!space) {\n this.logger.error('scheduled post has no space', { orgId, postId, spaceId: post.spaceId });\n return;\n }\n const author = await this.authors.actorFor(orgId, post.orgUserId);\n const refused = author === null || !(await this.submittable(post, space, author));\n const patch =\n author === null || refused\n ? DRAFT\n : this.submissionOf(\n space.settings.requireReview,\n skipsReview(author.permissions, { communityId: post.communityId }),\n now,\n );\n const mentioned = await this.mentionedOpeners(orgId, post);\n const saved = await this.uow.run(async ({ posts, outbox }) => {\n const next = await posts.updateIf(orgId, postId, { status: 'scheduled', dueBy: now }, patch);\n if (!next) {\n return null;\n }\n await outbox.append([this.landed(orgId, next, this.meta(null, post.status), mentioned)]);\n return next;\n });\n if (!saved) {\n this.logger.debug('scheduled post already handled', { orgId, postId });\n return;\n }\n this.logger.info('scheduled post submitted', { orgId, postId, status: saved.status, refused });\n await this.syncCover(saved);\n }\n\n private async arm(\n orgId: string,\n actor: Actor,\n post: Post,\n previousScheduledAt: Date | null,\n ): Promise<void> {\n if (post.scheduledAt === null) {\n return;\n }\n try {\n await this.scheduler.at(POST_PUBLISH_JOB, post.scheduledAt, post.id, {\n orgId,\n postId: post.id,\n });\n return;\n } catch (err) {\n this.logger.error('post timer not set', { orgId, postId: post.id, err });\n }\n await this.uow.run(async ({ posts, outbox }) => {\n const reverted = await posts.updateIf(\n orgId,\n post.id,\n { status: 'scheduled', scheduledAt: post.scheduledAt! },\n previousScheduledAt ? { scheduledAt: previousScheduledAt } : DRAFT,\n );\n if (!reverted) {\n return;\n }\n await outbox.append([\n this.updated(\n orgId,\n reverted,\n this.meta(actor, reverted.status === 'draft' ? post.status : undefined),\n ),\n ]);\n });\n throw new UnavailableError('The post could not be scheduled; try again', { postId: post.id });\n }\n\n private syncCover(post: Post): Promise<void> {\n return this.images.syncPublicImages(\n post.orgId,\n post.id,\n post.status === 'published' && post.coverAssetId ? [post.coverAssetId] : [],\n );\n }\n\n private async disarm(orgId: string, postId: string): Promise<void> {\n try {\n await this.scheduler.cancel(POST_PUBLISH_JOB, postId);\n } catch (err) {\n this.logger.warn('post timer not cancelled', { orgId, postId, err });\n }\n }\n\n async approve(postId: string, communityId: string | null, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId, communityId);\n this.requireModerator(actor, post, 'approve');\n if (post.status !== 'pending') {\n throw new ConflictError('This post is not awaiting review');\n }\n const now = new Date();\n const mentioned = await this.mentionedOpeners(orgId, post);\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await this.mustUpdate(posts, orgId, postId, {\n status: 'published',\n publishedAt: now,\n scheduledAt: null,\n removedBy: null,\n });\n await outbox.append([this.landed(orgId, next, this.meta(actor, post.status), mentioned)]);\n return next;\n });\n this.logger.info('post approved', { orgId, postId, actorId: actor.id });\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async remove(postId: string, communityId: string | null, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId, communityId);\n if (post.orgUserId !== actor.id) {\n this.requireModerator(actor, post, 'remove');\n }\n if (post.status === 'removed') {\n throw new ConflictError('This post was removed');\n }\n if (post.status !== 'published' && post.status !== 'pending') {\n throw new ConflictError('This post cannot be removed');\n }\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await this.mustUpdate(posts, orgId, postId, {\n status: 'removed',\n removedBy: actor.id,\n });\n if (post.orgUserId !== actor.id) {\n await posts.resolveFlags(orgId, postId, {\n resolvedAt: new Date(),\n resolvedBy: actor.id,\n resolution: 'removed',\n });\n }\n await outbox.append([\n discussionEvents.postRemoved.make({\n orgId,\n data: next,\n metadata: this.meta(actor, post.status),\n }),\n ]);\n return next;\n });\n this.logger.info('post removed', { orgId, postId, actorId: actor.id });\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async restore(postId: string, communityId: string | null, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post, space } = await this.loadVisible(actor, postId, communityId);\n this.requireModerator(actor, post, 'restore');\n if (post.status !== 'removed') {\n throw new ConflictError('This post was not removed');\n }\n const now = new Date();\n const author = (await this.authors.permissionsOfMany(orgId, [post.orgUserId])).get(\n post.orgUserId,\n );\n const skips = author !== undefined && skipsReview(author, { communityId: post.communityId });\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await this.mustUpdate(\n posts,\n orgId,\n postId,\n this.submissionOf(space.settings.requireReview, skips, now),\n );\n const metadata = this.meta(actor, post.status);\n await outbox.append([\n next.status === 'published'\n ? this.published(orgId, next, metadata, [])\n : this.updated(orgId, next, metadata),\n ]);\n return next;\n });\n this.logger.info('post restored', {\n orgId,\n postId,\n status: updated.status,\n actorId: actor.id,\n });\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n pin(postId: string, actor: Actor): Promise<PostView> {\n return this.moderate(postId, actor, { pinned: true }, (post) => post.pinned, 'post pinned');\n }\n\n unpin(postId: string, actor: Actor): Promise<PostView> {\n return this.moderate(postId, actor, { pinned: false }, (post) => !post.pinned, 'post unpinned');\n }\n\n closeComments(postId: string, actor: Actor): Promise<PostView> {\n return this.moderate(\n postId,\n actor,\n { commentsClosed: true },\n (post) => post.commentsClosed === true,\n 'post comments closed',\n );\n }\n\n openComments(postId: string, actor: Actor): Promise<PostView> {\n return this.moderate(\n postId,\n actor,\n { commentsClosed: false },\n (post) => post.commentsClosed === false,\n 'post comments opened',\n );\n }\n\n setReactions(postId: string, enabled: boolean, actor: Actor): Promise<PostView> {\n return this.moderate(\n postId,\n actor,\n { reactionsEnabled: enabled },\n (post) => post.reactionsEnabled === enabled,\n 'post reactions changed',\n );\n }\n\n async setReaction(\n postId: string,\n emoji: ReactionEmoji | null,\n actor: Actor,\n ): Promise<PostReactions> {\n const orgId = actor.orgId;\n const { post, space } = await this.loadVisible(actor, postId);\n if (!(post.reactionsEnabled ?? space.settings.reactions)) {\n throw new ForbiddenError('Reactions are off on this post');\n }\n await this.uow.run(async ({ posts, outbox }) => {\n const first = await posts.setReaction(orgId, postId, actor.id, emoji);\n if (!first || emoji === null) {\n return;\n }\n await outbox.append([\n discussionEvents.postReactionAdded.make({\n orgId,\n data: {\n postId,\n spaceId: post.spaceId,\n communityId: post.communityId,\n orgUserId: actor.id,\n reaction: emoji,\n },\n metadata: this.meta(actor),\n }),\n ]);\n });\n this.logger.debug('post reaction set', { orgId, postId, orgUserId: actor.id });\n const counts = await this.repo.reactionsOf(orgId, [postId], actor.id);\n return counts[postId] ?? { reactions: {} };\n }\n\n async bookmark(postId: string, actor: Actor): Promise<void> {\n const orgId = actor.orgId;\n await this.loadVisible(actor, postId);\n await this.repo.bookmark(orgId, postId, actor.id);\n this.logger.debug('post bookmarked', { orgId, postId, orgUserId: actor.id });\n }\n\n async unbookmark(postId: string, actor: Actor): Promise<void> {\n const orgId = actor.orgId;\n await this.loadVisible(actor, postId);\n await this.repo.unbookmark(orgId, postId, actor.id);\n this.logger.debug('post unbookmarked', { orgId, postId, orgUserId: actor.id });\n }\n\n async flag(postId: string, reason: string, actor: Actor): Promise<PostFlag> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId);\n const now = new Date();\n const flag: PostFlag = {\n orgId,\n id: genId('postFlag'),\n postId,\n orgUserId: actor.id,\n reason,\n resolvedAt: null,\n resolution: null,\n resolvedBy: null,\n createdAt: now,\n updatedAt: now,\n };\n const saved = await this.uow.run(async ({ posts, outbox }) => {\n const created = await posts.insertFlag(orgId, flag);\n if (!created) {\n const existing = await posts.findFlag(orgId, postId, actor.id);\n if (!existing) {\n throw new NotFoundError('Flag', postId);\n }\n return existing;\n }\n await outbox.append([\n discussionEvents.postReported.make({\n orgId,\n data: { ...created, communityId: post.communityId },\n metadata: this.meta(actor),\n }),\n ]);\n return created;\n });\n this.logger.info('post flagged', { orgId, postId, flagId: saved.id, actorId: actor.id });\n return saved;\n }\n\n async resolveFlags(\n postId: string,\n resolution: Extract<PostFlagResolution, 'dismissed'>,\n communityId: string | null,\n actor: Actor,\n ): Promise<void> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId, communityId);\n this.requireModerator(actor, post, 'resolve flags');\n await this.repo.resolveFlags(orgId, postId, {\n resolvedAt: new Date(),\n resolvedBy: actor.id,\n resolution,\n });\n this.logger.info('post flags resolved', { orgId, postId, resolution, actorId: actor.id });\n }\n\n async spaceFeed(\n communityId: string,\n spaceId: string,\n query: FeedQuery,\n actor: Actor,\n ): Promise<Page<PostView>> {\n const orgId = actor.orgId;\n const space = await this.requireOpen(actor, spaceId, communityId);\n if (query.topicId && !space.topics.some((topic) => topic.id === query.topicId)) {\n throw new NotFoundError('Topic', query.topicId);\n }\n const page = await this.feedPage(actor, [spaceId], query);\n this.logger.debug('space feed read', { orgId, spaceId, rows: page.rows.length });\n return page;\n }\n\n async memberFeed(\n communityId: string,\n query: Pick<FeedQuery, 'page' | 'pageSize'>,\n actor: Actor,\n ): Promise<Page<PostView>> {\n const orgId = actor.orgId;\n const spaceIds = await this.openSpaceIdsIn(actor, communityId);\n const page = await this.feedPage(actor, spaceIds, query);\n this.logger.debug('member feed read', {\n orgId,\n communityId,\n spaces: spaceIds.length,\n rows: page.rows.length,\n });\n return page;\n }\n\n private async openSpaceIdsIn(actor: Actor, communityId: string): Promise<string[]> {\n if (!(await this.access.isCommunityMember(communityId, actor))) {\n throw new NotFoundError('Community', communityId);\n }\n return this.access.openSpaceIds(communityId, actor);\n }\n\n async listOwn(communityId: string, query: PageQuery, actor: Actor): Promise<Page<PostView>> {\n const orgId = actor.orgId;\n const spaceIds = await this.openSpaceIdsIn(actor, communityId);\n const page = await this.repo.listByAuthor(orgId, actor.id, spaceIds, query);\n this.logger.debug('own posts read', { orgId, communityId, rows: page.rows.length });\n return { ...page, rows: await this.viewsOf(actor, page.rows) };\n }\n\n async listBookmarked(\n communityId: string,\n query: PageQuery,\n actor: Actor,\n ): Promise<Page<PostView>> {\n const orgId = actor.orgId;\n const spaceIds = await this.openSpaceIdsIn(actor, communityId);\n const page = await this.repo.listBookmarked(orgId, actor.id, spaceIds, {\n ...query,\n visibleStatuses: this.visibleStatuses(actor, communityId),\n });\n this.logger.debug('bookmarked posts read', { orgId, communityId, rows: page.rows.length });\n return { ...page, rows: await this.viewsOf(actor, page.rows) };\n }\n\n async coverFile(postId: string, actor: Actor): Promise<string> {\n const post = await this.repo.find(actor.orgId, postId);\n return this.signShown(actor, post, post?.coverAssetId ?? null, 'Post cover', postId);\n }\n\n async assetFile(postId: string, assetId: string, actor: Actor): Promise<string> {\n const post = await this.repo.find(actor.orgId, postId);\n const shown = post !== null && this.bodies.parse(post.body).assetIds.includes(assetId);\n const [upload] = shown ? await this.images.memberUploads(actor.orgId, [assetId]) : [];\n return this.signShown(\n actor,\n post,\n upload ? assetId : null,\n 'Post file',\n assetId,\n upload && !INLINE_TYPES.test(upload.contentType) ? upload.filename : undefined,\n );\n }\n\n private async signShown(\n actor: Actor,\n post: Post | null,\n assetId: string | null,\n label: string,\n id: string,\n saveAs?: string,\n ): Promise<string> {\n const orgId = actor.orgId;\n if (!post || !assetId || !this.canSee(actor, post)) {\n throw new NotFoundError(label, id);\n }\n const space = await this.content.getSpace(post.spaceId, this.authors.systemActor(orgId));\n if (!space || !(await this.access.canOpen(space, actor))) {\n throw new NotFoundError(label, id);\n }\n const url = await this.images.signFile(orgId, assetId, saveAs ? { saveAs } : {});\n if (!url) {\n throw new NotFoundError(label, id);\n }\n return url;\n }\n\n async getPost(postId: string, actor: Actor): Promise<PostView> {\n const { post } = await this.loadVisible(actor, postId);\n this.logger.debug('post read', { orgId: actor.orgId, postId });\n return this.viewOf(actor, post);\n }\n\n async moderationQueue(\n communityId: string,\n spaceId: string,\n actor: Actor,\n ): Promise<SpaceModerationQueue> {\n const orgId = actor.orgId;\n const space = await this.requireOpen(actor, spaceId, communityId);\n if (!actor.permissions.has('communities:moderate', space.communityId)) {\n this.logger.warn('space queue refused — not a moderator', {\n orgId,\n communityId,\n spaceId,\n actorId: actor.id,\n });\n throw new ForbiddenError('You need communities:moderate');\n }\n const [pending, flags, openCommentFlags] = await Promise.all([\n this.repo.listPending(orgId, spaceId, MODERATION_QUEUE_LIMIT),\n this.repo.listOpenFlags(orgId, spaceId, MODERATION_QUEUE_LIMIT),\n this.comments.listOpenFlagsForSpace(orgId, spaceId, MODERATION_QUEUE_LIMIT),\n ]);\n this.logger.debug('space queue read', {\n orgId,\n spaceId,\n pending: pending.length,\n flags: flags.length,\n commentFlags: openCommentFlags.length,\n });\n return {\n pending: await this.viewsOf(actor, pending),\n flags,\n commentFlags: await this.flaggedCommentViews(actor, space.communityId, openCommentFlags),\n };\n }\n\n private async flaggedCommentViews(\n actor: Actor,\n communityId: string,\n flags: FlaggedComment[],\n ): Promise<FlaggedCommentView[]> {\n if (flags.length === 0) {\n return [];\n }\n const orgId = actor.orgId;\n const authorIds = [...new Set(flags.map((flag) => flag.comment.orgUserId))];\n const [records, permissions] = await Promise.all([\n this.profiles.authorsOf(orgId, authorIds),\n this.authors.permissionsOfMany(orgId, authorIds),\n ]);\n return flags.map((flag) => {\n const record = records[flag.comment.orgUserId];\n if (!record) {\n throw new NotFoundError('Member', flag.comment.orgUserId);\n }\n return {\n ...flag,\n comment: {\n ...flag.comment,\n author: authorView(\n orgId,\n record,\n this.fileUrls,\n teamBadge(permissions.get(flag.comment.orgUserId), communityId),\n ),\n },\n };\n });\n }\n\n visible(postId: string, actor: Actor): Promise<{ post: Post; space: SpaceDetail }> {\n return this.loadVisible(actor, postId);\n }\n\n find(orgId: string, postId: string): Promise<Post | null> {\n return this.repo.find(orgId, postId);\n }\n\n private async submittable(post: Post, space: SpaceDetail, author: Actor): Promise<boolean> {\n if (!this.topicFits(space, post.topicId)) {\n return false;\n }\n return this.access.canOpen(space, author);\n }\n\n private async feedPage(\n actor: Actor,\n spaceIds: string[],\n query: FeedQuery,\n ): Promise<Page<PostView>> {\n const page = await this.repo.listPublished(actor.orgId, spaceIds, query);\n return { ...page, rows: await this.viewsOf(actor, page.rows) };\n }\n\n private async viewOf(actor: Actor, post: Post): Promise<PostView> {\n const [view] = await this.viewsOf(actor, [post]);\n return view!;\n }\n\n private async viewsOf(actor: Actor, posts: Post[]): Promise<PostView[]> {\n if (posts.length === 0) {\n return [];\n }\n const orgId = actor.orgId;\n const postIds = posts.map((post) => post.id);\n const authorIds = [...new Set(posts.map((post) => post.orgUserId))];\n const now = new Date();\n const bodyAssets = new Map(\n posts.map((post) => [post.id, this.bodies.parse(post.body).assetIds]),\n );\n const [\n records,\n permissions,\n reactions,\n commentCounts,\n subscribed,\n bookmarked,\n mentioned,\n uploads,\n ] = await Promise.all([\n this.profiles.authorsOf(orgId, authorIds),\n this.authors.permissionsOfMany(orgId, authorIds),\n this.repo.reactionsOf(orgId, postIds, actor.id),\n this.comments.publishedCommentCounts(orgId, postIds),\n this.subscriptions.forViewer(orgId, actor.id, 'post', postIds),\n this.repo.bookmarkedAmong(orgId, postIds, actor.id),\n mentionViews(this.mentions, this.profiles, orgId, 'post', postIds),\n this.images.memberUploads(orgId, [...new Set([...bodyAssets.values()].flat())]),\n ]);\n const uploadOf = new Map(uploads.map((upload) => [upload.id, upload]));\n const subscriptionOf = new Map(subscribed.map((row) => [row.itemId, row]));\n const saved = new Set(bookmarked);\n return posts.map((post) => {\n const record = records[post.orgUserId];\n if (!record) {\n throw new NotFoundError('Member', post.orgUserId);\n }\n const counts = reactions[post.id];\n return {\n ...post,\n coverUrl: !post.coverAssetId\n ? null\n : post.status === 'published'\n ? this.fileUrls.publicImage(orgId, post.id, post.coverAssetId)\n : this.fileUrls.postCover(post.id),\n assets: Object.fromEntries(\n (bodyAssets.get(post.id) ?? []).flatMap((assetId) => {\n const upload = uploadOf.get(assetId);\n return upload\n ? [\n [\n assetId,\n {\n url: this.fileUrls.postAsset(post.id, assetId),\n kind: upload.kind,\n filename: upload.filename,\n size: upload.size,\n },\n ],\n ]\n : [];\n }),\n ),\n author: authorView(\n orgId,\n record,\n this.fileUrls,\n teamBadge(permissions.get(post.orgUserId), post.communityId),\n ),\n reactions: counts?.reactions ?? {},\n viewerReaction: counts?.viewerReaction ?? null,\n commentCount: commentCounts[post.id] ?? 0,\n subscription: activeSubscription(subscriptionOf.get(post.id), now),\n bookmarked: saved.has(post.id),\n mentions: mentioned[post.id] ?? [],\n };\n });\n }\n\n private async commitSubmission(\n orgId: string,\n post: Post,\n space: SpaceDetail,\n skips: boolean,\n actor: Actor,\n now: Date,\n ): Promise<Post> {\n const mentioned = await this.mentionedOpeners(orgId, post);\n return this.uow.run(async ({ posts, outbox }) => {\n const next = await posts.updateIf(\n orgId,\n post.id,\n { status: post.status },\n this.submissionOf(space.settings.requireReview, skips, now),\n );\n if (!next) {\n throw new ConflictError('This post cannot be submitted');\n }\n await outbox.append([this.landed(orgId, next, this.meta(actor, post.status), mentioned)]);\n return next;\n });\n }\n\n private async moderate(\n postId: string,\n actor: Actor,\n patch: PostPatch,\n unchanged: (post: Post) => boolean,\n log: string,\n ): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId);\n this.requireModerator(actor, post, log);\n if (post.status === 'removed') {\n throw new ConflictError('This post was removed');\n }\n if (unchanged(post)) {\n return this.viewOf(actor, post);\n }\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await this.mustUpdate(posts, orgId, postId, patch);\n await outbox.append([\n this.updated(\n orgId,\n next,\n this.meta(actor, next.status === 'pending' ? post.status : undefined),\n ),\n ]);\n return next;\n });\n this.logger.info(log, { orgId, postId, actorId: actor.id });\n return this.viewOf(actor, updated);\n }\n\n private async mustUpdate(\n posts: PostRepository,\n orgId: string,\n postId: string,\n patch: PostPatch,\n ): Promise<Post> {\n const next = await posts.update(orgId, postId, patch);\n if (!next) {\n throw new NotFoundError('Post', postId);\n }\n return next;\n }\n\n private initial(input: CreatePostInput, space: SpaceDetail, actor: Actor, now: Date) {\n if (input.mode === 'draft') {\n return { status: 'draft' as const, scheduledAt: null, publishedAt: null, removedBy: null };\n }\n if (input.mode === 'schedule') {\n if (!input.scheduledAt) {\n throw new InvalidInputError('A scheduled post needs a time');\n }\n if (input.scheduledAt <= now) {\n throw new InvalidInputError('A scheduled time must be in the future');\n }\n return {\n status: 'scheduled' as const,\n scheduledAt: input.scheduledAt,\n publishedAt: null,\n removedBy: null,\n };\n }\n return this.submissionOf(\n space.settings.requireReview,\n skipsReview(actor.permissions, { communityId: space.communityId }),\n now,\n );\n }\n\n private submissionOf(requireReview: boolean, skips: boolean, now: Date) {\n if (requireReview && !skips) {\n return { status: 'pending' as const, scheduledAt: null, publishedAt: null, removedBy: null };\n }\n return { status: 'published' as const, scheduledAt: null, publishedAt: now, removedBy: null };\n }\n\n private async requireOwnedImage(\n orgId: string,\n orgUserId: string,\n assetId: string | null,\n ): Promise<void> {\n if (assetId === null) {\n return;\n }\n if (!(await this.images.ownsImage(orgId, assetId, orgUserId))) {\n this.logger.debug('cover refused', { orgId, orgUserId, assetId });\n throw new NotFoundError('Asset', assetId);\n }\n }\n\n private async requireBodyAssets(\n orgId: string,\n orgUserId: string,\n assetIds: string[],\n ): Promise<void> {\n if (assetIds.length > MAX_BODY_ASSETS) {\n throw new InvalidInputError(`A post shows at most ${MAX_BODY_ASSETS} files`);\n }\n for (const assetId of assetIds) {\n if (!(await this.images.ownsUpload(orgId, assetId, orgUserId))) {\n this.logger.debug('body file refused', { orgId, orgUserId, assetId });\n throw new NotFoundError('Asset', assetId);\n }\n }\n }\n\n private async openSpace(\n actor: Actor,\n spaceId: string,\n communityId?: string | null,\n ): Promise<SpaceDetail | null> {\n const space = await this.content.getSpace(spaceId, this.authors.systemActor(actor.orgId));\n if (!space || (communityId != null && space.communityId !== communityId)) {\n return null;\n }\n return (await this.access.canOpen(space, actor)) ? space : null;\n }\n\n private async requireOpen(\n actor: Actor,\n spaceId: string,\n communityId?: string,\n ): Promise<SpaceDetail> {\n const space = await this.openSpace(actor, spaceId, communityId);\n if (!space) {\n throw new NotFoundError('Space', spaceId);\n }\n return space;\n }\n\n private async loadVisible(actor: Actor, postId: string, communityId?: string | null) {\n const post = await this.repo.find(actor.orgId, postId);\n if (!post || (communityId != null && post.communityId !== communityId)) {\n throw new NotFoundError('Post', postId);\n }\n const space = await this.openSpace(actor, post.spaceId);\n if (!space || !this.canSee(actor, post)) {\n throw new NotFoundError('Post', postId);\n }\n return { post, space };\n }\n\n private canSee(actor: Actor, post: Post): boolean {\n return (\n post.orgUserId === actor.id ||\n this.visibleStatuses(actor, post.communityId).includes(post.status)\n );\n }\n\n private visibleStatuses(actor: Actor, communityId: string): PostStatus[] {\n return this.moderates(actor.permissions, communityId) ? MODERATOR_VISIBLE : PUBLISHED_ONLY;\n }\n\n private moderates(permissions: EffectivePermissions, communityId: string): boolean {\n return permissions.has('communities:moderate', communityId);\n }\n\n private requireModerator(actor: Actor, post: Post, action: string): void {\n if (!this.moderates(actor.permissions, post.communityId)) {\n this.logger.warn('post moderation refused — not a moderator', {\n orgId: actor.orgId,\n postId: post.id,\n communityId: post.communityId,\n action,\n actorId: actor.id,\n });\n throw new ForbiddenError('You need communities:moderate');\n }\n }\n\n private assertAuthor(actor: Actor, post: Post): void {\n if (post.orgUserId !== actor.id) {\n throw new ForbiddenError('You can change only your own post');\n }\n }\n\n private topicFits(space: SpaceDetail, topicId: string | null): boolean {\n return topicId === null || space.topics.some((topic) => topic.id === topicId);\n }\n\n private assertTopic(space: SpaceDetail, topicId: string | null): void {\n if (topicId !== null && !this.topicFits(space, topicId)) {\n throw new NotFoundError('Topic', topicId);\n }\n }\n\n private patchChanges(post: Post, patch: UpdatePostInput): boolean {\n return (Object.keys(patch) as (keyof UpdatePostInput)[]).some((key) => {\n const value = patch[key];\n if (value === undefined) {\n return false;\n }\n if (key === 'extra') {\n return JSON.stringify(post.extra) !== JSON.stringify(value);\n }\n return post[key] !== value;\n });\n }\n\n private async mentionable(\n orgId: string,\n spaceId: string,\n title: string,\n body: string[],\n ): Promise<string[]> {\n return this.openersOf(orgId, spaceId, [...new Set([...mentionTokens(title), ...body])]);\n }\n\n private async openersOf(orgId: string, spaceId: string, orgUserIds: string[]): Promise<string[]> {\n if (orgUserIds.length === 0) {\n return [];\n }\n return keepAllowed(orgUserIds, await this.access.spaceOpenersAmong(orgId, spaceId, orgUserIds));\n }\n\n private async mentionedOpeners(orgId: string, post: Post): Promise<string[]> {\n return this.openersOf(orgId, post.spaceId, await this.mentions.ofItem(orgId, 'post', post.id));\n }\n\n private landed(\n orgId: string,\n post: Post,\n metadata: EventMeta,\n mentioned: string[],\n ): NewDiscussionEvent {\n if (post.status !== 'published') {\n return this.updated(orgId, post, metadata);\n }\n return this.published(orgId, post, metadata, mentioned);\n }\n\n private published(\n orgId: string,\n post: Post,\n metadata: EventMeta,\n mentionedOrgUserIds: string[],\n ): NewDiscussionEvent {\n return discussionEvents.postPublished.make({\n orgId,\n data: { ...post, mentionedOrgUserIds },\n metadata,\n });\n }\n\n private updated(\n orgId: string,\n post: Post,\n metadata: EventMeta,\n mentionedOrgUserIds: string[] = [],\n ): NewDiscussionEvent {\n return discussionEvents.postUpdated.make({\n orgId,\n data: { ...post, mentionedOrgUserIds },\n metadata,\n });\n }\n\n private meta(actor: Actor | null, previousStatus?: PostStatus | null): EventMeta {\n return {\n ...(actor ? { actorId: actor.id } : {}),\n ...(previousStatus !== undefined ? { previousStatus } : {}),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AA8EA,MAAM,kBAAkB;AACxB,MAAM,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AAA,IAAY,EAAE,eAAe,IAAI,CAAC;EAC3D;CACF;AACF"}
1
+ {"version":3,"file":"posts.js","names":[],"sources":["../../src/discussion/posts.ts"],"sourcesContent":["import { genId } from '../shared/id.js';\nimport {\n ConflictError,\n ForbiddenError,\n InvalidInputError,\n NotFoundError,\n UnavailableError,\n} from '../shared/errors.js';\nimport type { BodyParser, Logger, Scheduler } from '../shared/ports.js';\nimport { noopLogger } from '../shared/logger.js';\nimport type { SpaceDetail } from '../content/index.js';\nimport type {\n AssetFiles,\n FileUrls,\n MemberImageReader,\n MemberUploadReader,\n} from '../assets/index.js';\nimport type {\n FlaggedComment,\n FlaggedCommentView,\n Post,\n PostFlag,\n PostFlagResolution,\n PostStatus,\n PostView,\n} from '../types/index.js';\nimport type { Actor, EffectivePermissions } from '../shared/actor.js';\nimport type { NewDiscussionEvent } from './events.js';\nimport { discussionEvents } from './events.js';\nimport { authorView } from './authors.js';\nimport { POST_PUBLISH_JOB } from './jobs.js';\nimport { activeSubscription } from './subscriptions.js';\nimport { keepAllowed, mentionTokens, mentionViews } from './mentions.js';\nimport { skipsReview, teamBadge } from './rules.js';\nimport type {\n AuthorPermissionReader,\n AuthorProfileReader,\n CommunityAccess,\n CreatePostInput,\n FeedQuery,\n MentionsRepository,\n PageQuery,\n PostPatch,\n PostCommentReader,\n PostReactions,\n PostRepository,\n PostService,\n PostUnitOfWork,\n SpaceModerationQueue,\n SpaceReader,\n SubscriptionsRepository,\n UpdatePostInput,\n PublishedPost,\n} from './ports.js';\nimport { MODERATION_QUEUE_LIMIT } from './ports.js';\nimport type { Page, ReactionEmoji } from './types.js';\n\nexport type PostServiceParams = {\n repo: PostRepository;\n access: CommunityAccess;\n content: Pick<SpaceReader, 'getSpace'>;\n authors: AuthorPermissionReader;\n profiles: AuthorProfileReader;\n comments: PostCommentReader;\n subscriptions: SubscriptionsRepository;\n mentions: MentionsRepository;\n images: MemberImageReader &\n MemberUploadReader &\n Pick<AssetFiles, 'fileLinks' | 'syncPublicImages'>;\n fileUrls: FileUrls;\n bodies: BodyParser;\n uow: PostUnitOfWork;\n scheduler: Pick<Scheduler, 'at' | 'cancel'>;\n logger?: Logger;\n};\n\ntype EventMeta = { actorId?: string; previousStatus?: PostStatus | null };\n\nconst MAX_BODY_ASSETS = 20;\nconst INLINE_TYPES = /^(image\\/(png|jpeg|gif|webp|avif)|video\\/.+|audio\\/.+|application\\/pdf)$/i;\nconst PUBLISHED_ONLY: PostStatus[] = ['published'];\nconst MODERATOR_VISIBLE: PostStatus[] = ['published', 'pending', 'removed'];\nconst DRAFT = {\n status: 'draft' as const,\n scheduledAt: null,\n publishedAt: null,\n removedBy: null,\n};\n\nexport class PostServiceImpl implements PostService {\n private readonly repo: PostRepository;\n private readonly access: CommunityAccess;\n private readonly content: Pick<SpaceReader, 'getSpace'>;\n private readonly authors: AuthorPermissionReader;\n private readonly profiles: AuthorProfileReader;\n private readonly comments: PostCommentReader;\n private readonly subscriptions: SubscriptionsRepository;\n private readonly mentions: MentionsRepository;\n private readonly images: MemberImageReader &\n MemberUploadReader &\n Pick<AssetFiles, 'fileLinks' | 'syncPublicImages'>;\n private readonly fileUrls: FileUrls;\n private readonly bodies: BodyParser;\n private readonly uow: PostUnitOfWork;\n private readonly scheduler: Pick<Scheduler, 'at' | 'cancel'>;\n private readonly logger: Logger;\n\n constructor(params: PostServiceParams) {\n this.repo = params.repo;\n this.access = params.access;\n this.content = params.content;\n this.authors = params.authors;\n this.profiles = params.profiles;\n this.comments = params.comments;\n this.subscriptions = params.subscriptions;\n this.mentions = params.mentions;\n this.images = params.images;\n this.fileUrls = params.fileUrls;\n this.bodies = params.bodies;\n this.uow = params.uow;\n this.scheduler = params.scheduler;\n this.logger = params.logger ?? noopLogger;\n }\n\n async visibleTitles(postIds: string[], actor: Actor): Promise<Record<string, string>> {\n const orgId = actor.orgId;\n const found = await this.repo.findMany(orgId, [...new Set(postIds)]);\n const communityIds = [...new Set(found.map((post) => post.communityId))];\n const open = new Set(\n (\n await Promise.all(\n communityIds.map((communityId) => this.access.openSpaceIds(communityId, actor)),\n )\n ).flat(),\n );\n return Object.fromEntries(\n found\n .filter((post) => open.has(post.spaceId) && this.canSee(actor, post))\n .map((post) => [post.id, post.title]),\n );\n }\n\n publishedBetween(\n orgId: string,\n communityId: string,\n from: Date,\n to: Date,\n ): Promise<PublishedPost[]> {\n return this.repo.publishedBetween(orgId, communityId, from, to);\n }\n\n async create(input: CreatePostInput, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const space = await this.requireOpen(actor, input.spaceId, input.communityId);\n await this.requireOwnedImage(orgId, actor.id, input.coverAssetId);\n const parsed = this.bodies.parse(input.body);\n await this.requireBodyAssets(orgId, actor.id, parsed.assetIds);\n this.assertTopic(space, input.topicId);\n const now = new Date();\n const landing = this.initial(input, space, actor, now);\n const post: Post = {\n orgId,\n id: genId('post'),\n communityId: space.communityId,\n spaceId: space.id,\n orgUserId: actor.id,\n topicId: input.topicId,\n title: input.title,\n body: input.body,\n extra: input.extra,\n coverAssetId: input.coverAssetId,\n pinned: false,\n commentsClosed: null,\n reactionsEnabled: null,\n createdAt: now,\n updatedAt: now,\n ...landing,\n };\n const mentioned = await this.mentionable(orgId, space.id, post.title, parsed.mentions);\n const saved = await this.uow.run(async ({ posts, mentions, outbox }) => {\n const created = await posts.insert(orgId, post);\n await mentions.sync(orgId, 'post', created.id, mentioned, now);\n const events: NewDiscussionEvent[] = [\n discussionEvents.postCreated.make({\n orgId,\n data: created,\n metadata: this.meta(actor, created.status === 'pending' ? null : undefined),\n }),\n ];\n if (created.status === 'published') {\n events.push(this.published(orgId, created, this.meta(actor, null), mentioned));\n }\n await outbox.append(events);\n return created;\n });\n this.logger.info('post created', {\n orgId,\n postId: saved.id,\n status: saved.status,\n actorId: actor.id,\n });\n if (saved.status === 'scheduled') {\n await this.arm(orgId, actor, saved, null);\n }\n await this.syncCover(saved);\n return this.viewOf(actor, saved);\n }\n\n async update(postId: string, patch: UpdatePostInput, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post, space } = await this.loadVisible(actor, postId);\n this.assertAuthor(actor, post);\n if (post.status === 'removed') {\n throw new ConflictError('This post was removed');\n }\n if (patch.topicId !== undefined) {\n this.assertTopic(space, patch.topicId);\n }\n if (typeof patch.coverAssetId === 'string') {\n await this.requireOwnedImage(orgId, actor.id, patch.coverAssetId);\n }\n const parsed = this.bodies.parse(patch.body ?? post.body);\n if (patch.body !== undefined) {\n await this.requireBodyAssets(orgId, actor.id, parsed.assetIds);\n }\n if (!this.patchChanges(post, patch)) {\n return this.viewOf(actor, post);\n }\n const retext = patch.title !== undefined || patch.body !== undefined;\n const candidates = retext\n ? await this.mentionable(orgId, post.spaceId, patch.title ?? post.title, parsed.mentions)\n : [];\n const updated = await this.uow.run(async ({ posts, mentions, outbox }) => {\n const next = await this.mustUpdate(posts, orgId, postId, patch);\n const added = retext\n ? await mentions.sync(orgId, 'post', postId, candidates, new Date())\n : [];\n await outbox.append([\n this.updated(\n orgId,\n next,\n this.meta(actor, next.status === 'pending' ? post.status : undefined),\n next.status === 'published' ? keepAllowed(candidates, added) : [],\n ),\n ]);\n return next;\n });\n this.logger.info('post updated', {\n orgId,\n postId,\n fields: Object.keys(patch),\n actorId: actor.id,\n });\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async submit(postId: string, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post, space } = await this.loadVisible(actor, postId);\n this.assertAuthor(actor, post);\n if (post.status !== 'draft' && post.status !== 'scheduled') {\n throw new ConflictError('This post cannot be submitted');\n }\n this.assertTopic(space, post.topicId);\n const saved = await this.commitSubmission(\n orgId,\n post,\n space,\n skipsReview(actor.permissions, { communityId: post.communityId }),\n actor,\n new Date(),\n );\n this.logger.info('post submitted', { orgId, postId, status: saved.status, actorId: actor.id });\n if (post.status === 'scheduled') {\n await this.disarm(orgId, postId);\n }\n await this.syncCover(saved);\n return this.viewOf(actor, saved);\n }\n\n async schedule(postId: string, scheduledAt: Date, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId);\n this.assertAuthor(actor, post);\n if (post.status === 'published' || post.status === 'removed' || post.status === 'pending') {\n throw new ConflictError('This post cannot be scheduled');\n }\n if (scheduledAt <= new Date()) {\n throw new InvalidInputError('A scheduled time must be in the future');\n }\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await posts.updateIf(\n orgId,\n postId,\n { status: post.status },\n { status: 'scheduled', scheduledAt, publishedAt: null, removedBy: null },\n );\n if (!next) {\n throw new ConflictError('This post cannot be scheduled');\n }\n await outbox.append([this.updated(orgId, next, this.meta(actor, post.status))]);\n return next;\n });\n this.logger.info('post scheduled', {\n orgId,\n postId,\n scheduledAt: scheduledAt.toISOString(),\n actorId: actor.id,\n });\n await this.arm(orgId, actor, updated, post.status === 'scheduled' ? post.scheduledAt : null);\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async unschedule(postId: string, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId);\n this.assertAuthor(actor, post);\n if (post.status !== 'scheduled') {\n throw new ConflictError('This post is not scheduled');\n }\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await posts.updateIf(orgId, postId, { status: 'scheduled' }, DRAFT);\n if (!next) {\n throw new ConflictError('This post is not scheduled');\n }\n await outbox.append([this.updated(orgId, next, this.meta(actor, post.status))]);\n return next;\n });\n this.logger.info('post unscheduled', { orgId, postId, actorId: actor.id });\n await this.disarm(orgId, postId);\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async publishScheduled(orgId: string, postId: string, now: Date): Promise<void> {\n const post = await this.repo.find(orgId, postId);\n if (!post || post.status !== 'scheduled' || post.scheduledAt === null) {\n this.logger.debug('scheduled post no longer scheduled', { orgId, postId });\n return;\n }\n if (post.scheduledAt > now) {\n await this.scheduler.at(POST_PUBLISH_JOB, post.scheduledAt, postId, { orgId, postId });\n this.logger.info('scheduled post timer moved', {\n orgId,\n postId,\n scheduledAt: post.scheduledAt.toISOString(),\n });\n return;\n }\n const space = await this.content.getSpace(post.spaceId, this.authors.systemActor(orgId));\n if (!space) {\n this.logger.error('scheduled post has no space', { orgId, postId, spaceId: post.spaceId });\n return;\n }\n const author = await this.authors.actorFor(orgId, post.orgUserId);\n const refused = author === null || !(await this.submittable(post, space, author));\n const patch =\n author === null || refused\n ? DRAFT\n : this.submissionOf(\n space.settings.requireReview,\n skipsReview(author.permissions, { communityId: post.communityId }),\n now,\n );\n const mentioned = await this.mentionedOpeners(orgId, post);\n const saved = await this.uow.run(async ({ posts, outbox }) => {\n const next = await posts.updateIf(orgId, postId, { status: 'scheduled', dueBy: now }, patch);\n if (!next) {\n return null;\n }\n await outbox.append([this.landed(orgId, next, this.meta(null, post.status), mentioned)]);\n return next;\n });\n if (!saved) {\n this.logger.debug('scheduled post already handled', { orgId, postId });\n return;\n }\n this.logger.info('scheduled post submitted', { orgId, postId, status: saved.status, refused });\n await this.syncCover(saved);\n }\n\n private async arm(\n orgId: string,\n actor: Actor,\n post: Post,\n previousScheduledAt: Date | null,\n ): Promise<void> {\n if (post.scheduledAt === null) {\n return;\n }\n try {\n await this.scheduler.at(POST_PUBLISH_JOB, post.scheduledAt, post.id, {\n orgId,\n postId: post.id,\n });\n return;\n } catch (err) {\n this.logger.error('post timer not set', { orgId, postId: post.id, err });\n }\n await this.uow.run(async ({ posts, outbox }) => {\n const reverted = await posts.updateIf(\n orgId,\n post.id,\n { status: 'scheduled', scheduledAt: post.scheduledAt! },\n previousScheduledAt ? { scheduledAt: previousScheduledAt } : DRAFT,\n );\n if (!reverted) {\n return;\n }\n await outbox.append([\n this.updated(\n orgId,\n reverted,\n this.meta(actor, reverted.status === 'draft' ? post.status : undefined),\n ),\n ]);\n });\n throw new UnavailableError('The post could not be scheduled; try again', { postId: post.id });\n }\n\n private syncCover(post: Post): Promise<void> {\n return this.images.syncPublicImages(\n post.orgId,\n post.id,\n post.status === 'published' && post.coverAssetId ? [post.coverAssetId] : [],\n );\n }\n\n private async disarm(orgId: string, postId: string): Promise<void> {\n try {\n await this.scheduler.cancel(POST_PUBLISH_JOB, postId);\n } catch (err) {\n this.logger.warn('post timer not cancelled', { orgId, postId, err });\n }\n }\n\n async approve(postId: string, communityId: string | null, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId, communityId);\n this.requireModerator(actor, post, 'approve');\n if (post.status !== 'pending') {\n throw new ConflictError('This post is not awaiting review');\n }\n const now = new Date();\n const mentioned = await this.mentionedOpeners(orgId, post);\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await this.mustUpdate(posts, orgId, postId, {\n status: 'published',\n publishedAt: now,\n scheduledAt: null,\n removedBy: null,\n });\n await outbox.append([this.landed(orgId, next, this.meta(actor, post.status), mentioned)]);\n return next;\n });\n this.logger.info('post approved', { orgId, postId, actorId: actor.id });\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async remove(postId: string, communityId: string | null, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId, communityId);\n if (post.orgUserId !== actor.id) {\n this.requireModerator(actor, post, 'remove');\n }\n if (post.status === 'removed') {\n throw new ConflictError('This post was removed');\n }\n if (post.status !== 'published' && post.status !== 'pending') {\n throw new ConflictError('This post cannot be removed');\n }\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await this.mustUpdate(posts, orgId, postId, {\n status: 'removed',\n removedBy: actor.id,\n });\n if (post.orgUserId !== actor.id) {\n await posts.resolveFlags(orgId, postId, {\n resolvedAt: new Date(),\n resolvedBy: actor.id,\n resolution: 'removed',\n });\n }\n await outbox.append([\n discussionEvents.postRemoved.make({\n orgId,\n data: next,\n metadata: this.meta(actor, post.status),\n }),\n ]);\n return next;\n });\n this.logger.info('post removed', { orgId, postId, actorId: actor.id });\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n async restore(postId: string, communityId: string | null, actor: Actor): Promise<PostView> {\n const orgId = actor.orgId;\n const { post, space } = await this.loadVisible(actor, postId, communityId);\n this.requireModerator(actor, post, 'restore');\n if (post.status !== 'removed') {\n throw new ConflictError('This post was not removed');\n }\n const now = new Date();\n const author = (await this.authors.permissionsOfMany(orgId, [post.orgUserId])).get(\n post.orgUserId,\n );\n const skips = author !== undefined && skipsReview(author, { communityId: post.communityId });\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await this.mustUpdate(\n posts,\n orgId,\n postId,\n this.submissionOf(space.settings.requireReview, skips, now),\n );\n const metadata = this.meta(actor, post.status);\n await outbox.append([\n next.status === 'published'\n ? this.published(orgId, next, metadata, [])\n : this.updated(orgId, next, metadata),\n ]);\n return next;\n });\n this.logger.info('post restored', {\n orgId,\n postId,\n status: updated.status,\n actorId: actor.id,\n });\n await this.syncCover(updated);\n return this.viewOf(actor, updated);\n }\n\n pin(postId: string, actor: Actor): Promise<PostView> {\n return this.moderate(postId, actor, { pinned: true }, (post) => post.pinned, 'post pinned');\n }\n\n unpin(postId: string, actor: Actor): Promise<PostView> {\n return this.moderate(postId, actor, { pinned: false }, (post) => !post.pinned, 'post unpinned');\n }\n\n closeComments(postId: string, actor: Actor): Promise<PostView> {\n return this.moderate(\n postId,\n actor,\n { commentsClosed: true },\n (post) => post.commentsClosed === true,\n 'post comments closed',\n );\n }\n\n openComments(postId: string, actor: Actor): Promise<PostView> {\n return this.moderate(\n postId,\n actor,\n { commentsClosed: false },\n (post) => post.commentsClosed === false,\n 'post comments opened',\n );\n }\n\n setReactions(postId: string, enabled: boolean, actor: Actor): Promise<PostView> {\n return this.moderate(\n postId,\n actor,\n { reactionsEnabled: enabled },\n (post) => post.reactionsEnabled === enabled,\n 'post reactions changed',\n );\n }\n\n async setReaction(\n postId: string,\n emoji: ReactionEmoji | null,\n actor: Actor,\n ): Promise<PostReactions> {\n const orgId = actor.orgId;\n const { post, space } = await this.loadVisible(actor, postId);\n if (!(post.reactionsEnabled ?? space.settings.reactions)) {\n throw new ForbiddenError('Reactions are off on this post');\n }\n await this.uow.run(async ({ posts, outbox }) => {\n const first = await posts.setReaction(orgId, postId, actor.id, emoji);\n if (!first || emoji === null) {\n return;\n }\n await outbox.append([\n discussionEvents.postReactionAdded.make({\n orgId,\n data: {\n postId,\n spaceId: post.spaceId,\n communityId: post.communityId,\n orgUserId: actor.id,\n reaction: emoji,\n },\n metadata: this.meta(actor),\n }),\n ]);\n });\n this.logger.debug('post reaction set', { orgId, postId, orgUserId: actor.id });\n const counts = await this.repo.reactionsOf(orgId, [postId], actor.id);\n return counts[postId] ?? { reactions: {} };\n }\n\n async bookmark(postId: string, actor: Actor): Promise<void> {\n const orgId = actor.orgId;\n await this.loadVisible(actor, postId);\n await this.repo.bookmark(orgId, postId, actor.id);\n this.logger.debug('post bookmarked', { orgId, postId, orgUserId: actor.id });\n }\n\n async unbookmark(postId: string, actor: Actor): Promise<void> {\n const orgId = actor.orgId;\n await this.loadVisible(actor, postId);\n await this.repo.unbookmark(orgId, postId, actor.id);\n this.logger.debug('post unbookmarked', { orgId, postId, orgUserId: actor.id });\n }\n\n async flag(postId: string, reason: string, actor: Actor): Promise<PostFlag> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId);\n const now = new Date();\n const flag: PostFlag = {\n orgId,\n id: genId('postFlag'),\n postId,\n orgUserId: actor.id,\n reason,\n resolvedAt: null,\n resolution: null,\n resolvedBy: null,\n createdAt: now,\n updatedAt: now,\n };\n const saved = await this.uow.run(async ({ posts, outbox }) => {\n const created = await posts.insertFlag(orgId, flag);\n if (!created) {\n const existing = await posts.findFlag(orgId, postId, actor.id);\n if (!existing) {\n throw new NotFoundError('Flag', postId);\n }\n return existing;\n }\n await outbox.append([\n discussionEvents.postReported.make({\n orgId,\n data: { ...created, communityId: post.communityId },\n metadata: this.meta(actor),\n }),\n ]);\n return created;\n });\n this.logger.info('post flagged', { orgId, postId, flagId: saved.id, actorId: actor.id });\n return saved;\n }\n\n async resolveFlags(\n postId: string,\n resolution: Extract<PostFlagResolution, 'dismissed'>,\n communityId: string | null,\n actor: Actor,\n ): Promise<void> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId, communityId);\n this.requireModerator(actor, post, 'resolve flags');\n await this.repo.resolveFlags(orgId, postId, {\n resolvedAt: new Date(),\n resolvedBy: actor.id,\n resolution,\n });\n this.logger.info('post flags resolved', { orgId, postId, resolution, actorId: actor.id });\n }\n\n async spaceFeed(\n communityId: string,\n spaceId: string,\n query: FeedQuery,\n actor: Actor,\n ): Promise<Page<PostView>> {\n const orgId = actor.orgId;\n const space = await this.requireOpen(actor, spaceId, communityId);\n if (query.topicId && !space.topics.some((topic) => topic.id === query.topicId)) {\n throw new NotFoundError('Topic', query.topicId);\n }\n const page = await this.feedPage(actor, [spaceId], query);\n this.logger.debug('space feed read', { orgId, spaceId, rows: page.rows.length });\n return page;\n }\n\n async memberFeed(\n communityId: string,\n query: Pick<FeedQuery, 'page' | 'pageSize'>,\n actor: Actor,\n ): Promise<Page<PostView>> {\n const orgId = actor.orgId;\n const spaceIds = await this.openSpaceIdsIn(actor, communityId);\n const page = await this.feedPage(actor, spaceIds, query);\n this.logger.debug('member feed read', {\n orgId,\n communityId,\n spaces: spaceIds.length,\n rows: page.rows.length,\n });\n return page;\n }\n\n private async openSpaceIdsIn(actor: Actor, communityId: string): Promise<string[]> {\n if (!(await this.access.isCommunityMember(communityId, actor))) {\n throw new NotFoundError('Community', communityId);\n }\n return this.access.openSpaceIds(communityId, actor);\n }\n\n async listOwn(communityId: string, query: PageQuery, actor: Actor): Promise<Page<PostView>> {\n const orgId = actor.orgId;\n const spaceIds = await this.openSpaceIdsIn(actor, communityId);\n const page = await this.repo.listByAuthor(orgId, actor.id, spaceIds, query);\n this.logger.debug('own posts read', { orgId, communityId, rows: page.rows.length });\n return { ...page, rows: await this.viewsOf(actor, page.rows) };\n }\n\n async listBookmarked(\n communityId: string,\n query: PageQuery,\n actor: Actor,\n ): Promise<Page<PostView>> {\n const orgId = actor.orgId;\n const spaceIds = await this.openSpaceIdsIn(actor, communityId);\n const page = await this.repo.listBookmarked(orgId, actor.id, spaceIds, {\n ...query,\n visibleStatuses: this.visibleStatuses(actor, communityId),\n });\n this.logger.debug('bookmarked posts read', { orgId, communityId, rows: page.rows.length });\n return { ...page, rows: await this.viewsOf(actor, page.rows) };\n }\n\n async getPost(postId: string, actor: Actor): Promise<PostView> {\n const { post } = await this.loadVisible(actor, postId);\n this.logger.debug('post read', { orgId: actor.orgId, postId });\n return this.viewOf(actor, post);\n }\n\n async moderationQueue(\n communityId: string,\n spaceId: string,\n actor: Actor,\n ): Promise<SpaceModerationQueue> {\n const orgId = actor.orgId;\n const space = await this.requireOpen(actor, spaceId, communityId);\n if (!actor.permissions.has('communities:moderate', space.communityId)) {\n this.logger.warn('space queue refused — not a moderator', {\n orgId,\n communityId,\n spaceId,\n actorId: actor.id,\n });\n throw new ForbiddenError('You need communities:moderate');\n }\n const [pending, flags, openCommentFlags] = await Promise.all([\n this.repo.listPending(orgId, spaceId, MODERATION_QUEUE_LIMIT),\n this.repo.listOpenFlags(orgId, spaceId, MODERATION_QUEUE_LIMIT),\n this.comments.listOpenFlagsForSpace(orgId, spaceId, MODERATION_QUEUE_LIMIT),\n ]);\n this.logger.debug('space queue read', {\n orgId,\n spaceId,\n pending: pending.length,\n flags: flags.length,\n commentFlags: openCommentFlags.length,\n });\n return {\n pending: await this.viewsOf(actor, pending),\n flags,\n commentFlags: await this.flaggedCommentViews(actor, space.communityId, openCommentFlags),\n };\n }\n\n private async flaggedCommentViews(\n actor: Actor,\n communityId: string,\n flags: FlaggedComment[],\n ): Promise<FlaggedCommentView[]> {\n if (flags.length === 0) {\n return [];\n }\n const orgId = actor.orgId;\n const authorIds = [...new Set(flags.map((flag) => flag.comment.orgUserId))];\n const [records, permissions] = await Promise.all([\n this.profiles.authorsOf(orgId, authorIds),\n this.authors.permissionsOfMany(orgId, authorIds),\n ]);\n return flags.map((flag) => {\n const record = records[flag.comment.orgUserId];\n if (!record) {\n throw new NotFoundError('Member', flag.comment.orgUserId);\n }\n return {\n ...flag,\n comment: {\n ...flag.comment,\n author: authorView(\n orgId,\n record,\n this.fileUrls,\n teamBadge(permissions.get(flag.comment.orgUserId), communityId),\n ),\n },\n };\n });\n }\n\n visible(postId: string, actor: Actor): Promise<{ post: Post; space: SpaceDetail }> {\n return this.loadVisible(actor, postId);\n }\n\n find(orgId: string, postId: string): Promise<Post | null> {\n return this.repo.find(orgId, postId);\n }\n\n private async submittable(post: Post, space: SpaceDetail, author: Actor): Promise<boolean> {\n if (!this.topicFits(space, post.topicId)) {\n return false;\n }\n return this.access.canOpen(space, author);\n }\n\n private async feedPage(\n actor: Actor,\n spaceIds: string[],\n query: FeedQuery,\n ): Promise<Page<PostView>> {\n const page = await this.repo.listPublished(actor.orgId, spaceIds, query);\n return { ...page, rows: await this.viewsOf(actor, page.rows) };\n }\n\n private async viewOf(actor: Actor, post: Post): Promise<PostView> {\n const [view] = await this.viewsOf(actor, [post]);\n return view!;\n }\n\n private async viewsOf(actor: Actor, posts: Post[]): Promise<PostView[]> {\n if (posts.length === 0) {\n return [];\n }\n const orgId = actor.orgId;\n const postIds = posts.map((post) => post.id);\n const authorIds = [...new Set(posts.map((post) => post.orgUserId))];\n const now = new Date();\n const bodyAssets = new Map(\n posts.map((post) => [post.id, this.bodies.parse(post.body).assetIds]),\n );\n const [\n records,\n permissions,\n reactions,\n commentCounts,\n subscribed,\n bookmarked,\n mentioned,\n uploads,\n ] = await Promise.all([\n this.profiles.authorsOf(orgId, authorIds),\n this.authors.permissionsOfMany(orgId, authorIds),\n this.repo.reactionsOf(orgId, postIds, actor.id),\n this.comments.publishedCommentCounts(orgId, postIds),\n this.subscriptions.forViewer(orgId, actor.id, 'post', postIds),\n this.repo.bookmarkedAmong(orgId, postIds, actor.id),\n mentionViews(this.mentions, this.profiles, orgId, 'post', postIds),\n this.images.memberUploads(orgId, [...new Set([...bodyAssets.values()].flat())]),\n ]);\n const uploadOf = new Map(uploads.map((upload) => [upload.id, upload]));\n const links = await this.images.fileLinks(orgId, [\n ...posts.flatMap((post) =>\n post.coverAssetId && post.status !== 'published' ? [{ assetId: post.coverAssetId }] : [],\n ),\n ...uploads.map((upload) =>\n INLINE_TYPES.test(upload.contentType)\n ? { assetId: upload.id }\n : { assetId: upload.id, saveAs: upload.filename },\n ),\n ]);\n const subscriptionOf = new Map(subscribed.map((row) => [row.itemId, row]));\n const saved = new Set(bookmarked);\n return posts.map((post) => {\n const record = records[post.orgUserId];\n if (!record) {\n throw new NotFoundError('Member', post.orgUserId);\n }\n const counts = reactions[post.id];\n return {\n ...post,\n coverUrl: !post.coverAssetId\n ? null\n : post.status === 'published'\n ? this.fileUrls.publicImage(orgId, post.id, post.coverAssetId)\n : (links[post.coverAssetId] ?? null),\n assets: Object.fromEntries(\n (bodyAssets.get(post.id) ?? []).flatMap((assetId) => {\n const upload = uploadOf.get(assetId);\n const url = links[assetId];\n return upload && url\n ? [\n [\n assetId,\n {\n url,\n kind: upload.kind,\n filename: upload.filename,\n size: upload.size,\n },\n ],\n ]\n : [];\n }),\n ),\n author: authorView(\n orgId,\n record,\n this.fileUrls,\n teamBadge(permissions.get(post.orgUserId), post.communityId),\n ),\n reactions: counts?.reactions ?? {},\n viewerReaction: counts?.viewerReaction ?? null,\n commentCount: commentCounts[post.id] ?? 0,\n subscription: activeSubscription(subscriptionOf.get(post.id), now),\n bookmarked: saved.has(post.id),\n mentions: mentioned[post.id] ?? [],\n };\n });\n }\n\n private async commitSubmission(\n orgId: string,\n post: Post,\n space: SpaceDetail,\n skips: boolean,\n actor: Actor,\n now: Date,\n ): Promise<Post> {\n const mentioned = await this.mentionedOpeners(orgId, post);\n return this.uow.run(async ({ posts, outbox }) => {\n const next = await posts.updateIf(\n orgId,\n post.id,\n { status: post.status },\n this.submissionOf(space.settings.requireReview, skips, now),\n );\n if (!next) {\n throw new ConflictError('This post cannot be submitted');\n }\n await outbox.append([this.landed(orgId, next, this.meta(actor, post.status), mentioned)]);\n return next;\n });\n }\n\n private async moderate(\n postId: string,\n actor: Actor,\n patch: PostPatch,\n unchanged: (post: Post) => boolean,\n log: string,\n ): Promise<PostView> {\n const orgId = actor.orgId;\n const { post } = await this.loadVisible(actor, postId);\n this.requireModerator(actor, post, log);\n if (post.status === 'removed') {\n throw new ConflictError('This post was removed');\n }\n if (unchanged(post)) {\n return this.viewOf(actor, post);\n }\n const updated = await this.uow.run(async ({ posts, outbox }) => {\n const next = await this.mustUpdate(posts, orgId, postId, patch);\n await outbox.append([\n this.updated(\n orgId,\n next,\n this.meta(actor, next.status === 'pending' ? post.status : undefined),\n ),\n ]);\n return next;\n });\n this.logger.info(log, { orgId, postId, actorId: actor.id });\n return this.viewOf(actor, updated);\n }\n\n private async mustUpdate(\n posts: PostRepository,\n orgId: string,\n postId: string,\n patch: PostPatch,\n ): Promise<Post> {\n const next = await posts.update(orgId, postId, patch);\n if (!next) {\n throw new NotFoundError('Post', postId);\n }\n return next;\n }\n\n private initial(input: CreatePostInput, space: SpaceDetail, actor: Actor, now: Date) {\n if (input.mode === 'draft') {\n return { status: 'draft' as const, scheduledAt: null, publishedAt: null, removedBy: null };\n }\n if (input.mode === 'schedule') {\n if (!input.scheduledAt) {\n throw new InvalidInputError('A scheduled post needs a time');\n }\n if (input.scheduledAt <= now) {\n throw new InvalidInputError('A scheduled time must be in the future');\n }\n return {\n status: 'scheduled' as const,\n scheduledAt: input.scheduledAt,\n publishedAt: null,\n removedBy: null,\n };\n }\n return this.submissionOf(\n space.settings.requireReview,\n skipsReview(actor.permissions, { communityId: space.communityId }),\n now,\n );\n }\n\n private submissionOf(requireReview: boolean, skips: boolean, now: Date) {\n if (requireReview && !skips) {\n return { status: 'pending' as const, scheduledAt: null, publishedAt: null, removedBy: null };\n }\n return { status: 'published' as const, scheduledAt: null, publishedAt: now, removedBy: null };\n }\n\n private async requireOwnedImage(\n orgId: string,\n orgUserId: string,\n assetId: string | null,\n ): Promise<void> {\n if (assetId === null) {\n return;\n }\n if (!(await this.images.ownsImage(orgId, assetId, orgUserId))) {\n this.logger.debug('cover refused', { orgId, orgUserId, assetId });\n throw new NotFoundError('Asset', assetId);\n }\n }\n\n private async requireBodyAssets(\n orgId: string,\n orgUserId: string,\n assetIds: string[],\n ): Promise<void> {\n if (assetIds.length > MAX_BODY_ASSETS) {\n throw new InvalidInputError(`A post shows at most ${MAX_BODY_ASSETS} files`);\n }\n for (const assetId of assetIds) {\n if (!(await this.images.ownsUpload(orgId, assetId, orgUserId))) {\n this.logger.debug('body file refused', { orgId, orgUserId, assetId });\n throw new NotFoundError('Asset', assetId);\n }\n }\n }\n\n private async openSpace(\n actor: Actor,\n spaceId: string,\n communityId?: string | null,\n ): Promise<SpaceDetail | null> {\n const space = await this.content.getSpace(spaceId, this.authors.systemActor(actor.orgId));\n if (!space || (communityId != null && space.communityId !== communityId)) {\n return null;\n }\n return (await this.access.canOpen(space, actor)) ? space : null;\n }\n\n private async requireOpen(\n actor: Actor,\n spaceId: string,\n communityId?: string,\n ): Promise<SpaceDetail> {\n const space = await this.openSpace(actor, spaceId, communityId);\n if (!space) {\n throw new NotFoundError('Space', spaceId);\n }\n return space;\n }\n\n private async loadVisible(actor: Actor, postId: string, communityId?: string | null) {\n const post = await this.repo.find(actor.orgId, postId);\n if (!post || (communityId != null && post.communityId !== communityId)) {\n throw new NotFoundError('Post', postId);\n }\n const space = await this.openSpace(actor, post.spaceId);\n if (!space || !this.canSee(actor, post)) {\n throw new NotFoundError('Post', postId);\n }\n return { post, space };\n }\n\n private canSee(actor: Actor, post: Post): boolean {\n return (\n post.orgUserId === actor.id ||\n this.visibleStatuses(actor, post.communityId).includes(post.status)\n );\n }\n\n private visibleStatuses(actor: Actor, communityId: string): PostStatus[] {\n return this.moderates(actor.permissions, communityId) ? MODERATOR_VISIBLE : PUBLISHED_ONLY;\n }\n\n private moderates(permissions: EffectivePermissions, communityId: string): boolean {\n return permissions.has('communities:moderate', communityId);\n }\n\n private requireModerator(actor: Actor, post: Post, action: string): void {\n if (!this.moderates(actor.permissions, post.communityId)) {\n this.logger.warn('post moderation refused — not a moderator', {\n orgId: actor.orgId,\n postId: post.id,\n communityId: post.communityId,\n action,\n actorId: actor.id,\n });\n throw new ForbiddenError('You need communities:moderate');\n }\n }\n\n private assertAuthor(actor: Actor, post: Post): void {\n if (post.orgUserId !== actor.id) {\n throw new ForbiddenError('You can change only your own post');\n }\n }\n\n private topicFits(space: SpaceDetail, topicId: string | null): boolean {\n return topicId === null || space.topics.some((topic) => topic.id === topicId);\n }\n\n private assertTopic(space: SpaceDetail, topicId: string | null): void {\n if (topicId !== null && !this.topicFits(space, topicId)) {\n throw new NotFoundError('Topic', topicId);\n }\n }\n\n private patchChanges(post: Post, patch: UpdatePostInput): boolean {\n return (Object.keys(patch) as (keyof UpdatePostInput)[]).some((key) => {\n const value = patch[key];\n if (value === undefined) {\n return false;\n }\n if (key === 'extra') {\n return JSON.stringify(post.extra) !== JSON.stringify(value);\n }\n return post[key] !== value;\n });\n }\n\n private async mentionable(\n orgId: string,\n spaceId: string,\n title: string,\n body: string[],\n ): Promise<string[]> {\n return this.openersOf(orgId, spaceId, [...new Set([...mentionTokens(title), ...body])]);\n }\n\n private async openersOf(orgId: string, spaceId: string, orgUserIds: string[]): Promise<string[]> {\n if (orgUserIds.length === 0) {\n return [];\n }\n return keepAllowed(orgUserIds, await this.access.spaceOpenersAmong(orgId, spaceId, orgUserIds));\n }\n\n private async mentionedOpeners(orgId: string, post: Post): Promise<string[]> {\n return this.openersOf(orgId, post.spaceId, await this.mentions.ofItem(orgId, 'post', post.id));\n }\n\n private landed(\n orgId: string,\n post: Post,\n metadata: EventMeta,\n mentioned: string[],\n ): NewDiscussionEvent {\n if (post.status !== 'published') {\n return this.updated(orgId, post, metadata);\n }\n return this.published(orgId, post, metadata, mentioned);\n }\n\n private published(\n orgId: string,\n post: Post,\n metadata: EventMeta,\n mentionedOrgUserIds: string[],\n ): NewDiscussionEvent {\n return discussionEvents.postPublished.make({\n orgId,\n data: { ...post, mentionedOrgUserIds },\n metadata,\n });\n }\n\n private updated(\n orgId: string,\n post: Post,\n metadata: EventMeta,\n mentionedOrgUserIds: string[] = [],\n ): NewDiscussionEvent {\n return discussionEvents.postUpdated.make({\n orgId,\n data: { ...post, mentionedOrgUserIds },\n metadata,\n });\n }\n\n private meta(actor: Actor | null, previousStatus?: PostStatus | null): EventMeta {\n return {\n ...(actor ? { actorId: actor.id } : {}),\n ...(previousStatus !== undefined ? { previousStatus } : {}),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AA8EA,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,iBAA+B,CAAC,WAAW;AACjD,MAAM,oBAAkC;CAAC;CAAa;CAAW;AAAS;AAC1E,MAAM,QAAQ;CACZ,QAAQ;CACR,aAAa;CACb,aAAa;CACb,WAAW;AACb;AAEA,IAAa,kBAAb,MAAoD;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA;CAEA,YAAY,QAA2B;EACrC,KAAK,OAAO,OAAO;EACnB,KAAK,SAAS,OAAO;EACrB,KAAK,UAAU,OAAO;EACtB,KAAK,UAAU,OAAO;EACtB,KAAK,WAAW,OAAO;EACvB,KAAK,WAAW,OAAO;EACvB,KAAK,gBAAgB,OAAO;EAC5B,KAAK,WAAW,OAAO;EACvB,KAAK,SAAS,OAAO;EACrB,KAAK,WAAW,OAAO;EACvB,KAAK,SAAS,OAAO;EACrB,KAAK,MAAM,OAAO;EAClB,KAAK,YAAY,OAAO;EACxB,KAAK,SAAS,OAAO,UAAU;CACjC;CAEA,MAAM,cAAc,SAAmB,OAA+C;EACpF,MAAM,QAAQ,MAAM;EACpB,MAAM,QAAQ,MAAM,KAAK,KAAK,SAAS,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,CAAC;EACnE,MAAM,eAAe,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,SAAS,K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AAiB,YAAyC;EAC/F,IAAI,WAAW,WAAW,GACxB,OAAO,CAAC;EAEV,OAAO,YAAY,YAAY,MAAM,KAAK,OAAO,kBAAkB,OAAO,SAAS,UAAU,CAAC;CAChG;CAEA,MAAc,iBAAiB,OAAe,MAA+B;EAC3E,OAAO,KAAK,UAAU,OAAO,KAAK,SAAS,MAAM,KAAK,SAAS,OAAO,OAAO,QAAQ,KAAK,EAAE,CAAC;CAC/F;CAEA,OACE,OACA,MACA,UACA,WACoB;EACpB,IAAI,KAAK,WAAW,aAClB,OAAO,KAAK,QAAQ,OAAO,MAAM,QAAQ;EAE3C,OAAO,KAAK,UAAU,OAAO,MAAM,UAAU,SAAS;CACxD;CAEA,UACE,OACA,MACA,UACA,qBACoB;EACpB,OAAO,iBAAiB,cAAc,KAAK;GACzC;GACA,MAAM;IAAE,GAAG;IAAM;GAAoB;GACrC;EACF,CAAC;CACH;CAEA,QACE,OACA,MACA,UACA,sBAAgC,CAAC,GACb;EACpB,OAAO,iBAAiB,YAAY,KAAK;GACvC;GACA,MAAM;IAAE,GAAG;IAAM;GAAoB;GACrC;EACF,CAAC;CACH;CAEA,KAAa,OAAqB,gBAA+C;EAC/E,OAAO;GACL,GAAI,QAAQ,EAAE,SAAS,MAAM,GAAG,IAAI,CAAC;GACrC,GAAI,mBAAmB,KAAA,IAAY,EAAE,eAAe,IAAI,CAAC;EAC3D;CACF;AACF"}
@@ -8,7 +8,7 @@ declare const entitlementEvents: {
8
8
  orgUserId: string;
9
9
  bundleId: string | null;
10
10
  contentId: string | null;
11
- status: "revoked" | "active";
11
+ status: "active" | "revoked";
12
12
  source: string;
13
13
  grantedAt: Date;
14
14
  expiresAt: Date | null;
@@ -20,7 +20,7 @@ declare const entitlementEvents: {
20
20
  orgUserId: string;
21
21
  bundleId: string | null;
22
22
  contentId: string | null;
23
- status: "revoked" | "active";
23
+ status: "active" | "revoked";
24
24
  source: string;
25
25
  grantedAt: unknown;
26
26
  expiresAt: unknown;
@@ -31,8 +31,8 @@ declare const entitlementEvents: {
31
31
  id: import("zod").ZodString;
32
32
  source: import("zod").ZodString;
33
33
  status: import("zod").ZodEnum<{
34
- revoked: "revoked";
35
34
  active: "active";
35
+ revoked: "revoked";
36
36
  }>;
37
37
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
38
38
  createdAt: import("zod").ZodCoercedDate<unknown>;
@@ -48,7 +48,7 @@ declare const entitlementEvents: {
48
48
  orgUserId: string;
49
49
  bundleId: string | null;
50
50
  contentId: string | null;
51
- status: "revoked" | "active";
51
+ status: "active" | "revoked";
52
52
  source: string;
53
53
  grantedAt: Date;
54
54
  expiresAt: Date | null;
@@ -60,7 +60,7 @@ declare const entitlementEvents: {
60
60
  orgUserId: string;
61
61
  bundleId: string | null;
62
62
  contentId: string | null;
63
- status: "revoked" | "active";
63
+ status: "active" | "revoked";
64
64
  source: string;
65
65
  grantedAt: unknown;
66
66
  expiresAt: unknown;
@@ -71,8 +71,8 @@ declare const entitlementEvents: {
71
71
  id: import("zod").ZodString;
72
72
  source: import("zod").ZodString;
73
73
  status: import("zod").ZodEnum<{
74
- revoked: "revoked";
75
74
  active: "active";
75
+ revoked: "revoked";
76
76
  }>;
77
77
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
78
78
  createdAt: import("zod").ZodCoercedDate<unknown>;
@@ -88,7 +88,7 @@ declare const entitlementEvents: {
88
88
  orgUserId: string;
89
89
  bundleId: string | null;
90
90
  contentId: string | null;
91
- status: "revoked" | "active";
91
+ status: "active" | "revoked";
92
92
  source: string;
93
93
  grantedAt: Date;
94
94
  expiresAt: Date | null;
@@ -100,7 +100,7 @@ declare const entitlementEvents: {
100
100
  orgUserId: string;
101
101
  bundleId: string | null;
102
102
  contentId: string | null;
103
- status: "revoked" | "active";
103
+ status: "active" | "revoked";
104
104
  source: string;
105
105
  grantedAt: unknown;
106
106
  expiresAt: unknown;
@@ -111,8 +111,8 @@ declare const entitlementEvents: {
111
111
  id: import("zod").ZodString;
112
112
  source: import("zod").ZodString;
113
113
  status: import("zod").ZodEnum<{
114
- revoked: "revoked";
115
114
  active: "active";
115
+ revoked: "revoked";
116
116
  }>;
117
117
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
118
118
  createdAt: import("zod").ZodCoercedDate<unknown>;
@@ -128,7 +128,7 @@ declare const entitlementEvents: {
128
128
  orgUserId: string;
129
129
  bundleId: string | null;
130
130
  contentId: string | null;
131
- status: "revoked" | "active";
131
+ status: "active" | "revoked";
132
132
  source: string;
133
133
  grantedAt: Date;
134
134
  expiresAt: Date | null;
@@ -140,7 +140,7 @@ declare const entitlementEvents: {
140
140
  orgUserId: string;
141
141
  bundleId: string | null;
142
142
  contentId: string | null;
143
- status: "revoked" | "active";
143
+ status: "active" | "revoked";
144
144
  source: string;
145
145
  grantedAt: unknown;
146
146
  expiresAt: unknown;
@@ -151,8 +151,8 @@ declare const entitlementEvents: {
151
151
  id: import("zod").ZodString;
152
152
  source: import("zod").ZodString;
153
153
  status: import("zod").ZodEnum<{
154
- revoked: "revoked";
155
154
  active: "active";
155
+ revoked: "revoked";
156
156
  }>;
157
157
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
158
158
  createdAt: import("zod").ZodCoercedDate<unknown>;
@@ -168,7 +168,7 @@ declare const entitlementEvents: {
168
168
  orgUserId: string;
169
169
  bundleId: string | null;
170
170
  contentId: string | null;
171
- status: "revoked" | "active";
171
+ status: "active" | "revoked";
172
172
  source: string;
173
173
  grantedAt: Date;
174
174
  expiresAt: Date | null;
@@ -181,7 +181,7 @@ declare const entitlementEvents: {
181
181
  orgUserId: string;
182
182
  bundleId: string | null;
183
183
  contentId: string | null;
184
- status: "revoked" | "active";
184
+ status: "active" | "revoked";
185
185
  source: string;
186
186
  grantedAt: unknown;
187
187
  expiresAt: unknown;
@@ -193,8 +193,8 @@ declare const entitlementEvents: {
193
193
  id: import("zod").ZodString;
194
194
  source: import("zod").ZodString;
195
195
  status: import("zod").ZodEnum<{
196
- revoked: "revoked";
197
196
  active: "active";
197
+ revoked: "revoked";
198
198
  }>;
199
199
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
200
200
  createdAt: import("zod").ZodCoercedDate<unknown>;
@@ -211,8 +211,8 @@ declare const entitlementEvents: {
211
211
  communityId: string;
212
212
  spaceId: string;
213
213
  orgUserId: string;
214
- status: "revoked" | "active" | "requested" | "invited";
215
- source: "manual" | "request" | "invite";
214
+ status: "active" | "revoked" | "requested" | "invited";
215
+ source: "request" | "invite" | "manual";
216
216
  createdAt: Date;
217
217
  updatedAt: Date;
218
218
  }, "entitlement.space_member.created", 1>, {
@@ -221,8 +221,8 @@ declare const entitlementEvents: {
221
221
  communityId: string;
222
222
  spaceId: string;
223
223
  orgUserId: string;
224
- status: "revoked" | "active" | "requested" | "invited";
225
- source: "manual" | "request" | "invite";
224
+ status: "active" | "revoked" | "requested" | "invited";
225
+ source: "request" | "invite" | "manual";
226
226
  createdAt: unknown;
227
227
  updatedAt: unknown;
228
228
  }, import("zod").ZodObject<{
@@ -232,15 +232,15 @@ declare const entitlementEvents: {
232
232
  spaceId: import("zod").ZodString;
233
233
  orgUserId: import("zod").ZodString;
234
234
  status: import("zod").ZodEnum<{
235
- revoked: "revoked";
236
235
  active: "active";
236
+ revoked: "revoked";
237
237
  requested: "requested";
238
238
  invited: "invited";
239
239
  }>;
240
240
  source: import("zod").ZodEnum<{
241
- manual: "manual";
242
241
  request: "request";
243
242
  invite: "invite";
243
+ manual: "manual";
244
244
  }>;
245
245
  createdAt: import("zod").ZodCoercedDate<unknown>;
246
246
  updatedAt: import("zod").ZodCoercedDate<unknown>;
@@ -251,8 +251,8 @@ declare const entitlementEvents: {
251
251
  communityId: string;
252
252
  spaceId: string;
253
253
  orgUserId: string;
254
- status: "revoked" | "active" | "requested" | "invited";
255
- source: "manual" | "request" | "invite";
254
+ status: "active" | "revoked" | "requested" | "invited";
255
+ source: "request" | "invite" | "manual";
256
256
  createdAt: Date;
257
257
  updatedAt: Date;
258
258
  }, "entitlement.space_member.updated", 1>, {
@@ -261,8 +261,8 @@ declare const entitlementEvents: {
261
261
  communityId: string;
262
262
  spaceId: string;
263
263
  orgUserId: string;
264
- status: "revoked" | "active" | "requested" | "invited";
265
- source: "manual" | "request" | "invite";
264
+ status: "active" | "revoked" | "requested" | "invited";
265
+ source: "request" | "invite" | "manual";
266
266
  createdAt: unknown;
267
267
  updatedAt: unknown;
268
268
  }, import("zod").ZodObject<{
@@ -272,15 +272,15 @@ declare const entitlementEvents: {
272
272
  spaceId: import("zod").ZodString;
273
273
  orgUserId: import("zod").ZodString;
274
274
  status: import("zod").ZodEnum<{
275
- revoked: "revoked";
276
275
  active: "active";
276
+ revoked: "revoked";
277
277
  requested: "requested";
278
278
  invited: "invited";
279
279
  }>;
280
280
  source: import("zod").ZodEnum<{
281
- manual: "manual";
282
281
  request: "request";
283
282
  invite: "invite";
283
+ manual: "manual";
284
284
  }>;
285
285
  createdAt: import("zod").ZodCoercedDate<unknown>;
286
286
  updatedAt: import("zod").ZodCoercedDate<unknown>;
@@ -291,8 +291,8 @@ declare const entitlementEvents: {
291
291
  communityId: string;
292
292
  spaceId: string;
293
293
  orgUserId: string;
294
- status: "revoked" | "active" | "requested" | "invited";
295
- source: "manual" | "request" | "invite";
294
+ status: "active" | "revoked" | "requested" | "invited";
295
+ source: "request" | "invite" | "manual";
296
296
  createdAt: Date;
297
297
  updatedAt: Date;
298
298
  }, "entitlement.space_member.deleted", 1>, {
@@ -301,8 +301,8 @@ declare const entitlementEvents: {
301
301
  communityId: string;
302
302
  spaceId: string;
303
303
  orgUserId: string;
304
- status: "revoked" | "active" | "requested" | "invited";
305
- source: "manual" | "request" | "invite";
304
+ status: "active" | "revoked" | "requested" | "invited";
305
+ source: "request" | "invite" | "manual";
306
306
  createdAt: unknown;
307
307
  updatedAt: unknown;
308
308
  }, import("zod").ZodObject<{
@@ -312,15 +312,15 @@ declare const entitlementEvents: {
312
312
  spaceId: import("zod").ZodString;
313
313
  orgUserId: import("zod").ZodString;
314
314
  status: import("zod").ZodEnum<{
315
- revoked: "revoked";
316
315
  active: "active";
316
+ revoked: "revoked";
317
317
  requested: "requested";
318
318
  invited: "invited";
319
319
  }>;
320
320
  source: import("zod").ZodEnum<{
321
- manual: "manual";
322
321
  request: "request";
323
322
  invite: "invite";
323
+ manual: "manual";
324
324
  }>;
325
325
  createdAt: import("zod").ZodCoercedDate<unknown>;
326
326
  updatedAt: import("zod").ZodCoercedDate<unknown>;