fix: enum type fixes in SDL (HBE-183) (#55)
* fix: added reqType typed in sdl * fix: updateUserSession type
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Field, ID, ArgsType } from '@nestjs/graphql';
|
import { Field, ID, ArgsType } from '@nestjs/graphql';
|
||||||
import { ReqType } from '@prisma/client';
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import { PaginationArgs } from 'src/types/input-types.args';
|
import { PaginationArgs } from 'src/types/input-types.args';
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
@@ -82,7 +82,7 @@ export class ImportUserCollectionsFromJSONArgs {
|
|||||||
description: 'JSON string to import',
|
description: 'JSON string to import',
|
||||||
})
|
})
|
||||||
jsonString: string;
|
jsonString: string;
|
||||||
@Field({
|
@Field(() => ReqType, {
|
||||||
name: 'reqType',
|
name: 'reqType',
|
||||||
description: 'Type of UserCollection',
|
description: 'Type of UserCollection',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,16 +18,12 @@ import { AuthUser } from 'src/types/AuthUser';
|
|||||||
import * as E from 'fp-ts/Either';
|
import * as E from 'fp-ts/Either';
|
||||||
import * as O from 'fp-ts/Option';
|
import * as O from 'fp-ts/Option';
|
||||||
import { PubSubService } from 'src/pubsub/pubsub.service';
|
import { PubSubService } from 'src/pubsub/pubsub.service';
|
||||||
import {
|
import { Prisma, UserCollection, ReqType as DBReqType } from '@prisma/client';
|
||||||
Prisma,
|
|
||||||
User,
|
|
||||||
UserCollection,
|
|
||||||
ReqType as DBReqType,
|
|
||||||
} from '@prisma/client';
|
|
||||||
import { UserCollection as UserCollectionModel } from './user-collections.model';
|
import { UserCollection as UserCollectionModel } from './user-collections.model';
|
||||||
import { ReqType } from 'src/types/RequestTypes';
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import { isValidLength, stringToJson } from 'src/utils';
|
import { isValidLength, stringToJson } from 'src/utils';
|
||||||
import { CollectionFolder } from 'src/types/CollectionFolder';
|
import { CollectionFolder } from 'src/types/CollectionFolder';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserCollectionService {
|
export class UserCollectionService {
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Field, ID, ObjectType, registerEnumType } from '@nestjs/graphql';
|
import { Field, ID, ObjectType, registerEnumType } from '@nestjs/graphql';
|
||||||
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class UserHistory {
|
export class UserHistory {
|
||||||
@@ -39,11 +40,6 @@ export class UserHistory {
|
|||||||
executedOn: Date;
|
executedOn: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ReqType {
|
|
||||||
REST = 'REST',
|
|
||||||
GQL = 'GQL',
|
|
||||||
}
|
|
||||||
|
|
||||||
registerEnumType(ReqType, {
|
registerEnumType(ReqType, {
|
||||||
name: 'ReqType',
|
name: 'ReqType',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Args, ID, Mutation, Resolver, Subscription } from '@nestjs/graphql';
|
|||||||
import { UserHistoryService } from './user-history.service';
|
import { UserHistoryService } from './user-history.service';
|
||||||
import { PubSubService } from '../pubsub/pubsub.service';
|
import { PubSubService } from '../pubsub/pubsub.service';
|
||||||
import { UserHistory } from './user-history.model';
|
import { UserHistory } from './user-history.model';
|
||||||
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import { UseGuards } from '@nestjs/common';
|
import { UseGuards } from '@nestjs/common';
|
||||||
import { GqlAuthGuard } from '../guards/gql-auth.guard';
|
import { GqlAuthGuard } from '../guards/gql-auth.guard';
|
||||||
import { GqlUser } from '../decorators/gql-user.decorator';
|
import { GqlUser } from '../decorators/gql-user.decorator';
|
||||||
@@ -40,8 +41,9 @@ export class UserHistoryResolver {
|
|||||||
@Args({
|
@Args({
|
||||||
name: 'reqType',
|
name: 'reqType',
|
||||||
description: 'Request type, REST or GQL',
|
description: 'Request type, REST or GQL',
|
||||||
|
type: () => ReqType,
|
||||||
})
|
})
|
||||||
reqType: string,
|
reqType: ReqType,
|
||||||
): Promise<UserHistory> {
|
): Promise<UserHistory> {
|
||||||
const createdHistory = await this.userHistoryService.createUserHistory(
|
const createdHistory = await this.userHistoryService.createUserHistory(
|
||||||
user.uid,
|
user.uid,
|
||||||
@@ -101,8 +103,9 @@ export class UserHistoryResolver {
|
|||||||
@Args({
|
@Args({
|
||||||
name: 'reqType',
|
name: 'reqType',
|
||||||
description: 'Request type, REST or GQL',
|
description: 'Request type, REST or GQL',
|
||||||
|
type: () => ReqType,
|
||||||
})
|
})
|
||||||
reqType: string,
|
reqType: ReqType,
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const deletedHistory = await this.userHistoryService.deleteAllUserHistory(
|
const deletedHistory = await this.userHistoryService.deleteAllUserHistory(
|
||||||
user.uid,
|
user.uid,
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import { UserHistoryService } from './user-history.service';
|
|||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { PubSubService } from '../pubsub/pubsub.service';
|
import { PubSubService } from '../pubsub/pubsub.service';
|
||||||
import { mockDeep, mockReset } from 'jest-mock-extended';
|
import { mockDeep, mockReset } from 'jest-mock-extended';
|
||||||
import { ReqType, UserHistory } from './user-history.model';
|
import { UserHistory } from './user-history.model';
|
||||||
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import {
|
import {
|
||||||
USER_HISTORY_INVALID_REQ_TYPE,
|
USER_HISTORY_INVALID_REQ_TYPE,
|
||||||
USER_HISTORY_NOT_FOUND,
|
USER_HISTORY_NOT_FOUND,
|
||||||
} from '../errors';
|
} from '../errors';
|
||||||
import { ReqType as DBReqType } from '@prisma/client';
|
|
||||||
|
|
||||||
const mockPrisma = mockDeep<PrismaService>();
|
const mockPrisma = mockDeep<PrismaService>();
|
||||||
const mockPubSub = mockDeep<PubSubService>();
|
const mockPubSub = mockDeep<PubSubService>();
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { PubSubService } from '../pubsub/pubsub.service';
|
import { PubSubService } from '../pubsub/pubsub.service';
|
||||||
import { ReqType, UserHistory } from './user-history.model';
|
import { UserHistory } from './user-history.model';
|
||||||
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import * as E from 'fp-ts/Either';
|
import * as E from 'fp-ts/Either';
|
||||||
import * as O from 'fp-ts/Option';
|
import * as O from 'fp-ts/Option';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { Args, Parent, ResolveField, Resolver } from '@nestjs/graphql';
|
import { Args, Parent, ResolveField, Resolver } from '@nestjs/graphql';
|
||||||
import { User } from '../user/user.model';
|
import { User } from '../user/user.model';
|
||||||
import { UserHistoryService } from './user-history.service';
|
import { UserHistoryService } from './user-history.service';
|
||||||
import { ReqType, UserHistory } from './user-history.model';
|
import { UserHistory } from './user-history.model';
|
||||||
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import { PaginationArgs } from '../types/input-types.args';
|
import { PaginationArgs } from '../types/input-types.args';
|
||||||
|
|
||||||
@Resolver(() => User)
|
@Resolver(() => User)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Field, ID, ArgsType } from '@nestjs/graphql';
|
import { Field, ID, ArgsType } from '@nestjs/graphql';
|
||||||
import { PaginationArgs } from 'src/types/input-types.args';
|
import { PaginationArgs } from 'src/types/input-types.args';
|
||||||
import { ReqType } from 'src/user-history/user-history.model';
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export class GetUserRequestArgs extends PaginationArgs {
|
export class GetUserRequestArgs extends PaginationArgs {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
} from '../input-type.args';
|
} from '../input-type.args';
|
||||||
import { AuthUser } from 'src/types/AuthUser';
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
import { User } from 'src/user/user.model';
|
import { User } from 'src/user/user.model';
|
||||||
import { ReqType } from 'src/user-history/user-history.model';
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
||||||
import { SkipThrottle } from '@nestjs/throttler';
|
import { SkipThrottle } from '@nestjs/throttler';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Field, ID, ObjectType } from '@nestjs/graphql';
|
import { Field, ID, ObjectType } from '@nestjs/graphql';
|
||||||
import { ReqType } from 'src/user-history/user-history.model';
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class UserRequest {
|
export class UserRequest {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
import { UserRequest } from './user-request.model';
|
import { UserRequest } from './user-request.model';
|
||||||
import { UserRequestService } from './user-request.service';
|
import { UserRequestService } from './user-request.service';
|
||||||
import { AuthUser } from 'src/types/AuthUser';
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
import { ReqType } from 'src/user-history/user-history.model';
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import { UserCollectionService } from 'src/user-collection/user-collection.service';
|
import { UserCollectionService } from 'src/user-collection/user-collection.service';
|
||||||
|
|
||||||
const mockPrisma = mockDeep<PrismaService>();
|
const mockPrisma = mockDeep<PrismaService>();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
} from 'src/errors';
|
} from 'src/errors';
|
||||||
import { stringToJson } from 'src/utils';
|
import { stringToJson } from 'src/utils';
|
||||||
import { AuthUser } from 'src/types/AuthUser';
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
import { ReqType } from 'src/user-history/user-history.model';
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import { UserCollectionService } from 'src/user-collection/user-collection.service';
|
import { UserCollectionService } from 'src/user-collection/user-collection.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import {
|
|||||||
ObjectType,
|
ObjectType,
|
||||||
ID,
|
ID,
|
||||||
Field,
|
Field,
|
||||||
InputType,
|
|
||||||
registerEnumType,
|
registerEnumType,
|
||||||
} from '@nestjs/graphql';
|
} from '@nestjs/graphql';
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export class UserResolver {
|
|||||||
@Args({
|
@Args({
|
||||||
name: 'sessionType',
|
name: 'sessionType',
|
||||||
description: 'Type of the session',
|
description: 'Type of the session',
|
||||||
|
type: () => SessionType,
|
||||||
})
|
})
|
||||||
sessionType: SessionType,
|
sessionType: SessionType,
|
||||||
): Promise<User> {
|
): Promise<User> {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import * as T from 'fp-ts/Task';
|
|||||||
import * as A from 'fp-ts/Array';
|
import * as A from 'fp-ts/Array';
|
||||||
import { pipe, constVoid } from 'fp-ts/function';
|
import { pipe, constVoid } from 'fp-ts/function';
|
||||||
import { AuthUser } from 'src/types/AuthUser';
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
import { USER_NOT_FOUND, USERS_NOT_FOUND } from 'src/errors';
|
import { USER_NOT_FOUND } from 'src/errors';
|
||||||
import { SessionType, User } from './user.model';
|
import { SessionType, User } from './user.model';
|
||||||
import { USER_UPDATE_FAILED } from 'src/errors';
|
import { USER_UPDATE_FAILED } from 'src/errors';
|
||||||
import { PubSubService } from 'src/pubsub/pubsub.service';
|
import { PubSubService } from 'src/pubsub/pubsub.service';
|
||||||
|
|||||||
Reference in New Issue
Block a user