@secondlayer/subgraphs 3.14.4 → 3.15.1

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.
@@ -281,6 +281,8 @@ class SubgraphContext {
281
281
  return this.overlayMany(table, where, dbRows);
282
282
  }
283
283
  overlayOne(table, where, dbRow) {
284
+ if (this.ops.length === 0)
285
+ return dbRow;
284
286
  let row = dbRow;
285
287
  for (const op of this.ops) {
286
288
  if (op.table !== table)
@@ -290,12 +292,17 @@ class SubgraphContext {
290
292
  return row;
291
293
  }
292
294
  overlayMany(table, where, dbRows) {
295
+ if (this.ops.length === 0)
296
+ return [...dbRows];
293
297
  let result = [...dbRows];
294
298
  for (const op of this.ops) {
295
299
  if (op.table !== table)
296
300
  continue;
297
301
  if (op.kind === "update") {
298
- result = result.map((r) => rowMatches(r, op.data) ? { ...r, ...op.set ?? {} } : r);
302
+ for (let i = 0;i < result.length; i++) {
303
+ if (rowMatches(result[i], op.data))
304
+ result[i] = { ...result[i], ...op.set ?? {} };
305
+ }
299
306
  } else if (op.kind === "delete") {
300
307
  result = result.filter((r) => !rowMatches(r, op.data));
301
308
  } else {
@@ -303,7 +310,8 @@ class SubgraphContext {
303
310
  const clean = stripControlKeys(op.data);
304
311
  const idx = upsertKeys ? result.findIndex((r) => upsertKeys.every((k) => valEq(r[k], clean[k]))) : -1;
305
312
  if (idx >= 0) {
306
- result[idx] = this.applyOpToRow(op, result[idx], where) ?? result[idx];
313
+ const existing = result[idx];
314
+ result[idx] = this.applyOpToRow(op, existing, where) ?? existing;
307
315
  } else {
308
316
  const created = this.applyOpToRow(op, null, where);
309
317
  if (created)
@@ -3003,7 +3011,8 @@ async function handleSubgraphReorg(blockHeight, loadSubgraphDef) {
3003
3011
  }).as("row_pk"),
3004
3012
  eb2.val("pending").as("status")
3005
3013
  ]).where("subgraph_name", "=", sg.name).where("table_name", "=", tableName).where("status", "=", "active")).onConflict((oc) => oc.column("dedup_key").doNothing()).execute().catch((err) => {
3006
- logger8.warn("Failed to emit revert event for subscriptions", {
3014
+ logger8.error("Failed to emit revert event for subscriptions", {
3015
+ event: "reorg_revert_emit_dropped",
3007
3016
  subgraph: sg.name,
3008
3017
  table: tableName,
3009
3018
  blockHeight,
@@ -3494,5 +3503,5 @@ export {
3494
3503
  startSubgraphOperationRunner
3495
3504
  };
3496
3505
 
3497
- //# debugId=1DEB7C89274A13F064756E2164756E21
3506
+ //# debugId=77CBB7AC98ED393264756E2164756E21
3498
3507
  //# sourceMappingURL=processor.js.map