Skip to content

feat: v2.0.0 — modular architecture, IYS module, ESM type support#35

Open
umtcnzn-netgsm wants to merge 11 commits intonetgsm:mainfrom
umtcnzn-netgsm:main
Open

feat: v2.0.0 — modular architecture, IYS module, ESM type support#35
umtcnzn-netgsm wants to merge 11 commits intonetgsm:mainfrom
umtcnzn-netgsm:main

Conversation

@umtcnzn-netgsm
Copy link
Copy Markdown

🎯 Purpose of Changes

Migrating the library to v2.0.0 with a modular architecture, adding an IYS consent management module, and fixing ESM
type resolution issues.

🧪 How Was It Tested?

  • 21 unit tests (IYS module) and 7 IYS integration tests added
  • SMS module unit and integration tests updated for the modular API
  • VS Code IntelliSense verified on ./dist/index.mjs imports — all types resolve correctly instead of showing any

📝 Type of Change

  • New feature (non-breaking change which adds functionality)
  • Code quality improvement
  • Documentation update
  • CI/CD process improvement

🔄 Related Issues

Resolves #

📸 Screenshots (if applicable)

N/A

📋 Additional Information

Modular architecture (refactor):

  • src/client.ts — HTTP auth, get/post, and error handling extracted into a base client
  • src/modules/sms.ts — send, sendOtp, cancel, getReport, getStats, getHeaders, getInbox, checkBalance
  • src/enums/ and src/types/ — split into separate files for SMS and IYS
  • src/netgsm.ts — composes modules; legacy methods kept as @deprecated shims for backward compatibility

IYS module (feat):

  • queryConsent, saveConsents, setWebhook methods
  • Bearer token auth with lazy login and 401 auto-retry
  • IYS enums (IysRecipientType, IysAddressType, IysConsentStatus, IysSource) exported from package root

Enum additions (feat):

  • SmsEncoding (DEFAULT/UNICODE/TR) and IysFilter enums added; RestSmsPayload fields typed accordingly

Build and publish improvements (build):

  • .d.ts.d.mts conversion: TypeScript now resolves correct types for ESM imports
  • package.json: "module" field added, types condition moved first in exports
  • declarationMap: true: "Go to Definition" jumps directly to source .ts files
  • .npmignore expanded: scripts/, .github/, .husky/, and config files excluded

✅ Checklist

  • Code follows the project's coding standards (linting)
  • Tests have been added or updated
  • Documentation has been updated
  • All tests pass successfully
  • PR title is meaningful and descriptive

Ümitcan Zanbak and others added 11 commits April 17, 2026 10:56
- Extract base HTTP client (auth, post, get, handleResponse) into src/client.ts
- Add src/modules/sms.ts with all SMS operations (send, sendOtp, cancel,
  getReport, getStats, getHeaders, getInbox, checkBalance)
- Add src/modules/iys.ts as placeholder for upcoming IYS integration
- Split src/enums.ts into src/enums/sms.enums.ts and src/enums/iys.enums.ts
- Split src/types.ts into src/types/sms.types.ts and src/types/iys.types.ts
- Refactor src/netgsm.ts to compose modules; keep all existing methods
  as @deprecated shims for full backward compatibility
- Rewrite unit tests: modular API, deprecated delegation, client error paths
- Update integration tests: use modular API, fix report date range issue,
  add getStats test, replace deprecated fail() with throw
- IysModule with queryConsent, saveConsents, setWebhook methods
- Bearer token auth with lazy login and 401 auto-retry
- IYS base URL (ext-api.netgsm.com.tr) extracted to constants.ts alongside SMS_BASE_URL
- clientType hardcoded to API (4), path hardcoded to SMSAPI — not user-configurable
- IYS enums (IysRecipientType, IysAddressType, IysConsentStatus, IysSource) exported from package index
- IysClientType and IysPath kept internal only
- StatsErrorCode added to package exports (was missing)
- Fixed getReport body to use consistent spread pattern
- Fixed checkBalance and IYS login() to handle JSON parse errors
- 21 unit tests and 7 integration tests added
- Bump version to 2.0.0
- README: modular API examples, IYS section, migration guide from 1.x
- CHANGELOG: [2.0.0] entry with all changes
- basic-usage.js: netgsm.sms.* methods, BalanceType import, stip param
- scheduled-sms.js: sms.send(), sms.cancel(), remove Enums import
- bulk-sms.js: sms.send(), sms.getReport(), remove Enums import
- additional-examples.js: sms.send() throughout
- Add examples/advanced/iys-consent.js with queryConsent, saveConsents, setWebhook examples
RestSmsPayload encoding and iysfilter fields now typed with SmsEncoding/IysFilter enums instead of plain strings. Both enums exported from package root. Examples, README, and CHANGELOG updated accordingly.
SmsEncoding: DEFAULT=0, UNICODE=8, TR=11. IysFilter: NONE, COMMERCIAL_INDIVIDUAL, COMMERCIAL_MERCHANT. Both exported from package root. RestSmsPayload fields typed accordingly. Docs and examples updated.
Root-level only processing caused missing dist/enums/index.mjs and similar files, breaking ESM imports at runtime.
Prevents esm/ from being published to npm and blocks deep imports of internal enums (IysClientType, IysPath).
- Add module field and reorder exports conditions (types first)
- Generate .d.mts files from .d.ts for proper ESM type resolution
- Enable declarationMap for source-level Go to Definition support
- Expand .npmignore to exclude dev tooling and internal files
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