@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
package/dist/src/index.js
CHANGED
|
@@ -242,6 +242,13 @@ var TYPE_MAP = {
|
|
|
242
242
|
timestamp: "TIMESTAMPTZ",
|
|
243
243
|
jsonb: "JSONB"
|
|
244
244
|
};
|
|
245
|
+
var MAX_IDENT_BYTES = 63;
|
|
246
|
+
function safeIndexName(name) {
|
|
247
|
+
if (name.length <= MAX_IDENT_BYTES)
|
|
248
|
+
return name;
|
|
249
|
+
const hash = createHash("sha256").update(name).digest("hex").slice(0, 8);
|
|
250
|
+
return `${name.slice(0, MAX_IDENT_BYTES - hash.length - 1)}_${hash}`;
|
|
251
|
+
}
|
|
245
252
|
function escapeLiteralDefault(value) {
|
|
246
253
|
if (value === null || value === undefined)
|
|
247
254
|
return "NULL";
|
|
@@ -284,6 +291,7 @@ function emitTableDDL(schemaName, tableName, tableDef) {
|
|
|
284
291
|
for (const [colName, col] of Object.entries(tableDef.columns)) {
|
|
285
292
|
if (col.indexed) {
|
|
286
293
|
statements.push(`CREATE INDEX IF NOT EXISTS ${quotePgIdent(`idx_${schemaName}_${tableName}_${colName}`)} ON ${qualifiedName} (${quotePgIdent(colName)})`);
|
|
294
|
+
statements.push(`CREATE INDEX IF NOT EXISTS ${quotePgIdent(safeIndexName(`idx_${schemaName}_${tableName}_${colName}_id`))} ON ${qualifiedName} (${quotePgIdent(colName)}, ${quotePgIdent("_id")})`);
|
|
287
295
|
}
|
|
288
296
|
}
|
|
289
297
|
for (const [colName, col] of Object.entries(tableDef.columns)) {
|
|
@@ -1842,6 +1850,7 @@ function matchSources(sources, transactions, events, traitContracts = new Map, f
|
|
|
1842
1850
|
}
|
|
1843
1851
|
|
|
1844
1852
|
// src/runtime/block-processor.ts
|
|
1853
|
+
import { secretsKeyAvailable } from "@secondlayer/shared/crypto/secrets";
|
|
1845
1854
|
import { getTargetDb } from "@secondlayer/shared/db";
|
|
1846
1855
|
import { resolveTraitContractIds } from "@secondlayer/shared/db/queries/contracts";
|
|
1847
1856
|
import { advanceOperationCursor } from "@secondlayer/shared/db/queries/subgraph-operations";
|
|
@@ -2779,12 +2788,22 @@ async function refreshMatcher(db) {
|
|
|
2779
2788
|
|
|
2780
2789
|
// src/runtime/block-processor.ts
|
|
2781
2790
|
var routeCache = new Map;
|
|
2791
|
+
|
|
2792
|
+
class ByoKeyUnavailableError extends Error {
|
|
2793
|
+
constructor(subgraphName) {
|
|
2794
|
+
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.`);
|
|
2795
|
+
this.name = "ByoKeyUnavailableError";
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2782
2798
|
async function resolveRoute(subgraphName, targetDb) {
|
|
2783
2799
|
const cached = routeCache.get(subgraphName);
|
|
2784
2800
|
if (cached)
|
|
2785
2801
|
return cached;
|
|
2786
2802
|
const row = await targetDb.selectFrom("subgraphs").selectAll().where("name", "=", subgraphName).executeTakeFirst();
|
|
2787
2803
|
const byo = row ? isByoSubgraph(row) : false;
|
|
2804
|
+
if (row && byo && !secretsKeyAvailable()) {
|
|
2805
|
+
throw new ByoKeyUnavailableError(subgraphName);
|
|
2806
|
+
}
|
|
2788
2807
|
const route = {
|
|
2789
2808
|
schemaName: row?.schema_name ?? pgSchemaName(subgraphName),
|
|
2790
2809
|
dataDb: row && byo ? resolveSubgraphDb(row) : targetDb,
|
|
@@ -5063,5 +5082,5 @@ export {
|
|
|
5063
5082
|
ByoBreakingChangeError
|
|
5064
5083
|
};
|
|
5065
5084
|
|
|
5066
|
-
//# debugId=
|
|
5085
|
+
//# debugId=4073E46E0CD7575564756E2164756E21
|
|
5067
5086
|
//# sourceMappingURL=index.js.map
|