@secondlayer/shared 13.3.0 → 13.5.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/dist/src/archive/range-digest.d.ts +50 -0
- package/dist/src/archive/semantic-digest-builder.d.ts +50 -0
- package/dist/src/coverage/index.d.ts +50 -0
- package/dist/src/db/index.d.ts +54 -1
- package/dist/src/db/index.js +4 -1
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +50 -0
- package/dist/src/db/queries/chain-reorgs.js +4 -1
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +50 -0
- package/dist/src/db/queries/instance.d.ts +50 -0
- package/dist/src/db/queries/integrity.d.ts +50 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +50 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +50 -0
- package/dist/src/db/queries/subgraphs.d.ts +50 -0
- package/dist/src/db/queries/sync-scope.d.ts +50 -0
- package/dist/src/db/queries/webhooks.d.ts +50 -0
- package/dist/src/db/schema.d.ts +51 -1
- package/dist/src/index.d.ts +169 -7
- package/dist/src/index.js +239 -87
- package/dist/src/index.js.map +6 -4
- package/dist/src/insights/index.d.ts +1540 -0
- package/dist/src/insights/index.js +2284 -0
- package/dist/src/insights/index.js.map +29 -0
- package/dist/src/insights/thresholds.d.ts +56 -0
- package/dist/src/insights/thresholds.js +86 -0
- package/dist/src/insights/thresholds.js.map +10 -0
- package/dist/src/leader.d.ts +3 -1
- package/dist/src/leader.js +3 -1
- package/dist/src/leader.js.map +3 -3
- package/dist/src/node/local-client.d.ts +50 -0
- package/dist/src/queue/listener.js +4 -1
- package/dist/src/queue/listener.js.map +3 -3
- package/dist/src/schemas/index.d.ts +95 -7
- package/dist/src/schemas/index.js +180 -87
- package/dist/src/schemas/index.js.map +4 -3
- package/dist/src/schemas/insights.d.ts +89 -0
- package/dist/src/schemas/insights.js +98 -0
- package/dist/src/schemas/insights.js.map +10 -0
- package/migrations/0169_subgraph_health_history.ts +54 -0
- package/migrations/0170_insights.ts +63 -0
- package/package.json +13 -1
package/dist/src/index.js
CHANGED
|
@@ -854,6 +854,7 @@ var TABLE_TO_DB = {
|
|
|
854
854
|
subgraph_health_snapshots: "target",
|
|
855
855
|
subgraph_gaps: "target",
|
|
856
856
|
subgraph_violations: "target",
|
|
857
|
+
subgraph_error_groups: "target",
|
|
857
858
|
subgraph_processing_stats: "target",
|
|
858
859
|
account_credits: "target",
|
|
859
860
|
archive_fetches: "target",
|
|
@@ -865,6 +866,8 @@ var TABLE_TO_DB = {
|
|
|
865
866
|
contact_requests: "target",
|
|
866
867
|
api_failed_requests: "target",
|
|
867
868
|
api_request_log: "target",
|
|
869
|
+
insights: "target",
|
|
870
|
+
insight_mutes: "target",
|
|
868
871
|
feedback_tickets: "target",
|
|
869
872
|
service_heartbeats: "both"
|
|
870
873
|
};
|
|
@@ -1255,8 +1258,94 @@ var BILLING_PAUSED_PREFIX = "billing_paused: ";
|
|
|
1255
1258
|
function billingPausedCode(lastError) {
|
|
1256
1259
|
return lastError?.startsWith(BILLING_PAUSED_PREFIX) ? lastError.slice(BILLING_PAUSED_PREFIX.length) : null;
|
|
1257
1260
|
}
|
|
1258
|
-
// src/schemas/
|
|
1261
|
+
// src/schemas/insights.ts
|
|
1259
1262
|
import { z as z3 } from "zod";
|
|
1263
|
+
var INSIGHT_SEVERITIES = [
|
|
1264
|
+
"losing",
|
|
1265
|
+
"will_fail",
|
|
1266
|
+
"costs",
|
|
1267
|
+
"recovered"
|
|
1268
|
+
];
|
|
1269
|
+
var InsightSeveritySchema = z3.enum(INSIGHT_SEVERITIES);
|
|
1270
|
+
var InsightResourceKindSchema = z3.enum(["webhook", "subgraph", "account"]);
|
|
1271
|
+
var InsightEvidenceSchema = z3.discriminatedUnion("kind", [
|
|
1272
|
+
z3.object({
|
|
1273
|
+
kind: z3.literal("series"),
|
|
1274
|
+
title: z3.string(),
|
|
1275
|
+
series: z3.array(z3.object({
|
|
1276
|
+
name: z3.string(),
|
|
1277
|
+
role: z3.enum(["a", "context", "mark"]),
|
|
1278
|
+
points: z3.array(z3.number())
|
|
1279
|
+
})),
|
|
1280
|
+
labels: z3.array(z3.tuple([z3.number(), z3.string()])),
|
|
1281
|
+
unit: z3.string().optional()
|
|
1282
|
+
}),
|
|
1283
|
+
z3.object({
|
|
1284
|
+
kind: z3.literal("table"),
|
|
1285
|
+
title: z3.string(),
|
|
1286
|
+
columns: z3.array(z3.string()),
|
|
1287
|
+
rows: z3.array(z3.array(z3.union([z3.string(), z3.number()]))),
|
|
1288
|
+
markRow: z3.number().optional()
|
|
1289
|
+
}),
|
|
1290
|
+
z3.object({
|
|
1291
|
+
kind: z3.literal("shapes"),
|
|
1292
|
+
title: z3.string(),
|
|
1293
|
+
shapes: z3.array(z3.object({
|
|
1294
|
+
code: z3.string(),
|
|
1295
|
+
body: z3.string(),
|
|
1296
|
+
count: z3.number(),
|
|
1297
|
+
isNew: z3.boolean()
|
|
1298
|
+
}))
|
|
1299
|
+
}),
|
|
1300
|
+
z3.object({
|
|
1301
|
+
kind: z3.literal("timeline"),
|
|
1302
|
+
title: z3.string(),
|
|
1303
|
+
steps: z3.array(z3.object({
|
|
1304
|
+
what: z3.string(),
|
|
1305
|
+
at: z3.string(),
|
|
1306
|
+
note: z3.string().optional(),
|
|
1307
|
+
failed: z3.boolean()
|
|
1308
|
+
}))
|
|
1309
|
+
})
|
|
1310
|
+
]);
|
|
1311
|
+
var InsightSchema = z3.object({
|
|
1312
|
+
id: z3.string(),
|
|
1313
|
+
rule: z3.string(),
|
|
1314
|
+
severity: InsightSeveritySchema,
|
|
1315
|
+
impact: z3.number(),
|
|
1316
|
+
resource: z3.object({
|
|
1317
|
+
kind: InsightResourceKindSchema,
|
|
1318
|
+
id: z3.string(),
|
|
1319
|
+
name: z3.string()
|
|
1320
|
+
}),
|
|
1321
|
+
line: z3.string(),
|
|
1322
|
+
meta: z3.string().optional(),
|
|
1323
|
+
lead: z3.string(),
|
|
1324
|
+
body: z3.string(),
|
|
1325
|
+
evidence: z3.array(InsightEvidenceSchema),
|
|
1326
|
+
handoff: z3.object({
|
|
1327
|
+
prompt: z3.string(),
|
|
1328
|
+
commands: z3.array(z3.string())
|
|
1329
|
+
}),
|
|
1330
|
+
how: z3.object({
|
|
1331
|
+
detector: z3.string(),
|
|
1332
|
+
facts: z3.array(z3.tuple([z3.string(), z3.string()])),
|
|
1333
|
+
label: z3.object({ cause: z3.string(), confidence: z3.number() }).optional()
|
|
1334
|
+
}),
|
|
1335
|
+
createdAt: z3.string(),
|
|
1336
|
+
resolvedAt: z3.string().nullable().optional()
|
|
1337
|
+
});
|
|
1338
|
+
var InsightListResponseSchema = z3.object({
|
|
1339
|
+
data: z3.array(InsightSchema)
|
|
1340
|
+
});
|
|
1341
|
+
var SEVERITY_ORDER = {
|
|
1342
|
+
losing: 0,
|
|
1343
|
+
will_fail: 1,
|
|
1344
|
+
costs: 2,
|
|
1345
|
+
recovered: 3
|
|
1346
|
+
};
|
|
1347
|
+
// src/schemas/webhooks.ts
|
|
1348
|
+
import { z as z4 } from "zod";
|
|
1260
1349
|
var WEBHOOK_FORMATS = [
|
|
1261
1350
|
"standard-webhooks",
|
|
1262
1351
|
"inngest",
|
|
@@ -1282,7 +1371,7 @@ function webhookTimeoutMsCeiling() {
|
|
|
1282
1371
|
return ceilingFromEnv("WEBHOOK_TIMEOUT_MS_CEILING", WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT);
|
|
1283
1372
|
}
|
|
1284
1373
|
function maxRetriesField() {
|
|
1285
|
-
return
|
|
1374
|
+
return z4.number().int().min(0).optional().superRefine((v, ctx) => {
|
|
1286
1375
|
if (v === undefined)
|
|
1287
1376
|
return;
|
|
1288
1377
|
const ceiling = webhookMaxRetriesCeiling();
|
|
@@ -1295,7 +1384,7 @@ function maxRetriesField() {
|
|
|
1295
1384
|
});
|
|
1296
1385
|
}
|
|
1297
1386
|
function timeoutMsField() {
|
|
1298
|
-
return
|
|
1387
|
+
return z4.number().int().min(100).optional().superRefine((v, ctx) => {
|
|
1299
1388
|
if (v === undefined)
|
|
1300
1389
|
return;
|
|
1301
1390
|
const ceiling = webhookTimeoutMsCeiling();
|
|
@@ -1307,8 +1396,8 @@ function timeoutMsField() {
|
|
|
1307
1396
|
}
|
|
1308
1397
|
});
|
|
1309
1398
|
}
|
|
1310
|
-
var webhookUrl =
|
|
1311
|
-
var name =
|
|
1399
|
+
var webhookUrl = z4.string().trim().min(1).refine((value) => value.startsWith("http://") || value.startsWith("https://"), "must be an http(s) URL");
|
|
1400
|
+
var name = z4.string().trim().min(1).max(128);
|
|
1312
1401
|
var MANAGED_NAME_PREFIXES = {
|
|
1313
1402
|
"sentinel:": "Sentinel"
|
|
1314
1403
|
};
|
|
@@ -1319,8 +1408,8 @@ function managedByForName(name) {
|
|
|
1319
1408
|
}
|
|
1320
1409
|
return null;
|
|
1321
1410
|
}
|
|
1322
|
-
var WebhookStatusSchema =
|
|
1323
|
-
var WebhookFormatSchema =
|
|
1411
|
+
var WebhookStatusSchema = z4.enum(WEBHOOK_STATUSES);
|
|
1412
|
+
var WebhookFormatSchema = z4.enum(WEBHOOK_FORMATS);
|
|
1324
1413
|
var CHAIN_TRIGGER_TYPES = [
|
|
1325
1414
|
"stx_transfer",
|
|
1326
1415
|
"stx_mint",
|
|
@@ -1350,212 +1439,212 @@ var CHAIN_TRIGGER_TYPES = [
|
|
|
1350
1439
|
"rune_transfer",
|
|
1351
1440
|
"rune_burn"
|
|
1352
1441
|
];
|
|
1353
|
-
var runeRef =
|
|
1354
|
-
var triggerAmount =
|
|
1355
|
-
|
|
1356
|
-
|
|
1442
|
+
var runeRef = z4.string().trim().min(1);
|
|
1443
|
+
var triggerAmount = z4.union([
|
|
1444
|
+
z4.string().trim().regex(/^\d+$/, "must be a non-negative integer string"),
|
|
1445
|
+
z4.number().int().nonnegative()
|
|
1357
1446
|
]);
|
|
1358
|
-
var triggerPattern =
|
|
1359
|
-
var trait =
|
|
1360
|
-
var printWhereValue =
|
|
1361
|
-
var PrintWhereSchema =
|
|
1447
|
+
var triggerPattern = z4.string().trim().min(1);
|
|
1448
|
+
var trait = z4.string().trim().min(1);
|
|
1449
|
+
var printWhereValue = z4.string().min(1).max(256);
|
|
1450
|
+
var PrintWhereSchema = z4.record(z4.string().trim().min(1).max(64), z4.union([printWhereValue, z4.array(printWhereValue).min(1).max(20)])).refine((o) => {
|
|
1362
1451
|
const n = Object.keys(o).length;
|
|
1363
1452
|
return n >= 1 && n <= 10;
|
|
1364
1453
|
}, "where takes 1 to 10 keys");
|
|
1365
|
-
var ChainTriggerSchema =
|
|
1366
|
-
|
|
1367
|
-
type:
|
|
1454
|
+
var ChainTriggerSchema = z4.discriminatedUnion("type", [
|
|
1455
|
+
z4.object({
|
|
1456
|
+
type: z4.literal("stx_transfer"),
|
|
1368
1457
|
sender: triggerPattern.optional(),
|
|
1369
1458
|
recipient: triggerPattern.optional(),
|
|
1370
1459
|
minAmount: triggerAmount.optional(),
|
|
1371
1460
|
maxAmount: triggerAmount.optional()
|
|
1372
1461
|
}).strict(),
|
|
1373
|
-
|
|
1374
|
-
type:
|
|
1462
|
+
z4.object({
|
|
1463
|
+
type: z4.literal("stx_mint"),
|
|
1375
1464
|
recipient: triggerPattern.optional(),
|
|
1376
1465
|
minAmount: triggerAmount.optional()
|
|
1377
1466
|
}).strict(),
|
|
1378
|
-
|
|
1379
|
-
type:
|
|
1467
|
+
z4.object({
|
|
1468
|
+
type: z4.literal("stx_burn"),
|
|
1380
1469
|
sender: triggerPattern.optional(),
|
|
1381
1470
|
minAmount: triggerAmount.optional()
|
|
1382
1471
|
}).strict(),
|
|
1383
|
-
|
|
1384
|
-
type:
|
|
1472
|
+
z4.object({
|
|
1473
|
+
type: z4.literal("stx_lock"),
|
|
1385
1474
|
lockedAddress: triggerPattern.optional(),
|
|
1386
1475
|
minAmount: triggerAmount.optional()
|
|
1387
1476
|
}).strict(),
|
|
1388
|
-
|
|
1389
|
-
type:
|
|
1477
|
+
z4.object({
|
|
1478
|
+
type: z4.literal("ft_transfer"),
|
|
1390
1479
|
assetIdentifier: triggerPattern.optional(),
|
|
1391
1480
|
sender: triggerPattern.optional(),
|
|
1392
1481
|
recipient: triggerPattern.optional(),
|
|
1393
1482
|
minAmount: triggerAmount.optional(),
|
|
1394
1483
|
trait: trait.optional()
|
|
1395
1484
|
}).strict(),
|
|
1396
|
-
|
|
1397
|
-
type:
|
|
1485
|
+
z4.object({
|
|
1486
|
+
type: z4.literal("ft_mint"),
|
|
1398
1487
|
assetIdentifier: triggerPattern.optional(),
|
|
1399
1488
|
recipient: triggerPattern.optional(),
|
|
1400
1489
|
minAmount: triggerAmount.optional(),
|
|
1401
1490
|
trait: trait.optional()
|
|
1402
1491
|
}).strict(),
|
|
1403
|
-
|
|
1404
|
-
type:
|
|
1492
|
+
z4.object({
|
|
1493
|
+
type: z4.literal("ft_burn"),
|
|
1405
1494
|
assetIdentifier: triggerPattern.optional(),
|
|
1406
1495
|
sender: triggerPattern.optional(),
|
|
1407
1496
|
minAmount: triggerAmount.optional(),
|
|
1408
1497
|
trait: trait.optional()
|
|
1409
1498
|
}).strict(),
|
|
1410
|
-
|
|
1411
|
-
type:
|
|
1499
|
+
z4.object({
|
|
1500
|
+
type: z4.literal("nft_transfer"),
|
|
1412
1501
|
assetIdentifier: triggerPattern.optional(),
|
|
1413
1502
|
sender: triggerPattern.optional(),
|
|
1414
1503
|
recipient: triggerPattern.optional(),
|
|
1415
1504
|
trait: trait.optional()
|
|
1416
1505
|
}).strict(),
|
|
1417
|
-
|
|
1418
|
-
type:
|
|
1506
|
+
z4.object({
|
|
1507
|
+
type: z4.literal("nft_mint"),
|
|
1419
1508
|
assetIdentifier: triggerPattern.optional(),
|
|
1420
1509
|
recipient: triggerPattern.optional(),
|
|
1421
1510
|
trait: trait.optional()
|
|
1422
1511
|
}).strict(),
|
|
1423
|
-
|
|
1424
|
-
type:
|
|
1512
|
+
z4.object({
|
|
1513
|
+
type: z4.literal("nft_burn"),
|
|
1425
1514
|
assetIdentifier: triggerPattern.optional(),
|
|
1426
1515
|
sender: triggerPattern.optional(),
|
|
1427
1516
|
trait: trait.optional()
|
|
1428
1517
|
}).strict(),
|
|
1429
|
-
|
|
1430
|
-
type:
|
|
1518
|
+
z4.object({
|
|
1519
|
+
type: z4.literal("contract_call"),
|
|
1431
1520
|
contractId: triggerPattern.optional(),
|
|
1432
1521
|
functionName: triggerPattern.optional(),
|
|
1433
1522
|
caller: triggerPattern.optional(),
|
|
1434
1523
|
trait: trait.optional()
|
|
1435
1524
|
}).strict(),
|
|
1436
|
-
|
|
1437
|
-
type:
|
|
1525
|
+
z4.object({
|
|
1526
|
+
type: z4.literal("contract_deploy"),
|
|
1438
1527
|
deployer: triggerPattern.optional(),
|
|
1439
1528
|
contractName: triggerPattern.optional()
|
|
1440
1529
|
}).strict(),
|
|
1441
|
-
|
|
1442
|
-
type:
|
|
1530
|
+
z4.object({
|
|
1531
|
+
type: z4.literal("print_event"),
|
|
1443
1532
|
contractId: triggerPattern.optional(),
|
|
1444
1533
|
topic: triggerPattern.optional(),
|
|
1445
1534
|
trait: trait.optional(),
|
|
1446
1535
|
where: PrintWhereSchema.optional()
|
|
1447
1536
|
}).strict(),
|
|
1448
|
-
|
|
1449
|
-
type:
|
|
1537
|
+
z4.object({
|
|
1538
|
+
type: z4.literal("nested_contract_call"),
|
|
1450
1539
|
contractId: triggerPattern.optional(),
|
|
1451
1540
|
functionName: triggerPattern.optional(),
|
|
1452
1541
|
caller: triggerPattern.optional(),
|
|
1453
1542
|
sender: triggerPattern.optional(),
|
|
1454
1543
|
trait: trait.optional()
|
|
1455
1544
|
}).strict(),
|
|
1456
|
-
|
|
1457
|
-
type:
|
|
1545
|
+
z4.object({
|
|
1546
|
+
type: z4.literal("var_set"),
|
|
1458
1547
|
contractId: triggerPattern.optional(),
|
|
1459
1548
|
varName: triggerPattern.optional(),
|
|
1460
1549
|
trait: trait.optional()
|
|
1461
1550
|
}).strict(),
|
|
1462
|
-
|
|
1463
|
-
type:
|
|
1551
|
+
z4.object({
|
|
1552
|
+
type: z4.literal("map_set"),
|
|
1464
1553
|
contractId: triggerPattern.optional(),
|
|
1465
1554
|
map: triggerPattern.optional(),
|
|
1466
1555
|
trait: trait.optional()
|
|
1467
1556
|
}).strict(),
|
|
1468
|
-
|
|
1469
|
-
type:
|
|
1557
|
+
z4.object({
|
|
1558
|
+
type: z4.literal("map_insert"),
|
|
1470
1559
|
contractId: triggerPattern.optional(),
|
|
1471
1560
|
map: triggerPattern.optional(),
|
|
1472
1561
|
trait: trait.optional()
|
|
1473
1562
|
}).strict(),
|
|
1474
|
-
|
|
1475
|
-
type:
|
|
1563
|
+
z4.object({
|
|
1564
|
+
type: z4.literal("map_delete"),
|
|
1476
1565
|
contractId: triggerPattern.optional(),
|
|
1477
1566
|
map: triggerPattern.optional(),
|
|
1478
1567
|
trait: trait.optional()
|
|
1479
1568
|
}).strict(),
|
|
1480
|
-
|
|
1481
|
-
type:
|
|
1569
|
+
z4.object({
|
|
1570
|
+
type: z4.literal("sbtc_deposit"),
|
|
1482
1571
|
sender: triggerPattern.optional(),
|
|
1483
1572
|
minAmount: triggerAmount.optional(),
|
|
1484
1573
|
maxAmount: triggerAmount.optional(),
|
|
1485
1574
|
bitcoinTxid: triggerPattern.optional(),
|
|
1486
|
-
requestId:
|
|
1575
|
+
requestId: z4.number().int().nonnegative().optional()
|
|
1487
1576
|
}).strict(),
|
|
1488
|
-
|
|
1489
|
-
type:
|
|
1577
|
+
z4.object({
|
|
1578
|
+
type: z4.literal("sbtc_withdrawal_create"),
|
|
1490
1579
|
sender: triggerPattern.optional(),
|
|
1491
1580
|
minAmount: triggerAmount.optional(),
|
|
1492
1581
|
maxAmount: triggerAmount.optional(),
|
|
1493
|
-
requestId:
|
|
1582
|
+
requestId: z4.number().int().nonnegative().optional()
|
|
1494
1583
|
}).strict(),
|
|
1495
|
-
|
|
1496
|
-
type:
|
|
1497
|
-
requestId:
|
|
1584
|
+
z4.object({
|
|
1585
|
+
type: z4.literal("sbtc_withdrawal_accept"),
|
|
1586
|
+
requestId: z4.number().int().nonnegative().optional(),
|
|
1498
1587
|
sweepTxid: triggerPattern.optional()
|
|
1499
1588
|
}).strict(),
|
|
1500
|
-
|
|
1501
|
-
type:
|
|
1502
|
-
requestId:
|
|
1589
|
+
z4.object({
|
|
1590
|
+
type: z4.literal("sbtc_withdrawal_reject"),
|
|
1591
|
+
requestId: z4.number().int().nonnegative().optional()
|
|
1503
1592
|
}).strict(),
|
|
1504
|
-
|
|
1505
|
-
type:
|
|
1506
|
-
requestId:
|
|
1593
|
+
z4.object({
|
|
1594
|
+
type: z4.literal("sbtc_withdrawal_swept_confirmed"),
|
|
1595
|
+
requestId: z4.number().int().nonnegative().optional(),
|
|
1507
1596
|
sweepTxid: triggerPattern.optional()
|
|
1508
1597
|
}).strict(),
|
|
1509
|
-
|
|
1510
|
-
type:
|
|
1598
|
+
z4.object({
|
|
1599
|
+
type: z4.literal("rune_etch"),
|
|
1511
1600
|
rune: runeRef.optional()
|
|
1512
1601
|
}).strict(),
|
|
1513
|
-
|
|
1514
|
-
type:
|
|
1602
|
+
z4.object({
|
|
1603
|
+
type: z4.literal("rune_mint"),
|
|
1515
1604
|
rune: runeRef.optional()
|
|
1516
1605
|
}).strict(),
|
|
1517
|
-
|
|
1518
|
-
type:
|
|
1606
|
+
z4.object({
|
|
1607
|
+
type: z4.literal("rune_transfer"),
|
|
1519
1608
|
rune: runeRef.optional(),
|
|
1520
1609
|
address: triggerPattern.optional(),
|
|
1521
1610
|
minAmount: triggerAmount.optional()
|
|
1522
1611
|
}).strict(),
|
|
1523
|
-
|
|
1524
|
-
type:
|
|
1612
|
+
z4.object({
|
|
1613
|
+
type: z4.literal("rune_burn"),
|
|
1525
1614
|
rune: runeRef.optional()
|
|
1526
1615
|
}).strict()
|
|
1527
1616
|
]);
|
|
1528
|
-
var ChainTriggersSchema =
|
|
1617
|
+
var ChainTriggersSchema = z4.array(ChainTriggerSchema).min(1).max(50);
|
|
1529
1618
|
var CHAIN_TRIGGER_FIELDS = Object.fromEntries(ChainTriggerSchema._zod.def.options.map((opt) => {
|
|
1530
1619
|
const shape = opt._zod.def.shape;
|
|
1531
1620
|
const type = shape.type._zod.def.values[0];
|
|
1532
1621
|
return [type, Object.keys(shape).filter((k) => k !== "type")];
|
|
1533
1622
|
}));
|
|
1534
|
-
var CreateWebhookRequestSchema =
|
|
1623
|
+
var CreateWebhookRequestSchema = z4.object({
|
|
1535
1624
|
name,
|
|
1536
1625
|
triggers: ChainTriggersSchema,
|
|
1537
1626
|
url: webhookUrl,
|
|
1538
1627
|
format: WebhookFormatSchema.default("standard-webhooks"),
|
|
1539
|
-
authConfig:
|
|
1628
|
+
authConfig: z4.record(z4.string(), z4.unknown()).optional(),
|
|
1540
1629
|
maxRetries: maxRetriesField(),
|
|
1541
1630
|
timeoutMs: timeoutMsField(),
|
|
1542
|
-
concurrency:
|
|
1631
|
+
concurrency: z4.number().int().min(1).max(100).optional()
|
|
1543
1632
|
});
|
|
1544
|
-
var UpdateWebhookRequestSchema =
|
|
1633
|
+
var UpdateWebhookRequestSchema = z4.object({
|
|
1545
1634
|
name: name.optional(),
|
|
1546
1635
|
url: webhookUrl.optional(),
|
|
1547
1636
|
format: WebhookFormatSchema.optional(),
|
|
1548
|
-
authConfig:
|
|
1637
|
+
authConfig: z4.record(z4.string(), z4.unknown()).optional(),
|
|
1549
1638
|
maxRetries: maxRetriesField(),
|
|
1550
1639
|
timeoutMs: timeoutMsField(),
|
|
1551
|
-
concurrency:
|
|
1640
|
+
concurrency: z4.number().int().min(1).max(100).optional()
|
|
1552
1641
|
}).refine((value) => Object.keys(value).length > 0, {
|
|
1553
1642
|
message: "At least one field must be provided"
|
|
1554
1643
|
});
|
|
1555
|
-
var ReplayWebhookRequestSchema =
|
|
1556
|
-
fromBlock:
|
|
1557
|
-
toBlock:
|
|
1558
|
-
force:
|
|
1644
|
+
var ReplayWebhookRequestSchema = z4.object({
|
|
1645
|
+
fromBlock: z4.number().int().nonnegative(),
|
|
1646
|
+
toBlock: z4.number().int().nonnegative(),
|
|
1647
|
+
force: z4.string().trim().min(1).max(64).optional()
|
|
1559
1648
|
}).refine((value) => value.fromBlock <= value.toBlock, {
|
|
1560
1649
|
message: "fromBlock must be less than or equal to toBlock",
|
|
1561
1650
|
path: ["toBlock"]
|
|
@@ -1997,6 +2086,61 @@ function generateSubgraphSpec(detail, format, options = {}) {
|
|
|
1997
2086
|
return generateSubgraphAgentSchema(detail, options);
|
|
1998
2087
|
return generateSubgraphMarkdown(detail, options);
|
|
1999
2088
|
}
|
|
2089
|
+
// src/subgraphs/health.ts
|
|
2090
|
+
var HOUR_MS = 3600000;
|
|
2091
|
+
function positiveDeltas(values) {
|
|
2092
|
+
let total = 0;
|
|
2093
|
+
let prev = null;
|
|
2094
|
+
for (const value of values) {
|
|
2095
|
+
if (value === null)
|
|
2096
|
+
continue;
|
|
2097
|
+
if (prev !== null && value > prev)
|
|
2098
|
+
total += value - prev;
|
|
2099
|
+
prev = value;
|
|
2100
|
+
}
|
|
2101
|
+
return total;
|
|
2102
|
+
}
|
|
2103
|
+
function toNumber(value) {
|
|
2104
|
+
if (value === null)
|
|
2105
|
+
return null;
|
|
2106
|
+
const n = Number(value);
|
|
2107
|
+
return Number.isFinite(n) ? n : null;
|
|
2108
|
+
}
|
|
2109
|
+
function bucketHourly(snapshots, hours, now = Date.now()) {
|
|
2110
|
+
const sorted = snapshots.map((s) => ({ ...s, at: new Date(s.captured_at).getTime() })).sort((a, b) => a.at - b.at);
|
|
2111
|
+
const currentHourStart = Math.floor(now / HOUR_MS) * HOUR_MS;
|
|
2112
|
+
const out = [];
|
|
2113
|
+
for (let i = hours - 1;i >= 0; i--) {
|
|
2114
|
+
const start = currentHourStart - i * HOUR_MS;
|
|
2115
|
+
const end = start + HOUR_MS;
|
|
2116
|
+
const inHour = sorted.filter((s) => s.at >= start && s.at < end);
|
|
2117
|
+
if (inHour.length === 0) {
|
|
2118
|
+
out.push({
|
|
2119
|
+
hour: new Date(start).toISOString(),
|
|
2120
|
+
lagBlocks: null,
|
|
2121
|
+
rowsWritten: 0,
|
|
2122
|
+
errors: 0,
|
|
2123
|
+
eventsHandled: 0
|
|
2124
|
+
});
|
|
2125
|
+
continue;
|
|
2126
|
+
}
|
|
2127
|
+
const before = sorted.filter((s) => s.at < start).at(-1);
|
|
2128
|
+
const series = before ? [before, ...inHour] : inHour;
|
|
2129
|
+
const lags = inHour.map((s) => {
|
|
2130
|
+
const tip = toNumber(s.chain_tip);
|
|
2131
|
+
const cursor = toNumber(s.last_processed_block);
|
|
2132
|
+
return tip === null || cursor === null ? null : Math.max(0, tip - cursor);
|
|
2133
|
+
}).filter((lag) => lag !== null);
|
|
2134
|
+
out.push({
|
|
2135
|
+
hour: new Date(start).toISOString(),
|
|
2136
|
+
lagBlocks: lags.length > 0 ? Math.max(...lags) : null,
|
|
2137
|
+
rowsWritten: positiveDeltas(series.map((s) => toNumber(s.rows_written_total))),
|
|
2138
|
+
errors: positiveDeltas(series.map((s) => toNumber(s.total_errors))),
|
|
2139
|
+
eventsHandled: positiveDeltas(series.map((s) => toNumber(s.total_processed)))
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
return out;
|
|
2143
|
+
}
|
|
2000
2144
|
// src/crypto/hmac.ts
|
|
2001
2145
|
var exports_hmac = {};
|
|
2002
2146
|
__export(exports_hmac, {
|
|
@@ -2118,12 +2262,19 @@ export {
|
|
|
2118
2262
|
EMPTY_RANGE_EVENT_INDEX_SENTINEL,
|
|
2119
2263
|
ErrorCodes,
|
|
2120
2264
|
ForbiddenError,
|
|
2265
|
+
INSIGHT_SEVERITIES,
|
|
2266
|
+
InsightEvidenceSchema,
|
|
2267
|
+
InsightListResponseSchema,
|
|
2268
|
+
InsightResourceKindSchema,
|
|
2269
|
+
InsightSchema,
|
|
2270
|
+
InsightSeveritySchema,
|
|
2121
2271
|
KeyRotatedError,
|
|
2122
2272
|
NotFoundError,
|
|
2123
2273
|
PaymentRequiredError,
|
|
2124
2274
|
RUNE_EVENT_TYPES,
|
|
2125
2275
|
RateLimitError,
|
|
2126
2276
|
ReplayWebhookRequestSchema,
|
|
2277
|
+
SEVERITY_ORDER,
|
|
2127
2278
|
SOURCE_READ_COLUMNS,
|
|
2128
2279
|
SOURCE_READ_PKS,
|
|
2129
2280
|
SOURCE_READ_TYPES,
|
|
@@ -2147,6 +2298,7 @@ export {
|
|
|
2147
2298
|
assertDbSplit,
|
|
2148
2299
|
billingPausedCode,
|
|
2149
2300
|
blockEndCursor,
|
|
2301
|
+
bucketHourly,
|
|
2150
2302
|
closeDb,
|
|
2151
2303
|
closeDbOrTimeout,
|
|
2152
2304
|
committedHeight,
|
|
@@ -2186,5 +2338,5 @@ export {
|
|
|
2186
2338
|
sql2 as sql
|
|
2187
2339
|
};
|
|
2188
2340
|
|
|
2189
|
-
//# debugId=
|
|
2341
|
+
//# debugId=D95357BE1793CC7464756E2164756E21
|
|
2190
2342
|
//# sourceMappingURL=index.js.map
|