@drodil/backstage-plugin-qeta-backend 3.54.0 → 3.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/DatabaseQetaStore.cjs.js +1 -0
- package/dist/database/DatabaseQetaStore.cjs.js.map +1 -1
- package/dist/database/stores/CollectionsStore.cjs.js +262 -23
- package/dist/database/stores/CollectionsStore.cjs.js.map +1 -1
- package/dist/database/stores/PostsStore.cjs.js +6 -0
- package/dist/database/stores/PostsStore.cjs.js.map +1 -1
- package/dist/service/routes/collections.cjs.js +6 -0
- package/dist/service/routes/collections.cjs.js.map +1 -1
- package/dist/service/types.cjs.js +4 -1
- package/dist/service/types.cjs.js.map +1 -1
- package/dist/service/util.cjs.js +74 -18
- package/dist/service/util.cjs.js.map +1 -1
- package/migrations/20260109_automatic_collections.js +59 -0
- package/package.json +6 -6
|
@@ -76,6 +76,7 @@ class DatabaseQetaStore {
|
|
|
76
76
|
const badgesStore = new BadgesStore.BadgesStore(client);
|
|
77
77
|
const helpersStore = new HelpersStore.HelpersStore(client);
|
|
78
78
|
postsStore.setAnswersStore(answersStore);
|
|
79
|
+
postsStore.setCollectionsStore(collectionsStore);
|
|
79
80
|
return new DatabaseQetaStore(
|
|
80
81
|
postsStore,
|
|
81
82
|
answersStore,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseQetaStore.cjs.js","sources":["../../src/database/DatabaseQetaStore.ts"],"sourcesContent":["import {\n DatabaseService,\n resolvePackagePath,\n} from '@backstage/backend-plugin-api';\n\nimport {\n AnswerOptions,\n Answers,\n AttachmentParameters,\n AwardBadgeResult,\n CollectionOptions,\n CollectionPostRank,\n Collections,\n CommentOptions,\n EntitiesResponse,\n EntityResponse,\n MaybeAnswer,\n MaybeCollection,\n MaybePost,\n PostOptions,\n PostReview,\n Posts,\n QetaStore,\n Templates,\n UserResponse,\n UsersResponse,\n TimelineFilters,\n} from './QetaStore';\nimport { Badge, UserBadge } from '@drodil/backstage-plugin-qeta-common';\nimport {\n AIResponse,\n AnswersQuery,\n Attachment,\n Collection,\n Comment as QetaComment,\n EntitiesQuery,\n EntityLinks,\n GlobalStat,\n Post,\n PostStatus,\n PostType,\n PostsQuery,\n Statistic,\n StatisticsRequestParameters,\n TagResponse,\n TagsQuery,\n TagsResponse,\n Template,\n UserCollectionsResponse,\n UserEntitiesResponse,\n UsersQuery,\n UserStat,\n UserTagsResponse,\n UserUsersResponse,\n TimelineOptions,\n TimelineResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { QetaFilters } from '../service/util';\nimport { PermissionCriteria } from '@backstage/plugin-permission-common';\nimport { TagDatabase } from '@drodil/backstage-plugin-qeta-node';\nimport { PostsStore } from './stores/PostsStore';\nimport { AnswersStore } from './stores/AnswersStore';\nimport { CommentsStore } from './stores/CommentsStore';\nimport { CollectionsStore } from './stores/CollectionsStore';\nimport { StatsStore } from './stores/StatsStore';\nimport { TagsStore } from './stores/TagsStore';\nimport { UsersStore } from './stores/UsersStore';\nimport { EntitiesStore } from './stores/EntitiesStore';\nimport { TemplatesStore } from './stores/TemplatesStore';\nimport { AttachmentsStore } from './stores/AttachmentsStore';\nimport { BadgesStore } from './stores/BadgesStore';\nimport { HelpersStore } from './stores/HelpersStore';\n\nconst migrationsDir = resolvePackagePath(\n '@drodil/backstage-plugin-qeta-backend',\n 'migrations',\n);\n\n// Local interfaces removed, imported from stores\n\nexport class DatabaseQetaStore implements QetaStore {\n private constructor(\n private readonly postsStore: PostsStore,\n private readonly answersStore: AnswersStore,\n private readonly commentsStore: CommentsStore,\n private readonly collectionsStore: CollectionsStore,\n private readonly statsStore: StatsStore,\n private readonly tagsStore: TagsStore,\n private readonly usersStore: UsersStore,\n private readonly entitiesStore: EntitiesStore,\n private readonly templatesStore: TemplatesStore,\n private readonly attachmentsStore: AttachmentsStore,\n private readonly badgesStore: BadgesStore,\n private readonly helpersStore: HelpersStore,\n ) {}\n\n async getTimeline(\n user_ref: string,\n options: TimelineOptions,\n filters?: TimelineFilters,\n ): Promise<TimelineResponse> {\n return this.helpersStore.getTimeline(user_ref, options, filters);\n }\n\n static async create({\n database,\n skipMigrations,\n tagDatabase,\n }: {\n database: DatabaseService;\n skipMigrations?: boolean;\n tagDatabase?: TagDatabase;\n }): Promise<DatabaseQetaStore> {\n const client = await database.getClient();\n\n if (!database.migrations?.skip && !skipMigrations) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n const commentsStore = new CommentsStore(client);\n const tagsStore = new TagsStore(client, tagDatabase);\n const entitiesStore = new EntitiesStore(client);\n const usersStore = new UsersStore(client);\n const templatesStore = new TemplatesStore(client, tagsStore, entitiesStore);\n const attachmentsStore = new AttachmentsStore(client);\n const postsStore = new PostsStore(\n client,\n commentsStore,\n tagsStore,\n entitiesStore,\n attachmentsStore,\n tagDatabase,\n );\n const answersStore = new AnswersStore(\n client,\n commentsStore,\n postsStore,\n attachmentsStore,\n );\n const collectionsStore = new CollectionsStore(\n client,\n postsStore,\n attachmentsStore,\n );\n const statsStore = new StatsStore(client);\n const badgesStore = new BadgesStore(client);\n const helpersStore = new HelpersStore(client);\n\n postsStore.setAnswersStore(answersStore);\n\n return new DatabaseQetaStore(\n postsStore,\n answersStore,\n commentsStore,\n collectionsStore,\n statsStore,\n tagsStore,\n usersStore,\n entitiesStore,\n templatesStore,\n attachmentsStore,\n badgesStore,\n helpersStore,\n );\n }\n\n async getPosts(\n user_ref: string,\n options: PostsQuery,\n filters?: PermissionCriteria<QetaFilters>,\n opts?: PostOptions,\n ): Promise<Posts> {\n return this.postsStore.getPosts(user_ref, options, filters, opts);\n }\n\n async getPost(\n user_ref: string,\n id: number,\n recordView?: boolean,\n options?: PostOptions,\n ): Promise<MaybePost> {\n return this.postsStore.getPost(user_ref, id, recordView, options);\n }\n\n async getPostByAnswerId(\n user_ref: string,\n answerId: number,\n recordView?: boolean,\n options?: PostOptions,\n ): Promise<MaybePost> {\n return this.postsStore.getPostByAnswerId(\n user_ref,\n answerId,\n recordView,\n options,\n );\n }\n\n async createPost(options: {\n user_ref: string;\n title: string;\n content: string;\n created: Date;\n author?: string;\n tags?: string[];\n entities?: string[];\n images?: number[];\n anonymous?: boolean;\n type?: PostType;\n headerImage?: string;\n url?: string;\n status?: PostStatus;\n opts?: PostOptions;\n }): Promise<Post> {\n return this.postsStore.createPost(options);\n }\n\n async updatePost(options: {\n user_ref: string;\n id: number;\n title?: string;\n content?: string;\n author?: string;\n tags?: string[];\n entities?: string[];\n images?: number[];\n headerImage?: string;\n url?: string;\n status?: PostStatus;\n opts?: PostOptions;\n }): Promise<MaybePost> {\n return this.postsStore.updatePost(options);\n }\n\n async deletePost(id: number, permanently?: boolean): Promise<boolean> {\n return this.postsStore.deletePost(id, permanently);\n }\n\n async votePost(\n user_ref: string,\n postId: number,\n score: number,\n ): Promise<boolean> {\n return this.postsStore.votePost(user_ref, postId, score);\n }\n\n async deletePostVote(user_ref: string, postId: number): Promise<boolean> {\n return this.postsStore.deletePostVote(user_ref, postId);\n }\n\n async favoritePost(user_ref: string, postId: number): Promise<boolean> {\n return this.postsStore.favoritePost(user_ref, postId);\n }\n\n async unfavoritePost(user_ref: string, postId: number): Promise<boolean> {\n return this.postsStore.unfavoritePost(user_ref, postId);\n }\n\n async getUsersWhoFavoritedPost(postId: number): Promise<string[]> {\n return this.postsStore.getUsersWhoFavoritedPost(postId);\n }\n\n async getAnswers(\n user_ref: string,\n options: AnswersQuery,\n filters?: PermissionCriteria<QetaFilters>,\n opts?: AnswerOptions,\n ): Promise<Answers> {\n return this.answersStore.getAnswers(user_ref, options, filters, opts);\n }\n\n async getAnswer(\n answerId: number,\n user_ref: string,\n options?: AnswerOptions,\n ): Promise<MaybeAnswer> {\n return this.answersStore.getAnswer(answerId, user_ref, options);\n }\n\n async answerPost(\n user_ref: string,\n questionId: number,\n answer: string,\n created: Date,\n images?: number[],\n anonymous?: boolean,\n options?: AnswerOptions,\n ): Promise<MaybeAnswer> {\n return this.answersStore.answerPost(\n user_ref,\n questionId,\n answer,\n created,\n images,\n anonymous,\n options,\n );\n }\n\n async updateAnswer(\n user_ref: string,\n questionId: number,\n answerId: number,\n answer: string,\n author?: string,\n images?: number[],\n options?: AnswerOptions,\n ): Promise<MaybeAnswer> {\n return this.answersStore.updateAnswer(\n user_ref,\n questionId,\n answerId,\n answer,\n author,\n images,\n options,\n );\n }\n\n async deleteAnswer(id: number): Promise<boolean> {\n return this.answersStore.deleteAnswer(id);\n }\n\n async voteAnswer(\n user_ref: string,\n answerId: number,\n score: number,\n ): Promise<boolean> {\n return this.answersStore.voteAnswer(user_ref, answerId, score);\n }\n\n async deleteAnswerVote(user_ref: string, answerId: number): Promise<boolean> {\n return this.answersStore.deleteAnswerVote(user_ref, answerId);\n }\n\n async markAnswerCorrect(postId: number, answerId: number): Promise<boolean> {\n return this.answersStore.markAnswerCorrect(postId, answerId);\n }\n\n async markAnswerIncorrect(\n postId: number,\n answerId: number,\n ): Promise<boolean> {\n return this.answersStore.markAnswerIncorrect(postId, answerId);\n }\n\n async clickPost(user_ref: string, postId: number): Promise<void> {\n const vote = await this.postsStore.getPostVote(user_ref, postId);\n const score = (vote?.score || 0) + 1;\n await this.postsStore.votePost(user_ref, postId, score);\n }\n\n async commentPost(\n post_id: number,\n user_ref: string,\n content: string,\n created: Date,\n ): Promise<MaybePost> {\n await this.commentsStore.commentPost(post_id, user_ref, content, created);\n return this.getPost(user_ref, post_id);\n }\n\n async commentAnswer(\n answer_id: number,\n user_ref: string,\n content: string,\n created: Date,\n ): Promise<MaybeAnswer> {\n await this.commentsStore.commentAnswer(\n answer_id,\n user_ref,\n content,\n created,\n );\n return this.getAnswer(answer_id, user_ref);\n }\n\n async updatePostComment(\n post_id: number,\n id: number,\n user_ref: string,\n content: string,\n ): Promise<MaybePost> {\n await this.commentsStore.updatePostComment(post_id, id, user_ref, content);\n return this.getPost(user_ref, post_id);\n }\n\n async updateAnswerComment(\n answer_id: number,\n id: number,\n user_ref: string,\n content: string,\n ): Promise<MaybeAnswer> {\n await this.commentsStore.updateAnswerComment(\n answer_id,\n id,\n user_ref,\n content,\n );\n return this.getAnswer(answer_id, user_ref);\n }\n\n async deletePostComment(\n post_id: number,\n id: number,\n user_ref: string,\n ): Promise<MaybePost> {\n await this.commentsStore.deletePostComment(post_id, id);\n return this.getPost(user_ref, post_id);\n }\n\n async deleteAnswerComment(\n answer_id: number,\n id: number,\n user_ref: string,\n ): Promise<MaybeAnswer> {\n await this.commentsStore.deleteAnswerComment(answer_id, id);\n return this.getAnswer(answer_id, user_ref);\n }\n\n async getCollections(\n user_ref: string,\n options: PostsQuery,\n opts?: CollectionOptions,\n ): Promise<Collections> {\n return this.collectionsStore.getCollections(user_ref, options, opts);\n }\n\n async getCollection(\n user_ref: string,\n id: number,\n options?: CollectionOptions,\n ): Promise<MaybeCollection> {\n return this.collectionsStore.getCollection(user_ref, id, options);\n }\n\n async createCollection(options: {\n user_ref: string;\n title: string;\n description?: string;\n created: Date;\n images?: number[];\n headerImage?: string;\n opts?: CollectionOptions;\n }): Promise<Collection> {\n return this.collectionsStore.createCollection(\n options,\n ) as Promise<Collection>;\n }\n\n async updateCollection(options: {\n id: number;\n user_ref: string;\n title: string;\n description?: string;\n images?: number[];\n headerImage?: string;\n opts?: CollectionOptions;\n }): Promise<MaybeCollection> {\n return this.collectionsStore.updateCollection(options);\n }\n\n async deleteCollection(id: number): Promise<boolean> {\n return this.collectionsStore.deleteCollection(id);\n }\n\n async addPostToCollection(\n user_ref: string,\n id: number,\n postId: number,\n options?: CollectionOptions,\n ): Promise<MaybeCollection> {\n return this.collectionsStore.addPostToCollection(\n user_ref,\n id,\n postId,\n options,\n );\n }\n\n async removePostFromCollection(\n user_ref: string,\n id: number,\n postId: number,\n options?: CollectionOptions,\n ): Promise<MaybeCollection> {\n return this.collectionsStore.removePostFromCollection(\n user_ref,\n id,\n postId,\n options,\n );\n }\n\n async getUsersForCollection(collectionId: number): Promise<string[]> {\n return this.collectionsStore.getUsersForCollection(collectionId);\n }\n\n async followCollection(\n user_ref: string,\n collectionId: number,\n ): Promise<boolean> {\n return this.collectionsStore.followCollection(user_ref, collectionId);\n }\n\n async unfollowCollection(\n user_ref: string,\n collectionId: number,\n ): Promise<boolean> {\n return this.collectionsStore.unfollowCollection(user_ref, collectionId);\n }\n\n async getUserCollections(\n user_ref: string,\n options?: CollectionOptions,\n ): Promise<UserCollectionsResponse> {\n return this.collectionsStore.getUserCollections(user_ref, options);\n }\n\n async getPostRank(\n collectionId: number,\n postId: number,\n ): Promise<number | null> {\n return this.collectionsStore.getPostRank(collectionId, postId);\n }\n\n async getTopRankedPostId(\n collectionId: number,\n ): Promise<CollectionPostRank | null> {\n return this.collectionsStore.getTopRankedPostId(collectionId);\n }\n\n async getBottomRankedPostId(\n collectionId: number,\n ): Promise<CollectionPostRank | null> {\n return this.collectionsStore.getBottomRankedPostId(collectionId);\n }\n\n async getNextRankedPostId(\n collectionId: number,\n postId: number,\n ): Promise<CollectionPostRank | null> {\n return this.collectionsStore.getNextRankedPostId(collectionId, postId);\n }\n\n async getPreviousRankedPostId(\n collectionId: number,\n postId: number,\n ): Promise<CollectionPostRank | null> {\n return this.collectionsStore.getPreviousRankedPostId(collectionId, postId);\n }\n\n async updatePostRank(\n collectionId: number,\n postId: number,\n rank: number,\n ): Promise<void> {\n return this.collectionsStore.updatePostRank(collectionId, postId, rank);\n }\n\n async getTags(\n options?: { noDescription?: boolean; ids?: number[] } & TagsQuery,\n filters?: PermissionCriteria<QetaFilters>,\n ): Promise<TagsResponse> {\n return this.tagsStore.getTags(options, filters);\n }\n\n async getTagExperts(tags: string[]): Promise<string[]> {\n return this.tagsStore.getTagExperts(tags);\n }\n\n async getTag(tag: string): Promise<TagResponse | null> {\n return this.tagsStore.getTag(tag);\n }\n\n async getTagById(id: number): Promise<TagResponse | null> {\n return this.tagsStore.getTagById(id);\n }\n\n async createTag(\n tag: string,\n description?: string,\n experts?: string[],\n ): Promise<TagResponse | null> {\n return this.tagsStore.createTag(tag, description, experts);\n }\n\n async updateTag(\n id: number,\n description?: string,\n experts?: string[],\n ): Promise<TagResponse | null> {\n return this.tagsStore.updateTag(id, description, experts);\n }\n\n async deleteTag(id: number): Promise<boolean> {\n return this.tagsStore.deleteTag(id);\n }\n\n async getEntities(\n options?: { entityRefs?: string[] } & EntitiesQuery,\n ): Promise<EntitiesResponse> {\n return this.entitiesStore.getEntities(options);\n }\n\n async getEntity(entity_ref: string): Promise<EntityResponse | null> {\n return this.entitiesStore.getEntity(entity_ref);\n }\n\n async getUsers(\n options?: { entityRefs?: string[] } & UsersQuery,\n ): Promise<UsersResponse> {\n return this.usersStore.getUsers(options);\n }\n\n async getUser(user_ref: string): Promise<UserResponse | null> {\n return this.usersStore.getUser(user_ref);\n }\n\n async getUserTags(\n user_ref: string,\n filters?: PermissionCriteria<QetaFilters>,\n ): Promise<UserTagsResponse> {\n return this.tagsStore.getUserTags(user_ref, filters);\n }\n\n async followTag(user_ref: string, tag: string): Promise<boolean> {\n return this.tagsStore.followTag(user_ref, tag);\n }\n\n async unfollowTag(user_ref: string, tag: string): Promise<boolean> {\n return this.tagsStore.unfollowTag(user_ref, tag);\n }\n\n async getUserEntities(user_ref: string): Promise<UserEntitiesResponse> {\n return this.entitiesStore.getUserEntities(user_ref);\n }\n\n async followEntity(user_ref: string, entityRef: string): Promise<boolean> {\n return this.entitiesStore.followEntity(user_ref, entityRef);\n }\n\n async unfollowEntity(user_ref: string, entityRef: string): Promise<boolean> {\n return this.entitiesStore.unfollowEntity(user_ref, entityRef);\n }\n\n async getUsersForTags(tags: string[]): Promise<string[]> {\n return this.tagsStore.getUsersForTags(tags);\n }\n\n async getUsersForEntities(entityRefs: string[]): Promise<string[]> {\n return this.entitiesStore.getUsersForEntities(entityRefs);\n }\n\n async getFollowedUsers(user_ref: string): Promise<UserUsersResponse> {\n return this.usersStore.getFollowedUsers(user_ref);\n }\n\n async followUser(\n user_ref: string,\n followedUserRef: string,\n ): Promise<boolean> {\n return this.usersStore.followUser(user_ref, followedUserRef);\n }\n\n async unfollowUser(\n user_ref: string,\n followedUserRef: string,\n ): Promise<boolean> {\n return this.usersStore.unfollowUser(user_ref, followedUserRef);\n }\n\n async getGlobalStats(): Promise<GlobalStat[]> {\n return this.statsStore.getGlobalStats();\n }\n\n async getUserStats(user_ref: string): Promise<UserStat[]> {\n return this.statsStore.getUserStats(user_ref);\n }\n\n async getTemplates(): Promise<Templates> {\n return this.templatesStore.getTemplates();\n }\n\n async getTemplate(id: number): Promise<Template | null> {\n return this.templatesStore.getTemplate(id);\n }\n\n async createTemplate(options: {\n title: string;\n description: string;\n questionTitle?: string;\n questionContent?: string;\n tags?: string[];\n entities?: string[];\n }): Promise<Template> {\n return this.templatesStore.createTemplate(options);\n }\n\n async deleteTemplate(id: number): Promise<boolean> {\n return this.templatesStore.deleteTemplate(id);\n }\n\n async updateTemplate(options: {\n id: number;\n title: string;\n description: string;\n questionTitle?: string;\n questionContent?: string;\n tags?: string[];\n entities?: string[];\n }): Promise<Template | null> {\n return this.templatesStore.updateTemplate(options);\n }\n\n async reviewPost(\n user_ref: string,\n postId: number,\n status: 'valid' | 'obsolete',\n comment?: string,\n ): Promise<MaybePost> {\n return this.postsStore.reviewPost(user_ref, postId, status, comment);\n }\n\n async getPostReviews(postId: number): Promise<PostReview[]> {\n return this.postsStore.getPostReviews(postId);\n }\n\n async getAIAnswer(postId: number): Promise<AIResponse | null> {\n return this.postsStore.getAIAnswer(postId);\n }\n\n async saveAIAnswer(postId: number, response: AIResponse): Promise<void> {\n return this.postsStore.saveAIAnswer(postId, response);\n }\n\n async deleteAIAnswer(postId: number): Promise<boolean> {\n return this.postsStore.deleteAIAnswer(postId);\n }\n\n async postAttachment({\n uuid,\n locationType,\n locationUri,\n extension,\n mimeType,\n binaryImage,\n path,\n creator,\n }: AttachmentParameters): Promise<Attachment> {\n return this.attachmentsStore.postAttachment({\n uuid,\n locationType,\n locationUri,\n extension,\n mimeType,\n binaryImage,\n path,\n creator,\n });\n }\n\n async getAttachment(uuid: string): Promise<Attachment | undefined> {\n return this.attachmentsStore.getAttachment(uuid);\n }\n\n async deleteAttachment(uuid: string): Promise<boolean> {\n return this.attachmentsStore.deleteAttachment(uuid);\n }\n\n async getDeletableAttachments(dayLimit: number): Promise<Attachment[]> {\n return this.attachmentsStore.getDeletableAttachments(dayLimit);\n }\n\n // Stats\n\n async getMostUpvotedPosts({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getMostUpvotedPosts({ author, options });\n }\n\n async getTotalPosts({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getTotalPosts({ author, options });\n }\n\n async getMostUpvotedAnswers({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getMostUpvotedAnswers({ author, options });\n }\n\n async getMostUpvotedCorrectAnswers({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getMostUpvotedCorrectAnswers({ author, options });\n }\n\n async getTotalAnswers({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getTotalAnswers({ author, options });\n }\n\n async getCount(\n table: string,\n filters?: { author?: string; type?: PostType },\n ): Promise<number> {\n return this.statsStore.getCount(table, filters);\n }\n\n async saveGlobalStats(date: Date): Promise<void> {\n return this.statsStore.saveGlobalStats(date);\n }\n\n async saveUserStats(userRef: string, date: Date): Promise<void> {\n return this.statsStore.saveUserStats(userRef, date);\n }\n\n async getTotalViews(\n user_ref: string,\n lastDays?: number,\n excludeUser?: boolean,\n ): Promise<number> {\n return this.statsStore.getTotalViews(user_ref, lastDays, excludeUser);\n }\n\n async getBadges(): Promise<Badge[]> {\n return this.badgesStore.getBadges();\n }\n\n async getBadge(key: string): Promise<Badge | undefined> {\n return this.badgesStore.getBadge(key);\n }\n\n async getUserBadges(userRef: string): Promise<UserBadge[]> {\n return this.badgesStore.getUserBadges(userRef);\n }\n\n async awardBadge(\n userRef: string,\n badgeKey: string,\n uniqueKey?: string,\n ): Promise<AwardBadgeResult | null> {\n return this.badgesStore.awardBadge(userRef, badgeKey, uniqueKey);\n }\n\n async createBadge(badge: Omit<Badge, 'id'>): Promise<void> {\n return this.badgesStore.createBadge(badge);\n }\n\n async suggestPosts(\n user_ref: string,\n title: string,\n content: string,\n tags?: string[],\n entities?: string[],\n filters?: PermissionCriteria<QetaFilters>,\n opts?: PostOptions,\n ): Promise<Posts> {\n return this.postsStore.suggestPosts(\n user_ref,\n title,\n content,\n tags,\n entities,\n filters,\n opts,\n );\n }\n\n async cleanStats(days: number, date: Date): Promise<void> {\n return this.statsStore.cleanStats(days, date);\n }\n\n async getUsersCount(): Promise<number> {\n return this.usersStore.getUsersCount();\n }\n\n async getFollowingUsers(user_ref: string): Promise<string[]> {\n return this.usersStore.getFollowingUsers(user_ref);\n }\n\n async getEntityLinks(): Promise<EntityLinks[]> {\n return this.entitiesStore.getEntityLinks();\n }\n\n async getComments(\n options?: { ids?: number[] },\n opts?: CommentOptions,\n ): Promise<QetaComment[]> {\n return this.commentsStore.getComments(options, opts);\n }\n\n async getComment(\n commentId: number,\n opts?: CommentOptions & { postId?: number; answerId?: number },\n ): Promise<QetaComment | null> {\n return this.commentsStore.getComment(commentId, opts);\n }\n}\n"],"names":["resolvePackagePath","CommentsStore","TagsStore","EntitiesStore","UsersStore","TemplatesStore","AttachmentsStore","PostsStore","AnswersStore","CollectionsStore","StatsStore","BadgesStore","HelpersStore"],"mappings":";;;;;;;;;;;;;;;;AAyEA,MAAM,aAAgB,GAAAA,mCAAA;AAAA,EACpB,uCAAA;AAAA,EACA;AACF,CAAA;AAIO,MAAM,iBAAuC,CAAA;AAAA,EAC1C,WACW,CAAA,UAAA,EACA,YACA,EAAA,aAAA,EACA,gBACA,EAAA,UAAA,EACA,SACA,EAAA,UAAA,EACA,aACA,EAAA,cAAA,EACA,gBACA,EAAA,WAAA,EACA,YACjB,EAAA;AAZiB,IAAA,IAAA,CAAA,UAAA,GAAA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AA,CAAc,UAAW,CAAA,SAAA,EAAW,IAAI,CAAA;AAAA;AAExD;;;;"}
|
|
1
|
+
{"version":3,"file":"DatabaseQetaStore.cjs.js","sources":["../../src/database/DatabaseQetaStore.ts"],"sourcesContent":["import {\n DatabaseService,\n resolvePackagePath,\n} from '@backstage/backend-plugin-api';\n\nimport {\n AnswerOptions,\n Answers,\n AttachmentParameters,\n AwardBadgeResult,\n CollectionOptions,\n CollectionPostRank,\n Collections,\n CommentOptions,\n EntitiesResponse,\n EntityResponse,\n MaybeAnswer,\n MaybeCollection,\n MaybePost,\n PostOptions,\n PostReview,\n Posts,\n QetaStore,\n Templates,\n UserResponse,\n UsersResponse,\n TimelineFilters,\n} from './QetaStore';\nimport { Badge, UserBadge } from '@drodil/backstage-plugin-qeta-common';\nimport {\n AIResponse,\n AnswersQuery,\n Attachment,\n Collection,\n Comment as QetaComment,\n EntitiesQuery,\n EntityLinks,\n GlobalStat,\n Post,\n PostStatus,\n PostType,\n PostsQuery,\n Statistic,\n StatisticsRequestParameters,\n TagResponse,\n TagsQuery,\n TagsResponse,\n Template,\n UserCollectionsResponse,\n UserEntitiesResponse,\n UsersQuery,\n UserStat,\n UserTagsResponse,\n UserUsersResponse,\n TimelineOptions,\n TimelineResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { QetaFilters } from '../service/util';\nimport { PermissionCriteria } from '@backstage/plugin-permission-common';\nimport { TagDatabase } from '@drodil/backstage-plugin-qeta-node';\nimport { PostsStore } from './stores/PostsStore';\nimport { AnswersStore } from './stores/AnswersStore';\nimport { CommentsStore } from './stores/CommentsStore';\nimport { CollectionsStore } from './stores/CollectionsStore';\nimport { StatsStore } from './stores/StatsStore';\nimport { TagsStore } from './stores/TagsStore';\nimport { UsersStore } from './stores/UsersStore';\nimport { EntitiesStore } from './stores/EntitiesStore';\nimport { TemplatesStore } from './stores/TemplatesStore';\nimport { AttachmentsStore } from './stores/AttachmentsStore';\nimport { BadgesStore } from './stores/BadgesStore';\nimport { HelpersStore } from './stores/HelpersStore';\n\nconst migrationsDir = resolvePackagePath(\n '@drodil/backstage-plugin-qeta-backend',\n 'migrations',\n);\n\n// Local interfaces removed, imported from stores\n\nexport class DatabaseQetaStore implements QetaStore {\n private constructor(\n private readonly postsStore: PostsStore,\n private readonly answersStore: AnswersStore,\n private readonly commentsStore: CommentsStore,\n private readonly collectionsStore: CollectionsStore,\n private readonly statsStore: StatsStore,\n private readonly tagsStore: TagsStore,\n private readonly usersStore: UsersStore,\n private readonly entitiesStore: EntitiesStore,\n private readonly templatesStore: TemplatesStore,\n private readonly attachmentsStore: AttachmentsStore,\n private readonly badgesStore: BadgesStore,\n private readonly helpersStore: HelpersStore,\n ) {}\n\n async getTimeline(\n user_ref: string,\n options: TimelineOptions,\n filters?: TimelineFilters,\n ): Promise<TimelineResponse> {\n return this.helpersStore.getTimeline(user_ref, options, filters);\n }\n\n static async create({\n database,\n skipMigrations,\n tagDatabase,\n }: {\n database: DatabaseService;\n skipMigrations?: boolean;\n tagDatabase?: TagDatabase;\n }): Promise<DatabaseQetaStore> {\n const client = await database.getClient();\n\n if (!database.migrations?.skip && !skipMigrations) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n const commentsStore = new CommentsStore(client);\n const tagsStore = new TagsStore(client, tagDatabase);\n const entitiesStore = new EntitiesStore(client);\n const usersStore = new UsersStore(client);\n const templatesStore = new TemplatesStore(client, tagsStore, entitiesStore);\n const attachmentsStore = new AttachmentsStore(client);\n const postsStore = new PostsStore(\n client,\n commentsStore,\n tagsStore,\n entitiesStore,\n attachmentsStore,\n tagDatabase,\n );\n const answersStore = new AnswersStore(\n client,\n commentsStore,\n postsStore,\n attachmentsStore,\n );\n const collectionsStore = new CollectionsStore(\n client,\n postsStore,\n attachmentsStore,\n );\n const statsStore = new StatsStore(client);\n const badgesStore = new BadgesStore(client);\n const helpersStore = new HelpersStore(client);\n\n postsStore.setAnswersStore(answersStore);\n postsStore.setCollectionsStore(collectionsStore);\n\n return new DatabaseQetaStore(\n postsStore,\n answersStore,\n commentsStore,\n collectionsStore,\n statsStore,\n tagsStore,\n usersStore,\n entitiesStore,\n templatesStore,\n attachmentsStore,\n badgesStore,\n helpersStore,\n );\n }\n\n async getPosts(\n user_ref: string,\n options: PostsQuery,\n filters?: PermissionCriteria<QetaFilters>,\n opts?: PostOptions,\n ): Promise<Posts> {\n return this.postsStore.getPosts(user_ref, options, filters, opts);\n }\n\n async getPost(\n user_ref: string,\n id: number,\n recordView?: boolean,\n options?: PostOptions,\n ): Promise<MaybePost> {\n return this.postsStore.getPost(user_ref, id, recordView, options);\n }\n\n async getPostByAnswerId(\n user_ref: string,\n answerId: number,\n recordView?: boolean,\n options?: PostOptions,\n ): Promise<MaybePost> {\n return this.postsStore.getPostByAnswerId(\n user_ref,\n answerId,\n recordView,\n options,\n );\n }\n\n async createPost(options: {\n user_ref: string;\n title: string;\n content: string;\n created: Date;\n author?: string;\n tags?: string[];\n entities?: string[];\n images?: number[];\n anonymous?: boolean;\n type?: PostType;\n headerImage?: string;\n url?: string;\n status?: PostStatus;\n opts?: PostOptions;\n }): Promise<Post> {\n return this.postsStore.createPost(options);\n }\n\n async updatePost(options: {\n user_ref: string;\n id: number;\n title?: string;\n content?: string;\n author?: string;\n tags?: string[];\n entities?: string[];\n images?: number[];\n headerImage?: string;\n url?: string;\n status?: PostStatus;\n opts?: PostOptions;\n }): Promise<MaybePost> {\n return this.postsStore.updatePost(options);\n }\n\n async deletePost(id: number, permanently?: boolean): Promise<boolean> {\n return this.postsStore.deletePost(id, permanently);\n }\n\n async votePost(\n user_ref: string,\n postId: number,\n score: number,\n ): Promise<boolean> {\n return this.postsStore.votePost(user_ref, postId, score);\n }\n\n async deletePostVote(user_ref: string, postId: number): Promise<boolean> {\n return this.postsStore.deletePostVote(user_ref, postId);\n }\n\n async favoritePost(user_ref: string, postId: number): Promise<boolean> {\n return this.postsStore.favoritePost(user_ref, postId);\n }\n\n async unfavoritePost(user_ref: string, postId: number): Promise<boolean> {\n return this.postsStore.unfavoritePost(user_ref, postId);\n }\n\n async getUsersWhoFavoritedPost(postId: number): Promise<string[]> {\n return this.postsStore.getUsersWhoFavoritedPost(postId);\n }\n\n async getAnswers(\n user_ref: string,\n options: AnswersQuery,\n filters?: PermissionCriteria<QetaFilters>,\n opts?: AnswerOptions,\n ): Promise<Answers> {\n return this.answersStore.getAnswers(user_ref, options, filters, opts);\n }\n\n async getAnswer(\n answerId: number,\n user_ref: string,\n options?: AnswerOptions,\n ): Promise<MaybeAnswer> {\n return this.answersStore.getAnswer(answerId, user_ref, options);\n }\n\n async answerPost(\n user_ref: string,\n questionId: number,\n answer: string,\n created: Date,\n images?: number[],\n anonymous?: boolean,\n options?: AnswerOptions,\n ): Promise<MaybeAnswer> {\n return this.answersStore.answerPost(\n user_ref,\n questionId,\n answer,\n created,\n images,\n anonymous,\n options,\n );\n }\n\n async updateAnswer(\n user_ref: string,\n questionId: number,\n answerId: number,\n answer: string,\n author?: string,\n images?: number[],\n options?: AnswerOptions,\n ): Promise<MaybeAnswer> {\n return this.answersStore.updateAnswer(\n user_ref,\n questionId,\n answerId,\n answer,\n author,\n images,\n options,\n );\n }\n\n async deleteAnswer(id: number): Promise<boolean> {\n return this.answersStore.deleteAnswer(id);\n }\n\n async voteAnswer(\n user_ref: string,\n answerId: number,\n score: number,\n ): Promise<boolean> {\n return this.answersStore.voteAnswer(user_ref, answerId, score);\n }\n\n async deleteAnswerVote(user_ref: string, answerId: number): Promise<boolean> {\n return this.answersStore.deleteAnswerVote(user_ref, answerId);\n }\n\n async markAnswerCorrect(postId: number, answerId: number): Promise<boolean> {\n return this.answersStore.markAnswerCorrect(postId, answerId);\n }\n\n async markAnswerIncorrect(\n postId: number,\n answerId: number,\n ): Promise<boolean> {\n return this.answersStore.markAnswerIncorrect(postId, answerId);\n }\n\n async clickPost(user_ref: string, postId: number): Promise<void> {\n const vote = await this.postsStore.getPostVote(user_ref, postId);\n const score = (vote?.score || 0) + 1;\n await this.postsStore.votePost(user_ref, postId, score);\n }\n\n async commentPost(\n post_id: number,\n user_ref: string,\n content: string,\n created: Date,\n ): Promise<MaybePost> {\n await this.commentsStore.commentPost(post_id, user_ref, content, created);\n return this.getPost(user_ref, post_id);\n }\n\n async commentAnswer(\n answer_id: number,\n user_ref: string,\n content: string,\n created: Date,\n ): Promise<MaybeAnswer> {\n await this.commentsStore.commentAnswer(\n answer_id,\n user_ref,\n content,\n created,\n );\n return this.getAnswer(answer_id, user_ref);\n }\n\n async updatePostComment(\n post_id: number,\n id: number,\n user_ref: string,\n content: string,\n ): Promise<MaybePost> {\n await this.commentsStore.updatePostComment(post_id, id, user_ref, content);\n return this.getPost(user_ref, post_id);\n }\n\n async updateAnswerComment(\n answer_id: number,\n id: number,\n user_ref: string,\n content: string,\n ): Promise<MaybeAnswer> {\n await this.commentsStore.updateAnswerComment(\n answer_id,\n id,\n user_ref,\n content,\n );\n return this.getAnswer(answer_id, user_ref);\n }\n\n async deletePostComment(\n post_id: number,\n id: number,\n user_ref: string,\n ): Promise<MaybePost> {\n await this.commentsStore.deletePostComment(post_id, id);\n return this.getPost(user_ref, post_id);\n }\n\n async deleteAnswerComment(\n answer_id: number,\n id: number,\n user_ref: string,\n ): Promise<MaybeAnswer> {\n await this.commentsStore.deleteAnswerComment(answer_id, id);\n return this.getAnswer(answer_id, user_ref);\n }\n\n async getCollections(\n user_ref: string,\n options: PostsQuery,\n opts?: CollectionOptions,\n ): Promise<Collections> {\n return this.collectionsStore.getCollections(user_ref, options, opts);\n }\n\n async getCollection(\n user_ref: string,\n id: number,\n options?: CollectionOptions,\n ): Promise<MaybeCollection> {\n return this.collectionsStore.getCollection(user_ref, id, options);\n }\n\n async createCollection(options: {\n user_ref: string;\n title: string;\n description?: string;\n created: Date;\n images?: number[];\n headerImage?: string;\n opts?: CollectionOptions;\n tags?: string[];\n entities?: string[];\n users?: string[];\n }): Promise<Collection> {\n return this.collectionsStore.createCollection(\n options,\n ) as Promise<Collection>;\n }\n\n async updateCollection(options: {\n id: number;\n user_ref: string;\n title: string;\n description?: string;\n images?: number[];\n headerImage?: string;\n opts?: CollectionOptions;\n tags?: string[];\n entities?: string[];\n users?: string[];\n }): Promise<MaybeCollection> {\n return this.collectionsStore.updateCollection(options);\n }\n\n async deleteCollection(id: number): Promise<boolean> {\n return this.collectionsStore.deleteCollection(id);\n }\n\n async addPostToCollection(\n user_ref: string,\n id: number,\n postId: number,\n options?: CollectionOptions,\n ): Promise<MaybeCollection> {\n return this.collectionsStore.addPostToCollection(\n user_ref,\n id,\n postId,\n options,\n );\n }\n\n async removePostFromCollection(\n user_ref: string,\n id: number,\n postId: number,\n options?: CollectionOptions,\n ): Promise<MaybeCollection> {\n return this.collectionsStore.removePostFromCollection(\n user_ref,\n id,\n postId,\n options,\n );\n }\n\n async getUsersForCollection(collectionId: number): Promise<string[]> {\n return this.collectionsStore.getUsersForCollection(collectionId);\n }\n\n async followCollection(\n user_ref: string,\n collectionId: number,\n ): Promise<boolean> {\n return this.collectionsStore.followCollection(user_ref, collectionId);\n }\n\n async unfollowCollection(\n user_ref: string,\n collectionId: number,\n ): Promise<boolean> {\n return this.collectionsStore.unfollowCollection(user_ref, collectionId);\n }\n\n async getUserCollections(\n user_ref: string,\n options?: CollectionOptions,\n ): Promise<UserCollectionsResponse> {\n return this.collectionsStore.getUserCollections(user_ref, options);\n }\n\n async getPostRank(\n collectionId: number,\n postId: number,\n ): Promise<number | null> {\n return this.collectionsStore.getPostRank(collectionId, postId);\n }\n\n async getTopRankedPostId(\n collectionId: number,\n ): Promise<CollectionPostRank | null> {\n return this.collectionsStore.getTopRankedPostId(collectionId);\n }\n\n async getBottomRankedPostId(\n collectionId: number,\n ): Promise<CollectionPostRank | null> {\n return this.collectionsStore.getBottomRankedPostId(collectionId);\n }\n\n async getNextRankedPostId(\n collectionId: number,\n postId: number,\n ): Promise<CollectionPostRank | null> {\n return this.collectionsStore.getNextRankedPostId(collectionId, postId);\n }\n\n async getPreviousRankedPostId(\n collectionId: number,\n postId: number,\n ): Promise<CollectionPostRank | null> {\n return this.collectionsStore.getPreviousRankedPostId(collectionId, postId);\n }\n\n async updatePostRank(\n collectionId: number,\n postId: number,\n rank: number,\n ): Promise<void> {\n return this.collectionsStore.updatePostRank(collectionId, postId, rank);\n }\n\n async getTags(\n options?: { noDescription?: boolean; ids?: number[] } & TagsQuery,\n filters?: PermissionCriteria<QetaFilters>,\n ): Promise<TagsResponse> {\n return this.tagsStore.getTags(options, filters);\n }\n\n async getTagExperts(tags: string[]): Promise<string[]> {\n return this.tagsStore.getTagExperts(tags);\n }\n\n async getTag(tag: string): Promise<TagResponse | null> {\n return this.tagsStore.getTag(tag);\n }\n\n async getTagById(id: number): Promise<TagResponse | null> {\n return this.tagsStore.getTagById(id);\n }\n\n async createTag(\n tag: string,\n description?: string,\n experts?: string[],\n ): Promise<TagResponse | null> {\n return this.tagsStore.createTag(tag, description, experts);\n }\n\n async updateTag(\n id: number,\n description?: string,\n experts?: string[],\n ): Promise<TagResponse | null> {\n return this.tagsStore.updateTag(id, description, experts);\n }\n\n async deleteTag(id: number): Promise<boolean> {\n return this.tagsStore.deleteTag(id);\n }\n\n async getEntities(\n options?: { entityRefs?: string[] } & EntitiesQuery,\n ): Promise<EntitiesResponse> {\n return this.entitiesStore.getEntities(options);\n }\n\n async getEntity(entity_ref: string): Promise<EntityResponse | null> {\n return this.entitiesStore.getEntity(entity_ref);\n }\n\n async getUsers(\n options?: { entityRefs?: string[] } & UsersQuery,\n ): Promise<UsersResponse> {\n return this.usersStore.getUsers(options);\n }\n\n async getUser(user_ref: string): Promise<UserResponse | null> {\n return this.usersStore.getUser(user_ref);\n }\n\n async getUserTags(\n user_ref: string,\n filters?: PermissionCriteria<QetaFilters>,\n ): Promise<UserTagsResponse> {\n return this.tagsStore.getUserTags(user_ref, filters);\n }\n\n async followTag(user_ref: string, tag: string): Promise<boolean> {\n return this.tagsStore.followTag(user_ref, tag);\n }\n\n async unfollowTag(user_ref: string, tag: string): Promise<boolean> {\n return this.tagsStore.unfollowTag(user_ref, tag);\n }\n\n async getUserEntities(user_ref: string): Promise<UserEntitiesResponse> {\n return this.entitiesStore.getUserEntities(user_ref);\n }\n\n async followEntity(user_ref: string, entityRef: string): Promise<boolean> {\n return this.entitiesStore.followEntity(user_ref, entityRef);\n }\n\n async unfollowEntity(user_ref: string, entityRef: string): Promise<boolean> {\n return this.entitiesStore.unfollowEntity(user_ref, entityRef);\n }\n\n async getUsersForTags(tags: string[]): Promise<string[]> {\n return this.tagsStore.getUsersForTags(tags);\n }\n\n async getUsersForEntities(entityRefs: string[]): Promise<string[]> {\n return this.entitiesStore.getUsersForEntities(entityRefs);\n }\n\n async getFollowedUsers(user_ref: string): Promise<UserUsersResponse> {\n return this.usersStore.getFollowedUsers(user_ref);\n }\n\n async followUser(\n user_ref: string,\n followedUserRef: string,\n ): Promise<boolean> {\n return this.usersStore.followUser(user_ref, followedUserRef);\n }\n\n async unfollowUser(\n user_ref: string,\n followedUserRef: string,\n ): Promise<boolean> {\n return this.usersStore.unfollowUser(user_ref, followedUserRef);\n }\n\n async getGlobalStats(): Promise<GlobalStat[]> {\n return this.statsStore.getGlobalStats();\n }\n\n async getUserStats(user_ref: string): Promise<UserStat[]> {\n return this.statsStore.getUserStats(user_ref);\n }\n\n async getTemplates(): Promise<Templates> {\n return this.templatesStore.getTemplates();\n }\n\n async getTemplate(id: number): Promise<Template | null> {\n return this.templatesStore.getTemplate(id);\n }\n\n async createTemplate(options: {\n title: string;\n description: string;\n questionTitle?: string;\n questionContent?: string;\n tags?: string[];\n entities?: string[];\n }): Promise<Template> {\n return this.templatesStore.createTemplate(options);\n }\n\n async deleteTemplate(id: number): Promise<boolean> {\n return this.templatesStore.deleteTemplate(id);\n }\n\n async updateTemplate(options: {\n id: number;\n title: string;\n description: string;\n questionTitle?: string;\n questionContent?: string;\n tags?: string[];\n entities?: string[];\n }): Promise<Template | null> {\n return this.templatesStore.updateTemplate(options);\n }\n\n async reviewPost(\n user_ref: string,\n postId: number,\n status: 'valid' | 'obsolete',\n comment?: string,\n ): Promise<MaybePost> {\n return this.postsStore.reviewPost(user_ref, postId, status, comment);\n }\n\n async getPostReviews(postId: number): Promise<PostReview[]> {\n return this.postsStore.getPostReviews(postId);\n }\n\n async getAIAnswer(postId: number): Promise<AIResponse | null> {\n return this.postsStore.getAIAnswer(postId);\n }\n\n async saveAIAnswer(postId: number, response: AIResponse): Promise<void> {\n return this.postsStore.saveAIAnswer(postId, response);\n }\n\n async deleteAIAnswer(postId: number): Promise<boolean> {\n return this.postsStore.deleteAIAnswer(postId);\n }\n\n async postAttachment({\n uuid,\n locationType,\n locationUri,\n extension,\n mimeType,\n binaryImage,\n path,\n creator,\n }: AttachmentParameters): Promise<Attachment> {\n return this.attachmentsStore.postAttachment({\n uuid,\n locationType,\n locationUri,\n extension,\n mimeType,\n binaryImage,\n path,\n creator,\n });\n }\n\n async getAttachment(uuid: string): Promise<Attachment | undefined> {\n return this.attachmentsStore.getAttachment(uuid);\n }\n\n async deleteAttachment(uuid: string): Promise<boolean> {\n return this.attachmentsStore.deleteAttachment(uuid);\n }\n\n async getDeletableAttachments(dayLimit: number): Promise<Attachment[]> {\n return this.attachmentsStore.getDeletableAttachments(dayLimit);\n }\n\n // Stats\n\n async getMostUpvotedPosts({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getMostUpvotedPosts({ author, options });\n }\n\n async getTotalPosts({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getTotalPosts({ author, options });\n }\n\n async getMostUpvotedAnswers({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getMostUpvotedAnswers({ author, options });\n }\n\n async getMostUpvotedCorrectAnswers({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getMostUpvotedCorrectAnswers({ author, options });\n }\n\n async getTotalAnswers({\n author,\n options,\n }: StatisticsRequestParameters): Promise<Statistic[]> {\n return this.statsStore.getTotalAnswers({ author, options });\n }\n\n async getCount(\n table: string,\n filters?: { author?: string; type?: PostType },\n ): Promise<number> {\n return this.statsStore.getCount(table, filters);\n }\n\n async saveGlobalStats(date: Date): Promise<void> {\n return this.statsStore.saveGlobalStats(date);\n }\n\n async saveUserStats(userRef: string, date: Date): Promise<void> {\n return this.statsStore.saveUserStats(userRef, date);\n }\n\n async getTotalViews(\n user_ref: string,\n lastDays?: number,\n excludeUser?: boolean,\n ): Promise<number> {\n return this.statsStore.getTotalViews(user_ref, lastDays, excludeUser);\n }\n\n async getBadges(): Promise<Badge[]> {\n return this.badgesStore.getBadges();\n }\n\n async getBadge(key: string): Promise<Badge | undefined> {\n return this.badgesStore.getBadge(key);\n }\n\n async getUserBadges(userRef: string): Promise<UserBadge[]> {\n return this.badgesStore.getUserBadges(userRef);\n }\n\n async awardBadge(\n userRef: string,\n badgeKey: string,\n uniqueKey?: string,\n ): Promise<AwardBadgeResult | null> {\n return this.badgesStore.awardBadge(userRef, badgeKey, uniqueKey);\n }\n\n async createBadge(badge: Omit<Badge, 'id'>): Promise<void> {\n return this.badgesStore.createBadge(badge);\n }\n\n async suggestPosts(\n user_ref: string,\n title: string,\n content: string,\n tags?: string[],\n entities?: string[],\n filters?: PermissionCriteria<QetaFilters>,\n opts?: PostOptions,\n ): Promise<Posts> {\n return this.postsStore.suggestPosts(\n user_ref,\n title,\n content,\n tags,\n entities,\n filters,\n opts,\n );\n }\n\n async cleanStats(days: number, date: Date): Promise<void> {\n return this.statsStore.cleanStats(days, date);\n }\n\n async getUsersCount(): Promise<number> {\n return this.usersStore.getUsersCount();\n }\n\n async getFollowingUsers(user_ref: string): Promise<string[]> {\n return this.usersStore.getFollowingUsers(user_ref);\n }\n\n async getEntityLinks(): Promise<EntityLinks[]> {\n return this.entitiesStore.getEntityLinks();\n }\n\n async getComments(\n options?: { ids?: number[] },\n opts?: CommentOptions,\n ): Promise<QetaComment[]> {\n return this.commentsStore.getComments(options, opts);\n }\n\n async getComment(\n commentId: number,\n opts?: CommentOptions & { postId?: number; answerId?: number },\n ): Promise<QetaComment | null> {\n return this.commentsStore.getComment(commentId, opts);\n }\n}\n"],"names":["resolvePackagePath","CommentsStore","TagsStore","EntitiesStore","UsersStore","TemplatesStore","AttachmentsStore","PostsStore","AnswersStore","CollectionsStore","StatsStore","BadgesStore","HelpersStore"],"mappings":";;;;;;;;;;;;;;;;AAyEA,MAAM,aAAgB,GAAAA,mCAAA;AAAA,EACpB,uCAAA;AAAA,EACA;AACF,CAAA;AAIO,MAAM,iBAAuC,CAAA;AAAA,EAC1C,WACW,CAAA,UAAA,EACA,YACA,EAAA,aAAA,EACA,gBACA,EAAA,UAAA,EACA,SACA,EAAA,UAAA,EACA,aACA,EAAA,cAAA,EACA,gBACA,EAAA,WAAA,EACA,YACjB,EAAA;AAZiB,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AACA,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA;AACA,IAAA,IAAA,CAAA,gBAAA,GAAA,gBAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA;AACA,IAAA,IAAA,CAAA,cAAA,GAAA,cAAA;AACA,IAAA,IAAA,CAAA,gBAAA,GAAA,gBAAA;AACA,IAAA,IAAA,CAAA,WAAA,GAAA,WAAA;AACA,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AAAA;AAChB,EAEH,MAAM,WAAA,CACJ,QACA,EAAA,OAAA,EACA,OAC2B,EAAA;AAC3B,IAAA,OAAO,IAAK,CAAA,YAAA,CAAa,WAAY,CAAA,QAAA,EAAU,SAAS,OAAO,CAAA;AAAA;AACjE,EAEA,aAAa,MAAO,CAAA;AAAA,IAClB,QAAA;AAAA,IACA,cAA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AA,OAAO,IAAK,CAAA,UAAA,CAAW,UAAW,CAAA,IAAA,EAAM,IAAI,CAAA;AAAA;AAC9C,EAEA,MAAM,aAAiC,GAAA;AACrC,IAAO,OAAA,IAAA,CAAK,WAAW,aAAc,EAAA;AAAA;AACvC,EAEA,MAAM,kBAAkB,QAAqC,EAAA;AAC3D,IAAO,OAAA,IAAA,CAAK,UAAW,CAAA,iBAAA,CAAkB,QAAQ,CAAA;AAAA;AACnD,EAEA,MAAM,cAAyC,GAAA;AAC7C,IAAO,OAAA,IAAA,CAAK,cAAc,cAAe,EAAA;AAAA;AAC3C,EAEA,MAAM,WACJ,CAAA,OAAA,EACA,IACwB,EAAA;AACxB,IAAA,OAAO,IAAK,CAAA,aAAA,CAAc,WAAY,CAAA,OAAA,EAAS,IAAI,CAAA;AAAA;AACrD,EAEA,MAAM,UACJ,CAAA,SAAA,EACA,IAC6B,EAAA;AAC7B,IAAA,OAAO,IAAK,CAAA,aAAA,CAAc,UAAW,CAAA,SAAA,EAAW,IAAI,CAAA;AAAA;AAExD;;;;"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var backstagePluginQetaCommon = require('@drodil/backstage-plugin-qeta-common');
|
|
3
4
|
var lodash = require('lodash');
|
|
4
5
|
var BaseStore = require('./BaseStore.cjs.js');
|
|
6
|
+
var tagDb = require('../../tagDb.cjs.js');
|
|
5
7
|
|
|
6
8
|
class CollectionsStore extends BaseStore.BaseStore {
|
|
7
|
-
constructor(db, postsStore, attachmentsStore) {
|
|
9
|
+
constructor(db, postsStore, attachmentsStore, tagDatabase) {
|
|
8
10
|
super(db);
|
|
9
11
|
this.db = db;
|
|
10
12
|
this.postsStore = postsStore;
|
|
11
13
|
this.attachmentsStore = attachmentsStore;
|
|
14
|
+
this.tagDatabase = tagDatabase;
|
|
12
15
|
}
|
|
13
16
|
async getCollections(user_ref, options, opts) {
|
|
14
17
|
const query = this.getCollectionsBaseQuery();
|
|
@@ -59,7 +62,18 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
59
62
|
))[0];
|
|
60
63
|
}
|
|
61
64
|
async createCollection(options) {
|
|
62
|
-
const {
|
|
65
|
+
const {
|
|
66
|
+
user_ref,
|
|
67
|
+
title,
|
|
68
|
+
description,
|
|
69
|
+
created,
|
|
70
|
+
images,
|
|
71
|
+
headerImage,
|
|
72
|
+
tags,
|
|
73
|
+
entities,
|
|
74
|
+
users,
|
|
75
|
+
opts
|
|
76
|
+
} = options;
|
|
63
77
|
const collections = await this.db.insert(
|
|
64
78
|
{
|
|
65
79
|
owner: user_ref,
|
|
@@ -70,17 +84,34 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
70
84
|
},
|
|
71
85
|
["id"]
|
|
72
86
|
).into("collections").returning("*");
|
|
73
|
-
await
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
await Promise.all([
|
|
88
|
+
this.updateAttachments(
|
|
89
|
+
"collectionId",
|
|
90
|
+
description ?? "",
|
|
91
|
+
images ?? [],
|
|
92
|
+
collections[0].id,
|
|
93
|
+
headerImage
|
|
94
|
+
),
|
|
95
|
+
this.addCollectionTags(collections[0].id, tags),
|
|
96
|
+
this.addCollectionEntities(collections[0].id, entities),
|
|
97
|
+
this.addCollectionUsers(collections[0].id, users)
|
|
98
|
+
]);
|
|
99
|
+
await this.syncCollectionToPosts(collections[0].id);
|
|
80
100
|
return (await this.mapCollectionEntities([collections[0]], user_ref, opts))[0];
|
|
81
101
|
}
|
|
82
102
|
async updateCollection(options) {
|
|
83
|
-
const {
|
|
103
|
+
const {
|
|
104
|
+
id,
|
|
105
|
+
user_ref,
|
|
106
|
+
title,
|
|
107
|
+
description,
|
|
108
|
+
images,
|
|
109
|
+
headerImage,
|
|
110
|
+
tags,
|
|
111
|
+
entities,
|
|
112
|
+
users,
|
|
113
|
+
opts
|
|
114
|
+
} = options;
|
|
84
115
|
const rows = await this.db("collections").where("id", "=", id).update({
|
|
85
116
|
title,
|
|
86
117
|
description,
|
|
@@ -89,13 +120,19 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
89
120
|
if (!rows || rows.length === 0) {
|
|
90
121
|
return null;
|
|
91
122
|
}
|
|
92
|
-
await
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
123
|
+
await Promise.all([
|
|
124
|
+
this.updateAttachments(
|
|
125
|
+
"collectionId",
|
|
126
|
+
description ?? "",
|
|
127
|
+
images ?? [],
|
|
128
|
+
id,
|
|
129
|
+
headerImage
|
|
130
|
+
),
|
|
131
|
+
this.addCollectionTags(id, tags, true),
|
|
132
|
+
this.addCollectionEntities(id, entities, true),
|
|
133
|
+
this.addCollectionUsers(id, users, true)
|
|
134
|
+
]);
|
|
135
|
+
await this.syncCollectionToPosts(id);
|
|
99
136
|
return (await this.mapCollectionEntities([rows[0]], user_ref, opts))[0];
|
|
100
137
|
}
|
|
101
138
|
async deleteCollection(id) {
|
|
@@ -159,6 +196,105 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
159
196
|
const users = await this.db("user_collections").where("collectionId", collectionId).select("userRef");
|
|
160
197
|
return users.map((user) => user.userRef);
|
|
161
198
|
}
|
|
199
|
+
async syncCollectionToPosts(collectionId) {
|
|
200
|
+
const tags = await this.getCollectionTags([collectionId]);
|
|
201
|
+
const entities = await this.getCollectionEntities([collectionId]);
|
|
202
|
+
const users = await this.getCollectionUsers([collectionId]);
|
|
203
|
+
const collectionTags = tags.get(collectionId) || [];
|
|
204
|
+
const collectionEntities = entities.get(collectionId) || [];
|
|
205
|
+
const collectionUsers = users.get(collectionId) || [];
|
|
206
|
+
if (collectionTags.length === 0 && collectionEntities.length === 0 && collectionUsers.length === 0) {
|
|
207
|
+
await this.db("collection_posts").where("collectionId", collectionId).where("automatic", true).delete();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const posts = await this.db("posts").leftJoin("post_tags", "posts.id", "post_tags.postId").leftJoin("tags", "post_tags.tagId", "tags.id").leftJoin("post_entities", "posts.id", "post_entities.postId").leftJoin("entities", "post_entities.entityId", "entities.id").where((builder) => {
|
|
211
|
+
if (collectionTags.length > 0) {
|
|
212
|
+
builder.orWhereIn("tags.tag", collectionTags);
|
|
213
|
+
}
|
|
214
|
+
if (collectionEntities.length > 0) {
|
|
215
|
+
builder.orWhereIn("entities.entity_ref", collectionEntities);
|
|
216
|
+
}
|
|
217
|
+
if (collectionUsers.length > 0) {
|
|
218
|
+
builder.orWhereIn("posts.author", collectionUsers);
|
|
219
|
+
}
|
|
220
|
+
}).select("posts.id").distinct();
|
|
221
|
+
const postIds = posts.map((p) => p.id);
|
|
222
|
+
if (postIds.length > 0) {
|
|
223
|
+
await Promise.all(
|
|
224
|
+
postIds.map(async (postId) => {
|
|
225
|
+
await this.db.insert({
|
|
226
|
+
collectionId,
|
|
227
|
+
postId,
|
|
228
|
+
automatic: true
|
|
229
|
+
}).into("collection_posts").onConflict(["collectionId", "postId"]).ignore();
|
|
230
|
+
})
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const deleteQuery = this.db("collection_posts").where("collectionId", collectionId).where("automatic", true);
|
|
234
|
+
if (postIds.length > 0) {
|
|
235
|
+
deleteQuery.whereNotIn("postId", postIds);
|
|
236
|
+
}
|
|
237
|
+
await deleteQuery.delete();
|
|
238
|
+
const count = await this.db("collection_posts").where("collectionId", collectionId).count("* as CNT").first();
|
|
239
|
+
await this.db("collections").where("id", collectionId).update("postsCount", this.mapToInteger(count?.CNT));
|
|
240
|
+
}
|
|
241
|
+
async syncPostToCollections(postId) {
|
|
242
|
+
const post = await this.postsStore.getPost("", postId);
|
|
243
|
+
if (!post) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const postTags = post.tags || [];
|
|
247
|
+
const postEntities = post.entities || [];
|
|
248
|
+
const postAuthor = post.author;
|
|
249
|
+
const collections = await this.db("collections").leftJoin(
|
|
250
|
+
"collection_tags",
|
|
251
|
+
"collections.id",
|
|
252
|
+
"collection_tags.collectionId"
|
|
253
|
+
).leftJoin("tags", "collection_tags.tagId", "tags.id").leftJoin(
|
|
254
|
+
"collection_entities",
|
|
255
|
+
"collections.id",
|
|
256
|
+
"collection_entities.collectionId"
|
|
257
|
+
).leftJoin("entities", "collection_entities.entityId", "entities.id").leftJoin(
|
|
258
|
+
"collection_users",
|
|
259
|
+
"collections.id",
|
|
260
|
+
"collection_users.collectionId"
|
|
261
|
+
).where((builder) => {
|
|
262
|
+
if (postTags.length > 0) {
|
|
263
|
+
builder.orWhereIn("tags.tag", postTags);
|
|
264
|
+
}
|
|
265
|
+
if (postEntities.length > 0) {
|
|
266
|
+
builder.orWhereIn("entities.entity_ref", postEntities);
|
|
267
|
+
}
|
|
268
|
+
if (postAuthor) {
|
|
269
|
+
builder.orWhere("collection_users.userRef", postAuthor);
|
|
270
|
+
}
|
|
271
|
+
}).select("collections.id").distinct();
|
|
272
|
+
const collectionIds = collections.map((c) => c.id);
|
|
273
|
+
if (collectionIds.length > 0) {
|
|
274
|
+
await Promise.all(
|
|
275
|
+
collectionIds.map(async (collectionId) => {
|
|
276
|
+
await this.db.insert({
|
|
277
|
+
collectionId,
|
|
278
|
+
postId,
|
|
279
|
+
automatic: true
|
|
280
|
+
}).into("collection_posts").onConflict(["collectionId", "postId"]).ignore();
|
|
281
|
+
})
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
const deleteQuery = this.db("collection_posts").where("postId", postId).where("automatic", true);
|
|
285
|
+
if (collectionIds.length > 0) {
|
|
286
|
+
deleteQuery.whereNotIn("collectionId", collectionIds);
|
|
287
|
+
}
|
|
288
|
+
await deleteQuery.delete();
|
|
289
|
+
if (collectionIds.length > 0) {
|
|
290
|
+
await Promise.all(
|
|
291
|
+
collectionIds.map(async (collectionId) => {
|
|
292
|
+
const count = await this.db("collection_posts").where("collectionId", collectionId).count("* as CNT").first();
|
|
293
|
+
await this.db("collections").where("id", collectionId).update("postsCount", this.mapToInteger(count?.CNT));
|
|
294
|
+
})
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
162
298
|
async followCollection(user_ref, collectionId) {
|
|
163
299
|
await this.db.insert({
|
|
164
300
|
userRef: user_ref,
|
|
@@ -191,7 +327,7 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
191
327
|
includePosts = true,
|
|
192
328
|
includeExperts = true
|
|
193
329
|
} = options ?? {};
|
|
194
|
-
const [posts, attachments, followers, experts] = await Promise.all([
|
|
330
|
+
const [posts, attachments, followers, experts, tags, entities, users] = await Promise.all([
|
|
195
331
|
includePosts && this.postsStore ? this.postsStore.getPosts(
|
|
196
332
|
user_ref,
|
|
197
333
|
{ includeEntities: true },
|
|
@@ -204,6 +340,8 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
204
340
|
includeVotes: false,
|
|
205
341
|
includeTotal: false,
|
|
206
342
|
includeExperts: includeExperts ?? false,
|
|
343
|
+
includeHealth: false,
|
|
344
|
+
includeTags: true,
|
|
207
345
|
includeCollections: true,
|
|
208
346
|
collectionIds
|
|
209
347
|
}
|
|
@@ -214,7 +352,10 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
214
352
|
"collection_posts",
|
|
215
353
|
"collection_posts.postId",
|
|
216
354
|
"post_tags.postId"
|
|
217
|
-
).whereIn("collection_posts.collectionId", collectionIds).select("collection_posts.collectionId", "tag_experts.entityRef") : void 0
|
|
355
|
+
).whereIn("collection_posts.collectionId", collectionIds).select("collection_posts.collectionId", "tag_experts.entityRef") : void 0,
|
|
356
|
+
this.getCollectionTags(collectionIds),
|
|
357
|
+
this.getCollectionEntities(collectionIds),
|
|
358
|
+
this.getCollectionUsers(collectionIds)
|
|
218
359
|
]);
|
|
219
360
|
const postsMap = /* @__PURE__ */ new Map();
|
|
220
361
|
posts.posts?.forEach((p) => {
|
|
@@ -236,10 +377,10 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
236
377
|
});
|
|
237
378
|
return rows.map((val) => {
|
|
238
379
|
const collectionPosts = postsMap.get(val.id) || [];
|
|
239
|
-
const
|
|
380
|
+
const postEntities = lodash.compact([
|
|
240
381
|
...new Set(collectionPosts.map((p) => p.entities).flat())
|
|
241
382
|
]);
|
|
242
|
-
const
|
|
383
|
+
const postTags = lodash.compact([
|
|
243
384
|
...new Set(collectionPosts.map((p) => p.tags).flat())
|
|
244
385
|
]);
|
|
245
386
|
return {
|
|
@@ -254,14 +395,47 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
254
395
|
questionsCount: this.mapToInteger(val.questionsCount),
|
|
255
396
|
articlesCount: this.mapToInteger(val.articlesCount),
|
|
256
397
|
linksCount: this.mapToInteger(val.linksCount),
|
|
257
|
-
entities,
|
|
258
|
-
tags,
|
|
398
|
+
entities: entities.get(val.id) || [],
|
|
399
|
+
tags: tags.get(val.id) || [],
|
|
400
|
+
users: users.get(val.id) || [],
|
|
401
|
+
postEntities,
|
|
402
|
+
postTags,
|
|
259
403
|
images: attachmentsMap.get(val.id) || [],
|
|
260
404
|
followers: followersMap.get(val.id) || 0,
|
|
261
405
|
experts: expertsMap.get(val.id)
|
|
262
406
|
};
|
|
263
407
|
});
|
|
264
408
|
}
|
|
409
|
+
async getCollectionTags(ids) {
|
|
410
|
+
const rows = await this.db("collection_tags").leftJoin("tags", "collection_tags.tagId", "tags.id").whereIn("collection_tags.collectionId", ids).select("collection_tags.collectionId", "tags.tag");
|
|
411
|
+
const result = /* @__PURE__ */ new Map();
|
|
412
|
+
rows.forEach((row) => {
|
|
413
|
+
const tags = result.get(row.collectionId) || [];
|
|
414
|
+
tags.push(row.tag);
|
|
415
|
+
result.set(row.collectionId, tags);
|
|
416
|
+
});
|
|
417
|
+
return result;
|
|
418
|
+
}
|
|
419
|
+
async getCollectionEntities(ids) {
|
|
420
|
+
const rows = await this.db("collection_entities").leftJoin("entities", "collection_entities.entityId", "entities.id").whereIn("collection_entities.collectionId", ids).select("collection_entities.collectionId", "entities.entity_ref");
|
|
421
|
+
const result = /* @__PURE__ */ new Map();
|
|
422
|
+
rows.forEach((row) => {
|
|
423
|
+
const entities = result.get(row.collectionId) || [];
|
|
424
|
+
entities.push(row.entity_ref);
|
|
425
|
+
result.set(row.collectionId, entities);
|
|
426
|
+
});
|
|
427
|
+
return result;
|
|
428
|
+
}
|
|
429
|
+
async getCollectionUsers(ids) {
|
|
430
|
+
const rows = await this.db("collection_users").whereIn("collectionId", ids).select("collectionId", "userRef");
|
|
431
|
+
const result = /* @__PURE__ */ new Map();
|
|
432
|
+
rows.forEach((row) => {
|
|
433
|
+
const users = result.get(row.collectionId) || [];
|
|
434
|
+
users.push(row.userRef);
|
|
435
|
+
result.set(row.collectionId, users);
|
|
436
|
+
});
|
|
437
|
+
return result;
|
|
438
|
+
}
|
|
265
439
|
getCollectionsBaseQuery() {
|
|
266
440
|
const questionsCount = this.db("collection_posts").leftJoin("posts", "collection_posts.postId", "posts.id").where("collection_posts.collectionId", this.db.ref("collections.id")).where("posts.type", "question").count("*").as("questionsCount");
|
|
267
441
|
const articlesCount = this.db("collection_posts").leftJoin("posts", "collection_posts.postId", "posts.id").where("collection_posts.collectionId", this.db.ref("collections.id")).where("posts.type", "article").count("*").as("articlesCount");
|
|
@@ -275,6 +449,71 @@ class CollectionsStore extends BaseStore.BaseStore {
|
|
|
275
449
|
followerCount
|
|
276
450
|
).groupBy("collections.id");
|
|
277
451
|
}
|
|
452
|
+
async addCollectionTags(id, tagsInput, removeOld) {
|
|
453
|
+
const tags = backstagePluginQetaCommon.filterTags(tagsInput);
|
|
454
|
+
if (removeOld) {
|
|
455
|
+
await this.db("collection_tags").where("collectionId", "=", id).delete();
|
|
456
|
+
}
|
|
457
|
+
if (!tags || tags.length === 0) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const existingTags = await this.db("tags").whereIn("tag", tags).returning("id").select();
|
|
461
|
+
const newTags = tags.filter((t) => !existingTags.some((e) => e.tag === t));
|
|
462
|
+
const allTags = {
|
|
463
|
+
...tagDb.TAGS,
|
|
464
|
+
...await this.tagDatabase?.getTags()
|
|
465
|
+
};
|
|
466
|
+
const tagIds = (await Promise.all(
|
|
467
|
+
[...new Set(newTags)].map(async (tag) => {
|
|
468
|
+
const trimmed = tag.trim();
|
|
469
|
+
const description = trimmed in allTags ? allTags[trimmed] : void 0;
|
|
470
|
+
return this.db.insert({ tag: trimmed, description }).into("tags").returning("id").onConflict("tag").ignore();
|
|
471
|
+
})
|
|
472
|
+
)).flat().map((tag) => tag.id).concat(existingTags.map((t) => t.id));
|
|
473
|
+
await Promise.all(
|
|
474
|
+
tagIds.map(async (tagId) => {
|
|
475
|
+
await this.db.insert({ collectionId: id, tagId }).into("collection_tags").onConflict().ignore();
|
|
476
|
+
})
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
async addCollectionEntities(id, entitiesInput, removeOld) {
|
|
480
|
+
if (removeOld) {
|
|
481
|
+
await this.db("collection_entities").where("collectionId", "=", id).delete();
|
|
482
|
+
}
|
|
483
|
+
const regex = /\w+:\w+\/\w+/;
|
|
484
|
+
const entities = entitiesInput?.filter((t) => regex.test(t)).map((t) => t.toLowerCase()).filter((t) => t.length > 0) ?? [];
|
|
485
|
+
if (!entities || entities.length === 0) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const existingEntities = await this.db("entities").whereIn("entity_ref", entities).returning("id").select();
|
|
489
|
+
const newEntities = entities.filter(
|
|
490
|
+
(t) => !existingEntities.some((e) => e.entity_ref === t)
|
|
491
|
+
);
|
|
492
|
+
const entityIds = (await Promise.all(
|
|
493
|
+
[...new Set(newEntities)].map(
|
|
494
|
+
async (entityRef) => this.db.insert({ entity_ref: entityRef }).into("entities").returning("id").onConflict("entity_ref").ignore()
|
|
495
|
+
)
|
|
496
|
+
)).flat().map((entity) => entity.id).concat(existingEntities.map((c) => c.id));
|
|
497
|
+
await Promise.all(
|
|
498
|
+
entityIds.map(async (entityId) => {
|
|
499
|
+
await this.db.insert({ collectionId: id, entityId }).into("collection_entities").onConflict().ignore();
|
|
500
|
+
})
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
async addCollectionUsers(id, usersInput, removeOld) {
|
|
504
|
+
if (removeOld) {
|
|
505
|
+
await this.db("collection_users").where("collectionId", "=", id).delete();
|
|
506
|
+
}
|
|
507
|
+
const users = [...new Set(usersInput?.filter((u) => u.length > 0) ?? [])];
|
|
508
|
+
if (users.length === 0) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
await Promise.all(
|
|
512
|
+
users.map(async (userRef) => {
|
|
513
|
+
await this.db.insert({ collectionId: id, userRef }).into("collection_users");
|
|
514
|
+
})
|
|
515
|
+
);
|
|
516
|
+
}
|
|
278
517
|
}
|
|
279
518
|
|
|
280
519
|
exports.CollectionsStore = CollectionsStore;
|