Skip to content

fix: add new enums and types for Pix payload structure #34

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

Merged
merged 1 commit into from
May 23, 2025

Conversation

jonashger
Copy link
Collaborator

@jonashger jonashger commented May 23, 2025

  • What kind of change does this PR introduce?
    Feature - Enhanced PIX payload type definitions and added new enums

  • What is the current behavior?
    The current implementation has basic type definitions for PIX payloads with some string-based enums and less structured types.

  • What is the new behavior (if this is a feature change)?
    Added comprehensive type definitions and enums for PIX payload structure:

  • New enums for better type safety:

    • Periodicidade (SEMANAL, MENSAL, TRIMESTRAL, SEMESTRAL, ANUAL)
    • PoliticaRetentativa (NAO_PERMITE, PERMITE_3R_7D)
    • StatusRec (CRIADA, APROVADA, REJEITADA, EXPIRADA, CANCELADA)
    • ModalidadeAgente (AGTEC, AGTOT, AGPSS)
    • ModalidadeAgenteTroco (AGTEC, AGTOT)
  • Enhanced type definitions:

    • Added DevedorPF and DevedorPJ types with union type Devedor
    • Added RetiradaSaque and RetiradaTroco types with union type Retirada
    • Updated all PIX payload types to use the new type definitions
    • Improved type safety by replacing string literals with proper enums
    • Added optional fields where appropriate
    • Removed deprecated example payload
  • Other information:
    This change improves type safety and provides better documentation through TypeScript's type system. The changes are backward compatible as they only enhance the type definitions without changing the runtime behavior.

Copy link

coderabbitai bot commented May 23, 2025

Walkthrough

This update introduces several new enums and types to model periodicity, retry policies, status codes, agent modalities, debtor entities, and withdrawal details. It refactors existing payload types to use these new definitions, renames some fields, adds optional fields, updates type annotations, and removes a previously exported example constant.

Changes

File(s) Change Summary
src/types/pixDynamicPayload.ts Added enums for periodicity, retry policy, status, and agent modalities. Defined new types for debtor entities and withdrawal details. Refactored payload types to use new types, renamed and updated fields, and removed the exported PayloadExample constant.

Poem

🐇
New types and enums hop into view,
With agents, debtors—quite a crew!
Withdrawals, retries, status codes too,
Payloads refactored, shiny and new.
The example’s gone, but don’t feel blue—
For structure and order now ensue!
🌱

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 53b861f and 63b4622.

📒 Files selected for processing (1)
  • src/types/pixDynamicPayload.ts (5 hunks)
🔇 Additional comments (10)
src/types/pixDynamicPayload.ts (10)

8-14: Well-structured enum for payment periodicity

The Periodicidade enum is clearly defined with appropriate string values that match the Brazilian PIX standard nomenclature for recurring payment periods. This provides good type safety and self-documentation.


16-19: Properly defined retry policy enum

The PoliticaRetentativa enum correctly represents the retry policy options available in the PIX system, with clear and descriptive values that follow the official specification.


21-27: Comprehensive status enum for recurring payments

The StatusRec enum covers all the necessary states for recurring PIX payments, providing better type safety than string literals.


29-38: Well-defined agent modality enums

Both ModalidadeAgente and ModalidadeAgenteTroco enums follow the PIX specification for agent types. Note that ModalidadeAgenteTroco has fewer options than ModalidadeAgente (missing AGPSS), which correctly reflects the PIX specification for change agents.


50-60: Good type abstraction for debtor entities

Creating dedicated types for DevedorPF (individual) and DevedorPJ (company) and unifying them with the Devedor union type improves code organization and reusability. This approach eliminates duplication and ensures consistent structure across the codebase.


62-79: Well-structured withdrawal types

The RetiradaSaque, RetiradaTroco, and combined Retirada types properly model the withdrawal functionality according to PIX specifications. The optional properties and nested structure provide flexibility while maintaining type safety.


89-89: Good improvements to PIXFuturePayload

Replacing the inline debtor definition with the reusable Devedor type and adding the optional nomeFantasia field enhances both code maintainability and functionality.

Also applies to: 94-94


122-122: Enhanced PIXInstantPayload with withdrawal support

Using the Devedor type and adding the retirada field properly implements the withdrawal functionality for instant payments as described in the PR objectives.

Also applies to: 126-126


139-146: Improved PIXRecPayload calendar and debtor fields

The changes correctly use the new Devedor type and add support for an optional end date (dataFinal) in the calendar. Using the enum Periodicidade instead of string literals improves type safety.


156-159: Improved type safety for policy and status fields

Using the newly defined enums PoliticaRetentativa and StatusRec for the respective fields improves type safety and provides better developer experience through autocompletion and documentation.

@thalesog thalesog merged commit 081e586 into thalesog:master May 23, 2025
5 of 6 checks passed
thalesog pushed a commit that referenced this pull request May 23, 2025
## [2.7.1](v2.7.0...v2.7.1) (2025-05-23)

### Bug Fixes

* add new enums and types for Pix payload structure ([#34](#34)) ([081e586](081e586))
@thalesog
Copy link
Owner

🎉 This issue has been resolved in version 2.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants