@apibara/indexer 2.0.0-beta.28 → 2.0.0-beta.29
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.
|
@@ -12,16 +12,32 @@ require('hookable');
|
|
|
12
12
|
require('node:assert');
|
|
13
13
|
require('@opentelemetry/api');
|
|
14
14
|
|
|
15
|
-
function generateMockMessages(count = 10) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
function generateMockMessages(count = 10, options) {
|
|
16
|
+
const invalidateAt = options?.invalidate;
|
|
17
|
+
const messages = [];
|
|
18
|
+
for (let i = 0; i < count; i++) {
|
|
19
|
+
if (invalidateAt && i === invalidateAt.invalidateTriggerIndex) {
|
|
20
|
+
messages.push({
|
|
21
|
+
_tag: "invalidate",
|
|
22
|
+
invalidate: {
|
|
23
|
+
cursor: {
|
|
24
|
+
orderKey: BigInt(5e6 + invalidateAt.invalidateFromIndex)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
messages.push({
|
|
30
|
+
_tag: "data",
|
|
31
|
+
data: {
|
|
32
|
+
cursor: { orderKey: BigInt(5e6 + i - 1) },
|
|
33
|
+
finality: "accepted",
|
|
34
|
+
data: [{ data: `${5e6 + i}` }],
|
|
35
|
+
endCursor: { orderKey: BigInt(5e6 + i) }
|
|
36
|
+
}
|
|
37
|
+
});
|
|
23
38
|
}
|
|
24
|
-
}
|
|
39
|
+
}
|
|
40
|
+
return messages;
|
|
25
41
|
}
|
|
26
42
|
function getMockIndexer({
|
|
27
43
|
plugins,
|
|
@@ -3,7 +3,13 @@ import { MockStreamResponse, MockFilter, MockBlock } from '@apibara/protocol/tes
|
|
|
3
3
|
import '@apibara/protocol';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type MockMessagesOptions = {
|
|
7
|
+
invalidate?: {
|
|
8
|
+
invalidateFromIndex: number;
|
|
9
|
+
invalidateTriggerIndex: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare function generateMockMessages(count?: number, options?: MockMessagesOptions): MockStreamResponse[];
|
|
7
13
|
declare function getMockIndexer({ plugins, override, }?: {
|
|
8
14
|
plugins?: ReadonlyArray<IndexerPlugin<MockFilter, MockBlock>>;
|
|
9
15
|
override?: Partial<IndexerConfig<MockFilter, MockBlock>>;
|
|
@@ -27,4 +33,4 @@ declare function useMockSink(): {
|
|
|
27
33
|
output: unknown[];
|
|
28
34
|
};
|
|
29
35
|
|
|
30
|
-
export { type MockRet, generateMockMessages, getMockIndexer, mockSink, useMockSink };
|
|
36
|
+
export { type MockMessagesOptions, type MockRet, generateMockMessages, getMockIndexer, mockSink, useMockSink };
|
|
@@ -3,7 +3,13 @@ import { MockStreamResponse, MockFilter, MockBlock } from '@apibara/protocol/tes
|
|
|
3
3
|
import '@apibara/protocol';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type MockMessagesOptions = {
|
|
7
|
+
invalidate?: {
|
|
8
|
+
invalidateFromIndex: number;
|
|
9
|
+
invalidateTriggerIndex: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare function generateMockMessages(count?: number, options?: MockMessagesOptions): MockStreamResponse[];
|
|
7
13
|
declare function getMockIndexer({ plugins, override, }?: {
|
|
8
14
|
plugins?: ReadonlyArray<IndexerPlugin<MockFilter, MockBlock>>;
|
|
9
15
|
override?: Partial<IndexerConfig<MockFilter, MockBlock>>;
|
|
@@ -27,4 +33,4 @@ declare function useMockSink(): {
|
|
|
27
33
|
output: unknown[];
|
|
28
34
|
};
|
|
29
35
|
|
|
30
|
-
export { type MockRet, generateMockMessages, getMockIndexer, mockSink, useMockSink };
|
|
36
|
+
export { type MockMessagesOptions, type MockRet, generateMockMessages, getMockIndexer, mockSink, useMockSink };
|
|
@@ -3,7 +3,13 @@ import { MockStreamResponse, MockFilter, MockBlock } from '@apibara/protocol/tes
|
|
|
3
3
|
import '@apibara/protocol';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type MockMessagesOptions = {
|
|
7
|
+
invalidate?: {
|
|
8
|
+
invalidateFromIndex: number;
|
|
9
|
+
invalidateTriggerIndex: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare function generateMockMessages(count?: number, options?: MockMessagesOptions): MockStreamResponse[];
|
|
7
13
|
declare function getMockIndexer({ plugins, override, }?: {
|
|
8
14
|
plugins?: ReadonlyArray<IndexerPlugin<MockFilter, MockBlock>>;
|
|
9
15
|
override?: Partial<IndexerConfig<MockFilter, MockBlock>>;
|
|
@@ -27,4 +33,4 @@ declare function useMockSink(): {
|
|
|
27
33
|
output: unknown[];
|
|
28
34
|
};
|
|
29
35
|
|
|
30
|
-
export { type MockRet, generateMockMessages, getMockIndexer, mockSink, useMockSink };
|
|
36
|
+
export { type MockMessagesOptions, type MockRet, generateMockMessages, getMockIndexer, mockSink, useMockSink };
|
|
@@ -10,16 +10,32 @@ import 'hookable';
|
|
|
10
10
|
import 'node:assert';
|
|
11
11
|
import '@opentelemetry/api';
|
|
12
12
|
|
|
13
|
-
function generateMockMessages(count = 10) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
function generateMockMessages(count = 10, options) {
|
|
14
|
+
const invalidateAt = options?.invalidate;
|
|
15
|
+
const messages = [];
|
|
16
|
+
for (let i = 0; i < count; i++) {
|
|
17
|
+
if (invalidateAt && i === invalidateAt.invalidateTriggerIndex) {
|
|
18
|
+
messages.push({
|
|
19
|
+
_tag: "invalidate",
|
|
20
|
+
invalidate: {
|
|
21
|
+
cursor: {
|
|
22
|
+
orderKey: BigInt(5e6 + invalidateAt.invalidateFromIndex)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
messages.push({
|
|
28
|
+
_tag: "data",
|
|
29
|
+
data: {
|
|
30
|
+
cursor: { orderKey: BigInt(5e6 + i - 1) },
|
|
31
|
+
finality: "accepted",
|
|
32
|
+
data: [{ data: `${5e6 + i}` }],
|
|
33
|
+
endCursor: { orderKey: BigInt(5e6 + i) }
|
|
34
|
+
}
|
|
35
|
+
});
|
|
21
36
|
}
|
|
22
|
-
}
|
|
37
|
+
}
|
|
38
|
+
return messages;
|
|
23
39
|
}
|
|
24
40
|
function getMockIndexer({
|
|
25
41
|
plugins,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/indexer",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"vitest": "^1.6.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@apibara/protocol": "2.0.0-beta.
|
|
61
|
+
"@apibara/protocol": "2.0.0-beta.29",
|
|
62
62
|
"@opentelemetry/api": "^1.9.0",
|
|
63
63
|
"ci-info": "^4.1.0",
|
|
64
64
|
"consola": "^3.2.3",
|
package/src/internal/testing.ts
CHANGED
|
@@ -10,16 +10,45 @@ import { useIndexerContext } from "../context";
|
|
|
10
10
|
import { type IndexerConfig, createIndexer, defineIndexer } from "../indexer";
|
|
11
11
|
import { type IndexerPlugin, defineIndexerPlugin } from "../plugins";
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
export type MockMessagesOptions = {
|
|
14
|
+
invalidate?: {
|
|
15
|
+
invalidateFromIndex: number;
|
|
16
|
+
invalidateTriggerIndex: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function generateMockMessages(
|
|
21
|
+
count = 10,
|
|
22
|
+
options?: MockMessagesOptions,
|
|
23
|
+
): MockStreamResponse[] {
|
|
24
|
+
const invalidateAt = options?.invalidate;
|
|
25
|
+
|
|
26
|
+
const messages: MockStreamResponse[] = [];
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < count; i++) {
|
|
29
|
+
if (invalidateAt && i === invalidateAt.invalidateTriggerIndex) {
|
|
30
|
+
messages.push({
|
|
31
|
+
_tag: "invalidate",
|
|
32
|
+
invalidate: {
|
|
33
|
+
cursor: {
|
|
34
|
+
orderKey: BigInt(5_000_000 + invalidateAt.invalidateFromIndex),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
messages.push({
|
|
40
|
+
_tag: "data",
|
|
41
|
+
data: {
|
|
42
|
+
cursor: { orderKey: BigInt(5_000_000 + i - 1) },
|
|
43
|
+
finality: "accepted",
|
|
44
|
+
data: [{ data: `${5_000_000 + i}` }],
|
|
45
|
+
endCursor: { orderKey: BigInt(5_000_000 + i) },
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return messages;
|
|
23
52
|
}
|
|
24
53
|
|
|
25
54
|
export function getMockIndexer({
|