@secondlayer/shared 7.5.1 → 7.7.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.
@@ -0,0 +1,54 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onChainPlane } from "../src/db/migration-role.ts";
3
+
4
+ /**
5
+ * Durable receipt log for state-affecting Stacks observer callbacks.
6
+ *
7
+ * The raw body is immutable evidence. Processing fields are deliberately
8
+ * separate so a callback can be recovered and replayed if the indexer dies
9
+ * after the receipt is durable but before derived state commits.
10
+ */
11
+ export async function up(db: Kysely<unknown>): Promise<void> {
12
+ await onChainPlane(async () => {
13
+ await sql`SET lock_timeout = '30s'`.execute(db);
14
+
15
+ await sql`
16
+ CREATE TABLE IF NOT EXISTS observer_journal (
17
+ sequence BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
18
+ network TEXT NOT NULL,
19
+ path TEXT NOT NULL,
20
+ source TEXT,
21
+ received_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
22
+ raw_body BYTEA NOT NULL,
23
+ raw_body_sha256 TEXT NOT NULL,
24
+ status TEXT NOT NULL DEFAULT 'received',
25
+ semantic_sha256 TEXT,
26
+ block_height BIGINT,
27
+ block_hash TEXT,
28
+ burn_block_height BIGINT,
29
+ burn_block_hash TEXT,
30
+ result JSONB,
31
+ error TEXT,
32
+ processed_at TIMESTAMPTZ,
33
+ CONSTRAINT observer_journal_status_check
34
+ CHECK (status IN ('received', 'processed', 'failed'))
35
+ )
36
+ `.execute(db);
37
+
38
+ await sql`
39
+ CREATE INDEX IF NOT EXISTS observer_journal_path_sequence_idx
40
+ ON observer_journal (path, sequence)
41
+ `.execute(db);
42
+
43
+ await sql`
44
+ CREATE INDEX IF NOT EXISTS observer_journal_status_sequence_idx
45
+ ON observer_journal (status, sequence)
46
+ `.execute(db);
47
+ });
48
+ }
49
+
50
+ export async function down(db: Kysely<unknown>): Promise<void> {
51
+ await onChainPlane(async () => {
52
+ await sql`DROP TABLE IF EXISTS observer_journal`.execute(db);
53
+ });
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/shared",
3
- "version": "7.5.1",
3
+ "version": "7.7.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -108,6 +108,14 @@
108
108
  "types": "./dist/src/streams-bulk-manifest.d.ts",
109
109
  "import": "./dist/src/streams-bulk-manifest.js"
110
110
  },
111
+ "./archive/copy-loader": {
112
+ "types": "./dist/src/archive/copy-loader.d.ts",
113
+ "import": "./dist/src/archive/copy-loader.js"
114
+ },
115
+ "./archive/range-digest": {
116
+ "types": "./dist/src/archive/range-digest.d.ts",
117
+ "import": "./dist/src/archive/range-digest.js"
118
+ },
111
119
  "./errors": {
112
120
  "types": "./dist/src/errors.d.ts",
113
121
  "import": "./dist/src/errors.js"