@sqd-pipes/delta-db 0.0.1-alpha.1 → 0.0.1-alpha.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqd-pipes/delta-db",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "0.0.1-alpha.2",
4
4
  "description": "Embedded rollback-aware computation engine for blockchain data",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -11,8 +11,8 @@
11
11
  }
12
12
  },
13
13
  "scripts": {
14
- "build": "napi build --cargo-cwd ../.. --features napi --release",
15
- "build:debug": "napi build --cargo-cwd ../.. --features napi",
14
+ "build": "napi build --cargo-cwd ../../.. --features napi --release src",
15
+ "build:debug": "napi build --cargo-cwd ../../.. --features napi src",
16
16
  "test": "vitest run",
17
17
  "test:watch": "vitest"
18
18
  },
package/src/delta-db.node CHANGED
Binary file
package/src/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
1
6
  /** Configuration for opening a DeltaDb instance. */
2
7
  export interface DeltaDbConfig {
3
8
  /** SQL schema definition string. */
@@ -10,65 +15,49 @@ export interface DeltaDbConfig {
10
15
  /** Maximum buffer size before backpressure (default: 10000). */
11
16
  maxBufferSize?: number
12
17
  }
13
-
14
18
  /** Block cursor: number + hash. */
15
19
  export interface DeltaDbCursor {
16
20
  number: number
17
21
  hash: string
18
22
  }
19
-
20
- /** A single delta record. */
21
- export interface DeltaRecord {
22
- table: string
23
- operation: string
24
- key: Record<string, any>
25
- values: Record<string, any>
26
- prevValues?: Record<string, any> | null
27
- }
28
-
29
- /** A batch of delta records. */
30
- export interface DeltaBatch {
31
- sequence: number
32
- finalizedHead?: DeltaDbCursor | null
33
- latestHead?: DeltaDbCursor | null
34
- records: Array<DeltaRecord>
35
- }
36
-
37
23
  /** Input for the atomic `ingest()` method. */
38
24
  export interface IngestInput {
39
- /** Table name → rows. Rows must contain `block_number`. */
40
- data: Record<string, Array<Record<string, any>>>
25
+ /** Table name → rows, msgpack-encoded as `{tableName: [{col: val}, ...], ...}`. */
26
+ data: Buffer
41
27
  /** Unfinalized blocks with hashes for fork resolution. */
42
28
  rollbackChain?: Array<DeltaDbCursor>
43
29
  /** Finalized head cursor — both number and hash stored. */
44
30
  finalizedHead: DeltaDbCursor
45
31
  }
46
-
47
- /** Delta DB — embedded rollback-aware computation engine. */
32
+ /** Delta DB N-API wrapper. */
48
33
  export declare class DeltaDb {
49
34
  /** Open a new DeltaDb instance. */
50
35
  static open(config: DeltaDbConfig): DeltaDb
51
36
  /**
52
37
  * Process a batch of rows for a raw table.
38
+ * `rows` is a msgpack-encoded Buffer: `[{col: val, ...}, ...]`.
53
39
  * Returns true if backpressure should be applied.
54
40
  */
55
- processBatch(table: string, block: number, rows: Array<Record<string, any>>): boolean
41
+ processBatch(table: string, block: number, rows: Buffer): boolean
56
42
  /** Roll back all state after fork_point. */
57
43
  rollback(forkPoint: number): void
58
44
  /** Finalize all state up to and including the given block. */
59
45
  finalize(block: number): void
60
46
  /**
61
47
  * Atomic ingest: process all tables, store rollback chain, finalize, flush.
62
- * Returns the delta batch, or null if no records produced.
48
+ * Returns a msgpack-encoded DeltaBatch buffer, or null if no records produced.
63
49
  */
64
- ingest(input: IngestInput): DeltaBatch | null
50
+ ingest(input: IngestInput): Buffer | null
65
51
  /**
66
52
  * Find the common ancestor between our state and the Portal's chain.
67
53
  * Returns the matching block cursor, or null if no common ancestor found.
68
54
  */
69
55
  resolveForkCursor(previousBlocks: Array<DeltaDbCursor>): DeltaDbCursor | null
70
- /** Flush buffered deltas into a batch. Returns null if no pending records. */
71
- flush(): DeltaBatch | null
56
+ /**
57
+ * Flush buffered deltas into a msgpack-encoded batch.
58
+ * Returns null if no pending records.
59
+ */
60
+ flush(): Buffer | null
72
61
  /** Acknowledge a flushed batch by sequence number. */
73
62
  ack(sequence: number): void
74
63
  /** Number of pending (unflushed) delta records. */