Skip to content

feat: dataChecklist plugin#760

Merged
carlbrugger merged 3 commits intomainfrom
feat/data-checklist-plugin
Feb 21, 2025
Merged

feat: dataChecklist plugin#760
carlbrugger merged 3 commits intomainfrom
feat/data-checklist-plugin

Conversation

@carlbrugger
Copy link
Contributor

Please explain how to summarize this PR for the Changelog:

This release creates a dataChecklistPlugin for ease of use when not using the configureSpace plugin or if you want to keep the Data Checklist Document updated when the workbooks/sheets change.

Tell code reviewer how and what to test:

Just build, run the sandbox listener, and create a space.

@carlbrugger carlbrugger marked this pull request as ready for review February 21, 2025 16:24
@promptless
Copy link

promptless bot commented Feb 21, 2025

📝 Documentation updates detected! You can review documentation updates here

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2025

Walkthrough

This pull request introduces a new dataChecklist plugin associated with the @flatfile/plugin-space-configure. It includes the removal of legacy plugins and updates to the bulkRecordHook to enhance record handling with additional context. The configureSpace function has been refactored to utilize a single contacts sheet and a new submission action, along with a property for tracking changes. Additionally, module exports have been modified to include the new plugin functionality.

Changes

File(s) Change Summary
.changeset/cuddly-moles-rule.md Added new entry for the dataChecklist plugin associated with @flatfile/plugin-space-configure.
flatfilers/sandbox/src/index.ts Removed storedConstraint and ExcelExtractor plugins, updated bulkRecordHook to include FlatfileEvent, removed createDataChecklist from the listener, and refactored configureSpace to use a single contacts sheet with a simpleSubmitAction (label updated to "Submit data") and a new settings property (trackChanges: true).
plugins/space-configure/src/data.checklist.ts Introduced dataChecklistPlugin to listen for workbook:created and workbook:updated events.
plugins/space-configure/src/index.ts Added export statement for dataChecklistPlugin to enhance module exports.
plugins/space-configure/src/utils/data.checklist.ts Renamed createDataChecklist to dataChecklist and refactored logic to update or create a document based on existence.

Sequence Diagram(s)

sequenceDiagram
    participant E as Workbook Event
    participant P as dataChecklistPlugin
    participant D as dataChecklist Function
    participant API as Documents API

    E->>P: Trigger workbook:created/updated event
    P->>D: Invoke dataChecklist with spaceId
    D->>API: List documents for spaceId
    API-->>D: Return document list
    alt Document exists
        D->>API: Update existing "Data Checklist" document
    else
        D->>API: Create new "Data Checklist" document
    end
Loading

Possibly related PRs

  • feat: data checklist #755: The changes in the main PR introduce the dataChecklistPlugin function, while the retrieved PR adds the createDataChecklist function, indicating a direct relationship in their functionality related to data checklist creation.
  • feat: remove remeda & add disableFileNameUpdate option #672: The changes in the main PR, specifically the introduction of the dataChecklistPlugin and modifications to the configureSpace function, are related to the updates made in the retrieved PR regarding the configureSpace function, as both involve alterations to the plugin's configuration and functionality.
  • fix: async/await bug #685: The changes in the main PR, specifically the addition of the dataChecklistPlugin function in configureSpace, are related to the modifications in the retrieved PR, which also involves changes to the configureSpace function, although the focus is on fixing async/await issues rather than introducing new functionality.

Suggested reviewers

  • ncronquist

📜 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 cba0cd8 and 72aabce.

📒 Files selected for processing (1)
  • plugins/space-configure/src/utils/data.checklist.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/space-configure/src/utils/data.checklist.ts
⏰ Context from checks skipped due to timeout of 90000ms (22)
  • GitHub Check: Unit (@flatfile/plugin-enrich-geocode)
  • GitHub Check: Unit (@flatfile/plugin-enrich-gpx)
  • GitHub Check: Unit (@flatfile/plugin-enrich-summarize)
  • GitHub Check: Unit (@flatfile/plugin-convert-currency)
  • GitHub Check: Unit (@flatfile/plugin-validate-number)
  • GitHub Check: Unit (@flatfile/plugin-validate-email)
  • GitHub Check: Unit (@flatfile/plugin-validate-boolean)
  • GitHub Check: Unit (@flatfile/plugin-validate-string)
  • GitHub Check: Unit (@flatfile/plugin-validate-isbn)
  • GitHub Check: Unit (@flatfile/plugin-validate-phone)
  • GitHub Check: Unit (@flatfile/utils-testing)
  • GitHub Check: Unit (@flatfile/util-common)
  • GitHub Check: Unit (@flatfile/plugin-delimiter-extractor)
  • GitHub Check: Unit (@flatfile/plugin-dxp-configure)
  • GitHub Check: Unit (@flatfile/plugin-autocast)
  • GitHub Check: Unit (@flatfile/plugin-record-hook)
  • GitHub Check: Unit (@flatfile/plugin-xml-extractor)
  • GitHub Check: Unit (@flatfile/plugin-convert-openapi-schema)
  • GitHub Check: Unit (@flatfile/plugin-graphql-schema)
  • GitHub Check: Unit (@flatfile/plugin-json-extractor)
  • GitHub Check: Unit (@flatfile/plugin-dedupe)
  • GitHub Check: E2E

🪧 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.

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)
plugins/space-configure/src/data.checklist.ts (1)

5-18: Consider adding error handling and validation.

The plugin implementation looks good, but could benefit from additional error handling and validation:

  1. Validate that spaceId exists in the event context
  2. Add try-catch block around the dataChecklist call
 export function dataChecklistPlugin() {
   return function (listener: FlatfileListener) {
     listener.on(
       ['workbook:created', 'workbook:updated'],
       async (event: FlatfileEvent) => {
         const { spaceId } = event.context
+        if (!spaceId) {
+          console.error('No spaceId found in event context')
+          return
+        }
         console.log(
           `\`dataChecklist\` firing on \`${event.topic}\` for space \`${spaceId}\``
         )
+        try {
           await dataChecklist(spaceId as Flatfile.SpaceId)
+        } catch (error) {
+          console.error('Failed to update data checklist:', error)
+        }
       }
     )
   }
 }
plugins/space-configure/src/utils/data.checklist.ts (1)

51-65: Consider adding error handling and validation.

The document update logic could benefit from additional error handling:

  1. Validate API responses
  2. Add try-catch blocks around API calls
+  try {
     const { data: documents } = await api.documents.list(spaceId)
+    if (!documents) {
+      throw new Error('Failed to retrieve documents')
+    }
     const checklistDocument = documents.find(
       (document) => document.title === 'Data Checklist'
     )
     if (checklistDocument) {
       await api.documents.update(spaceId, checklistDocument.id, {
         title: `Data Checklist`,
         body,
       })
     } else {
       await api.documents.create(spaceId, {
         title: `Data Checklist`,
         body,
       })
     }
+  } catch (error) {
+    console.error('Failed to update data checklist document:', error)
+    throw error
+  }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a14aa0 and 672f72b.

📒 Files selected for processing (5)
  • .changeset/cuddly-moles-rule.md (1 hunks)
  • flatfilers/sandbox/src/index.ts (1 hunks)
  • plugins/space-configure/src/data.checklist.ts (1 hunks)
  • plugins/space-configure/src/index.ts (1 hunks)
  • plugins/space-configure/src/utils/data.checklist.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • plugins/space-configure/src/index.ts
🧰 Additional context used
🪛 LanguageTool
.changeset/cuddly-moles-rule.md

[grammar] ~5-~5: The preposition ‘for’ is repeated. Make sure that it is correct.
Context: ... release creates a dataChecklist plugin for the for ease of use

(IN_DT_IN)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup
🔇 Additional comments (5)
plugins/space-configure/src/data.checklist.ts (1)

1-4: LGTM!

The imports are correctly defined and the dependencies are properly typed.

flatfilers/sandbox/src/index.ts (3)

14-18: Add implementation for the TODO comment.

The bulk record hook contains a TODO comment without any implementation. Consider adding validation or transformation logic for the records.

Do you need assistance implementing the record processing logic?


22-22: LGTM!

The data checklist plugin is correctly integrated into the listener pipeline.


29-41: LGTM!

The space configuration changes look good:

  • Single sheet configuration simplifies the structure
  • Submit action is properly configured
  • Change tracking is enabled
plugins/space-configure/src/utils/data.checklist.ts (1)

5-5: LGTM!

The function signature is correctly updated to reflect its new behavior of creating or updating the checklist.

carlbrugger and others added 2 commits February 21, 2025 12:45
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@carlbrugger carlbrugger merged commit 3df7554 into main Feb 21, 2025
37 checks passed
@carlbrugger carlbrugger deleted the feat/data-checklist-plugin branch February 21, 2025 18:58
@coderabbitai coderabbitai bot mentioned this pull request Feb 28, 2025
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