@inkress/admin-sdk 1.0.0 → 1.1.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 +213 -0
- package/README.md +1174 -87
- package/dist/client.d.ts +3 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/data-mappings.d.ts +177 -0
- package/dist/data-mappings.d.ts.map +1 -0
- package/dist/index.d.ts +34 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +4166 -154
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4203 -153
- package/dist/index.js.map +1 -1
- package/dist/resources/addresses.d.ts +58 -0
- package/dist/resources/addresses.d.ts.map +1 -0
- package/dist/resources/billing-plans.d.ts +32 -15
- package/dist/resources/billing-plans.d.ts.map +1 -1
- package/dist/resources/categories.d.ts +30 -20
- package/dist/resources/categories.d.ts.map +1 -1
- package/dist/resources/currencies.d.ts +41 -0
- package/dist/resources/currencies.d.ts.map +1 -0
- package/dist/resources/exchange-rates.d.ts +50 -0
- package/dist/resources/exchange-rates.d.ts.map +1 -0
- package/dist/resources/fees.d.ts +58 -0
- package/dist/resources/fees.d.ts.map +1 -0
- package/dist/resources/financial-accounts.d.ts +47 -0
- package/dist/resources/financial-accounts.d.ts.map +1 -0
- package/dist/resources/financial-requests.d.ts +51 -0
- package/dist/resources/financial-requests.d.ts.map +1 -0
- package/dist/resources/generics.d.ts +57 -0
- package/dist/resources/generics.d.ts.map +1 -0
- package/dist/resources/kyc.d.ts +118 -0
- package/dist/resources/kyc.d.ts.map +1 -0
- package/dist/resources/merchants.d.ts +52 -15
- package/dist/resources/merchants.d.ts.map +1 -1
- package/dist/resources/orders.d.ts +74 -2
- package/dist/resources/orders.d.ts.map +1 -1
- package/dist/resources/payment-links.d.ts +65 -0
- package/dist/resources/payment-links.d.ts.map +1 -0
- package/dist/resources/payment-methods.d.ts +48 -0
- package/dist/resources/payment-methods.d.ts.map +1 -0
- package/dist/resources/products.d.ts +62 -16
- package/dist/resources/products.d.ts.map +1 -1
- package/dist/resources/public.d.ts +27 -7
- package/dist/resources/public.d.ts.map +1 -1
- package/dist/resources/subscriptions.d.ts +86 -20
- package/dist/resources/subscriptions.d.ts.map +1 -1
- package/dist/resources/tokens.d.ts +62 -0
- package/dist/resources/tokens.d.ts.map +1 -0
- package/dist/resources/transaction-entries.d.ts +48 -0
- package/dist/resources/transaction-entries.d.ts.map +1 -0
- package/dist/resources/users.d.ts +43 -21
- package/dist/resources/users.d.ts.map +1 -1
- package/dist/resources/webhook-urls.d.ts +49 -0
- package/dist/resources/webhook-urls.d.ts.map +1 -0
- package/dist/types/resources.d.ts +1294 -0
- package/dist/types/resources.d.ts.map +1 -0
- package/dist/types.d.ts +1069 -197
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/query-builders.d.ts +518 -0
- package/dist/utils/query-builders.d.ts.map +1 -0
- package/dist/utils/query-transformer.d.ts +123 -0
- package/dist/utils/query-transformer.d.ts.map +1 -0
- package/dist/utils/translators.d.ts +126 -0
- package/dist/utils/translators.d.ts.map +1 -0
- package/dist/utils/webhooks.d.ts +19 -4
- package/dist/utils/webhooks.d.ts.map +1 -1
- package/package.json +14 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,219 @@ All notable changes to the Inkress Admin SDK will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.0] - 2024-12-16
|
|
9
|
+
|
|
10
|
+
### 🚀 Feature Release - Enhanced Type Safety & Query System
|
|
11
|
+
|
|
12
|
+
This release adds significant new features and includes breaking changes to the configuration interface.
|
|
13
|
+
|
|
14
|
+
### ⚠️ BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
#### Configuration Interface Changes
|
|
17
|
+
The SDK configuration has been updated for better developer experience:
|
|
18
|
+
|
|
19
|
+
**Old Configuration:**
|
|
20
|
+
```typescript
|
|
21
|
+
const inkress = new InkressSDK({
|
|
22
|
+
bearerToken: 'your-jwt-token',
|
|
23
|
+
clientId: 'm-merchant-username',
|
|
24
|
+
endpoint: 'https://api.inkress.com',
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**New Configuration:**
|
|
29
|
+
```typescript
|
|
30
|
+
const inkress = new InkressSDK({
|
|
31
|
+
accessToken: 'your-jwt-token', // renamed from bearerToken
|
|
32
|
+
username: 'merchant-username', // renamed from clientId, SDK prepends 'm-'
|
|
33
|
+
mode: 'live', // replaces endpoint ('live' or 'sandbox')
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Migration Guide:**
|
|
38
|
+
1. Replace `bearerToken` with `accessToken`
|
|
39
|
+
2. Replace `clientId` with `username` (remove the 'm-' prefix, SDK adds it automatically)
|
|
40
|
+
3. Replace `endpoint` with `mode`:
|
|
41
|
+
- `'https://api.inkress.com'` → `mode: 'live'`
|
|
42
|
+
- `'https://api-dev.inkress.com'` → `mode: 'sandbox'`
|
|
43
|
+
|
|
44
|
+
### ✨ Added
|
|
45
|
+
|
|
46
|
+
#### New Resources (14 additional resources)
|
|
47
|
+
- **Payment Links** - Payment link generation and management
|
|
48
|
+
- **Financial Accounts** - Financial account management
|
|
49
|
+
- **Financial Requests** - Payout and withdrawal requests
|
|
50
|
+
- **Webhook URLs** - Webhook configuration and management
|
|
51
|
+
- **Tokens** - API token management
|
|
52
|
+
- **Addresses** - Address management
|
|
53
|
+
- **Currencies** - Multi-currency support
|
|
54
|
+
- **Exchange Rates** - Currency exchange rate management
|
|
55
|
+
- **Fees** - Fee management and configuration
|
|
56
|
+
- **Payment Methods** - Payment method configuration
|
|
57
|
+
- **Posts** - Content management system
|
|
58
|
+
- **Transaction Entries** - Transaction tracking
|
|
59
|
+
- **Generics** - Dynamic endpoint access
|
|
60
|
+
- **KYC** - Know Your Customer operations
|
|
61
|
+
|
|
62
|
+
#### Advanced Query System
|
|
63
|
+
- **Query Builder Pattern** - Fluent query builder for all resources
|
|
64
|
+
```typescript
|
|
65
|
+
const orders = await inkress.orders.createQueryBuilder()
|
|
66
|
+
.whereStatus(['confirmed', 'shipped'])
|
|
67
|
+
.whereTotalRange(100, 1000)
|
|
68
|
+
.whereReferenceContains('VIP')
|
|
69
|
+
.execute();
|
|
70
|
+
```
|
|
71
|
+
- **Direct Query Method** - Intuitive object-based query syntax
|
|
72
|
+
```typescript
|
|
73
|
+
const products = await inkress.products.query({
|
|
74
|
+
status: ['published', 'featured'],
|
|
75
|
+
price: { min: 100, max: 1000 },
|
|
76
|
+
title: { contains: 'laptop' }
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
- **Automatic Query Transformation** - SDK automatically converts clean queries to API format
|
|
80
|
+
- **Runtime Field Type Validation** - Prevents type mismatches before API calls
|
|
81
|
+
- **18 Query Builder Classes** - One for each resource with query support
|
|
82
|
+
|
|
83
|
+
#### Contextual Translation System
|
|
84
|
+
- **Human-Readable API** - Use contextual strings instead of integers
|
|
85
|
+
```typescript
|
|
86
|
+
// Before: await inkress.orders.update(123, { status: 4, kind: 1 });
|
|
87
|
+
// Now: await inkress.orders.update(123, { status: 'confirmed', kind: 'online' });
|
|
88
|
+
```
|
|
89
|
+
- **Automatic Conversion** - SDK converts strings to integers for API calls
|
|
90
|
+
- **Three Translator Classes**:
|
|
91
|
+
- `StatusTranslator` - For status fields across all resources
|
|
92
|
+
- `KindTranslator` - For kind/type fields
|
|
93
|
+
- `FeeStructureTranslator` - For fee structure fields
|
|
94
|
+
- **Bidirectional Translation** - API responses converted back to readable strings
|
|
95
|
+
- **Backward Compatible** - Integer values still work
|
|
96
|
+
|
|
97
|
+
#### 100% Type Safety
|
|
98
|
+
- **128+ Fully Typed Methods** - Every method has explicit input and return types
|
|
99
|
+
- **Zero `any` Types** - No untyped parameters or responses
|
|
100
|
+
- **Specific Response Interfaces** - All responses use specific types:
|
|
101
|
+
- `MerchantBalance`, `MerchantLimits`, `MerchantSubscription`, `MerchantInvoice`
|
|
102
|
+
- `SubscriptionUsageResponse`, `SubscriptionCancelResponse`
|
|
103
|
+
- `CreateSubscriptionLinkResponse`, `ChargeSubscriptionResponse`
|
|
104
|
+
- And many more...
|
|
105
|
+
- **Field Type Mappings** - Runtime validation for all resource fields
|
|
106
|
+
- **Query Type Safety** - Fully typed query parameters for all resources
|
|
107
|
+
|
|
108
|
+
#### Enhanced Merchant Methods
|
|
109
|
+
- `balances()` - Get merchant account balances (properly typed)
|
|
110
|
+
- `limits()` - Get merchant account limits (properly typed)
|
|
111
|
+
- `subscription()` - Get merchant subscription plan (properly typed)
|
|
112
|
+
- `invoices()` - Get merchant invoices (properly typed)
|
|
113
|
+
- `invoice(id)` - Get specific invoice (properly typed)
|
|
114
|
+
|
|
115
|
+
#### Enhanced Subscription Methods
|
|
116
|
+
- `createLink()` - Create subscription payment link
|
|
117
|
+
- `charge()` - Charge existing subscription
|
|
118
|
+
- `usage()` - Record usage for usage-based billing (now properly typed)
|
|
119
|
+
- `cancel()` - Cancel subscription (now properly typed)
|
|
120
|
+
- `getPeriods()` - Get subscription billing periods
|
|
121
|
+
|
|
122
|
+
#### Webhook Verification
|
|
123
|
+
- **`WebhookUtils.verifySignature()`** - Verify webhook signature with body, signature, and secret
|
|
124
|
+
- **`WebhookUtils.verifyRequest()`** - Automatic verification from HTTP request object
|
|
125
|
+
- **`createWebhookMiddleware()`** - Express middleware for automatic webhook verification
|
|
126
|
+
- **Shopify-style signatures** - HMAC SHA256 with Base64 encoding
|
|
127
|
+
- **Header format** - `X-Inkress-Webhook-Signature`
|
|
128
|
+
- See `examples/webhook-server.ts` for complete implementation
|
|
129
|
+
|
|
130
|
+
### 🔄 Changed
|
|
131
|
+
|
|
132
|
+
#### Configuration Interface (BREAKING)
|
|
133
|
+
- **accessToken** replaces `bearerToken` - More standard terminology
|
|
134
|
+
- **username** replaces `clientId` - SDK automatically prepends 'm-' prefix
|
|
135
|
+
- **mode** replaces `endpoint` - Choose 'live' or 'sandbox' instead of full URLs
|
|
136
|
+
|
|
137
|
+
#### Improvements
|
|
138
|
+
- **Consistent Request Patterns** - All resources follow same patterns
|
|
139
|
+
- **Proper HTTP Verbs** - GET for reads, POST for creates, PUT for updates, DELETE for deletes
|
|
140
|
+
- **Translation in CRUD** - All create/update methods use translators
|
|
141
|
+
- **Query Support** - 18 resources now have query() and createQueryBuilder()
|
|
142
|
+
- **Automatic endpoint resolution** - SDK computes API URL from mode
|
|
143
|
+
|
|
144
|
+
### 🐛 Fixed
|
|
145
|
+
|
|
146
|
+
#### Critical Bugs
|
|
147
|
+
- Fixed `addresses.update()` - Was passing `data` instead of `internalData`
|
|
148
|
+
- Fixed `fees.update()` - Was passing `data` instead of `internalData`
|
|
149
|
+
- Fixed merchant account methods - Changed from POST to GET
|
|
150
|
+
- Fixed merchant account methods - Added proper type safety
|
|
151
|
+
|
|
152
|
+
#### Translation Fixes
|
|
153
|
+
- Fixed `billing-plans` - Now translates kind and status in create/update
|
|
154
|
+
- Fixed `subscriptions` - Now translates kind and status in create
|
|
155
|
+
- Fixed `users` - Now uses translator in create method
|
|
156
|
+
|
|
157
|
+
#### Type Safety Fixes
|
|
158
|
+
- Fixed `subscriptions.usage()` - Returns `SubscriptionUsageResponse` instead of `any`
|
|
159
|
+
- Fixed `subscriptions.cancel()` - Returns `SubscriptionCancelResponse` instead of `any`
|
|
160
|
+
- Fixed `public.getMerchantFees()` - Uses `MerchantFeesParams` interface
|
|
161
|
+
- Fixed `ChargeSubscriptionResponse` - Transaction field properly typed
|
|
162
|
+
|
|
163
|
+
### 📚 Documentation
|
|
164
|
+
- **Complete README Rewrite** - Comprehensive documentation with all features
|
|
165
|
+
- **Advanced Query Examples** - Detailed examples for both query syntaxes
|
|
166
|
+
- **TypeScript Guide** - Complete guide to type-safe usage
|
|
167
|
+
- **Resource Examples** - Examples for all 23 resources
|
|
168
|
+
- **Migration Guide** - Available in CONSISTENCY_IMPROVEMENTS.md
|
|
169
|
+
|
|
170
|
+
### 🎯 Statistics
|
|
171
|
+
- **23 Resources** - Up from 9 in v1.0.0 (156% increase)
|
|
172
|
+
- **128+ Methods** - All fully typed
|
|
173
|
+
- **100% Type Coverage** - Zero any types in new code
|
|
174
|
+
- **18 Query Builders** - Fluent API for complex queries
|
|
175
|
+
- **3 Translator Classes** - Automatic contextual conversions
|
|
176
|
+
|
|
177
|
+
### 📦 Upgrading from 1.0.0
|
|
178
|
+
|
|
179
|
+
**Configuration Changes (Required):**
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// OLD (v1.0.0)
|
|
183
|
+
const inkress = new InkressSDK({
|
|
184
|
+
bearerToken: 'your-jwt-token',
|
|
185
|
+
clientId: 'm-merchant-username',
|
|
186
|
+
endpoint: 'https://api.inkress.com',
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// NEW (v1.1.0)
|
|
190
|
+
const inkress = new InkressSDK({
|
|
191
|
+
accessToken: 'your-jwt-token', // renamed
|
|
192
|
+
username: 'merchant-username', // renamed, remove 'm-' prefix
|
|
193
|
+
mode: 'live', // replaces endpoint
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**New Features (Optional):**
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// Use contextual strings for better readability
|
|
201
|
+
await inkress.orders.update(123, { status: 'confirmed' });
|
|
202
|
+
|
|
203
|
+
// Use advanced query system
|
|
204
|
+
await inkress.orders.query({
|
|
205
|
+
status: ['confirmed', 'shipped'],
|
|
206
|
+
total: { min: 100, max: 1000 }
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Import new types
|
|
210
|
+
import {
|
|
211
|
+
MerchantBalance,
|
|
212
|
+
SubscriptionUsageResponse,
|
|
213
|
+
// ... other new types
|
|
214
|
+
} from '@inkress/admin-sdk';
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
See `CONSISTENCY_IMPROVEMENTS.md` for complete details.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
8
221
|
## [1.0.0] - 2025-07-01
|
|
9
222
|
|
|
10
223
|
### Added
|