Skip to content

Typescript solid refactor - #49

Open
tesuser4444 wants to merge 21 commits into
open-pay:masterfrom
tesuser4444:typescript-solid-refactor
Open

Typescript solid refactor#49
tesuser4444 wants to merge 21 commits into
open-pay:masterfrom
tesuser4444:typescript-solid-refactor

Conversation

@tesuser4444

Copy link
Copy Markdown

No description provided.

- Add tsconfig.json targeting ES2015/commonjs, compiling src/ to lib/
- Add devDependencies: typescript, @types/node, @types/underscore
- Add build/prepublishOnly scripts and types field to package.json
- src/url-utils.ts: typed escapeBrackets function
- src/openpay.ts: full type definitions for all resource classes
  (Merchant, Charges, Payouts, Fees, Plans, Cards, Customers,
   Webhooks, Tokens, Checkouts, Pse, Stores, Groups)
- Callback and BaseData types extracted for reuse
- Uses CommonJS export (= Openpay) for backwards compatibility
- lib/openpay.js: CommonJS build (module.exports = Openpay)
- lib/openpay.d.ts: type declarations for TypeScript consumers
- lib/url-utils.js / lib/url-utils.d.ts
- Sourcemaps and declaration maps for debugging
- Update .gitignore to exclude .reasonix/ tool folder
…aces

- strict: true, target ES2022, Node >=20
- Typed interfaces for all API resources (ChargeRequest, PayoutRequest, etc.)
- Custom error classes: OpenpayError, NetworkError, TimeoutError
- Replace underscore utils with native ES2022 equivalents
- Remove console.log noise from url-utils
- License, repository, keywords metadata
- HttpClient interface for dependency inversion
- UrllibHttpClient / StoreHttpClient implementations
- BaseResource provides shared request(), resolveListParams(), url() helpers
- Resources depend on abstractions, not on urllib directly
- 13 resource files: merchant, charges, payouts, fees, plans, cards,
  customers (6 sub-resources), webhooks, tokens, checkouts, stores, pse, groups
- Each resource is a class extending BaseResource
- Nested resources composed as typed class instances
- Open/Closed: new resources can be added without modifying existing code
- Openpay class now ~170 lines (was ~1500)
- Resources instantiated with dependency injection (config + HttpClient)
- rebuildResources() for dynamic config changes (setMerchantId, etc.)
- index.ts barrel export with CommonJS export= for backwards compat
- All .js, .d.ts, .d.ts.map, .js.map files
- Both lib/openpay.js and lib/index.js export Openpay correctly
- Fully backwards compatible: require('../lib/openpay') works as before
- Add Requirements section (Node >=20, TypeScript optional)
- Add Quick Start with JavaScript and TypeScript examples
- Add constructor parameters table with country code
- Add Architecture section showing file tree and SOLID principles
- Add Upgrading from v2.x migration guide
- Update Development section with build step
- Remove duplicate Configuration/Development sections
- Keep all existing per-country API examples intact
- Rename package to @neo-cheems/openpay (scoped)
- Remove unused underscore dependency
- Add publishConfig.access: public for scoped package
- Update repository, bugs, homepage URLs
- Update README with new install/require paths
- package.json: 3.0.0 → 4.0.0
- README: v3.x → v4.x references
lib/ contains compiled JS output. It was already in .gitignore but
was previously committed, so git still tracked it. This commit
removes it from tracking while keeping the files on disk.
…tch API

Refactor the codebase to adhere to SOLID principles and improve maintainability.
Key changes include:

- Migrated HTTP client from `urllib` to the native `fetch` API.
- Introduced `NestedCollection` to reduce duplication in sub-resources.
- Implemented Dependency Inversion Principle (DIP) by having resources depend on the `HttpClient` interface.
- Refactored `Openpay` class to use a more robust resource rebuilding mechanism.
- Added support for country-specific API hosts.
- Removed legacy configuration files (`.jshintrc`, `.project`, `.travis.yml`) and dependencies (`urllib`, `underscore`).
- Updated test suite to remove `underscore` dependencies and align with new architecture.
- Breaking changes: removed static BASE_URL/SANDBOX_URL/API_VERSION from Openpay class,
  removed TimeoutError class, removed urllib dependency in favor of native fetch
- Fix tests: replace urllib with native fetch in test/test.js and test/group_test.js
Runs TypeScript build and mocha tests on push/PR for Node.js 20 and 22.
Tests are integration tests against the Openpay sandbox — CI reports
results but notes sandbox availability as a factor.
@davchz513

Copy link
Copy Markdown

Buenas!! En tu fork tienes abierto para contribuir??

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.

2 participants