Skip to content

Update SDK#6

Merged
pulgueta merged 5 commits intomainfrom
pulgueta/refactor
Jan 28, 2026
Merged

Update SDK#6
pulgueta merged 5 commits intomainfrom
pulgueta/refactor

Conversation

@pulgueta
Copy link
Owner

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

⚠️ No Changeset found

Latest commit: c506f4a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pulgueta pulgueta merged commit 9eb1897 into main Jan 28, 2026
2 checks passed
@pulgueta
Copy link
Owner Author

@greptile plz

@greptile-apps
Copy link

greptile-apps bot commented Jan 28, 2026

Greptile Overview

Greptile Summary

This PR represents a major refactor that modernizes the SDK architecture and improves type safety significantly.

Key Changes:

  • Converted to monorepo workspace structure with packages under packages/server
  • Migrated from pnpm to Bun as package manager and build tool
  • Added comprehensive Zod schema validation for all API requests and responses
  • Changed return types from object-based { data, error } to tuple-based [error, data] for better type inference
  • Improved error handling with type-safe error codes and validation
  • Fixed critical endpoint path issues (missing /payments/v2/, /subscriptions/v2/, etc. prefixes)
  • Removed Husky, commitlint, and oxlint in favor of Biome for linting
  • Removed old TypeScript build setup (tsup) in favor of Bun's native bundler
  • Updated CI/CD to use Bun and simplified GitHub Actions workflows
  • Updated engine requirements to Node 24+ and Bun 1.3.6+

Issues Found:

  • The env configuration option in NequiOptionsSchema is defined but never used - environment selection still relies on process.env.NODE_ENV
  • Typo in error name: invalid_api_Key should be invalid_api_key

Overall Assessment:
The refactor significantly improves the SDK's type safety and developer experience through Zod validation and tuple-based error handling. The endpoint path fixes are critical improvements. However, the environment configuration logic needs completion, and the error name typo should be fixed before merging.

Confidence Score: 3/5

  • This PR contains important improvements but has logic issues that need resolution before merging
  • The refactor brings significant improvements in type safety and fixes critical endpoint path issues. However, the environment configuration logic is incomplete (env field unused) and there's a typo in an error name that could cause runtime issues. These issues should be resolved to ensure the SDK works correctly across development and production environments.
  • packages/server/src/constants/index.ts and packages/server/src/types.ts need attention for the environment configuration, and packages/server/src/nequi.ts needs the error name typo fixed

Important Files Changed

Filename Overview
packages/server/src/nequi.ts Core SDK class with Zod validation, error handling improvements, and tuple-based return type; contains a typo in error name
packages/server/src/types.ts Added Zod schema for options validation; env field defined but not utilized in codebase
packages/server/src/constants/index.ts Fixed endpoint paths to include proper base paths; environment detection relies on NODE_ENV instead of SDK config
packages/server/src/auth/index.ts Improved auth with Zod validation and better error handling; properly validates API responses
package.json Converted to monorepo workspace with Bun, removed Husky and commitlint, updated to Node 24+

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +3 to +9
process.env.NODE_ENV === "development"
? "https://api.sandbox.nequi.com"
: "https://api.nequi.com",
AUTH_URI:
process.env.NODE_ENV === "development"
? "https://oauth.sandbox.nequi.com/oauth2/token"
: "https://oauth.nequi.com/oauth2/token",
Copy link

Choose a reason for hiding this comment

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

process.env.NODE_ENV is used but the NequiOptionsSchema accepts an env field that is never utilized. The URLs should use the env option passed to the Nequi constructor instead of relying on process.env.NODE_ENV.

Currently, users cannot control which environment to use through the SDK configuration - it only respects the NODE_ENV environment variable.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/server/src/constants/index.ts
Line: 3:9

Comment:
`process.env.NODE_ENV` is used but the `NequiOptionsSchema` accepts an `env` field that is never utilized. The URLs should use the `env` option passed to the `Nequi` constructor instead of relying on `process.env.NODE_ENV`.

Currently, users cannot control which environment to use through the SDK configuration - it only respects the `NODE_ENV` environment variable.

How can I resolve this? If you propose a fix, please make it concise.

apiKey: z.string().min(1, "API key is required"),
clientId: z.string().min(1, "Client ID is required"),
clientSecret: z.string().min(1, "Client secret is required"),
env: z.enum(["development", "production"]).default("development"),
Copy link

Choose a reason for hiding this comment

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

The env field is defined in the schema but never used in the codebase. Either remove it or implement environment switching based on this configuration option.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/server/src/types.ts
Line: 10:10

Comment:
The `env` field is defined in the schema but never used in the codebase. Either remove it or implement environment switching based on this configuration option.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +86 to +87
name:
req.status === 403 ? "invalid_api_Key" : "application_error",
Copy link

Choose a reason for hiding this comment

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

Typo in error name: invalid_api_Key should be invalid_api_key (lowercase 'k') to match the error types defined in error/types.ts:8

Suggested change
name:
req.status === 403 ? "invalid_api_Key" : "application_error",
name:
req.status === 403 ? "invalid_api_key" : "application_error",
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/server/src/nequi.ts
Line: 86:87

Comment:
Typo in error name: `invalid_api_Key` should be `invalid_api_key` (lowercase 'k') to match the error types defined in `error/types.ts:8`

```suggestion
              name:
                req.status === 403 ? "invalid_api_key" : "application_error",
```

How can I resolve this? If you propose a fix, please make it concise.

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.

1 participant