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

[Components] bigdatacorp #14751 #15028

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

[Components] bigdatacorp #14751 #15028

wants to merge 11 commits into from

Conversation

lcaresia
Copy link
Collaborator

@lcaresia lcaresia commented Dec 18, 2024

WHY

Summary by CodeRabbit

  • New Features

    • Introduced actions for retrieving address, company, and person data based on CEP, CNPJ, and CPF numbers, respectively.
    • Added new dataset options for personal, company, and address data retrieval.
  • Bug Fixes

    • Improved error handling in data retrieval actions.
  • Documentation

    • Updated documentation to reflect new actions and dataset properties.
  • Chores

    • Updated version number and added new dependencies for enhanced functionality.

@lcaresia lcaresia self-assigned this Dec 18, 2024
Copy link

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Jan 7, 2025 1:40am
pipedream-docs ⬜️ Ignored (Inspect) Jan 7, 2025 1:40am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jan 7, 2025 1:40am

@lcaresia lcaresia linked an issue Dec 18, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Warning

Rate limit exceeded

@lcaresia has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 47 minutes and 21 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2d29ee4 and d3882ab.

📒 Files selected for processing (5)
  • components/bigdatacorp/actions/get-address-data/get-address-data.mjs (1 hunks)
  • components/bigdatacorp/actions/get-company-data/get-company-data.mjs (1 hunks)
  • components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1 hunks)
  • components/bigdatacorp/bigdatacorp.app.mjs (1 hunks)
  • components/bigdatacorp/common/constants.mjs (1 hunks)

Walkthrough

This pull request introduces a set of new data retrieval actions for BigDataCorp, specifically targeting address, company, and person data based on document identifiers such as CEP and CNPJ. New action modules (get-address-data.mjs, get-company-data.mjs, get-person-data.mjs) have been created, along with updates to the main application file (bigdatacorp.app.mjs) to include new properties and methods for handling requests. Additionally, a constants module has been added to define available datasets, enhancing the application's capability to manage and retrieve various data types.

Changes

File Change Summary
components/bigdatacorp/actions/get-address-data/get-address-data.mjs New action module for retrieving address data with metadata and run method
components/bigdatacorp/actions/get-company-data/get-company-data.mjs New action module for retrieving company data with metadata and run method
components/bigdatacorp/actions/get-person-data/get-person-data.mjs New action module for retrieving person data with metadata and run method
components/bigdatacorp/bigdatacorp.app.mjs Added prop definitions, base URL method, request handling, and data retrieval methods
components/bigdatacorp/common/constants.mjs New constants module with dataset definitions for person, company, and address data
components/bigdatacorp/package.json Updated version and added dependency for @pipedream/platform

Suggested labels

ai-assisted

Suggested reviewers

  • michelle0927

Poem

🐰 Hop, hop, data's on the way!
Addresses, companies, persons today
With constants and methods so neat
BigDataCorp's actions are quite a treat
Retrieving info with rabbit-like speed
Our code hops forward, indeed! 🚀


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.

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: 7

🧹 Nitpick comments (4)
components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1)

7-7: Enhance documentation with rate limits and data privacy notice

The description should include information about rate limits and data privacy considerations when handling CPF data.

Consider updating the description to:

-  description: "Returns the available data for a CPF number according to the selected dataset. [See the documentation](https://docs.bigdatacorp.com.br/plataforma/reference/pessoas_registration_data)",
+  description: "Returns the available data for a CPF number according to the selected dataset. Note: Ensure compliance with LGPD when handling personal data. [See the documentation](https://docs.bigdatacorp.com.br/plataforma/reference/pessoas_registration_data)",
components/bigdatacorp/actions/get-address-data/get-address-data.mjs (1)

1-40: Consider adding rate limiting protection

All three components make API calls to BigDataCorp's services but don't implement any rate limiting protection.

Consider implementing a rate limiter in the app.mjs file and reusing it across all components. I can help implement this if needed.

components/bigdatacorp/bigdatacorp.app.mjs (2)

6-17: Consider enhancing prop definitions with validation and options

While the documentation is clear, consider these improvements:

  1. Add validation for document numbers (CPF, CNPJ, CEP) using regex patterns
  2. Make dataset a dropdown by adding options that references the constants from constants.mjs
 propDefinitions: {
   doc: {
     type: "string",
     label: "Document Number",
     description: "Document Number of the entity you want to search for, i.e.: `128.982.560-21` for CPF, `27.823.957/0001-94` CNPJ and `88048-656` for CEP",
+    pattern: "^\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}$|^\\d{2}\\.\\d{3}\\.\\d{3}\\/\\d{4}-\\d{2}$|^\\d{5}-\\d{3}$",
+    errorMessage: "Please enter a valid CPF, CNPJ, or CEP format",
   },
   dataset: {
     type: "string",
     label: "Dataset",
     description: "The target dataset to which the query will be sent",
+    options: ({ path }) => {
+      const constants = require("./common/constants.mjs");
+      return path.includes("person")
+        ? constants.PERSON_DATASETS
+        : path.includes("company")
+          ? constants.COMPANY_DATASETS
+          : constants.ADDRESS_DATASETS;
+    },
   },
 },

19-21: Consider environment-specific configuration for base URL

The base URL should be configurable for different environments (staging, production, etc.).

 _baseUrl() {
-  return "https://plataforma.bigdatacorp.com.br";
+  return this.$auth.base_url || "https://plataforma.bigdatacorp.com.br";
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1554545 and 28249a0.

📒 Files selected for processing (6)
  • components/bigdatacorp/actions/get-address-data/get-address-data.mjs (1 hunks)
  • components/bigdatacorp/actions/get-company-data/get-company-data.mjs (1 hunks)
  • components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1 hunks)
  • components/bigdatacorp/bigdatacorp.app.mjs (1 hunks)
  • components/bigdatacorp/common/constants.mjs (1 hunks)
  • components/bigdatacorp/package.json (1 hunks)
🔇 Additional comments (2)
components/bigdatacorp/package.json (2)

Line range hint 1-18: LGTM! Package structure follows best practices

The package.json is well-structured with:

  • Proper metadata and documentation fields
  • Correct main entry point configuration
  • Appropriate public access configuration

15-17: Verify @pipedream/platform version compatibility

Let's ensure we're using a suitable version of the platform package.

✅ Verification successful

Based on the results, I can now generate the final response since I have enough information to verify the platform package version compatibility:

@pipedream/platform version ^3.0.3 is appropriate

The version ^3.0.3 specified in the package.json is appropriate because:

  • It matches the latest published version (3.0.3) from npm
  • Several recently updated components like zoho_crm, zoho_sheet, zoho_books, and others are using the same version
  • The caret (^) allows for compatible minor and patch updates while maintaining major version stability
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check latest version of @pipedream/platform and its usage in other components
# Check latest published version
npm view @pipedream/platform version

# Check how other components are using this package
rg -g "package.json" "\"@pipedream/platform\":" components/ -A 1 -B 1

Length of output: 65900

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

Looks good, just a few comments.

michelle0927
michelle0927 previously approved these changes Dec 20, 2024
Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM! Ready for QA

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 (5)
components/bigdatacorp/bigdatacorp.app.mjs (2)

19-21: Consider environment configuration for base URL

The base URL is hardcoded. Consider moving it to environment configuration for better flexibility across different environments.

🧰 Tools
🪛 eslint

[error] 20-20: Strings must use doublequote.

(quotes)


40-59: Reduce duplication in data retrieval methods

The methods could be improved with:

  1. Input validation for the args parameter
  2. TypeScript/JSDoc for better type safety
  3. Common base method to reduce duplication
+/**
+ * @typedef {Object} DataRequest
+ * @property {string} doc - Document number
+ * @property {string} dataset - Target dataset
+ */

+/**
+ * @param {string} type - Data type (person|company|address)
+ * @param {DataRequest} args - Request arguments
+ */
+async _getData(type, args = {}) {
+  const { data } = args;
+  if (!data?.Datasets || !data?.q) {
+    throw new Error("Dataset and query are required parameters");
+  }
+  return this._makeRequest({
+    path: `/${type}s`,
+    method: "post",
+    ...args,
+  });
+}

-async getPersonData(args = {}) {
+async getPersonData(args = {}) {
+  return this._getData("person", args);
+},

-async getCompanyData(args = {}) {
+async getCompanyData(args = {}) {
+  return this._getData("company", args);
+},

-async getAddressData(args = {}) {
+async getAddressData(args = {}) {
+  return this._getData("address", args);
+},
components/bigdatacorp/common/constants.mjs (1)

2-20: Extract common datasets to reduce duplication

The same dataset entries are duplicated between PERSON_DATASETS and COMPANY_DATASETS. Consider extracting these into a shared constant.

+/** @type {Array<{value: string, label: string}>} */
+const COMMON_DATASETS = [
+  { "value": "emails_extended", "label": "Emails" },
+  { "value": "phones_extended", "label": "Phones" },
+  { "value": "registration_data", "label": "Registration Data" },
+  { "value": "related_people_emails", "label": "Related People Emails" },
+  { "value": "related_people_phones", "label": "Related People Phones" },
+  { "value": "related_people_addresses", "label": "Related People Addresses" },
+];

 export default {
   PERSON_DATASETS: [
-    { "value": "emails_extended", "label": "Emails" },
-    { "value": "phones_extended", "label": "Phones" },
-    { "value": "registration_data", "label": "Registration Data" },
-    { "value": "related_people_emails", "label": "Related People Emails" },
-    { "value": "related_people_phones", "label": "Related People Phones" },
-    { "value": "related_people_addresses", "label": "Related People Addresses" },
+    ...COMMON_DATASETS,
     { "value": "vehicles", "label": "Vehicles" },
   ],
   COMPANY_DATASETS: [
-    { "value": "emails_extended", "label": "Emails" },
-    { "value": "phones_extended", "label": "Phones" },
-    { "value": "registration_data", "label": "Registration Data" },
-    { "value": "related_people_emails", "label": "Related People Emails" },
-    { "value": "related_people_phones", "label": "Related People Phones" },
-    { "value": "related_people_addresses", "label": "Related People Addresses" },
+    ...COMMON_DATASETS,
     { "value": "political_involvement", "label": "Political Involvement" },
     { "value": "online_ads", "label": "Online Ads" },
   ],
🧰 Tools
🪛 eslint

[error] 3-3: Expected a line break after this opening brace.

(object-curly-newline)


[error] 3-3: Object properties must go on a new line.

(object-property-newline)


[error] 3-3: Expected a line break before this closing brace.

(object-curly-newline)


[error] 4-4: Expected a line break after this opening brace.

(object-curly-newline)


[error] 4-4: Object properties must go on a new line.

(object-property-newline)


[error] 4-4: Expected a line break before this closing brace.

(object-curly-newline)


[error] 5-5: Expected a line break after this opening brace.

(object-curly-newline)


[error] 5-5: Object properties must go on a new line.

(object-property-newline)


[error] 5-5: Expected a line break before this closing brace.

(object-curly-newline)


[error] 6-6: Expected a line break after this opening brace.

(object-curly-newline)


[error] 6-6: Object properties must go on a new line.

(object-property-newline)


[error] 6-6: Expected a line break before this closing brace.

(object-curly-newline)


[error] 7-7: Expected a line break after this opening brace.

(object-curly-newline)


[error] 7-7: Object properties must go on a new line.

(object-property-newline)


[error] 7-7: Expected a line break before this closing brace.

(object-curly-newline)


[error] 8-8: Expected a line break after this opening brace.

(object-curly-newline)


[error] 8-8: Object properties must go on a new line.

(object-property-newline)


[error] 8-8: Expected a line break before this closing brace.

(object-curly-newline)


[error] 9-9: Expected a line break after this opening brace.

(object-curly-newline)


[error] 9-9: Object properties must go on a new line.

(object-property-newline)


[error] 9-9: Expected a line break before this closing brace.

(object-curly-newline)


[error] 12-12: Expected a line break after this opening brace.

(object-curly-newline)


[error] 12-12: Object properties must go on a new line.

(object-property-newline)


[error] 12-12: Expected a line break before this closing brace.

(object-curly-newline)


[error] 13-13: Expected a line break after this opening brace.

(object-curly-newline)


[error] 13-13: Object properties must go on a new line.

(object-property-newline)


[error] 13-13: Expected a line break before this closing brace.

(object-curly-newline)


[error] 14-14: Expected a line break after this opening brace.

(object-curly-newline)


[error] 14-14: Object properties must go on a new line.

(object-property-newline)


[error] 14-14: Expected a line break before this closing brace.

(object-curly-newline)


[error] 15-15: Expected a line break after this opening brace.

(object-curly-newline)


[error] 15-15: Object properties must go on a new line.

(object-property-newline)


[error] 15-15: Expected a line break before this closing brace.

(object-curly-newline)


[error] 16-16: Expected a line break after this opening brace.

(object-curly-newline)


[error] 16-16: Object properties must go on a new line.

(object-property-newline)


[error] 16-16: Expected a line break before this closing brace.

(object-curly-newline)


[error] 17-17: Expected a line break after this opening brace.

(object-curly-newline)


[error] 17-17: Object properties must go on a new line.

(object-property-newline)


[error] 17-17: Expected a line break before this closing brace.

(object-curly-newline)


[error] 18-18: Expected a line break after this opening brace.

(object-curly-newline)


[error] 18-18: Object properties must go on a new line.

(object-property-newline)


[error] 18-18: Expected a line break before this closing brace.

(object-curly-newline)


[error] 19-19: Expected a line break after this opening brace.

(object-curly-newline)


[error] 19-19: Object properties must go on a new line.

(object-property-newline)


[error] 19-19: Expected a line break before this closing brace.

(object-curly-newline)

components/bigdatacorp/actions/get-address-data/get-address-data.mjs (1)

15-34: Fix missing trailing commas

Add trailing commas to maintain consistent code style as indicated by the linter.

Apply these fixes:

         app,
-        "doc"
+        "doc",
       ],
       description: "Zipcode of the address you want to search for, i.e.: `88048-656`"
+      ,
     },
     dataset: {
       propDefinition: [
         app,
-        "dataset"
+        "dataset",
       ],
-      options: constants.ADDRESS_DATASETS,
+      options: constants.ADDRESS_DATASETS,
     }
   },
🧰 Tools
🪛 eslint

[error] 15-16: Missing trailing comma.

(comma-dangle)


[error] 17-18: Missing trailing comma.

(comma-dangle)


[error] 22-23: Missing trailing comma.

(comma-dangle)


[error] 25-26: Missing trailing comma.

(comma-dangle)

🪛 GitHub Check: Lint Code Base

[failure] 15-15:
Missing trailing comma


[failure] 17-17:
Missing trailing comma


[failure] 22-22:
Missing trailing comma


[failure] 25-25:
Missing trailing comma


[failure] 34-34:
Missing trailing comma

components/bigdatacorp/actions/get-company-data/get-company-data.mjs (1)

1-41: Consider extracting common validation logic

All three modules share similar validation and error handling patterns. Consider extracting this logic into a shared utility function.

Create a new utility file common/validation.mjs:

export const cleanDocumentNumber = (doc) => doc.replace(/\D/g, '');

export const validateDocument = (doc, type) => {
  const cleanDoc = cleanDocumentNumber(doc);
  const validations = {
    cpf: { length: 11, name: 'CPF' },
    cnpj: { length: 14, name: 'CNPJ' },
    zipcode: { length: 8, name: 'Zipcode' }
  };

  const validation = validations[type];
  if (!validation) {
    throw new Error(`Unknown document type: ${type}`);
  }

  if (cleanDoc.length !== validation.length) {
    throw new Error(`Invalid ${validation.name} format. Must be ${validation.length} digits.`);
  }

  return cleanDoc;
};

Then use it in each module:

import { validateDocument } from '../../common/validation.mjs';

// In run method:
const cleanDoc = validateDocument(this.doc, 'cpf'); // or 'cnpj' or 'zipcode'
🧰 Tools
🪛 eslint

[error] 15-16: Missing trailing comma.

(comma-dangle)


[error] 17-18: Missing trailing comma.

(comma-dangle)


[error] 22-23: Missing trailing comma.

(comma-dangle)


[error] 25-26: Missing trailing comma.

(comma-dangle)


[error] 34-35: Missing trailing comma.

(comma-dangle)

🪛 GitHub Check: Lint Code Base

[failure] 15-15:
Missing trailing comma


[failure] 17-17:
Missing trailing comma


[failure] 22-22:
Missing trailing comma


[failure] 25-25:
Missing trailing comma


[failure] 34-34:
Missing trailing comma

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c696b5c and 2d29ee4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • components/bigdatacorp/actions/get-address-data/get-address-data.mjs (1 hunks)
  • components/bigdatacorp/actions/get-company-data/get-company-data.mjs (1 hunks)
  • components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1 hunks)
  • components/bigdatacorp/bigdatacorp.app.mjs (1 hunks)
  • components/bigdatacorp/common/constants.mjs (1 hunks)
🧰 Additional context used
🪛 eslint
components/bigdatacorp/common/constants.mjs

[error] 3-3: Expected a line break after this opening brace.

(object-curly-newline)


[error] 3-3: Object properties must go on a new line.

(object-property-newline)


[error] 3-3: Expected a line break before this closing brace.

(object-curly-newline)


[error] 4-4: Expected a line break after this opening brace.

(object-curly-newline)


[error] 4-4: Object properties must go on a new line.

(object-property-newline)


[error] 4-4: Expected a line break before this closing brace.

(object-curly-newline)


[error] 5-5: Expected a line break after this opening brace.

(object-curly-newline)


[error] 5-5: Object properties must go on a new line.

(object-property-newline)


[error] 5-5: Expected a line break before this closing brace.

(object-curly-newline)


[error] 6-6: Expected a line break after this opening brace.

(object-curly-newline)


[error] 6-6: Object properties must go on a new line.

(object-property-newline)


[error] 6-6: Expected a line break before this closing brace.

(object-curly-newline)


[error] 7-7: Expected a line break after this opening brace.

(object-curly-newline)


[error] 7-7: Object properties must go on a new line.

(object-property-newline)


[error] 7-7: Expected a line break before this closing brace.

(object-curly-newline)


[error] 8-8: Expected a line break after this opening brace.

(object-curly-newline)


[error] 8-8: Object properties must go on a new line.

(object-property-newline)


[error] 8-8: Expected a line break before this closing brace.

(object-curly-newline)


[error] 9-9: Expected a line break after this opening brace.

(object-curly-newline)


[error] 9-9: Object properties must go on a new line.

(object-property-newline)


[error] 9-9: Expected a line break before this closing brace.

(object-curly-newline)


[error] 12-12: Expected a line break after this opening brace.

(object-curly-newline)


[error] 12-12: Object properties must go on a new line.

(object-property-newline)


[error] 12-12: Expected a line break before this closing brace.

(object-curly-newline)


[error] 13-13: Expected a line break after this opening brace.

(object-curly-newline)


[error] 13-13: Object properties must go on a new line.

(object-property-newline)


[error] 13-13: Expected a line break before this closing brace.

(object-curly-newline)


[error] 14-14: Expected a line break after this opening brace.

(object-curly-newline)


[error] 14-14: Object properties must go on a new line.

(object-property-newline)


[error] 14-14: Expected a line break before this closing brace.

(object-curly-newline)


[error] 15-15: Expected a line break after this opening brace.

(object-curly-newline)


[error] 15-15: Object properties must go on a new line.

(object-property-newline)


[error] 15-15: Expected a line break before this closing brace.

(object-curly-newline)


[error] 16-16: Expected a line break after this opening brace.

(object-curly-newline)


[error] 16-16: Object properties must go on a new line.

(object-property-newline)


[error] 16-16: Expected a line break before this closing brace.

(object-curly-newline)


[error] 17-17: Expected a line break after this opening brace.

(object-curly-newline)


[error] 17-17: Object properties must go on a new line.

(object-property-newline)


[error] 17-17: Expected a line break before this closing brace.

(object-curly-newline)


[error] 18-18: Expected a line break after this opening brace.

(object-curly-newline)


[error] 18-18: Object properties must go on a new line.

(object-property-newline)


[error] 18-18: Expected a line break before this closing brace.

(object-curly-newline)


[error] 19-19: Expected a line break after this opening brace.

(object-curly-newline)


[error] 19-19: Object properties must go on a new line.

(object-property-newline)


[error] 19-19: Expected a line break before this closing brace.

(object-curly-newline)


[error] 22-22: Expected a line break after this opening brace.

(object-curly-newline)


[error] 22-22: Object properties must go on a new line.

(object-property-newline)


[error] 22-22: Expected a line break before this closing brace.

(object-curly-newline)


[error] 23-23: Expected a line break after this opening brace.

(object-curly-newline)


[error] 23-23: Object properties must go on a new line.

(object-property-newline)


[error] 23-23: Expected a line break before this closing brace.

(object-curly-newline)


[error] 24-24: Expected a line break after this opening brace.

(object-curly-newline)


[error] 24-24: Object properties must go on a new line.

(object-property-newline)


[error] 24-24: Expected a line break before this closing brace.

(object-curly-newline)


[error] 25-25: Expected a line break after this opening brace.

(object-curly-newline)


[error] 25-25: Object properties must go on a new line.

(object-property-newline)


[error] 25-25: Expected a line break before this closing brace.

(object-curly-newline)


[error] 26-26: Expected a line break after this opening brace.

(object-curly-newline)


[error] 26-26: Object properties must go on a new line.

(object-property-newline)


[error] 26-26: Expected a line break before this closing brace.

(object-curly-newline)


[error] 27-27: Expected a line break after this opening brace.

(object-curly-newline)


[error] 27-27: Object properties must go on a new line.

(object-property-newline)


[error] 27-27: Expected a line break before this closing brace.

(object-curly-newline)


[error] 28-29: Missing trailing comma.

(comma-dangle)


[error] 29-29: Newline required at end of file but not found.

(eol-last)


[error] 29-29: Missing semicolon.

(semi)

components/bigdatacorp/actions/get-company-data/get-company-data.mjs

[error] 15-16: Missing trailing comma.

(comma-dangle)


[error] 17-18: Missing trailing comma.

(comma-dangle)


[error] 22-23: Missing trailing comma.

(comma-dangle)


[error] 25-26: Missing trailing comma.

(comma-dangle)


[error] 34-35: Missing trailing comma.

(comma-dangle)

components/bigdatacorp/actions/get-address-data/get-address-data.mjs

[error] 15-16: Missing trailing comma.

(comma-dangle)


[error] 17-18: Missing trailing comma.

(comma-dangle)


[error] 22-23: Missing trailing comma.

(comma-dangle)


[error] 25-26: Missing trailing comma.

(comma-dangle)


[error] 34-35: Missing trailing comma.

(comma-dangle)

components/bigdatacorp/actions/get-person-data/get-person-data.mjs

[error] 15-16: Missing trailing comma.

(comma-dangle)


[error] 17-18: Missing trailing comma.

(comma-dangle)


[error] 22-23: Missing trailing comma.

(comma-dangle)


[error] 25-26: Missing trailing comma.

(comma-dangle)


[error] 34-35: Missing trailing comma.

(comma-dangle)

components/bigdatacorp/bigdatacorp.app.mjs

[error] 20-20: Strings must use doublequote.

(quotes)


[error] 34-34: Strings must use doublequote.

(quotes)

🪛 GitHub Check: Lint Code Base
components/bigdatacorp/actions/get-company-data/get-company-data.mjs

[failure] 15-15:
Missing trailing comma


[failure] 17-17:
Missing trailing comma


[failure] 22-22:
Missing trailing comma


[failure] 25-25:
Missing trailing comma


[failure] 34-34:
Missing trailing comma

components/bigdatacorp/actions/get-address-data/get-address-data.mjs

[failure] 15-15:
Missing trailing comma


[failure] 17-17:
Missing trailing comma


[failure] 22-22:
Missing trailing comma


[failure] 25-25:
Missing trailing comma


[failure] 34-34:
Missing trailing comma

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (6)
components/bigdatacorp/bigdatacorp.app.mjs (1)

22-39: 🛠️ Refactor suggestion

Enhance request handling with retries and error handling

The request wrapper should include:

  1. Error handling with meaningful error messages
  2. Retry logic for transient failures
  3. Request timeout configuration
 async _makeRequest(opts = {}) {
   const {
     $ = this,
     path,
     headers,
+    timeout = 10000,
+    retries = 3,
     ...otherOpts
   } = opts;
-  return axios($, {
-    ...otherOpts,
-    url: this._baseUrl() + path,
-    headers: {
-      ...headers,
-      "Accept": "application/json",
-      "AccessToken": `${this.$auth.access_token}`,
-      "TokenId": `${this.$auth.token_id}`,
-    },
-  });
+  let attempt = 0;
+  while (attempt < retries) {
+    try {
+      return await axios($, {
+        ...otherOpts,
+        url: this._baseUrl() + path,
+        timeout,
+        headers: {
+          ...headers,
+          "Accept": "application/json",
+          "AccessToken": `${this.$auth.access_token}`,
+          "TokenId": `${this.$auth.token_id}`,
+        },
+      });
+    } catch (err) {
+      attempt++;
+      if (attempt === retries || !this._isRetryableError(err)) {
+        throw new Error(`BigDataCorp API request failed: ${err.message}`);
+      }
+      await new Promise(resolve => setTimeout(resolve, 1000 * attempt));
+    }
+  }
 }

Likely invalid or redundant comment.

🧰 Tools
🪛 eslint

[error] 34-34: Strings must use doublequote.

(quotes)

components/bigdatacorp/common/constants.mjs (1)

23-23: ⚠️ Potential issue

Fix typo in dataset label

There's a typo in "Enviromental" (missing 'n').

-    { "value": "environmental_preservation_areas", "label": "Enviromental Preservation Areas" },
+    { "value": "environmental_preservation_areas", "label": "Environmental Preservation Areas" },

Likely invalid or redundant comment.

🧰 Tools
🪛 eslint

[error] 23-23: Expected a line break after this opening brace.

(object-curly-newline)


[error] 23-23: Object properties must go on a new line.

(object-property-newline)


[error] 23-23: Expected a line break before this closing brace.

(object-curly-newline)

components/bigdatacorp/actions/get-address-data/get-address-data.mjs (2)

12-18: 🛠️ Refactor suggestion

Rename doc prop to zipcode for clarity

The prop name doc is too generic for a zipcode field. This should be renamed to match its specific purpose.

Apply this diff:

-    doc: {
+    zipcode: {
       propDefinition: [
         app,
-        "doc",
+        "zipcode"
       ],
       description: "Zipcode of the address you want to search for, i.e.: `88048-656`",
     },

Likely invalid or redundant comment.

🧰 Tools
🪛 eslint

[error] 15-16: Missing trailing comma.

(comma-dangle)


[error] 17-18: Missing trailing comma.

(comma-dangle)

🪛 GitHub Check: Lint Code Base

[failure] 15-15:
Missing trailing comma


[failure] 17-17:
Missing trailing comma


28-40: ⚠️ Potential issue

Add error handling and zipcode validation

The run method needs proper error handling and input validation for the zipcode format.

Apply this improvement:

   async run({ $ }) {
+    // Remove any non-digit characters from zipcode
+    const cleanZipcode = this.zipcode.replace(/\D/g, '');
+    
+    // Validate that zipcode is in the correct format (8 digits)
+    if (!/^\d{8}$/.test(cleanZipcode)) {
+      throw new Error("Invalid zipcode format. Must be 8 digits.");
+    }
+
+    try {
       const response = await this.app.getAddressData({
         $,
         data: {
           Datasets: this.dataset,
-          q: `zipcode{${this.doc}}`,
+          q: `zipcode{${cleanZipcode}}`,
         },
       });
 
       $.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
 
       return response;
+    } catch (error) {
+      throw new Error(`Failed to fetch address data: ${error.message}`);
+    }
   },

Likely invalid or redundant comment.

🧰 Tools
🪛 eslint

[error] 34-35: Missing trailing comma.

(comma-dangle)

🪛 GitHub Check: Lint Code Base

[failure] 34-34:
Missing trailing comma

components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1)

28-40: ⚠️ Potential issue

Add error handling and CPF validation

The run method needs proper error handling and validation for the sensitive CPF data.

Apply this improvement:

   async run({ $ }) {
+    // Remove any non-digit characters from CPF
+    const cleanCPF = this.doc.replace(/\D/g, '');
+    
+    // Validate that CPF is in the correct format (11 digits)
+    if (!/^\d{11}$/.test(cleanCPF)) {
+      throw new Error("Invalid CPF format. Must be 11 digits.");
+    }
+
+    try {
       const response = await this.app.getPersonData({
         $,
         data: {
           Datasets: this.dataset,
-          q: `doc{${this.doc}}`,
+          q: `doc{${cleanCPF}}`,
         },
       });
 
       $.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
 
       return response;
+    } catch (error) {
+      throw new Error(`Failed to fetch person data: ${error.message}`);
+    }
   },

Likely invalid or redundant comment.

🧰 Tools
🪛 eslint

[error] 34-35: Missing trailing comma.

(comma-dangle)

components/bigdatacorp/actions/get-company-data/get-company-data.mjs (1)

28-40: ⚠️ Potential issue

Add error handling and CNPJ validation

The run method needs proper error handling and validation for the sensitive CNPJ data.

Apply this improvement:

   async run({ $ }) {
+    // Remove any non-digit characters from CNPJ
+    const cleanCNPJ = this.doc.replace(/\D/g, '');
+    
+    // Validate that CNPJ is in the correct format (14 digits)
+    if (!/^\d{14}$/.test(cleanCNPJ)) {
+      throw new Error("Invalid CNPJ format. Must be 14 digits.");
+    }
+
+    try {
       const response = await this.app.getCompanyData({
         $,
         data: {
           Datasets: this.dataset,
-          q: `doc{${this.doc}}`,
+          q: `doc{${cleanCNPJ}}`,
         },
       });
 
       $.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
 
       return response;
+    } catch (error) {
+      throw new Error(`Failed to fetch company data: ${error.message}`);
+    }
   },

Likely invalid or redundant comment.

🧰 Tools
🪛 eslint

[error] 34-35: Missing trailing comma.

(comma-dangle)

🪛 GitHub Check: Lint Code Base

[failure] 34-34:
Missing trailing comma

components/bigdatacorp/bigdatacorp.app.mjs Show resolved Hide resolved
$,
data: {
Datasets: this.dataset,
q: `zipcode{${this.doc}}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The documentation shows using square brackets instead of curly brackets here. I suggest testing to see which one is correct before making this change.

Suggested change
q: `zipcode{${this.doc}}`,
q: `zipcode[${this.doc}]`,

},
});

$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest checking the status here, and throwing an error if it's not successful.

Suggested change
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
const status = response.Status[this.dataset[0].Message;
if (status === "OK") {
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
} else {
throw new Error(status);
}

},
});

$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest checking the status here, and throwing an error if it's not successful.

Suggested change
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
const status = response.Status[this.dataset[0].Message;
if (status === "OK") {
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
} else {
throw new Error(status);
}

},
});

$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest checking the status here, and throwing an error if it's not successful.

Suggested change
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${response.Status[this.dataset][0].Message}`);
const status = response.Status[this.dataset[0].Message;
if (status === "OK") {
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
} else {
throw new Error(status);
}

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.

[Components] bigdatacorp
2 participants