@secondlayer/subgraphs 3.24.2 → 3.25.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/index.js +20 -1
- package/dist/src/index.js.map +4 -4
- package/dist/src/runtime/block-processor.d.ts +12 -1
- package/dist/src/runtime/block-processor.js +21 -1
- package/dist/src/runtime/block-processor.js.map +4 -4
- package/dist/src/runtime/catchup.js +20 -1
- package/dist/src/runtime/catchup.js.map +4 -4
- package/dist/src/runtime/context.js +9 -1
- package/dist/src/runtime/context.js.map +3 -3
- package/dist/src/runtime/processor.js +20 -1
- package/dist/src/runtime/processor.js.map +4 -4
- package/dist/src/runtime/reindex.js +20 -1
- package/dist/src/runtime/reindex.js.map +4 -4
- package/dist/src/runtime/reorg.js +20 -1
- package/dist/src/runtime/reorg.js.map +4 -4
- package/dist/src/schema/index.js +9 -1
- package/dist/src/schema/index.js.map +3 -3
- package/dist/src/service.js +20 -1
- package/dist/src/service.js.map +4 -4
- package/dist/src/testing/index.js +9 -1
- package/dist/src/testing/index.js.map +3 -3
- package/package.json +2 -2
|
@@ -27,6 +27,13 @@ var TYPE_MAP = {
|
|
|
27
27
|
timestamp: "TIMESTAMPTZ",
|
|
28
28
|
jsonb: "JSONB"
|
|
29
29
|
};
|
|
30
|
+
var MAX_IDENT_BYTES = 63;
|
|
31
|
+
function safeIndexName(name) {
|
|
32
|
+
if (name.length <= MAX_IDENT_BYTES)
|
|
33
|
+
return name;
|
|
34
|
+
const hash = createHash("sha256").update(name).digest("hex").slice(0, 8);
|
|
35
|
+
return `${name.slice(0, MAX_IDENT_BYTES - hash.length - 1)}_${hash}`;
|
|
36
|
+
}
|
|
30
37
|
function escapeLiteralDefault(value) {
|
|
31
38
|
if (value === null || value === undefined)
|
|
32
39
|
return "NULL";
|
|
@@ -69,6 +76,7 @@ function emitTableDDL(schemaName, tableName, tableDef) {
|
|
|
69
76
|
for (const [colName, col] of Object.entries(tableDef.columns)) {
|
|
70
77
|
if (col.indexed) {
|
|
71
78
|
statements.push(`CREATE INDEX IF NOT EXISTS ${quotePgIdent(`idx_${schemaName}_${tableName}_${colName}`)} ON ${qualifiedName} (${quotePgIdent(colName)})`);
|
|
79
|
+
statements.push(`CREATE INDEX IF NOT EXISTS ${quotePgIdent(safeIndexName(`idx_${schemaName}_${tableName}_${colName}_id`))} ON ${qualifiedName} (${quotePgIdent(colName)}, ${quotePgIdent("_id")})`);
|
|
72
80
|
}
|
|
73
81
|
}
|
|
74
82
|
for (const [colName, col] of Object.entries(tableDef.columns)) {
|
|
@@ -1627,6 +1635,7 @@ function matchSources(sources, transactions, events, traitContracts = new Map, f
|
|
|
1627
1635
|
}
|
|
1628
1636
|
|
|
1629
1637
|
// src/runtime/block-processor.ts
|
|
1638
|
+
import { secretsKeyAvailable } from "@secondlayer/shared/crypto/secrets";
|
|
1630
1639
|
import { getTargetDb } from "@secondlayer/shared/db";
|
|
1631
1640
|
import { resolveTraitContractIds } from "@secondlayer/shared/db/queries/contracts";
|
|
1632
1641
|
import { advanceOperationCursor } from "@secondlayer/shared/db/queries/subgraph-operations";
|
|
@@ -2564,12 +2573,22 @@ async function refreshMatcher(db) {
|
|
|
2564
2573
|
|
|
2565
2574
|
// src/runtime/block-processor.ts
|
|
2566
2575
|
var routeCache = new Map;
|
|
2576
|
+
|
|
2577
|
+
class ByoKeyUnavailableError extends Error {
|
|
2578
|
+
constructor(subgraphName) {
|
|
2579
|
+
super(`subgraph ${subgraphName} is BYO (database_url_enc set) but this process has no SECONDLAYER_SECRETS_KEY — the subgraph processor deliberately does not hold it (f072). Route BYO subgraphs to a process that does, or unset BYO.`);
|
|
2580
|
+
this.name = "ByoKeyUnavailableError";
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2567
2583
|
async function resolveRoute(subgraphName, targetDb) {
|
|
2568
2584
|
const cached = routeCache.get(subgraphName);
|
|
2569
2585
|
if (cached)
|
|
2570
2586
|
return cached;
|
|
2571
2587
|
const row = await targetDb.selectFrom("subgraphs").selectAll().where("name", "=", subgraphName).executeTakeFirst();
|
|
2572
2588
|
const byo = row ? isByoSubgraph(row) : false;
|
|
2589
|
+
if (row && byo && !secretsKeyAvailable()) {
|
|
2590
|
+
throw new ByoKeyUnavailableError(subgraphName);
|
|
2591
|
+
}
|
|
2573
2592
|
const route = {
|
|
2574
2593
|
schemaName: row?.schema_name ?? pgSchemaName(subgraphName),
|
|
2575
2594
|
dataDb: row && byo ? resolveSubgraphDb(row) : targetDb,
|
|
@@ -3398,5 +3417,5 @@ export {
|
|
|
3398
3417
|
handleSubgraphReorg
|
|
3399
3418
|
};
|
|
3400
3419
|
|
|
3401
|
-
//# debugId=
|
|
3420
|
+
//# debugId=98FB8939ACF3110F64756E2164756E21
|
|
3402
3421
|
//# sourceMappingURL=reorg.js.map
|