@coderule/clients 1.0.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 +224 -0
- package/dist/clients/auth-client.d.ts +26 -0
- package/dist/clients/auth-client.d.ts.map +1 -0
- package/dist/clients/auth-client.js +129 -0
- package/dist/clients/auth-client.js.map +1 -0
- package/dist/clients/retrieval-client.d.ts +49 -0
- package/dist/clients/retrieval-client.d.ts.map +1 -0
- package/dist/clients/retrieval-client.js +274 -0
- package/dist/clients/retrieval-client.js.map +1 -0
- package/dist/clients/sync-client.d.ts +46 -0
- package/dist/clients/sync-client.d.ts.map +1 -0
- package/dist/clients/sync-client.js +198 -0
- package/dist/clients/sync-client.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5 -0
- package/dist/polyfills/fetch-native.d.ts +10 -0
- package/dist/polyfills/fetch-native.d.ts.map +1 -0
- package/dist/polyfills/fetch-native.js +10 -0
- package/dist/polyfills/fetch-native.js.map +1 -0
- package/dist/polyfills/fetch-polyfill.d.ts +7 -0
- package/dist/polyfills/fetch-polyfill.d.ts.map +1 -0
- package/dist/polyfills/fetch-polyfill.js +38 -0
- package/dist/polyfills/fetch-polyfill.js.map +1 -0
- package/dist/utils/fetch-wrapper.d.ts +11 -0
- package/dist/utils/fetch-wrapper.d.ts.map +1 -0
- package/dist/utils/fetch-wrapper.js +34 -0
- package/dist/utils/fetch-wrapper.js.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Coderule TypeScript Client SDK
|
|
2
|
+
|
|
3
|
+
TypeScript HTTP clients for core Coderule microservices (Auth, Sync, Retrieval) with automatic fetch polyfill support.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js 14+ (automatically uses node-fetch for versions < 18, native fetch for 18+)
|
|
8
|
+
- TypeScript 5.0+
|
|
9
|
+
|
|
10
|
+
## Node.js Version Compatibility
|
|
11
|
+
|
|
12
|
+
- **Node.js 18+**: Uses native fetch API (no additional dependencies needed)
|
|
13
|
+
- **Node.js 14-17**: Requires `node-fetch` to be installed:
|
|
14
|
+
```bash
|
|
15
|
+
npm install node-fetch@2
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The library automatically detects your Node.js version and uses the appropriate fetch implementation.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install
|
|
24
|
+
npm run build
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage Examples
|
|
28
|
+
|
|
29
|
+
### Authentication Service
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { AuthHttpClient } from '@coderule/clients';
|
|
33
|
+
|
|
34
|
+
const authClient = new AuthHttpClient('http://localhost:8001');
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
// Authenticate and get JWT
|
|
38
|
+
const authResponse = await authClient.authenticate('your-token');
|
|
39
|
+
const jwt = authResponse.jwt;
|
|
40
|
+
console.log(`JWT expires at: ${authResponse.expires_at}`);
|
|
41
|
+
|
|
42
|
+
// Check health
|
|
43
|
+
const health = await authClient.health();
|
|
44
|
+
console.log(`Auth service status: ${health.status}`);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Authentication failed:', error);
|
|
47
|
+
} finally {
|
|
48
|
+
authClient.close();
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Sync Service
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { SyncHttpClient } from '@coderule/clients';
|
|
56
|
+
|
|
57
|
+
const syncClient = new SyncHttpClient('http://localhost:8002', jwt);
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
// Prepare files for sync (you need to provide the content)
|
|
61
|
+
const files = [
|
|
62
|
+
{ file_path: 'src/main.ts', content: 'const x = 1;' },
|
|
63
|
+
{ file_path: 'src/utils.ts', content: 'export function util() {}' },
|
|
64
|
+
{ file_path: 'package.json', content: '{"name": "test"}' }
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
// Calculate file hashes
|
|
68
|
+
const filesInfo = [];
|
|
69
|
+
const fileHashes = [];
|
|
70
|
+
const fileContents = new Map();
|
|
71
|
+
|
|
72
|
+
for (const file of files) {
|
|
73
|
+
const fileHash = SyncHttpClient.calculateFileHash(file.file_path, file.content);
|
|
74
|
+
filesInfo.push({
|
|
75
|
+
file_path: file.file_path,
|
|
76
|
+
file_hash: fileHash
|
|
77
|
+
});
|
|
78
|
+
fileContents.set(fileHash, {
|
|
79
|
+
path: file.file_path,
|
|
80
|
+
content: Buffer.from(file.content)
|
|
81
|
+
});
|
|
82
|
+
fileHashes.push(fileHash);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Calculate snapshot hash
|
|
86
|
+
const snapshotHash = SyncHttpClient.calculateSnapshotHash(fileHashes);
|
|
87
|
+
console.log(`Snapshot hash: ${snapshotHash}`);
|
|
88
|
+
|
|
89
|
+
// Check if snapshot exists
|
|
90
|
+
const status = await syncClient.checkSnapshotStatus(snapshotHash);
|
|
91
|
+
console.log(`Snapshot status: ${status.status}`);
|
|
92
|
+
|
|
93
|
+
if (status.status === 'NOT_FOUND') {
|
|
94
|
+
// Create snapshot
|
|
95
|
+
const result = await syncClient.createSnapshot(snapshotHash, filesInfo);
|
|
96
|
+
|
|
97
|
+
// Upload missing files if needed
|
|
98
|
+
if (result.status === 'MISSING_CONTENT' && result.missing_files) {
|
|
99
|
+
const missingContent = new Map();
|
|
100
|
+
for (const missingFile of result.missing_files) {
|
|
101
|
+
if (fileContents.has(missingFile.file_hash)) {
|
|
102
|
+
missingContent.set(missingFile.file_hash, fileContents.get(missingFile.file_hash));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (missingContent.size > 0) {
|
|
107
|
+
await syncClient.uploadFileContent(missingContent);
|
|
108
|
+
// Retry snapshot creation
|
|
109
|
+
await syncClient.createSnapshot(snapshotHash, filesInfo);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error('Sync failed:', error);
|
|
115
|
+
} finally {
|
|
116
|
+
syncClient.close();
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Retrieval Service
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { RetrievalHttpClient } from '@coderule/clients';
|
|
124
|
+
|
|
125
|
+
const retrievalClient = new RetrievalHttpClient('http://localhost:8004');
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
// Execute a retrieval query
|
|
129
|
+
const result = await retrievalClient.query(
|
|
130
|
+
snapshotHash,
|
|
131
|
+
'Find the main authentication logic',
|
|
132
|
+
3000, // budget tokens
|
|
133
|
+
jwt,
|
|
134
|
+
{
|
|
135
|
+
formatter: 'compact',
|
|
136
|
+
flow_strength: 1.5,
|
|
137
|
+
blend_alpha: 0.8
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
console.log(result.formatted_output);
|
|
142
|
+
|
|
143
|
+
// Check snapshot status
|
|
144
|
+
const status = await retrievalClient.checkSnapshotStatus(snapshotHash, jwt);
|
|
145
|
+
console.log(`Snapshot indexing status: ${status.status}`);
|
|
146
|
+
|
|
147
|
+
// Get cache statistics
|
|
148
|
+
const cacheStats = await retrievalClient.getCacheStats(jwt);
|
|
149
|
+
console.log(`Cached snapshots: ${cacheStats.cached_snapshots}`);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error('Retrieval failed:', error);
|
|
152
|
+
} finally {
|
|
153
|
+
retrievalClient.close();
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Utility Methods
|
|
158
|
+
|
|
159
|
+
The SyncHttpClient provides static utility methods for hash calculation:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { SyncHttpClient } from '@coderule/clients';
|
|
163
|
+
|
|
164
|
+
// Calculate file hash from path and content
|
|
165
|
+
const fileHash = SyncHttpClient.calculateFileHash('src/main.ts', 'const x = 1;');
|
|
166
|
+
console.log(`File hash: ${fileHash}`);
|
|
167
|
+
|
|
168
|
+
// Calculate snapshot hash from file hashes
|
|
169
|
+
const fileHashes = ['hash1', 'hash2', 'hash3'];
|
|
170
|
+
const snapshotHash = SyncHttpClient.calculateSnapshotHash(fileHashes);
|
|
171
|
+
console.log(`Snapshot hash: ${snapshotHash}`);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Error Handling
|
|
175
|
+
|
|
176
|
+
All clients throw errors with descriptive messages on failures:
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
try {
|
|
180
|
+
const result = await client.someMethod();
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (error.message.includes('timeout')) {
|
|
183
|
+
console.error('Request timed out');
|
|
184
|
+
} else if (error.message.includes('401')) {
|
|
185
|
+
console.error('Authentication failed');
|
|
186
|
+
} else {
|
|
187
|
+
console.error('Unexpected error:', error.message);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Configuration
|
|
193
|
+
|
|
194
|
+
All clients support timeout configuration in milliseconds:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
// Custom timeout of 30 seconds
|
|
198
|
+
const client = new RetrievalHttpClient('http://localhost:8004', 30000);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Notes
|
|
202
|
+
|
|
203
|
+
- **Automatic fetch detection**: Works with Node.js 14+ (uses node-fetch for < 18, native fetch for 18+)
|
|
204
|
+
- **Optional dependency**: `node-fetch` is only required for Node.js versions < 18
|
|
205
|
+
- **Zero dependencies for Node.js 18+**: Uses native fetch API
|
|
206
|
+
- Clients automatically handle JSON serialization/deserialization
|
|
207
|
+
- JWT tokens are required for most operations (except health checks)
|
|
208
|
+
- All clients have a `close()` method for consistency, though fetch doesn't maintain persistent connections
|
|
209
|
+
|
|
210
|
+
## Building from Source
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Install dependencies
|
|
214
|
+
npm install
|
|
215
|
+
|
|
216
|
+
# Build TypeScript to JavaScript
|
|
217
|
+
npm run build
|
|
218
|
+
|
|
219
|
+
# Output will be in dist/ directory
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
ISC
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface AuthResponse {
|
|
2
|
+
jwt: string;
|
|
3
|
+
expires_at: string;
|
|
4
|
+
}
|
|
5
|
+
interface HealthResponse {
|
|
6
|
+
status: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export declare class AuthHttpClient {
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private timeout;
|
|
13
|
+
constructor(baseUrl: string, timeout?: number);
|
|
14
|
+
authenticate(token: string): Promise<AuthResponse>;
|
|
15
|
+
health(): Promise<HealthResponse>;
|
|
16
|
+
close(): void;
|
|
17
|
+
}
|
|
18
|
+
interface JWTPayload {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
exp?: number;
|
|
21
|
+
iat?: number;
|
|
22
|
+
nbf?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function decodeJWT(jwtToken: string): JWTPayload | null;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=auth-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-client.d.ts","sourceRoot":"","sources":["../../src/clients/auth-client.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;gBAOZ,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAc;IAW9C,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA4ClD,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAoCvC,KAAK,IAAI,IAAI;CAGd;AAKD,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AASD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAoC7D"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AuthHttpClient = void 0;
|
|
37
|
+
exports.decodeJWT = decodeJWT;
|
|
38
|
+
const fetch_wrapper_1 = __importStar(require("../utils/fetch-wrapper"));
|
|
39
|
+
class AuthHttpClient {
|
|
40
|
+
constructor(baseUrl, timeout = 30000) {
|
|
41
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
42
|
+
this.timeout = timeout;
|
|
43
|
+
}
|
|
44
|
+
async authenticate(token) {
|
|
45
|
+
const url = `${this.baseUrl}/api/auth/authenticate`;
|
|
46
|
+
try {
|
|
47
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
48
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
49
|
+
const response = await (0, fetch_wrapper_1.default)(url, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
},
|
|
54
|
+
body: JSON.stringify({ token }),
|
|
55
|
+
signal: controller.signal,
|
|
56
|
+
});
|
|
57
|
+
clearTimeout(timeoutId);
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
const errorText = await response.text();
|
|
60
|
+
throw new Error(`Authentication failed with status ${response.status}: ${errorText}`);
|
|
61
|
+
}
|
|
62
|
+
const data = (await response.json());
|
|
63
|
+
console.debug(`Authentication successful, JWT expires at ${data.expires_at}`);
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error.name === 'AbortError') {
|
|
68
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
69
|
+
}
|
|
70
|
+
console.error(`Authentication request failed: ${error.message}`);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async health() {
|
|
75
|
+
const url = `${this.baseUrl}/api/auth/health`;
|
|
76
|
+
try {
|
|
77
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
78
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
79
|
+
const response = await (0, fetch_wrapper_1.default)(url, {
|
|
80
|
+
method: 'GET',
|
|
81
|
+
signal: controller.signal,
|
|
82
|
+
});
|
|
83
|
+
clearTimeout(timeoutId);
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
const errorText = await response.text();
|
|
86
|
+
throw new Error(`Health check failed with status ${response.status}: ${errorText}`);
|
|
87
|
+
}
|
|
88
|
+
const data = (await response.json());
|
|
89
|
+
console.debug(`Health check: ${data.status}`);
|
|
90
|
+
return data;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error.name === 'AbortError') {
|
|
94
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
95
|
+
}
|
|
96
|
+
console.error(`Health check request failed: ${error.message}`);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
close() {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.AuthHttpClient = AuthHttpClient;
|
|
104
|
+
function decodeJWT(jwtToken) {
|
|
105
|
+
try {
|
|
106
|
+
const parts = jwtToken.split('.');
|
|
107
|
+
if (parts.length !== 3) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const payload = parts[1];
|
|
111
|
+
const paddedPayload = payload + '='.repeat((4 - (payload.length % 4)) % 4);
|
|
112
|
+
const base64 = paddedPayload.replace(/-/g, '+').replace(/_/g, '/');
|
|
113
|
+
const jsonString = Buffer.from(base64, 'base64').toString('utf8');
|
|
114
|
+
const payloadObj = JSON.parse(jsonString);
|
|
115
|
+
if (payloadObj.exp) {
|
|
116
|
+
const now = Math.floor(Date.now() / 1000);
|
|
117
|
+
if (payloadObj.exp < now) {
|
|
118
|
+
console.debug('JWT token is expired');
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return payloadObj;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.error('Failed to decode JWT:', error);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=auth-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-client.js","sourceRoot":"","sources":["../../src/clients/auth-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,8BAoCC;AA3KD,wEAAgE;AAahE,MAAa,cAAc;IASzB,YAAY,OAAe,EAAE,UAAkB,KAAK;QAClD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAQD,KAAK,CAAC,YAAY,CAAC,KAAa;QAC9B,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,wBAAwB,CAAC;QAEpD,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,IAAI,+BAAe,EAAE,CAAC;YACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,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,aAAa,GAAG,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAG3E,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAGnE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAGlE,MAAM,UAAU,GAAe,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAGtD,IAAI,UAAU,CAAC,GAAG,EAAE,CAAC;YACnB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;YAC1C,IAAI,UAAU,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBACtC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
interface HealthResponse {
|
|
2
|
+
status: string;
|
|
3
|
+
database?: string;
|
|
4
|
+
embedder?: string;
|
|
5
|
+
cache_size?: number;
|
|
6
|
+
cache_ttl?: number;
|
|
7
|
+
version?: string;
|
|
8
|
+
}
|
|
9
|
+
interface RetrievalOptions {
|
|
10
|
+
flow_strength?: number;
|
|
11
|
+
blend_alpha?: number;
|
|
12
|
+
hop_depth?: number;
|
|
13
|
+
max_iterations?: number;
|
|
14
|
+
split?: number;
|
|
15
|
+
formatter?: 'standard' | 'compact';
|
|
16
|
+
}
|
|
17
|
+
interface RetrievalResult {
|
|
18
|
+
formatted_output: string;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
interface SnapshotStatus {
|
|
22
|
+
snapshot_hash: string;
|
|
23
|
+
status: 'PENDING' | 'INDEXING' | 'READY' | 'FAILED' | 'NOT_FOUND';
|
|
24
|
+
indexed_at?: string;
|
|
25
|
+
total_files?: number;
|
|
26
|
+
total_chunks?: number;
|
|
27
|
+
message?: string;
|
|
28
|
+
}
|
|
29
|
+
interface CacheStats {
|
|
30
|
+
cached_snapshots: number;
|
|
31
|
+
max_size: number;
|
|
32
|
+
ttl: number;
|
|
33
|
+
snapshots: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare class RetrievalHttpClient {
|
|
36
|
+
private baseUrl;
|
|
37
|
+
private timeout;
|
|
38
|
+
private apiBase;
|
|
39
|
+
constructor(uri?: string, timeout?: number);
|
|
40
|
+
healthCheck(): Promise<HealthResponse>;
|
|
41
|
+
query(snapshotHash: string, queryText: string, budgetTokens: number | undefined, jwt: string, options?: RetrievalOptions): Promise<RetrievalResult>;
|
|
42
|
+
checkSnapshotStatus(snapshotHash: string, jwt: string): Promise<SnapshotStatus>;
|
|
43
|
+
clearCache(jwt: string): Promise<boolean>;
|
|
44
|
+
getCacheStats(jwt: string): Promise<CacheStats>;
|
|
45
|
+
queryWithOptions(snapshotHash: string, queryText: string, jwt: string, budgetTokens?: number, flowStrength?: number, blendAlpha?: number, hopDepth?: number, maxIterations?: number, split?: number, formatter?: 'standard' | 'compact'): Promise<RetrievalResult>;
|
|
46
|
+
close(): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=retrieval-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-client.d.ts","sourceRoot":"","sources":["../../src/clients/retrieval-client.ts"],"names":[],"mappings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IAsDtC,KAAK,CACT,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,YAAO,EAC3B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,eAAe,CAAC;IAmFrB,mBAAmB,CACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,cAAc,CAAC;IA4DpB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA6CzC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAyD/C,gBAAgB,CACpB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,YAAY,GAAE,MAAa,EAC3B,YAAY,GAAE,MAAY,EAC1B,UAAU,GAAE,MAAY,EACxB,QAAQ,GAAE,MAAU,EACpB,aAAa,GAAE,MAAW,EAC1B,KAAK,GAAE,MAAY,EACnB,SAAS,GAAE,UAAU,GAAG,SAAsB,GAC7C,OAAO,CAAC,eAAe,CAAC;IAgB3B,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.RetrievalHttpClient = void 0;
|
|
37
|
+
const fetch_wrapper_1 = __importStar(require("../utils/fetch-wrapper"));
|
|
38
|
+
class RetrievalHttpClient {
|
|
39
|
+
constructor(uri = 'http://localhost:8004', timeout = 60000) {
|
|
40
|
+
let processedUri = uri;
|
|
41
|
+
if (!uri.startsWith('http://') && !uri.startsWith('https://')) {
|
|
42
|
+
processedUri = `http://${uri}`;
|
|
43
|
+
}
|
|
44
|
+
const url = new URL(processedUri);
|
|
45
|
+
if (url.pathname && url.pathname !== '/') {
|
|
46
|
+
this.baseUrl = `${url.protocol}//${url.host}${url.pathname}`;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.baseUrl = `${url.protocol}//${url.host}`;
|
|
50
|
+
}
|
|
51
|
+
this.timeout = timeout;
|
|
52
|
+
if (this.baseUrl.endsWith('/')) {
|
|
53
|
+
this.apiBase = `${this.baseUrl}api/retrieval/`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.apiBase = `${this.baseUrl}/api/retrieval/`;
|
|
57
|
+
}
|
|
58
|
+
console.debug(`Initialized HTTP client for ${this.baseUrl}`);
|
|
59
|
+
console.debug(`API base: ${this.apiBase}`);
|
|
60
|
+
}
|
|
61
|
+
async healthCheck() {
|
|
62
|
+
const healthEndpoint = `${this.apiBase}health`;
|
|
63
|
+
console.debug(`Checking server health: ${healthEndpoint}`);
|
|
64
|
+
try {
|
|
65
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
66
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
67
|
+
const response = await (0, fetch_wrapper_1.default)(healthEndpoint, {
|
|
68
|
+
method: 'GET',
|
|
69
|
+
signal: controller.signal,
|
|
70
|
+
});
|
|
71
|
+
clearTimeout(timeoutId);
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
const errorText = await response.text();
|
|
74
|
+
throw new Error(`Health check failed with status ${response.status}: ${errorText}`);
|
|
75
|
+
}
|
|
76
|
+
const healthInfo = (await response.json());
|
|
77
|
+
console.debug(`HTTP retrieval server status:`, healthInfo);
|
|
78
|
+
return {
|
|
79
|
+
status: healthInfo.status || 'UNKNOWN',
|
|
80
|
+
database: healthInfo.database || 'UNKNOWN',
|
|
81
|
+
embedder: healthInfo.embedder || 'UNKNOWN',
|
|
82
|
+
cache_size: healthInfo.cache_size || 0,
|
|
83
|
+
cache_ttl: healthInfo.cache_ttl || 0,
|
|
84
|
+
version: healthInfo.version || 'unknown',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error.name === 'AbortError') {
|
|
89
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
90
|
+
}
|
|
91
|
+
console.error(`Error checking HTTP server health: ${error.message}`);
|
|
92
|
+
throw new Error(`Unable to connect to HTTP server ${this.baseUrl}: ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async query(snapshotHash, queryText, budgetTokens = 3000, jwt, options) {
|
|
96
|
+
if (!snapshotHash) {
|
|
97
|
+
throw new Error('Snapshot hash must be provided');
|
|
98
|
+
}
|
|
99
|
+
if (!queryText) {
|
|
100
|
+
throw new Error('Query text must be provided');
|
|
101
|
+
}
|
|
102
|
+
if (!jwt) {
|
|
103
|
+
throw new Error('JWT must be provided');
|
|
104
|
+
}
|
|
105
|
+
if (budgetTokens < 100) {
|
|
106
|
+
throw new Error('Budget tokens must be at least 100');
|
|
107
|
+
}
|
|
108
|
+
const startTime = Date.now();
|
|
109
|
+
const queryEndpoint = `${this.apiBase}query`;
|
|
110
|
+
try {
|
|
111
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
112
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
113
|
+
const requestBody = {
|
|
114
|
+
snapshot_hash: snapshotHash,
|
|
115
|
+
query: queryText,
|
|
116
|
+
budget_tokens: budgetTokens,
|
|
117
|
+
};
|
|
118
|
+
if (options) {
|
|
119
|
+
requestBody.options = options;
|
|
120
|
+
}
|
|
121
|
+
const response = await (0, fetch_wrapper_1.default)(queryEndpoint, {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
headers: {
|
|
124
|
+
'Content-Type': 'application/json',
|
|
125
|
+
Authorization: `Bearer ${jwt}`,
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify(requestBody),
|
|
128
|
+
signal: controller.signal,
|
|
129
|
+
});
|
|
130
|
+
clearTimeout(timeoutId);
|
|
131
|
+
if (response.status === 404) {
|
|
132
|
+
const errorData = (await response.json());
|
|
133
|
+
throw new Error(errorData.detail || 'Snapshot not found or access denied');
|
|
134
|
+
}
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
const errorText = await response.text();
|
|
137
|
+
throw new Error(`Query failed with status ${response.status}: ${errorText}`);
|
|
138
|
+
}
|
|
139
|
+
const result = (await response.json());
|
|
140
|
+
const elapsedTime = (Date.now() - startTime) / 1000;
|
|
141
|
+
const formatter = options?.formatter || 'standard';
|
|
142
|
+
console.debug(`Retrieval query completed for snapshot ${snapshotHash.substring(0, 8)}... ` +
|
|
143
|
+
`Formatter: ${formatter}. Total time: ${elapsedTime.toFixed(2)}s`);
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (error.name === 'AbortError') {
|
|
148
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
149
|
+
}
|
|
150
|
+
console.error(`Error executing retrieval query: ${error.message}`);
|
|
151
|
+
throw new Error(`Failed to execute retrieval query: ${error.message}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async checkSnapshotStatus(snapshotHash, jwt) {
|
|
155
|
+
if (!snapshotHash) {
|
|
156
|
+
throw new Error('Snapshot hash must be provided');
|
|
157
|
+
}
|
|
158
|
+
if (!jwt) {
|
|
159
|
+
throw new Error('JWT must be provided');
|
|
160
|
+
}
|
|
161
|
+
const statusEndpoint = `${this.apiBase}snapshots/${snapshotHash}/status`;
|
|
162
|
+
try {
|
|
163
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
164
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
165
|
+
const response = await (0, fetch_wrapper_1.default)(statusEndpoint, {
|
|
166
|
+
method: 'GET',
|
|
167
|
+
headers: {
|
|
168
|
+
Authorization: `Bearer ${jwt}`,
|
|
169
|
+
},
|
|
170
|
+
signal: controller.signal,
|
|
171
|
+
});
|
|
172
|
+
clearTimeout(timeoutId);
|
|
173
|
+
if (response.status === 404) {
|
|
174
|
+
return {
|
|
175
|
+
snapshot_hash: snapshotHash,
|
|
176
|
+
status: 'NOT_FOUND',
|
|
177
|
+
message: 'Snapshot not found or access denied',
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
if (!response.ok) {
|
|
181
|
+
const errorText = await response.text();
|
|
182
|
+
throw new Error(`Status check failed with status ${response.status}: ${errorText}`);
|
|
183
|
+
}
|
|
184
|
+
const statusInfo = (await response.json());
|
|
185
|
+
console.debug(`Snapshot ${snapshotHash.substring(0, 8)}... status: ${statusInfo.status}`);
|
|
186
|
+
return statusInfo;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
if (error.name === 'AbortError') {
|
|
190
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
191
|
+
}
|
|
192
|
+
console.error(`Error checking snapshot status: ${error.message}`);
|
|
193
|
+
throw new Error(`Failed to check snapshot status: ${error.message}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async clearCache(jwt) {
|
|
197
|
+
if (!jwt) {
|
|
198
|
+
throw new Error('JWT must be provided');
|
|
199
|
+
}
|
|
200
|
+
const cacheEndpoint = `${this.apiBase}cache`;
|
|
201
|
+
try {
|
|
202
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
203
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
204
|
+
const response = await (0, fetch_wrapper_1.default)(cacheEndpoint, {
|
|
205
|
+
method: 'DELETE',
|
|
206
|
+
headers: {
|
|
207
|
+
Authorization: `Bearer ${jwt}`,
|
|
208
|
+
},
|
|
209
|
+
signal: controller.signal,
|
|
210
|
+
});
|
|
211
|
+
clearTimeout(timeoutId);
|
|
212
|
+
if (!response.ok) {
|
|
213
|
+
const errorText = await response.text();
|
|
214
|
+
throw new Error(`Cache clear failed with status ${response.status}: ${errorText}`);
|
|
215
|
+
}
|
|
216
|
+
console.info('Graph cache cleared successfully');
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
if (error.name === 'AbortError') {
|
|
221
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
222
|
+
}
|
|
223
|
+
console.error(`Error clearing cache: ${error.message}`);
|
|
224
|
+
throw new Error(`Failed to clear cache: ${error.message}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async getCacheStats(jwt) {
|
|
228
|
+
if (!jwt) {
|
|
229
|
+
throw new Error('JWT must be provided');
|
|
230
|
+
}
|
|
231
|
+
const statsEndpoint = `${this.apiBase}cache/stats`;
|
|
232
|
+
try {
|
|
233
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
234
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
235
|
+
const response = await (0, fetch_wrapper_1.default)(statsEndpoint, {
|
|
236
|
+
method: 'GET',
|
|
237
|
+
headers: {
|
|
238
|
+
Authorization: `Bearer ${jwt}`,
|
|
239
|
+
},
|
|
240
|
+
signal: controller.signal,
|
|
241
|
+
});
|
|
242
|
+
clearTimeout(timeoutId);
|
|
243
|
+
if (!response.ok) {
|
|
244
|
+
const errorText = await response.text();
|
|
245
|
+
throw new Error(`Stats retrieval failed with status ${response.status}: ${errorText}`);
|
|
246
|
+
}
|
|
247
|
+
const stats = (await response.json());
|
|
248
|
+
console.debug(`Cache stats: ${stats.cached_snapshots || 0} snapshots cached`);
|
|
249
|
+
return stats;
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
if (error.name === 'AbortError') {
|
|
253
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
254
|
+
}
|
|
255
|
+
console.error(`Error getting cache stats: ${error.message}`);
|
|
256
|
+
throw new Error(`Failed to get cache stats: ${error.message}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
async queryWithOptions(snapshotHash, queryText, jwt, budgetTokens = 3000, flowStrength = 1.5, blendAlpha = 0.8, hopDepth = 2, maxIterations = 12, split = 0.8, formatter = 'standard') {
|
|
260
|
+
const options = {
|
|
261
|
+
flow_strength: flowStrength,
|
|
262
|
+
blend_alpha: blendAlpha,
|
|
263
|
+
hop_depth: hopDepth,
|
|
264
|
+
max_iterations: maxIterations,
|
|
265
|
+
split,
|
|
266
|
+
formatter,
|
|
267
|
+
};
|
|
268
|
+
return this.query(snapshotHash, queryText, budgetTokens, jwt, options);
|
|
269
|
+
}
|
|
270
|
+
close() {
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
exports.RetrievalHttpClient = RetrievalHttpClient;
|
|
274
|
+
//# sourceMappingURL=retrieval-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-client.js","sourceRoot":"","sources":["../../src/clients/retrieval-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wEAAgE;AAyChE,MAAa,mBAAmB;IAU9B,YAAY,MAAc,uBAAuB,EAAE,UAAkB,KAAK;QAExE,IAAI,YAAY,GAAG,GAAG,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9D,YAAY,GAAG,UAAU,GAAG,EAAE,CAAC;QACjC,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAGlC,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC;YACzC,IAAI,CAAC,OAAO,GAAG,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;QAChD,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAGvB,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,gBAAgB,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,iB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D,KAAK,CAAC,gBAAgB,CACpB,YAAoB,EACpB,SAAiB,EACjB,GAAW,EACX,eAAuB,IAAI,EAC3B,eAAuB,GAAG,EAC1B,aAAqB,GAAG,EACxB,WAAmB,CAAC,EACpB,gBAAwB,EAAE,EAC1B,QAAgB,GAAG,EACnB,YAAoC,UAAU;QAE9C,MAAM,OAAO,GAAqB;YAChC,aAAa,EAAE,YAAY;YAC3B,WAAW,EAAE,UAAU;YACvB,SAAS,EAAE,QAAQ;YACnB,cAAc,EAAE,aAAa;YAC7B,KAAK;YACL,SAAS;SACV,CAAC;QAEF,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAKD,KAAK;IAEL,CAAC;CACF;AA9XD,kDA8XC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
interface SnapshotStatus {
|
|
2
|
+
status: 'NOT_FOUND' | 'READY' | 'INDEXING' | 'PENDING' | 'FAILED' | 'MISSING_CONTENT';
|
|
3
|
+
snapshot_hash?: string;
|
|
4
|
+
created_at?: string;
|
|
5
|
+
indexed_at?: string;
|
|
6
|
+
total_files?: number;
|
|
7
|
+
missing_files?: Array<{
|
|
8
|
+
file_path: string;
|
|
9
|
+
file_hash: string;
|
|
10
|
+
}>;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
interface FileInfo {
|
|
14
|
+
file_path: string;
|
|
15
|
+
file_hash: string;
|
|
16
|
+
}
|
|
17
|
+
interface UploadResult {
|
|
18
|
+
uploaded_count: number;
|
|
19
|
+
failed_count: number;
|
|
20
|
+
failed_files?: string[];
|
|
21
|
+
}
|
|
22
|
+
interface HealthResponse {
|
|
23
|
+
status: string;
|
|
24
|
+
database?: string;
|
|
25
|
+
version?: string;
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
28
|
+
export declare class SyncHttpClient {
|
|
29
|
+
private baseUrl;
|
|
30
|
+
private jwtToken;
|
|
31
|
+
private timeout;
|
|
32
|
+
private headers;
|
|
33
|
+
constructor(baseUrl: string, jwtToken: string, timeout?: number);
|
|
34
|
+
checkSnapshotStatus(snapshotHash: string): Promise<SnapshotStatus>;
|
|
35
|
+
createSnapshot(snapshotHash: string, files: FileInfo[]): Promise<SnapshotStatus>;
|
|
36
|
+
uploadFileContent(filesContent: Map<string, {
|
|
37
|
+
path: string;
|
|
38
|
+
content: Buffer | string;
|
|
39
|
+
}>): Promise<UploadResult>;
|
|
40
|
+
static calculateFileHash(filePath: string, content: Buffer | string): string;
|
|
41
|
+
static calculateSnapshotHash(fileHashes: string[]): string;
|
|
42
|
+
health(): Promise<HealthResponse>;
|
|
43
|
+
close(): void;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=sync-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-client.d.ts","sourceRoot":"","sources":["../../src/clients/sync-client.ts"],"names":[],"mappings":"AASA,UAAU,cAAc;IACtB,MAAM,EACF,WAAW,GACX,OAAO,GACP,UAAU,GACV,SAAS,GACT,QAAQ,GACR,iBAAiB,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,UAAU,QAAQ;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,YAAY;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAyB;gBAQ5B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAAc;IAgBhE,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA6ClE,cAAc,CAClB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,QAAQ,EAAE,GAChB,OAAO,CAAC,cAAc,CAAC;IAuDpB,iBAAiB,CACrB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC,GACpE,OAAO,CAAC,YAAY,CAAC;IA+DxB,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAe5E,MAAM,CAAC,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM;IAapD,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAoCvC,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SyncHttpClient = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
const fetch_wrapper_1 = __importStar(require("../utils/fetch-wrapper"));
|
|
39
|
+
class SyncHttpClient {
|
|
40
|
+
constructor(baseUrl, jwtToken, timeout = 60000) {
|
|
41
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
42
|
+
this.jwtToken = jwtToken;
|
|
43
|
+
this.timeout = timeout;
|
|
44
|
+
this.headers = {
|
|
45
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async checkSnapshotStatus(snapshotHash) {
|
|
50
|
+
const url = `${this.baseUrl}/sync/v1/snapshots`;
|
|
51
|
+
try {
|
|
52
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
53
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
54
|
+
const response = await (0, fetch_wrapper_1.default)(url, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: this.headers,
|
|
57
|
+
body: JSON.stringify({ snapshot_hash: snapshotHash }),
|
|
58
|
+
signal: controller.signal,
|
|
59
|
+
});
|
|
60
|
+
clearTimeout(timeoutId);
|
|
61
|
+
if (response.status === 404) {
|
|
62
|
+
return { status: 'NOT_FOUND' };
|
|
63
|
+
}
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
const errorText = await response.text();
|
|
66
|
+
throw new Error(`Failed to check snapshot with status ${response.status}: ${errorText}`);
|
|
67
|
+
}
|
|
68
|
+
const data = (await response.json());
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error.name === 'AbortError') {
|
|
73
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
74
|
+
}
|
|
75
|
+
console.error(`Request failed: ${error.message}`);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async createSnapshot(snapshotHash, files) {
|
|
80
|
+
const url = `${this.baseUrl}/sync/v1/snapshots`;
|
|
81
|
+
try {
|
|
82
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
83
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
84
|
+
const response = await (0, fetch_wrapper_1.default)(url, {
|
|
85
|
+
method: 'POST',
|
|
86
|
+
headers: this.headers,
|
|
87
|
+
body: JSON.stringify({
|
|
88
|
+
snapshot_hash: snapshotHash,
|
|
89
|
+
files: files,
|
|
90
|
+
}),
|
|
91
|
+
signal: controller.signal,
|
|
92
|
+
});
|
|
93
|
+
clearTimeout(timeoutId);
|
|
94
|
+
if (response.status === 422) {
|
|
95
|
+
const data = (await response.json());
|
|
96
|
+
console.info(`Snapshot ${snapshotHash.substring(0, 8)}... missing ${data.missing_files?.length || 0} files`);
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
const errorText = await response.text();
|
|
101
|
+
throw new Error(`Failed to create snapshot with status ${response.status}: ${errorText}`);
|
|
102
|
+
}
|
|
103
|
+
const data = (await response.json());
|
|
104
|
+
console.info(`Snapshot ${snapshotHash.substring(0, 8)}... status: ${data.status}`);
|
|
105
|
+
return data;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (error.name === 'AbortError') {
|
|
109
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
110
|
+
}
|
|
111
|
+
console.error(`Request failed: ${error.message}`);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async uploadFileContent(filesContent) {
|
|
116
|
+
const url = `${this.baseUrl}/sync/v1/files/content`;
|
|
117
|
+
try {
|
|
118
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
119
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
120
|
+
const formData = new fetch_wrapper_1.FormData();
|
|
121
|
+
for (const [fileHash, fileData] of filesContent.entries()) {
|
|
122
|
+
const content = typeof fileData.content === 'string'
|
|
123
|
+
? Buffer.from(fileData.content)
|
|
124
|
+
: fileData.content;
|
|
125
|
+
const blob = new Blob([content], { type: 'application/octet-stream' });
|
|
126
|
+
formData.append(fileHash, blob, fileData.path);
|
|
127
|
+
}
|
|
128
|
+
const uploadHeaders = { ...this.headers };
|
|
129
|
+
delete uploadHeaders['Content-Type'];
|
|
130
|
+
const response = await (0, fetch_wrapper_1.default)(url, {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: uploadHeaders,
|
|
133
|
+
body: formData,
|
|
134
|
+
signal: controller.signal,
|
|
135
|
+
});
|
|
136
|
+
clearTimeout(timeoutId);
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
const errorText = await response.text();
|
|
139
|
+
throw new Error(`Failed to upload files with status ${response.status}: ${errorText}`);
|
|
140
|
+
}
|
|
141
|
+
const data = (await response.json());
|
|
142
|
+
console.info(`Uploaded ${data.uploaded_count || 0} files, ${data.failed_count || 0} failed`);
|
|
143
|
+
return data;
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
if (error.name === 'AbortError') {
|
|
147
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
148
|
+
}
|
|
149
|
+
console.error(`Request failed: ${error.message}`);
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
static calculateFileHash(filePath, content) {
|
|
154
|
+
const contentBuffer = typeof content === 'string' ? Buffer.from(content) : content;
|
|
155
|
+
const fileData = Buffer.concat([
|
|
156
|
+
Buffer.from(`${filePath}\n`, 'utf-8'),
|
|
157
|
+
contentBuffer,
|
|
158
|
+
]);
|
|
159
|
+
return crypto.createHash('sha256').update(fileData).digest('hex');
|
|
160
|
+
}
|
|
161
|
+
static calculateSnapshotHash(fileHashes) {
|
|
162
|
+
const snapshotData = fileHashes.sort().join('\n');
|
|
163
|
+
return crypto
|
|
164
|
+
.createHash('sha256')
|
|
165
|
+
.update(snapshotData, 'utf-8')
|
|
166
|
+
.digest('hex');
|
|
167
|
+
}
|
|
168
|
+
async health() {
|
|
169
|
+
const url = `${this.baseUrl}/sync/v1/health`;
|
|
170
|
+
try {
|
|
171
|
+
const controller = new fetch_wrapper_1.AbortController();
|
|
172
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
173
|
+
const response = await (0, fetch_wrapper_1.default)(url, {
|
|
174
|
+
method: 'GET',
|
|
175
|
+
headers: { Authorization: `Bearer ${this.jwtToken}` },
|
|
176
|
+
signal: controller.signal,
|
|
177
|
+
});
|
|
178
|
+
clearTimeout(timeoutId);
|
|
179
|
+
if (!response.ok) {
|
|
180
|
+
const errorText = await response.text();
|
|
181
|
+
throw new Error(`Health check failed with status ${response.status}: ${errorText}`);
|
|
182
|
+
}
|
|
183
|
+
const data = (await response.json());
|
|
184
|
+
return data;
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
if (error.name === 'AbortError') {
|
|
188
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
189
|
+
}
|
|
190
|
+
console.error(`Request failed: ${error.message}`);
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
close() {
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.SyncHttpClient = SyncHttpClient;
|
|
198
|
+
//# sourceMappingURL=sync-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-client.js","sourceRoot":"","sources":["../../src/clients/sync-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,+CAAiC;AAEjC,wEAA0E;AAoC1E,MAAa,cAAc;IAYzB,YAAY,OAAe,EAAE,QAAgB,EAAE,UAAkB,KAAK;QACpE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG;YACb,aAAa,EAAE,UAAU,QAAQ,EAAE;YACnC,cAAc,EAAE,kBAAkB;SACnC,CAAC;IACJ,CAAC;IAQD,KAAK,CAAC,mBAAmB,CAAC,YAAoB;QAC5C,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,oBAAoB,CAAC;QAEhD,IAAI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QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CACnE,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmB,CAAC;YACvD,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,mBAAmB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAClD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAKD,KAAK;IAEL,CAAC;CACF;AAvQD,wCAuQC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AuthHttpClient, decodeJWT } from './clients/auth-client';
|
|
2
|
+
export { SyncHttpClient } from './clients/sync-client';
|
|
3
|
+
export { RetrievalHttpClient } from './clients/retrieval-client';
|
|
4
|
+
export { default as fetch } from './utils/fetch-wrapper';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetch = exports.RetrievalHttpClient = exports.SyncHttpClient = exports.decodeJWT = exports.AuthHttpClient = void 0;
|
|
7
|
+
var auth_client_1 = require("./clients/auth-client");
|
|
8
|
+
Object.defineProperty(exports, "AuthHttpClient", { enumerable: true, get: function () { return auth_client_1.AuthHttpClient; } });
|
|
9
|
+
Object.defineProperty(exports, "decodeJWT", { enumerable: true, get: function () { return auth_client_1.decodeJWT; } });
|
|
10
|
+
var sync_client_1 = require("./clients/sync-client");
|
|
11
|
+
Object.defineProperty(exports, "SyncHttpClient", { enumerable: true, get: function () { return sync_client_1.SyncHttpClient; } });
|
|
12
|
+
var retrieval_client_1 = require("./clients/retrieval-client");
|
|
13
|
+
Object.defineProperty(exports, "RetrievalHttpClient", { enumerable: true, get: function () { return retrieval_client_1.RetrievalHttpClient; } });
|
|
14
|
+
var fetch_wrapper_1 = require("./utils/fetch-wrapper");
|
|
15
|
+
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return __importDefault(fetch_wrapper_1).default; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAQA,qDAAkE;AAAzD,6GAAA,cAAc,OAAA;AAAE,wGAAA,SAAS,OAAA;AAClC,qDAAuD;AAA9C,6GAAA,cAAc,OAAA;AACvB,+DAAiE;AAAxD,uHAAA,mBAAmB,OAAA;AAG5B,uDAAyD;AAAhD,uHAAA,OAAO,OAAS"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AuthHttpClient, decodeJWT } from './clients/auth-client';
|
|
2
|
+
export { SyncHttpClient } from './clients/sync-client';
|
|
3
|
+
export { RetrievalHttpClient } from './clients/retrieval-client';
|
|
4
|
+
export { default as fetch } from './utils/fetch-wrapper';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const fetch: typeof globalThis.fetch;
|
|
2
|
+
export declare const Headers: typeof import("undici-types").Headers;
|
|
3
|
+
export declare const Request: typeof import("undici-types").Request;
|
|
4
|
+
export declare const Response: typeof import("undici-types").Response;
|
|
5
|
+
export declare const FormData: typeof import("undici-types").FormData;
|
|
6
|
+
export declare const AbortController: {
|
|
7
|
+
new (): AbortController;
|
|
8
|
+
prototype: AbortController;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=fetch-native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-native.d.ts","sourceRoot":"","sources":["../../src/polyfills/fetch-native.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,yBAAmB,CAAC;AACtC,eAAO,MAAM,OAAO,uCAAqB,CAAC;AAC1C,eAAO,MAAM,OAAO,uCAAqB,CAAC;AAC1C,eAAO,MAAM,QAAQ,wCAAsB,CAAC;AAC5C,eAAO,MAAM,QAAQ,wCAAsB,CAAC;AAC5C,eAAO,MAAM,eAAe;;;CAA6B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbortController = exports.FormData = exports.Response = exports.Request = exports.Headers = exports.fetch = void 0;
|
|
4
|
+
exports.fetch = globalThis.fetch;
|
|
5
|
+
exports.Headers = globalThis.Headers;
|
|
6
|
+
exports.Request = globalThis.Request;
|
|
7
|
+
exports.Response = globalThis.Response;
|
|
8
|
+
exports.FormData = globalThis.FormData;
|
|
9
|
+
exports.AbortController = globalThis.AbortController;
|
|
10
|
+
//# sourceMappingURL=fetch-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-native.js","sourceRoot":"","sources":["../../src/polyfills/fetch-native.ts"],"names":[],"mappings":";;;AAKa,QAAA,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;AACzB,QAAA,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;AAC7B,QAAA,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;AAC7B,QAAA,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;AAC/B,QAAA,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;AAC/B,QAAA,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const fetch: any;
|
|
2
|
+
export declare const Headers: any;
|
|
3
|
+
export declare const Request: any;
|
|
4
|
+
export declare const Response: any;
|
|
5
|
+
export declare const FormData: any;
|
|
6
|
+
export declare const AbortController: any;
|
|
7
|
+
//# sourceMappingURL=fetch-polyfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-polyfill.d.ts","sourceRoot":"","sources":["../../src/polyfills/fetch-polyfill.ts"],"names":[],"mappings":"AA2CA,eAAO,MAAM,KAAK,KAAY,CAAC;AAC/B,eAAO,MAAM,OAAO,KAAc,CAAC;AACnC,eAAO,MAAM,OAAO,KAAc,CAAC;AACnC,eAAO,MAAM,QAAQ,KAAe,CAAC;AACrC,eAAO,MAAM,QAAQ,KAAe,CAAC;AACrC,eAAO,MAAM,eAAe,KAAsB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbortController = exports.FormData = exports.Response = exports.Request = exports.Headers = exports.fetch = void 0;
|
|
4
|
+
let nodeFetch;
|
|
5
|
+
let NodeHeaders;
|
|
6
|
+
let NodeRequest;
|
|
7
|
+
let NodeResponse;
|
|
8
|
+
let NodeFormData;
|
|
9
|
+
let NodeAbortController;
|
|
10
|
+
try {
|
|
11
|
+
const module = require('node-fetch');
|
|
12
|
+
nodeFetch = module.default || module;
|
|
13
|
+
NodeHeaders = module.Headers;
|
|
14
|
+
NodeRequest = module.Request;
|
|
15
|
+
NodeResponse = module.Response;
|
|
16
|
+
try {
|
|
17
|
+
NodeFormData =
|
|
18
|
+
module.FormData || require('formdata-polyfill/esm.min.js').FormData;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
NodeFormData = class FormData {
|
|
22
|
+
constructor() {
|
|
23
|
+
throw new Error('FormData is not available. Install formdata-polyfill if needed.');
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
NodeAbortController = globalThis.AbortController || module.AbortController;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new Error('For Node.js < 18, please install node-fetch: npm install node-fetch@2');
|
|
31
|
+
}
|
|
32
|
+
exports.fetch = nodeFetch;
|
|
33
|
+
exports.Headers = NodeHeaders;
|
|
34
|
+
exports.Request = NodeRequest;
|
|
35
|
+
exports.Response = NodeResponse;
|
|
36
|
+
exports.FormData = NodeFormData;
|
|
37
|
+
exports.AbortController = NodeAbortController;
|
|
38
|
+
//# sourceMappingURL=fetch-polyfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-polyfill.js","sourceRoot":"","sources":["../../src/polyfills/fetch-polyfill.ts"],"names":[],"mappings":";;;AAKA,IAAI,SAAc,CAAC;AACnB,IAAI,WAAgB,CAAC;AACrB,IAAI,WAAgB,CAAC;AACrB,IAAI,YAAiB,CAAC;AACtB,IAAI,YAAiB,CAAC;AACtB,IAAI,mBAAwB,CAAC;AAE7B,IAAI,CAAC;IAEH,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC,SAAS,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC;IACrC,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC;IAG/B,IAAI,CAAC;QACH,YAAY;YAEV,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,8BAA8B,CAAC,CAAC,QAAQ,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,YAAY,GAAG,MAAM,QAAQ;YAC3B;gBACE,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;IAGD,mBAAmB,GAAG,UAAU,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC;AAC7E,CAAC;AAAC,MAAM,CAAC;IACP,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;AACJ,CAAC;AAEY,QAAA,KAAK,GAAG,SAAS,CAAC;AAClB,QAAA,OAAO,GAAG,WAAW,CAAC;AACtB,QAAA,OAAO,GAAG,WAAW,CAAC;AACtB,QAAA,QAAQ,GAAG,YAAY,CAAC;AACxB,QAAA,QAAQ,GAAG,YAAY,CAAC;AACxB,QAAA,eAAe,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const fetch: typeof globalThis.fetch;
|
|
2
|
+
export declare const Headers: typeof import("undici-types").Headers;
|
|
3
|
+
export declare const Request: typeof import("undici-types").Request;
|
|
4
|
+
export declare const Response: typeof import("undici-types").Response;
|
|
5
|
+
export declare const FormData: typeof import("undici-types").FormData;
|
|
6
|
+
export declare const AbortController: {
|
|
7
|
+
new (): AbortController;
|
|
8
|
+
prototype: AbortController;
|
|
9
|
+
};
|
|
10
|
+
export default fetch;
|
|
11
|
+
//# sourceMappingURL=fetch-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-wrapper.d.ts","sourceRoot":"","sources":["../../src/utils/fetch-wrapper.ts"],"names":[],"mappings":"AA4CA,eAAO,MAAM,KAAK,yBAAoB,CAAC;AACvC,eAAO,MAAM,OAAO,uCAAsB,CAAC;AAC3C,eAAO,MAAM,OAAO,uCAAsB,CAAC;AAC3C,eAAO,MAAM,QAAQ,wCAAuB,CAAC;AAC7C,eAAO,MAAM,QAAQ,wCAAuB,CAAC;AAC7C,eAAO,MAAM,eAAe;;;CAA8B,CAAC;AAG3D,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbortController = exports.FormData = exports.Response = exports.Request = exports.Headers = exports.fetch = void 0;
|
|
4
|
+
const hasNativeFetch = typeof globalThis.fetch !== 'undefined';
|
|
5
|
+
let fetchModule;
|
|
6
|
+
if (hasNativeFetch) {
|
|
7
|
+
fetchModule = {
|
|
8
|
+
fetch: globalThis.fetch,
|
|
9
|
+
Headers: globalThis.Headers,
|
|
10
|
+
Request: globalThis.Request,
|
|
11
|
+
Response: globalThis.Response,
|
|
12
|
+
FormData: globalThis.FormData,
|
|
13
|
+
AbortController: globalThis.AbortController,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
try {
|
|
18
|
+
fetchModule = require('../polyfills/fetch-polyfill');
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
throw new Error(`This library requires Node.js 18+ or the node-fetch package.\n` +
|
|
22
|
+
`Please either:\n` +
|
|
23
|
+
`1. Upgrade to Node.js 18 or later, or\n` +
|
|
24
|
+
`2. Install node-fetch: npm install node-fetch@2`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.fetch = fetchModule.fetch;
|
|
28
|
+
exports.Headers = fetchModule.Headers;
|
|
29
|
+
exports.Request = fetchModule.Request;
|
|
30
|
+
exports.Response = fetchModule.Response;
|
|
31
|
+
exports.FormData = fetchModule.FormData;
|
|
32
|
+
exports.AbortController = fetchModule.AbortController;
|
|
33
|
+
exports.default = exports.fetch;
|
|
34
|
+
//# sourceMappingURL=fetch-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-wrapper.js","sourceRoot":"","sources":["../../src/utils/fetch-wrapper.ts"],"names":[],"mappings":";;;AAKA,MAAM,cAAc,GAAG,OAAO,UAAU,CAAC,KAAK,KAAK,WAAW,CAAC;AAW/D,IAAI,WAAwB,CAAC;AAE7B,IAAI,cAAc,EAAE,CAAC;IAEnB,WAAW,GAAG;QACZ,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,eAAe,EAAE,UAAU,CAAC,eAAe;KAC5C,CAAC;AACJ,CAAC;KAAM,CAAC;IAEN,IAAI,CAAC;QAEH,WAAW,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,gEAAgE;YAC9D,kBAAkB;YAClB,yCAAyC;YACzC,iDAAiD,CACpD,CAAC;IACJ,CAAC;AACH,CAAC;AAGY,QAAA,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;AAC1B,QAAA,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;AAC9B,QAAA,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;AAC9B,QAAA,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;AAChC,QAAA,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;AAChC,QAAA,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC;AAG3D,kBAAe,aAAK,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coderule/clients",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript HTTP clients for core Coderule microservices (Auth, Sync, Retrieval)",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=14.0.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc && tsc --module esnext --outDir dist --declaration false --declarationMap false && mv dist/index.js dist/index.mjs",
|
|
23
|
+
"build:simple": "tsc",
|
|
24
|
+
"clean": "rm -rf dist",
|
|
25
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
26
|
+
"lint:fix": "eslint 'src/**/*.ts' --fix",
|
|
27
|
+
"format": "prettier --write 'src/**/*.ts'",
|
|
28
|
+
"format:check": "prettier --check 'src/**/*.ts'",
|
|
29
|
+
"prepublishOnly": "npm run lint && npm run format:check && npm run build",
|
|
30
|
+
"publish:npm": "npm run build && npm publish --access public",
|
|
31
|
+
"prepare": "npm run build:simple",
|
|
32
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"coderule",
|
|
36
|
+
"client",
|
|
37
|
+
"sdk",
|
|
38
|
+
"http",
|
|
39
|
+
"microservices",
|
|
40
|
+
"api"
|
|
41
|
+
],
|
|
42
|
+
"author": "n0isy2011@gmail.com",
|
|
43
|
+
"license": "ISC",
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^24.5.2",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
50
|
+
"@typescript-eslint/parser": "^8.44.0",
|
|
51
|
+
"eslint": "^9.36.0",
|
|
52
|
+
"eslint-config-prettier": "^10.1.8",
|
|
53
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
54
|
+
"eslint-plugin-import": "^2.32.0",
|
|
55
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
56
|
+
"prettier": "^3.6.2",
|
|
57
|
+
"typescript": "^5.9.2"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"node-fetch": "^2.6.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"node-fetch": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"files": [
|
|
68
|
+
"dist",
|
|
69
|
+
"README.md"
|
|
70
|
+
]
|
|
71
|
+
}
|