Skip to content

Commit

Permalink
fix codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnlaugurG committed May 21, 2024
1 parent e6eba48 commit c6899ef
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
DelegationType,
DelegationTypeModel,
Domain,
getPersonalRepresentativeDelegationType,
InactiveReason,
MergedDelegationDTO,
PersonalRepresentative,
Expand Down Expand Up @@ -57,6 +56,7 @@ import {
personalRepresentativeType,
} from '../../../test/stubs/personalRepresentativeStubs'
import { AuthDelegationProvider } from 'delegation'
import { getPersonalRepresentativeDelegationType } from '@island.is/shared/types'

describe('DelegationsController', () => {
describe('Given a user is authenticated', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { User } from '@island.is/auth-nest-tools'
import {
AuthDelegationProvider,
AuthDelegationType,
getPersonalRepresentativeDelegationType,
} from '@island.is/shared/types'

import { ApiScope } from '../resources/models/api-scope.model'
Expand All @@ -16,8 +17,8 @@ import { DelegationIndex } from './models/delegation-index.model'
import { DelegationIndexMeta } from './models/delegation-index-meta.model'
import { DelegationDTO } from './dto/delegation.dto'
import {
DelegationRecordInputDTO,
DelegationRecordDTO,
DelegationRecordInputDTO,
PaginatedDelegationRecordDTO,
} from './dto/delegation-index.dto'
import { DelegationsIncomingCustomService } from './delegations-incoming-custom.service'
Expand All @@ -29,9 +30,9 @@ import {
PersonalRepresentativeDelegationType,
} from './types/delegationRecord'
import {
delegationProviderTypeMap,
validateDelegationTypeAndProvider,
validateToAndFromNationalId,
delegationProviderTypeMap,
} from './utils/delegations'
import { DelegationDirection } from './types/delegationDirection'
import { UserIdentitiesService } from '../user-identities/user-identities.service'
Expand Down Expand Up @@ -101,8 +102,8 @@ const validateCrudParams = (delegation: DelegationRecordInputDTO) => {
}
}

export const getPersonalRepresentativeDelegationType = (right: string) =>
`${AuthDelegationType.PersonalRepresentative}:${right}` as PersonalRepresentativeDelegationType
// export const getPersonalRepresentativeDelegationType = (right: string) =>
// `${AuthDelegationType.PersonalRepresentative}:${right}` as PersonalRepresentativeDelegationType

const hasAllSameScopes = (
a: string[] | undefined,
Expand Down Expand Up @@ -457,7 +458,9 @@ export class DelegationsIndexService {

const delegations = delegation.rights.map((right) => ({
...delegation,
type: getPersonalRepresentativeDelegationType(right.code),
type: getPersonalRepresentativeDelegationType(
right.code,
) as PersonalRepresentativeDelegationType,
}))

return [...acc, ...delegations]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { DelegationProviderModel } from '../delegations/models/delegation-provid
PersonalRepresentativeRightType,
PersonalRepresentativeScopePermission,
PersonalRepresentativeType,
PersonalRepresentativeDelegationTypeModel,
DelegationProviderModel,
DelegationTypeModel,
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'
import { InjectModel } from '@nestjs/sequelize'
import { Op, WhereOptions } from 'sequelize'
import { Sequelize } from 'sequelize-typescript'

import { getPersonalRepresentativeDelegationType } from '@island.is/shared/types'

import { PaginatedPersonalRepresentativeDto } from '../dto/paginated-personal-representative.dto'
import { PaginationWithNationalIdsDto } from '../dto/pagination-with-national-ids.dto'
import { PersonalRepresentativeCreateDTO } from '../dto/personal-representative-create.dto'
Expand All @@ -15,7 +18,6 @@ import { InactiveReason } from '../models/personal-representative.enum'
import { PersonalRepresentative } from '../models/personal-representative.model'
import { PersonalRepresentativeDelegationTypeModel } from '../models/personal-representative-delegation-type.model'
import { DelegationTypeModel } from '../../delegations/models/delegation-type.model'
import { getPersonalRepresentativeDelegationType } from '../../delegations/delegations-index.service'

type GetByPersonalRepresentativeOptions = {
nationalIdPersonalRepresentative: string
Expand Down
1 change: 1 addition & 0 deletions libs/shared/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './lib/static-text'
export * from './lib/delegation'
export * from './lib/environment'
export * from './lib/searchable-content-types'
export * from './lib/PersonalRepresentativeDelegationType'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { AuthDelegationType } from '..'

export const getPersonalRepresentativeDelegationType = (right: string) =>
`${AuthDelegationType.PersonalRepresentative}:${right}`

0 comments on commit c6899ef

Please sign in to comment.