feat: v2.0.0 — modular architecture, IYS module, ESM type support#35
Open
umtcnzn-netgsm wants to merge 11 commits intonetgsm:mainfrom
Open
feat: v2.0.0 — modular architecture, IYS module, ESM type support#35umtcnzn-netgsm wants to merge 11 commits intonetgsm:mainfrom
umtcnzn-netgsm wants to merge 11 commits intonetgsm:mainfrom
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 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?
./dist/index.mjsimports — all types resolve correctly instead of showingany📝 Type of Change
🔄 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 clientsrc/modules/sms.ts— send, sendOtp, cancel, getReport, getStats, getHeaders, getInbox, checkBalancesrc/enums/andsrc/types/— split into separate files for SMS and IYSsrc/netgsm.ts— composes modules; legacy methods kept as@deprecatedshims for backward compatibilityIYS module (
feat):queryConsent,saveConsents,setWebhookmethodsIysRecipientType,IysAddressType,IysConsentStatus,IysSource) exported from package rootEnum additions (
feat):SmsEncoding(DEFAULT/UNICODE/TR) andIysFilterenums added;RestSmsPayloadfields typed accordinglyBuild and publish improvements (
build):.d.ts→.d.mtsconversion: TypeScript now resolves correct types for ESM importspackage.json:"module"field added,typescondition moved first inexportsdeclarationMap: true: "Go to Definition" jumps directly to source.tsfiles.npmignoreexpanded:scripts/,.github/,.husky/, and config files excluded✅ Checklist