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(form-system): Application #15444

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

feat(form-system): Application #15444

wants to merge 163 commits into from

Conversation

Hyosam
Copy link
Contributor

@Hyosam Hyosam commented Jul 4, 2024

...

  • An initial shell for the application part of the form-system project within apps/portals/form-system
  • Two libraries to be shared by both the new app and the form building part of the form-system project:
  • graphql library
  • Ui library

Checklist:

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

Summary by CodeRabbit

  • New Features

    • Added a new service for form system integration.
    • Enhanced the LimitedAccessFileController to support specific subpoena retrieval based on IDs.
    • Introduced a new GraphQL client initialization function with error handling and retry mechanisms.
  • Improvements

    • Updated ESLint configuration for stricter module boundary rules and improved TypeScript handling.
    • Adjusted logging and formatting in the FileController for better readability.

Hyosam and others added 30 commits February 1, 2024 15:46
…cript, removed all console.logs and removed all code that was commented out
Hyosam and others added 21 commits October 25, 2024 14:44
This commit adds the form system API setup to the uber-charts/islandis.ts file. This allows the form system service to be used in the application.
@Hyosam Hyosam requested review from a team as code owners December 19, 2024 11:33
Copy link

gitguardian bot commented Dec 19, 2024

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
- - X-API-Key Secret fc7f69d apps/form-builder/services/translationStation.tsx View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

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

🧹 Nitpick comments (2)
apps/judicial-system/api/src/app/modules/file/limitedAccessFile.controller.ts (2)

9-9: Remove unused import.

The Query decorator is imported but not used anywhere in the controller.

-  Query,

23-23: Remove unused import.

The SubpoenaType type is imported but not used in the controller.

-import type { SubpoenaType, User } from '@island.is/judicial-system/types'
+import type { User } from '@island.is/judicial-system/types'
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c747e5b and d1d30ed.

📒 Files selected for processing (4)
  • .eslintrc.json (1 hunks)
  • apps/api/infra/api.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/file/file.controller.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/file/limitedAccessFile.controller.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/judicial-system/api/src/app/modules/file/file.controller.ts
🧰 Additional context used
📓 Path-based instructions (2)
apps/api/infra/api.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/api/src/app/modules/file/limitedAccessFile.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)
.eslintrc.json (1)

45-45: LGTM!

The addition of lib:form-system to the scope:portals-admin dependencies aligns with the PR objectives for the form-system project integration.

apps/api/infra/api.ts (1)

68-68: LGTM!

The addition of formSystemService parameter aligns with the form-system project integration.

Comment on lines +201 to +207
dev: 'http://localhost:3434',
staging: '',
prod: '',
},
// FORM_SYSTEM_API_BASE_PATH: ref(
// (h) => `http://${h.svc(services.formSystemService)}`,
// ),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review environment configuration values.

There are several concerns with the current configuration:

  1. Staging and prod environments have empty string values
  2. Development environment uses a hardcoded localhost URL
  3. There's a commented-out configuration that might be the intended approach using the service reference

Consider either:

  1. Providing proper URLs for staging and prod environments
  2. Using the service reference approach as shown in the commented code
-      FORM_SYSTEM_API_BASE_PATH: {
-        dev: 'http://localhost:3434',
-        staging: '',
-        prod: '',
-      },
-      // FORM_SYSTEM_API_BASE_PATH: ref(
-      //   (h) => `http://${h.svc(services.formSystemService)}`,
-      // ),
+      FORM_SYSTEM_API_BASE_PATH: ref(
+        (h) => `http://${h.svc(services.formSystemService)}`,
+      ),

Committable suggestion skipped: line range outside the PR's diff.

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

🧹 Nitpick comments (2)
libs/portals/form-system/graphql/src/lib/client.ts (2)

11-11: Consider configuring RetryLink with operation-specific retry policies.

The default retry configuration might not be optimal for all operations. Consider customizing the retry logic:

-const retryLink = new RetryLink()
+const retryLink = new RetryLink({
+  delay: {
+    initial: 300,
+    max: 3000,
+    jitter: true
+  },
+  attempts: {
+    max: 3,
+    retryIf: (error, operation) => {
+      // Retry on network errors but not on client errors
+      return !!error && operation.operationName !== 'specialOperation'
+    }
+  }
+})

31-35: Consider configuring InMemoryCache for optimal performance.

The default cache configuration might not be optimal for your use case. Consider customizing it:

 return new ApolloClient({
   link: ApolloLink.from([retryLink, errorLink, httpLink].filter(Boolean)),
-  cache: new InMemoryCache(),
+  cache: new InMemoryCache({
+    typePolicies: {
+      Query: {
+        fields: {
+          // Example: Configure field-specific caching
+          forms: {
+            merge: true,
+            // Custom merge function if needed
+          }
+        }
+      }
+    },
+    possibleTypes: {
+      // Add possible types for interfaces/unions
+    }
+  }),
 })
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1d30ed and e5fc39c.

📒 Files selected for processing (1)
  • libs/portals/form-system/graphql/src/lib/client.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/form-system/graphql/src/lib/client.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."
🔇 Additional comments (2)
libs/portals/form-system/graphql/src/lib/client.ts (2)

1-10: Well-structured imports with good tree-shaking practices!

The imports are properly organized and use specific paths, which is great for tree-shaking. Good choice using cross-fetch for universal fetch support.


25-30: Well-implemented dynamic GraphQL endpoint configuration!

The client initialization with dynamic URI construction based on operation name is a good approach. The function is properly typed and exported, adhering to TypeScript guidelines.

Comment on lines +13 to +23
const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors)
graphQLErrors.map(({ message, locations, path, extensions }) => {
const problem = JSON.stringify(extensions?.problem, null, ' ')
console.log(
`[GraphQL error]: Message: ${message}, Path: ${path}, Problem: ${problem}`,
)
})

if (networkError) console.log(`[Network error]: ${networkError}`)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance error handling for production use.

While the error logging is comprehensive, using console.log in production isn't ideal. Consider these improvements:

 const errorLink = onError(({ graphQLErrors, networkError }) => {
   if (graphQLErrors)
     graphQLErrors.map(({ message, locations, path, extensions }) => {
       const problem = JSON.stringify(extensions?.problem, null, '  ')
-      console.log(
-        `[GraphQL error]: Message: ${message}, Path: ${path}, Problem: ${problem}`,
-      )
+      // Use a proper error tracking service
+      errorTracker.captureException({
+        type: 'GraphQLError',
+        message,
+        path,
+        problem,
+        locations
+      })
     })

-  if (networkError) console.log(`[Network error]: ${networkError}`)
+  if (networkError) {
+    errorTracker.captureException({
+      type: 'NetworkError',
+      error: networkError
+    })
+  }
+  
+  // Allow consuming code to handle errors
+  return forward(operation)
 })

Committable suggestion skipped: line range outside the PR's diff.

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.

4 participants