envio 3.15.0 → 3.16.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.
- package/README.md +40 -34
- package/evm.schema.json +11 -2
- package/fuel.schema.json +10 -1
- package/index.d.ts +6 -0
- package/licenses/README.md +1 -1
- package/package.json +8 -8
- package/src/Batch.res.mjs +5 -5
- package/src/BatchProcessing.res +1 -0
- package/src/BatchProcessing.res.mjs +1 -0
- package/src/ChainState.res +48 -7
- package/src/ChainState.res.mjs +27 -11
- package/src/Clock.res +57 -0
- package/src/Clock.res.mjs +72 -0
- package/src/Config.res +10 -3
- package/src/Config.res.mjs +4 -2
- package/src/Core.res +4 -40
- package/src/EffectState.res +10 -2
- package/src/EffectState.res.mjs +8 -4
- package/src/EffectState.resi +3 -1
- package/src/EntityId.res +2 -7
- package/src/EntityId.res.mjs +1 -8
- package/src/EntityTables.res +4 -1
- package/src/EntityTables.res.mjs +1 -1
- package/src/FetchState.res +157 -69
- package/src/FetchState.res.mjs +144 -49
- package/src/FinalizeBackfill.res +2 -4
- package/src/FinalizeBackfill.res.mjs +3 -4
- package/src/InMemoryTable.res +17 -16
- package/src/InMemoryTable.res.mjs +14 -15
- package/src/IndexerState.res +28 -4
- package/src/IndexerState.res.mjs +19 -6
- package/src/IndexerState.resi +4 -0
- package/src/Internal.res +0 -49
- package/src/Internal.res.mjs +1 -80
- package/src/LoadLayer.res +14 -8
- package/src/LoadLayer.res.mjs +8 -6
- package/src/Main.res.mjs +1 -1
- package/src/Persistence.res +3 -23
- package/src/Persistence.res.mjs +3 -3
- package/src/Rollback.res +0 -1
- package/src/Rollback.res.mjs +1 -1
- package/src/SafeCheckpointTracking.res +4 -4
- package/src/SafeCheckpointTracking.res.mjs +1 -1
- package/src/StagedRows.res +106 -0
- package/src/StagedRows.res.mjs +102 -0
- package/src/Staging.res +32 -14
- package/src/Staging.res.mjs +17 -20
- package/src/Storage.res +277 -948
- package/src/Storage.res.mjs +215 -707
- package/src/Supervisor.res +75 -56
- package/src/Supervisor.res.mjs +55 -26
- package/src/TestIndexer.res +22 -27
- package/src/TestIndexer.res.mjs +20 -17
- package/src/Throttler.res +15 -8
- package/src/Throttler.res.mjs +9 -6
- package/src/Throttler.resi +1 -1
- package/src/Utils.res +0 -6
- package/src/Utils.res.mjs +0 -5
- package/src/Writing.res +0 -1
- package/src/Writing.res.mjs +1 -1
- package/src/bindings/ClickHouse.res +0 -322
- package/src/bindings/ClickHouse.res.mjs +0 -338
- package/src/bindings/StorageClient.res +107 -174
- package/src/bindings/StorageClient.res.mjs +19 -8
- package/src/bindings/Vitest.res +0 -26
- package/src/bindings/Vitest.res.mjs +0 -3
- package/src/db/Table.res +24 -150
- package/src/db/Table.res.mjs +38 -272
- package/src/sources/ChainSources.res +2 -0
- package/src/sources/ChainSources.res.mjs +2 -2
- package/src/sources/EvmChain.res +3 -0
- package/src/sources/EvmChain.res.mjs +4 -2
- package/src/sources/EvmHyperSyncSource.res +2 -2
- package/src/sources/EvmHyperSyncSource.res.mjs +1 -1
- package/src/sources/EvmRpcClient.res +13 -3
- package/src/sources/EvmRpcClient.res.mjs +4 -3
- package/src/sources/EvmRpcWs.res +4 -3
- package/src/sources/EvmRpcWs.res.mjs +2 -2
- package/src/sources/HeightFeed.res +31 -10
- package/src/sources/HeightFeed.res.mjs +10 -6
- package/src/sources/HeightStream.res +32 -17
- package/src/sources/HeightStream.res.mjs +10 -10
- package/src/sources/HyperSyncSSE.res +4 -6
- package/src/sources/HyperSyncSSE.res.mjs +2 -2
- package/src/sources/RpcSource.res +10 -1
- package/src/sources/RpcSource.res.mjs +4 -3
- package/src/sources/Source.res +3 -0
- package/src/sources/SourceManager.res +84 -77
- package/src/sources/SourceManager.res.mjs +17 -20
- package/src/sources/SourceManager.resi +3 -4
- package/src/sources/StartBlockResolver.res +1 -0
- package/src/sources/StartBlockResolver.res.mjs +3 -2
- package/src/sources/SvmHyperSyncSource.res +2 -2
- package/src/sources/SvmHyperSyncSource.res.mjs +1 -1
- package/svm.schema.json +11 -2
- package/src/PgWriting.res +0 -36
- package/src/PgWriting.res.mjs +0 -34
- package/src/db/IndexDefinition.res +0 -47
- package/src/db/IndexDefinition.res.mjs +0 -67
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Rows cross in arenas both ways. A write stages its rows into memory the addon
|
|
2
|
-
// lends (`
|
|
3
|
-
// arena that `lendResult` hands over and `releaseResult` takes
|
|
4
|
-
// writing through a buffer after it has been handed back is
|
|
5
|
-
// prevents — the rules are the ones at the top of
|
|
2
|
+
// lends (`beginChanges`/`beginRows` to `commitStage`); a read lands its rows in
|
|
3
|
+
// a Rust-owned arena that `lendResult` hands over and `releaseResult` takes
|
|
4
|
+
// back. Reading or writing through a buffer after it has been handed back is
|
|
5
|
+
// what detaching prevents — the rules are the ones at the top of
|
|
6
6
|
// `packages/cli/src/columnar/mod.rs`.
|
|
7
7
|
|
|
8
8
|
type t
|
|
@@ -19,6 +19,9 @@ type postgresOptions = {
|
|
|
19
19
|
applicationName: string,
|
|
20
20
|
pgSchema: string,
|
|
21
21
|
isHasuraEnabled: bool,
|
|
22
|
+
// An `envio start --chain` process: builds and looks for a per-chain
|
|
23
|
+
// entity's indexes on its own chains' partitions only.
|
|
24
|
+
isolated: bool,
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
type clickHouseOptions = {
|
|
@@ -31,7 +34,6 @@ type clickHouseOptions = {
|
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
type options = {
|
|
34
|
-
chainIdMode: string,
|
|
35
37
|
postgres: postgresOptions,
|
|
36
38
|
clickhouse?: clickHouseOptions,
|
|
37
39
|
}
|
|
@@ -45,71 +47,31 @@ type queryResult = {
|
|
|
45
47
|
rows: int,
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
// read schemas parse every store's rows by.
|
|
50
|
-
type clickHouseColumn = {
|
|
51
|
-
name: string,
|
|
52
|
-
rowName?: string,
|
|
53
|
-
// The schema field, which `@storage(clickhouse: {...})` expressions name a
|
|
54
|
-
// column by even when a rename is configured.
|
|
55
|
-
fieldName?: string,
|
|
56
|
-
fieldType: string,
|
|
57
|
-
isNullable: bool,
|
|
58
|
-
isArray: bool,
|
|
59
|
-
precision?: int,
|
|
60
|
-
scale?: int,
|
|
61
|
-
enumVariants?: array<string>,
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
type skippingIndex = {
|
|
65
|
-
name: string,
|
|
66
|
-
expr: string,
|
|
67
|
-
indexType: string,
|
|
68
|
-
granularity?: int,
|
|
69
|
-
}
|
|
50
|
+
type store = Postgres | ClickHouse
|
|
70
51
|
|
|
71
|
-
type
|
|
72
|
-
name: string,
|
|
73
|
-
historyTable: string,
|
|
74
|
-
columns: array<clickHouseColumn>,
|
|
75
|
-
chainIdColumn?: string,
|
|
76
|
-
partitionBy?: string,
|
|
77
|
-
orderBy?: array<string>,
|
|
78
|
-
ttl?: string,
|
|
79
|
-
skippingIndexes?: array<skippingIndex>,
|
|
80
|
-
}
|
|
52
|
+
type stagedField = Staging.stagedField
|
|
81
53
|
|
|
82
|
-
|
|
83
|
-
// schema names, the indexer's own tables for Postgres alone.
|
|
84
|
-
type tableInput = {
|
|
54
|
+
type entityLayout = {
|
|
85
55
|
name: string,
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
// The store the entity is read from; none when no configured store keeps it.
|
|
57
|
+
home?: store,
|
|
58
|
+
fields: array<stagedField>,
|
|
88
59
|
}
|
|
89
60
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
type
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
61
|
+
// How every batch is laid out: an entity's change set is its fields, then each
|
|
62
|
+
// change's checkpoint and whether it deletes.
|
|
63
|
+
type layouts = {
|
|
64
|
+
// By entity index.
|
|
65
|
+
entities: array<entityLayout>,
|
|
66
|
+
rawEvents: array<stagedField>,
|
|
67
|
+
effectCache: array<stagedField>,
|
|
96
68
|
}
|
|
97
69
|
|
|
98
|
-
type
|
|
99
|
-
|
|
100
|
-
// What each store made of a table: present for the stores that keep it.
|
|
101
|
-
type registeredTable = {
|
|
102
|
-
handle: int,
|
|
103
|
-
// The store the table is read from.
|
|
104
|
-
home: store,
|
|
105
|
-
postgres?: postgresRegistered,
|
|
106
|
-
clickhouse?: clickHouseRegistered,
|
|
107
|
-
}
|
|
70
|
+
type stagedTable = RawEvents | EffectCache
|
|
108
71
|
|
|
109
72
|
type bounds = {
|
|
110
|
-
sequence: CheckpointSequence.t,
|
|
111
73
|
chainIds: array<ChainId.t>,
|
|
112
|
-
checkpointIds: array<
|
|
74
|
+
checkpointIds: array<bigint>,
|
|
113
75
|
}
|
|
114
76
|
|
|
115
77
|
type progress = {
|
|
@@ -146,15 +108,7 @@ type chainConfig = {
|
|
|
146
108
|
maxReorgDepth: int,
|
|
147
109
|
}
|
|
148
110
|
|
|
149
|
-
type partition = {table: int, chainId: ChainId.t, name: string}
|
|
150
|
-
|
|
151
|
-
type enum = {name: string, variants: array<string>}
|
|
152
|
-
|
|
153
111
|
type initialize = {
|
|
154
|
-
sequence: CheckpointSequence.t,
|
|
155
|
-
tables: array<int>,
|
|
156
|
-
partitions: array<partition>,
|
|
157
|
-
enums: array<enum>,
|
|
158
112
|
chains: array<chainConfig>,
|
|
159
113
|
envioInfo: string,
|
|
160
114
|
contractNames: array<string>,
|
|
@@ -163,18 +117,9 @@ type initialize = {
|
|
|
163
117
|
|
|
164
118
|
type addChain = {
|
|
165
119
|
chain: chainConfig,
|
|
166
|
-
partitions: array<partition>,
|
|
167
120
|
addresses: addresses,
|
|
168
121
|
}
|
|
169
122
|
|
|
170
|
-
type resume = {
|
|
171
|
-
sequence: CheckpointSequence.t,
|
|
172
|
-
// Every entity table.
|
|
173
|
-
tables: array<int>,
|
|
174
|
-
// The chains this run drives, which are the only ones trimmed.
|
|
175
|
-
chainIds: array<ChainId.t>,
|
|
176
|
-
}
|
|
177
|
-
|
|
178
123
|
type storedChain = {
|
|
179
124
|
id: float,
|
|
180
125
|
ecosystem: string,
|
|
@@ -203,11 +148,11 @@ type resumedChain = {
|
|
|
203
148
|
// Unix seconds.
|
|
204
149
|
progressBlockTime?: float,
|
|
205
150
|
sourceBlock: int,
|
|
206
|
-
checkpointId:
|
|
151
|
+
checkpointId: bigint,
|
|
207
152
|
}
|
|
208
153
|
|
|
209
154
|
type reorgCheckpoint = {
|
|
210
|
-
id:
|
|
155
|
+
id: bigint,
|
|
211
156
|
chainId: float,
|
|
212
157
|
blockNumber: int,
|
|
213
158
|
blockHash: string,
|
|
@@ -227,57 +172,40 @@ type progressDiff = {
|
|
|
227
172
|
|
|
228
173
|
type rollbackData = {removed: queryResult, restored: queryResult}
|
|
229
174
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
// Rows of a batch: staged into an arena, or one rendered parameter per cell,
|
|
236
|
-
// every row's first column first.
|
|
237
|
-
type rows = {
|
|
238
|
-
staged?: int,
|
|
239
|
-
cells?: array<Null.t<string>>,
|
|
175
|
+
// `chainId` is left out for a cross-chain cache.
|
|
176
|
+
type storedEffectCache = {
|
|
177
|
+
effectName: string,
|
|
178
|
+
chainId?: ChainId.t,
|
|
179
|
+
tableName: string,
|
|
240
180
|
rows: int,
|
|
241
181
|
}
|
|
242
182
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
sets?: rows,
|
|
246
|
-
setCheckpointIds: array<string>,
|
|
247
|
-
deleteIds: array<string>,
|
|
248
|
-
deleteCheckpointIds: array<string>,
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
type postgresEntityWrite = {
|
|
252
|
-
sets?: rows,
|
|
253
|
-
deletes: array<string>,
|
|
254
|
-
history?: historyWrite,
|
|
255
|
-
}
|
|
183
|
+
// An optional field is left out rather than null, both ways: the addon refuses
|
|
184
|
+
// a null for one, and leaves out one it has no value for.
|
|
256
185
|
|
|
257
|
-
|
|
258
|
-
|
|
186
|
+
// One entity's changes within one chain scope, staged.
|
|
187
|
+
type changes = {
|
|
188
|
+
entity: int,
|
|
259
189
|
chainId?: ChainId.t,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
clickhouse?: int,
|
|
190
|
+
keepsHistory: bool,
|
|
191
|
+
changes: int,
|
|
263
192
|
}
|
|
264
193
|
|
|
265
194
|
type diffCheckpoint = {
|
|
266
195
|
chainId: ChainId.t,
|
|
267
|
-
checkpointId:
|
|
196
|
+
checkpointId: bigint,
|
|
268
197
|
blockNumber: int,
|
|
269
198
|
}
|
|
270
199
|
|
|
271
200
|
type rollbackWrite = {
|
|
272
201
|
bounds: bounds,
|
|
273
|
-
tables: array<int>,
|
|
274
202
|
progress: array<progress>,
|
|
275
203
|
removedAddresses: addresses,
|
|
276
204
|
diffCheckpoints: array<diffCheckpoint>,
|
|
277
205
|
}
|
|
278
206
|
|
|
279
207
|
type checkpoints = {
|
|
280
|
-
ids: array<
|
|
208
|
+
ids: array<bigint>,
|
|
281
209
|
chainIds: array<ChainId.t>,
|
|
282
210
|
blockNumbers: array<int>,
|
|
283
211
|
blockHashes: array<Null.t<string>>,
|
|
@@ -285,17 +213,15 @@ type checkpoints = {
|
|
|
285
213
|
keepsHistory: array<bool>,
|
|
286
214
|
}
|
|
287
215
|
|
|
288
|
-
type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<
|
|
289
|
-
|
|
290
|
-
type tableWrite = {table: int, rows: rows}
|
|
216
|
+
type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<bigint>}
|
|
291
217
|
|
|
292
|
-
type effectCacheWrite = {table:
|
|
218
|
+
type effectCacheWrite = {table: string, create: bool, rows: int}
|
|
293
219
|
|
|
294
220
|
type batch = {
|
|
295
221
|
rollback?: rollbackWrite,
|
|
296
222
|
progress: array<progress>,
|
|
297
|
-
rawEvents?:
|
|
298
|
-
|
|
223
|
+
rawEvents?: int,
|
|
224
|
+
changes: array<changes>,
|
|
299
225
|
chainMeta: array<chainMeta>,
|
|
300
226
|
addresses: addresses,
|
|
301
227
|
frontier: frontier,
|
|
@@ -305,37 +231,31 @@ type batch = {
|
|
|
305
231
|
|
|
306
232
|
type writeTiming = {store: store, seconds: float}
|
|
307
233
|
|
|
308
|
-
// What a build was for, which decides how much an existing index has to match.
|
|
309
|
-
type indexPurpose = | @as("Query") Query | @as("Schema") Schema
|
|
310
|
-
|
|
311
|
-
@tag("kind")
|
|
312
|
-
type indexEvent =
|
|
313
|
-
| Invalid({names: array<string>})
|
|
314
|
-
| Planned({declared: int, missing: array<string>, rebuilt: array<string>})
|
|
315
|
-
| Building({purpose: indexPurpose, name: string, tableName: string, isRebuild: bool})
|
|
316
|
-
| Built({purpose: indexPurpose, name: string, seconds: float})
|
|
317
|
-
| Failed({
|
|
318
|
-
purpose: indexPurpose,
|
|
319
|
-
name: string,
|
|
320
|
-
tableName: string,
|
|
321
|
-
columns: array<string>,
|
|
322
|
-
error: string,
|
|
323
|
-
code?: string,
|
|
324
|
-
})
|
|
325
|
-
| ResyncFailed({name: string, error: string, code?: string})
|
|
326
|
-
| Committed({count: int, seconds: float})
|
|
327
|
-
|
|
328
|
-
@send
|
|
329
|
-
external classCreate: (Core.storageCtor, options, indexEvent => unit, string => unit) => t =
|
|
330
|
-
"create"
|
|
331
|
-
|
|
332
|
-
let make = (options, ~onIndexEvent, ~onWarning) =>
|
|
333
|
-
Core.getAddon().storage->classCreate(options, onIndexEvent, onWarning)
|
|
334
|
-
|
|
335
|
-
@send external registerTable: (t, tableInput) => registeredTable = "registerTable"
|
|
336
|
-
|
|
337
234
|
@send
|
|
338
|
-
external
|
|
235
|
+
external classCreate: (
|
|
236
|
+
Core.storageCtor,
|
|
237
|
+
options,
|
|
238
|
+
Null.t<string>,
|
|
239
|
+
Logger.native,
|
|
240
|
+
array<string>,
|
|
241
|
+
) => t = "create"
|
|
242
|
+
|
|
243
|
+
// The storage of the entities `configJson` declares — the config the CLI
|
|
244
|
+
// wrote — or of none. The addon logs through `logger` itself, with the fields
|
|
245
|
+
// bound to it.
|
|
246
|
+
let make = (options, ~configJson=?, ~logger: Logger.t) =>
|
|
247
|
+
Core.getAddon().storage->classCreate(
|
|
248
|
+
options,
|
|
249
|
+
configJson->Null.fromOption,
|
|
250
|
+
logger.output.native,
|
|
251
|
+
logger.boundFieldsJson,
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
@send external layouts: t => layouts = "layouts"
|
|
255
|
+
|
|
256
|
+
@send external beginChanges: (t, ~entity: int, ~rows: int) => Staging.begun = "beginChanges"
|
|
257
|
+
|
|
258
|
+
@send external beginRows: (t, ~table: stagedTable, ~rows: int) => Staging.begun = "beginRows"
|
|
339
259
|
|
|
340
260
|
@send
|
|
341
261
|
external growStage: (
|
|
@@ -353,8 +273,8 @@ external commitStage: (t, ~handle: int, ~buffers: array<ArrayBuffer.t>) => unit
|
|
|
353
273
|
|
|
354
274
|
@send external discardStaged: (t, array<int>) => unit = "discardStaged"
|
|
355
275
|
|
|
356
|
-
let arena = (client,
|
|
357
|
-
beginStage: (~
|
|
276
|
+
let arena = (client, begin): Staging.arena => {
|
|
277
|
+
beginStage: (~rows) => begin(~rows),
|
|
358
278
|
growStage: (~handle, ~column, ~needed, ~stale) =>
|
|
359
279
|
client->growStage(~handle, ~column, ~needed, ~stale),
|
|
360
280
|
commitStage: (~handle, ~buffers) => client->commitStage(~handle, ~buffers),
|
|
@@ -391,13 +311,26 @@ let queryForTests = async (client, sql, ~params=[]) =>
|
|
|
391
311
|
@send
|
|
392
312
|
external loadWhereRaw: (t, int, array<LoadCondition.t>) => promise<queryResult> = "loadWhere"
|
|
393
313
|
|
|
394
|
-
let loadWhere = async (client, ~
|
|
395
|
-
client->read(await client->loadWhereRaw(
|
|
314
|
+
let loadWhere = async (client, ~entity, ~conditions) =>
|
|
315
|
+
client->read(await client->loadWhereRaw(entity, conditions))
|
|
316
|
+
|
|
317
|
+
@send
|
|
318
|
+
external loadEffectCacheRaw: (t, string, array<LoadCondition.t>) => promise<queryResult> =
|
|
319
|
+
"loadEffectCache"
|
|
320
|
+
|
|
321
|
+
let loadEffectCache = async (client, ~table, ~conditions) =>
|
|
322
|
+
client->read(await client->loadEffectCacheRaw(table, conditions))
|
|
323
|
+
|
|
324
|
+
@send
|
|
325
|
+
external clickHouseRowsForTestsRaw: (t, int) => promise<queryResult> = "clickhouseRowsForTests"
|
|
326
|
+
|
|
327
|
+
let clickHouseRowsForTests = async (client, ~entity) =>
|
|
328
|
+
client->read(await client->clickHouseRowsForTestsRaw(entity))
|
|
396
329
|
|
|
397
330
|
@send external historyForTestsRaw: (t, int) => promise<queryResult> = "historyForTests"
|
|
398
331
|
|
|
399
|
-
let historyForTests = async (client, ~
|
|
400
|
-
client->read(await client->historyForTestsRaw(
|
|
332
|
+
let historyForTests = async (client, ~entity) =>
|
|
333
|
+
client->read(await client->historyForTestsRaw(entity))
|
|
401
334
|
|
|
402
335
|
// What the storage holds before anything is initialized or resumed.
|
|
403
336
|
type holding =
|
|
@@ -419,49 +352,49 @@ type holding =
|
|
|
419
352
|
|
|
420
353
|
@send external readStoredConfig: t => promise<storedConfig> = "readStoredConfig"
|
|
421
354
|
|
|
422
|
-
|
|
355
|
+
// Resumes the chains this run drives, the only ones ClickHouse trims.
|
|
356
|
+
@send external resume: (t, array<ChainId.t>) => promise<resumed> = "resume"
|
|
423
357
|
|
|
424
358
|
@send external setChainMeta: (t, array<chainMeta>) => promise<unit> = "setChainMeta"
|
|
425
359
|
|
|
360
|
+
// Builds every index the schema promises for the chains, then stamps them
|
|
361
|
+
// ready at the given unix milliseconds.
|
|
426
362
|
@send
|
|
427
|
-
external finalizeBackfill: (t, array<
|
|
428
|
-
"finalizeBackfill"
|
|
363
|
+
external finalizeBackfill: (t, array<ChainId.t>, float) => promise<unit> = "finalizeBackfill"
|
|
429
364
|
|
|
430
|
-
@send
|
|
431
|
-
external ensureSchemaIndexes: (t, array<Core.pgIndexInput>) => promise<unit> = "ensureSchemaIndexes"
|
|
365
|
+
@send external ensureSchemaIndexes: (t, array<ChainId.t>) => promise<unit> = "ensureSchemaIndexes"
|
|
432
366
|
|
|
433
367
|
// Null when the indexes are already there, which is every call but the first,
|
|
434
|
-
// and every call for
|
|
368
|
+
// and every call for an entity Postgres doesn't keep.
|
|
435
369
|
@send
|
|
436
|
-
external ensureQueryIndexes: (
|
|
437
|
-
|
|
370
|
+
external ensureQueryIndexes: (
|
|
371
|
+
t,
|
|
372
|
+
~entity: int,
|
|
373
|
+
~chainId: Null.t<ChainId.t>,
|
|
374
|
+
~columns: array<string>,
|
|
375
|
+
) => Null.t<promise<unit>> = "ensureQueryIndexes"
|
|
438
376
|
|
|
439
377
|
@send external pruneCheckpoints: (t, bounds) => promise<unit> = "pruneCheckpoints"
|
|
440
378
|
|
|
441
379
|
@send external pruneHistory: (t, int, bounds) => promise<unit> = "pruneHistory"
|
|
442
380
|
|
|
443
381
|
@send
|
|
444
|
-
external rollbackTargetCheckpoint: (
|
|
445
|
-
|
|
446
|
-
ChainId.t,
|
|
447
|
-
int,
|
|
448
|
-
CheckpointSequence.t,
|
|
449
|
-
) => promise<Nullable.t<string>> = "rollbackTargetCheckpoint"
|
|
382
|
+
external rollbackTargetCheckpoint: (t, ChainId.t, int) => promise<Nullable.t<bigint>> =
|
|
383
|
+
"rollbackTargetCheckpoint"
|
|
450
384
|
|
|
451
385
|
@send
|
|
452
386
|
external rollbackProgressDiff: (t, bounds) => promise<array<progressDiff>> = "rollbackProgressDiff"
|
|
453
387
|
|
|
454
388
|
@send external rollbackData: (t, int, bounds) => promise<rollbackData> = "rollbackData"
|
|
455
389
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
type cacheDump = {tableName: string, path: string}
|
|
390
|
+
// Uploads the caches saved under the directory first when `upload` says to,
|
|
391
|
+
// logging how that went.
|
|
392
|
+
@send
|
|
393
|
+
external restoreEffectCache: (t, string, bool) => promise<array<storedEffectCache>> =
|
|
394
|
+
"restoreEffectCache"
|
|
463
395
|
|
|
464
|
-
|
|
396
|
+
// Never rejects: a dump that doesn't finish is logged.
|
|
397
|
+
@send external dumpEffectCache: (t, string) => promise<unit> = "dumpEffectCache"
|
|
465
398
|
|
|
466
399
|
@send external reset: t => promise<unit> = "reset"
|
|
467
400
|
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Core from "../Core.res.mjs";
|
|
4
4
|
import * as Reading from "../Reading.res.mjs";
|
|
5
|
+
import * as Stdlib_Null from "@rescript/runtime/lib/es6/Stdlib_Null.js";
|
|
5
6
|
|
|
6
|
-
function make(options,
|
|
7
|
-
return Core.getAddon().Storage.create(options,
|
|
7
|
+
function make(options, configJson, logger) {
|
|
8
|
+
return Core.getAddon().Storage.create(options, Stdlib_Null.fromOption(configJson), logger.output.native, logger.boundFieldsJson);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
function arena(client,
|
|
11
|
+
function arena(client, begin) {
|
|
11
12
|
return {
|
|
12
|
-
beginStage:
|
|
13
|
+
beginStage: rows => begin(rows),
|
|
13
14
|
growStage: (handle, column, needed, stale) => client.growStage(handle, column, needed, stale),
|
|
14
15
|
commitStage: (handle, buffers) => {
|
|
15
16
|
client.commitStage(handle, buffers);
|
|
@@ -39,12 +40,20 @@ async function queryForTests(client, sql, paramsOpt) {
|
|
|
39
40
|
return read(client, await client.queryForTests(sql, params));
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
async function loadWhere(client,
|
|
43
|
-
return read(client, await client.loadWhere(
|
|
43
|
+
async function loadWhere(client, entity, conditions) {
|
|
44
|
+
return read(client, await client.loadWhere(entity, conditions));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
async function
|
|
47
|
-
return read(client, await client.
|
|
47
|
+
async function loadEffectCache(client, table, conditions) {
|
|
48
|
+
return read(client, await client.loadEffectCache(table, conditions));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function clickHouseRowsForTests(client, entity) {
|
|
52
|
+
return read(client, await client.clickhouseRowsForTests(entity));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function historyForTests(client, entity) {
|
|
56
|
+
return read(client, await client.historyForTests(entity));
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
export {
|
|
@@ -53,6 +62,8 @@ export {
|
|
|
53
62
|
read,
|
|
54
63
|
queryForTests,
|
|
55
64
|
loadWhere,
|
|
65
|
+
loadEffectCache,
|
|
66
|
+
clickHouseRowsForTests,
|
|
56
67
|
historyForTests,
|
|
57
68
|
}
|
|
58
69
|
/* Core Not a pure module */
|
package/src/bindings/Vitest.res
CHANGED
|
@@ -169,29 +169,3 @@ let messageOfThrown: (unit => 'a) => option<string> = %raw(`function (fn) {
|
|
|
169
169
|
// happens to equal the placeholder.
|
|
170
170
|
let toThrowErrorEqual = (t: testContext, fn: unit => 'a, ~message=?, expected: string) =>
|
|
171
171
|
t.expect(fn->messageOfThrown, ~message?).toEqual(Some(expected))
|
|
172
|
-
|
|
173
|
-
// ============================================================================
|
|
174
|
-
// Fake timers
|
|
175
|
-
// ============================================================================
|
|
176
|
-
|
|
177
|
-
module Vi = {
|
|
178
|
-
@module("vitest") @scope("vi")
|
|
179
|
-
external useFakeTimers: unit => unit = "useFakeTimers"
|
|
180
|
-
|
|
181
|
-
@module("vitest") @scope("vi")
|
|
182
|
-
external useRealTimers: unit => unit = "useRealTimers"
|
|
183
|
-
|
|
184
|
-
// Runs every timer that comes due within the window, awaiting the
|
|
185
|
-
// microtasks each one queues before moving on.
|
|
186
|
-
@module("vitest") @scope("vi")
|
|
187
|
-
external advanceTimersByTimeAsync: int => promise<unit> = "advanceTimersByTimeAsync"
|
|
188
|
-
|
|
189
|
-
@module("vitest") @scope("vi")
|
|
190
|
-
external advanceTimersToNextTimerAsync: unit => promise<unit> = "advanceTimersToNextTimerAsync"
|
|
191
|
-
|
|
192
|
-
@module("vitest") @scope("vi")
|
|
193
|
-
external getTimerCount: unit => int = "getTimerCount"
|
|
194
|
-
|
|
195
|
-
@module("vitest") @scope("vi")
|
|
196
|
-
external clearAllTimers: unit => unit = "clearAllTimers"
|
|
197
|
-
}
|