pathao-merchant-sdk 2.1.0 → 2.3.0

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,179 @@ 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.0](https://github.com/Sifat07/pathao-merchant-sdk/compare/pathao-merchant-sdk-v2.2.0...pathao-merchant-sdk-v2.3.0) (2026-04-16)
9
+
10
+
11
+ ### Features
12
+
13
+ * add comprehensive CI/CD pipeline and automatic release management ([2448245](https://github.com/Sifat07/pathao-merchant-sdk/commit/244824566dd20171fe28365d0b312d3c7f07f51e))
14
+ * add comprehensive CI/CD pipeline and automatic release management ([2448245](https://github.com/Sifat07/pathao-merchant-sdk/commit/244824566dd20171fe28365d0b312d3c7f07f51e))
15
+ * add webhook support and comprehensive security hardening (v2.1.0) ([fd24917](https://github.com/Sifat07/pathao-merchant-sdk/commit/fd24917a2d6bdd21dada4eb434750c010d660c45))
16
+ * enhance Pathao API SDK with environment variable support and improved error handling ([b4fa591](https://github.com/Sifat07/pathao-merchant-sdk/commit/b4fa59117c9f19d5da1396f2b6fa507d6610d7b5))
17
+ * update error handling ([fa4dce5](https://github.com/Sifat07/pathao-merchant-sdk/commit/fa4dce5a13a414a0ecec312a149a7162655ee360))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * auto release ([eaabb14](https://github.com/Sifat07/pathao-merchant-sdk/commit/eaabb148a919b418288b0dd9b68c50616e941502))
23
+ * correct version base to 2.2.0 and use PAT for release-please ([eaabb14](https://github.com/Sifat07/pathao-merchant-sdk/commit/eaabb148a919b418288b0dd9b68c50616e941502))
24
+ * defer validation ([2c08435](https://github.com/Sifat07/pathao-merchant-sdk/commit/2c0843549a012f81d89f74344a97393ab81638c3))
25
+ * fix and update using latest developers docs ([f2205a2](https://github.com/Sifat07/pathao-merchant-sdk/commit/f2205a23ae9b5c38e38ecf94cb48bf300f46c6a0))
26
+ * fix webhook integration ([498d0f2](https://github.com/Sifat07/pathao-merchant-sdk/commit/498d0f25ee7e0f88484131f8b18ec8ce20faa04b))
27
+ * separate publishing from CI and fix permission issues ([2448245](https://github.com/Sifat07/pathao-merchant-sdk/commit/244824566dd20171fe28365d0b312d3c7f07f51e))
28
+ * update CI/CD workflows to use pnpm instead of npm ([2448245](https://github.com/Sifat07/pathao-merchant-sdk/commit/244824566dd20171fe28365d0b312d3c7f07f51e))
29
+ * update pnpm version to 9 in CI workflows ([2448245](https://github.com/Sifat07/pathao-merchant-sdk/commit/244824566dd20171fe28365d0b312d3c7f07f51e))
30
+ * upgrade pnpm to v10 in CI to fix audit endpoint 410 error ([eaabb14](https://github.com/Sifat07/pathao-merchant-sdk/commit/eaabb148a919b418288b0dd9b68c50616e941502))
31
+
14
32
  ## [Unreleased]
15
33
 
34
+ ### Added
35
+
36
+ - `PATHAO_STORE_ID` env var documented in `.env.example`
37
+ - `examples/tsconfig.json` — scoped tsconfig for the examples directory so `process` and Node types resolve correctly in IDE
38
+ - 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
39
+
40
+ ### Changed
41
+
42
+ - `.env` renamed to `.env.example` with placeholder credentials (proper convention for committed template files)
43
+ - Example files updated: package name corrected from `@sifat07/pathao-merchant-sdk` to `pathao-merchant-sdk`
44
+ - `examples/test-sandbox.ts`: fixed import path and updated doc URL to `merchant.pathao.com/courier/developer-api`
45
+ - Debug log comment in `advanced-usage.ts` corrected to show `Bearer [REDACTED]` (matches actual SDK behavior)
46
+
47
+ ### Removed
48
+
49
+ - `IMPROVEMENTS.md` — internal dev notes, not relevant to consumers
50
+ - `RELEASE.md` / `RELEASE_NOTES.md` — redundant with `CHANGELOG.md`
51
+ - `SETUP.md` — personal repo-setup scratch file
52
+ - `env.example` — duplicate of `.env.example`
53
+ - `docs/pathao-api-reference.txt` — superseded by `docs/official-pathao-api-documentation.md`
54
+ - `examples/env-example.js` — superseded by `.env.example`
55
+ - `coverage/` — generated artifact (already gitignored)
56
+
57
+ ---
58
+
59
+ ## [2.2.0] - 2026-04-16
60
+
61
+ ### Added
62
+
63
+ - 3 new webhook event types from official Pathao dashboard documentation:
64
+ - `order.return-id-created` (`ORDER_RETURN_ID_CREATED`)
65
+ - `order.return-in-transit` (`ORDER_RETURN_IN_TRANSIT`)
66
+ - `order.returned-to-merchant` (`ORDER_RETURNED_TO_MERCHANT`)
67
+ - `ReturnOrderWebhookPayload` base interface with `return_consignment_id`, `return_type`, `collected_amount`, `reason?`
68
+
69
+ ### Fixed
70
+
71
+ - `tsconfig.json`: added `node` and `jest` to `types` array — resolves `Buffer` and `EventEmitter` type errors
72
+ - Webhook secret header is now always set on every response (not just handshake)
73
+
74
+ ### Changed
75
+
76
+ - Webhook documentation updated to reflect official Pathao dashboard specs
77
+ - Sandbox credentials restored in `docs/` for developer convenience (publicly provided by Pathao)
78
+
79
+ ---
80
+
81
+ ## [2.1.0] - 2026-03-10
82
+
83
+ ### Added
84
+
85
+ - `pathao-merchant-sdk/webhooks` sub-path entry point (zero extra runtime dependencies)
86
+ - `PathaoWebhookHandler` — EventEmitter with fully typed `on()` and `once()` overloads for all event types
87
+ - `constructEvent(rawBody)` — parse and validate a webhook payload
88
+ - Express middleware via `handler.expressMiddleware()`
89
+ - Framework-agnostic middleware via `handler.middleware()` — never rejects, returns `WebhookResponseInstructions`
90
+ - `PathaoWebhookError` error class
91
+ - Constant-time secret comparison via `crypto.timingSafeEqual`
92
+ - Full TypeScript payload types for all 21 event types with `WebhookEventPayloadMap`
93
+
94
+ ---
95
+
16
96
  ## [2.0.2] - 2025-12-08
17
97
 
18
98
  ### 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
99
+
100
+ - Factory methods: `PathaoApiService.fromEnv()`, `PathaoApiService.fromConfig()`, `PathaoApiService.sandbox()`, `PathaoApiService.production()`
101
+ - `debug` option — logs all HTTP requests and responses; `Authorization` header redacted as `Bearer [REDACTED]`
102
+ - Configurable circuit breaker via `circuitBreaker: { threshold, timeout }` option
24
103
 
25
104
  ### 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.
105
+
106
+ - **Breaking**: Configuration validation deferred to first API call — constructor no longer throws
107
+ - Constructor now accepts optional second argument: `new PathaoApiService(config, { debug?, circuitBreaker? })`
30
108
 
31
109
  ### 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
110
 
36
- ### Verified
37
- - `npm test` passes with 22/22 tests.
38
- - Build succeeds (CJS/ESM/DTS).
111
+ - `ResolvedPathaoConfig` internal type ensures `timeout` is always a `number`
112
+ - Circuit breaker resets correctly on successful requests
113
+ - `parseInt` NaN + zero guard for `PATHAO_TIMEOUT` env var
114
+ - `encodeURIComponent()` applied to `consignmentId` in URL path
115
+ - Removed `as any` / `as Error` casts — replaced with proper type guards
116
+ - Removed dead `requestQueue` / `processRequestQueue` code
117
+ - Scoped `jest.spyOn` restores only console spies in test setup
118
+
119
+ ---
39
120
 
40
121
  ## [2.0.1] - 2025-12-05
41
122
 
42
- ### Changed
43
- - Added `PathaoApiError` with structured fields (`status`, `code`, `type`, `errors`, `validation`, `responseData`) and updated all SDK methods to throw it.
123
+ ### Added
124
+
125
+ - `PathaoApiError` class with structured fields: `status`, `code`, `type`, `errors`, `validation`, `responseData`
126
+ - All SDK methods now throw `PathaoApiError` instead of plain `Error`
44
127
 
45
- ### Verified
46
- - `npm test` (jest) passes.
128
+ ---
47
129
 
48
130
  ## [1.2.0] - 2024-12-05
49
131
 
132
+ ### Added
133
+
134
+ - `CONTRIBUTING.md` for contributors
135
+ - Reorganized documentation into `docs/` folder
136
+ - ESM `exports` field in `package.json` with `sideEffects: false`
137
+
50
138
  ### Fixed
51
- - Fixed `PathaoPriceRequest` type - removed incorrect `recipient_area` field
139
+
140
+ - `PathaoPriceRequest` type — removed incorrect `recipient_area` field
52
141
  - Split store response types into `PathaoStoreCreateResponse` and `PathaoStoreListResponse`
53
- - Updated README examples to match official API response structures
142
+ - README examples updated to match official API response structures
54
143
  - Removed deprecated `StoreType` enum references
55
144
 
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
145
+ ---
65
146
 
66
147
  ## [1.1.0] - 2024-10-01
67
148
 
68
149
  ### Added
69
- - Comprehensive CI/CD pipeline and automatic release management
70
150
 
71
- ## [1.0.0] - 2024-10-01
151
+ - CI/CD pipeline and automatic release management via GitHub Actions
72
152
 
73
- ### 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
153
+ ---
85
154
 
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
155
+ ## [1.0.0] - 2024-10-01
98
156
 
99
157
  ### Added
158
+
100
159
  - Initial release
101
- - Complete Pathao API integration
102
- - TypeScript support
103
- - Automatic authentication
104
- - Order management
105
- - Store management
160
+ - Full TypeScript support with complete type definitions
161
+ - Automatic OAuth2 authentication and token refresh
162
+ - Order management: create single order, bulk orders, track by consignment ID
163
+ - Store management: create store, list stores with pagination, `getStoresAll()` auto-paginator
106
164
  - Price calculation
107
- - Location services
165
+ - Location services: cities, zones, areas
166
+ - `PathaoApiError` for structured error handling
167
+ - Built-in static validation helpers: phone, address, weight, name
168
+ - `User-Agent: pathao-merchant-sdk node/<version>` header
169
+ - Retry logic: 429 reads `Retry-After`; 5xx exponential backoff (max 2 retries)
170
+ - Circuit breaker: throws `PathaoApiError` (code 503) when open
171
+ - HTTPS enforcement in `validateConfiguration()`
172
+ - Support for both CommonJS and ESM module formats
173
+
174
+ <!-- comparison links -->
175
+
176
+ [Unreleased]: https://github.com/sifat07/pathao-merchant-sdk/compare/v2.2.0...HEAD
177
+ [2.2.0]: https://github.com/sifat07/pathao-merchant-sdk/compare/v2.1.0...v2.2.0
178
+ [2.1.0]: https://github.com/sifat07/pathao-merchant-sdk/compare/v2.0.2...v2.1.0
179
+ [2.0.2]: https://github.com/sifat07/pathao-merchant-sdk/compare/v2.0.1...v2.0.2
180
+ [2.0.1]: https://github.com/sifat07/pathao-merchant-sdk/compare/v1.2.0...v2.0.1
181
+ [1.2.0]: https://github.com/sifat07/pathao-merchant-sdk/compare/v1.1.0...v1.2.0
182
+ [1.1.0]: https://github.com/sifat07/pathao-merchant-sdk/compare/v1.0.0...v1.1.0
183
+ [1.0.0]: https://github.com/sifat07/pathao-merchant-sdk/releases/tag/v1.0.0