From c8630cd28dac211f40c012bf0c11720bb071b895 Mon Sep 17 00:00:00 2001 From: pontus Date: Sat, 14 Oct 2023 15:41:59 +0200 Subject: [PATCH 01/20] adds gql schema for invidualDoorAcess and postDoorAccess --- package-lock.json | 4 ++-- src/schemas/access.graphql | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 286f9153..96244aa4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ekorre-ts", - "version": "1.3.0", + "version": "1.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ekorre-ts", - "version": "1.3.0", + "version": "1.4.0", "license": "AGPL-3.0-only", "dependencies": { "@esek/auth-server": "5.0.2", diff --git a/src/schemas/access.graphql b/src/schemas/access.graphql index 91eb3183..226e236f 100644 --- a/src/schemas/access.graphql +++ b/src/schemas/access.graphql @@ -4,6 +4,8 @@ type Query { individualAccess(username: String!): Access! postAccess(postId: Int!): Access! + individualDoorAccess(door: Door!): [User!]! + postDoorAccess(door: Door!): [User!]! features: [FeatureInfo!]! doors: [DoorInfo!]! } From a61bcfc2778b5d8e2b3e0165167d03d273eb97a7 Mon Sep 17 00:00:00 2001 From: pontus Date: Sun, 15 Oct 2023 10:38:53 +0200 Subject: [PATCH 02/20] adds api function for getting individual access for a door --- src/api/access.api.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/api/access.api.ts b/src/api/access.api.ts index 53a3a341..b2ac83cc 100644 --- a/src/api/access.api.ts +++ b/src/api/access.api.ts @@ -10,6 +10,7 @@ import { PrismaIndividualAccess, PrismaPostAccess, PrismaResourceType, + PrismaUser, } from '@prisma/client'; import prisma from './prisma'; @@ -41,6 +42,20 @@ export class AccessAPI { return access; } + + /** + * + * @param door target door which you want to get all individual access for + */ + async getIndividualAccessForDoor(door: Door): Promise { + const usersWithAccess = await prisma.prismaIndividualAccess.findMany({ + where: { + resource: door, + } + }) + return usersWithAccess; + } + /** * Get access for a post in alphabetical order From f1ef8547e0665c046baa357bf7d8aa2dd8d20274 Mon Sep 17 00:00:00 2001 From: pontus Date: Sun, 15 Oct 2023 17:31:42 +0200 Subject: [PATCH 03/20] Adds resolver --- src/api/access.api.ts | 13 +- src/api/prisma.ts | 1 + src/models/generated/graphql.ts | 923 +++++++++---------------------- src/resolvers/access.resolver.ts | 8 + src/schemas/access.graphql | 2 +- 5 files changed, 269 insertions(+), 678 deletions(-) diff --git a/src/api/access.api.ts b/src/api/access.api.ts index b2ac83cc..757c8047 100644 --- a/src/api/access.api.ts +++ b/src/api/access.api.ts @@ -47,10 +47,17 @@ export class AccessAPI { * * @param door target door which you want to get all individual access for */ - async getIndividualAccessForDoor(door: Door): Promise { - const usersWithAccess = await prisma.prismaIndividualAccess.findMany({ + async getIndividualAccessForDoor(door: Door): Promise { + const usersWithAccess = await prisma.prismaUser.findMany({ where: { - resource: door, + access: { + some: { + resource: door, + } + } + }, + include: { + access: true, } }) return usersWithAccess; diff --git a/src/api/prisma.ts b/src/api/prisma.ts index 7584a220..14ab0f3d 100644 --- a/src/api/prisma.ts +++ b/src/api/prisma.ts @@ -17,6 +17,7 @@ if (config.DEV) { logger.debug(`Query ${params.model ?? ''}.${params.action} took ${after - before}ms`); // eslint-disable-next-line @typescript-eslint/no-unsafe-return return result; + }); } diff --git a/src/models/generated/graphql.ts b/src/models/generated/graphql.ts index a8967222..699d7896 100644 --- a/src/models/generated/graphql.ts +++ b/src/models/generated/graphql.ts @@ -1,17 +1,6 @@ import type { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; - +import type { ArticleResponse, FileResponse, MeetingResponse, ElectionResponse, ProposalResponse, NominationResponse, HeheResponse, ApiKeyResponse } from '../mappers'; import type { Context } from '../context'; -import type { - ArticleResponse, - FileResponse, - MeetingResponse, - ElectionResponse, - ProposalResponse, - NominationResponse, - HeheResponse, - ApiKeyResponse, -} from '../mappers'; - export type Maybe = T | null; export type InputMaybe = Maybe; export type Exact = { [K in keyof T]: T[K] }; @@ -43,13 +32,13 @@ export type AccessInput = { export enum AccessResourceType { Door = 'door', - Feature = 'feature', + Feature = 'feature' } export enum AccessType { Admin = 'ADMIN', Authenticated = 'AUTHENTICATED', - Public = 'PUBLIC', + Public = 'PUBLIC' } export type ApiKey = { @@ -76,6 +65,7 @@ export type Article = { title: Scalars['String']; }; + /** Body is saved as HTML serversInte, but edited in MarkDown */ export type ArticleTagsArgs = { includeSpecial?: InputMaybe; @@ -84,7 +74,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 = { @@ -106,7 +96,7 @@ export enum Door { Pa = 'pa', Pump = 'pump', Sikrit = 'sikrit', - Ulla = 'ulla', + Ulla = 'ulla' } export type DoorInfo = { @@ -143,7 +133,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 */ @@ -158,7 +148,7 @@ export enum Feature { NewsEditor = 'news_editor', PostAdmin = 'post_admin', Superadmin = 'superadmin', - UserAdmin = 'user_admin', + UserAdmin = 'user_admin' } export type FeatureInfo = { @@ -196,7 +186,7 @@ export enum FileType { Pdf = 'PDF', Powerpoint = 'POWERPOINT', Spreadsheet = 'SPREADSHEET', - Text = 'TEXT', + Text = 'TEXT' } export type GroupedPost = { @@ -264,7 +254,7 @@ export enum MeetingDocumentType { LateDocuments = 'lateDocuments', Protocol = 'protocol', /** Kallelse */ - Summons = 'summons', + Summons = 'summons' } export enum MeetingType { @@ -277,7 +267,7 @@ export enum MeetingType { /** Valmöte */ Vm = 'VM', /** Vårterminsmöte */ - Vtm = 'VTM', + Vtm = 'VTM' } /** We don't need every part; It should already exist */ @@ -367,47 +357,56 @@ export type Mutation = { validateToken: Scalars['Boolean']; }; + export type MutationActivatePostArgs = { id: Scalars['Int']; }; + 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 MutationAddUsersToPostArgs = { end?: InputMaybe; id: Scalars['Int']; @@ -415,200 +414,243 @@ 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 MutationModifyArticleArgs = { articleId: Scalars['Int']; entry: ModifyArticle; }; + export type MutationModifyPostArgs = { info: ModifyPost; }; + 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 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 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']; }; @@ -657,7 +699,7 @@ export type Nomination = { export enum NominationAnswer { No = 'NO', NotAnswered = 'NOT_ANSWERED', - Yes = 'YES', + Yes = 'YES' } export type Post = { @@ -682,6 +724,7 @@ export type Post = { utskott: Utskott; }; + export type PostHistoryArgs = { current?: InputMaybe; }; @@ -698,7 +741,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 */ @@ -735,6 +778,7 @@ export type Query = { /** Used if nominations are hidden but an election-admin wants too see nominations */ hiddenNominations: Array; individualAccess: Access; + individualDoorAccess: Array; latestBoardMeetings: Array; latestElections: Array; latestHehe: Array; @@ -752,6 +796,7 @@ export type Query = { openElection: Election; post: Post; postAccess: Access; + postDoorAccess: Array; posts: Array; searchFiles: Array; searchUser: Array; @@ -761,6 +806,7 @@ export type Query = { utskott: Utskott; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -769,6 +815,7 @@ export type QueryApiKeyArgs = { key: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -778,6 +825,7 @@ export type QueryArticleArgs = { slug?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -789,6 +837,7 @@ export type QueryArticlesArgs = { type?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -797,6 +846,7 @@ export type QueryElectionArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -805,6 +855,7 @@ export type QueryElectionsArgs = { electionIds: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -813,6 +864,7 @@ export type QueryFileArgs = { id: Scalars['ID']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -821,6 +873,7 @@ export type QueryFileSystemArgs = { folder: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -829,6 +882,7 @@ export type QueryFilesArgs = { type?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -837,6 +891,7 @@ export type QueryGroupedPostsArgs = { includeInactive?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -846,6 +901,7 @@ export type QueryHeheArgs = { year: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -854,6 +910,7 @@ export type QueryHehesArgs = { year: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -863,6 +920,7 @@ export type QueryHiddenNominationsArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -871,6 +929,16 @@ export type QueryIndividualAccessArgs = { username: Scalars['String']; }; + +/** + * Queries and mutations that relies on an election being open + * does not take an `electionId` parameter. + */ +export type QueryIndividualDoorAccessArgs = { + door: Door; +}; + + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -879,6 +947,7 @@ export type QueryLatestBoardMeetingsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -889,6 +958,7 @@ export type QueryLatestElectionsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -898,6 +968,7 @@ export type QueryLatestHeheArgs = { sortOrder?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -906,6 +977,7 @@ export type QueryLatestnewsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -914,6 +986,7 @@ export type QueryMeetingArgs = { id: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -924,6 +997,7 @@ export type QueryMeetingsArgs = { year?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -933,6 +1007,7 @@ export type QueryMyNominationsArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -943,6 +1018,7 @@ export type QueryNewsentriesArgs = { before?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -951,6 +1027,7 @@ export type QueryNumberOfMembersArgs = { noAlumni?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -960,6 +1037,7 @@ export type QueryNumberOfNominationsArgs = { postId?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -969,6 +1047,7 @@ export type QueryNumberOfProposalsArgs = { postId?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -977,6 +1056,7 @@ export type QueryNumberOfVolunteersArgs = { date?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -985,6 +1065,7 @@ export type QueryPostArgs = { id: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -993,6 +1074,16 @@ export type QueryPostAccessArgs = { postId: Scalars['Int']; }; + +/** + * Queries and mutations that relies on an election being open + * does not take an `electionId` parameter. + */ +export type QueryPostDoorAccessArgs = { + door: Door; +}; + + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1002,6 +1093,7 @@ export type QueryPostsArgs = { utskott?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1010,6 +1102,7 @@ export type QuerySearchFilesArgs = { search: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1018,6 +1111,7 @@ export type QuerySearchUserArgs = { search: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1026,6 +1120,7 @@ export type QueryUserArgs = { username: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1034,6 +1129,7 @@ export type QueryUserByCardArgs = { luCard: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1042,6 +1138,7 @@ export type QueryUsersArgs = { usernames: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1060,7 +1157,7 @@ export type SendEmailOptions = { export enum SortOrder { Asc = 'asc', - Desc = 'desc', + Desc = 'desc' } export type TokenResponse = { @@ -1103,6 +1200,7 @@ export type User = { zipCode?: Maybe; }; + export type UserPostHistoryArgs = { current?: InputMaybe; }; @@ -1125,7 +1223,7 @@ export enum Utskott { Other = 'OTHER', Pengu = 'PENGU', Sre = 'SRE', - Styrelsen = 'STYRELSEN', + Styrelsen = 'STYRELSEN' } export type WithIndex = TObject & Record; @@ -1133,41 +1231,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; } @@ -1181,27 +1272,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; @@ -1210,7 +1291,7 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping between all available schema types and the resolvers types */ @@ -1233,9 +1314,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; @@ -1286,9 +1365,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; @@ -1318,19 +1395,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 ApiKeyResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['ApiKey'] = ResolversParentTypes['ApiKey'], -> = ResolversObject<{ +export type ApiKeyResolvers = ResolversObject<{ access?: Resolver; creator?: Resolver; description?: Resolver; @@ -1338,10 +1409,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; @@ -1351,20 +1419,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; @@ -1375,19 +1435,13 @@ export interface DateScalarConfig extends GraphQLScalarTypeConfig = 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; @@ -1401,10 +1455,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; @@ -1412,19 +1463,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>; @@ -1437,37 +1482,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<{ file?: Resolver; number?: Resolver; uploader?: Resolver; @@ -1475,10 +1508,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; @@ -1486,10 +1516,7 @@ export type HistoryEntryResolvers< __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; @@ -1497,20 +1524,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>; @@ -1525,330 +1546,64 @@ export type MeetingResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type MutationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation'], -> = ResolversObject<{ - activatePost?: Resolver< - ResolversTypes['Boolean'], - 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 - >; - 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>; + addArticle?: Resolver>; + addElectables?: Resolver>; + addEmergencyContact?: Resolver>; + addFileToMeeting?: Resolver>; + addHehe?: Resolver>; + addMeeting?: Resolver>; + addPost?: 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; - modifyArticle?: Resolver< - ResolversTypes['Article'], - ParentType, - ContextType, - RequireFields - >; - modifyPost?: Resolver< - ResolversTypes['Boolean'], - 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 - >; - 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 - >; - 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 - >; + modifyArticle?: Resolver>; + modifyPost?: Resolver>; + nominate?: Resolver>; + openElection?: Resolver>; + propose?: Resolver>; + providerLogin?: Resolver>; + refresh?: Resolver>; + removeArticle?: Resolver>; + removeElectables?: Resolver>; + removeEmergencyContact?: Resolver>; + removeFileFromMeeting?: Resolver>; + removeHehe?: Resolver>; + removeHistoryEntry?: Resolver>; + removeMeeting?: Resolver>; + removeProposal?: 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>; }>; -export type NominationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Nomination'] = ResolversParentTypes['Nomination'], -> = ResolversObject<{ +export type NominationResolvers = ResolversObject<{ answer?: Resolver; post?: Resolver; user?: Resolver; @@ -1859,20 +1614,12 @@ export interface ObjectScalarConfig extends GraphQLScalarTypeConfig = 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; @@ -1883,228 +1630,63 @@ 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<{ - apiKey?: Resolver< - ResolversTypes['ApiKey'], - ParentType, - ContextType, - RequireFields - >; +export type QueryResolvers = ResolversObject<{ + 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 - >; - latestBoardMeetings?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestElections?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestHehe?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestnews?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + groupedPosts?: Resolver, ParentType, ContextType, Partial>; + hehe?: Resolver>; + hehes?: Resolver, ParentType, ContextType, RequireFields>; + hiddenNominations?: Resolver, ParentType, ContextType, RequireFields>; + individualAccess?: Resolver>; + individualDoorAccess?: Resolver, ParentType, ContextType, RequireFields>; + latestBoardMeetings?: Resolver, ParentType, ContextType, Partial>; + latestElections?: Resolver, ParentType, ContextType, Partial>; + latestHehe?: Resolver, ParentType, ContextType, Partial>; + latestnews?: Resolver, ParentType, ContextType, Partial>; 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; - post?: Resolver< - ResolversTypes['Post'], - ParentType, - ContextType, - RequireFields - >; - postAccess?: Resolver< - ResolversTypes['Access'], - ParentType, - ContextType, - RequireFields - >; + post?: Resolver>; + postAccess?: Resolver>; + postDoorAccess?: Resolver, ParentType, ContextType, RequireFields>; posts?: Resolver, ParentType, ContextType, Partial>; - searchFiles?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - searchUser?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - user?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - userByCard?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - users?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - utskott?: Resolver< - ResolversTypes['Utskott'], - ParentType, - ContextType, - RequireFields - >; + searchFiles?: Resolver, ParentType, ContextType, RequireFields>; + searchUser?: Resolver, ParentType, ContextType, RequireFields>; + user?: Resolver>; + userByCard?: Resolver>; + users?: Resolver, ParentType, ContextType, RequireFields>; + utskott?: Resolver>; }>; -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; @@ -2117,12 +1699,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; website?: Resolver, ParentType, ContextType>; @@ -2131,10 +1708,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; @@ -2170,3 +1744,4 @@ export type Resolvers = ResolversObject<{ User?: UserResolvers; UserPostHistoryEntry?: UserPostHistoryEntryResolvers; }>; + diff --git a/src/resolvers/access.resolver.ts b/src/resolvers/access.resolver.ts index fba5163a..2e4e21d4 100644 --- a/src/resolvers/access.resolver.ts +++ b/src/resolvers/access.resolver.ts @@ -1,7 +1,10 @@ +import { Context } from '@/models/context'; import { hasAccess, hasAuthenticated } from '@/util'; import { AccessAPI } from '@api/access'; import { Door, Feature, Resolvers } from '@generated/graphql'; +import { PrismaUser } from '@prisma/client'; import { accessReducer, doorReducer, featureReducer } from '@reducer/access'; +import { userReduce} from '@reducer/user'; const accessApi = new AccessAPI(); @@ -13,6 +16,11 @@ const accessresolver: Resolvers = { return accessReducer(access); }, + individualAccessForDoor: async (_: any, { door }: { door: Door }, ctx: Context) => { + await hasAuthenticated(ctx); + const users: PrismaUser[] = (await accessApi.getIndividualAccessForDoor(door)); + return users.map(userReduce); + }, postAccess: async (_, { postId }, ctx) => { await hasAuthenticated(ctx); const access = await accessApi.getPostAccess(postId); diff --git a/src/schemas/access.graphql b/src/schemas/access.graphql index 226e236f..a7fe6575 100644 --- a/src/schemas/access.graphql +++ b/src/schemas/access.graphql @@ -4,7 +4,7 @@ type Query { individualAccess(username: String!): Access! postAccess(postId: Int!): Access! - individualDoorAccess(door: Door!): [User!]! + individualAccessForDoor(door: Door!): [User!] postDoorAccess(door: Door!): [User!]! features: [FeatureInfo!]! doors: [DoorInfo!]! From 690db37defaf319d1ccc01b78f33b58cf7b87b65 Mon Sep 17 00:00:00 2001 From: pontus Date: Sun, 15 Oct 2023 17:33:26 +0200 Subject: [PATCH 04/20] Remove additon postAccess --- src/schemas/access.graphql | 1 - 1 file changed, 1 deletion(-) diff --git a/src/schemas/access.graphql b/src/schemas/access.graphql index a7fe6575..1269c1e9 100644 --- a/src/schemas/access.graphql +++ b/src/schemas/access.graphql @@ -5,7 +5,6 @@ type Query { individualAccess(username: String!): Access! postAccess(postId: Int!): Access! individualAccessForDoor(door: Door!): [User!] - postDoorAccess(door: Door!): [User!]! features: [FeatureInfo!]! doors: [DoorInfo!]! } From 181238455fcd86ae678fa452b3a311593ed09552 Mon Sep 17 00:00:00 2001 From: pontus Date: Mon, 16 Oct 2023 22:15:30 +0200 Subject: [PATCH 05/20] adds usersWithIndividualAccess --- src/api/access.api.ts | 12 +++++++++++- src/api/user.api.ts | 14 ++++++++++++++ src/resolvers/access.resolver.ts | 4 ++-- src/resolvers/user.resolver.ts | 5 +++++ src/schemas/access.graphql | 2 +- src/schemas/user.graphql | 1 + 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/api/access.api.ts b/src/api/access.api.ts index 757c8047..bf029c19 100644 --- a/src/api/access.api.ts +++ b/src/api/access.api.ts @@ -45,7 +45,7 @@ export class AccessAPI { /** * - * @param door target door which you want to get all individual access for + * @param door target door which you want to get all users with access to */ async getIndividualAccessForDoor(door: Door): Promise { const usersWithAccess = await prisma.prismaUser.findMany({ @@ -64,6 +64,16 @@ export class AccessAPI { } + async getAllIndividualAccess(): Promise { + const access = await prisma.prismaIndividualAccess.findMany({ + orderBy: { + resource: 'asc', + }, + }); + + return access; + } + /** * Get access for a post in alphabetical order * @param postId ID for the post diff --git a/src/api/user.api.ts b/src/api/user.api.ts index 100657de..aab82f77 100644 --- a/src/api/user.api.ts +++ b/src/api/user.api.ts @@ -200,6 +200,20 @@ export class UserAPI { } } + async getUsersWithIndividualAccess(): Promise { + const users = await prisma.prismaUser.findMany({ + where: { + access: { + some: {}, + }, + }, + include: { + access: true, + }, + }); + return users; + } + /** * Ensures a login is correct, and if so returns the user * @param username Username for the user diff --git a/src/resolvers/access.resolver.ts b/src/resolvers/access.resolver.ts index 2e4e21d4..a393d8b1 100644 --- a/src/resolvers/access.resolver.ts +++ b/src/resolvers/access.resolver.ts @@ -16,9 +16,9 @@ const accessresolver: Resolvers = { return accessReducer(access); }, - individualAccessForDoor: async (_: any, { door }: { door: Door }, ctx: Context) => { + individualAccessForDoor: async (_: unknown, { door }: { door: Door }, ctx: Context) => { await hasAuthenticated(ctx); - const users: PrismaUser[] = (await accessApi.getIndividualAccessForDoor(door)); + const users: PrismaUser[] = await accessApi.getIndividualAccessForDoor(door); return users.map(userReduce); }, postAccess: async (_, { postId }, ctx) => { diff --git a/src/resolvers/user.resolver.ts b/src/resolvers/user.resolver.ts index 76493060..315c02b4 100644 --- a/src/resolvers/user.resolver.ts +++ b/src/resolvers/user.resolver.ts @@ -145,6 +145,11 @@ const userResolver: Resolvers = { return reduce(users, userReduce); }, numberOfMembers: async (_, { noAlumni }) => api.getNumberOfMembers(noAlumni === true), + usersWithIndividualAccess: async (_: unknown, __: unknown, ctx: Context) => { + await hasAuthenticated(ctx); + const users = await api.getUsersWithIndividualAccess(); + return reduce(users, userReduce); + } }, Mutation: { updateUser: async (_, { input }, { getUsername }) => { diff --git a/src/schemas/access.graphql b/src/schemas/access.graphql index 1269c1e9..4eff4392 100644 --- a/src/schemas/access.graphql +++ b/src/schemas/access.graphql @@ -4,7 +4,7 @@ type Query { individualAccess(username: String!): Access! postAccess(postId: Int!): Access! - individualAccessForDoor(door: Door!): [User!] + individualAccessForDoor(door: Door!): [User!]! features: [FeatureInfo!]! doors: [DoorInfo!]! } diff --git a/src/schemas/user.graphql b/src/schemas/user.graphql index d48d2508..b83070a2 100644 --- a/src/schemas/user.graphql +++ b/src/schemas/user.graphql @@ -9,6 +9,7 @@ type Query { users(usernames: [String!]!): [User!]! userByCard(luCard: String!): User! searchUser(search: String!): [User!]! + usersWithIndividualAccess: [User!]! me: User! numberOfMembers(noAlumni: Boolean): Int! } From f81518bdafb76807295f34e3d608b9caacc00b77 Mon Sep 17 00:00:00 2001 From: pontus Date: Mon, 16 Oct 2023 22:43:22 +0200 Subject: [PATCH 06/20] adds comment --- src/api/user.api.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/user.api.ts b/src/api/user.api.ts index aab82f77..20b1d925 100644 --- a/src/api/user.api.ts +++ b/src/api/user.api.ts @@ -200,6 +200,10 @@ export class UserAPI { } } + /** + * + * @returns All users with individual access + */ async getUsersWithIndividualAccess(): Promise { const users = await prisma.prismaUser.findMany({ where: { From ec6a9e9da0ac1b894c488e472d8731128a228cba Mon Sep 17 00:00:00 2001 From: pontus Date: Mon, 16 Oct 2023 22:46:17 +0200 Subject: [PATCH 07/20] npm run perttier-format --- src/api/access.api.ts | 13 +- src/api/prisma.ts | 1 - src/api/user.api.ts | 2 +- src/models/generated/graphql.ts | 917 +++++++++++++++++++++++-------- src/resolvers/access.resolver.ts | 2 +- src/resolvers/user.resolver.ts | 2 +- 6 files changed, 695 insertions(+), 242 deletions(-) diff --git a/src/api/access.api.ts b/src/api/access.api.ts index bf029c19..5a002f2c 100644 --- a/src/api/access.api.ts +++ b/src/api/access.api.ts @@ -42,9 +42,9 @@ export class AccessAPI { return access; } - + /** - * + * * @param door target door which you want to get all users with access to */ async getIndividualAccessForDoor(door: Door): Promise { @@ -53,16 +53,15 @@ export class AccessAPI { access: { some: { resource: door, - } - } + }, + }, }, include: { access: true, - } - }) + }, + }); return usersWithAccess; } - async getAllIndividualAccess(): Promise { const access = await prisma.prismaIndividualAccess.findMany({ diff --git a/src/api/prisma.ts b/src/api/prisma.ts index 14ab0f3d..7584a220 100644 --- a/src/api/prisma.ts +++ b/src/api/prisma.ts @@ -17,7 +17,6 @@ if (config.DEV) { logger.debug(`Query ${params.model ?? ''}.${params.action} took ${after - before}ms`); // eslint-disable-next-line @typescript-eslint/no-unsafe-return return result; - }); } diff --git a/src/api/user.api.ts b/src/api/user.api.ts index 20b1d925..c0483551 100644 --- a/src/api/user.api.ts +++ b/src/api/user.api.ts @@ -201,7 +201,7 @@ export class UserAPI { } /** - * + * * @returns All users with individual access */ async getUsersWithIndividualAccess(): Promise { diff --git a/src/models/generated/graphql.ts b/src/models/generated/graphql.ts index 699d7896..57213f5d 100644 --- a/src/models/generated/graphql.ts +++ b/src/models/generated/graphql.ts @@ -1,6 +1,17 @@ import type { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; -import type { ArticleResponse, FileResponse, MeetingResponse, ElectionResponse, ProposalResponse, NominationResponse, HeheResponse, ApiKeyResponse } from '../mappers'; + import type { Context } from '../context'; +import type { + ArticleResponse, + FileResponse, + MeetingResponse, + ElectionResponse, + ProposalResponse, + NominationResponse, + HeheResponse, + ApiKeyResponse, +} from '../mappers'; + export type Maybe = T | null; export type InputMaybe = Maybe; export type Exact = { [K in keyof T]: T[K] }; @@ -32,13 +43,13 @@ export type AccessInput = { export enum AccessResourceType { Door = 'door', - Feature = 'feature' + Feature = 'feature', } export enum AccessType { Admin = 'ADMIN', Authenticated = 'AUTHENTICATED', - Public = 'PUBLIC' + Public = 'PUBLIC', } export type ApiKey = { @@ -65,7 +76,6 @@ export type Article = { title: Scalars['String']; }; - /** Body is saved as HTML serversInte, but edited in MarkDown */ export type ArticleTagsArgs = { includeSpecial?: InputMaybe; @@ -74,7 +84,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 = { @@ -96,7 +106,7 @@ export enum Door { Pa = 'pa', Pump = 'pump', Sikrit = 'sikrit', - Ulla = 'ulla' + Ulla = 'ulla', } export type DoorInfo = { @@ -133,7 +143,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 */ @@ -148,7 +158,7 @@ export enum Feature { NewsEditor = 'news_editor', PostAdmin = 'post_admin', Superadmin = 'superadmin', - UserAdmin = 'user_admin' + UserAdmin = 'user_admin', } export type FeatureInfo = { @@ -186,7 +196,7 @@ export enum FileType { Pdf = 'PDF', Powerpoint = 'POWERPOINT', Spreadsheet = 'SPREADSHEET', - Text = 'TEXT' + Text = 'TEXT', } export type GroupedPost = { @@ -254,7 +264,7 @@ export enum MeetingDocumentType { LateDocuments = 'lateDocuments', Protocol = 'protocol', /** Kallelse */ - Summons = 'summons' + Summons = 'summons', } export enum MeetingType { @@ -267,7 +277,7 @@ export enum MeetingType { /** Valmöte */ Vm = 'VM', /** Vårterminsmöte */ - Vtm = 'VTM' + Vtm = 'VTM', } /** We don't need every part; It should already exist */ @@ -357,56 +367,47 @@ export type Mutation = { validateToken: Scalars['Boolean']; }; - export type MutationActivatePostArgs = { id: Scalars['Int']; }; - 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 MutationAddUsersToPostArgs = { end?: InputMaybe; id: Scalars['Int']; @@ -414,243 +415,200 @@ 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 MutationModifyArticleArgs = { articleId: Scalars['Int']; entry: ModifyArticle; }; - export type MutationModifyPostArgs = { info: ModifyPost; }; - 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 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 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']; }; @@ -699,7 +657,7 @@ export type Nomination = { export enum NominationAnswer { No = 'NO', NotAnswered = 'NOT_ANSWERED', - Yes = 'YES' + Yes = 'YES', } export type Post = { @@ -724,7 +682,6 @@ export type Post = { utskott: Utskott; }; - export type PostHistoryArgs = { current?: InputMaybe; }; @@ -741,7 +698,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 */ @@ -806,7 +763,6 @@ export type Query = { utskott: Utskott; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -815,7 +771,6 @@ export type QueryApiKeyArgs = { key: Scalars['String']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -825,7 +780,6 @@ export type QueryArticleArgs = { slug?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -837,7 +791,6 @@ export type QueryArticlesArgs = { type?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -846,7 +799,6 @@ export type QueryElectionArgs = { electionId: Scalars['Int']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -855,7 +807,6 @@ export type QueryElectionsArgs = { electionIds: Array; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -864,7 +815,6 @@ export type QueryFileArgs = { id: Scalars['ID']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -873,7 +823,6 @@ export type QueryFileSystemArgs = { folder: Scalars['String']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -882,7 +831,6 @@ export type QueryFilesArgs = { type?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -891,7 +839,6 @@ export type QueryGroupedPostsArgs = { includeInactive?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -901,7 +848,6 @@ export type QueryHeheArgs = { year: Scalars['Int']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -910,7 +856,6 @@ export type QueryHehesArgs = { year: Scalars['Int']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -920,7 +865,6 @@ export type QueryHiddenNominationsArgs = { electionId: Scalars['Int']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -929,7 +873,6 @@ export type QueryIndividualAccessArgs = { username: Scalars['String']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -938,7 +881,6 @@ export type QueryIndividualDoorAccessArgs = { door: Door; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -947,7 +889,6 @@ export type QueryLatestBoardMeetingsArgs = { limit?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -958,7 +899,6 @@ export type QueryLatestElectionsArgs = { limit?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -968,7 +908,6 @@ export type QueryLatestHeheArgs = { sortOrder?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -977,7 +916,6 @@ export type QueryLatestnewsArgs = { limit?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -986,7 +924,6 @@ export type QueryMeetingArgs = { id: Scalars['Int']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -997,7 +934,6 @@ export type QueryMeetingsArgs = { year?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1007,7 +943,6 @@ export type QueryMyNominationsArgs = { electionId: Scalars['Int']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1018,7 +953,6 @@ export type QueryNewsentriesArgs = { before?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1027,7 +961,6 @@ export type QueryNumberOfMembersArgs = { noAlumni?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1037,7 +970,6 @@ export type QueryNumberOfNominationsArgs = { postId?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1047,7 +979,6 @@ export type QueryNumberOfProposalsArgs = { postId?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1056,7 +987,6 @@ export type QueryNumberOfVolunteersArgs = { date?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1065,7 +995,6 @@ export type QueryPostArgs = { id: Scalars['Int']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1074,7 +1003,6 @@ export type QueryPostAccessArgs = { postId: Scalars['Int']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1083,7 +1011,6 @@ export type QueryPostDoorAccessArgs = { door: Door; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1093,7 +1020,6 @@ export type QueryPostsArgs = { utskott?: InputMaybe; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1102,7 +1028,6 @@ export type QuerySearchFilesArgs = { search: Scalars['String']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1111,7 +1036,6 @@ export type QuerySearchUserArgs = { search: Scalars['String']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1120,7 +1044,6 @@ export type QueryUserArgs = { username: Scalars['String']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1129,7 +1052,6 @@ export type QueryUserByCardArgs = { luCard: Scalars['String']; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1138,7 +1060,6 @@ export type QueryUsersArgs = { usernames: Array; }; - /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1157,7 +1078,7 @@ export type SendEmailOptions = { export enum SortOrder { Asc = 'asc', - Desc = 'desc' + Desc = 'desc', } export type TokenResponse = { @@ -1200,7 +1121,6 @@ export type User = { zipCode?: Maybe; }; - export type UserPostHistoryArgs = { current?: InputMaybe; }; @@ -1223,7 +1143,7 @@ export enum Utskott { Other = 'OTHER', Pengu = 'PENGU', Sre = 'SRE', - Styrelsen = 'STYRELSEN' + Styrelsen = 'STYRELSEN', } export type WithIndex = TObject & Record; @@ -1231,34 +1151,41 @@ 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 { +export interface SubscriptionSubscriberObject< + TResult, + TKey extends string, + TParent, + TContext, + TArgs, +> { subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>; resolve?: SubscriptionResolveFn; } @@ -1272,17 +1199,27 @@ export type SubscriptionObject | SubscriptionResolverObject; -export type SubscriptionResolver = +export type SubscriptionResolver< + TResult, + TKey extends string, + TParent = {}, + TContext = {}, + TArgs = {}, +> = | ((...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; @@ -1291,7 +1228,7 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping between all available schema types and the resolvers types */ @@ -1314,7 +1251,9 @@ export type ResolversTypes = ResolversObject<{ Feature: Feature; FeatureInfo: ResolverTypeWrapper; File: ResolverTypeWrapper; - FileSystemResponse: ResolverTypeWrapper & { files: Array }>; + FileSystemResponse: ResolverTypeWrapper< + Omit & { files: Array } + >; FileSystemResponsePath: ResolverTypeWrapper; FileType: FileType; GroupedPost: ResolverTypeWrapper; @@ -1365,7 +1304,9 @@ export type ResolversParentTypes = ResolversObject<{ EmergencyContact: EmergencyContact; FeatureInfo: FeatureInfo; File: FileResponse; - FileSystemResponse: Omit & { files: Array }; + FileSystemResponse: Omit & { + files: Array; + }; FileSystemResponsePath: FileSystemResponsePath; GroupedPost: GroupedPost; Hehe: HeheResponse; @@ -1395,13 +1336,19 @@ export type ResolversParentTypes = ResolversObject<{ UserPostHistoryEntry: UserPostHistoryEntry; }>; -export type AccessResolvers = ResolversObject<{ +export type AccessResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Access'] = ResolversParentTypes['Access'], +> = ResolversObject<{ doors?: Resolver, ParentType, ContextType>; features?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }>; -export type ApiKeyResolvers = ResolversObject<{ +export type ApiKeyResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['ApiKey'] = ResolversParentTypes['ApiKey'], +> = ResolversObject<{ access?: Resolver; creator?: Resolver; description?: Resolver; @@ -1409,7 +1356,10 @@ export type ApiKeyResolvers; }>; -export type ArticleResolvers = ResolversObject<{ +export type ArticleResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Article'] = ResolversParentTypes['Article'], +> = ResolversObject<{ articleType?: Resolver; author?: Resolver; body?: Resolver; @@ -1419,12 +1369,20 @@ export type ArticleResolvers; signature?: Resolver; slug?: Resolver; - tags?: Resolver, ParentType, ContextType, Partial>; + tags?: Resolver< + Array, + ParentType, + ContextType, + Partial + >; title?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type CasLoginResponseResolvers = ResolversObject<{ +export type CasLoginResponseResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['CasLoginResponse'] = ResolversParentTypes['CasLoginResponse'], +> = ResolversObject<{ exists?: Resolver; hash?: Resolver; username?: Resolver; @@ -1435,13 +1393,19 @@ export interface DateScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ +export type DoorInfoResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['DoorInfo'] = ResolversParentTypes['DoorInfo'], +> = ResolversObject<{ description?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type ElectionResolvers = ResolversObject<{ +export type ElectionResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Election'] = ResolversParentTypes['Election'], +> = ResolversObject<{ acceptedNominations?: Resolver, ParentType, ContextType>; closedAt?: Resolver, ParentType, ContextType>; createdAt?: Resolver; @@ -1455,7 +1419,10 @@ export type ElectionResolvers; }>; -export type EmergencyContactResolvers = ResolversObject<{ +export type EmergencyContactResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['EmergencyContact'] = ResolversParentTypes['EmergencyContact'], +> = ResolversObject<{ id?: Resolver; name?: Resolver; phone?: Resolver; @@ -1463,13 +1430,19 @@ export type EmergencyContactResolvers; }>; -export type FeatureInfoResolvers = ResolversObject<{ +export type FeatureInfoResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['FeatureInfo'] = ResolversParentTypes['FeatureInfo'], +> = ResolversObject<{ description?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type FileResolvers = ResolversObject<{ +export type FileResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['File'] = ResolversParentTypes['File'], +> = ResolversObject<{ accessType?: Resolver; createdAt?: Resolver, ParentType, ContextType>; createdBy?: Resolver, ParentType, ContextType>; @@ -1482,25 +1455,37 @@ export type FileResolvers; }>; -export type FileSystemResponseResolvers = ResolversObject<{ +export type FileSystemResponseResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['FileSystemResponse'] = ResolversParentTypes['FileSystemResponse'], +> = ResolversObject<{ files?: Resolver, ParentType, ContextType>; path?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }>; -export type FileSystemResponsePathResolvers = ResolversObject<{ +export type FileSystemResponsePathResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['FileSystemResponsePath'] = ResolversParentTypes['FileSystemResponsePath'], +> = ResolversObject<{ id?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type GroupedPostResolvers = ResolversObject<{ +export type GroupedPostResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['GroupedPost'] = ResolversParentTypes['GroupedPost'], +> = ResolversObject<{ posts?: Resolver, ParentType, ContextType>; utskott?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type HeheResolvers = ResolversObject<{ +export type HeheResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Hehe'] = ResolversParentTypes['Hehe'], +> = ResolversObject<{ file?: Resolver; number?: Resolver; uploader?: Resolver; @@ -1508,7 +1493,10 @@ export type HeheResolvers; }>; -export type HistoryEntryResolvers = ResolversObject<{ +export type HistoryEntryResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['HistoryEntry'] = ResolversParentTypes['HistoryEntry'], +> = ResolversObject<{ end?: Resolver, ParentType, ContextType>; holder?: Resolver; id?: Resolver; @@ -1516,7 +1504,10 @@ export type HistoryEntryResolvers; }>; -export type LoginProviderResolvers = ResolversObject<{ +export type LoginProviderResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['LoginProvider'] = ResolversParentTypes['LoginProvider'], +> = ResolversObject<{ email?: Resolver, ParentType, ContextType>; id?: Resolver; provider?: Resolver; @@ -1524,14 +1515,20 @@ export type LoginProviderResolvers; }>; -export type LoginResponseResolvers = ResolversObject<{ +export type LoginResponseResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['LoginResponse'] = ResolversParentTypes['LoginResponse'], +> = ResolversObject<{ accessToken?: Resolver; refreshToken?: Resolver; user?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type MeetingResolvers = ResolversObject<{ +export type MeetingResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Meeting'] = ResolversParentTypes['Meeting'], +> = ResolversObject<{ agenda?: Resolver, ParentType, ContextType>; appendix?: Resolver, ParentType, ContextType>; documents?: Resolver, ParentType, ContextType>; @@ -1546,64 +1543,330 @@ export type MeetingResolvers; }>; -export type MutationResolvers = ResolversObject<{ - activatePost?: Resolver>; - addArticle?: Resolver>; - addElectables?: Resolver>; - addEmergencyContact?: Resolver>; - addFileToMeeting?: Resolver>; - addHehe?: Resolver>; - addMeeting?: Resolver>; - addPost?: Resolver>; - addUsersToPost?: Resolver>; - casCreateUser?: Resolver>; - casLogin?: Resolver>; - changePassword?: Resolver>; +export type MutationResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation'], +> = ResolversObject<{ + activatePost?: Resolver< + ResolversTypes['Boolean'], + 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 + >; + 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 + >; closeElection?: Resolver; - createApiKey?: Resolver>; - createElection?: Resolver>; - createFolder?: Resolver>; - createUser?: Resolver>; - deactivatePost?: Resolver>; - deleteApiKey?: Resolver>; - deleteFile?: Resolver>; - forgetUser?: Resolver>; - issueTokens?: Resolver>; - linkLoginProvider?: Resolver>; - login?: 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 + >; logout?: Resolver; - modifyArticle?: Resolver>; - modifyPost?: Resolver>; - nominate?: Resolver>; - openElection?: Resolver>; - propose?: Resolver>; - providerLogin?: Resolver>; - refresh?: Resolver>; - removeArticle?: Resolver>; - removeElectables?: Resolver>; - removeEmergencyContact?: Resolver>; - removeFileFromMeeting?: Resolver>; - removeHehe?: Resolver>; - removeHistoryEntry?: Resolver>; - removeMeeting?: Resolver>; - removeProposal?: 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>; + modifyArticle?: Resolver< + ResolversTypes['Article'], + ParentType, + ContextType, + RequireFields + >; + modifyPost?: Resolver< + ResolversTypes['Boolean'], + 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 + >; + 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 + >; + 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 + >; }>; -export type NominationResolvers = ResolversObject<{ +export type NominationResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Nomination'] = ResolversParentTypes['Nomination'], +> = ResolversObject<{ answer?: Resolver; post?: Resolver; user?: Resolver; @@ -1614,12 +1877,20 @@ export interface ObjectScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ +export type PostResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Post'] = ResolversParentTypes['Post'], +> = ResolversObject<{ access?: Resolver; active?: Resolver; description?: Resolver; email?: Resolver, ParentType, ContextType>; - history?: Resolver, ParentType, ContextType, Partial>; + history?: Resolver< + Array, + ParentType, + ContextType, + Partial + >; id?: Resolver; interviewRequired?: Resolver, ParentType, ContextType>; postType?: Resolver; @@ -1630,63 +1901,240 @@ export type PostResolvers; }>; -export type ProposalResolvers = ResolversObject<{ +export type ProposalResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Proposal'] = ResolversParentTypes['Proposal'], +> = ResolversObject<{ post?: Resolver; user?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type QueryResolvers = ResolversObject<{ - apiKey?: Resolver>; +export type QueryResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query'], +> = ResolversObject<{ + apiKey?: Resolver< + ResolversTypes['ApiKey'], + ParentType, + ContextType, + RequireFields + >; apiKeys?: Resolver, ParentType, ContextType>; article?: Resolver>; - articles?: Resolver, ParentType, ContextType, Partial>; + articles?: Resolver< + Array, + ParentType, + ContextType, + Partial + >; doors?: Resolver, ParentType, ContextType>; - election?: Resolver>; - elections?: Resolver, ParentType, ContextType, RequireFields>; + election?: Resolver< + ResolversTypes['Election'], + ParentType, + ContextType, + RequireFields + >; + elections?: Resolver< + Array, + ParentType, + ContextType, + RequireFields + >; features?: Resolver, ParentType, ContextType>; - file?: Resolver>; - fileSystem?: Resolver>; + file?: Resolver< + ResolversTypes['File'], + ParentType, + ContextType, + RequireFields + >; + fileSystem?: Resolver< + ResolversTypes['FileSystemResponse'], + ParentType, + ContextType, + RequireFields + >; files?: Resolver, ParentType, ContextType, Partial>; - groupedPosts?: Resolver, ParentType, ContextType, Partial>; - hehe?: Resolver>; - hehes?: Resolver, ParentType, ContextType, RequireFields>; - hiddenNominations?: Resolver, ParentType, ContextType, RequireFields>; - individualAccess?: Resolver>; - individualDoorAccess?: Resolver, ParentType, ContextType, RequireFields>; - latestBoardMeetings?: Resolver, ParentType, ContextType, Partial>; - latestElections?: Resolver, ParentType, ContextType, Partial>; - latestHehe?: Resolver, ParentType, ContextType, Partial>; - latestnews?: 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 + >; + individualDoorAccess?: Resolver< + Array, + ParentType, + ContextType, + RequireFields + >; + latestBoardMeetings?: Resolver< + Array, + ParentType, + ContextType, + Partial + >; + latestElections?: Resolver< + Array, + ParentType, + ContextType, + Partial + >; + latestHehe?: Resolver< + Array, + ParentType, + ContextType, + Partial + >; + latestnews?: Resolver< + Array, + ParentType, + ContextType, + Partial + >; me?: Resolver; - 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>; + 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 + >; openElection?: Resolver; - post?: Resolver>; - postAccess?: Resolver>; - postDoorAccess?: Resolver, ParentType, ContextType, RequireFields>; + post?: Resolver< + ResolversTypes['Post'], + ParentType, + ContextType, + RequireFields + >; + postAccess?: Resolver< + ResolversTypes['Access'], + ParentType, + ContextType, + RequireFields + >; + postDoorAccess?: Resolver< + Array, + ParentType, + ContextType, + RequireFields + >; posts?: Resolver, ParentType, ContextType, Partial>; - searchFiles?: Resolver, ParentType, ContextType, RequireFields>; - searchUser?: Resolver, ParentType, ContextType, RequireFields>; - user?: Resolver>; - userByCard?: Resolver>; - users?: Resolver, ParentType, ContextType, RequireFields>; - utskott?: Resolver>; + searchFiles?: Resolver< + Array, + ParentType, + ContextType, + RequireFields + >; + searchUser?: Resolver< + Array, + ParentType, + ContextType, + RequireFields + >; + user?: Resolver< + ResolversTypes['User'], + ParentType, + ContextType, + RequireFields + >; + userByCard?: Resolver< + ResolversTypes['User'], + ParentType, + ContextType, + RequireFields + >; + users?: Resolver< + Array, + ParentType, + ContextType, + RequireFields + >; + utskott?: Resolver< + ResolversTypes['Utskott'], + ParentType, + ContextType, + RequireFields + >; }>; -export type TokenResponseResolvers = ResolversObject<{ +export type TokenResponseResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['TokenResponse'] = ResolversParentTypes['TokenResponse'], +> = ResolversObject<{ accessToken?: Resolver; refreshToken?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type UserResolvers = ResolversObject<{ +export type UserResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['User'] = ResolversParentTypes['User'], +> = ResolversObject<{ access?: Resolver; address?: Resolver, ParentType, ContextType>; class?: Resolver; @@ -1699,7 +2147,12 @@ export type UserResolvers, ParentType, ContextType>; phone?: Resolver, ParentType, ContextType>; photoUrl?: Resolver, ParentType, ContextType>; - postHistory?: Resolver, ParentType, ContextType, Partial>; + postHistory?: Resolver< + Array, + ParentType, + ContextType, + Partial + >; posts?: Resolver, ParentType, ContextType>; username?: Resolver; website?: Resolver, ParentType, ContextType>; @@ -1708,7 +2161,10 @@ export type UserResolvers; }>; -export type UserPostHistoryEntryResolvers = ResolversObject<{ +export type UserPostHistoryEntryResolvers< + ContextType = Context, + ParentType extends ResolversParentTypes['UserPostHistoryEntry'] = ResolversParentTypes['UserPostHistoryEntry'], +> = ResolversObject<{ end?: Resolver, ParentType, ContextType>; post?: Resolver; start?: Resolver; @@ -1744,4 +2200,3 @@ export type Resolvers = ResolversObject<{ User?: UserResolvers; UserPostHistoryEntry?: UserPostHistoryEntryResolvers; }>; - diff --git a/src/resolvers/access.resolver.ts b/src/resolvers/access.resolver.ts index a393d8b1..0ab8ce00 100644 --- a/src/resolvers/access.resolver.ts +++ b/src/resolvers/access.resolver.ts @@ -4,7 +4,7 @@ import { AccessAPI } from '@api/access'; import { Door, Feature, Resolvers } from '@generated/graphql'; import { PrismaUser } from '@prisma/client'; import { accessReducer, doorReducer, featureReducer } from '@reducer/access'; -import { userReduce} from '@reducer/user'; +import { userReduce } from '@reducer/user'; const accessApi = new AccessAPI(); diff --git a/src/resolvers/user.resolver.ts b/src/resolvers/user.resolver.ts index 315c02b4..0d73f860 100644 --- a/src/resolvers/user.resolver.ts +++ b/src/resolvers/user.resolver.ts @@ -149,7 +149,7 @@ const userResolver: Resolvers = { await hasAuthenticated(ctx); const users = await api.getUsersWithIndividualAccess(); return reduce(users, userReduce); - } + }, }, Mutation: { updateUser: async (_, { input }, { getUsername }) => { From f3d1354e0a291f54f85411c9bf9a1aa83eb8a274 Mon Sep 17 00:00:00 2001 From: pontus Date: Mon, 16 Oct 2023 22:53:08 +0200 Subject: [PATCH 08/20] remove previous additon getAccessForIndividual door for resolver and graphql schema --- src/resolvers/access.resolver.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/resolvers/access.resolver.ts b/src/resolvers/access.resolver.ts index 0ab8ce00..f5b619c7 100644 --- a/src/resolvers/access.resolver.ts +++ b/src/resolvers/access.resolver.ts @@ -16,11 +16,6 @@ const accessresolver: Resolvers = { return accessReducer(access); }, - individualAccessForDoor: async (_: unknown, { door }: { door: Door }, ctx: Context) => { - await hasAuthenticated(ctx); - const users: PrismaUser[] = await accessApi.getIndividualAccessForDoor(door); - return users.map(userReduce); - }, postAccess: async (_, { postId }, ctx) => { await hasAuthenticated(ctx); const access = await accessApi.getPostAccess(postId); From da769be06f98907bbb9d60a08b6242e12d014a49 Mon Sep 17 00:00:00 2001 From: pontus Date: Fri, 10 Nov 2023 11:04:50 +0100 Subject: [PATCH 09/20] added test --- src/api/access.api.ts | 30 ----------------------------- src/resolvers/access.resolver.ts | 3 --- src/schemas/access.graphql | 1 - test/integration/access.api.test.ts | 15 ++++++++++++++- 4 files changed, 14 insertions(+), 35 deletions(-) diff --git a/src/api/access.api.ts b/src/api/access.api.ts index 5a002f2c..00b1c495 100644 --- a/src/api/access.api.ts +++ b/src/api/access.api.ts @@ -43,36 +43,6 @@ export class AccessAPI { return access; } - /** - * - * @param door target door which you want to get all users with access to - */ - async getIndividualAccessForDoor(door: Door): Promise { - const usersWithAccess = await prisma.prismaUser.findMany({ - where: { - access: { - some: { - resource: door, - }, - }, - }, - include: { - access: true, - }, - }); - return usersWithAccess; - } - - async getAllIndividualAccess(): Promise { - const access = await prisma.prismaIndividualAccess.findMany({ - orderBy: { - resource: 'asc', - }, - }); - - return access; - } - /** * Get access for a post in alphabetical order * @param postId ID for the post diff --git a/src/resolvers/access.resolver.ts b/src/resolvers/access.resolver.ts index f5b619c7..fba5163a 100644 --- a/src/resolvers/access.resolver.ts +++ b/src/resolvers/access.resolver.ts @@ -1,10 +1,7 @@ -import { Context } from '@/models/context'; import { hasAccess, hasAuthenticated } from '@/util'; import { AccessAPI } from '@api/access'; import { Door, Feature, Resolvers } from '@generated/graphql'; -import { PrismaUser } from '@prisma/client'; import { accessReducer, doorReducer, featureReducer } from '@reducer/access'; -import { userReduce } from '@reducer/user'; const accessApi = new AccessAPI(); diff --git a/src/schemas/access.graphql b/src/schemas/access.graphql index 4eff4392..91eb3183 100644 --- a/src/schemas/access.graphql +++ b/src/schemas/access.graphql @@ -4,7 +4,6 @@ type Query { individualAccess(username: String!): Access! postAccess(postId: Int!): Access! - individualAccessForDoor(door: Door!): [User!]! features: [FeatureInfo!]! doors: [DoorInfo!]! } diff --git a/test/integration/access.api.test.ts b/test/integration/access.api.test.ts index b00b74a8..716245ca 100644 --- a/test/integration/access.api.test.ts +++ b/test/integration/access.api.test.ts @@ -178,7 +178,7 @@ describe('setting/getting access for user', () => { () => accessApi.setIndividualAccess(username, input); const getAccess = (username = username0) => accessApi.getIndividualAccess(username); - + const getAllIndividualAccessUsers = () => userApi.getUsersWithIndividualAccess(); it('setting single access', async () => { const expectedAccess = mapUserAccess(expectedAccessSingleInput); @@ -197,6 +197,19 @@ describe('setting/getting access for user', () => { await setGetTest(setAccess(accessMultipleInput), getAccess, expectedAccess); }); + //This seems kinda iffy + it('getting all access users', async () => { + const accessUsers = await getAllIndividualAccessUsers(); + + const usernamesToCheck = ['aa0000bb-s', username0]; // Add usernames to check + + expect(accessUsers).toEqual( + expect.arrayContaining( + usernamesToCheck.map((username) => expect.objectContaining({ username })) + ) + ); + }); + it('removing access', async () => { await setGetTest(setAccess(emptyAccess), getAccess, []); }); From 661fef68ab5a42c45bdacbfc7a8c743e65e43755 Mon Sep 17 00:00:00 2001 From: pontus Date: Sat, 18 Nov 2023 12:15:06 +0100 Subject: [PATCH 10/20] cleanup import --- src/api/access.api.ts | 1 - test/integration/access.api.test.ts | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/api/access.api.ts b/src/api/access.api.ts index 00b1c495..53a3a341 100644 --- a/src/api/access.api.ts +++ b/src/api/access.api.ts @@ -10,7 +10,6 @@ import { PrismaIndividualAccess, PrismaPostAccess, PrismaResourceType, - PrismaUser, } from '@prisma/client'; import prisma from './prisma'; diff --git a/test/integration/access.api.test.ts b/test/integration/access.api.test.ts index 716245ca..c7aba9a6 100644 --- a/test/integration/access.api.test.ts +++ b/test/integration/access.api.test.ts @@ -200,13 +200,13 @@ describe('setting/getting access for user', () => { //This seems kinda iffy it('getting all access users', async () => { const accessUsers = await getAllIndividualAccessUsers(); - + const usernamesToCheck = ['aa0000bb-s', username0]; // Add usernames to check - + expect(accessUsers).toEqual( expect.arrayContaining( - usernamesToCheck.map((username) => expect.objectContaining({ username })) - ) + usernamesToCheck.map((username) => expect.objectContaining({ username })), + ), ); }); From 791beb8790ee974c98f457828a198666a5156c58 Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Mon, 4 Dec 2023 09:53:01 +0100 Subject: [PATCH 11/20] add test for allUsersWithIndividualAccess --- src/api/user.api.ts | 15 ++++++++--- test/integration/access.api.test.ts | 40 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/api/user.api.ts b/src/api/user.api.ts index c0483551..1ee03ab0 100644 --- a/src/api/user.api.ts +++ b/src/api/user.api.ts @@ -3,7 +3,14 @@ import { Logger } from '@/logger'; import { devGuard } from '@/util'; import { LoginProvider } from '@esek/auth-server'; import type { NewUser } from '@generated/graphql'; -import { Prisma, PrismaLoginProvider, PrismaPasswordReset, PrismaUser } from '@prisma/client'; +import { + Prisma, + PrismaIndividualAccess, + PrismaLoginProvider, + PrismaPasswordReset, + PrismaPostAccess, + PrismaUser, +} from '@prisma/client'; import crypto, { randomUUID } from 'crypto'; import { @@ -204,7 +211,9 @@ export class UserAPI { * * @returns All users with individual access */ - async getUsersWithIndividualAccess(): Promise { + async getUsersWithIndividualAccess(): Promise< + (PrismaUser & { access: PrismaIndividualAccess[] })[] + > { const users = await prisma.prismaUser.findMany({ where: { access: { @@ -215,7 +224,7 @@ export class UserAPI { access: true, }, }); - return users; + return users as unknown as (PrismaUser & { access: PrismaIndividualAccess[] })[]; } /** diff --git a/test/integration/access.api.test.ts b/test/integration/access.api.test.ts index c7aba9a6..acd8c55a 100644 --- a/test/integration/access.api.test.ts +++ b/test/integration/access.api.test.ts @@ -172,6 +172,46 @@ const mapPostAccess = (access: Partial[], refPost: number = p const mapApiKeyAccess = (access: Partial[], refApiKey: string = apiKey) => access.map((a) => ({ ...a, refApiKey })); +function mapIndividualAccessToSingleInput(access: PrismaIndividualAccess[]): AccessInput { + return access.reduce( + (accum: AccessInput, currentValue: PrismaIndividualAccess) => { + if (currentValue.resourceType == 'door') { + accum.doors.push(currentValue.resource as Door); + } else { + accum.features.push(currentValue.resource as Feature); + } + return accum; + }, + { + doors: [], + features: [], + }, + ); +} + +async function addUserWithAccessThenCheckAllUsersWithAccess() { + const usernameTest = 'po7853sj-s'; + await userApi.createUser({ + username: usernameTest, + password: 'supersecretpassword', + firstName: 'Pontus', + lastName: 'SjöSjöstedt', + class: 'E21', + }); + await accessApi.setIndividualAccess(usernameTest, accessSingleInput); + const users = await userApi.getUsersWithIndividualAccess(); + const testUser = users.find((user) => user.username == usernameTest); + await userApi.deleteUser(usernameTest); + expect( + mapIndividualAccessToSingleInput(testUser?.access as PrismaIndividualAccess[]), + ).toStrictEqual(accessSingleInput); +} + +test( + 'Try creating user and seeing that their access is properly returned', + addUserWithAccessThenCheckAllUsersWithAccess, +); + describe('setting/getting access for user', () => { const setAccess = (input: AccessInput, username = username0) => From fb0ed39cc8dd79731bb5bc59d063210b6bfd3581 Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Mon, 4 Dec 2023 09:53:23 +0100 Subject: [PATCH 12/20] remove garbage test --- test/integration/access.api.test.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/integration/access.api.test.ts b/test/integration/access.api.test.ts index acd8c55a..28a8d6c3 100644 --- a/test/integration/access.api.test.ts +++ b/test/integration/access.api.test.ts @@ -237,19 +237,6 @@ describe('setting/getting access for user', () => { await setGetTest(setAccess(accessMultipleInput), getAccess, expectedAccess); }); - //This seems kinda iffy - it('getting all access users', async () => { - const accessUsers = await getAllIndividualAccessUsers(); - - const usernamesToCheck = ['aa0000bb-s', username0]; // Add usernames to check - - expect(accessUsers).toEqual( - expect.arrayContaining( - usernamesToCheck.map((username) => expect.objectContaining({ username })), - ), - ); - }); - it('removing access', async () => { await setGetTest(setAccess(emptyAccess), getAccess, []); }); From e240254be87bef879623a974251c6d3e5cb639c7 Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Mon, 4 Dec 2023 09:57:54 +0100 Subject: [PATCH 13/20] remove unused import --- src/api/user.api.ts | 1 - test/integration/access.api.test.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/api/user.api.ts b/src/api/user.api.ts index 1ee03ab0..fd118d35 100644 --- a/src/api/user.api.ts +++ b/src/api/user.api.ts @@ -8,7 +8,6 @@ import { PrismaIndividualAccess, PrismaLoginProvider, PrismaPasswordReset, - PrismaPostAccess, PrismaUser, } from '@prisma/client'; import crypto, { randomUUID } from 'crypto'; diff --git a/test/integration/access.api.test.ts b/test/integration/access.api.test.ts index 28a8d6c3..1947c634 100644 --- a/test/integration/access.api.test.ts +++ b/test/integration/access.api.test.ts @@ -218,7 +218,6 @@ describe('setting/getting access for user', () => { () => accessApi.setIndividualAccess(username, input); const getAccess = (username = username0) => accessApi.getIndividualAccess(username); - const getAllIndividualAccessUsers = () => userApi.getUsersWithIndividualAccess(); it('setting single access', async () => { const expectedAccess = mapUserAccess(expectedAccessSingleInput); From 1b9e77828b93741ba4f875488ea5af2b1100cfd4 Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Mon, 4 Dec 2023 10:01:12 +0100 Subject: [PATCH 14/20] update changelog --- CHANGELOG.MD | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 4c45fa9a..5798fea1 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -4,6 +4,9 @@ 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.6.0] - 2023-12-04 +la till ny gql metod: allUsersWithIndividualAccess + ## [1.4.1] - 2023-08-06 ### Ändrat From 1af0f665e9fbf3160c661b2112eecaf3f900ea51 Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Mon, 4 Dec 2023 10:02:19 +0100 Subject: [PATCH 15/20] fixade .env.example --- .env.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index c0ce0624..81834ad8 100644 --- a/.env.example +++ b/.env.example @@ -3,8 +3,8 @@ LOGLEVEL=debug PORT=3000 -Cors origins, ges av en kommaseparerad lista -#ALLOWED_ORIGINS= +#Cors origins, ges av en kommaseparerad lista +ALLOWED_ORIGINS= # Auth stuff JWT_SECRET=blabla From 729c88d9c5c34c992c94100480073dce09261b53 Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Mon, 4 Dec 2023 11:35:23 +0100 Subject: [PATCH 16/20] add comment --- src/api/user.api.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/user.api.ts b/src/api/user.api.ts index fd118d35..30344f68 100644 --- a/src/api/user.api.ts +++ b/src/api/user.api.ts @@ -214,6 +214,7 @@ export class UserAPI { (PrismaUser & { access: PrismaIndividualAccess[] })[] > { const users = await prisma.prismaUser.findMany({ + //filters out users with empty access where: { access: { some: {}, From e79d499eff8f5c4706ff16739348055c6f199fdd Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Thu, 7 Dec 2023 18:07:56 +0100 Subject: [PATCH 17/20] generate and fix typecast --- src/api/user.api.ts | 2 +- src/models/generated/graphql.ts | 929 ++++++++------------------------ 2 files changed, 228 insertions(+), 703 deletions(-) diff --git a/src/api/user.api.ts b/src/api/user.api.ts index 30344f68..23d1855e 100644 --- a/src/api/user.api.ts +++ b/src/api/user.api.ts @@ -224,7 +224,7 @@ export class UserAPI { access: true, }, }); - return users as unknown as (PrismaUser & { access: PrismaIndividualAccess[] })[]; + return users as (PrismaUser & { access: PrismaIndividualAccess[] })[]; } /** diff --git a/src/models/generated/graphql.ts b/src/models/generated/graphql.ts index 57213f5d..aadf28d9 100644 --- a/src/models/generated/graphql.ts +++ b/src/models/generated/graphql.ts @@ -1,17 +1,6 @@ import type { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; - +import type { ArticleResponse, FileResponse, MeetingResponse, ElectionResponse, ProposalResponse, NominationResponse, HeheResponse, ApiKeyResponse } from '../mappers'; import type { Context } from '../context'; -import type { - ArticleResponse, - FileResponse, - MeetingResponse, - ElectionResponse, - ProposalResponse, - NominationResponse, - HeheResponse, - ApiKeyResponse, -} from '../mappers'; - export type Maybe = T | null; export type InputMaybe = Maybe; export type Exact = { [K in keyof T]: T[K] }; @@ -43,13 +32,13 @@ export type AccessInput = { export enum AccessResourceType { Door = 'door', - Feature = 'feature', + Feature = 'feature' } export enum AccessType { Admin = 'ADMIN', Authenticated = 'AUTHENTICATED', - Public = 'PUBLIC', + Public = 'PUBLIC' } export type ApiKey = { @@ -76,6 +65,7 @@ export type Article = { title: Scalars['String']; }; + /** Body is saved as HTML serversInte, but edited in MarkDown */ export type ArticleTagsArgs = { includeSpecial?: InputMaybe; @@ -84,7 +74,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 = { @@ -106,7 +96,7 @@ export enum Door { Pa = 'pa', Pump = 'pump', Sikrit = 'sikrit', - Ulla = 'ulla', + Ulla = 'ulla' } export type DoorInfo = { @@ -143,7 +133,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 */ @@ -158,7 +148,7 @@ export enum Feature { NewsEditor = 'news_editor', PostAdmin = 'post_admin', Superadmin = 'superadmin', - UserAdmin = 'user_admin', + UserAdmin = 'user_admin' } export type FeatureInfo = { @@ -196,7 +186,7 @@ export enum FileType { Pdf = 'PDF', Powerpoint = 'POWERPOINT', Spreadsheet = 'SPREADSHEET', - Text = 'TEXT', + Text = 'TEXT' } export type GroupedPost = { @@ -264,7 +254,7 @@ export enum MeetingDocumentType { LateDocuments = 'lateDocuments', Protocol = 'protocol', /** Kallelse */ - Summons = 'summons', + Summons = 'summons' } export enum MeetingType { @@ -277,7 +267,7 @@ export enum MeetingType { /** Valmöte */ Vm = 'VM', /** Vårterminsmöte */ - Vtm = 'VTM', + Vtm = 'VTM' } /** We don't need every part; It should already exist */ @@ -367,47 +357,56 @@ export type Mutation = { validateToken: Scalars['Boolean']; }; + export type MutationActivatePostArgs = { id: Scalars['Int']; }; + 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 MutationAddUsersToPostArgs = { end?: InputMaybe; id: Scalars['Int']; @@ -415,200 +414,243 @@ 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 MutationModifyArticleArgs = { articleId: Scalars['Int']; entry: ModifyArticle; }; + export type MutationModifyPostArgs = { info: ModifyPost; }; + 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 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 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']; }; @@ -657,7 +699,7 @@ export type Nomination = { export enum NominationAnswer { No = 'NO', NotAnswered = 'NOT_ANSWERED', - Yes = 'YES', + Yes = 'YES' } export type Post = { @@ -682,6 +724,7 @@ export type Post = { utskott: Utskott; }; + export type PostHistoryArgs = { current?: InputMaybe; }; @@ -698,7 +741,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 */ @@ -735,7 +778,6 @@ export type Query = { /** Used if nominations are hidden but an election-admin wants too see nominations */ hiddenNominations: Array; individualAccess: Access; - individualDoorAccess: Array; latestBoardMeetings: Array; latestElections: Array; latestHehe: Array; @@ -753,16 +795,17 @@ export type Query = { openElection: Election; post: Post; postAccess: Access; - postDoorAccess: Array; posts: Array; searchFiles: Array; searchUser: Array; user: User; userByCard: User; users: Array; + usersWithIndividualAccess: Array; utskott: Utskott; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -771,6 +814,7 @@ export type QueryApiKeyArgs = { key: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -780,6 +824,7 @@ export type QueryArticleArgs = { slug?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -791,6 +836,7 @@ export type QueryArticlesArgs = { type?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -799,6 +845,7 @@ export type QueryElectionArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -807,6 +854,7 @@ export type QueryElectionsArgs = { electionIds: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -815,6 +863,7 @@ export type QueryFileArgs = { id: Scalars['ID']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -823,6 +872,7 @@ export type QueryFileSystemArgs = { folder: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -831,6 +881,7 @@ export type QueryFilesArgs = { type?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -839,6 +890,7 @@ export type QueryGroupedPostsArgs = { includeInactive?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -848,6 +900,7 @@ export type QueryHeheArgs = { year: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -856,6 +909,7 @@ export type QueryHehesArgs = { year: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -865,6 +919,7 @@ export type QueryHiddenNominationsArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -873,13 +928,6 @@ export type QueryIndividualAccessArgs = { username: Scalars['String']; }; -/** - * Queries and mutations that relies on an election being open - * does not take an `electionId` parameter. - */ -export type QueryIndividualDoorAccessArgs = { - door: Door; -}; /** * Queries and mutations that relies on an election being open @@ -889,6 +937,7 @@ export type QueryLatestBoardMeetingsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -899,6 +948,7 @@ export type QueryLatestElectionsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -908,6 +958,7 @@ export type QueryLatestHeheArgs = { sortOrder?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -916,6 +967,7 @@ export type QueryLatestnewsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -924,6 +976,7 @@ export type QueryMeetingArgs = { id: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -934,6 +987,7 @@ export type QueryMeetingsArgs = { year?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -943,6 +997,7 @@ export type QueryMyNominationsArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -953,6 +1008,7 @@ export type QueryNewsentriesArgs = { before?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -961,6 +1017,7 @@ export type QueryNumberOfMembersArgs = { noAlumni?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -970,6 +1027,7 @@ export type QueryNumberOfNominationsArgs = { postId?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -979,6 +1037,7 @@ export type QueryNumberOfProposalsArgs = { postId?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -987,6 +1046,7 @@ export type QueryNumberOfVolunteersArgs = { date?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -995,6 +1055,7 @@ export type QueryPostArgs = { id: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1003,13 +1064,6 @@ export type QueryPostAccessArgs = { postId: Scalars['Int']; }; -/** - * Queries and mutations that relies on an election being open - * does not take an `electionId` parameter. - */ -export type QueryPostDoorAccessArgs = { - door: Door; -}; /** * Queries and mutations that relies on an election being open @@ -1020,6 +1074,7 @@ export type QueryPostsArgs = { utskott?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1028,6 +1083,7 @@ export type QuerySearchFilesArgs = { search: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1036,6 +1092,7 @@ export type QuerySearchUserArgs = { search: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1044,6 +1101,7 @@ export type QueryUserArgs = { username: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1052,6 +1110,7 @@ export type QueryUserByCardArgs = { luCard: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1060,6 +1119,7 @@ export type QueryUsersArgs = { usernames: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1078,7 +1138,7 @@ export type SendEmailOptions = { export enum SortOrder { Asc = 'asc', - Desc = 'desc', + Desc = 'desc' } export type TokenResponse = { @@ -1121,6 +1181,7 @@ export type User = { zipCode?: Maybe; }; + export type UserPostHistoryArgs = { current?: InputMaybe; }; @@ -1143,7 +1204,7 @@ export enum Utskott { Other = 'OTHER', Pengu = 'PENGU', Sre = 'SRE', - Styrelsen = 'STYRELSEN', + Styrelsen = 'STYRELSEN' } export type WithIndex = TObject & Record; @@ -1151,41 +1212,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; } @@ -1199,27 +1253,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; @@ -1228,7 +1272,7 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping between all available schema types and the resolvers types */ @@ -1251,9 +1295,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; @@ -1304,9 +1346,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; @@ -1336,19 +1376,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 ApiKeyResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['ApiKey'] = ResolversParentTypes['ApiKey'], -> = ResolversObject<{ +export type ApiKeyResolvers = ResolversObject<{ access?: Resolver; creator?: Resolver; description?: Resolver; @@ -1356,10 +1390,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; @@ -1369,20 +1400,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; @@ -1393,19 +1416,13 @@ export interface DateScalarConfig extends GraphQLScalarTypeConfig = 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; @@ -1419,10 +1436,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; @@ -1430,19 +1444,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>; @@ -1455,37 +1463,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<{ file?: Resolver; number?: Resolver; uploader?: Resolver; @@ -1493,10 +1489,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; @@ -1504,10 +1497,7 @@ export type HistoryEntryResolvers< __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; @@ -1515,20 +1505,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>; @@ -1543,330 +1527,64 @@ export type MeetingResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type MutationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation'], -> = ResolversObject<{ - activatePost?: Resolver< - ResolversTypes['Boolean'], - 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 - >; - 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>; + addArticle?: Resolver>; + addElectables?: Resolver>; + addEmergencyContact?: Resolver>; + addFileToMeeting?: Resolver>; + addHehe?: Resolver>; + addMeeting?: Resolver>; + addPost?: 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; - modifyArticle?: Resolver< - ResolversTypes['Article'], - ParentType, - ContextType, - RequireFields - >; - modifyPost?: Resolver< - ResolversTypes['Boolean'], - 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 - >; - 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 - >; - 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 - >; + modifyArticle?: Resolver>; + modifyPost?: Resolver>; + nominate?: Resolver>; + openElection?: Resolver>; + propose?: Resolver>; + providerLogin?: Resolver>; + refresh?: Resolver>; + removeArticle?: Resolver>; + removeElectables?: Resolver>; + removeEmergencyContact?: Resolver>; + removeFileFromMeeting?: Resolver>; + removeHehe?: Resolver>; + removeHistoryEntry?: Resolver>; + removeMeeting?: Resolver>; + removeProposal?: 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>; }>; -export type NominationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Nomination'] = ResolversParentTypes['Nomination'], -> = ResolversObject<{ +export type NominationResolvers = ResolversObject<{ answer?: Resolver; post?: Resolver; user?: Resolver; @@ -1877,20 +1595,12 @@ export interface ObjectScalarConfig extends GraphQLScalarTypeConfig = 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; @@ -1901,240 +1611,62 @@ 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<{ - apiKey?: Resolver< - ResolversTypes['ApiKey'], - ParentType, - ContextType, - RequireFields - >; +export type QueryResolvers = ResolversObject<{ + 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 - >; - individualDoorAccess?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - latestBoardMeetings?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestElections?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestHehe?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestnews?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + groupedPosts?: Resolver, ParentType, ContextType, Partial>; + hehe?: Resolver>; + hehes?: Resolver, ParentType, ContextType, RequireFields>; + hiddenNominations?: Resolver, ParentType, ContextType, RequireFields>; + individualAccess?: Resolver>; + latestBoardMeetings?: Resolver, ParentType, ContextType, Partial>; + latestElections?: Resolver, ParentType, ContextType, Partial>; + latestHehe?: Resolver, ParentType, ContextType, Partial>; + latestnews?: Resolver, ParentType, ContextType, Partial>; 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; - post?: Resolver< - ResolversTypes['Post'], - ParentType, - ContextType, - RequireFields - >; - postAccess?: Resolver< - ResolversTypes['Access'], - ParentType, - ContextType, - RequireFields - >; - postDoorAccess?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; + post?: Resolver>; + postAccess?: Resolver>; posts?: Resolver, ParentType, ContextType, Partial>; - searchFiles?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - searchUser?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - user?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - userByCard?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - users?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - utskott?: Resolver< - ResolversTypes['Utskott'], - ParentType, - ContextType, - RequireFields - >; + searchFiles?: Resolver, ParentType, ContextType, RequireFields>; + searchUser?: Resolver, ParentType, ContextType, RequireFields>; + user?: Resolver>; + userByCard?: Resolver>; + users?: Resolver, ParentType, ContextType, RequireFields>; + usersWithIndividualAccess?: Resolver, ParentType, ContextType>; + utskott?: Resolver>; }>; -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; @@ -2147,12 +1679,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; website?: Resolver, ParentType, ContextType>; @@ -2161,10 +1688,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; @@ -2200,3 +1724,4 @@ export type Resolvers = ResolversObject<{ User?: UserResolvers; UserPostHistoryEntry?: UserPostHistoryEntryResolvers; }>; + From e382f7555c58ed51ee4292c5c90901fbec19b5da Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Thu, 7 Dec 2023 18:58:22 +0100 Subject: [PATCH 18/20] update package.json version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 42569772..18575233 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ekorre-ts", - "version": "1.4.0", + "version": "1.6.0", "description": "E-Sektionens backend", "main": "src/index.ts", "scripts": { From 8f9b298b97766a1ef8f7ece2b9509d40e4e2323f Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Thu, 7 Dec 2023 18:59:37 +0100 Subject: [PATCH 19/20] update package.lock --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 96244aa4..d4490504 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ekorre-ts", - "version": "1.4.0", + "version": "1.6.0", "lockfileVersion": 2, "requires": true, "packages": { From 71a8e20a8310d4a1d67d8e7805924af6618366b5 Mon Sep 17 00:00:00 2001 From: Pontus Sjostedt Date: Thu, 7 Dec 2023 19:20:05 +0100 Subject: [PATCH 20/20] change return type --- src/api/user.api.ts | 21 +++++++++------------ src/resolvers/user.resolver.ts | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/api/user.api.ts b/src/api/user.api.ts index 23d1855e..b4a0c455 100644 --- a/src/api/user.api.ts +++ b/src/api/user.api.ts @@ -3,13 +3,7 @@ import { Logger } from '@/logger'; import { devGuard } from '@/util'; import { LoginProvider } from '@esek/auth-server'; import type { NewUser } from '@generated/graphql'; -import { - Prisma, - PrismaIndividualAccess, - PrismaLoginProvider, - PrismaPasswordReset, - PrismaUser, -} from '@prisma/client'; +import { Prisma, PrismaLoginProvider, PrismaPasswordReset, PrismaUser } from '@prisma/client'; import crypto, { randomUUID } from 'crypto'; import { @@ -20,6 +14,12 @@ import { } from '../errors/request.errors'; import prisma from './prisma'; +type UserWithAccess = Prisma.PrismaUserGetPayload<{ + include: { + access: true; + }; +}>; + const logger = Logger.getLogger('UserAPI'); const defaultOrder: Prisma.PrismaUserOrderByWithRelationAndSearchRelevanceInput[] = [ { @@ -205,14 +205,11 @@ export class UserAPI { return count; } } - /** * * @returns All users with individual access */ - async getUsersWithIndividualAccess(): Promise< - (PrismaUser & { access: PrismaIndividualAccess[] })[] - > { + async getUsersWithIndividualAccess(): Promise { const users = await prisma.prismaUser.findMany({ //filters out users with empty access where: { @@ -224,7 +221,7 @@ export class UserAPI { access: true, }, }); - return users as (PrismaUser & { access: PrismaIndividualAccess[] })[]; + return users; } /** diff --git a/src/resolvers/user.resolver.ts b/src/resolvers/user.resolver.ts index 0d73f860..cd591196 100644 --- a/src/resolvers/user.resolver.ts +++ b/src/resolvers/user.resolver.ts @@ -145,7 +145,7 @@ const userResolver: Resolvers = { return reduce(users, userReduce); }, numberOfMembers: async (_, { noAlumni }) => api.getNumberOfMembers(noAlumni === true), - usersWithIndividualAccess: async (_: unknown, __: unknown, ctx: Context) => { + usersWithIndividualAccess: async (_, __, ctx: Context) => { await hasAuthenticated(ctx); const users = await api.getUsersWithIndividualAccess(); return reduce(users, userReduce);