From eb4626a8dfdeb87fec340e49a4c601378ff435e8 Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Mon, 23 Dec 2024 22:16:32 +0100 Subject: [PATCH 1/9] added hidden flag functionality to activities --- CHANGELOG.MD | 5 + package-lock.json | 4 +- package.json | 2 +- prisma/data/activity.seed.ts | 15 + prisma/schema.prisma | 73 +- src/api/activity.api.ts | 9 +- src/models/generated/graphql.ts | 1069 +++++++--------------------- src/reducers/activity.reducer.ts | 1 + src/resolvers/activity.resolver.ts | 4 +- src/schemas/activity.graphql | 5 +- 10 files changed, 347 insertions(+), 840 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 624134e6..027d8f53 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -5,6 +5,11 @@ Alla märkbara ändringar ska dokumenteras i denna fil. Baserat på [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), och följer [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.15.0] +- added hidden flag functionality to activities +- query activities to include or exclude hidden activities +- (obviously there are) changes made to activity graphql and prisma schemas, reducer, resolver and api + ## [1.14.0] - log changes to individualAccess and postAccess diff --git a/package-lock.json b/package-lock.json index 0b066000..e2f6c238 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ekorre-ts", - "version": "1.13.0", + "version": "1.15.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ekorre-ts", - "version": "1.13.0", + "version": "1.15.0", "license": "AGPL-3.0-only", "dependencies": { "@esek/auth-server": "5.0.2", diff --git a/package.json b/package.json index d8c072a3..529dd4ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ekorre-ts", - "version": "1.14.0", + "version": "1.15.0", "description": "E-Sektionens backend", "main": "src/index.ts", "scripts": { diff --git a/prisma/data/activity.seed.ts b/prisma/data/activity.seed.ts index 3b25f2c9..b223a8e3 100644 --- a/prisma/data/activity.seed.ts +++ b/prisma/data/activity.seed.ts @@ -8,6 +8,10 @@ function getRandomDate(): Date { return new Date(randomTime); } +function getRandomBool(): boolean { + return Math.random() > 0.5; +} + export const activities: Prisma.PrismaActivityCreateInput[] = [ { utskott: PrismaUtskott.CM, @@ -18,6 +22,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.FVU, @@ -28,6 +33,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.INFU, @@ -38,6 +44,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.KM, @@ -48,6 +55,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.NOLLU, @@ -58,6 +66,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.ENU, @@ -68,6 +77,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.PENGU, @@ -78,6 +88,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.E6, @@ -88,6 +99,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.SRE, @@ -98,6 +110,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.STYRELSEN, @@ -108,6 +121,7 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, { utskott: PrismaUtskott.OTHER, @@ -118,5 +132,6 @@ export const activities: Prisma.PrismaActivityCreateInput[] = [ startDate: getRandomDate(), locationTitle: '', locationLink: '', + hidden: getRandomBool(), }, ]; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 67e2b0db..45422a6f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -28,41 +28,42 @@ model PrismaIndividualAccessLog { resource String isActive Boolean @map("is_active") timestamp DateTime @default(now()) + @@map("individual_accesses_log") } model PrismaUser { - username String @id - access PrismaIndividualAccess[] @relation(name: "PrismaIndividualAccessToPrismaUser") - grantedIndividualAccessLog PrismaIndividualAccessLog[] @relation(name: "PrismaIndividualAccessLogToPrismaUserGrantor") - grantedPostAccessLog PrismaPostAccessLog[] @relation(name: "PrismaPostAccessLogToPrismaUserGrantor") - targetIndividualAccessLog PrismaIndividualAccessLog[] @relation(name: "PrismaIndividualAccessLogToPrismaUserTarget") - articles PrismaArticle[] @relation(name: "PrismaArticleToAuthor") - editedArticles PrismaArticle[] @relation(name: "PrismaArticleToLastUpdateBy") - elections PrismaElection[] @relation(name: "PrismaElectionToPrismaUser") - nominations PrismaNomination[] @relation(name: "PrismaNominationToPrismaUser") - proposals PrismaProposal[] @relation(name: "PrismaProposalToPrismaUser") - files PrismaFile[] @relation(name: "PrismaFileToPrismaUser") - heHes PrismaHehe[] @relation(name: "PrismaHeheToPrismaUser") - postHistory PrismaPostHistory[] @relation(name: "PrismaPostHistoryToPrismaUser") - emergencyContacts PrismaEmergencyContact[] @relation(name: "PrismaEmergencyContactToPrismaUser") - passwordResets PrismaPasswordReset[] @relation(name: "PrismaPasswordResetToPrismaUser") - apiKeys PrismaApiKey[] @relation(name: "PrismaApiKeyToPrismaUser") - loginProviders PrismaLoginProvider[] @relation(name: "PrismaUserToPrismaLoginProvider") - passwordHash String @map("password_hash") - passwordSalt String @map("password_salt") - firstName String @map("first_name") - lastName String @map("last_name") - class String - photoUrl String? @map("photo_url") - email String @unique - phone String? - address String? - zipCode String? @map("zip_code") - website String? - luCard String? @unique - dateJoined DateTime @default(now()) @map("date_joined") - verifyInfo PrismaVerifyInfo? @relation(name: "PrismaVerifyInfoToPrismaUser") + username String @id + access PrismaIndividualAccess[] @relation(name: "PrismaIndividualAccessToPrismaUser") + grantedIndividualAccessLog PrismaIndividualAccessLog[] @relation(name: "PrismaIndividualAccessLogToPrismaUserGrantor") + grantedPostAccessLog PrismaPostAccessLog[] @relation(name: "PrismaPostAccessLogToPrismaUserGrantor") + targetIndividualAccessLog PrismaIndividualAccessLog[] @relation(name: "PrismaIndividualAccessLogToPrismaUserTarget") + articles PrismaArticle[] @relation(name: "PrismaArticleToAuthor") + editedArticles PrismaArticle[] @relation(name: "PrismaArticleToLastUpdateBy") + elections PrismaElection[] @relation(name: "PrismaElectionToPrismaUser") + nominations PrismaNomination[] @relation(name: "PrismaNominationToPrismaUser") + proposals PrismaProposal[] @relation(name: "PrismaProposalToPrismaUser") + files PrismaFile[] @relation(name: "PrismaFileToPrismaUser") + heHes PrismaHehe[] @relation(name: "PrismaHeheToPrismaUser") + postHistory PrismaPostHistory[] @relation(name: "PrismaPostHistoryToPrismaUser") + emergencyContacts PrismaEmergencyContact[] @relation(name: "PrismaEmergencyContactToPrismaUser") + passwordResets PrismaPasswordReset[] @relation(name: "PrismaPasswordResetToPrismaUser") + apiKeys PrismaApiKey[] @relation(name: "PrismaApiKeyToPrismaUser") + loginProviders PrismaLoginProvider[] @relation(name: "PrismaUserToPrismaLoginProvider") + passwordHash String @map("password_hash") + passwordSalt String @map("password_salt") + firstName String @map("first_name") + lastName String @map("last_name") + class String + photoUrl String? @map("photo_url") + email String @unique + phone String? + address String? + zipCode String? @map("zip_code") + website String? + luCard String? @unique + dateJoined DateTime @default(now()) @map("date_joined") + verifyInfo PrismaVerifyInfo? @relation(name: "PrismaVerifyInfoToPrismaUser") @@index([firstName, lastName]) @@map("users") @@ -88,6 +89,7 @@ model PrismaPostAccessLog { resource String isActive Boolean @map("is_active") timestamp DateTime @default(now()) + @@map("post_accesses_log") } @@ -100,10 +102,10 @@ model PrismaPost { history PrismaPostHistory[] @relation(name: "PrismaPostToPrismaPostHistory") sortPriority Int @default(0) postname String @unique - email String? - utskott PrismaUtskott - description String - spots Int + email String? + utskott PrismaUtskott + description String + spots Int postType PrismaPostType @map("post_type") active Boolean @default(true) interviewRequired Boolean @default(false) @map("interview_required") @@ -211,6 +213,7 @@ model PrismaNomination { model PrismaActivity { id String @id @default(cuid()) + hidden Boolean @default(false) source PrismaActivitySource title String description String? diff --git a/src/api/activity.api.ts b/src/api/activity.api.ts index bdaecee3..bb783566 100644 --- a/src/api/activity.api.ts +++ b/src/api/activity.api.ts @@ -24,6 +24,7 @@ export class ActivityAPI { from: Date, to: Date, utskott: Utskott[] = [Utskott.Other], + hidden = false, ): Promise { const activities = await prisma.prismaActivity.findMany({ where: { @@ -38,7 +39,12 @@ export class ActivityAPI { }, { AND: [{ startDate: { gte: from } }, { endDate: null }] }, ], - AND: { utskott: { in: utskott } }, + AND: [ + { utskott: { in: utskott } }, + { + OR: [{ hidden: false }, { hidden: true, ...(hidden ? {} : { hidden: false }) }], + }, + ], }, orderBy: { startDate: 'asc' }, }); @@ -72,6 +78,7 @@ export class ActivityAPI { imageUrl: activity.imageUrl, locationTitle: activity.location?.title, locationLink: activity.location?.link, + hidden: activity.hidden ?? false, }, }); diff --git a/src/models/generated/graphql.ts b/src/models/generated/graphql.ts index 28c9de89..dbb52e9e 100644 --- a/src/models/generated/graphql.ts +++ b/src/models/generated/graphql.ts @@ -1,19 +1,6 @@ import type { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; - +import type { ArticleResponse, FileResponse, MeetingResponse, ElectionResponse, ProposalResponse, NominationResponse, HeheResponse, AccessLogPostResponse, AccessLogIndividualAccessResponse, ApiKeyResponse } from '../mappers'; import type { Context } from '../context'; -import type { - ArticleResponse, - FileResponse, - MeetingResponse, - ElectionResponse, - ProposalResponse, - NominationResponse, - HeheResponse, - AccessLogPostResponse, - AccessLogIndividualAccessResponse, - ApiKeyResponse, -} from '../mappers'; - export type Maybe = T | null; export type InputMaybe = Maybe; export type Exact = { [K in keyof T]: T[K] }; @@ -66,18 +53,19 @@ export type AccessLogPost = { export enum AccessResourceType { Door = 'door', - Feature = 'feature', + Feature = 'feature' } export enum AccessType { Admin = 'ADMIN', Authenticated = 'AUTHENTICATED', - Public = 'PUBLIC', + Public = 'PUBLIC' } export type Activity = { description?: Maybe; endDate?: Maybe; + hidden: Scalars['Boolean']; id: Scalars['String']; imageUrl?: Maybe; location?: Maybe; @@ -90,7 +78,7 @@ export type Activity = { export enum ActivitySource { Orbi = 'ORBI', Other = 'OTHER', - Website = 'WEBSITE', + Website = 'WEBSITE' } export type ApiKey = { @@ -117,6 +105,7 @@ export type Article = { title: Scalars['String']; }; + /** Body is saved as HTML serversInte, but edited in MarkDown */ export type ArticleTagsArgs = { includeSpecial?: InputMaybe; @@ -125,7 +114,7 @@ export type ArticleTagsArgs = { /** News are the ones to be used by a website newsreel */ export enum ArticleType { Information = 'INFORMATION', - News = 'NEWS', + News = 'NEWS' } export type CasLoginResponse = { @@ -149,7 +138,7 @@ export enum Door { Pa = 'pa', Pump = 'pump', Sikrit = 'sikrit', - Ulla = 'ulla', + Ulla = 'ulla' } export type DoorInfo = { @@ -186,7 +175,7 @@ export enum EmergencyContactType { Mom = 'MOM', Other = 'OTHER', SignificantOther = 'SIGNIFICANT_OTHER', - Sister = 'SISTER', + Sister = 'SISTER' } /** Features are used for mapping access to a feature (ex article or election) for user or a post. This is not limited to efterphest */ @@ -204,7 +193,7 @@ export enum Feature { NewsEditor = 'news_editor', PostAdmin = 'post_admin', Superadmin = 'superadmin', - UserAdmin = 'user_admin', + UserAdmin = 'user_admin' } export type FeatureInfo = { @@ -242,7 +231,7 @@ export enum FileType { Pdf = 'PDF', Powerpoint = 'POWERPOINT', Spreadsheet = 'SPREADSHEET', - Text = 'TEXT', + Text = 'TEXT' } export type GroupedPost = { @@ -318,7 +307,7 @@ export enum MeetingDocumentType { LateDocuments = 'lateDocuments', Protocol = 'protocol', /** Kallelse */ - Summons = 'summons', + Summons = 'summons' } export enum MeetingType { @@ -337,12 +326,13 @@ export enum MeetingType { /** Valmöte */ Vm = 'VM', /** Vårterminsmöte */ - Vtm = 'VTM', + Vtm = 'VTM' } export type ModifiedActivity = { description?: InputMaybe; endDate?: InputMaybe; + hidden?: InputMaybe; imageUrl?: InputMaybe; location?: InputMaybe; startDate?: InputMaybe; @@ -452,55 +442,66 @@ export type Mutation = { verifyUser: Scalars['Boolean']; }; + export type MutationActivatePostArgs = { id: Scalars['Int']; }; + export type MutationAddActivityArgs = { activity: NewActivity; }; + export type MutationAddArticleArgs = { entry: NewArticle; }; + export type MutationAddElectablesArgs = { electionId: Scalars['Int']; postIds: Array; }; + export type MutationAddEmergencyContactArgs = { name: Scalars['String']; phone: Scalars['String']; type: EmergencyContactType; }; + export type MutationAddFileToMeetingArgs = { fileId: Scalars['String']; fileType: MeetingDocumentType; meetingId: Scalars['Int']; }; + export type MutationAddHeheArgs = { fileId: Scalars['ID']; number: Scalars['Int']; year: Scalars['Int']; }; + export type MutationAddMeetingArgs = { number?: InputMaybe; type: MeetingType; year?: InputMaybe; }; + export type MutationAddPostArgs = { info: NewPost; }; + export type MutationAddTicketArgs = { ticket: NewTicket; }; + export type MutationAddUsersToPostArgs = { end?: InputMaybe; id: Scalars['Int']; @@ -508,222 +509,270 @@ export type MutationAddUsersToPostArgs = { usernames: Array; }; + export type MutationCasCreateUserArgs = { hash: Scalars['String']; input: NewUser; }; + export type MutationCasLoginArgs = { token: Scalars['String']; }; + export type MutationChangePasswordArgs = { newPassword: Scalars['String']; oldPassword: Scalars['String']; }; + export type MutationCreateApiKeyArgs = { description: Scalars['String']; }; + export type MutationCreateElectionArgs = { electables: Array; nominationsHidden: Scalars['Boolean']; }; + export type MutationCreateFolderArgs = { name: Scalars['String']; path: Scalars['String']; }; + export type MutationCreateUserArgs = { input: NewUser; }; + export type MutationDeactivatePostArgs = { id: Scalars['Int']; }; + export type MutationDeleteApiKeyArgs = { key: Scalars['String']; }; + export type MutationDeleteFileArgs = { id: Scalars['ID']; }; + export type MutationForgetUserArgs = { username: Scalars['String']; }; + export type MutationIssueTokensArgs = { username: Scalars['String']; }; + export type MutationLinkLoginProviderArgs = { input: ProviderOptions; }; + export type MutationLoginArgs = { password: Scalars['String']; username: Scalars['String']; }; + export type MutationModifyActivityArgs = { entry: ModifiedActivity; id: Scalars['String']; }; + export type MutationModifyArticleArgs = { articleId: Scalars['Int']; entry: ModifyArticle; }; + export type MutationModifyPostArgs = { info: ModifyPost; }; + export type MutationModifyTicketArgs = { entry: ModifiedTicket; id: Scalars['String']; }; + export type MutationNominateArgs = { postIds: Array; username: Scalars['String']; }; + export type MutationOpenElectionArgs = { electionId: Scalars['Int']; }; + export type MutationProposeArgs = { electionId: Scalars['Int']; postId: Scalars['Int']; username: Scalars['String']; }; + export type MutationProviderLoginArgs = { input: ProviderOptions; }; + export type MutationRefreshArgs = { refreshToken: Scalars['String']; }; + export type MutationRemoveActivityArgs = { id: Scalars['String']; }; + export type MutationRemoveArticleArgs = { articleId: Scalars['Int']; }; + export type MutationRemoveElectablesArgs = { electionId: Scalars['Int']; postIds: Array; }; + export type MutationRemoveEmergencyContactArgs = { id: Scalars['Int']; }; + export type MutationRemoveFileFromMeetingArgs = { fileType: MeetingDocumentType; meetingId: Scalars['Int']; }; + export type MutationRemoveHeheArgs = { number: Scalars['Int']; year: Scalars['Int']; }; + export type MutationRemoveHistoryEntryArgs = { id: Scalars['Int']; }; + export type MutationRemoveMeetingArgs = { id: Scalars['Int']; }; + export type MutationRemoveProposalArgs = { electionId: Scalars['Int']; postId: Scalars['Int']; username: Scalars['String']; }; + export type MutationRemoveTicketArgs = { id: Scalars['String']; }; + export type MutationRequestPasswordResetArgs = { resetLink: Scalars['String']; returnTo?: InputMaybe; username: Scalars['String']; }; + export type MutationResetPasswordArgs = { password: Scalars['String']; token: Scalars['String']; username: Scalars['String']; }; + export type MutationRespondToNominationArgs = { accepts: NominationAnswer; postId: Scalars['Int']; }; + export type MutationSendEmailArgs = { options: SendEmailOptions; }; + export type MutationSetApiKeyAccessArgs = { access: AccessInput; key: Scalars['String']; }; + export type MutationSetElectablesArgs = { electionId: Scalars['Int']; postIds: Array; }; + export type MutationSetHiddenNominationsArgs = { electionId: Scalars['Int']; hidden: Scalars['Boolean']; }; + export type MutationSetIndividualAccessArgs = { access: AccessInput; username: Scalars['String']; }; + export type MutationSetPostAccessArgs = { access: AccessInput; postId: Scalars['Int']; }; + export type MutationSetUserPostEndArgs = { end: Scalars['Date']; id: Scalars['Int']; }; + export type MutationUnlinkLoginProviderArgs = { id: Scalars['Int']; }; + export type MutationUpdateUserArgs = { input: UpdateUser; }; + export type MutationValidatePasswordResetTokenArgs = { token: Scalars['String']; username: Scalars['String']; }; + export type MutationValidateTokenArgs = { token: Scalars['String']; }; + export type MutationVerifyUserArgs = { ssn: Scalars['String']; username: Scalars['String']; @@ -732,6 +781,7 @@ export type MutationVerifyUserArgs = { export type NewActivity = { description?: InputMaybe; endDate?: InputMaybe; + hidden?: InputMaybe; imageUrl?: InputMaybe; location?: InputMaybe; startDate: Scalars['DateTime']; @@ -796,12 +846,12 @@ export type Nomination = { export enum NominationAnswer { No = 'NO', NotAnswered = 'NOT_ANSWERED', - Yes = 'YES', + Yes = 'YES' } export enum Order { Asc = 'asc', - Desc = 'desc', + Desc = 'desc' } export type PageInfo = { @@ -849,6 +899,7 @@ export type Post = { utskott: Utskott; }; + export type PostHistoryArgs = { current?: InputMaybe; }; @@ -865,7 +916,7 @@ export enum PostType { /** Upp till _n_ stycken */ N = 'N', /** Unik, finns bara 1, t.ex. utskottsordförande */ - U = 'U', + U = 'U' } /** Valberedningens förslag */ @@ -937,16 +988,19 @@ export type Query = { utskott: Utskott; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. */ export type QueryActivitiesArgs = { from: Scalars['DateTime']; + hidden: Scalars['Boolean']; to: Scalars['DateTime']; utskott: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -955,6 +1009,7 @@ export type QueryActivityArgs = { id: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -963,6 +1018,7 @@ export type QueryApiKeyArgs = { key: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -972,6 +1028,7 @@ export type QueryArticleArgs = { slug?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -983,6 +1040,7 @@ export type QueryArticlesArgs = { type?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -991,6 +1049,7 @@ export type QueryElectionArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -999,6 +1058,7 @@ export type QueryElectionsArgs = { electionIds: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1007,6 +1067,7 @@ export type QueryFileArgs = { id: Scalars['ID']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1015,6 +1076,7 @@ export type QueryFileSystemArgs = { folder: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1023,6 +1085,7 @@ export type QueryFilesArgs = { type?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1031,6 +1094,7 @@ export type QueryGroupedPostsArgs = { includeInactive?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1040,6 +1104,7 @@ export type QueryHeheArgs = { year: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1048,6 +1113,7 @@ export type QueryHehesArgs = { year: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1057,6 +1123,7 @@ export type QueryHiddenNominationsArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1065,6 +1132,7 @@ export type QueryIndividualAccessArgs = { username: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1073,6 +1141,7 @@ export type QueryLatestBoardMeetingsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1083,6 +1152,7 @@ export type QueryLatestElectionsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1092,6 +1162,7 @@ export type QueryLatestHeheArgs = { sortOrder?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1100,6 +1171,7 @@ export type QueryLatestnewsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1108,6 +1180,7 @@ export type QueryLatexifyArgs = { text: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1116,6 +1189,7 @@ export type QueryMeetingArgs = { id: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1126,6 +1200,7 @@ export type QueryMeetingsArgs = { year?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1135,6 +1210,7 @@ export type QueryMyNominationsArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1145,6 +1221,7 @@ export type QueryNewsentriesArgs = { before?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1153,6 +1230,7 @@ export type QueryNumberOfMembersArgs = { noAlumni?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1162,6 +1240,7 @@ export type QueryNumberOfNominationsArgs = { postId?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1171,6 +1250,7 @@ export type QueryNumberOfProposalsArgs = { postId?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1179,6 +1259,7 @@ export type QueryNumberOfVolunteersArgs = { date?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1187,6 +1268,7 @@ export type QueryPaginatedHehesArgs = { pagination?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1195,6 +1277,7 @@ export type QueryPostArgs = { id: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1203,6 +1286,7 @@ export type QueryPostAccessArgs = { postId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1212,6 +1296,7 @@ export type QueryPostsArgs = { utskott?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1220,6 +1305,7 @@ export type QuerySearchFilesArgs = { search: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1228,6 +1314,7 @@ export type QuerySearchUserArgs = { search: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1236,6 +1323,7 @@ export type QueryTicketArgs = { id: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1244,6 +1332,7 @@ export type QueryTicketsArgs = { activityID?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1252,6 +1341,7 @@ export type QueryUserArgs = { username: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1260,6 +1350,7 @@ export type QueryUserByCardArgs = { luCard: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1268,6 +1359,7 @@ export type QueryUsersArgs = { usernames: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1286,7 +1378,7 @@ export type SendEmailOptions = { export enum SortOrder { Asc = 'asc', - Desc = 'desc', + Desc = 'desc' } export type Ticket = { @@ -1339,6 +1431,7 @@ export type User = { zipCode?: Maybe; }; + export type UserPostHistoryArgs = { current?: InputMaybe; }; @@ -1361,7 +1454,7 @@ export enum Utskott { Other = 'OTHER', Pengu = 'PENGU', Sre = 'SRE', - Styrelsen = 'STYRELSEN', + Styrelsen = 'STYRELSEN' } export type WithIndex = TObject & Record; @@ -1369,41 +1462,34 @@ export type ResolversObject = WithIndex; export type ResolverTypeWrapper = Promise | T; + export type ResolverWithResolve = { resolve: ResolverFn; }; -export type Resolver = - | ResolverFn - | ResolverWithResolve; +export type Resolver = ResolverFn | ResolverWithResolve; export type ResolverFn = ( parent: TParent, args: TArgs, context: TContext, - info: GraphQLResolveInfo, + info: GraphQLResolveInfo ) => Promise | TResult; export type SubscriptionSubscribeFn = ( parent: TParent, args: TArgs, context: TContext, - info: GraphQLResolveInfo, + info: GraphQLResolveInfo ) => AsyncIterable | Promise>; export type SubscriptionResolveFn = ( parent: TParent, args: TArgs, context: TContext, - info: GraphQLResolveInfo, + info: GraphQLResolveInfo ) => TResult | Promise; -export interface SubscriptionSubscriberObject< - TResult, - TKey extends string, - TParent, - TContext, - TArgs, -> { +export interface SubscriptionSubscriberObject { subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>; resolve?: SubscriptionResolveFn; } @@ -1417,27 +1503,17 @@ export type SubscriptionObject | SubscriptionResolverObject; -export type SubscriptionResolver< - TResult, - TKey extends string, - TParent = {}, - TContext = {}, - TArgs = {}, -> = +export type SubscriptionResolver = | ((...args: any[]) => SubscriptionObject) | SubscriptionObject; export type TypeResolveFn = ( parent: TParent, context: TContext, - info: GraphQLResolveInfo, + info: GraphQLResolveInfo ) => Maybe | Promise>; -export type IsTypeOfResolverFn = ( - obj: T, - context: TContext, - info: GraphQLResolveInfo, -) => boolean | Promise; +export type IsTypeOfResolverFn = (obj: T, context: TContext, info: GraphQLResolveInfo) => boolean | Promise; export type NextResolverFn = () => Promise; @@ -1446,7 +1522,7 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping between all available schema types and the resolvers types */ @@ -1474,9 +1550,7 @@ export type ResolversTypes = ResolversObject<{ Feature: Feature; FeatureInfo: ResolverTypeWrapper; File: ResolverTypeWrapper; - FileSystemResponse: ResolverTypeWrapper< - Omit & { files: Array } - >; + FileSystemResponse: ResolverTypeWrapper & { files: Array }>; FileSystemResponsePath: ResolverTypeWrapper; FileType: FileType; GroupedPost: ResolverTypeWrapper; @@ -1506,9 +1580,7 @@ export type ResolversTypes = ResolversObject<{ Object: ResolverTypeWrapper; Order: Order; PageInfo: ResolverTypeWrapper; - PaginatedHehes: ResolverTypeWrapper< - Omit & { values: Array } - >; + PaginatedHehes: ResolverTypeWrapper & { values: Array }>; Pagination: ResolversTypes['PaginatedHehes']; PaginationParams: PaginationParams; Post: ResolverTypeWrapper; @@ -1545,9 +1617,7 @@ export type ResolversParentTypes = ResolversObject<{ EmergencyContact: EmergencyContact; FeatureInfo: FeatureInfo; File: FileResponse; - FileSystemResponse: Omit & { - files: Array; - }; + FileSystemResponse: Omit & { files: Array }; FileSystemResponsePath: FileSystemResponsePath; GroupedPost: GroupedPost; Hehe: HeheResponse; @@ -1588,19 +1658,13 @@ export type ResolversParentTypes = ResolversObject<{ UserPostHistoryEntry: UserPostHistoryEntry; }>; -export type AccessResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Access'] = ResolversParentTypes['Access'], -> = ResolversObject<{ +export type AccessResolvers = ResolversObject<{ doors?: Resolver, ParentType, ContextType>; features?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }>; -export type AccessLogIndividualAccessResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['AccessLogIndividualAccess'] = ResolversParentTypes['AccessLogIndividualAccess'], -> = ResolversObject<{ +export type AccessLogIndividualAccessResolvers = ResolversObject<{ grantor?: Resolver; isActive?: Resolver; resource?: Resolver; @@ -1610,10 +1674,7 @@ export type AccessLogIndividualAccessResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type AccessLogPostResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['AccessLogPost'] = ResolversParentTypes['AccessLogPost'], -> = ResolversObject<{ +export type AccessLogPostResolvers = ResolversObject<{ grantor?: Resolver; isActive?: Resolver; resource?: Resolver; @@ -1623,12 +1684,10 @@ export type AccessLogPostResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type ActivityResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Activity'] = ResolversParentTypes['Activity'], -> = ResolversObject<{ +export type ActivityResolvers = ResolversObject<{ description?: Resolver, ParentType, ContextType>; endDate?: Resolver, ParentType, ContextType>; + hidden?: Resolver; id?: Resolver; imageUrl?: Resolver, ParentType, ContextType>; location?: Resolver, ParentType, ContextType>; @@ -1639,10 +1698,7 @@ export type ActivityResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type ApiKeyResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['ApiKey'] = ResolversParentTypes['ApiKey'], -> = ResolversObject<{ +export type ApiKeyResolvers = ResolversObject<{ access?: Resolver; creator?: Resolver; description?: Resolver; @@ -1650,10 +1706,7 @@ export type ApiKeyResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type ArticleResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Article'] = ResolversParentTypes['Article'], -> = ResolversObject<{ +export type ArticleResolvers = ResolversObject<{ articleType?: Resolver; author?: Resolver; body?: Resolver; @@ -1663,20 +1716,12 @@ export type ArticleResolvers< lastUpdatedBy?: Resolver; signature?: Resolver; slug?: Resolver; - tags?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + tags?: Resolver, ParentType, ContextType, Partial>; title?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type CasLoginResponseResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['CasLoginResponse'] = ResolversParentTypes['CasLoginResponse'], -> = ResolversObject<{ +export type CasLoginResponseResolvers = ResolversObject<{ exists?: Resolver; hash?: Resolver; username?: Resolver; @@ -1687,24 +1732,17 @@ export interface DateScalarConfig extends GraphQLScalarTypeConfig { +export interface DateTimeScalarConfig extends GraphQLScalarTypeConfig { name: 'DateTime'; } -export type DoorInfoResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['DoorInfo'] = ResolversParentTypes['DoorInfo'], -> = ResolversObject<{ +export type DoorInfoResolvers = ResolversObject<{ description?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type ElectionResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Election'] = ResolversParentTypes['Election'], -> = ResolversObject<{ +export type ElectionResolvers = ResolversObject<{ acceptedNominations?: Resolver, ParentType, ContextType>; closedAt?: Resolver, ParentType, ContextType>; createdAt?: Resolver; @@ -1718,10 +1756,7 @@ export type ElectionResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type EmergencyContactResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['EmergencyContact'] = ResolversParentTypes['EmergencyContact'], -> = ResolversObject<{ +export type EmergencyContactResolvers = ResolversObject<{ id?: Resolver; name?: Resolver; phone?: Resolver; @@ -1729,19 +1764,13 @@ export type EmergencyContactResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type FeatureInfoResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['FeatureInfo'] = ResolversParentTypes['FeatureInfo'], -> = ResolversObject<{ +export type FeatureInfoResolvers = ResolversObject<{ description?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type FileResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['File'] = ResolversParentTypes['File'], -> = ResolversObject<{ +export type FileResolvers = ResolversObject<{ accessType?: Resolver; createdAt?: Resolver, ParentType, ContextType>; createdBy?: Resolver, ParentType, ContextType>; @@ -1754,37 +1783,25 @@ export type FileResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type FileSystemResponseResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['FileSystemResponse'] = ResolversParentTypes['FileSystemResponse'], -> = ResolversObject<{ +export type FileSystemResponseResolvers = ResolversObject<{ files?: Resolver, ParentType, ContextType>; path?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }>; -export type FileSystemResponsePathResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['FileSystemResponsePath'] = ResolversParentTypes['FileSystemResponsePath'], -> = ResolversObject<{ +export type FileSystemResponsePathResolvers = ResolversObject<{ id?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type GroupedPostResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['GroupedPost'] = ResolversParentTypes['GroupedPost'], -> = ResolversObject<{ +export type GroupedPostResolvers = ResolversObject<{ posts?: Resolver, ParentType, ContextType>; utskott?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type HeheResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Hehe'] = ResolversParentTypes['Hehe'], -> = ResolversObject<{ +export type HeheResolvers = ResolversObject<{ coverEndpoint?: Resolver; coverId?: Resolver; file?: Resolver; @@ -1795,10 +1812,7 @@ export type HeheResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type HistoryEntryResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['HistoryEntry'] = ResolversParentTypes['HistoryEntry'], -> = ResolversObject<{ +export type HistoryEntryResolvers = ResolversObject<{ end?: Resolver, ParentType, ContextType>; holder?: Resolver; id?: Resolver; @@ -1806,19 +1820,13 @@ export type HistoryEntryResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type LocationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Location'] = ResolversParentTypes['Location'], -> = ResolversObject<{ +export type LocationResolvers = ResolversObject<{ link?: Resolver, ParentType, ContextType>; title?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type LoginProviderResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['LoginProvider'] = ResolversParentTypes['LoginProvider'], -> = ResolversObject<{ +export type LoginProviderResolvers = ResolversObject<{ email?: Resolver, ParentType, ContextType>; id?: Resolver; provider?: Resolver; @@ -1826,20 +1834,14 @@ export type LoginProviderResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type LoginResponseResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['LoginResponse'] = ResolversParentTypes['LoginResponse'], -> = ResolversObject<{ +export type LoginResponseResolvers = ResolversObject<{ accessToken?: Resolver; refreshToken?: Resolver; user?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type MeetingResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Meeting'] = ResolversParentTypes['Meeting'], -> = ResolversObject<{ +export type MeetingResolvers = ResolversObject<{ agenda?: Resolver, ParentType, ContextType>; appendix?: Resolver, ParentType, ContextType>; documents?: Resolver, ParentType, ContextType>; @@ -1854,372 +1856,71 @@ export type MeetingResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type MutationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation'], -> = ResolversObject<{ - activatePost?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - addActivity?: Resolver< - ResolversTypes['Activity'], - ParentType, - ContextType, - RequireFields - >; - addArticle?: Resolver< - ResolversTypes['Article'], - ParentType, - ContextType, - RequireFields - >; - addElectables?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - addEmergencyContact?: Resolver< - ResolversTypes['EmergencyContact'], - ParentType, - ContextType, - RequireFields - >; - addFileToMeeting?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - addHehe?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - addMeeting?: Resolver< - ResolversTypes['Meeting'], - ParentType, - ContextType, - RequireFields - >; - addPost?: Resolver< - ResolversTypes['Post'], - ParentType, - ContextType, - RequireFields - >; - addTicket?: Resolver< - ResolversTypes['Ticket'], - ParentType, - ContextType, - RequireFields - >; - addUsersToPost?: Resolver< - ResolversTypes['Post'], - ParentType, - ContextType, - RequireFields - >; - casCreateUser?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - casLogin?: Resolver< - ResolversTypes['CasLoginResponse'], - ParentType, - ContextType, - RequireFields - >; - changePassword?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; +export type MutationResolvers = ResolversObject<{ + activatePost?: Resolver>; + addActivity?: Resolver>; + addArticle?: Resolver>; + addElectables?: Resolver>; + addEmergencyContact?: Resolver>; + addFileToMeeting?: Resolver>; + addHehe?: Resolver>; + addMeeting?: Resolver>; + addPost?: Resolver>; + addTicket?: Resolver>; + addUsersToPost?: Resolver>; + casCreateUser?: Resolver>; + casLogin?: Resolver>; + changePassword?: Resolver>; closeElection?: Resolver; - createApiKey?: Resolver< - ResolversTypes['String'], - ParentType, - ContextType, - RequireFields - >; - createElection?: Resolver< - ResolversTypes['Election'], - ParentType, - ContextType, - RequireFields - >; - createFolder?: Resolver< - ResolversTypes['File'], - ParentType, - ContextType, - RequireFields - >; - createUser?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - deactivatePost?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - deleteApiKey?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - deleteFile?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - forgetUser?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - issueTokens?: Resolver< - ResolversTypes['TokenResponse'], - ParentType, - ContextType, - RequireFields - >; - linkLoginProvider?: Resolver< - ResolversTypes['LoginProvider'], - ParentType, - ContextType, - RequireFields - >; - login?: Resolver< - ResolversTypes['LoginResponse'], - ParentType, - ContextType, - RequireFields - >; + createApiKey?: Resolver>; + createElection?: Resolver>; + createFolder?: Resolver>; + createUser?: Resolver>; + deactivatePost?: Resolver>; + deleteApiKey?: Resolver>; + deleteFile?: Resolver>; + forgetUser?: Resolver>; + issueTokens?: Resolver>; + linkLoginProvider?: Resolver>; + login?: Resolver>; logout?: Resolver; - modifyActivity?: Resolver< - ResolversTypes['Activity'], - ParentType, - ContextType, - RequireFields - >; - modifyArticle?: Resolver< - ResolversTypes['Article'], - ParentType, - ContextType, - RequireFields - >; - modifyPost?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - modifyTicket?: Resolver< - ResolversTypes['Ticket'], - ParentType, - ContextType, - RequireFields - >; - nominate?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - openElection?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - propose?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - providerLogin?: Resolver< - ResolversTypes['LoginResponse'], - ParentType, - ContextType, - RequireFields - >; - refresh?: Resolver< - ResolversTypes['TokenResponse'], - ParentType, - ContextType, - RequireFields - >; - removeActivity?: Resolver< - ResolversTypes['Activity'], - ParentType, - ContextType, - RequireFields - >; - removeArticle?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeElectables?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeEmergencyContact?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeFileFromMeeting?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeHehe?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeHistoryEntry?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeMeeting?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeProposal?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeTicket?: Resolver< - ResolversTypes['Ticket'], - ParentType, - ContextType, - RequireFields - >; - requestPasswordReset?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - resetPassword?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - respondToNomination?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - sendEmail?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setApiKeyAccess?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setElectables?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setHiddenNominations?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setIndividualAccess?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setPostAccess?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setUserPostEnd?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - unlinkLoginProvider?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - updateUser?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - validatePasswordResetToken?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - validateToken?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - verifyUser?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; + modifyActivity?: Resolver>; + modifyArticle?: Resolver>; + modifyPost?: Resolver>; + modifyTicket?: Resolver>; + nominate?: Resolver>; + openElection?: Resolver>; + propose?: Resolver>; + providerLogin?: Resolver>; + refresh?: Resolver>; + removeActivity?: Resolver>; + removeArticle?: Resolver>; + removeElectables?: Resolver>; + removeEmergencyContact?: Resolver>; + removeFileFromMeeting?: Resolver>; + removeHehe?: Resolver>; + removeHistoryEntry?: Resolver>; + removeMeeting?: Resolver>; + removeProposal?: Resolver>; + removeTicket?: Resolver>; + requestPasswordReset?: Resolver>; + resetPassword?: Resolver>; + respondToNomination?: Resolver>; + sendEmail?: Resolver>; + setApiKeyAccess?: Resolver>; + setElectables?: Resolver>; + setHiddenNominations?: Resolver>; + setIndividualAccess?: Resolver>; + setPostAccess?: Resolver>; + setUserPostEnd?: Resolver>; + unlinkLoginProvider?: Resolver>; + updateUser?: Resolver>; + validatePasswordResetToken?: Resolver>; + validateToken?: Resolver>; + verifyUser?: Resolver>; }>; -export type NominationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Nomination'] = ResolversParentTypes['Nomination'], -> = ResolversObject<{ +export type NominationResolvers = ResolversObject<{ answer?: Resolver; post?: Resolver; user?: Resolver; @@ -2230,10 +1931,7 @@ export interface ObjectScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ +export type PageInfoResolvers = ResolversObject<{ firstPage?: Resolver; hasNextPage?: Resolver; hasPreviousPage?: Resolver; @@ -2242,37 +1940,23 @@ export type PageInfoResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type PaginatedHehesResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['PaginatedHehes'] = ResolversParentTypes['PaginatedHehes'], -> = ResolversObject<{ +export type PaginatedHehesResolvers = ResolversObject<{ pageInfo?: Resolver; values?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }>; -export type PaginationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Pagination'] = ResolversParentTypes['Pagination'], -> = ResolversObject<{ +export type PaginationResolvers = ResolversObject<{ __resolveType: TypeResolveFn<'PaginatedHehes', ParentType, ContextType>; pageInfo?: Resolver; }>; -export type PostResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Post'] = ResolversParentTypes['Post'], -> = ResolversObject<{ +export type PostResolvers = ResolversObject<{ access?: Resolver; active?: Resolver; description?: Resolver; email?: Resolver, ParentType, ContextType>; - history?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + history?: Resolver, ParentType, ContextType, Partial>; id?: Resolver; interviewRequired?: Resolver, ParentType, ContextType>; postType?: Resolver; @@ -2283,262 +1967,64 @@ export type PostResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type ProposalResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Proposal'] = ResolversParentTypes['Proposal'], -> = ResolversObject<{ +export type ProposalResolvers = ResolversObject<{ post?: Resolver; user?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type QueryResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query'], -> = ResolversObject<{ - activities?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - activity?: Resolver< - ResolversTypes['Activity'], - ParentType, - ContextType, - RequireFields - >; - apiKey?: Resolver< - ResolversTypes['ApiKey'], - ParentType, - ContextType, - RequireFields - >; +export type QueryResolvers = ResolversObject<{ + activities?: Resolver, ParentType, ContextType, RequireFields>; + activity?: Resolver>; + apiKey?: Resolver>; apiKeys?: Resolver, ParentType, ContextType>; article?: Resolver>; - articles?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + articles?: Resolver, ParentType, ContextType, Partial>; doors?: Resolver, ParentType, ContextType>; - election?: Resolver< - ResolversTypes['Election'], - ParentType, - ContextType, - RequireFields - >; - elections?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; + election?: Resolver>; + elections?: Resolver, ParentType, ContextType, RequireFields>; features?: Resolver, ParentType, ContextType>; - file?: Resolver< - ResolversTypes['File'], - ParentType, - ContextType, - RequireFields - >; - fileSystem?: Resolver< - ResolversTypes['FileSystemResponse'], - ParentType, - ContextType, - RequireFields - >; + file?: Resolver>; + fileSystem?: Resolver>; files?: Resolver, ParentType, ContextType, Partial>; - groupedPosts?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - hehe?: Resolver< - ResolversTypes['Hehe'], - ParentType, - ContextType, - RequireFields - >; - hehes?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - hiddenNominations?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - individualAccess?: Resolver< - ResolversTypes['Access'], - ParentType, - ContextType, - RequireFields - >; - individualAccessLogs?: Resolver< - Array, - ParentType, - ContextType - >; - latestBoardMeetings?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestElections?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestHehe?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestnews?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latexify?: Resolver< - ResolversTypes['String'], - ParentType, - ContextType, - RequireFields - >; + groupedPosts?: Resolver, ParentType, ContextType, Partial>; + hehe?: Resolver>; + hehes?: Resolver, ParentType, ContextType, RequireFields>; + hiddenNominations?: Resolver, ParentType, ContextType, RequireFields>; + individualAccess?: Resolver>; + individualAccessLogs?: Resolver, ParentType, ContextType>; + latestBoardMeetings?: Resolver, ParentType, ContextType, Partial>; + latestElections?: Resolver, ParentType, ContextType, Partial>; + latestHehe?: Resolver, ParentType, ContextType, Partial>; + latestnews?: Resolver, ParentType, ContextType, Partial>; + latexify?: Resolver>; me?: Resolver; - meeting?: Resolver< - ResolversTypes['Meeting'], - ParentType, - ContextType, - RequireFields - >; - meetings?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - myNominations?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - newsentries?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - numberOfMembers?: Resolver< - ResolversTypes['Int'], - ParentType, - ContextType, - Partial - >; - numberOfNominations?: Resolver< - ResolversTypes['Int'], - ParentType, - ContextType, - RequireFields - >; - numberOfProposals?: Resolver< - ResolversTypes['Int'], - ParentType, - ContextType, - RequireFields - >; - numberOfVolunteers?: Resolver< - ResolversTypes['Int'], - ParentType, - ContextType, - Partial - >; + meeting?: Resolver>; + meetings?: Resolver, ParentType, ContextType, Partial>; + myNominations?: Resolver, ParentType, ContextType, RequireFields>; + newsentries?: Resolver, ParentType, ContextType, Partial>; + numberOfMembers?: Resolver>; + numberOfNominations?: Resolver>; + numberOfProposals?: Resolver>; + numberOfVolunteers?: Resolver>; openElection?: Resolver; - paginatedHehes?: Resolver< - ResolversTypes['PaginatedHehes'], - ParentType, - ContextType, - Partial - >; - post?: Resolver< - ResolversTypes['Post'], - ParentType, - ContextType, - RequireFields - >; - postAccess?: Resolver< - ResolversTypes['Access'], - ParentType, - ContextType, - RequireFields - >; + paginatedHehes?: Resolver>; + post?: Resolver>; + postAccess?: Resolver>; postAccessLogs?: Resolver, ParentType, ContextType>; posts?: Resolver, ParentType, ContextType, Partial>; - searchFiles?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - searchUser?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - ticket?: Resolver< - ResolversTypes['Ticket'], - ParentType, - ContextType, - RequireFields - >; - tickets?: Resolver< - Array>, - ParentType, - ContextType, - Partial - >; - user?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - userByCard?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - users?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; + searchFiles?: Resolver, ParentType, ContextType, RequireFields>; + searchUser?: Resolver, ParentType, ContextType, RequireFields>; + ticket?: Resolver>; + tickets?: Resolver>, ParentType, ContextType, Partial>; + user?: Resolver>; + userByCard?: Resolver>; + users?: Resolver, ParentType, ContextType, RequireFields>; usersWithIndividualAccess?: Resolver, ParentType, ContextType>; - utskott?: Resolver< - ResolversTypes['Utskott'], - ParentType, - ContextType, - RequireFields - >; + utskott?: Resolver>; }>; -export type TicketResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Ticket'] = ResolversParentTypes['Ticket'], -> = ResolversObject<{ +export type TicketResolvers = ResolversObject<{ activityID?: Resolver, ParentType, ContextType>; count?: Resolver, ParentType, ContextType>; currency?: Resolver, ParentType, ContextType>; @@ -2548,19 +2034,13 @@ export type TicketResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type TokenResponseResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['TokenResponse'] = ResolversParentTypes['TokenResponse'], -> = ResolversObject<{ +export type TokenResponseResolvers = ResolversObject<{ accessToken?: Resolver; refreshToken?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type UserResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['User'] = ResolversParentTypes['User'], -> = ResolversObject<{ +export type UserResolvers = ResolversObject<{ access?: Resolver; address?: Resolver, ParentType, ContextType>; class?: Resolver; @@ -2573,12 +2053,7 @@ export type UserResolvers< luCard?: Resolver, ParentType, ContextType>; phone?: Resolver, ParentType, ContextType>; photoUrl?: Resolver, ParentType, ContextType>; - postHistory?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + postHistory?: Resolver, ParentType, ContextType, Partial>; posts?: Resolver, ParentType, ContextType>; username?: Resolver; verified?: Resolver; @@ -2588,10 +2063,7 @@ export type UserResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type UserPostHistoryEntryResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['UserPostHistoryEntry'] = ResolversParentTypes['UserPostHistoryEntry'], -> = ResolversObject<{ +export type UserPostHistoryEntryResolvers = ResolversObject<{ end?: Resolver, ParentType, ContextType>; post?: Resolver; start?: Resolver; @@ -2636,3 +2108,4 @@ export type Resolvers = ResolversObject<{ User?: UserResolvers; UserPostHistoryEntry?: UserPostHistoryEntryResolvers; }>; + diff --git a/src/reducers/activity.reducer.ts b/src/reducers/activity.reducer.ts index 522d4843..92f553c2 100644 --- a/src/reducers/activity.reducer.ts +++ b/src/reducers/activity.reducer.ts @@ -16,5 +16,6 @@ export const activityReducer = (dbActivity: PrismaActivity): Activity => { utskott: dbActivity.utskott as Utskott, imageUrl: dbActivity.imageUrl, location: location, + hidden: dbActivity.hidden, }; }; diff --git a/src/resolvers/activity.resolver.ts b/src/resolvers/activity.resolver.ts index d81a2c2c..b84ce736 100644 --- a/src/resolvers/activity.resolver.ts +++ b/src/resolvers/activity.resolver.ts @@ -14,9 +14,9 @@ const activityresolver: Resolvers = { return activityReducer(activity); }, - activities: async (_, { from, to, utskott }, ctx) => { + activities: async (_, { from, to, utskott, hidden }, ctx) => { await hasAuthenticated(ctx); - const activities = await activityApi.getActivities(from, to, utskott); + const activities = await activityApi.getActivities(from, to, utskott, hidden); return reduce(activities, activityReducer); }, diff --git a/src/schemas/activity.graphql b/src/schemas/activity.graphql index cde03df4..526a1dc4 100644 --- a/src/schemas/activity.graphql +++ b/src/schemas/activity.graphql @@ -4,7 +4,7 @@ scalar DateTime type Query{ activity(id: String!) : Activity! - activities(from: DateTime!, to: DateTime!, utskott: [Utskott!]!) : [Activity!]! + activities(from: DateTime!, to: DateTime!, utskott: [Utskott!]!, hidden: Boolean!) : [Activity!]! } type Mutation{ @@ -23,6 +23,7 @@ type Activity{ utskott: Utskott! imageUrl: String location: Location + hidden: Boolean! } type Location{ @@ -43,6 +44,7 @@ input NewActivity{ utskott: Utskott! imageUrl: String location: NewLocation + hidden: Boolean } input ModifiedActivity{ @@ -53,6 +55,7 @@ input ModifiedActivity{ utskott: Utskott imageUrl: String location: NewLocation + hidden: Boolean } enum ActivitySource{ From 300f6104619b6eb5002697d4ad53065706684134 Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Mon, 23 Dec 2024 22:57:18 +0100 Subject: [PATCH 2/9] forgot to commit test updates --- test/unit/activity.reducer.test.ts | 2 ++ test/unit/activityandticket.api.test.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/unit/activity.reducer.test.ts b/test/unit/activity.reducer.test.ts index 42000e0a..f2e42aaa 100644 --- a/test/unit/activity.reducer.test.ts +++ b/test/unit/activity.reducer.test.ts @@ -14,6 +14,7 @@ test('reducing valid DatabaseActivity', () => { imageUrl: null, locationTitle: 'LocationTestTitle', locationLink: 'LocationLinkTest', + hidden: false, }; const expected: Activity = { @@ -29,6 +30,7 @@ test('reducing valid DatabaseActivity', () => { title: 'LocationTestTitle', link: 'LocationLinkTest', }, + hidden: false, }; const impossibleActivity: PrismaActivity = { diff --git a/test/unit/activityandticket.api.test.ts b/test/unit/activityandticket.api.test.ts index 40a05339..38c4df45 100644 --- a/test/unit/activityandticket.api.test.ts +++ b/test/unit/activityandticket.api.test.ts @@ -24,6 +24,7 @@ const EXISTING_ACT: PrismaActivity = { imageUrl: 'Existing imageUrl', locationTitle: 'Existing location', locationLink: 'Existing link', + hidden: false, }; const DUMMY_NEWTICKET: NewTicket = { @@ -49,6 +50,7 @@ const DUMMY_PRISMAACTIVITY: PrismaActivity = { imageUrl: null, locationTitle: 'LocationTestTitle', locationLink: 'LocationLinkTest', + hidden: false, }; const DUMMY_NEWACTIVITY: NewActivity = { From 0b1e6015540b4c197383989647eb48176c3f37cd Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Fri, 3 Jan 2025 22:37:17 +0100 Subject: [PATCH 3/9] add openssl explicitly in dockerfile for prisma dependency --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 918ad01f..d6087b23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,8 @@ WORKDIR $WORKING_DIR # where available (npm@5+) COPY package*.json ./ +RUN apk add openssl + RUN npm ci # Bundle app source From 2d0aeda16d40da28c390abc8264cf733bc2f4289 Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Fri, 3 Jan 2025 22:47:22 +0100 Subject: [PATCH 4/9] added binary target to prisma schema --- prisma/schema.prisma | 1 + 1 file changed, 1 insertion(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 45422a6f..e8125bf7 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -6,6 +6,7 @@ datasource pg { generator client { provider = "prisma-client-js" previewFeatures = ["fullTextSearch"] + binaryTargets = ["native", "linux-musl"] } model PrismaIndividualAccess { From 42960e43c222e3f768415d4acbebb197385164be Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:11:39 +0100 Subject: [PATCH 5/9] undid failed fixes --- Dockerfile | 2 -- prisma/schema.prisma | 1 - 2 files changed, 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d6087b23..918ad01f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,8 +18,6 @@ WORKDIR $WORKING_DIR # where available (npm@5+) COPY package*.json ./ -RUN apk add openssl - RUN npm ci # Bundle app source diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e8125bf7..45422a6f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -6,7 +6,6 @@ datasource pg { generator client { provider = "prisma-client-js" previewFeatures = ["fullTextSearch"] - binaryTargets = ["native", "linux-musl"] } model PrismaIndividualAccess { From cfa24afd1ca33544bbe63ae8821608d0dbfda8d3 Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:30:03 +0100 Subject: [PATCH 6/9] attempt #2 of modifying the dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 918ad01f..aa44f782 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ ARG WORKING_DIR # Create app directory WORKDIR $WORKING_DIR +RUN apk add --no-cache openssl1.1-compat # Install app dependencies # A wildcard is used to ensure both package.json AND package-lock.json are copied # where available (npm@5+) @@ -44,7 +45,7 @@ WORKDIR $WORKING_DIR # Best practices # https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md -RUN apk add --no-cache tini bash +RUN apk add --no-cache tini bash openssl1.1-compat ENTRYPOINT [ "/sbin/tini", "--" ] RUN wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh; chmod +x wait-for-it.sh From b845e42e9ffa26b10c6f5336a21c332beb53035e Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:33:37 +0100 Subject: [PATCH 7/9] attempt #3 of modifying the dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index aa44f782..715dbf75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ ARG WORKING_DIR # Create app directory WORKDIR $WORKING_DIR -RUN apk add --no-cache openssl1.1-compat +RUN apk add --no-cache openssl # Install app dependencies # A wildcard is used to ensure both package.json AND package-lock.json are copied # where available (npm@5+) @@ -45,7 +45,7 @@ WORKDIR $WORKING_DIR # Best practices # https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md -RUN apk add --no-cache tini bash openssl1.1-compat +RUN apk add --no-cache tini bash openssl ENTRYPOINT [ "/sbin/tini", "--" ] RUN wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh; chmod +x wait-for-it.sh From 381b291c9f315f737a9b2cadc5ca94dbf5bd27e5 Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Sat, 4 Jan 2025 16:49:12 +0100 Subject: [PATCH 8/9] renamed hidden variable in activity schema to includeHidden --- src/api/activity.api.ts | 33 ++++++++++++++---------------- src/models/generated/graphql.ts | 4 ++-- src/resolvers/activity.resolver.ts | 4 ++-- src/schemas/activity.graphql | 2 +- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/api/activity.api.ts b/src/api/activity.api.ts index bb783566..669383da 100644 --- a/src/api/activity.api.ts +++ b/src/api/activity.api.ts @@ -24,27 +24,24 @@ export class ActivityAPI { from: Date, to: Date, utskott: Utskott[] = [Utskott.Other], - hidden = false, + includeHidden = false, ): Promise { + //Acts where (start < to) && ((end > from) || ((start > from) && (end == null))) + const dateFilters = { + startDate: { lte: to }, + OR: [{ endDate: { gte: from } }, { AND: [{ startDate: { gte: from } }, { endDate: null }] }], + }; + + //Only acts in utskott[] + const utskottFilter = { utskott: { in: utskott } }; + + //If includeHidden, get all acts, else only the visible ones + const hiddenFilter = includeHidden ? {} : { OR: [{ hidden: false }] }; + const activities = await prisma.prismaActivity.findMany({ where: { - startDate: { - lte: to, - }, - OR: [ - { - endDate: { - gte: from, - }, - }, - { AND: [{ startDate: { gte: from } }, { endDate: null }] }, - ], - AND: [ - { utskott: { in: utskott } }, - { - OR: [{ hidden: false }, { hidden: true, ...(hidden ? {} : { hidden: false }) }], - }, - ], + ...dateFilters, + AND: [utskottFilter, hiddenFilter], }, orderBy: { startDate: 'asc' }, }); diff --git a/src/models/generated/graphql.ts b/src/models/generated/graphql.ts index dbb52e9e..74d1e9e8 100644 --- a/src/models/generated/graphql.ts +++ b/src/models/generated/graphql.ts @@ -995,7 +995,7 @@ export type Query = { */ export type QueryActivitiesArgs = { from: Scalars['DateTime']; - hidden: Scalars['Boolean']; + includeHidden: Scalars['Boolean']; to: Scalars['DateTime']; utskott: Array; }; @@ -1974,7 +1974,7 @@ export type ProposalResolvers; export type QueryResolvers = ResolversObject<{ - activities?: Resolver, ParentType, ContextType, RequireFields>; + activities?: Resolver, ParentType, ContextType, RequireFields>; activity?: Resolver>; apiKey?: Resolver>; apiKeys?: Resolver, ParentType, ContextType>; diff --git a/src/resolvers/activity.resolver.ts b/src/resolvers/activity.resolver.ts index b84ce736..13e4e720 100644 --- a/src/resolvers/activity.resolver.ts +++ b/src/resolvers/activity.resolver.ts @@ -14,9 +14,9 @@ const activityresolver: Resolvers = { return activityReducer(activity); }, - activities: async (_, { from, to, utskott, hidden }, ctx) => { + activities: async (_, { from, to, utskott, includeHidden }, ctx) => { await hasAuthenticated(ctx); - const activities = await activityApi.getActivities(from, to, utskott, hidden); + const activities = await activityApi.getActivities(from, to, utskott, includeHidden); return reduce(activities, activityReducer); }, diff --git a/src/schemas/activity.graphql b/src/schemas/activity.graphql index 526a1dc4..4904715f 100644 --- a/src/schemas/activity.graphql +++ b/src/schemas/activity.graphql @@ -4,7 +4,7 @@ scalar DateTime type Query{ activity(id: String!) : Activity! - activities(from: DateTime!, to: DateTime!, utskott: [Utskott!]!, hidden: Boolean!) : [Activity!]! + activities(from: DateTime!, to: DateTime!, utskott: [Utskott!]!, includeHidden: Boolean!) : [Activity!]! } type Mutation{ From e4a79d68bab885d75b5e7db7fc4c640ce6c7e706 Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:13:43 +0100 Subject: [PATCH 9/9] made includeHidden optional per Froborg's good suggestion :) --- src/resolvers/activity.resolver.ts | 2 +- src/schemas/activity.graphql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resolvers/activity.resolver.ts b/src/resolvers/activity.resolver.ts index 13e4e720..eae4e8ad 100644 --- a/src/resolvers/activity.resolver.ts +++ b/src/resolvers/activity.resolver.ts @@ -16,7 +16,7 @@ const activityresolver: Resolvers = { }, activities: async (_, { from, to, utskott, includeHidden }, ctx) => { await hasAuthenticated(ctx); - const activities = await activityApi.getActivities(from, to, utskott, includeHidden); + const activities = await activityApi.getActivities(from, to, utskott, includeHidden ?? false); return reduce(activities, activityReducer); }, diff --git a/src/schemas/activity.graphql b/src/schemas/activity.graphql index 4904715f..8870f892 100644 --- a/src/schemas/activity.graphql +++ b/src/schemas/activity.graphql @@ -4,7 +4,7 @@ scalar DateTime type Query{ activity(id: String!) : Activity! - activities(from: DateTime!, to: DateTime!, utskott: [Utskott!]!, includeHidden: Boolean!) : [Activity!]! + activities(from: DateTime!, to: DateTime!, utskott: [Utskott!]!, includeHidden: Boolean) : [Activity!]! } type Mutation{