@calimero-network/mero-js 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.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +443 -0
  3. package/dist/admin-api/admin-client.d.ts +38 -0
  4. package/dist/admin-api/admin-client.d.ts.map +1 -0
  5. package/dist/admin-api/admin-client.js +104 -0
  6. package/dist/admin-api/admin-client.js.map +1 -0
  7. package/dist/admin-api/admin-factory.d.ts +8 -0
  8. package/dist/admin-api/admin-factory.d.ts.map +1 -0
  9. package/dist/admin-api/admin-factory.js +42 -0
  10. package/dist/admin-api/admin-factory.js.map +1 -0
  11. package/dist/admin-api/admin-types.d.ts +213 -0
  12. package/dist/admin-api/admin-types.d.ts.map +1 -0
  13. package/dist/admin-api/admin-types.js +3 -0
  14. package/dist/admin-api/admin-types.js.map +1 -0
  15. package/dist/admin-api/index.d.ts +4 -0
  16. package/dist/admin-api/index.d.ts.map +1 -0
  17. package/dist/admin-api/index.js +5 -0
  18. package/dist/admin-api/index.js.map +1 -0
  19. package/dist/auth-api/auth-client.d.ts +34 -0
  20. package/dist/auth-api/auth-client.d.ts.map +1 -0
  21. package/dist/auth-api/auth-client.js +112 -0
  22. package/dist/auth-api/auth-client.js.map +1 -0
  23. package/dist/auth-api/auth-factory.d.ts +8 -0
  24. package/dist/auth-api/auth-factory.d.ts.map +1 -0
  25. package/dist/auth-api/auth-factory.js +42 -0
  26. package/dist/auth-api/auth-factory.js.map +1 -0
  27. package/dist/auth-api/auth-types.d.ts +127 -0
  28. package/dist/auth-api/auth-types.d.ts.map +1 -0
  29. package/dist/auth-api/auth-types.js +3 -0
  30. package/dist/auth-api/auth-types.js.map +1 -0
  31. package/dist/auth-api/index.d.ts +4 -0
  32. package/dist/auth-api/index.d.ts.map +1 -0
  33. package/dist/auth-api/index.js +5 -0
  34. package/dist/auth-api/index.js.map +1 -0
  35. package/dist/http-client/api-response.d.ts +16 -0
  36. package/dist/http-client/api-response.d.ts.map +1 -0
  37. package/dist/http-client/api-response.js +2 -0
  38. package/dist/http-client/api-response.js.map +1 -0
  39. package/dist/http-client/http-factory.d.ts +32 -0
  40. package/dist/http-client/http-factory.d.ts.map +1 -0
  41. package/dist/http-client/http-factory.js +52 -0
  42. package/dist/http-client/http-factory.js.map +1 -0
  43. package/dist/http-client/http-types.d.ts +42 -0
  44. package/dist/http-client/http-types.d.ts.map +1 -0
  45. package/dist/http-client/http-types.js +2 -0
  46. package/dist/http-client/http-types.js.map +1 -0
  47. package/dist/http-client/index.d.ts +8 -0
  48. package/dist/http-client/index.d.ts.map +1 -0
  49. package/dist/http-client/index.js +12 -0
  50. package/dist/http-client/index.js.map +1 -0
  51. package/dist/http-client/retry.d.ts +6 -0
  52. package/dist/http-client/retry.d.ts.map +1 -0
  53. package/dist/http-client/retry.js +83 -0
  54. package/dist/http-client/retry.js.map +1 -0
  55. package/dist/http-client/signal-utils.d.ts +3 -0
  56. package/dist/http-client/signal-utils.d.ts.map +1 -0
  57. package/dist/http-client/signal-utils.js +42 -0
  58. package/dist/http-client/signal-utils.js.map +1 -0
  59. package/dist/http-client/web-client.d.ts +38 -0
  60. package/dist/http-client/web-client.d.ts.map +1 -0
  61. package/dist/http-client/web-client.js +296 -0
  62. package/dist/http-client/web-client.js.map +1 -0
  63. package/dist/index.browser.mjs +2 -0
  64. package/dist/index.browser.mjs.map +7 -0
  65. package/dist/index.cjs +995 -0
  66. package/dist/index.cjs.map +7 -0
  67. package/dist/index.d.ts +6 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +12 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/index.mjs +973 -0
  72. package/dist/index.mjs.map +7 -0
  73. package/dist/mero-js.d.ts +77 -0
  74. package/dist/mero-js.d.ts.map +1 -0
  75. package/dist/mero-js.js +175 -0
  76. package/dist/mero-js.js.map +1 -0
  77. package/dist/types/api-response.d.ts +16 -0
  78. package/dist/types/api-response.d.ts.map +1 -0
  79. package/dist/types/api-response.js +2 -0
  80. package/dist/types/api-response.js.map +1 -0
  81. package/dist/types/index.d.ts +2 -0
  82. package/dist/types/index.d.ts.map +1 -0
  83. package/dist/types/index.js +2 -0
  84. package/dist/types/index.js.map +1 -0
  85. package/package.json +86 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Calimero Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,443 @@
1
+ # Mero.js - Pure JavaScript SDK for Calimero
2
+
3
+ A lightweight, universal JavaScript SDK for Calimero that works in both browser and Node.js environments using Web Standards.
4
+
5
+ > **🚨 Breaking Change (v1.0.0)**: This version removes all legacy Axios-based code. The package now uses only Web Standards (`fetch`, `AbortController`) with zero external dependencies.
6
+
7
+ ## Features
8
+
9
+ - 🌐 **Web Standards First**: Built on `fetch`, `AbortController`, and other Web APIs
10
+ - 🔄 **Universal**: Works in browsers, Node.js, and edge runtimes
11
+ - 📦 **Zero Dependencies**: No external dependencies, uses native Web APIs
12
+ - 🔧 **Dependency Injection**: Flexible and testable architecture
13
+ - ⚡ **Modern**: ES2020+ with TypeScript support
14
+ - 🛡️ **Type Safe**: Full TypeScript definitions
15
+ - 🔄 **Smart Retry**: Distinguishes user aborts vs timeouts for intelligent retry logic
16
+ - 🎯 **Advanced Cancellation**: Signal combination and proper timeout handling
17
+
18
+ ## Behavior
19
+
20
+ ### Error Model (Throwing)
21
+
22
+ The client **throws** `HTTPError` on any `!response.ok` status. Network/timeout/abort errors are re-thrown as-is:
23
+
24
+ ```typescript
25
+ try {
26
+ const data = await httpClient.get('/api/data');
27
+ // Success - data is the parsed response
28
+ } catch (error) {
29
+ if (error instanceof HTTPError) {
30
+ console.log(`HTTP ${error.status}: ${error.statusText}`);
31
+ console.log('URL:', error.url);
32
+ console.log('Headers:', error.headers);
33
+ console.log('Body:', error.bodyText); // Up to 64KB
34
+ } else if (error.name === 'TimeoutError') {
35
+ // Request timed out
36
+ } else if (error.name === 'AbortError') {
37
+ // Request was cancelled
38
+ }
39
+ }
40
+ ```
41
+
42
+ ### Parsing Defaults & Override
43
+
44
+ Each method accepts optional `{ parse?: 'json'|'text'|'blob'|'arrayBuffer'|'response' }`:
45
+
46
+ **Default parsing rules:**
47
+
48
+ - `Content-Type: application/json` → parse as JSON
49
+ - `Content-Type: text/*` → parse as text
50
+ - Other types → parse as `arrayBuffer`
51
+
52
+ **Override:**
53
+
54
+ ```typescript
55
+ // Get raw Response object
56
+ const response = await httpClient.get('/api/data', { parse: 'response' });
57
+ ```
58
+
59
+ ### Retry Policy (`withRetry`)
60
+
61
+ The `withRetry` helper retries on:
62
+
63
+ - `HTTPError` with status `429` or `>= 500`
64
+ - `TimeoutError` (internal timeouts)
65
+ - `TypeError` (network failures)
66
+
67
+ **Never retries:**
68
+
69
+ - `AbortError` (user/caller aborts)
70
+
71
+ ```typescript
72
+ import { withRetry } from '@calimero-network/mero-js';
73
+
74
+ const data = await withRetry(
75
+ (attempt) => httpClient.get('/api/data'),
76
+ { attempts: 3 }, // Default: 3 attempts
77
+ );
78
+ ```
79
+
80
+ ### Signal Composition
81
+
82
+ The client combines caller signals with internal timeouts:
83
+
84
+ ```typescript
85
+ const userSignal = new AbortController().signal;
86
+ const data = await httpClient.get('/api/data', {
87
+ signal: userSignal,
88
+ timeoutMs: 5000,
89
+ });
90
+ ```
91
+
92
+ ### Header Precedence & Authorization
93
+
94
+ - **Caller headers win**: Request-level headers override client defaults
95
+ - **Authorization rules**: Only set `Authorization: Bearer ${token}` if caller didn't provide any `authorization` header (case-insensitive)
96
+
97
+ ### FormData Handling
98
+
99
+ For `FormData` bodies, the client does **not** set `content-type` (lets browser/undici add the boundary):
100
+
101
+ ```typescript
102
+ const formData = new FormData();
103
+ formData.append('file', file);
104
+ await httpClient.post('/api/upload', formData);
105
+ // No content-type header is set by the client
106
+ ```
107
+
108
+ ### Credentials
109
+
110
+ No implicit `same-origin` default. Credentials are only set if explicitly provided:
111
+
112
+ ```typescript
113
+ const client = createBrowserHttpClient({
114
+ baseUrl: 'https://api.example.com',
115
+ credentials: 'include', // Only if you want to include credentials
116
+ });
117
+ ```
118
+
119
+ ## Installation
120
+
121
+ ```bash
122
+ npm install @calimero-network/mero-js
123
+ ```
124
+
125
+ ## Quick Start
126
+
127
+ ### Browser Usage
128
+
129
+ ```typescript
130
+ import { createBrowserHttpClient } from '@calimero-network/mero-js';
131
+
132
+ const httpClient = createBrowserHttpClient({
133
+ baseUrl: 'https://api.calimero.network',
134
+ getAuthToken: async () => localStorage.getItem('access_token'),
135
+ onTokenRefresh: async (newToken) =>
136
+ localStorage.setItem('access_token', newToken),
137
+ });
138
+
139
+ // Make requests
140
+ try {
141
+ const data = await httpClient.get<{ message: string }>('/api/hello');
142
+ console.log(data.message);
143
+ } catch (error) {
144
+ console.error('Request failed:', error);
145
+ }
146
+ ```
147
+
148
+ ### Node.js Usage
149
+
150
+ ```typescript
151
+ import { createNodeHttpClient } from '@calimero-network/mero-js';
152
+ // For Node.js < 18, install undici: npm install undici
153
+ import { fetch as undiciFetch } from 'undici';
154
+
155
+ const httpClient = createNodeHttpClient({
156
+ baseUrl: 'https://api.calimero.network',
157
+ fetch: undiciFetch, // Required for Node.js < 18
158
+ getAuthToken: async () => process.env.ACCESS_TOKEN,
159
+ });
160
+
161
+ const data = await httpClient.get<{ message: string }>('/api/hello');
162
+ console.log(data.message);
163
+ ```
164
+
165
+ ### Universal Usage
166
+
167
+ ```typescript
168
+ import { createUniversalHttpClient } from '@calimero-network/mero-js';
169
+
170
+ const httpClient = createUniversalHttpClient({
171
+ baseUrl: 'https://api.calimero.network',
172
+ getAuthToken: async () => {
173
+ return typeof window !== 'undefined'
174
+ ? localStorage.getItem('access_token')
175
+ : process.env.ACCESS_TOKEN;
176
+ },
177
+ });
178
+ ```
179
+
180
+ ## API Reference
181
+
182
+ ### Factory Functions
183
+
184
+ #### `createBrowserHttpClient(options)`
185
+
186
+ Creates an HTTP client optimized for browser environments.
187
+
188
+ #### `createNodeHttpClient(options)`
189
+
190
+ Creates an HTTP client for Node.js environments.
191
+
192
+ #### `createUniversalHttpClient(options)`
193
+
194
+ Creates an HTTP client that works in both browser and Node.js.
195
+
196
+ ### Options
197
+
198
+ ```typescript
199
+ interface HttpClientOptions {
200
+ baseUrl: string; // Base URL for all requests
201
+ fetch?: typeof fetch; // Custom fetch implementation (Node.js)
202
+ getAuthToken?: () => Promise<string | undefined>; // Token getter
203
+ onTokenRefresh?: (token: string) => Promise<void>; // Token refresh callback
204
+ defaultHeaders?: Record<string, string>; // Default headers
205
+ timeoutMs?: number; // Request timeout (default: 30000)
206
+ credentials?: RequestCredentials; // CORS credentials (default: 'same-origin' for browser)
207
+ defaultAbortSignal?: AbortSignal; // Default abort signal for all requests
208
+ }
209
+ ```
210
+
211
+ ### HTTP Methods
212
+
213
+ ```typescript
214
+ // GET request
215
+ const response = await httpClient.get<T>('/api/endpoint', init?);
216
+
217
+ // POST request
218
+ const response = await httpClient.post<T>('/api/endpoint', body?, init?);
219
+
220
+ // PUT request
221
+ const response = await httpClient.put<T>('/api/endpoint', body?, init?);
222
+
223
+ // DELETE request
224
+ const response = await httpClient.delete<T>('/api/endpoint', init?);
225
+
226
+ // PATCH request
227
+ const response = await httpClient.patch<T>('/api/endpoint', body?, init?);
228
+
229
+ // HEAD request
230
+ const response = await httpClient.head<T>('/api/endpoint', init?);
231
+
232
+ // Generic request
233
+ const response = await httpClient.request<T>('/api/endpoint', init?);
234
+ ```
235
+
236
+ ### Request Options
237
+
238
+ ```typescript
239
+ interface RequestOptions extends RequestInit {
240
+ parse?: 'json' | 'text' | 'blob' | 'arrayBuffer' | 'response';
241
+ timeoutMs?: number;
242
+ }
243
+ ```
244
+
245
+ ### Response Format
246
+
247
+ All methods return the parsed data directly or throw errors:
248
+
249
+ ```typescript
250
+ // Success - returns parsed data
251
+ const data: T = await httpClient.get<T>('/api/data');
252
+
253
+ // Error - throws HTTPError or other errors
254
+ try {
255
+ const data = await httpClient.get('/api/data');
256
+ } catch (error) {
257
+ if (error instanceof HTTPError) {
258
+ console.log(`HTTP ${error.status}: ${error.statusText}`);
259
+ console.log('URL:', error.url);
260
+ console.log('Headers:', error.headers);
261
+ console.log('Body:', error.bodyText);
262
+ }
263
+ }
264
+ ```
265
+
266
+ ## Advanced Usage
267
+
268
+ ### Custom Transport
269
+
270
+ ```typescript
271
+ import { createHttpClient, Transport } from '@calimero-network/mero-js';
272
+
273
+ const transport: Transport = {
274
+ fetch: customFetch,
275
+ baseUrl: 'https://api.example.com',
276
+ getAuthToken: async () => 'your-token',
277
+ timeoutMs: 5000,
278
+ };
279
+
280
+ const httpClient = createHttpClient(transport);
281
+ ```
282
+
283
+ ### Error Handling
284
+
285
+ ```typescript
286
+ try {
287
+ const data = await httpClient.get('/api/data');
288
+ // Success - data is the parsed response
289
+ console.log(data);
290
+ } catch (error) {
291
+ if (error instanceof HTTPError) {
292
+ // HTTP error (4xx, 5xx)
293
+ console.error(`HTTP ${error.status}: ${error.statusText}`);
294
+ console.error('URL:', error.url);
295
+ console.error('Body:', error.bodyText);
296
+ } else if (error.name === 'TimeoutError') {
297
+ // Request timed out
298
+ console.error('Request timed out');
299
+ } else if (error.name === 'AbortError') {
300
+ // Request was cancelled
301
+ console.error('Request was cancelled');
302
+ } else {
303
+ // Network or other errors
304
+ console.error('Request failed:', error);
305
+ }
306
+ }
307
+ ```
308
+
309
+ ### Custom Headers
310
+
311
+ ```typescript
312
+ const data = await httpClient.post('/api/data', body, {
313
+ headers: {
314
+ 'Content-Type': 'application/json',
315
+ 'X-Custom-Header': 'value',
316
+ },
317
+ });
318
+ ```
319
+
320
+ ### Request Cancellation
321
+
322
+ ```typescript
323
+ const abortController = new AbortController();
324
+
325
+ // Cancel request after 5 seconds
326
+ setTimeout(() => abortController.abort(), 5000);
327
+
328
+ const data = await httpClient.get('/api/slow-endpoint', {
329
+ signal: abortController.signal,
330
+ });
331
+ ```
332
+
333
+ ### FormData Support
334
+
335
+ ```typescript
336
+ const formData = new FormData();
337
+ formData.append('file', fileInput.files[0]);
338
+ formData.append('name', 'John Doe');
339
+
340
+ const data = await httpClient.post('/api/upload', formData);
341
+ // Content-Type is set by the browser/undici with proper boundary
342
+ ```
343
+
344
+ ### Response Parsing
345
+
346
+ ```typescript
347
+ // Explicit parsing
348
+ const jsonData = await httpClient.get('/api/data', { parse: 'json' });
349
+ const textData = await httpClient.get('/api/text', { parse: 'text' });
350
+ const blobData = await httpClient.get('/api/file', { parse: 'blob' });
351
+
352
+ // Auto-detection based on Content-Type (default)
353
+ const autoData = await httpClient.get('/api/data');
354
+ ```
355
+
356
+ ### Retry with Exponential Backoff
357
+
358
+ ```typescript
359
+ import { withRetry } from '@calimero-network/mero-js';
360
+
361
+ const data = await withRetry(
362
+ (attempt) => httpClient.get('/api/unreliable-endpoint'),
363
+ { attempts: 3 }, // Default: 3 attempts
364
+ );
365
+ ```
366
+
367
+ ### Signal Combination
368
+
369
+ ```typescript
370
+ import { combineSignals, createTimeoutSignal } from '@calimero-network/mero-js';
371
+
372
+ // Combine multiple abort signals
373
+ const userSignal = new AbortController().signal;
374
+ const timeoutSignal = createTimeoutSignal(5000);
375
+ const combinedSignal = combineSignals([userSignal, timeoutSignal]);
376
+
377
+ const data = await httpClient.get('/api/endpoint', {
378
+ signal: combinedSignal,
379
+ });
380
+ ```
381
+
382
+ ### CORS and Credentials
383
+
384
+ ```typescript
385
+ const httpClient = createBrowserHttpClient({
386
+ baseUrl: 'https://api.example.com',
387
+ credentials: 'include', // Include cookies in CORS requests
388
+ });
389
+
390
+ // For APIs that require credentials
391
+ const data = await httpClient.get('/api/protected', {
392
+ credentials: 'include',
393
+ });
394
+ ```
395
+
396
+ ## Migration from Axios
397
+
398
+ If you're migrating from an Axios-based client:
399
+
400
+ 1. **Replace imports**: Use the factory functions instead of direct class instantiation
401
+ 2. **Update method signatures**: Methods now use `RequestInit` instead of custom options
402
+ 3. **Handle responses**: Methods now return parsed data directly or throw errors (no more `ResponseData<T>`)
403
+ 4. **Token management**: Use the `getAuthToken` and `onTokenRefresh` callbacks
404
+
405
+ ## Browser Support
406
+
407
+ - Modern browsers with `fetch` support (Chrome 42+, Firefox 39+, Safari 10.1+)
408
+ - Node.js 18+ (native fetch) or Node.js 16+ with `undici`
409
+
410
+ ## Bundle Sizes
411
+
412
+ - **ESM**: ~9.4kb (gzipped: ~3.2kb)
413
+ - **CJS**: ~10.5kb (gzipped: ~3.6kb)
414
+
415
+ ## Examples
416
+
417
+ See the `examples/` directory for complete usage examples:
418
+
419
+ - `browser-example.ts` - Browser-specific usage (designed for browser environments)
420
+ - `node-example.ts` - Node.js-specific usage (designed for Node.js environments)
421
+ - `universal-example.ts` - Universal usage (works in both browser and Node.js)
422
+
423
+ **Note**: Run `npm run build` before running the examples, as they import from the built library.
424
+
425
+ ## Development
426
+
427
+ ```bash
428
+ # Install dependencies
429
+ pnpm install
430
+
431
+ # Build
432
+ pnpm build
433
+
434
+ # Test
435
+ pnpm test
436
+
437
+ # Lint
438
+ pnpm lint
439
+ ```
440
+
441
+ ## License
442
+
443
+ MIT
@@ -0,0 +1,38 @@
1
+ import { HttpClient } from '../http-client';
2
+ import { HealthStatus, AdminAuthStatus, InstallApplicationRequest, InstallDevApplicationRequest, InstallApplicationResponse, UninstallApplicationResponse, ListApplicationsResponse, GetApplicationResponse, CreateContextRequest, CreateContextResponse, DeleteContextResponse, ListContextsResponse, GetContextResponse, UploadBlobRequest, UploadBlobResponse, DeleteBlobResponse, ListBlobsResponse, GetBlobResponse, CreateAliasRequest, CreateAliasResponse, DeleteAliasResponse, ListAliasesResponse, GetAliasResponse, GetNetworkPeersResponse, GetNetworkStatsResponse, GetNetworkConfigResponse, UpdateNetworkConfigRequest, UpdateNetworkConfigResponse, GetSystemInfoResponse, GetSystemLogsResponse, GetSystemMetricsResponse, RestartSystemResponse, ShutdownSystemResponse } from './admin-types';
3
+ export declare class AdminApiClient {
4
+ private httpClient;
5
+ constructor(httpClient: HttpClient);
6
+ healthCheck(): Promise<HealthStatus>;
7
+ isAuthed(): Promise<AdminAuthStatus>;
8
+ installApplication(request: InstallApplicationRequest): Promise<InstallApplicationResponse>;
9
+ installDevApplication(request: InstallDevApplicationRequest): Promise<InstallApplicationResponse>;
10
+ uninstallApplication(appId: string): Promise<UninstallApplicationResponse>;
11
+ listApplications(): Promise<ListApplicationsResponse>;
12
+ getApplication(appId: string): Promise<GetApplicationResponse>;
13
+ createContext(request: CreateContextRequest): Promise<CreateContextResponse>;
14
+ deleteContext(contextId: string): Promise<DeleteContextResponse>;
15
+ getContexts(): Promise<ListContextsResponse>;
16
+ getContext(contextId: string): Promise<GetContextResponse>;
17
+ uploadBlob(request: UploadBlobRequest): Promise<UploadBlobResponse>;
18
+ deleteBlob(blobId: string): Promise<DeleteBlobResponse>;
19
+ listBlobs(): Promise<ListBlobsResponse>;
20
+ getBlob(blobId: string): Promise<GetBlobResponse>;
21
+ createAlias(request: CreateAliasRequest): Promise<CreateAliasResponse>;
22
+ deleteAlias(aliasId: string): Promise<DeleteAliasResponse>;
23
+ listAliases(): Promise<ListAliasesResponse>;
24
+ getAlias(aliasId: string): Promise<GetAliasResponse>;
25
+ getNetworkPeers(): Promise<GetNetworkPeersResponse>;
26
+ getNetworkStats(): Promise<GetNetworkStatsResponse>;
27
+ getNetworkConfig(): Promise<GetNetworkConfigResponse>;
28
+ updateNetworkConfig(request: UpdateNetworkConfigRequest): Promise<UpdateNetworkConfigResponse>;
29
+ getPeersCount(): Promise<{
30
+ count: number;
31
+ }>;
32
+ getSystemInfo(): Promise<GetSystemInfoResponse>;
33
+ getSystemLogs(): Promise<GetSystemLogsResponse>;
34
+ getSystemMetrics(): Promise<GetSystemMetricsResponse>;
35
+ restartSystem(): Promise<RestartSystemResponse>;
36
+ shutdownSystem(): Promise<ShutdownSystemResponse>;
37
+ }
38
+ //# sourceMappingURL=admin-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-client.d.ts","sourceRoot":"","sources":["../../src/admin-api/admin-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAIL,YAAY,EACZ,eAAe,EAGf,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EAGtB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAGlB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EAGf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAGhB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAG3B,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,eAAe,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MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAKpD,eAAe,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAInD,eAAe,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAInD,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAIrD,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,2BAA2B,CAAC;IAOjC,aAAa,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAK3C,aAAa,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAI/C,aAAa,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAI/C,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAIrD,aAAa,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAI/C,cAAc,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAGxD"}
@@ -0,0 +1,104 @@
1
+ export class AdminApiClient {
2
+ constructor(httpClient) {
3
+ this.httpClient = httpClient;
4
+ }
5
+ // Health and Status Endpoints
6
+ async healthCheck() {
7
+ const response = await this.httpClient.get('/health');
8
+ if (!response.data) {
9
+ throw new Error('Health response data is null');
10
+ }
11
+ return response.data;
12
+ }
13
+ async isAuthed() {
14
+ return this.httpClient.get('/is-authed');
15
+ }
16
+ // Application Management Endpoints
17
+ async installApplication(request) {
18
+ return this.httpClient.post('/install-application', request);
19
+ }
20
+ async installDevApplication(request) {
21
+ return this.httpClient.post('/install-dev-application', request);
22
+ }
23
+ async uninstallApplication(appId) {
24
+ return this.httpClient.delete(`/applications/${appId}`);
25
+ }
26
+ async listApplications() {
27
+ return this.httpClient.get('/applications');
28
+ }
29
+ async getApplication(appId) {
30
+ return this.httpClient.get(`/applications/${appId}`);
31
+ }
32
+ // Context Management Endpoints
33
+ async createContext(request) {
34
+ return this.httpClient.post('/contexts', request);
35
+ }
36
+ async deleteContext(contextId) {
37
+ return this.httpClient.delete(`/contexts/${contextId}`);
38
+ }
39
+ async getContexts() {
40
+ return this.httpClient.get('/contexts');
41
+ }
42
+ async getContext(contextId) {
43
+ return this.httpClient.get(`/contexts/${contextId}`);
44
+ }
45
+ // Blob Management Endpoints
46
+ async uploadBlob(request) {
47
+ return this.httpClient.post('/blobs', request);
48
+ }
49
+ async deleteBlob(blobId) {
50
+ return this.httpClient.delete(`/blobs/${blobId}`);
51
+ }
52
+ async listBlobs() {
53
+ return this.httpClient.get('/blobs');
54
+ }
55
+ async getBlob(blobId) {
56
+ return this.httpClient.get(`/blobs/${blobId}`);
57
+ }
58
+ // Alias Management Endpoints
59
+ async createAlias(request) {
60
+ return this.httpClient.post('/alias', request);
61
+ }
62
+ async deleteAlias(aliasId) {
63
+ return this.httpClient.delete(`/alias/${aliasId}`);
64
+ }
65
+ async listAliases() {
66
+ return this.httpClient.get('/alias');
67
+ }
68
+ async getAlias(aliasId) {
69
+ return this.httpClient.get(`/alias/${aliasId}`);
70
+ }
71
+ // Network Management Endpoints
72
+ async getNetworkPeers() {
73
+ return this.httpClient.get('/network/peers');
74
+ }
75
+ async getNetworkStats() {
76
+ return this.httpClient.get('/network/stats');
77
+ }
78
+ async getNetworkConfig() {
79
+ return this.httpClient.get('/network/config');
80
+ }
81
+ async updateNetworkConfig(request) {
82
+ return this.httpClient.put('/network/config', request);
83
+ }
84
+ async getPeersCount() {
85
+ return this.httpClient.get('/network/peers/count');
86
+ }
87
+ // System Management Endpoints
88
+ async getSystemInfo() {
89
+ return this.httpClient.get('/system/info');
90
+ }
91
+ async getSystemLogs() {
92
+ return this.httpClient.get('/system/logs');
93
+ }
94
+ async getSystemMetrics() {
95
+ return this.httpClient.get('/system/metrics');
96
+ }
97
+ async restartSystem() {
98
+ return this.httpClient.post('/system/restart');
99
+ }
100
+ async shutdownSystem() {
101
+ return this.httpClient.post('/system/shutdown');
102
+ }
103
+ }
104
+ //# sourceMappingURL=admin-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-client.js","sourceRoot":"","s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AAI,CAAC,UAAU,CAAC,IAAI,CAAyB,kBAAkB,CAAC,CAAC;IAC1E,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import { AdminApiClient } from './admin-client';
2
+ import { AdminApiClientConfig } from './admin-types';
3
+ import { HttpClient } from '../http-client';
4
+ export declare function createBrowserAdminApiClient(_config: AdminApiClientConfig): AdminApiClient;
5
+ export declare function createNodeAdminApiClient(_config: AdminApiClientConfig): AdminApiClient;
6
+ export declare function createAdminApiClient(_config: AdminApiClientConfig): AdminApiClient;
7
+ export declare function createAdminApiClientFromHttpClient(httpClient: HttpClient, _config: AdminApiClientConfig): AdminApiClient;
8
+ //# sourceMappingURL=admin-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-factory.d.ts","sourceRoot":"","sources":["../../src/admin-api/admin-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA0C5C,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,GAC5B,cAAc,CAGhB;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,oBAAoB,GAC5B,cAAc,CAGhB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,oBAAoB,GAC5B,cAAc,CAGhB;AAED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,oBAAoB,GAC5B,cAAc,CAEhB"}
@@ -0,0 +1,42 @@
1
+ import { AdminApiClient } from './admin-client';
2
+ // Mock HTTP client for testing
3
+ class MockHttpClient {
4
+ async get() {
5
+ throw new Error('HTTP client not implemented - use createAdminApiClientFromHttpClient with a real HTTP client');
6
+ }
7
+ async post() {
8
+ throw new Error('HTTP client not implemented - use createAdminApiClientFromHttpClient with a real HTTP client');
9
+ }
10
+ async put() {
11
+ throw new Error('HTTP client not implemented - use createAdminApiClientFromHttpClient with a real HTTP client');
12
+ }
13
+ async delete() {
14
+ throw new Error('HTTP client not implemented - use createAdminApiClientFromHttpClient with a real HTTP client');
15
+ }
16
+ async patch() {
17
+ throw new Error('HTTP client not implemented - use createAdminApiClientFromHttpClient with a real HTTP client');
18
+ }
19
+ async head() {
20
+ throw new Error('HTTP client not implemented - use createAdminApiClientFromHttpClient with a real HTTP client');
21
+ }
22
+ async request() {
23
+ throw new Error('HTTP client not implemented - use createAdminApiClientFromHttpClient with a real HTTP client');
24
+ }
25
+ }
26
+ // Factory functions for creating Admin API clients
27
+ export function createBrowserAdminApiClient(_config) {
28
+ const httpClient = new MockHttpClient();
29
+ return new AdminApiClient(httpClient);
30
+ }
31
+ export function createNodeAdminApiClient(_config) {
32
+ const httpClient = new MockHttpClient();
33
+ return new AdminApiClient(httpClient);
34
+ }
35
+ export function createAdminApiClient(_config) {
36
+ const httpClient = new MockHttpClient();
37
+ return new AdminApiClient(httpClient);
38
+ }
39
+ export function createAdminApiClientFromHttpClient(httpClient, _config) {
40
+ return new AdminApiClient(httpClient);
41
+ }
42
+ //# sourceMappingURL=admin-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-factory.js","sourceRoot":"","sources":["../../src/admin-api/admin-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIhD,+BAA+B;AAC/B,MAAM,cAAc;IAClB,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F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