-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[Components] bigdatacorp #14751 #15028
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis pull request introduces several new action modules for BigDataCorp, specifically designed to retrieve address, company, and person data based on document identifiers such as Zipcode and CNPJ. The new modules ( Changes
Suggested labels
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 noticeThe 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 protectionAll 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 optionsWhile the documentation is clear, consider these improvements:
- Add validation for document numbers (CPF, CNPJ, CEP) using regex patterns
- Make dataset a dropdown by adding
optionsthat references the constants fromconstants.mjspropDefinitions: { 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 URLThe 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
📒 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
michelle0927
left a comment
There was a problem hiding this 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.
components/bigdatacorp/actions/get-address-data/get-address-data.mjs
Outdated
Show resolved
Hide resolved
Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
…ta.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
…ta.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
michelle0927
left a comment
There was a problem hiding this 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
There was a problem hiding this 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 URLThe 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 methodsThe methods could be improved with:
- Input validation for the args parameter
- TypeScript/JSDoc for better type safety
- 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 duplicationThe 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 commasAdd 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 commacomponents/bigdatacorp/actions/get-company-data/get-company-data.mjs (1)
1-41: Consider extracting common validation logicAll 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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis 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 suggestionEnhance request handling with retries and error handling
The request wrapper should include:
- Error handling with meaningful error messages
- Retry logic for transient failures
- 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 issueFix 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 suggestionRename
docprop tozipcodefor clarityThe prop name
docis 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 issueAdd 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 commacomponents/bigdatacorp/actions/get-person-data/get-person-data.mjs (1)
28-40:⚠️ Potential issueAdd 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 issueAdd 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/actions/get-address-data/get-address-data.mjs
Outdated
Show resolved
Hide resolved
components/bigdatacorp/actions/get-address-data/get-address-data.mjs
Outdated
Show resolved
Hide resolved
components/bigdatacorp/actions/get-company-data/get-company-data.mjs
Outdated
Show resolved
Hide resolved
components/bigdatacorp/actions/get-person-data/get-person-data.mjs
Outdated
Show resolved
Hide resolved
…ta.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
…ta.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
….mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
…ta.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
There was a problem hiding this 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
♻️ Duplicate comments (2)
components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1)
37-42:⚠️ Potential issueFix syntax error in status check.
There's a syntax error in the status check that's causing pipeline failures.
- const 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); }🧰 Tools
🪛 Biome (1.9.4)
[error] 37-37: expected
]but instead found;Remove ;
(parse)
🪛 GitHub Actions: Pull Request Checks
[error] 37-37: Parsing error: Unexpected token ;
components/bigdatacorp/actions/get-company-data/get-company-data.mjs (1)
37-42:⚠️ Potential issueFix syntax error in status check.
There's a syntax error in the status check that's causing pipeline failures.
- const 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); }🧰 Tools
🪛 Biome (1.9.4)
[error] 37-37: expected
]but instead found;Remove ;
(parse)
🪛 GitHub Actions: Pull Request Checks
[error] 37-37: Parsing error: Unexpected token ;
🧹 Nitpick comments (2)
components/bigdatacorp/bigdatacorp.app.mjs (2)
22-39: Add retry logic and improve error handling.Enhance the request wrapper with retry logic for transient failures and better error messages.
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) { + throw new Error(`BigDataCorp API request failed: ${err.message}`); + } + await new Promise(resolve => setTimeout(resolve, 1000 * attempt)); + } + } },
40-59: Reduce duplication in data retrieval methods.Create a base method to handle common functionality and reduce code 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 paths = { + person: "/pessoas", + company: "/empresas", + address: "/enderecos" + }; + return this._makeRequest({ + path: paths[type], + method: "post", + ...args, + }); + }, + - async getPersonData(args = {}) { - return this._makeRequest({ - path: "/pessoas", - method: "post", - ...args, - }); - }, + async getPersonData(args = {}) { + return this._getData("person", args); + }, - async getCompanyData(args = {}) { - return this._makeRequest({ - path: "/empresas", - method: "post", - ...args, - }); - }, + async getCompanyData(args = {}) { + return this._getData("company", args); + }, - async getAddressData(args = {}) { - return this._makeRequest({ - path: "/enderecos", - method: "post", - ...args, - }); - }, + async getAddressData(args = {}) { + return this._getData("address", args); + },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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)
🚧 Files skipped from review as they are similar to previous changes (1)
- components/bigdatacorp/common/constants.mjs
🧰 Additional context used
🪛 Biome (1.9.4)
components/bigdatacorp/actions/get-company-data/get-company-data.mjs
[error] 37-37: expected ] but instead found ;
Remove ;
(parse)
components/bigdatacorp/actions/get-address-data/get-address-data.mjs
[error] 37-37: expected ] but instead found ;
Remove ;
(parse)
components/bigdatacorp/actions/get-person-data/get-person-data.mjs
[error] 37-37: expected ] but instead found ;
Remove ;
(parse)
🪛 GitHub Actions: Pull Request Checks
components/bigdatacorp/actions/get-company-data/get-company-data.mjs
[error] 37-37: Parsing error: Unexpected token ;
components/bigdatacorp/actions/get-address-data/get-address-data.mjs
[error] 37-37: Parsing error: Unexpected token ;
components/bigdatacorp/actions/get-person-data/get-person-data.mjs
[error] 37-37: Parsing error: Unexpected token ;
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (5)
components/bigdatacorp/actions/get-address-data/get-address-data.mjs (2)
12-18: 🛠️ Refactor suggestionRename
docprop tozipcodefor clarity.The prop name should match its purpose. Since this is specifically for ZIP codes, rename it to be more explicit.
- 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.
28-35:⚠️ Potential issueAdd CEP validation and error handling.
Add proper validation for the Brazilian postal code (CEP) format and wrap the API call in a try-catch block.
async run({ $ }) { + // Remove non-numeric characters and validate CEP format + const cep = this.doc.replace(/\D/g, ''); + if (!/^\d{8}$/.test(cep)) { + throw new Error("Invalid CEP format. Must be 8 digits."); + } + + try { const response = await this.app.getAddressData({ $, data: { Datasets: this.dataset, - q: `zipcode[${this.doc}]`, + q: `zipcode[${cep}]`, }, }); + } catch (error) { + throw new Error(`Failed to fetch address data: ${error.message}`); + }Likely invalid or redundant comment.
components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1)
28-35:⚠️ Potential issueAdd CPF validation and error handling.
Add proper validation for the Brazilian CPF format and wrap the API call in a try-catch block.
async run({ $ }) { + // Remove non-numeric characters and validate CPF format + const cpf = this.doc.replace(/\D/g, ''); + if (!/^\d{11}$/.test(cpf)) { + 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{${cpf}}`, }, }); + } catch (error) { + throw new Error(`Failed to fetch person data: ${error.message}`); + }Likely invalid or redundant comment.
components/bigdatacorp/actions/get-company-data/get-company-data.mjs (1)
28-35:⚠️ Potential issueAdd CNPJ validation and error handling.
Add proper validation for the Brazilian CNPJ format and wrap the API call in a try-catch block.
async run({ $ }) { + // Remove non-numeric characters and validate CNPJ format + const cnpj = this.doc.replace(/\D/g, ''); + if (!/^\d{14}$/.test(cnpj)) { + 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{${cnpj}}`, }, }); + } catch (error) { + throw new Error(`Failed to fetch company data: ${error.message}`); + }Likely invalid or redundant comment.
components/bigdatacorp/bigdatacorp.app.mjs (1)
7-16: 🛠️ Refactor suggestionCreate specific props for each document type.
The generic
docprop is used for different document types (CPF, CNPJ, CEP). Create specific props for better type safety and validation.- doc: { - type: "string", - label: "Document Number", - description: "Document Number of the entity you want to search for", - }, + cpf: { + type: "string", + label: "CPF Number", + description: "CPF number of the person you want to search for", + }, + cnpj: { + type: "string", + label: "CNPJ Number", + description: "CNPJ number of the company you want to search for", + }, + cep: { + type: "string", + label: "CEP", + description: "CEP (postal code) of the address you want to search for", + },Likely invalid or redundant comment.
| 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); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix syntax error in status check.
There's a syntax error in the status check that's causing pipeline failures.
- const 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);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 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); | |
| } | |
| 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); | |
| } |
🧰 Tools
🪛 Biome (1.9.4)
[error] 37-37: expected ] but instead found ;
Remove ;
(parse)
🪛 GitHub Actions: Pull Request Checks
[error] 37-37: Parsing error: Unexpected token ;
There was a problem hiding this 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
♻️ Duplicate comments (1)
components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1)
10-26:⚠️ Potential issueAdd CPF format validation.
While the props are well-structured, the
docproperty should include format validation to ensure valid CPF numbers.Add validation to ensure the CPF is in the correct format:
doc: { propDefinition: [ app, "doc", ], description: "Document Number of the entity you want to search for, i.e.: `128.982.560-21`", + validate: (value) => { + // Remove non-digits for validation + const digits = value.replace(/\D/g, ''); + if (!/^\d{11}$/.test(digits)) { + throw new Error("Invalid CPF format. Must be 11 digits."); + } + return true; + }, },
🧹 Nitpick comments (1)
components/bigdatacorp/actions/get-person-data/get-person-data.mjs (1)
4-9: Consider enhancing the description.The metadata is well-structured, but the description could be more specific about the required CPF format and any limitations.
- 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 (format: XXX.XXX.XXX-XX) according to the selected dataset. Rate limits and usage quotas may apply. [See the documentation](https://docs.bigdatacorp.com.br/plataforma/reference/pessoas_registration_data)",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
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)
🚧 Files skipped from review as they are similar to previous changes (2)
- components/bigdatacorp/actions/get-company-data/get-company-data.mjs
- components/bigdatacorp/actions/get-address-data/get-address-data.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
- GitHub Check: pnpm publish
🔇 Additional comments (2)
components/bigdatacorp/actions/get-person-data/get-person-data.mjs (2)
1-2: LGTM!The imports are correctly structured and include the necessary dependencies.
28-46: 🛠️ Refactor suggestionEnhance error handling.
While the status checking is good, the error handling could be more robust.
Add comprehensive error handling:
async run({ $ }) { + try { const response = await this.app.getPersonData({ $, data: { Datasets: this.dataset, q: `doc{${this.doc}}`, }, }); + if (!response?.Status?.[this.dataset]?.[0]?.Message) { + throw new Error("Invalid response format from API"); + } + 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); + throw new Error(`API Error: ${status}`); } return response; + } catch (error) { + throw new Error(`Failed to fetch person data: ${error.message}`); + } },Likely invalid or redundant comment.
WHY
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores