@iteradian-rpc/sdk 1.0.1

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/dist/index.mjs ADDED
@@ -0,0 +1,770 @@
1
+ // src/http.ts
2
+ var IteradianError = class extends Error {
3
+ constructor(message, statusCode, error, rpc) {
4
+ super(message);
5
+ this.name = "IteradianError";
6
+ this.statusCode = statusCode;
7
+ this.error = error;
8
+ this.rpcCode = rpc?.code;
9
+ this.retryAfter = rpc?.retryAfter;
10
+ this.data = rpc?.data;
11
+ }
12
+ /** True when the request failed because the subscription is out of allowance. */
13
+ get isQuotaExhausted() {
14
+ return this.rpcCode === -32006 || this.rpcCode === -32007;
15
+ }
16
+ /** True when the request was throttled and is worth retrying. */
17
+ get isRateLimited() {
18
+ return this.rpcCode === -32005;
19
+ }
20
+ };
21
+ var NON_IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
22
+ "eth_sendRawTransaction",
23
+ "eth_sendTransaction",
24
+ "eth_submitWork",
25
+ "author_submitExtrinsic",
26
+ "author_submitAndWatchExtrinsic",
27
+ "sendTransaction",
28
+ "requestAirdrop",
29
+ "broadcast_tx_sync",
30
+ "broadcast_tx_async",
31
+ "broadcast_tx_commit"
32
+ ]);
33
+ var MAX_RETRY_DELAY_MS = 3e4;
34
+ function isReplayableBody(body) {
35
+ const one = (r) => {
36
+ const method = r?.method;
37
+ return typeof method === "string" && NON_IDEMPOTENT_METHODS.has(method);
38
+ };
39
+ if (Array.isArray(body)) return !body.some(one);
40
+ if (body && typeof body === "object") return !one(body);
41
+ return true;
42
+ }
43
+ var HttpClient = class {
44
+ constructor(config) {
45
+ this.baseUrl = (config.baseUrl || "https://api.iteradian.com/api/v1").replace(/\/$/, "");
46
+ this.gatewayUrl = (config.gatewayUrl || "https://rpc.iteradian.com").replace(/\/$/, "");
47
+ this.accessToken = config.accessToken;
48
+ this.apiKey = config.apiKey;
49
+ this.timeout = config.timeout || 3e4;
50
+ this.customHeaders = config.headers || {};
51
+ this.retry = config.retry !== false;
52
+ this.maxRetries = config.maxRetries || 3;
53
+ }
54
+ setAccessToken(token) {
55
+ this.accessToken = token;
56
+ }
57
+ clearAccessToken() {
58
+ this.accessToken = void 0;
59
+ }
60
+ buildHeaders() {
61
+ const headers = {
62
+ "Content-Type": "application/json",
63
+ Accept: "application/json",
64
+ ...this.customHeaders
65
+ };
66
+ if (this.accessToken) {
67
+ headers["Authorization"] = `Bearer ${this.accessToken}`;
68
+ }
69
+ if (this.apiKey) {
70
+ headers["X-API-Key"] = this.apiKey;
71
+ }
72
+ return headers;
73
+ }
74
+ async request(method, path, body, attempt = 1, base, signal) {
75
+ const url = `${base ?? this.baseUrl}${path}`;
76
+ const controller = new AbortController();
77
+ const timer = setTimeout(() => controller.abort(), this.timeout);
78
+ const onAbort = () => controller.abort();
79
+ signal?.addEventListener("abort", onAbort, { once: true });
80
+ if (signal?.aborted) controller.abort();
81
+ try {
82
+ const response = await fetch(url, {
83
+ method,
84
+ headers: this.buildHeaders(),
85
+ body: body != null ? JSON.stringify(body) : void 0,
86
+ signal: controller.signal,
87
+ // Neither host redirects. Following one would hand `X-API-Key` to
88
+ // whatever origin the redirect names: Node's fetch strips
89
+ // `Authorization` across origins but keeps custom headers.
90
+ redirect: "manual"
91
+ });
92
+ if (response.status >= 300 && response.status < 400) {
93
+ clearTimeout(timer);
94
+ throw new IteradianError(
95
+ `Unexpected redirect (${response.status}) from ${url}. The Iteradian API does not redirect; refusing to resend credentials to another origin.`,
96
+ response.status,
97
+ "UNEXPECTED_REDIRECT"
98
+ );
99
+ }
100
+ clearTimeout(timer);
101
+ if (!response.ok) {
102
+ let errorBody;
103
+ try {
104
+ errorBody = await response.json();
105
+ } catch {
106
+ errorBody = {
107
+ message: response.statusText || "Unknown error",
108
+ statusCode: response.status
109
+ };
110
+ }
111
+ const rpc = errorBody?.error;
112
+ const rpcCode = typeof rpc?.code === "number" ? rpc.code : void 0;
113
+ const retryAfter = typeof rpc?.data?.retryAfter === "number" ? rpc.data.retryAfter : void 0;
114
+ const worthRetrying = response.status >= 500 || response.status === 429 && rpcCode !== -32006 && rpcCode !== -32007;
115
+ if (this.retry && attempt < this.maxRetries && worthRetrying && isReplayableBody(body) && !controller.signal.aborted) {
116
+ const backoff = Math.min(1e3 * 2 ** (attempt - 1), 1e4);
117
+ const delay = Math.min(
118
+ retryAfter != null ? retryAfter * 1e3 : backoff,
119
+ MAX_RETRY_DELAY_MS
120
+ );
121
+ await new Promise((r) => setTimeout(r, delay));
122
+ return this.request(method, path, body, attempt + 1, base, signal);
123
+ }
124
+ throw new IteradianError(
125
+ rpc?.message || errorBody.message || response.statusText,
126
+ errorBody.statusCode || response.status,
127
+ errorBody.error,
128
+ { code: rpcCode, retryAfter, data: rpc?.data }
129
+ );
130
+ }
131
+ if (response.status === 204 || response.status === 205) {
132
+ return void 0;
133
+ }
134
+ const text = await response.text();
135
+ if (text === "") {
136
+ throw new IteradianError(
137
+ `Empty response body from ${method} ${path}`,
138
+ response.status,
139
+ "EMPTY_RESPONSE"
140
+ );
141
+ }
142
+ try {
143
+ return JSON.parse(text);
144
+ } catch (err) {
145
+ throw new IteradianError(
146
+ `Could not decode the response body: ${err.message}`,
147
+ response.status,
148
+ "DECODE_ERROR"
149
+ );
150
+ }
151
+ } catch (err) {
152
+ clearTimeout(timer);
153
+ if (err instanceof IteradianError) throw err;
154
+ if (err.name === "AbortError") {
155
+ if (signal?.aborted) {
156
+ throw new IteradianError("Request cancelled", 0, "CANCELLED");
157
+ }
158
+ throw new IteradianError("Request timed out", 408, "TIMEOUT");
159
+ }
160
+ throw new IteradianError(err.message, 0, "NETWORK_ERROR");
161
+ } finally {
162
+ clearTimeout(timer);
163
+ signal?.removeEventListener("abort", onAbort);
164
+ }
165
+ }
166
+ get(path) {
167
+ return this.request("GET", path);
168
+ }
169
+ post(path, body) {
170
+ return this.request("POST", path, body);
171
+ }
172
+ put(path, body) {
173
+ return this.request("PUT", path, body);
174
+ }
175
+ patch(path, body) {
176
+ return this.request("PATCH", path, body);
177
+ }
178
+ /**
179
+ * Call the RPC gateway rather than the control plane.
180
+ *
181
+ * Separate base URL because the gateway is not under `/api/v1`: it serves
182
+ * `POST /rpc/v1/{network}` at the host root.
183
+ */
184
+ gateway(path, body, signal) {
185
+ return this.request("POST", path, body, 1, this.gatewayUrl, signal);
186
+ }
187
+ gatewayGet(path, signal) {
188
+ return this.request("GET", path, void 0, 1, this.gatewayUrl, signal);
189
+ }
190
+ delete(path, body) {
191
+ return this.request("DELETE", path, body);
192
+ }
193
+ };
194
+
195
+ // src/resources/auth.ts
196
+ var AuthResource = class {
197
+ constructor(http) {
198
+ this.http = http;
199
+ }
200
+ /** Register a new user account */
201
+ register(data) {
202
+ return this.http.post("/auth/register", data);
203
+ }
204
+ /** Login with email/password (optionally with 2FA code) */
205
+ async login(data) {
206
+ const tokens = await this.http.post("/auth/login", data);
207
+ this.http.setAccessToken(tokens.accessToken);
208
+ return tokens;
209
+ }
210
+ /** Logout current session */
211
+ logout() {
212
+ return this.http.post("/auth/logout");
213
+ }
214
+ /** Refresh the access token */
215
+ async refresh(refreshToken) {
216
+ const tokens = await this.http.post("/auth/refresh", {
217
+ refreshToken
218
+ });
219
+ this.http.setAccessToken(tokens.accessToken);
220
+ return tokens;
221
+ }
222
+ /** Verify email with token */
223
+ verifyEmail(token) {
224
+ return this.http.post("/auth/verify-email", { token });
225
+ }
226
+ /** Resend email verification */
227
+ resendVerification(email) {
228
+ return this.http.post("/auth/resend-verification", { email });
229
+ }
230
+ /** Request password reset email */
231
+ forgotPassword(email) {
232
+ return this.http.post("/auth/forgot-password", { email });
233
+ }
234
+ /** Reset password with token */
235
+ resetPassword(token, newPassword) {
236
+ return this.http.post("/auth/reset-password", { token, newPassword });
237
+ }
238
+ /** Request a magic login link */
239
+ requestMagicLink(email) {
240
+ return this.http.post("/auth/magic-link", { email });
241
+ }
242
+ /** Login via magic link token */
243
+ async loginWithMagicLink(token) {
244
+ const tokens = await this.http.post("/auth/magic-login", {
245
+ token
246
+ });
247
+ this.http.setAccessToken(tokens.accessToken);
248
+ return tokens;
249
+ }
250
+ /** Enable 2FA – returns QR code image and secret */
251
+ enable2FA(password) {
252
+ return this.http.post("/auth/2fa/enable", { password });
253
+ }
254
+ /** Verify 2FA setup with code from authenticator app */
255
+ verify2FA(code) {
256
+ return this.http.post("/auth/2fa/verify", { code });
257
+ }
258
+ /** Disable 2FA */
259
+ disable2FA(password, code) {
260
+ return this.http.post("/auth/2fa/disable", { password, code });
261
+ }
262
+ /** Regenerate backup codes */
263
+ regenerateBackupCodes(password) {
264
+ return this.http.post("/auth/2fa/backup-codes", { password });
265
+ }
266
+ };
267
+
268
+ // src/resources/organizations.ts
269
+ var OrganizationsResource = class {
270
+ constructor(http) {
271
+ this.http = http;
272
+ }
273
+ /** List organizations the current user belongs to */
274
+ list() {
275
+ return this.http.get("/orgs");
276
+ }
277
+ /** Create a new organization */
278
+ create(data) {
279
+ return this.http.post("/orgs", data);
280
+ }
281
+ /** Get organization details */
282
+ get(orgId) {
283
+ return this.http.get(`/orgs/${orgId}`);
284
+ }
285
+ /** Update an organization */
286
+ update(orgId, data) {
287
+ return this.http.put(`/orgs/${orgId}`, data);
288
+ }
289
+ /** Delete an organization */
290
+ delete(orgId) {
291
+ return this.http.delete(`/orgs/${orgId}`);
292
+ }
293
+ /** Leave an organization */
294
+ leave(orgId) {
295
+ return this.http.post(`/orgs/${orgId}/leave`);
296
+ }
297
+ /** List organization members */
298
+ listMembers(orgId) {
299
+ return this.http.get(`/orgs/${orgId}/members`);
300
+ }
301
+ /** Invite a member to the organization */
302
+ inviteMember(orgId, data) {
303
+ return this.http.post(`/orgs/${orgId}/members`, data);
304
+ }
305
+ /** Update a member's role */
306
+ updateMemberRole(orgId, memberId, role) {
307
+ return this.http.put(`/orgs/${orgId}/members/${memberId}`, { role });
308
+ }
309
+ /** Remove a member from the organization */
310
+ removeMember(orgId, memberId) {
311
+ return this.http.delete(`/orgs/${orgId}/members/${memberId}`);
312
+ }
313
+ /** Get current user's permissions in the organization */
314
+ getMyPermissions(orgId) {
315
+ return this.http.get(`/orgs/${orgId}/permissions`);
316
+ }
317
+ };
318
+
319
+ // src/resources/api-keys.ts
320
+ var ApiKeysResource = class {
321
+ constructor(http) {
322
+ this.http = http;
323
+ }
324
+ /** List all API keys for an organization */
325
+ list(orgId) {
326
+ return this.http.get(`/orgs/${orgId}/keys`);
327
+ }
328
+ /** Get a specific API key */
329
+ get(orgId, keyId) {
330
+ return this.http.get(`/orgs/${orgId}/keys/${keyId}`);
331
+ }
332
+ /** Create a new API key (returns the full key only once) */
333
+ create(orgId, data) {
334
+ return this.http.post(`/orgs/${orgId}/keys`, data);
335
+ }
336
+ /** Update an API key */
337
+ update(orgId, keyId, data) {
338
+ return this.http.put(`/orgs/${orgId}/keys/${keyId}`, data);
339
+ }
340
+ /** Revoke (delete) an API key */
341
+ revoke(orgId, keyId) {
342
+ return this.http.delete(`/orgs/${orgId}/keys/${keyId}`);
343
+ }
344
+ /** Rotate an API key (revoke old, create new) */
345
+ rotate(orgId, keyId) {
346
+ return this.http.post(`/orgs/${orgId}/keys/${keyId}/rotate`);
347
+ }
348
+ /** Get analytics for an API key */
349
+ getAnalytics(orgId, keyId, timeRange = "7d") {
350
+ return this.http.get(
351
+ `/orgs/${orgId}/keys/${keyId}/analytics?timeRange=${timeRange}`
352
+ );
353
+ }
354
+ };
355
+
356
+ // src/resources/endpoints.ts
357
+ var EndpointsResource = class {
358
+ constructor(http) {
359
+ this.http = http;
360
+ }
361
+ // ==================== Networks ====================
362
+ /** List all available networks */
363
+ getNetworks() {
364
+ return this.http.get("/networks");
365
+ }
366
+ /** Get a specific network */
367
+ getNetwork(networkId) {
368
+ return this.http.get(`/networks/${networkId}`);
369
+ }
370
+ // ==================== Endpoints CRUD ====================
371
+ /** List all endpoints for an organization */
372
+ list(orgId) {
373
+ return this.http.get(`/orgs/${orgId}/endpoints`);
374
+ }
375
+ /** Get a specific endpoint */
376
+ get(orgId, endpointId) {
377
+ return this.http.get(`/orgs/${orgId}/endpoints/${endpointId}`);
378
+ }
379
+ /** Create a new endpoint */
380
+ create(orgId, data) {
381
+ return this.http.post(`/orgs/${orgId}/endpoints`, data);
382
+ }
383
+ /** Update an endpoint */
384
+ update(orgId, endpointId, data) {
385
+ return this.http.put(`/orgs/${orgId}/endpoints/${endpointId}`, data);
386
+ }
387
+ /** Delete an endpoint */
388
+ delete(orgId, endpointId) {
389
+ return this.http.delete(`/orgs/${orgId}/endpoints/${endpointId}`);
390
+ }
391
+ // ==================== Status Management ====================
392
+ /** Pause an endpoint */
393
+ pause(orgId, endpointId) {
394
+ return this.http.post(`/orgs/${orgId}/endpoints/${endpointId}/pause`);
395
+ }
396
+ /** Resume an endpoint */
397
+ resume(orgId, endpointId) {
398
+ return this.http.post(`/orgs/${orgId}/endpoints/${endpointId}/resume`);
399
+ }
400
+ // ==================== Health & Metrics ====================
401
+ /** Trigger a health check */
402
+ checkHealth(orgId, endpointId) {
403
+ return this.http.post(
404
+ `/orgs/${orgId}/endpoints/${endpointId}/health-check`
405
+ );
406
+ }
407
+ /** Get endpoint health summary */
408
+ getHealthOverview(orgId) {
409
+ return this.http.get(`/orgs/${orgId}/endpoints/summary`);
410
+ }
411
+ /** Get endpoint metrics */
412
+ getMetrics(orgId, endpointId, from, to) {
413
+ const params = new URLSearchParams();
414
+ if (from) params.append("from", from);
415
+ if (to) params.append("to", to);
416
+ return this.http.get(
417
+ `/orgs/${orgId}/endpoints/${endpointId}/metrics?${params.toString()}`
418
+ );
419
+ }
420
+ /** Update endpoint priorities */
421
+ updatePriorities(orgId, priorities) {
422
+ return this.http.patch(`/orgs/${orgId}/endpoints/priorities`, {
423
+ priorities
424
+ });
425
+ }
426
+ };
427
+
428
+ // src/resources/usage.ts
429
+ var UsageResource = class {
430
+ constructor(http) {
431
+ this.http = http;
432
+ }
433
+ /** Get usage analytics for a date range */
434
+ get(orgId, from, to) {
435
+ return this.http.get(`/orgs/${orgId}/usage?from=${from}&to=${to}`);
436
+ }
437
+ /** Get usage summary */
438
+ getSummary(orgId) {
439
+ return this.http.get(`/orgs/${orgId}/usage/summary`);
440
+ }
441
+ };
442
+
443
+ // src/resources/dashboard.ts
444
+ var DashboardResource = class {
445
+ constructor(http) {
446
+ this.http = http;
447
+ }
448
+ /** Get full dashboard data */
449
+ get(orgId, period) {
450
+ const params = period ? `?period=${period}` : "";
451
+ return this.http.get(`/orgs/${orgId}/dashboard${params}`);
452
+ }
453
+ /** Get system health overview */
454
+ getHealth(orgId) {
455
+ return this.http.get(`/orgs/${orgId}/dashboard/health`);
456
+ }
457
+ /** Get quick stats */
458
+ getQuickStats(orgId, period) {
459
+ const params = period ? `?period=${period}` : "";
460
+ return this.http.get(`/orgs/${orgId}/dashboard/quick-stats${params}`);
461
+ }
462
+ /** Get request rate time series */
463
+ getRequestRate(orgId, period) {
464
+ const params = period ? `?period=${period}` : "";
465
+ return this.http.get(`/orgs/${orgId}/dashboard/request-rate${params}`);
466
+ }
467
+ /** Get error rate time series */
468
+ getErrorRate(orgId, period) {
469
+ const params = period ? `?period=${period}` : "";
470
+ return this.http.get(`/orgs/${orgId}/dashboard/error-rate${params}`);
471
+ }
472
+ /** Get latency metrics */
473
+ getLatency(orgId, period) {
474
+ const params = period ? `?period=${period}` : "";
475
+ return this.http.get(`/orgs/${orgId}/dashboard/latency${params}`);
476
+ }
477
+ /** Get performance metrics */
478
+ getPerformance(orgId) {
479
+ return this.http.get(`/orgs/${orgId}/dashboard/performance`);
480
+ }
481
+ };
482
+
483
+ // src/resources/alerts.ts
484
+ var AlertsResource = class {
485
+ constructor(http) {
486
+ this.http = http;
487
+ }
488
+ // ==================== Alerts ====================
489
+ /** List alerts for an organization */
490
+ list(orgId) {
491
+ return this.http.get(`/orgs/${orgId}/alerts`);
492
+ }
493
+ /** Acknowledge an alert */
494
+ acknowledge(orgId, alertId) {
495
+ return this.http.post(`/orgs/${orgId}/alerts/${alertId}/acknowledge`);
496
+ }
497
+ /** Resolve an alert */
498
+ resolve(orgId, alertId) {
499
+ return this.http.post(`/orgs/${orgId}/alerts/${alertId}/resolve`);
500
+ }
501
+ /** Evaluate all alert rules now */
502
+ evaluate(orgId) {
503
+ return this.http.post(`/orgs/${orgId}/alerts/evaluate`);
504
+ }
505
+ // ==================== Alert Rules ====================
506
+ /** List alert rules */
507
+ listRules(orgId) {
508
+ return this.http.get(`/orgs/${orgId}/alerts/rules`);
509
+ }
510
+ /** Create a new alert rule */
511
+ createRule(orgId, data) {
512
+ return this.http.post(`/orgs/${orgId}/alerts/rules`, data);
513
+ }
514
+ /** Get a specific alert rule */
515
+ getRule(orgId, ruleId) {
516
+ return this.http.get(`/orgs/${orgId}/alerts/rules/${ruleId}`);
517
+ }
518
+ /** Update an alert rule */
519
+ updateRule(orgId, ruleId, data) {
520
+ return this.http.put(`/orgs/${orgId}/alerts/rules/${ruleId}`, data);
521
+ }
522
+ /** Delete an alert rule */
523
+ deleteRule(orgId, ruleId) {
524
+ return this.http.delete(`/orgs/${orgId}/alerts/rules/${ruleId}`);
525
+ }
526
+ /** Toggle an alert rule on/off */
527
+ toggleRule(orgId, ruleId) {
528
+ return this.http.post(`/orgs/${orgId}/alerts/rules/${ruleId}/toggle`);
529
+ }
530
+ /** Seed default alert rules */
531
+ seedDefaults(orgId) {
532
+ return this.http.post(`/orgs/${orgId}/alerts/rules/seed-defaults`);
533
+ }
534
+ // ==================== Alert Channels ====================
535
+ /** List notification channels */
536
+ listChannels(orgId) {
537
+ return this.http.get(`/orgs/${orgId}/alerts/channels`);
538
+ }
539
+ /** Create a notification channel */
540
+ createChannel(orgId, data) {
541
+ return this.http.post(`/orgs/${orgId}/alerts/channels`, data);
542
+ }
543
+ /** Get a specific channel */
544
+ getChannel(orgId, channelId) {
545
+ return this.http.get(`/orgs/${orgId}/alerts/channels/${channelId}`);
546
+ }
547
+ /** Update a notification channel */
548
+ updateChannel(orgId, channelId, data) {
549
+ return this.http.put(`/orgs/${orgId}/alerts/channels/${channelId}`, data);
550
+ }
551
+ /** Delete a notification channel */
552
+ deleteChannel(orgId, channelId) {
553
+ return this.http.delete(`/orgs/${orgId}/alerts/channels/${channelId}`);
554
+ }
555
+ /** Test a notification channel */
556
+ testChannel(orgId, channelId) {
557
+ return this.http.post(`/orgs/${orgId}/alerts/channels/${channelId}/test`);
558
+ }
559
+ };
560
+
561
+ // src/resources/logs.ts
562
+ var LogsResource = class {
563
+ constructor(http) {
564
+ this.http = http;
565
+ }
566
+ /** Query request logs with filters and pagination */
567
+ query(orgId, params) {
568
+ const searchParams = new URLSearchParams();
569
+ if (params) {
570
+ for (const [key, value] of Object.entries(params)) {
571
+ if (value !== void 0 && value !== null && value !== "") {
572
+ searchParams.append(key, String(value));
573
+ }
574
+ }
575
+ }
576
+ const qs = searchParams.toString();
577
+ return this.http.get(`/orgs/${orgId}/logs${qs ? `?${qs}` : ""}`);
578
+ }
579
+ /** Get a single log entry */
580
+ get(orgId, logId) {
581
+ return this.http.get(`/orgs/${orgId}/logs/${logId}`);
582
+ }
583
+ /** Get log statistics */
584
+ getStats(orgId) {
585
+ return this.http.get(`/orgs/${orgId}/logs/stats`);
586
+ }
587
+ /** Get available filter options */
588
+ getFilterOptions(orgId) {
589
+ return this.http.get(`/orgs/${orgId}/logs/filters`);
590
+ }
591
+ };
592
+
593
+ // src/resources/subscriptions.ts
594
+ var SubscriptionsResource = class {
595
+ constructor(http) {
596
+ this.http = http;
597
+ }
598
+ /** Get current subscription */
599
+ get(orgId) {
600
+ return this.http.get(`/orgs/${orgId}/subscription`);
601
+ }
602
+ /** Change subscription plan */
603
+ changePlan(orgId, planId) {
604
+ return this.http.put(`/orgs/${orgId}/subscription/plan`, { planId });
605
+ }
606
+ /** Cancel subscription */
607
+ cancel(orgId) {
608
+ return this.http.post(`/orgs/${orgId}/subscription/cancel`);
609
+ }
610
+ /** Reactivate a cancelled subscription */
611
+ reactivate(orgId) {
612
+ return this.http.post(`/orgs/${orgId}/subscription/reactivate`);
613
+ }
614
+ /** Get invoices */
615
+ getInvoices(orgId, limit) {
616
+ const qs = limit ? `?limit=${limit}` : "";
617
+ return this.http.get(`/orgs/${orgId}/subscription/invoices${qs}`);
618
+ }
619
+ };
620
+
621
+ // src/resources/plans.ts
622
+ var PlansResource = class {
623
+ constructor(http) {
624
+ this.http = http;
625
+ }
626
+ /** List all available plans */
627
+ list() {
628
+ return this.http.get("/plans");
629
+ }
630
+ /** Get a specific plan */
631
+ get(planId) {
632
+ return this.http.get(`/plans/${planId}`);
633
+ }
634
+ };
635
+
636
+ // src/resources/support.ts
637
+ var SupportResource = class {
638
+ constructor(http) {
639
+ this.http = http;
640
+ }
641
+ /** Create a support ticket */
642
+ createTicket(orgId, data) {
643
+ return this.http.post(`/orgs/${orgId}/support/tickets`, data);
644
+ }
645
+ /** List support tickets */
646
+ listTickets(orgId) {
647
+ return this.http.get(`/orgs/${orgId}/support/tickets`);
648
+ }
649
+ /** Get ticket statistics */
650
+ getStats(orgId) {
651
+ return this.http.get(`/orgs/${orgId}/support/tickets/stats`);
652
+ }
653
+ /** Get a specific ticket */
654
+ getTicket(orgId, ticketId) {
655
+ return this.http.get(`/orgs/${orgId}/support/tickets/${ticketId}`);
656
+ }
657
+ /** Add a message to a ticket */
658
+ addMessage(orgId, ticketId, content) {
659
+ return this.http.post(
660
+ `/orgs/${orgId}/support/tickets/${ticketId}/messages`,
661
+ { body: content }
662
+ );
663
+ }
664
+ /** Update ticket status */
665
+ updateStatus(orgId, ticketId, status) {
666
+ return this.http.put(`/orgs/${orgId}/support/tickets/${ticketId}/status`, {
667
+ status
668
+ });
669
+ }
670
+ };
671
+
672
+ // src/resources/rpc.ts
673
+ var RpcResource = class {
674
+ constructor(http) {
675
+ this.http = http;
676
+ }
677
+ /**
678
+ * Send a JSON-RPC 2.0 request to the specified network via the Iteradian gateway.
679
+ *
680
+ * @example
681
+ * ```ts
682
+ * const result = await client.rpc.call('eth-mainnet', {
683
+ * jsonrpc: '2.0',
684
+ * method: 'eth_blockNumber',
685
+ * params: [],
686
+ * id: 1,
687
+ * });
688
+ * ```
689
+ */
690
+ call(network, request, options) {
691
+ return this.http.gateway(
692
+ `/rpc/v1/${encodeURIComponent(network)}`,
693
+ request,
694
+ options?.signal
695
+ );
696
+ }
697
+ /**
698
+ * Send a batch of JSON-RPC 2.0 requests to the specified network.
699
+ *
700
+ * A batch of N calls costs N against both your per-second rate limit and
701
+ * your monthly request quota — it is a transport optimisation, not a
702
+ * billing one.
703
+ *
704
+ * @example
705
+ * ```ts
706
+ * const results = await client.rpc.batch('eth-mainnet', [
707
+ * { jsonrpc: '2.0', method: 'eth_blockNumber', params: [], id: 1 },
708
+ * { jsonrpc: '2.0', method: 'net_peerCount', params: [], id: 2 },
709
+ * ]);
710
+ * ```
711
+ */
712
+ batch(network, requests, options) {
713
+ return this.http.gateway(
714
+ `/rpc/v1/${encodeURIComponent(network)}`,
715
+ requests,
716
+ options?.signal
717
+ );
718
+ }
719
+ /**
720
+ * List the networks the gateway can currently route to.
721
+ *
722
+ * Only networks with at least one healthy node are advertised.
723
+ */
724
+ networks() {
725
+ return this.http.gatewayGet("/rpc/v1/networks");
726
+ }
727
+ };
728
+
729
+ // src/client.ts
730
+ var IteradianClient = class {
731
+ constructor(config = {}) {
732
+ this.http = new HttpClient(config);
733
+ this.auth = new AuthResource(this.http);
734
+ this.organizations = new OrganizationsResource(this.http);
735
+ this.apiKeys = new ApiKeysResource(this.http);
736
+ this.endpoints = new EndpointsResource(this.http);
737
+ this.usage = new UsageResource(this.http);
738
+ this.dashboard = new DashboardResource(this.http);
739
+ this.alerts = new AlertsResource(this.http);
740
+ this.logs = new LogsResource(this.http);
741
+ this.subscriptions = new SubscriptionsResource(this.http);
742
+ this.plans = new PlansResource(this.http);
743
+ this.support = new SupportResource(this.http);
744
+ this.rpc = new RpcResource(this.http);
745
+ }
746
+ /** Set the access token for all subsequent requests */
747
+ setAccessToken(token) {
748
+ this.http.setAccessToken(token);
749
+ }
750
+ /** Clear the access token */
751
+ clearAccessToken() {
752
+ this.http.clearAccessToken();
753
+ }
754
+ };
755
+ export {
756
+ AlertsResource,
757
+ ApiKeysResource,
758
+ AuthResource,
759
+ DashboardResource,
760
+ EndpointsResource,
761
+ IteradianClient,
762
+ IteradianError,
763
+ LogsResource,
764
+ OrganizationsResource,
765
+ PlansResource,
766
+ RpcResource,
767
+ SubscriptionsResource,
768
+ SupportResource,
769
+ UsageResource
770
+ };