-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
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 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. 📒 Files selected for processing (5)
WalkthroughThis 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 ( 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
options
that references the constants fromconstants.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 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
components/bigdatacorp/actions/get-person-data/get-person-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-address-data/get-address-data.mjs
Outdated
Show resolved
Hide resolved
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 <[email protected]>
…ta.mjs Co-authored-by: michelle0927 <[email protected]>
…ta.mjs Co-authored-by: michelle0927 <[email protected]>
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.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 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
doc
prop tozipcode
for clarityThe 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 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
$, | ||
data: { | ||
Datasets: this.dataset, | ||
q: `zipcode{${this.doc}}`, |
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.
The documentation shows using square brackets instead of curly brackets here. I suggest testing to see which one is correct before making this 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}`); |
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.
I suggest checking the status here, and throwing an error if it's not successful.
$.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}`); |
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.
I suggest checking the status here, and throwing an error if it's not successful.
$.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}`); |
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.
I suggest checking the status here, and throwing an error if it's not successful.
$.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); | |
} |
WHY
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores