@dannychirkov/salesdrive-transport-fetch 0.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/README.md +88 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +182 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @dannychirkov/salesdrive-transport-fetch
|
|
2
|
+
|
|
3
|
+
Fetch-based HTTP transport for SalesDrive API client.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @dannychirkov/salesdrive-api-client @dannychirkov/salesdrive-transport-fetch
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createFetchTransport } from '@dannychirkov/salesdrive-transport-fetch';
|
|
15
|
+
import { createClient, orderService } from '@dannychirkov/salesdrive-api-client';
|
|
16
|
+
|
|
17
|
+
const transport = createFetchTransport({
|
|
18
|
+
apiKey: 'your-api-key',
|
|
19
|
+
baseUrl: 'https://your-account.salesdrive.me',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const client = createClient({
|
|
23
|
+
transport,
|
|
24
|
+
apiKey: 'your-api-key',
|
|
25
|
+
baseUrl: 'https://your-account.salesdrive.me',
|
|
26
|
+
}).extend(orderService);
|
|
27
|
+
|
|
28
|
+
const orders = await client.orders.list();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
interface FetchTransportConfig {
|
|
35
|
+
// SalesDrive API key (required)
|
|
36
|
+
apiKey: string;
|
|
37
|
+
|
|
38
|
+
// Base URL for the API (required)
|
|
39
|
+
// Example: https://demo.salesdrive.me
|
|
40
|
+
baseUrl: string;
|
|
41
|
+
|
|
42
|
+
// Additional headers to include in requests
|
|
43
|
+
headers?: Record<string, string>;
|
|
44
|
+
|
|
45
|
+
// Custom fetch implementation
|
|
46
|
+
// Useful for testing or Node.js < 18
|
|
47
|
+
fetch?: typeof fetch;
|
|
48
|
+
|
|
49
|
+
// Request timeout in milliseconds (default: 30000)
|
|
50
|
+
timeout?: number;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## With Retry Logic
|
|
55
|
+
|
|
56
|
+
For automatic retry on rate limit errors:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { createFetchTransportWithRetry } from '@dannychirkov/salesdrive-transport-fetch';
|
|
60
|
+
|
|
61
|
+
const transport = createFetchTransportWithRetry(
|
|
62
|
+
{
|
|
63
|
+
apiKey: 'your-api-key',
|
|
64
|
+
baseUrl: 'https://your-account.salesdrive.me',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
maxRetries: 3,
|
|
68
|
+
retryDelay: 1000,
|
|
69
|
+
retryMultiplier: 2,
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Custom Fetch Implementation
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import nodeFetch from 'node-fetch';
|
|
78
|
+
|
|
79
|
+
const transport = createFetchTransport({
|
|
80
|
+
apiKey: 'your-api-key',
|
|
81
|
+
baseUrl: 'https://your-account.salesdrive.me',
|
|
82
|
+
fetch: nodeFetch as unknown as typeof fetch,
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
[Apache License 2.0](../../LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SalesDrive Fetch Transport
|
|
3
|
+
*
|
|
4
|
+
* Fetch-based HTTP transport implementation for SalesDrive API.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { TransportFunction } from '@dannychirkov/salesdrive-api-client';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for the fetch transport
|
|
11
|
+
*/
|
|
12
|
+
export interface FetchTransportConfig {
|
|
13
|
+
/**
|
|
14
|
+
* SalesDrive API key
|
|
15
|
+
*/
|
|
16
|
+
readonly apiKey: string;
|
|
17
|
+
/**
|
|
18
|
+
* Base URL for the API (e.g., https://demo.salesdrive.me)
|
|
19
|
+
*/
|
|
20
|
+
readonly baseUrl: string;
|
|
21
|
+
/**
|
|
22
|
+
* Additional headers to include in requests
|
|
23
|
+
*/
|
|
24
|
+
readonly headers?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Custom fetch implementation (useful for testing or Node.js < 18)
|
|
27
|
+
*/
|
|
28
|
+
readonly fetch?: typeof fetch;
|
|
29
|
+
/**
|
|
30
|
+
* Request timeout in milliseconds (default: 30000)
|
|
31
|
+
*/
|
|
32
|
+
readonly timeout?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a fetch-based HTTP transport for SalesDrive API
|
|
36
|
+
*
|
|
37
|
+
* @param config - Transport configuration
|
|
38
|
+
* @returns Transport function compatible with SalesDrive client
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { createFetchTransport } from '@dannychirkov/salesdrive-transport-fetch';
|
|
43
|
+
* import { createClient, orderService } from '@dannychirkov/salesdrive-api-client';
|
|
44
|
+
*
|
|
45
|
+
* const transport = createFetchTransport({
|
|
46
|
+
* apiKey: 'your-api-key',
|
|
47
|
+
* baseUrl: 'https://demo.salesdrive.me',
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* const client = createClient({
|
|
51
|
+
* transport,
|
|
52
|
+
* apiKey: 'your-api-key',
|
|
53
|
+
* baseUrl: 'https://demo.salesdrive.me',
|
|
54
|
+
* }).extend(orderService);
|
|
55
|
+
*
|
|
56
|
+
* const orders = await client.orders.list();
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function createFetchTransport(config: FetchTransportConfig): TransportFunction;
|
|
60
|
+
/**
|
|
61
|
+
* Create transport with automatic retry for rate limiting
|
|
62
|
+
*
|
|
63
|
+
* @param config - Transport configuration
|
|
64
|
+
* @param retryConfig - Retry configuration
|
|
65
|
+
* @returns Transport function with retry logic
|
|
66
|
+
*/
|
|
67
|
+
export declare function createFetchTransportWithRetry(config: FetchTransportConfig, retryConfig?: {
|
|
68
|
+
maxRetries?: number;
|
|
69
|
+
retryDelay?: number;
|
|
70
|
+
retryMultiplier?: number;
|
|
71
|
+
}): TransportFunction;
|
|
72
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAGV,iBAAiB,EAElB,MAAM,qCAAqC,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,iBAAiB,CAiHpF;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,oBAAoB,EAC5B,WAAW,GAAE;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CACrB,GACL,iBAAiB,CA8BnB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SalesDrive Fetch Transport
|
|
4
|
+
*
|
|
5
|
+
* Fetch-based HTTP transport implementation for SalesDrive API.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createFetchTransport = createFetchTransport;
|
|
11
|
+
exports.createFetchTransportWithRetry = createFetchTransportWithRetry;
|
|
12
|
+
/**
|
|
13
|
+
* Build URL with query parameters
|
|
14
|
+
*/
|
|
15
|
+
function buildUrl(baseUrl, endpoint, params) {
|
|
16
|
+
const url = new URL(endpoint, baseUrl);
|
|
17
|
+
if (params) {
|
|
18
|
+
for (const [key, value] of Object.entries(params)) {
|
|
19
|
+
if (value !== undefined && value !== null) {
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
// Handle array parameters like filter[setStatusId][]
|
|
22
|
+
for (const item of value) {
|
|
23
|
+
url.searchParams.append(key, String(item));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
url.searchParams.append(key, String(value));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return url.toString();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a fetch-based HTTP transport for SalesDrive API
|
|
36
|
+
*
|
|
37
|
+
* @param config - Transport configuration
|
|
38
|
+
* @returns Transport function compatible with SalesDrive client
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { createFetchTransport } from '@dannychirkov/salesdrive-transport-fetch';
|
|
43
|
+
* import { createClient, orderService } from '@dannychirkov/salesdrive-api-client';
|
|
44
|
+
*
|
|
45
|
+
* const transport = createFetchTransport({
|
|
46
|
+
* apiKey: 'your-api-key',
|
|
47
|
+
* baseUrl: 'https://demo.salesdrive.me',
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* const client = createClient({
|
|
51
|
+
* transport,
|
|
52
|
+
* apiKey: 'your-api-key',
|
|
53
|
+
* baseUrl: 'https://demo.salesdrive.me',
|
|
54
|
+
* }).extend(orderService);
|
|
55
|
+
*
|
|
56
|
+
* const orders = await client.orders.list();
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
function createFetchTransport(config) {
|
|
60
|
+
const { apiKey, baseUrl, headers = {}, timeout = 30000 } = config;
|
|
61
|
+
const fetchFn = config.fetch ?? fetch;
|
|
62
|
+
return async (requestConfig) => {
|
|
63
|
+
const { method, endpoint, params, body, signal } = requestConfig;
|
|
64
|
+
// Build URL with query params for GET requests
|
|
65
|
+
const url = method === 'GET' ? buildUrl(baseUrl, endpoint, params) : new URL(endpoint, baseUrl).toString();
|
|
66
|
+
// Set up abort controller for timeout
|
|
67
|
+
const abortController = new AbortController();
|
|
68
|
+
const timeoutId = setTimeout(() => abortController.abort(), timeout);
|
|
69
|
+
// Combine external signal with timeout signal
|
|
70
|
+
const combinedSignal = signal
|
|
71
|
+
? (() => {
|
|
72
|
+
const combined = new AbortController();
|
|
73
|
+
signal.addEventListener('abort', () => combined.abort());
|
|
74
|
+
abortController.signal.addEventListener('abort', () => combined.abort());
|
|
75
|
+
return combined.signal;
|
|
76
|
+
})()
|
|
77
|
+
: abortController.signal;
|
|
78
|
+
try {
|
|
79
|
+
const response = await fetchFn(url, {
|
|
80
|
+
method,
|
|
81
|
+
headers: {
|
|
82
|
+
'X-Api-Key': apiKey,
|
|
83
|
+
'Content-Type': 'application/json',
|
|
84
|
+
Accept: 'application/json',
|
|
85
|
+
...headers,
|
|
86
|
+
},
|
|
87
|
+
body: method === 'POST' && body ? JSON.stringify(body) : undefined,
|
|
88
|
+
signal: combinedSignal,
|
|
89
|
+
});
|
|
90
|
+
clearTimeout(timeoutId);
|
|
91
|
+
// Handle HTTP errors
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
const errorBody = await response.text();
|
|
94
|
+
let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
95
|
+
try {
|
|
96
|
+
const errorJson = JSON.parse(errorBody);
|
|
97
|
+
if (errorJson.message) {
|
|
98
|
+
errorMessage = errorJson.message;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Use default error message
|
|
103
|
+
}
|
|
104
|
+
if (response.status === 401) {
|
|
105
|
+
const error = new Error(errorMessage);
|
|
106
|
+
error.name = 'AuthenticationError';
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
if (response.status === 429) {
|
|
110
|
+
const error = new Error(errorMessage);
|
|
111
|
+
error.name = 'RateLimitError';
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
const error = new Error(errorMessage);
|
|
115
|
+
error.name = 'ApiError';
|
|
116
|
+
error.statusCode = response.status;
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
const data = (await response.json());
|
|
120
|
+
return {
|
|
121
|
+
status: response.status,
|
|
122
|
+
data,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
clearTimeout(timeoutId);
|
|
127
|
+
if (error instanceof Error) {
|
|
128
|
+
// Re-throw our custom errors
|
|
129
|
+
if (error.name === 'AuthenticationError' ||
|
|
130
|
+
error.name === 'RateLimitError' ||
|
|
131
|
+
error.name === 'ApiError') {
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
// Handle abort/timeout
|
|
135
|
+
if (error.name === 'AbortError') {
|
|
136
|
+
const timeoutError = new Error('Request timeout');
|
|
137
|
+
timeoutError.name = 'NetworkError';
|
|
138
|
+
throw timeoutError;
|
|
139
|
+
}
|
|
140
|
+
// Wrap network errors
|
|
141
|
+
const networkError = new Error(`Network error: ${error.message}`);
|
|
142
|
+
networkError.name = 'NetworkError';
|
|
143
|
+
networkError.cause = error;
|
|
144
|
+
throw networkError;
|
|
145
|
+
}
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Create transport with automatic retry for rate limiting
|
|
152
|
+
*
|
|
153
|
+
* @param config - Transport configuration
|
|
154
|
+
* @param retryConfig - Retry configuration
|
|
155
|
+
* @returns Transport function with retry logic
|
|
156
|
+
*/
|
|
157
|
+
function createFetchTransportWithRetry(config, retryConfig = {}) {
|
|
158
|
+
const baseTransport = createFetchTransport(config);
|
|
159
|
+
const { maxRetries = 3, retryDelay = 1000, retryMultiplier = 2 } = retryConfig;
|
|
160
|
+
return async (requestConfig) => {
|
|
161
|
+
let lastError;
|
|
162
|
+
let delay = retryDelay;
|
|
163
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
164
|
+
try {
|
|
165
|
+
return await baseTransport(requestConfig);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (error instanceof Error && error.name === 'RateLimitError') {
|
|
169
|
+
lastError = error;
|
|
170
|
+
if (attempt < maxRetries) {
|
|
171
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
172
|
+
delay *= retryMultiplier;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
throw lastError;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAwFH,oDAiHC;AASD,sEAqCC;AAhND;;GAEG;AACH,SAAS,QAAQ,CAAC,OAAe,EAAE,QAAgB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E,CAAC;gBACf,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;oBAC9D,SAAS,GAAG,KAAK,CAAC;oBAElB,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;wBACzB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;wBAC3D,KAAK,IAAI,eAAe,CAAC;wBACzB,SAAS;oBACX,CAAC;gBACH,CAAC;gBAED,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,MAAM,SAAS,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dannychirkov/salesdrive-transport-fetch",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fetch-based HTTP transport for SalesDrive API client",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"author": "Danny Chirkov",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/dannychirkov/salesdrive-api",
|
|
15
|
+
"directory": "packages/salesdrive-transport-fetch"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/dannychirkov/salesdrive-api#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/dannychirkov/salesdrive-api/issues"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"salesdrive",
|
|
23
|
+
"transport",
|
|
24
|
+
"fetch",
|
|
25
|
+
"http"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"test": "jest",
|
|
30
|
+
"type-check": "tsc --noEmit",
|
|
31
|
+
"clean": "rimraf dist"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@dannychirkov/salesdrive-api-client": "*"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@dannychirkov/salesdrive-api-client": "*",
|
|
38
|
+
"typescript": "^5.3.0",
|
|
39
|
+
"@types/node": "^20.10.0",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"@types/jest": "^29.5.11",
|
|
42
|
+
"ts-jest": "^29.1.1",
|
|
43
|
+
"rimraf": "^5.0.5"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|