Skip to content

Commit

Permalink
Merge branch 'main' into feat/bff-my-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
snaerseljan authored Dec 2, 2024
2 parents bc062c0 + 5815544 commit ee3ab58
Show file tree
Hide file tree
Showing 26 changed files with 606 additions and 73 deletions.
43 changes: 36 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
node_modules/
dist/
scripts/ci/
# vi: ft=gitignore

# Known ignores
/.github/
/.git/
/scripts/ci/
/.env.*
/.envrc*
/.nx/

# Cache and packages
**/node_modules/
# Ignoring _all_ cache folders dosen't work, because we have libraries named `cache`
# **/cache/
/.yarn/cache/
/.yarn/install-state*
# Ignores e.g. `cache/` and `cache_outptut/`
/cache*
cache/
.git/
log/
*.log
/.cache*/

# Logs and temporaries
**/log/
**/*.log
**/tmp/
**/temp/

# Outputs
**/dist/
**/out/

# Docker-stuff
**/Dockerfile
**/Dockerfile.*
**/Containerfile
**/Containerfile.*
**/*-compose.yaml
**/*-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,11 @@ export class ApplicationService {
])

const staffList = resultsStaffWithApplications.map((row) => row.staff)
const staffListUniq = [...new Map(staffList.map((v) => [v.id, v])).values()]
const staffListUniq = [
...new Map(
staffList.filter((v) => v !== null).map((v) => [v.id, v]),
).values(),
]

return {
applications: resultsApplications.rows,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,25 @@ export class BackendService extends DataSource<{ req: Request }> {
return this.post(`case/${id}/file`, createFile)
}

createDefendantCaseFile(
id: string,
createFile: unknown,
defendantId: string,
): Promise<CaseFile> {
return this.post(`case/${id}/defendant/${defendantId}/file`, createFile)
}

createCivilClaimantCaseFile(
id: string,
createFile: unknown,
civilClaimantId: string,
): Promise<CaseFile> {
return this.post(
`case/${id}/civilClaimant/${civilClaimantId}/file`,
createFile,
)
}

getCaseFileSignedUrl(
caseId: string,
id: string,
Expand Down Expand Up @@ -439,6 +458,28 @@ export class BackendService extends DataSource<{ req: Request }> {
return this.post(`case/${id}/limitedAccess/file`, createFile)
}

limitedAccessCreateDefendantCaseFile(
id: string,
createFile: unknown,
defendantId: string,
): Promise<CaseFile> {
return this.post(
`case/${id}/limitedAccess$/defendant/${defendantId}/file`,
createFile,
)
}

limitedAccessCreateCivilClaimantCaseFile(
id: string,
createFile: unknown,
civilClaimantId: string,
): Promise<CaseFile> {
return this.post(
`case/${id}/limitedAccess$/civilClaimant/${civilClaimantId}/file`,
createFile,
)
}

limitedAccessGetCaseFileSignedUrl(
caseId: string,
id: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Allow } from 'class-validator'

import { Field, ID, InputType } from '@nestjs/graphql'

import { CreateFileInput } from './createFile.input'

@InputType()
export class CreateCivilClaimantFileInput extends CreateFileInput {
@Allow()
@Field(() => ID)
readonly civilClaimantId!: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Allow } from 'class-validator'

import { Field, ID, InputType } from '@nestjs/graphql'

import { CreateFileInput } from './createFile.input'

@InputType()
export class CreateDefendantFileInput extends CreateFileInput {
@Allow()
@Field(() => ID)
readonly defendantId!: string
}
50 changes: 50 additions & 0 deletions apps/judicial-system/api/src/app/modules/file/file.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import type { User } from '@island.is/judicial-system/types'

import { BackendService } from '../backend'
import { CreateCivilClaimantFileInput } from './dto/createCivilClaimantFile.input'
import { CreateDefendantFileInput } from './dto/createDefendantFile.input'
import { CreateFileInput } from './dto/createFile.input'
import { CreatePresignedPostInput } from './dto/createPresignedPost.input'
import { DeleteFileInput } from './dto/deleteFile.input'
Expand Down Expand Up @@ -77,6 +79,54 @@ export class FileResolver {
)
}

@Mutation(() => CaseFile)
createDefendantFile(
@Args('input', { type: () => CreateDefendantFileInput })
input: CreateDefendantFileInput,
@CurrentGraphQlUser() user: User,
@Context('dataSources')
{ backendService }: { backendService: BackendService },
): Promise<CaseFile> {
const { caseId, defendantId, ...createFile } = input

this.logger.debug(
`Creating a file for case ${caseId} and defendant ${defendantId}`,
)

return this.auditTrailService.audit(
user.id,
AuditedAction.CREATE_FILE,
backendService.createDefendantCaseFile(caseId, createFile, defendantId),
(file) => file.id,
)
}

@Mutation(() => CaseFile)
createCivilClaimantFile(
@Args('input', { type: () => CreateCivilClaimantFileInput })
input: CreateCivilClaimantFileInput,
@CurrentGraphQlUser() user: User,
@Context('dataSources')
{ backendService }: { backendService: BackendService },
): Promise<CaseFile> {
const { caseId, civilClaimantId, ...createFile } = input

this.logger.debug(
`Creating a file for case ${caseId} and civil claimant ${civilClaimantId}`,
)

return this.auditTrailService.audit(
user.id,
AuditedAction.CREATE_FILE,
backendService.createCivilClaimantCaseFile(
caseId,
createFile,
civilClaimantId,
),
(file) => file.id,
)
}

@Query(() => SignedUrl, { nullable: true })
getSignedUrl(
@Args('input', { type: () => GetSignedUrlInput })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import type { User } from '@island.is/judicial-system/types'

import { BackendService } from '../backend'
import { CreateCivilClaimantFileInput } from './dto/createCivilClaimantFile.input'
import { CreateDefendantFileInput } from './dto/createDefendantFile.input'
import { CreateFileInput } from './dto/createFile.input'
import { CreatePresignedPostInput } from './dto/createPresignedPost.input'
import { DeleteFileInput } from './dto/deleteFile.input'
Expand Down Expand Up @@ -76,6 +78,58 @@ export class LimitedAccessFileResolver {
)
}

@Mutation(() => CaseFile)
limitedAccessCreateDefendantFile(
@Args('input', { type: () => CreateDefendantFileInput })
input: CreateDefendantFileInput,
@CurrentGraphQlUser() user: User,
@Context('dataSources')
{ backendService }: { backendService: BackendService },
): Promise<CaseFile> {
const { caseId, defendantId, ...createFile } = input

this.logger.debug(
`Creating a file for case ${caseId} and defendant ${defendantId}`,
)

return this.auditTrailService.audit(
user.id,
AuditedAction.CREATE_FILE,
backendService.limitedAccessCreateDefendantCaseFile(
caseId,
createFile,
defendantId,
),
(file) => file.id,
)
}

@Mutation(() => CaseFile)
limitedAccessCreateCivilClaimantFile(
@Args('input', { type: () => CreateCivilClaimantFileInput })
input: CreateCivilClaimantFileInput,
@CurrentGraphQlUser() user: User,
@Context('dataSources')
{ backendService }: { backendService: BackendService },
): Promise<CaseFile> {
const { caseId, civilClaimantId, ...createFile } = input

this.logger.debug(
`Creating a file for case ${caseId} and civil claimant ${civilClaimantId}`,
)

return this.auditTrailService.audit(
user.id,
AuditedAction.CREATE_FILE,
backendService.limitedAccessCreateCivilClaimantCaseFile(
caseId,
createFile,
civilClaimantId,
),
(file) => file.id,
)
}

@Query(() => SignedUrl, { nullable: true })
limitedAccessGetSignedUrl(
@Args('input', { type: () => GetSignedUrlInput })
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict'

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction(async (t) => {
await queryInterface.addColumn(
'case_file',
'defendant_id',
{
type: Sequelize.UUID,
references: {
model: 'defendant',
key: 'id',
},
allowNull: true,
},
{ transaction: t },
)
await queryInterface.addColumn(
'case_file',
'civil_claimant_id',
{
type: Sequelize.UUID,
references: {
model: 'civil_claimant',
key: 'id',
},
allowNull: true,
},
{ transaction: t },
)
})
},
down: (queryInterface) => {
return queryInterface.sequelize.transaction(async (t) => {
await queryInterface.removeColumn('case_file', 'civil_claimant_id', {
transaction: t,
})
await queryInterface.removeColumn('case_file', 'defendant_id', {
transaction: t,
})
})
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ interface UpdateDateLog {
date?: Date
location?: string
}

export interface UpdateCase
extends Pick<
Case,
Expand Down
Loading

0 comments on commit ee3ab58

Please sign in to comment.