@apibara/indexer 2.0.0-beta.5 → 2.0.0-beta.7
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/dist/index.cjs +50 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.mjs +34 -0
- package/dist/plugins/index.cjs +7 -0
- package/dist/plugins/index.d.cts +4 -0
- package/dist/plugins/index.d.mts +4 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.mjs +5 -0
- package/dist/plugins/kv.cjs +131 -0
- package/dist/plugins/kv.d.cts +32 -0
- package/dist/plugins/kv.d.mts +32 -0
- package/dist/plugins/kv.d.ts +32 -0
- package/dist/plugins/kv.mjs +124 -0
- package/dist/plugins/persistence.cjs +182 -0
- package/dist/plugins/persistence.d.cts +50 -0
- package/dist/plugins/persistence.d.mts +50 -0
- package/dist/plugins/persistence.d.ts +50 -0
- package/dist/plugins/persistence.mjs +179 -0
- package/dist/shared/indexer.2c23c9cd.mjs +35 -0
- package/dist/shared/indexer.318d3617.cjs +47 -0
- package/dist/shared/indexer.36530330.mjs +249 -0
- package/dist/shared/indexer.500fd281.d.cts +23 -0
- package/dist/shared/indexer.541d43eb.cjs +266 -0
- package/dist/shared/indexer.93d6b2eb.mjs +17 -0
- package/dist/shared/indexer.a8b7ab1f.cjs +25 -0
- package/dist/shared/indexer.b9c8f0d8.d.cts +19 -0
- package/dist/shared/indexer.b9c8f0d8.d.mts +19 -0
- package/dist/shared/indexer.b9c8f0d8.d.ts +19 -0
- package/dist/shared/indexer.c7ed6b83.d.cts +82 -0
- package/dist/shared/indexer.e1856641.d.mts +23 -0
- package/dist/shared/indexer.e4f2430f.d.ts +23 -0
- package/dist/shared/indexer.e8bd138d.d.mts +82 -0
- package/dist/shared/indexer.f761abcd.d.ts +82 -0
- package/dist/sinks/csv.cjs +85 -0
- package/dist/sinks/csv.d.cts +66 -0
- package/dist/sinks/csv.d.mts +66 -0
- package/dist/sinks/csv.d.ts +66 -0
- package/dist/sinks/csv.mjs +78 -0
- package/dist/sinks/drizzle/index.cjs +210 -0
- package/dist/sinks/drizzle/index.d.cts +111 -0
- package/dist/sinks/drizzle/index.d.mts +111 -0
- package/dist/sinks/drizzle/index.d.ts +111 -0
- package/dist/sinks/drizzle/index.mjs +196 -0
- package/dist/sinks/sqlite.cjs +90 -0
- package/dist/sinks/sqlite.d.cts +71 -0
- package/dist/sinks/sqlite.d.mts +71 -0
- package/dist/sinks/sqlite.d.ts +71 -0
- package/dist/sinks/sqlite.mjs +87 -0
- package/dist/testing/index.cjs +64 -0
- package/dist/testing/index.d.cts +40 -0
- package/dist/testing/index.d.mts +40 -0
- package/dist/testing/index.d.ts +40 -0
- package/dist/testing/index.mjs +60 -0
- package/dist/vcr/index.cjs +25 -0
- package/dist/vcr/index.d.cts +18 -0
- package/dist/vcr/index.d.mts +18 -0
- package/dist/vcr/index.d.ts +18 -0
- package/dist/vcr/index.mjs +14 -0
- package/package.json +33 -11
- package/src/vcr/record.ts +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as vitest from 'vitest';
|
|
2
|
+
import { f as Indexer } from '../shared/indexer.e8bd138d.mjs';
|
|
3
|
+
import { a as VcrReplayResult } from '../shared/indexer.e1856641.mjs';
|
|
4
|
+
import { Cursor } from '@apibara/protocol';
|
|
5
|
+
import { S as Sink, b as SinkData, a as SinkCursorParams } from '../shared/indexer.b9c8f0d8.mjs';
|
|
6
|
+
import { MockStreamResponse } from '@apibara/protocol/testing';
|
|
7
|
+
import 'hookable';
|
|
8
|
+
|
|
9
|
+
declare const test: vitest.TestAPI<{
|
|
10
|
+
vcr: {
|
|
11
|
+
withClient: typeof withClient;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
type WithClientContext<TFilter, TBlock, TTxnParams> = {
|
|
15
|
+
run: (indexerArgs: Indexer<TFilter, TBlock, TTxnParams>) => Promise<VcrReplayResult>;
|
|
16
|
+
};
|
|
17
|
+
declare function withClient<TFilter, TBlock, TTxnParams>(cassetteName: string, range: {
|
|
18
|
+
fromBlock: bigint;
|
|
19
|
+
toBlock: bigint;
|
|
20
|
+
}, callback: (context: WithClientContext<TFilter, TBlock, TTxnParams>) => Promise<void>): Promise<void>;
|
|
21
|
+
|
|
22
|
+
type TxnParams = {
|
|
23
|
+
writer: {
|
|
24
|
+
insert: (data: SinkData[]) => void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare class VcrSink extends Sink {
|
|
28
|
+
result: VcrReplayResult["outputs"];
|
|
29
|
+
write({ data, endCursor }: {
|
|
30
|
+
data: SinkData[];
|
|
31
|
+
endCursor?: Cursor;
|
|
32
|
+
}): void;
|
|
33
|
+
transaction({ cursor, endCursor, finality }: SinkCursorParams, cb: (params: TxnParams) => Promise<void>): Promise<void>;
|
|
34
|
+
invalidate(cursor?: Cursor): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
declare function vcr(): VcrSink;
|
|
37
|
+
|
|
38
|
+
declare function generateMockMessages(count?: number): MockStreamResponse[];
|
|
39
|
+
|
|
40
|
+
export { VcrSink, generateMockMessages, test, vcr };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as vitest from 'vitest';
|
|
2
|
+
import { f as Indexer } from '../shared/indexer.f761abcd.js';
|
|
3
|
+
import { a as VcrReplayResult } from '../shared/indexer.e4f2430f.js';
|
|
4
|
+
import { Cursor } from '@apibara/protocol';
|
|
5
|
+
import { S as Sink, b as SinkData, a as SinkCursorParams } from '../shared/indexer.b9c8f0d8.js';
|
|
6
|
+
import { MockStreamResponse } from '@apibara/protocol/testing';
|
|
7
|
+
import 'hookable';
|
|
8
|
+
|
|
9
|
+
declare const test: vitest.TestAPI<{
|
|
10
|
+
vcr: {
|
|
11
|
+
withClient: typeof withClient;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
type WithClientContext<TFilter, TBlock, TTxnParams> = {
|
|
15
|
+
run: (indexerArgs: Indexer<TFilter, TBlock, TTxnParams>) => Promise<VcrReplayResult>;
|
|
16
|
+
};
|
|
17
|
+
declare function withClient<TFilter, TBlock, TTxnParams>(cassetteName: string, range: {
|
|
18
|
+
fromBlock: bigint;
|
|
19
|
+
toBlock: bigint;
|
|
20
|
+
}, callback: (context: WithClientContext<TFilter, TBlock, TTxnParams>) => Promise<void>): Promise<void>;
|
|
21
|
+
|
|
22
|
+
type TxnParams = {
|
|
23
|
+
writer: {
|
|
24
|
+
insert: (data: SinkData[]) => void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare class VcrSink extends Sink {
|
|
28
|
+
result: VcrReplayResult["outputs"];
|
|
29
|
+
write({ data, endCursor }: {
|
|
30
|
+
data: SinkData[];
|
|
31
|
+
endCursor?: Cursor;
|
|
32
|
+
}): void;
|
|
33
|
+
transaction({ cursor, endCursor, finality }: SinkCursorParams, cb: (params: TxnParams) => Promise<void>): Promise<void>;
|
|
34
|
+
invalidate(cursor?: Cursor): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
declare function vcr(): VcrSink;
|
|
37
|
+
|
|
38
|
+
declare function generateMockMessages(count?: number): MockStreamResponse[];
|
|
39
|
+
|
|
40
|
+
export { VcrSink, generateMockMessages, test, vcr };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { test as test$1 } from 'vitest';
|
|
2
|
+
import { i as isCassetteAvailable } from '../shared/indexer.2c23c9cd.mjs';
|
|
3
|
+
import { l as loadCassette, a as record, b as replay } from '../shared/indexer.36530330.mjs';
|
|
4
|
+
export { V as VcrSink, v as vcr } from '../shared/indexer.36530330.mjs';
|
|
5
|
+
import 'node:async_hooks';
|
|
6
|
+
import 'unctx';
|
|
7
|
+
import '@opentelemetry/api';
|
|
8
|
+
import 'node:fs';
|
|
9
|
+
import 'node:path';
|
|
10
|
+
import 'node:fs/promises';
|
|
11
|
+
import 'klona/full';
|
|
12
|
+
import 'consola';
|
|
13
|
+
import 'hookable';
|
|
14
|
+
import 'node:assert';
|
|
15
|
+
import '../shared/indexer.93d6b2eb.mjs';
|
|
16
|
+
import '@apibara/protocol/testing';
|
|
17
|
+
|
|
18
|
+
const test = test$1.extend({
|
|
19
|
+
vcr: {
|
|
20
|
+
withClient
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
async function withClient(cassetteName, range, callback) {
|
|
24
|
+
const vcrConfig = {
|
|
25
|
+
cassetteDir: "cassettes"
|
|
26
|
+
};
|
|
27
|
+
const cassetteOptions = {
|
|
28
|
+
name: cassetteName,
|
|
29
|
+
startingCursor: {
|
|
30
|
+
orderKey: range.fromBlock
|
|
31
|
+
},
|
|
32
|
+
endingCursor: {
|
|
33
|
+
orderKey: range.toBlock
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const context = {
|
|
37
|
+
async run(indexer) {
|
|
38
|
+
const client = loadCassette(vcrConfig, cassetteName);
|
|
39
|
+
if (!isCassetteAvailable(vcrConfig, cassetteName)) {
|
|
40
|
+
await record(vcrConfig, client, indexer, cassetteOptions);
|
|
41
|
+
}
|
|
42
|
+
return await replay(vcrConfig, indexer, cassetteName);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
await callback(context);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function generateMockMessages(count = 10) {
|
|
49
|
+
return [...Array(count)].map((_, i) => ({
|
|
50
|
+
_tag: "data",
|
|
51
|
+
data: {
|
|
52
|
+
cursor: { orderKey: BigInt(5e6 - 1) },
|
|
53
|
+
finality: "accepted",
|
|
54
|
+
data: [{ data: `${5e6 + i}` }],
|
|
55
|
+
endCursor: { orderKey: BigInt(5e6 + i) }
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { generateMockMessages, test };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const helper = require('../shared/indexer.318d3617.cjs');
|
|
4
|
+
const vcr_index = require('../shared/indexer.541d43eb.cjs');
|
|
5
|
+
require('node:async_hooks');
|
|
6
|
+
require('unctx');
|
|
7
|
+
require('@opentelemetry/api');
|
|
8
|
+
require('node:fs');
|
|
9
|
+
require('node:path');
|
|
10
|
+
require('node:fs/promises');
|
|
11
|
+
require('klona/full');
|
|
12
|
+
require('consola');
|
|
13
|
+
require('hookable');
|
|
14
|
+
require('node:assert');
|
|
15
|
+
require('../shared/indexer.a8b7ab1f.cjs');
|
|
16
|
+
require('@apibara/protocol/testing');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.deserialize = helper.deserialize;
|
|
21
|
+
exports.isCassetteAvailable = helper.isCassetteAvailable;
|
|
22
|
+
exports.serialize = helper.serialize;
|
|
23
|
+
exports.loadCassette = vcr_index.loadCassette;
|
|
24
|
+
exports.record = vcr_index.record;
|
|
25
|
+
exports.replay = vcr_index.replay;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { V as VcrConfig, C as CassetteOptions } from '../shared/indexer.500fd281.cjs';
|
|
2
|
+
export { a as VcrReplayResult, l as loadCassette, r as replay } from '../shared/indexer.500fd281.cjs';
|
|
3
|
+
import { StreamDataResponse, Client } from '@apibara/protocol';
|
|
4
|
+
import { f as Indexer } from '../shared/indexer.c7ed6b83.cjs';
|
|
5
|
+
import '../shared/indexer.b9c8f0d8.cjs';
|
|
6
|
+
import 'hookable';
|
|
7
|
+
|
|
8
|
+
declare function deserialize(str: string): any;
|
|
9
|
+
declare function serialize(obj: Record<string, unknown>): string;
|
|
10
|
+
declare function isCassetteAvailable(vcrConfig: VcrConfig, cassetteName: string): boolean;
|
|
11
|
+
|
|
12
|
+
type CassetteDataType<TFilter, TBlock> = {
|
|
13
|
+
filter: TFilter;
|
|
14
|
+
messages: StreamDataResponse<TBlock>[];
|
|
15
|
+
};
|
|
16
|
+
declare function record<TFilter, TBlock, TTxnParams>(vcrConfig: VcrConfig, client: Client<TFilter, TBlock>, indexerArg: Indexer<TFilter, TBlock, TTxnParams>, cassetteOptions: CassetteOptions): Promise<void>;
|
|
17
|
+
|
|
18
|
+
export { type CassetteDataType, CassetteOptions, VcrConfig, deserialize, isCassetteAvailable, record, serialize };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { V as VcrConfig, C as CassetteOptions } from '../shared/indexer.e1856641.mjs';
|
|
2
|
+
export { a as VcrReplayResult, l as loadCassette, r as replay } from '../shared/indexer.e1856641.mjs';
|
|
3
|
+
import { StreamDataResponse, Client } from '@apibara/protocol';
|
|
4
|
+
import { f as Indexer } from '../shared/indexer.e8bd138d.mjs';
|
|
5
|
+
import '../shared/indexer.b9c8f0d8.mjs';
|
|
6
|
+
import 'hookable';
|
|
7
|
+
|
|
8
|
+
declare function deserialize(str: string): any;
|
|
9
|
+
declare function serialize(obj: Record<string, unknown>): string;
|
|
10
|
+
declare function isCassetteAvailable(vcrConfig: VcrConfig, cassetteName: string): boolean;
|
|
11
|
+
|
|
12
|
+
type CassetteDataType<TFilter, TBlock> = {
|
|
13
|
+
filter: TFilter;
|
|
14
|
+
messages: StreamDataResponse<TBlock>[];
|
|
15
|
+
};
|
|
16
|
+
declare function record<TFilter, TBlock, TTxnParams>(vcrConfig: VcrConfig, client: Client<TFilter, TBlock>, indexerArg: Indexer<TFilter, TBlock, TTxnParams>, cassetteOptions: CassetteOptions): Promise<void>;
|
|
17
|
+
|
|
18
|
+
export { type CassetteDataType, CassetteOptions, VcrConfig, deserialize, isCassetteAvailable, record, serialize };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { V as VcrConfig, C as CassetteOptions } from '../shared/indexer.e4f2430f.js';
|
|
2
|
+
export { a as VcrReplayResult, l as loadCassette, r as replay } from '../shared/indexer.e4f2430f.js';
|
|
3
|
+
import { StreamDataResponse, Client } from '@apibara/protocol';
|
|
4
|
+
import { f as Indexer } from '../shared/indexer.f761abcd.js';
|
|
5
|
+
import '../shared/indexer.b9c8f0d8.js';
|
|
6
|
+
import 'hookable';
|
|
7
|
+
|
|
8
|
+
declare function deserialize(str: string): any;
|
|
9
|
+
declare function serialize(obj: Record<string, unknown>): string;
|
|
10
|
+
declare function isCassetteAvailable(vcrConfig: VcrConfig, cassetteName: string): boolean;
|
|
11
|
+
|
|
12
|
+
type CassetteDataType<TFilter, TBlock> = {
|
|
13
|
+
filter: TFilter;
|
|
14
|
+
messages: StreamDataResponse<TBlock>[];
|
|
15
|
+
};
|
|
16
|
+
declare function record<TFilter, TBlock, TTxnParams>(vcrConfig: VcrConfig, client: Client<TFilter, TBlock>, indexerArg: Indexer<TFilter, TBlock, TTxnParams>, cassetteOptions: CassetteOptions): Promise<void>;
|
|
17
|
+
|
|
18
|
+
export { type CassetteDataType, CassetteOptions, VcrConfig, deserialize, isCassetteAvailable, record, serialize };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { d as deserialize, i as isCassetteAvailable, s as serialize } from '../shared/indexer.2c23c9cd.mjs';
|
|
2
|
+
export { l as loadCassette, a as record, b as replay } from '../shared/indexer.36530330.mjs';
|
|
3
|
+
import 'node:async_hooks';
|
|
4
|
+
import 'unctx';
|
|
5
|
+
import '@opentelemetry/api';
|
|
6
|
+
import 'node:fs';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
import 'node:fs/promises';
|
|
9
|
+
import 'klona/full';
|
|
10
|
+
import 'consola';
|
|
11
|
+
import 'hookable';
|
|
12
|
+
import 'node:assert';
|
|
13
|
+
import '../shared/indexer.93d6b2eb.mjs';
|
|
14
|
+
import '@apibara/protocol/testing';
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/indexer",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.7",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
6
10
|
"main": "./dist/index.mjs",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
7
12
|
"exports": {
|
|
8
13
|
".": {
|
|
9
14
|
"types": "./dist/index.d.ts",
|
|
@@ -34,9 +39,32 @@
|
|
|
34
39
|
"import": "./dist/testing/index.mjs",
|
|
35
40
|
"require": "./dist/testing/index.cjs",
|
|
36
41
|
"default": "./dist/testing/index.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./vcr": {
|
|
44
|
+
"types": "./dist/vcr/index.d.ts",
|
|
45
|
+
"import": "./dist/vcr/index.mjs",
|
|
46
|
+
"require": "./dist/vcr/index.cjs",
|
|
47
|
+
"default": "./dist/vcr/index.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./plugins": {
|
|
50
|
+
"types": "./dist/plugins/index.d.ts",
|
|
51
|
+
"import": "./dist/plugins/index.mjs",
|
|
52
|
+
"require": "./dist/plugins/index.cjs",
|
|
53
|
+
"default": "./dist/plugins/index.mjs"
|
|
54
|
+
},
|
|
55
|
+
"./plugins/kv": {
|
|
56
|
+
"types": "./dist/plugins/kv.d.ts",
|
|
57
|
+
"import": "./dist/plugins/kv.mjs",
|
|
58
|
+
"require": "./dist/plugins/kv.cjs",
|
|
59
|
+
"default": "./dist/plugins/kv.mjs"
|
|
60
|
+
},
|
|
61
|
+
"./plugins/persistence": {
|
|
62
|
+
"types": "./dist/plugins/persistence.d.ts",
|
|
63
|
+
"import": "./dist/plugins/persistence.mjs",
|
|
64
|
+
"require": "./dist/plugins/persistence.cjs",
|
|
65
|
+
"default": "./dist/plugins/persistence.mjs"
|
|
37
66
|
}
|
|
38
67
|
},
|
|
39
|
-
"publishConfig": {},
|
|
40
68
|
"scripts": {
|
|
41
69
|
"build": "unbuild",
|
|
42
70
|
"lint": "biome check .",
|
|
@@ -59,7 +87,7 @@
|
|
|
59
87
|
"vitest": "^1.6.0"
|
|
60
88
|
},
|
|
61
89
|
"dependencies": {
|
|
62
|
-
"@apibara/protocol": "2.0.0-beta.
|
|
90
|
+
"@apibara/protocol": "2.0.0-beta.7",
|
|
63
91
|
"@opentelemetry/api": "^1.9.0",
|
|
64
92
|
"consola": "^3.2.3",
|
|
65
93
|
"hookable": "^5.5.3",
|
|
@@ -73,11 +101,5 @@
|
|
|
73
101
|
"drizzle-orm": "^0.33.0",
|
|
74
102
|
"postgres-range": "^1.1.4",
|
|
75
103
|
"vitest": "^1.6.0"
|
|
76
|
-
}
|
|
77
|
-
"files": [
|
|
78
|
-
"dist",
|
|
79
|
-
"src",
|
|
80
|
-
"README.md"
|
|
81
|
-
],
|
|
82
|
-
"types": "./dist/index.d.ts"
|
|
104
|
+
}
|
|
83
105
|
}
|
package/src/vcr/record.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { type Indexer, run } from "@apibara/indexer";
|
|
4
3
|
import type { Client, StreamDataResponse } from "@apibara/protocol";
|
|
5
4
|
import { klona } from "klona/full";
|
|
5
|
+
import { type Indexer, run } from "../indexer";
|
|
6
6
|
import type { CassetteOptions, VcrConfig } from "./config";
|
|
7
7
|
import { serialize } from "./helper";
|
|
8
8
|
|