@secondlayer/shared 6.7.0 → 6.8.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.
@@ -305,6 +305,9 @@ interface DecodedEventsTable {
305
305
  asset_identifier: string | null;
306
306
  value: string | null;
307
307
  memo: string | null;
308
+ /** Decoded payload for event types that don't fit the flat columns
309
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
310
+ payload: unknown | null;
308
311
  source_cursor: string;
309
312
  created_at: Generated<Date>;
310
313
  }
@@ -286,6 +286,9 @@ interface DecodedEventsTable {
286
286
  asset_identifier: string | null;
287
287
  value: string | null;
288
288
  memo: string | null;
289
+ /** Decoded payload for event types that don't fit the flat columns
290
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
291
+ payload: unknown | null;
289
292
  source_cursor: string;
290
293
  created_at: Generated<Date>;
291
294
  }
@@ -287,6 +287,9 @@ interface DecodedEventsTable {
287
287
  asset_identifier: string | null;
288
288
  value: string | null;
289
289
  memo: string | null;
290
+ /** Decoded payload for event types that don't fit the flat columns
291
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
292
+ payload: unknown | null;
290
293
  source_cursor: string;
291
294
  created_at: Generated<Date>;
292
295
  }
@@ -287,6 +287,9 @@ interface DecodedEventsTable {
287
287
  asset_identifier: string | null;
288
288
  value: string | null;
289
289
  memo: string | null;
290
+ /** Decoded payload for event types that don't fit the flat columns
291
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
292
+ payload: unknown | null;
290
293
  source_cursor: string;
291
294
  created_at: Generated<Date>;
292
295
  }
@@ -287,6 +287,9 @@ interface DecodedEventsTable {
287
287
  asset_identifier: string | null;
288
288
  value: string | null;
289
289
  memo: string | null;
290
+ /** Decoded payload for event types that don't fit the flat columns
291
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
292
+ payload: unknown | null;
290
293
  source_cursor: string;
291
294
  created_at: Generated<Date>;
292
295
  }
@@ -287,6 +287,9 @@ interface DecodedEventsTable {
287
287
  asset_identifier: string | null;
288
288
  value: string | null;
289
289
  memo: string | null;
290
+ /** Decoded payload for event types that don't fit the flat columns
291
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
292
+ payload: unknown | null;
290
293
  source_cursor: string;
291
294
  created_at: Generated<Date>;
292
295
  }
@@ -287,6 +287,9 @@ interface DecodedEventsTable {
287
287
  asset_identifier: string | null;
288
288
  value: string | null;
289
289
  memo: string | null;
290
+ /** Decoded payload for event types that don't fit the flat columns
291
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
292
+ payload: unknown | null;
290
293
  source_cursor: string;
291
294
  created_at: Generated<Date>;
292
295
  }
@@ -286,6 +286,9 @@ interface DecodedEventsTable {
286
286
  asset_identifier: string | null;
287
287
  value: string | null;
288
288
  memo: string | null;
289
+ /** Decoded payload for event types that don't fit the flat columns
290
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
291
+ payload: unknown | null;
289
292
  source_cursor: string;
290
293
  created_at: Generated<Date>;
291
294
  }
@@ -286,6 +286,9 @@ interface DecodedEventsTable {
286
286
  asset_identifier: string | null;
287
287
  value: string | null;
288
288
  memo: string | null;
289
+ /** Decoded payload for event types that don't fit the flat columns
290
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
291
+ payload: unknown | null;
289
292
  source_cursor: string;
290
293
  created_at: Generated<Date>;
291
294
  }
@@ -287,6 +287,9 @@ interface DecodedEventsTable {
287
287
  asset_identifier: string | null;
288
288
  value: string | null;
289
289
  memo: string | null;
290
+ /** Decoded payload for event types that don't fit the flat columns
291
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
292
+ payload: unknown | null;
290
293
  source_cursor: string;
291
294
  created_at: Generated<Date>;
292
295
  }
@@ -0,0 +1,12 @@
1
+ import { type Kysely, sql } from "kysely";
2
+
3
+ // Adds a generic JSONB column for decoded event types whose payload doesn't fit
4
+ // the flat transfer columns — first consumer is `print` (topic + decoded Clarity
5
+ // value + raw hex). Nullable; every existing transfer row leaves it null.
6
+ export async function up(db: Kysely<unknown>): Promise<void> {
7
+ await sql`ALTER TABLE decoded_events ADD COLUMN payload JSONB`.execute(db);
8
+ }
9
+
10
+ export async function down(db: Kysely<unknown>): Promise<void> {
11
+ await sql`ALTER TABLE decoded_events DROP COLUMN payload`.execute(db);
12
+ }
@@ -0,0 +1,22 @@
1
+ import { type Kysely, sql } from "kysely";
2
+
3
+ // Composite index backing the l2-decoder /health freshness probe
4
+ // (`readLatestDecodedAt`): `WHERE event_type = ? AND canonical = ?
5
+ // ORDER BY created_at DESC LIMIT 1`. Without it that query seq-scans the
6
+ // full decoded_events table (~18GB) and sorts millions of rows per call;
7
+ // /health fans it out per decoder, so under load Postgres pinned several
8
+ // cores. With this index it's an instant index-only scan.
9
+ //
10
+ // Already created CONCURRENTLY on prod; IF NOT EXISTS makes this a no-op
11
+ // there and a cheap build on fresh/dev databases (small data).
12
+ export async function up(db: Kysely<unknown>): Promise<void> {
13
+ await sql`CREATE INDEX IF NOT EXISTS decoded_events_evt_canon_created_idx ON decoded_events (event_type, canonical, created_at DESC)`.execute(
14
+ db,
15
+ );
16
+ }
17
+
18
+ export async function down(db: Kysely<unknown>): Promise<void> {
19
+ await sql`DROP INDEX IF EXISTS decoded_events_evt_canon_created_idx`.execute(
20
+ db,
21
+ );
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/shared",
3
- "version": "6.7.0",
3
+ "version": "6.8.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",