@secondlayer/sdk 6.7.0 → 6.9.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 +48 -3
- package/dist/index.d.ts +125 -4
- package/dist/index.js +76 -15
- package/dist/index.js.map +10 -9
- package/dist/streams/index.d.ts +16 -3
- package/dist/streams/index.js +7 -14
- package/dist/streams/index.js.map +4 -4
- package/dist/subgraphs/index.d.ts +122 -2
- package/dist/subgraphs/index.js +71 -2
- package/dist/subgraphs/index.js.map +9 -8
- package/package.json +2 -2
package/dist/subgraphs/index.js
CHANGED
|
@@ -242,6 +242,12 @@ class Subgraphs extends BaseClient {
|
|
|
242
242
|
const qs = options?.force ? "?force=true" : "";
|
|
243
243
|
return this.request("DELETE", `/api/subgraphs/${name}${qs}`);
|
|
244
244
|
}
|
|
245
|
+
async operations(name) {
|
|
246
|
+
return this.request("GET", `/api/subgraphs/${name}/operations`);
|
|
247
|
+
}
|
|
248
|
+
async getOperation(name, operationId) {
|
|
249
|
+
return this.request("GET", `/api/subgraphs/${name}/operations/${operationId}`);
|
|
250
|
+
}
|
|
245
251
|
async deploy(data) {
|
|
246
252
|
return this.request("POST", "/api/subgraphs", data);
|
|
247
253
|
}
|
|
@@ -324,6 +330,19 @@ class Subgraphs extends BaseClient {
|
|
|
324
330
|
};
|
|
325
331
|
}
|
|
326
332
|
}
|
|
333
|
+
// src/api-keys/client.ts
|
|
334
|
+
class ApiKeys extends BaseClient {
|
|
335
|
+
constructor(options = {}) {
|
|
336
|
+
super(options);
|
|
337
|
+
}
|
|
338
|
+
create(params = {}) {
|
|
339
|
+
return this.request("POST", "/v1/api-keys", {
|
|
340
|
+
product: params.product,
|
|
341
|
+
name: params.name
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
327
346
|
// src/contracts/client.ts
|
|
328
347
|
class Contracts extends BaseClient {
|
|
329
348
|
constructor(options = {}) {
|
|
@@ -473,6 +492,9 @@ class Index extends BaseClient {
|
|
|
473
492
|
constructor(options = {}) {
|
|
474
493
|
super(options);
|
|
475
494
|
}
|
|
495
|
+
usage() {
|
|
496
|
+
return this.request("GET", "/v1/index/usage");
|
|
497
|
+
}
|
|
476
498
|
ftTransfers = {
|
|
477
499
|
list: (params = {}) => this.listFtTransfers(params),
|
|
478
500
|
walk: (params = {}) => this.walkFtTransfers(params)
|
|
@@ -1331,12 +1353,15 @@ function createStreamsClient(options) {
|
|
|
1331
1353
|
},
|
|
1332
1354
|
tip() {
|
|
1333
1355
|
return request("/v1/streams/tip");
|
|
1356
|
+
},
|
|
1357
|
+
usage() {
|
|
1358
|
+
return request("/v1/streams/usage");
|
|
1334
1359
|
}
|
|
1335
1360
|
};
|
|
1336
1361
|
}
|
|
1337
1362
|
|
|
1338
1363
|
// src/subscriptions/client.ts
|
|
1339
|
-
import {
|
|
1364
|
+
import { trigger } from "@secondlayer/shared/schemas/subscriptions";
|
|
1340
1365
|
|
|
1341
1366
|
class Subscriptions extends BaseClient {
|
|
1342
1367
|
async list() {
|
|
@@ -1385,6 +1410,7 @@ class SecondLayer extends BaseClient {
|
|
|
1385
1410
|
contracts;
|
|
1386
1411
|
subgraphs;
|
|
1387
1412
|
subscriptions;
|
|
1413
|
+
apiKeys;
|
|
1388
1414
|
constructor(options = {}) {
|
|
1389
1415
|
super(options);
|
|
1390
1416
|
this.streams = createStreamsClient({
|
|
@@ -1397,6 +1423,49 @@ class SecondLayer extends BaseClient {
|
|
|
1397
1423
|
this.contracts = new Contracts(options);
|
|
1398
1424
|
this.subgraphs = new Subgraphs(options);
|
|
1399
1425
|
this.subscriptions = new Subscriptions(options);
|
|
1426
|
+
this.apiKeys = new ApiKeys(options);
|
|
1427
|
+
}
|
|
1428
|
+
async context() {
|
|
1429
|
+
const safe = (p) => p.then((v) => v).catch(() => null);
|
|
1430
|
+
const [account, streamsTip, indexEnv, subgraphsRes, subscriptionsRes] = await Promise.all([
|
|
1431
|
+
safe(this.request("GET", "/api/accounts/me")),
|
|
1432
|
+
safe(this.streams.tip()),
|
|
1433
|
+
safe(this.index.canonical.list({ limit: 1 })),
|
|
1434
|
+
safe(this.subgraphs.list()),
|
|
1435
|
+
safe(this.subscriptions.list())
|
|
1436
|
+
]);
|
|
1437
|
+
const subgraphs = subgraphsRes?.data ?? null;
|
|
1438
|
+
let subscriptions = null;
|
|
1439
|
+
if (subscriptionsRes) {
|
|
1440
|
+
const byStatus = {};
|
|
1441
|
+
for (const s of subscriptionsRes.data) {
|
|
1442
|
+
byStatus[s.status] = (byStatus[s.status] ?? 0) + 1;
|
|
1443
|
+
}
|
|
1444
|
+
subscriptions = { count: subscriptionsRes.data.length, byStatus };
|
|
1445
|
+
}
|
|
1446
|
+
let activeOperations = null;
|
|
1447
|
+
if (subgraphs) {
|
|
1448
|
+
const probed = await Promise.all(subgraphs.filter((s) => s.status === "reindexing").map(async (s) => {
|
|
1449
|
+
const res = await safe(this.subgraphs.operations(s.name));
|
|
1450
|
+
const op = res?.operations.find((o) => o.status === "queued" || o.status === "running");
|
|
1451
|
+
return op ? {
|
|
1452
|
+
subgraph: s.name,
|
|
1453
|
+
operationId: op.id,
|
|
1454
|
+
kind: op.kind,
|
|
1455
|
+
status: op.status,
|
|
1456
|
+
progress: op.progress
|
|
1457
|
+
} : null;
|
|
1458
|
+
}));
|
|
1459
|
+
activeOperations = probed.filter((o) => o !== null);
|
|
1460
|
+
}
|
|
1461
|
+
return {
|
|
1462
|
+
account,
|
|
1463
|
+
streamsTip,
|
|
1464
|
+
indexTip: indexEnv?.tip ?? null,
|
|
1465
|
+
subgraphs,
|
|
1466
|
+
subscriptions,
|
|
1467
|
+
activeOperations
|
|
1468
|
+
};
|
|
1400
1469
|
}
|
|
1401
1470
|
}
|
|
1402
1471
|
|
|
@@ -1415,5 +1484,5 @@ export {
|
|
|
1415
1484
|
Subgraphs
|
|
1416
1485
|
};
|
|
1417
1486
|
|
|
1418
|
-
//# debugId=
|
|
1487
|
+
//# debugId=31D759DA70279D1564756E2164756E21
|
|
1419
1488
|
//# sourceMappingURL=index.js.map
|