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

feat: Add endpoint and service for all data models #14668

Merged
merged 8 commits into from
Feb 17, 2025

Conversation

ErlingHauan
Copy link
Contributor

@ErlingHauan ErlingHauan commented Feb 14, 2025

Description

In PR #14625 we limited the data model lookup to the App/models directory. This might be a problem for org-datamodels repos, which often have custom folder structures.

This PR adds GET endpoints which returns all data models in a repo.

Out of scope:

  • Connecting all-json and all-xsd endpoints to query hooks.

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced dedicated endpoints to retrieve both generic and application-specific JSON and XSD data models.
    • Expanded support for accessing schema files directly from application directories.
  • Refactor

    • Updated API naming conventions to improve clarity and consistency.
    • Streamlined client-side paths to align with the updated endpoints.
    • Enhanced method names and signatures for better understanding of functionality.

Copy link
Contributor

coderabbitai bot commented Feb 14, 2025

📝 Walkthrough

Walkthrough

This pull request renames several methods and updates service calls to clarify schema file retrieval. It distinguishes between general schema files and application-specific files by introducing a set of new methods and corresponding API endpoints. The changes span controllers, repository classes, service implementations, interfaces, tests, and frontend API paths. Test cases have been updated to match the new naming conventions, ensuring that both JSON and XSD files are correctly handled in different contexts.

Changes

File(s) Change Summary
backend/src/Designer/Controllers/DatamodelsController.cs Renamed GetDataModels to GetAllJsonDataModels and GetXSDDataModels to GetAllXsdDataModels; added GetAppJsonDataModels and GetAppXsdDataModels with updated service calls.
backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs Introduced a new method GetAllSchemaFiles to retrieve all schema files; renamed GetSchemaFiles to GetAppSchemaFiles for application-specific retrieval.
backend/src/Designer/Services/{Implementation/SchemaModelService.cs, Interfaces/ISchemaModelService.cs} Renamed GetSchemaFiles to GetAllSchemaFiles and added GetAppSchemaFiles in both the service implementation and interface to clarify functionality.
backend/tests/Designer.Tests/{Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs, Services/SchemaModelServiceTests.cs} Updated test methods by renaming them to use GetAllSchemaFiles and added new tests for App schema files, ensuring proper behavior and property validation.
frontend/packages/shared/src/api/{paths.js, queries.ts} Renamed API path functions (dataModelsPathdataModelsAllJsonPath, dataModelsXsdPathdataModelsAllXsdPath); added dataModelsAppJsonPath and dataModelsAppXsdPath; updated query functions to use the new paths.

Possibly related PRs

Suggested labels

area/app-deploy, skip-documentation

Suggested reviewers

  • Konrad-Simso
  • mlqn

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7616767 and 6114a5c.

📒 Files selected for processing (1)
  • backend/src/Designer/Services/Interfaces/ISchemaModelService.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/src/Designer/Services/Interfaces/ISchemaModelService.cs
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Run dotnet build and test (macos-latest)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Run dotnet build and test (windows-latest)
  • GitHub Check: Run integration tests against actual gitea and db
  • GitHub Check: Run dotnet build and test (ubuntu-latest)
  • GitHub Check: Analyze
  • GitHub Check: Testing
  • GitHub Check: CodeQL
  • GitHub Check: Typechecking and linting

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. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added solution/studio/designer Issues related to the Altinn Studio Designer solution. quality/testing Tests that are missing, needs to be created or could be improved. backend frontend labels Feb 14, 2025
@ErlingHauan ErlingHauan marked this pull request as ready for review February 14, 2025 12:27
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3297ab and 7616767.

📒 Files selected for processing (8)
  • backend/src/Designer/Controllers/DatamodelsController.cs (2 hunks)
  • backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs (1 hunks)
  • backend/src/Designer/Services/Implementation/SchemaModelService.cs (1 hunks)
  • backend/src/Designer/Services/Interfaces/ISchemaModelService.cs (1 hunks)
  • backend/tests/Designer.Tests/Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs (3 hunks)
  • backend/tests/Designer.Tests/Services/SchemaModelServiceTests.cs (5 hunks)
  • frontend/packages/shared/src/api/paths.js (1 hunks)
  • frontend/packages/shared/src/api/queries.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Testing
🔇 Additional comments (13)
backend/src/Designer/Services/Interfaces/ISchemaModelService.cs (1)

19-24: LGTM! Clear and descriptive method name.

The renaming from GetSchemaFiles to GetAllSchemaFiles improves clarity by explicitly indicating that the method retrieves all schema files within the repository.

frontend/packages/shared/src/api/queries.ts (1)

113-114: LGTM! Consistent with backend changes.

The functions have been updated to use the new app-specific paths, maintaining alignment with the backend API changes.

frontend/packages/shared/src/api/paths.js (1)

34-37: LGTM! Well-structured path definitions.

The new path functions follow a consistent naming convention and align with the backend route changes, providing clear separation between all models and app-specific models.

backend/src/Designer/Controllers/DatamodelsController.cs (4)

124-131: LGTM! Clear method renaming.

The method name change from GetDataModels to GetAllJsonDataModels improves clarity by explicitly indicating it retrieves all JSON data models.


142-149: LGTM! Consistent method renaming.

The method name change from GetXSDDataModels to GetAllXsdDataModels maintains consistency with the JSON counterpart.


151-167: LGTM! Well-structured new endpoint.

The new GetAppJsonDataModels method follows the established pattern and properly handles app-specific JSON data models.


169-185: LGTM! Consistent implementation.

The new GetAppXsdDataModels method maintains consistency with its JSON counterpart and follows the same implementation pattern.

backend/tests/Designer.Tests/Services/SchemaModelServiceTests.cs (1)

48-49: LGTM! Method calls updated consistently.

The changes correctly update the method calls from GetSchemaFiles to GetAllSchemaFiles while maintaining the same test logic and assertions.

Also applies to: 60-61, 86-87, 98-99, 127-128, 135-136

backend/tests/Designer.Tests/Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs (2)

392-434: LGTM! Test methods renamed consistently.

The test methods have been appropriately renamed to match the new method names in the repository layer while preserving the test logic and assertions.


436-481: LGTM! Comprehensive test coverage for new functionality.

The new test methods provide thorough coverage for the GetAppSchemaFiles functionality, including edge cases and property validation.

backend/src/Designer/Services/Implementation/SchemaModelService.cs (1)

83-96: LGTM! Service layer changes are well-structured.

The service layer changes are consistent with the repository layer changes. The methods are well-documented and follow existing patterns.

backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs (2)

980-991: LGTM! New method follows existing patterns.

The new GetAllSchemaFiles method is well-documented and efficiently reuses existing functionality for finding and mapping files.


993-1014: LGTM! Method renamed while preserving functionality.

The method has been appropriately renamed to GetAppSchemaFiles while maintaining its original functionality and error handling.

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.76%. Comparing base (16630f9) to head (6114a5c).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14668   +/-   ##
=======================================
  Coverage   95.76%   95.76%           
=======================================
  Files        1914     1914           
  Lines       24948    24950    +2     
  Branches     2858     2858           
=======================================
+ Hits        23892    23894    +2     
  Misses        798      798           
  Partials      258      258           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ErlingHauan and others added 2 commits February 14, 2025 13:42
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@ErlingHauan ErlingHauan changed the title feat: Add endpoint org data models feat: Add endpoint and service for all data models Feb 14, 2025
@TomasEng TomasEng self-assigned this Feb 14, 2025
@TomasEng TomasEng removed their assignment Feb 14, 2025
Copy link
Contributor

@Konrad-Simso Konrad-Simso left a comment

Choose a reason for hiding this comment

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

Good work, Tested ok!

@ErlingHauan ErlingHauan merged commit d5dbf50 into main Feb 17, 2025
27 checks passed
@ErlingHauan ErlingHauan deleted the add-endpoint-org-data-models branch February 17, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend frontend quality/testing Tests that are missing, needs to be created or could be improved. solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-domain1
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants