pathao-merchant-sdk 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,3 @@
1
- ## [1.3.0] - 2025-12-04
2
-
3
- ### ✨ New Features
4
- - b4fa591 feat: enhance Pathao API SDK with environment variable support and improved error handling
5
-
6
-
7
1
  # Changelog
8
2
 
9
3
  All notable changes to this project will be documented in this file.
@@ -11,97 +5,172 @@ All notable changes to this project will be documented in this file.
11
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
12
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
13
7
 
8
+ ## [2.3.1](https://github.com/Sifat07/pathao-merchant-sdk/compare/pathao-merchant-sdk-v2.3.0...pathao-merchant-sdk-v2.3.1) (2026-09-17)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** bump axios to 1.20.0, resolve prod vulnerabilities ([0c31804](https://github.com/Sifat07/pathao-merchant-sdk/commit/0c318043831cf0a74a041b4aa6aa8a827a48f737))
14
+
15
+ ## [2.3.0](https://github.com/Sifat07/pathao-merchant-sdk/compare/pathao-merchant-sdk-v2.2.0...pathao-merchant-sdk-v2.3.0) (2026-04-16)
16
+
17
+ ### Bug Fixes
18
+
19
+ * Replace broken `pnpm audit` with OSV Scanner scoped to production dependencies
20
+ * Fix release-please to read from manifest — prevents wrong-version PRs
21
+ * Fix `manual-release.yml`: broken scripts, wrong step ordering, pnpm v9
22
+ * Add `permissions` blocks to all CI workflows
23
+ * Pin pnpm to v9 consistently across all workflows
24
+
14
25
  ## [Unreleased]
15
26
 
27
+ ### Added
28
+
29
+ - `PATHAO_STORE_ID` env var documented in `.env.example`
30
+ - `examples/tsconfig.json` — scoped tsconfig for the examples directory so `process` and Node types resolve correctly in IDE
31
+ - Comprehensive test suite rewrite: 67 tests covering all code paths including config validation, factory methods, all static validation helpers, pagination, URL encoding, retry backoff, circuit breaker, and debug token redaction
32
+
33
+ ### Changed
34
+
35
+ - `.env` renamed to `.env.example` with placeholder credentials (proper convention for committed template files)
36
+ - Example files updated: package name corrected from `@sifat07/pathao-merchant-sdk` to `pathao-merchant-sdk`
37
+ - `examples/test-sandbox.ts`: fixed import path and updated doc URL to `merchant.pathao.com/courier/developer-api`
38
+ - Debug log comment in `advanced-usage.ts` corrected to show `Bearer [REDACTED]` (matches actual SDK behavior)
39
+
40
+ ### Removed
41
+
42
+ - `IMPROVEMENTS.md` — internal dev notes, not relevant to consumers
43
+ - `RELEASE.md` / `RELEASE_NOTES.md` — redundant with `CHANGELOG.md`
44
+ - `SETUP.md` — personal repo-setup scratch file
45
+ - `env.example` — duplicate of `.env.example`
46
+ - `docs/pathao-api-reference.txt` — superseded by `docs/official-pathao-api-documentation.md`
47
+ - `examples/env-example.js` — superseded by `.env.example`
48
+ - `coverage/` — generated artifact (already gitignored)
49
+
50
+ ---
51
+
52
+ ## [2.2.0] - 2026-04-16
53
+
54
+ ### Added
55
+
56
+ - 3 new webhook event types from official Pathao dashboard documentation:
57
+ - `order.return-id-created` (`ORDER_RETURN_ID_CREATED`)
58
+ - `order.return-in-transit` (`ORDER_RETURN_IN_TRANSIT`)
59
+ - `order.returned-to-merchant` (`ORDER_RETURNED_TO_MERCHANT`)
60
+ - `ReturnOrderWebhookPayload` base interface with `return_consignment_id`, `return_type`, `collected_amount`, `reason?`
61
+
62
+ ### Fixed
63
+
64
+ - `tsconfig.json`: added `node` and `jest` to `types` array — resolves `Buffer` and `EventEmitter` type errors
65
+ - Webhook secret header is now always set on every response (not just handshake)
66
+
67
+ ### Changed
68
+
69
+ - Webhook documentation updated to reflect official Pathao dashboard specs
70
+ - Sandbox credentials restored in `docs/` for developer convenience (publicly provided by Pathao)
71
+
72
+ ---
73
+
74
+ ## [2.1.0] - 2026-03-10
75
+
76
+ ### Added
77
+
78
+ - `pathao-merchant-sdk/webhooks` sub-path entry point (zero extra runtime dependencies)
79
+ - `PathaoWebhookHandler` — EventEmitter with fully typed `on()` and `once()` overloads for all event types
80
+ - `constructEvent(rawBody)` — parse and validate a webhook payload
81
+ - Express middleware via `handler.expressMiddleware()`
82
+ - Framework-agnostic middleware via `handler.middleware()` — never rejects, returns `WebhookResponseInstructions`
83
+ - `PathaoWebhookError` error class
84
+ - Constant-time secret comparison via `crypto.timingSafeEqual`
85
+ - Full TypeScript payload types for all 21 event types with `WebhookEventPayloadMap`
86
+
87
+ ---
88
+
16
89
  ## [2.0.2] - 2025-12-08
17
90
 
18
91
  ### Added
19
- - **Factory methods**: `PathaoApiService.fromEnv()` and `PathaoApiService.fromConfig()` for convenient initialization patterns
20
- - **Debug logging**: Optional `debug` flag in constructor options to log all HTTP requests and responses
21
- - **Configurable circuit breaker**: `circuitBreaker` option to customize failure threshold and timeout
22
- - **Comprehensive error handling examples** in README with `PathaoApiError` usage patterns
23
- - **Advanced options documentation** for factory methods and configuration
92
+
93
+ - Factory methods: `PathaoApiService.fromEnv()`, `PathaoApiService.fromConfig()`, `PathaoApiService.sandbox()`, `PathaoApiService.production()`
94
+ - `debug` option — logs all HTTP requests and responses; `Authorization` header redacted as `Bearer [REDACTED]`
95
+ - Configurable circuit breaker via `circuitBreaker: { threshold, timeout }` option
24
96
 
25
97
  ### Changed
26
- - **Breaking**: Deferred configuration validation to first API call instead of constructor throw. SDK now initializes successfully even without credentials, and throws `PathaoApiError` when attempting an API call with missing config.
27
- - Removed config duplication in constructor (axios create config now uses resolved config values).
28
- - Constructor now accepts optional `options` parameter: `new PathaoApiService(config, { debug?, circuitBreaker? })`
29
- - Constructor no longer throws upfront, allowing graceful error handling at first API usage.
98
+
99
+ - **Breaking**: Configuration validation deferred to first API call — constructor no longer throws
100
+ - Constructor now accepts optional second argument: `new PathaoApiService(config, { debug?, circuitBreaker? })`
30
101
 
31
102
  ### Fixed
32
- - `ResolvedPathaoConfig` internal type ensures `timeout` is always a number.
33
- - Tests updated to reflect deferred validation behavior.
34
- - Circuit breaker now properly resets on successful requests and maintains configurable thresholds.
35
103
 
36
- ### Verified
37
- - `npm test` passes with 22/22 tests.
38
- - Build succeeds (CJS/ESM/DTS).
104
+ - `ResolvedPathaoConfig` internal type ensures `timeout` is always a `number`
105
+ - Circuit breaker resets correctly on successful requests
106
+ - `parseInt` NaN + zero guard for `PATHAO_TIMEOUT` env var
107
+ - `encodeURIComponent()` applied to `consignmentId` in URL path
108
+ - Removed `as any` / `as Error` casts — replaced with proper type guards
109
+ - Removed dead `requestQueue` / `processRequestQueue` code
110
+ - Scoped `jest.spyOn` restores only console spies in test setup
111
+
112
+ ---
39
113
 
40
114
  ## [2.0.1] - 2025-12-05
41
115
 
42
- ### Changed
43
- - Added `PathaoApiError` with structured fields (`status`, `code`, `type`, `errors`, `validation`, `responseData`) and updated all SDK methods to throw it.
116
+ ### Added
117
+
118
+ - `PathaoApiError` class with structured fields: `status`, `code`, `type`, `errors`, `validation`, `responseData`
119
+ - All SDK methods now throw `PathaoApiError` instead of plain `Error`
44
120
 
45
- ### Verified
46
- - `npm test` (jest) passes.
121
+ ---
47
122
 
48
123
  ## [1.2.0] - 2024-12-05
49
124
 
125
+ ### Added
126
+
127
+ - `CONTRIBUTING.md` for contributors
128
+ - Reorganized documentation into `docs/` folder
129
+ - ESM `exports` field in `package.json` with `sideEffects: false`
130
+
50
131
  ### Fixed
51
- - Fixed `PathaoPriceRequest` type - removed incorrect `recipient_area` field
132
+
133
+ - `PathaoPriceRequest` type — removed incorrect `recipient_area` field
52
134
  - Split store response types into `PathaoStoreCreateResponse` and `PathaoStoreListResponse`
53
- - Updated README examples to match official API response structures
135
+ - README examples updated to match official API response structures
54
136
  - Removed deprecated `StoreType` enum references
55
137
 
56
- ### Changed
57
- - Enhanced package.json with ESM exports field and sideEffects flag
58
- - Improved npm package structure with .npmignore
59
- - Added CONTRIBUTING.md for contributors
60
- - Reorganized documentation files into docs/ folder
61
-
62
- ### Verified
63
- - All endpoints tested against official Pathao sandbox API
64
- - Type definitions verified against actual API responses
138
+ ---
65
139
 
66
140
  ## [1.1.0] - 2024-10-01
67
141
 
68
142
  ### Added
69
- - Comprehensive CI/CD pipeline and automatic release management
143
+
144
+ - CI/CD pipeline and automatic release management via GitHub Actions
145
+
146
+ ---
70
147
 
71
148
  ## [1.0.0] - 2024-10-01
72
149
 
73
150
  ### Added
74
- - Initial release of Pathao Merchant API SDK
75
- - Full TypeScript support with complete type definitions
76
- - Automatic OAuth2 authentication and token refresh
77
- - Order management (create, track, status)
78
- - Store management (create, list stores)
79
- - Price calculation for delivery charges
80
- - Location services (cities, zones, areas)
81
- - Comprehensive error handling
82
- - Built-in validation helpers
83
- - Support for both CommonJS and ESM
84
- - Extensive documentation and examples
85
-
86
- ### Features
87
- - 🚀 Full TypeScript Support
88
- - 🔐 Automatic Authentication
89
- - 📦 Order Management
90
- - 🏪 Store Management
91
- - 💰 Price Calculation
92
- - 🌍 Location Services
93
- - ⚡ Built with Axios
94
- - 🛡️ Error Handling
95
- - 📚 Well Documented
96
-
97
- ## [1.0.0] - 2025-01-01
98
151
 
99
- ### Added
100
152
  - Initial release
101
- - Complete Pathao API integration
102
- - TypeScript support
103
- - Automatic authentication
104
- - Order management
105
- - Store management
153
+ - Full TypeScript support with complete type definitions
154
+ - Automatic OAuth2 authentication and token refresh
155
+ - Order management: create single order, bulk orders, track by consignment ID
156
+ - Store management: create store, list stores with pagination, `getStoresAll()` auto-paginator
106
157
  - Price calculation
107
- - Location services
158
+ - Location services: cities, zones, areas
159
+ - `PathaoApiError` for structured error handling
160
+ - Built-in static validation helpers: phone, address, weight, name
161
+ - `User-Agent: pathao-merchant-sdk node/<version>` header
162
+ - Retry logic: 429 reads `Retry-After`; 5xx exponential backoff (max 2 retries)
163
+ - Circuit breaker: throws `PathaoApiError` (code 503) when open
164
+ - HTTPS enforcement in `validateConfiguration()`
165
+ - Support for both CommonJS and ESM module formats
166
+
167
+ <!-- comparison links -->
168
+
169
+ [Unreleased]: https://github.com/sifat07/pathao-merchant-sdk/compare/v2.2.0...HEAD
170
+ [2.2.0]: https://github.com/sifat07/pathao-merchant-sdk/compare/v2.1.0...v2.2.0
171
+ [2.1.0]: https://github.com/sifat07/pathao-merchant-sdk/compare/v2.0.2...v2.1.0
172
+ [2.0.2]: https://github.com/sifat07/pathao-merchant-sdk/compare/v2.0.1...v2.0.2
173
+ [2.0.1]: https://github.com/sifat07/pathao-merchant-sdk/compare/v1.2.0...v2.0.1
174
+ [1.2.0]: https://github.com/sifat07/pathao-merchant-sdk/compare/v1.1.0...v1.2.0
175
+ [1.1.0]: https://github.com/sifat07/pathao-merchant-sdk/compare/v1.0.0...v1.1.0
176
+ [1.0.0]: https://github.com/sifat07/pathao-merchant-sdk/releases/tag/v1.0.0