@secondlayer/subgraphs 3.26.1 → 3.26.3

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.
@@ -16,6 +16,13 @@ function quotePgIdent(name) {
16
16
  return name;
17
17
  return `"${name.replace(/"/g, '""')}"`;
18
18
  }
19
+ function snakeToCamel(name) {
20
+ return name.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
21
+ }
22
+ function pascalCase(name) {
23
+ const camel = snakeToCamel(name);
24
+ return camel.charAt(0).toUpperCase() + camel.slice(1);
25
+ }
19
26
 
20
27
  // src/schema/generator.ts
21
28
  var TYPE_MAP = {
@@ -3045,7 +3052,7 @@ class StatsAccumulator {
3045
3052
  }
3046
3053
 
3047
3054
  // src/runtime/catchup.ts
3048
- import { getTargetDb as getTargetDb2 } from "@secondlayer/shared/db";
3055
+ import { getTargetDb as getTargetDb2, sql as sql4 } from "@secondlayer/shared/db";
3049
3056
  import { getSubgraph } from "@secondlayer/shared/db/queries/subgraphs";
3050
3057
  import { logger as logger8 } from "@secondlayer/shared/logger";
3051
3058
 
@@ -3116,6 +3123,15 @@ async function withSubgraphBlockLock(name, fn) {
3116
3123
  release();
3117
3124
  }
3118
3125
  }
3126
+ async function withSubgraphBlockAdvisoryLock(name, fn) {
3127
+ return getTargetDb2().transaction().execute(async (lockTx) => {
3128
+ await sql4`SELECT pg_advisory_xact_lock(hashtext(${`subgraph-block:${name}`}))`.execute(lockTx);
3129
+ return fn();
3130
+ });
3131
+ }
3132
+ async function withSubgraphBlockWriteLock(name, fn) {
3133
+ return withSubgraphBlockLock(name, () => withSubgraphBlockAdvisoryLock(name, fn));
3134
+ }
3119
3135
  function bumpReorgEpoch(name) {
3120
3136
  reorgEpoch.set(name, (reorgEpoch.get(name) ?? 0) + 1);
3121
3137
  }
@@ -3244,7 +3260,7 @@ async function catchUpSubgraph(subgraph, subgraphName) {
3244
3260
  const preloaded = blockData;
3245
3261
  let result;
3246
3262
  try {
3247
- result = await withSubgraphBlockLock(subgraphName, async () => {
3263
+ result = await withSubgraphBlockWriteLock(subgraphName, async () => {
3248
3264
  if (getReorgEpoch(subgraphName) !== walkEpoch) {
3249
3265
  throw new ReorgEpochChangedError(subgraphName);
3250
3266
  }
@@ -3312,7 +3328,7 @@ import {
3312
3328
  resolveSubgraphRawClient
3313
3329
  } from "@secondlayer/shared/db/queries/subgraphs";
3314
3330
  import { logger as logger9 } from "@secondlayer/shared/logger";
3315
- import { sql as sql4 } from "kysely";
3331
+ import { sql as sql5 } from "kysely";
3316
3332
  async function handleSubgraphReorg(blockHeight, loadSubgraphDef) {
3317
3333
  const targetDb = getTargetDb3();
3318
3334
  const activeSubgraphs = (await listSubgraphs(targetDb)).filter((v) => v.status === "active");
@@ -3330,7 +3346,7 @@ async function handleSubgraphReorg(blockHeight, loadSubgraphDef) {
3330
3346
  bumpReorgEpoch(sg.name);
3331
3347
  await withSubgraphBlockLock(sg.name, async () => {
3332
3348
  await getTargetDb3().transaction().execute(async (lockTx) => {
3333
- await sql4`SELECT pg_advisory_xact_lock(hashtext(${`subgraph-reorg:${sg.name}`}))`.execute(lockTx);
3349
+ await sql5`SELECT pg_advisory_xact_lock(hashtext(${`subgraph-reorg:${sg.name}`}))`.execute(lockTx);
3334
3350
  await reorgOneSubgraph(sg, schema, blockHeight, loadSubgraphDef);
3335
3351
  });
3336
3352
  });
@@ -3441,5 +3457,5 @@ export {
3441
3457
  handleSubgraphReorg
3442
3458
  };
3443
3459
 
3444
- //# debugId=9D5D02929028624564756E2164756E21
3460
+ //# debugId=2EEB85F9F0ECD1CF64756E2164756E21
3445
3461
  //# sourceMappingURL=reorg.js.map