@apibara/plugin-mongo 2.0.0-beta.29 → 2.0.0-beta.30
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 +7 -7
- package/dist/index.mjs +7 -7
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/mongo.ts +1 -1
- package/src/persistence.ts +9 -9
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ async function finalize(db, session, cursor, collections) {
|
|
|
30
30
|
for (const collection of collections) {
|
|
31
31
|
await db.collection(collection).deleteMany(
|
|
32
32
|
{
|
|
33
|
-
"_cursor.to": { $
|
|
33
|
+
"_cursor.to": { $lte: orderKeyValue }
|
|
34
34
|
},
|
|
35
35
|
{ session }
|
|
36
36
|
);
|
|
@@ -51,7 +51,7 @@ async function initializePersistentState(db, session) {
|
|
|
51
51
|
await filter.createIndex({ id: 1, fromBlock: 1 }, { session });
|
|
52
52
|
}
|
|
53
53
|
async function persistState(props) {
|
|
54
|
-
const { db, session, endCursor, filter, indexerName
|
|
54
|
+
const { db, session, endCursor, filter, indexerName } = props;
|
|
55
55
|
if (endCursor) {
|
|
56
56
|
await db.collection(checkpointCollectionName).updateOne(
|
|
57
57
|
{ id: indexerName },
|
|
@@ -87,7 +87,7 @@ async function persistState(props) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
async function getState(props) {
|
|
90
|
-
const { db, session, indexerName
|
|
90
|
+
const { db, session, indexerName } = props;
|
|
91
91
|
let cursor;
|
|
92
92
|
let filter;
|
|
93
93
|
const checkpointRow = await db.collection(checkpointCollectionName).findOne({ id: indexerName }, { session });
|
|
@@ -110,7 +110,7 @@ async function getState(props) {
|
|
|
110
110
|
return { cursor, filter };
|
|
111
111
|
}
|
|
112
112
|
async function invalidateState(props) {
|
|
113
|
-
const { db, session, cursor, indexerName
|
|
113
|
+
const { db, session, cursor, indexerName } = props;
|
|
114
114
|
await db.collection(filterCollectionName).deleteMany(
|
|
115
115
|
{ id: indexerName, fromBlock: { $gt: Number(cursor.orderKey) } },
|
|
116
116
|
{ session }
|
|
@@ -122,11 +122,11 @@ async function invalidateState(props) {
|
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
async function finalizeState(props) {
|
|
125
|
-
const { db, session, cursor, indexerName
|
|
125
|
+
const { db, session, cursor, indexerName } = props;
|
|
126
126
|
await db.collection(filterCollectionName).deleteMany(
|
|
127
127
|
{
|
|
128
128
|
id: indexerName,
|
|
129
|
-
toBlock: { $
|
|
129
|
+
toBlock: { $lte: Number(cursor.orderKey) }
|
|
130
130
|
},
|
|
131
131
|
{ session }
|
|
132
132
|
);
|
|
@@ -332,7 +332,7 @@ function mongoStorage({
|
|
|
332
332
|
dbOptions,
|
|
333
333
|
collections,
|
|
334
334
|
persistState: enablePersistence = true,
|
|
335
|
-
indexerName
|
|
335
|
+
indexerName = "default"
|
|
336
336
|
}) {
|
|
337
337
|
return plugins.defineIndexerPlugin((indexer) => {
|
|
338
338
|
indexer.hooks.hook("run:before", async () => {
|
package/dist/index.mjs
CHANGED
|
@@ -28,7 +28,7 @@ async function finalize(db, session, cursor, collections) {
|
|
|
28
28
|
for (const collection of collections) {
|
|
29
29
|
await db.collection(collection).deleteMany(
|
|
30
30
|
{
|
|
31
|
-
"_cursor.to": { $
|
|
31
|
+
"_cursor.to": { $lte: orderKeyValue }
|
|
32
32
|
},
|
|
33
33
|
{ session }
|
|
34
34
|
);
|
|
@@ -49,7 +49,7 @@ async function initializePersistentState(db, session) {
|
|
|
49
49
|
await filter.createIndex({ id: 1, fromBlock: 1 }, { session });
|
|
50
50
|
}
|
|
51
51
|
async function persistState(props) {
|
|
52
|
-
const { db, session, endCursor, filter, indexerName
|
|
52
|
+
const { db, session, endCursor, filter, indexerName } = props;
|
|
53
53
|
if (endCursor) {
|
|
54
54
|
await db.collection(checkpointCollectionName).updateOne(
|
|
55
55
|
{ id: indexerName },
|
|
@@ -85,7 +85,7 @@ async function persistState(props) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
async function getState(props) {
|
|
88
|
-
const { db, session, indexerName
|
|
88
|
+
const { db, session, indexerName } = props;
|
|
89
89
|
let cursor;
|
|
90
90
|
let filter;
|
|
91
91
|
const checkpointRow = await db.collection(checkpointCollectionName).findOne({ id: indexerName }, { session });
|
|
@@ -108,7 +108,7 @@ async function getState(props) {
|
|
|
108
108
|
return { cursor, filter };
|
|
109
109
|
}
|
|
110
110
|
async function invalidateState(props) {
|
|
111
|
-
const { db, session, cursor, indexerName
|
|
111
|
+
const { db, session, cursor, indexerName } = props;
|
|
112
112
|
await db.collection(filterCollectionName).deleteMany(
|
|
113
113
|
{ id: indexerName, fromBlock: { $gt: Number(cursor.orderKey) } },
|
|
114
114
|
{ session }
|
|
@@ -120,11 +120,11 @@ async function invalidateState(props) {
|
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
async function finalizeState(props) {
|
|
123
|
-
const { db, session, cursor, indexerName
|
|
123
|
+
const { db, session, cursor, indexerName } = props;
|
|
124
124
|
await db.collection(filterCollectionName).deleteMany(
|
|
125
125
|
{
|
|
126
126
|
id: indexerName,
|
|
127
|
-
toBlock: { $
|
|
127
|
+
toBlock: { $lte: Number(cursor.orderKey) }
|
|
128
128
|
},
|
|
129
129
|
{ session }
|
|
130
130
|
);
|
|
@@ -330,7 +330,7 @@ function mongoStorage({
|
|
|
330
330
|
dbOptions,
|
|
331
331
|
collections,
|
|
332
332
|
persistState: enablePersistence = true,
|
|
333
|
-
indexerName
|
|
333
|
+
indexerName = "default"
|
|
334
334
|
}) {
|
|
335
335
|
return defineIndexerPlugin((indexer) => {
|
|
336
336
|
indexer.hooks.hook("run:before", async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/plugin-mongo",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.30",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"mongodb": "^6.12.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@apibara/indexer": "2.0.0-beta.
|
|
39
|
-
"@apibara/protocol": "2.0.0-beta.
|
|
38
|
+
"@apibara/indexer": "2.0.0-beta.30",
|
|
39
|
+
"@apibara/protocol": "2.0.0-beta.30"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -54,7 +54,7 @@ export function mongoStorage<TFilter, TBlock>({
|
|
|
54
54
|
dbOptions,
|
|
55
55
|
collections,
|
|
56
56
|
persistState: enablePersistence = true,
|
|
57
|
-
indexerName,
|
|
57
|
+
indexerName = "default",
|
|
58
58
|
}: MongoStorageOptions) {
|
|
59
59
|
return defineIndexerPlugin<TFilter, TBlock>((indexer) => {
|
|
60
60
|
indexer.hooks.hook("run:before", async () => {
|
package/src/mongo.ts
CHANGED
|
@@ -43,7 +43,7 @@ export async function finalize(
|
|
|
43
43
|
// Delete documents where the upper bound of _cursor is less than the finalize cursor
|
|
44
44
|
await db.collection(collection).deleteMany(
|
|
45
45
|
{
|
|
46
|
-
"_cursor.to": { $
|
|
46
|
+
"_cursor.to": { $lte: orderKeyValue },
|
|
47
47
|
},
|
|
48
48
|
{ session },
|
|
49
49
|
);
|
package/src/persistence.ts
CHANGED
|
@@ -38,9 +38,9 @@ export async function persistState<TFilter>(props: {
|
|
|
38
38
|
session: ClientSession;
|
|
39
39
|
endCursor: Cursor;
|
|
40
40
|
filter?: TFilter;
|
|
41
|
-
indexerName
|
|
41
|
+
indexerName: string;
|
|
42
42
|
}) {
|
|
43
|
-
const { db, session, endCursor, filter, indexerName
|
|
43
|
+
const { db, session, endCursor, filter, indexerName } = props;
|
|
44
44
|
|
|
45
45
|
if (endCursor) {
|
|
46
46
|
await db.collection<CheckpointSchema>(checkpointCollectionName).updateOne(
|
|
@@ -86,9 +86,9 @@ export async function persistState<TFilter>(props: {
|
|
|
86
86
|
export async function getState<TFilter>(props: {
|
|
87
87
|
db: Db;
|
|
88
88
|
session: ClientSession;
|
|
89
|
-
indexerName
|
|
89
|
+
indexerName: string;
|
|
90
90
|
}): Promise<{ cursor?: Cursor; filter?: TFilter }> {
|
|
91
|
-
const { db, session, indexerName
|
|
91
|
+
const { db, session, indexerName } = props;
|
|
92
92
|
|
|
93
93
|
let cursor: Cursor | undefined;
|
|
94
94
|
let filter: TFilter | undefined;
|
|
@@ -125,9 +125,9 @@ export async function invalidateState(props: {
|
|
|
125
125
|
db: Db;
|
|
126
126
|
session: ClientSession;
|
|
127
127
|
cursor: Cursor;
|
|
128
|
-
indexerName
|
|
128
|
+
indexerName: string;
|
|
129
129
|
}) {
|
|
130
|
-
const { db, session, cursor, indexerName
|
|
130
|
+
const { db, session, cursor, indexerName } = props;
|
|
131
131
|
|
|
132
132
|
await db
|
|
133
133
|
.collection<FilterSchema>(filterCollectionName)
|
|
@@ -149,14 +149,14 @@ export async function finalizeState(props: {
|
|
|
149
149
|
db: Db;
|
|
150
150
|
session: ClientSession;
|
|
151
151
|
cursor: Cursor;
|
|
152
|
-
indexerName
|
|
152
|
+
indexerName: string;
|
|
153
153
|
}) {
|
|
154
|
-
const { db, session, cursor, indexerName
|
|
154
|
+
const { db, session, cursor, indexerName } = props;
|
|
155
155
|
|
|
156
156
|
await db.collection<FilterSchema>(filterCollectionName).deleteMany(
|
|
157
157
|
{
|
|
158
158
|
id: indexerName,
|
|
159
|
-
toBlock: { $
|
|
159
|
+
toBlock: { $lte: Number(cursor.orderKey) },
|
|
160
160
|
},
|
|
161
161
|
{ session },
|
|
162
162
|
);
|