Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(j-s): Send signed court record to police for investigation cases #17196

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

unakb
Copy link
Member

@unakb unakb commented Dec 11, 2024

Við erum að senda úrskurði og þingbækur of snemma í LÖKE

What

Send signed court record to police for investigation cases

Why

Because prosecutors sometimes need to use it when continuing the investigation

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Added functionality to deliver signed court records to the police.
    • Introduced messaging capabilities for signed court records in the case management system.
    • Added a new message type for delivering signed court records to police.
  • Bug Fixes

    • Corrected error message for case creation.
  • Tests

    • Added unit tests for delivering signed court records to the police.
    • Implemented tests for security guards associated with the delivery method.

@unakb unakb requested a review from a team as a code owner December 11, 2024 08:40
Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jest > @jest/core > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > tempy > del > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/codegen > [email protected]: Glob versions prior to v9 are no longer supported
warning react-native > @react-native/community-cli-plugin > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning react-native > @react-native/community-cli-plugin > @react-native/dev-middleware > @rnx-kit/chromium-edge-launcher > [email protected]: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
warning next-auth > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning next-auth > [email protected]: this version is no longer supported
warning next-auth > @next-auth/typeorm-legacy-adapter > typeorm > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > stylus > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > webpack-dev-server > [email protected]: Rimraf versions prior to v4 are no longer supported
warning @nx/next > @nx/webpack > fork-ts-checker-webpack-plugin > [email protected]: this will be v4
warning @nx/next > @nx/webpack > webpack-dev-server > webpack-dev-middleware > [email protected]: this will be v4
warning workspace-aggregator-4ad485d8-e311-423d-8747-fafb1fd85a07 > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.

Walkthrough

The changes in this pull request introduce new methods in the CaseService, InternalCaseController, and InternalCaseService classes to enhance the handling of signed court records. A method for adding messages to a queue for signed court records is added, along with a new delivery method to send these records to the police. Additionally, unit tests are created to ensure the functionality and security of these methods. Error messages have been updated for clarity, and improvements to the message service are made to handle empty message scenarios.

Changes

File Change Summary
apps/judicial-system/backend/src/app/modules/case/case.service.ts Added method addMessagesForSignedCourtRecordToQueue to send messages for signed court records. Updated getCourtRecordSignatureConfirmation to call the new method.
apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts Added method deliverSignedCourtRecordToPolice for delivering signed court records to the police with appropriate guards.
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts Added methods deliverSignedCourtRecordToPolice and getSignedCourtRecordPdf for retrieving and delivering signed court records. Corrected error message in deliverSignedRulingToPolice.
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPolice.spec.ts Introduced unit tests for deliverSignedCourtRecordToPolice method in InternalCaseController.
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPoliceGuards.spec.ts Introduced unit tests for guards associated with deliverSignedCourtRecordToPolice.
apps/judicial-system/web/messages/Core/errors.ts Updated error message identifier and default message for createCase.
libs/judicial-system/message/src/lib/message.service.ts Added early return in sendMessagesToQueue method for handling empty messages.
libs/judicial-system/message/src/lib/message.ts Added enum value DELIVERY_TO_POLICE_SIGNED_COURT_RECORD and corresponding entry in messageEndpoint.

Possibly related PRs

  • feat(j-s): Civil Demands #16010: The changes in the main PR involve adding a new method in the CaseService class that sends messages related to signed court records, which aligns with the modifications in the case.service.ts file of this PR that also enhances messaging functionality for case files.
  • feat(j-s): Deliver Confirmed Indictment Ruling to Court #17104: The main PR's updates to the addMessagesForCompletedIndictmentCaseToQueue method to include specific case file categories relate to the changes in this PR that also modify message handling for completed indictment cases.
  • feat(j-s): Upload Additional Files to Court #17152: The main PR's focus on uploading confirmed court records and enhancing messaging for indictment cases connects with the updates in this PR that allow for the upload of additional files related to indictment cases and improve messaging functionality.

Suggested labels

automerge


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (5)
libs/judicial-system/message/src/lib/message.service.ts (2)

201-203: Consider adding debug logging for empty message arrays.

To help with monitoring and debugging, consider logging when an empty message array is received:

   if (messages.length === 0) {
+    this.logger.debug('Received empty message array, skipping queue operation')
     return // No messages to send
   }

Line range hint 1-203: Excellent message queue implementation for handling court records.

The MessageService implementation is robust and well-suited for handling sensitive court records:

  • Proper AWS SQS integration with batch processing
  • Built-in retry mechanisms and error handling
  • Configurable queue parameters
  • Type-safe implementation

The service is well-positioned to handle the delivery of signed court records to police reliably and securely.

apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPoliceGuards.spec.ts (1)

14-15: Consider using a more specific type annotation instead of any[]

Replace the eslint-disable comment with a proper type definition for better type safety.

-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  let guards: any[]
+  let guards: Array<new () => CanActivate>
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPolice.spec.ts (2)

44-48: Enhance error handling setup with specific error cases

The current error setup uses a generic 'Some error' message. Consider using specific error types and messages that match real scenarios.

-    mockGetGeneratedObject.mockRejectedValue(new Error('Some error'))
+    mockGetGeneratedObject.mockRejectedValue(new Error('Failed to retrieve court record from S3'))
-    mockUpdatePoliceCase.mockRejectedValue(new Error('Some error'))
+    mockUpdatePoliceCase.mockRejectedValue(new Error('Failed to update police case: Invalid document format'))

55-56: Refactor promise handling to avoid assignments in expressions

The current implementation assigns values in then/catch expressions, which is flagged by static analysis.

-        .then((result) => (then.result = result))
-        .catch((error) => (then.error = error))
+        .then((result) => {
+          then.result = result;
+        })
+        .catch((error) => {
+          then.error = error;
+        })
🧰 Tools
🪛 Biome (1.9.4)

[error] 55-55: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 56-56: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0423040 and d056354.

📒 Files selected for processing (8)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPolice.spec.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPoliceGuards.spec.ts (1 hunks)
  • apps/judicial-system/web/messages/Core/errors.ts (1 hunks)
  • libs/judicial-system/message/src/lib/message.service.ts (1 hunks)
  • libs/judicial-system/message/src/lib/message.ts (2 hunks)
👮 Files not reviewed due to content moderation or server errors (3)
  • apps/judicial-system/web/messages/Core/errors.ts
  • apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts
🧰 Additional context used
📓 Path-based instructions (8)
libs/judicial-system/message/src/lib/message.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/judicial-system/message/src/lib/message.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPoliceGuards.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPolice.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/messages/Core/errors.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (2)
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPoliceGuards.spec.ts (4)
Learnt from: gudjong
PR: island-is/island.is#16389
File: apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getIndictmentPdfGuards.spec.ts:24-25
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In certain scenarios within the judicial-system backend, the `RolesGuard` may intentionally follow the `CaseExistsGuard` when specific roles rules require the guard order to be reversed, as seen in tests like `getIndictmentPdfGuards.spec.ts`.
Learnt from: gudjong
PR: island-is/island.is#16389
File: apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts:175-185
Timestamp: 2024-11-12T15:15:20.157Z
Learning: In the Jest tests for the `LimitedAccessViewCaseFileGuard` in `apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts`, code duplication in the `beforeEach` blocks is acceptable and should remain unchanged.
Learnt from: gudjong
PR: island-is/island.is#16389
File: apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getCaseFilesRecordPdfRolesRules.spec.ts:1-1
Timestamp: 2024-11-12T15:15:20.157Z
Learning: The usage of `defenderRule` in the following test files is intentional and should remain unchanged:

- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createPresignedPostRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/deleteCaseFileRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createCaseFileRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/getCaseFileSignedUrlRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getRulingPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getRequestPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getCourtRecordPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getByIdRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getAllFilesZipRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/caseController/getAllRolesRules.spec.ts`
Learnt from: gudjong
PR: island-is/island.is#15241
File: apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedRulingToPolice.spec.ts:41-42
Timestamp: 2024-11-12T15:15:26.274Z
Learning: User gudjong prefers not to make changes to error handling messages in test setups at this time.
apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1)
Learnt from: gudjong
PR: island-is/island.is#15393
File: apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts:28-28
Timestamp: 2024-11-12T15:15:11.835Z
Learning: The `DeliverCancellationNoticeDto` import in `apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts` is used in the `deliverIndictmentCancellationNoticeToCourt` method.
🪛 Biome (1.9.4)
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPolice.spec.ts

[error] 55-55: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 56-56: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (4)
libs/judicial-system/message/src/lib/message.service.ts (1)

201-203: LGTM! Good defensive programming practice.

The early return for empty message arrays is a good optimization that prevents unnecessary AWS SQS API calls.

apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedCourtRecordToPoliceGuards.spec.ts (1)

49-51: Verify the case types allowed for police delivery

The test confirms that both restriction and investigation cases are allowed. This aligns with the PR objectives mentioning investigation cases, but we should verify if restriction cases should also be included.

✅ Verification successful

Allowing both restriction and investigation cases for police delivery is correct

Based on the codebase analysis, the inclusion of both restriction cases (ADMISSION_TO_FACILITY, CUSTODY, TRAVEL_BAN) and investigation cases (AUTOPSY, BANKING_SECRECY_WAIVER, etc.) for police delivery is intentional and correct. This is consistently implemented across multiple endpoints in the codebase, particularly in file and case controllers where police-related operations are involved. The test is correctly verifying this established pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if restriction cases are handled similarly in other police delivery endpoints
ast-grep --pattern 'CaseTypeGuard.*\[...restrictionCases, ...investigationCases\]'

Length of output: 84


Script:

#!/bin/bash
# Let's search for case type guards in a broader context
ast-grep --pattern 'CaseTypeGuard'

# Also search for files containing both restrictionCases and investigationCases
rg -l "restrictionCases.*investigationCases|investigationCases.*restrictionCases"

# Let's check the actual implementation of the endpoint
rg -A 5 "deliverSignedCourtRecordToPolice" 

Length of output: 35828


Script:

#!/bin/bash
# Let's check the implementation of CaseTypeGuard and case types
rg -A 10 "export const restrictionCases|export const investigationCases" 

# Also check the implementation of the endpoint in the service
rg -A 10 "class InternalCaseService" 

Length of output: 2844

libs/judicial-system/message/src/lib/message.ts (1)

26-26: LGTM! Message type and endpoint mapping follow established patterns

The new message type DELIVERY_TO_POLICE_SIGNED_COURT_RECORD and its endpoint mapping are consistent with existing police delivery message types.

Also applies to: 66-66

✅ Verification successful

Let me verify the consistency of police delivery message types and their usage with another search.


New message type follows consistent naming and implementation patterns

The verification confirms that:

  • The new message type follows the established DELIVERY_TO_POLICE_* naming pattern
  • Its endpoint mapping deliverSignedCourtRecordToPolice follows the camelCase pattern used by other police delivery endpoints
  • The message type is properly used in both the controller and service layers
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the new endpoint is used consistently
rg "DELIVERY_TO_POLICE_SIGNED_COURT_RECORD" -A 1

Length of output: 1000


Script:

#!/bin/bash
# Check all police delivery related message types and their patterns
rg "DELIVERY_TO_POLICE" -A 1 libs/judicial-system/message/src/lib/message.ts

# Check the corresponding endpoint implementations
ast-grep --pattern 'deliverSignedCourtRecordToPolice($$$) {
  $$$
}'

Length of output: 1289

apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)

1924-1925: LGTM!

The addition of addMessagesForSignedCourtRecordToQueue is well-placed after successful upload and update operations, maintaining consistency with similar patterns in the codebase.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 6 lines in your changes missing coverage. Please review.

Project coverage is 35.77%. Comparing base (5c8c1b9) to head (b9f7579).

Files with missing lines Patch % Lines
...ckend/src/app/modules/case/internalCase.service.ts 66.66% 3 Missing ⚠️
...ystem/backend/src/app/modules/case/case.service.ts 75.00% 2 Missing ⚠️
...judicial-system/message/src/lib/message.service.ts 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17196   +/-   ##
=======================================
  Coverage   35.76%   35.77%           
=======================================
  Files        6931     6931           
  Lines      147959   147985   +26     
  Branches    42168    42175    +7     
=======================================
+ Hits        52922    52943   +21     
- Misses      95037    95042    +5     
Flag Coverage Δ
air-discount-scheme-backend 48.20% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
api-catalogue-services 75.81% <ø> (ø)
api-domains-air-discount-scheme 37.90% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.42% <ø> (ø)
api-domains-criminal-record 47.92% <ø> (ø)
api-domains-driving-license 44.81% <ø> (ø)
api-domains-education 31.22% <ø> (ø)
api-domains-mortgage-certificate 35.16% <ø> (ø)
api-domains-payment-schedule 42.04% <ø> (ø)
application-api-files 61.73% <ø> (ø)
application-core 76.01% <ø> (ø)
application-system-api 38.75% <ø> (-0.01%) ⬇️
application-template-api-modules 27.80% <ø> (+0.01%) ⬆️
application-templates-accident-notification 28.93% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.78% <ø> (ø)
application-templates-driving-license 18.12% <ø> (ø)
application-templates-estate 13.79% <ø> (ø)
application-templates-example-payment 24.71% <ø> (ø)
application-templates-financial-aid 14.42% <ø> (ø)
application-templates-general-petition 23.13% <ø> (ø)
application-templates-inheritance-report 6.54% <ø> (ø)
application-templates-marriage-conditions 15.11% <ø> (ø)
application-templates-mortgage-certificate 43.56% <ø> (ø)
application-templates-parental-leave 29.95% <ø> (ø)
application-types 6.57% <ø> (ø)
application-ui-components 1.24% <ø> (ø)
application-ui-shell 22.43% <ø> (ø)
auth-admin-web 2.43% <ø> (ø)
auth-nest-tools 31.52% <ø> (ø)
auth-shared 75.00% <ø> (ø)
clients-charge-fjs-v2 28.35% <ø> (ø)
clients-driving-license 40.79% <ø> (ø)
clients-driving-license-book 43.83% <ø> (ø)
clients-financial-statements-inao 49.59% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-middlewares 72.89% <ø> (ø)
clients-regulations 42.87% <ø> (ø)
clients-rsk-company-registry 31.04% <ø> (ø)
clients-rsk-personal-tax-return 38.32% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.41% <ø> (ø)
clients-zendesk 50.46% <ø> (ø)
cms 0.40% <ø> (ø)
cms-translations 38.75% <ø> (ø)
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.20% <ø> (ø)
contentful-apps 4.72% <ø> (ø)
dokobit-signing 62.10% <ø> (ø)
email-service 60.07% <ø> (ø)
feature-flags 90.76% <ø> (ø)
file-storage 45.86% <ø> (ø)
financial-aid-backend 51.40% <ø> (ø)
financial-aid-shared 17.88% <ø> (ø)
icelandic-names-registry-backend 54.33% <ø> (ø)
infra-nest-server 48.06% <ø> (ø)
infra-tracing 69.63% <ø> (ø)
island-ui-core 30.92% <ø> (ø)
judicial-system-api 20.16% <ø> (ø)
judicial-system-audit-trail 68.94% <ø> (ø)
judicial-system-backend 55.90% <73.07%> (+0.02%) ⬆️
judicial-system-formatters 78.28% <ø> (ø)
judicial-system-message 66.48% <66.66%> (+<0.01%) ⬆️
judicial-system-message-handler 48.16% <33.33%> (-0.08%) ⬇️
judicial-system-scheduler 70.88% <33.33%> (-0.10%) ⬇️
judicial-system-types 42.22% <ø> (ø)
judicial-system-web 27.89% <ø> (ø)
license-api 42.91% <ø> (ø)
localization 10.15% <ø> (ø)
logging 58.02% <ø> (ø)
message-queue 67.76% <ø> (ø)
nest-audit 65.78% <ø> (ø)
nest-aws 51.93% <ø> (ø)
nest-config 76.38% <ø> (ø)
nest-core 53.16% <ø> (ø)
nest-feature-flags 50.37% <ø> (-0.63%) ⬇️
nest-problem 45.64% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.13% <ø> (ø)
nova-sms 61.42% <ø> (ø)
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.76% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-admin-api 52.55% <ø> (ø)
services-auth-delegation-api 58.44% <ø> (-0.09%) ⬇️
services-auth-ids-api 52.54% <ø> (+0.01%) ⬆️
services-auth-public-api 49.39% <ø> (-0.01%) ⬇️
services-sessions 65.30% <ø> (ø)
services-university-gateway 49.53% <ø> (+0.11%) ⬆️
services-user-notification 46.58% <ø> (ø)
services-user-profile 56.98% <ø> (ø)
shared-components 30.08% <ø> (ø)
shared-form-fields 33.88% <ø> (ø)
shared-mocking 58.64% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.31% <ø> (ø)
web 2.43% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...nd/src/app/modules/case/internalCase.controller.ts 97.00% <100.00%> (+0.11%) ⬆️
apps/judicial-system/web/messages/Core/errors.ts 100.00% <ø> (ø)
libs/judicial-system/message/src/lib/message.ts 100.00% <100.00%> (ø)
...judicial-system/message/src/lib/message.service.ts 80.58% <50.00%> (-0.61%) ⬇️
...ystem/backend/src/app/modules/case/case.service.ts 90.28% <75.00%> (-0.23%) ⬇️
...ckend/src/app/modules/case/internalCase.service.ts 84.04% <66.66%> (-0.39%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c8c1b9...b9f7579. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 11, 2024

Datadog Report

All test runs 8591928 🔗

98 Total Test Services: 0 Failed, 90 Passed
🔻 Test Sessions change in coverage: 5 decreased, 1 increased (+0.04%), 194 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 63 0 22.75s N/A Link
air-discount-scheme-web 0 0 0 2 0 7.97s N/A Link
api 0 0 0 4 0 3.14s N/A Link
api-catalogue-services 0 0 0 23 0 11.67s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 20.41s N/A Link
api-domains-assets 0 0 0 3 0 12.68s N/A Link
api-domains-auth-admin 0 0 0 18 0 14s 1 no change Link
api-domains-communications 0 0 0 5 0 34.05s N/A Link
api-domains-criminal-record 0 0 0 5 0 9.97s N/A Link
api-domains-driving-license 0 0 0 23 0 34.03s N/A Link

🔻 Code Coverage Decreases vs Default Branch (5)

  • nest-feature-flags - jest 56.24% (-0.45%) - Details
  • judicial-system-scheduler - jest 76.55% (-0.12%) - Details
  • judicial-system-message-handler - jest 51.22% (-0.1%) - Details
  • services-auth-delegation-api - jest 50.43% (-0.04%) - Details
  • judicial-system-message - jest 68.19% (-0.01%) - Details

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1)

579-583: Consider adding rate limiting for this endpoint.

Since this endpoint handles sensitive documents (signed court records), consider adding rate limiting to prevent potential abuse.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9137c72 and a27a612.

📒 Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (2)
apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (2)

574-601: LGTM! The implementation follows established patterns and meets security requirements.

The new endpoint for delivering signed court records to police is well-implemented with:

  • Appropriate guards ensuring case existence, type restrictions, and completion status
  • Proper logging for audit trails
  • Consistent error handling through the service layer
  • Type-safe parameter handling with decorators

576-576: Verify case type guard configuration.

The guard allows both restriction and investigation cases, but PR objectives specifically mention investigation cases. Please confirm if restriction cases should also be included.

✅ Verification successful

The case type guard configuration is correctly implemented

The consistent pattern of using both restriction and investigation cases across multiple endpoints in the codebase, particularly for court record and ruling-related operations, indicates this is an intentional design. The guard is used in endpoints handling:

  • Court record delivery
  • Signed rulings
  • Case conclusions
  • Appeals processes

This implementation ensures both restriction and investigation cases have the necessary access controls for these judicial operations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if restriction cases should have access to signed court records
# by looking for related business logic or documentation

# Check for any documentation about restriction cases and signed court records
rg -i "restriction.*signed.*court.*record" --type md

# Look for existing usage patterns of signed court records with case types
ast-grep --pattern 'new CaseTypeGuard([...restrictionCases, ...investigationCases])'

Length of output: 4313


Script:

#!/bin/bash
# Let's check the case type guard usage context and the endpoint definition

# Check the endpoint and its surrounding context
rg -B 5 -A 5 "new CaseTypeGuard\(\[\.\.\.restrictionCases, \.\.\.investigationCases\]\)" apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts

# Look for case type definitions and constants
rg "restrictionCases|investigationCases" apps/judicial-system/backend/src/app/shared/constants.ts

# Check for any documentation about case types
fd README.md | xargs rg -i "case.*type|restriction.*case|investigation.*case"

Length of output: 3302


Script:

#!/bin/bash
# Let's check the actual constants file location and its content

# Find the constants file that defines case types
fd -e ts constants

# Check the message types being used in these endpoints
rg "MessageType\." apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts -A 1

Length of output: 12337

Copy link
Member

@gudjong gudjong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants