envio 3.15.0-subgraph → 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 +3 -3
- package/fuel.schema.json +2 -2
- package/index.d.ts +3 -3
- package/licenses/README.md +1 -1
- package/package.json +9 -10
- package/src/Batch.res.mjs +5 -5
- package/src/BatchProcessing.res +1 -0
- package/src/BatchProcessing.res.mjs +1 -0
- package/src/Bin.res +0 -7
- package/src/Bin.res.mjs +0 -8
- package/src/ChainFetching.res +17 -456
- package/src/ChainFetching.res.mjs +33 -404
- package/src/ChainState.res +48 -83
- package/src/ChainState.res.mjs +83 -115
- package/src/ChainState.resi +0 -26
- package/src/Clock.res +57 -0
- package/src/Clock.res.mjs +72 -0
- package/src/Config.res +7 -16
- package/src/Config.res.mjs +4 -11
- package/src/ContractRegisterContext.res +6 -3
- package/src/ContractRegisterContext.res.mjs +2 -4
- package/src/Core.res +5 -136
- package/src/Core.res.mjs +1 -90
- package/src/CrossChainState.res +2 -8
- package/src/CrossChainState.res.mjs +3 -3
- package/src/Ecosystem.res +4 -7
- package/src/Ecosystem.res.mjs +8 -8
- 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/Env.res +0 -16
- package/src/Env.res.mjs +0 -11
- package/src/EventProcessing.res +1 -38
- package/src/EventProcessing.res.mjs +1 -28
- package/src/FetchState.res +160 -319
- package/src/FetchState.res.mjs +182 -292
- package/src/FinalizeBackfill.res +2 -4
- package/src/FinalizeBackfill.res.mjs +3 -4
- package/src/HandlerLoader.res +15 -39
- package/src/HandlerLoader.res.mjs +8 -27
- package/src/HandlerRegister.res +0 -4
- package/src/HandlerRegister.res.mjs +2 -5
- package/src/HandlerRegister.resi +0 -2
- 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 -110
- package/src/Internal.res.mjs +1 -115
- package/src/LoadLayer.res +21 -47
- package/src/LoadLayer.res.mjs +47 -72
- package/src/LoadLayer.resi +0 -26
- package/src/Main.res +1 -14
- package/src/Main.res.mjs +3 -4
- 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/RunScope.res +0 -3
- package/src/SafeCheckpointTracking.res +4 -4
- package/src/SafeCheckpointTracking.res.mjs +1 -1
- package/src/SimulateItems.res +26 -42
- package/src/SimulateItems.res.mjs +16 -40
- 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 -998
- package/src/Storage.res.mjs +216 -731
- 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/UserContext.res +46 -410
- package/src/UserContext.res.mjs +30 -318
- package/src/Utils.res +0 -23
- package/src/Utils.res.mjs +1 -17
- 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 -175
- 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/AddressSet.res +0 -2
- package/src/sources/AddressStore.res +0 -3
- package/src/sources/ChainSources.res +2 -0
- package/src/sources/ChainSources.res.mjs +2 -2
- package/src/sources/EvmChain.res +4 -7
- package/src/sources/EvmChain.res.mjs +5 -4
- 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/HyperSync.res +1 -2
- package/src/sources/HyperSync.res.mjs +1 -2
- 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 +85 -104
- package/src/sources/SourceManager.res.mjs +18 -37
- package/src/sources/SourceManager.resi +3 -5
- package/src/sources/StartBlockResolver.res +1 -0
- package/src/sources/StartBlockResolver.res.mjs +4 -3
- package/src/sources/SvmHyperSyncSource.res +2 -2
- package/src/sources/SvmHyperSyncSource.res.mjs +1 -1
- package/svm.schema.json +3 -3
- package/src/EffectCacheLookup.res +0 -98
- package/src/EffectCacheLookup.res.mjs +0 -116
- package/src/PgWriting.res +0 -36
- package/src/PgWriting.res.mjs +0 -34
- package/src/PreloadLookahead.res +0 -184
- package/src/PreloadLookahead.res.mjs +0 -197
- package/src/SubgraphLog.res +0 -19
- package/src/SubgraphLog.res.mjs +0 -26
- package/src/SyncWrites.res +0 -101
- package/src/SyncWrites.res.mjs +0 -98
- package/src/db/IndexDefinition.res +0 -47
- package/src/db/IndexDefinition.res.mjs +0 -60
- package/src/sources/CallSource.res +0 -274
- package/src/sources/CallSource.res.mjs +0 -196
- package/src/subgraph/abi-types.ts +0 -84
- package/src/subgraph/aggregations.ts +0 -745
- package/src/subgraph/as-package.ts +0 -143
- package/src/subgraph/assemblyscript-regex.ts +0 -67
- package/src/subgraph/assemblyscript.ts +0 -731
- package/src/subgraph/blocks.ts +0 -398
- package/src/subgraph/calls-source.ts +0 -702
- package/src/subgraph/calls.ts +0 -258
- package/src/subgraph/conformance.ts +0 -106
- package/src/subgraph/errors.ts +0 -85
- package/src/subgraph/graft.ts +0 -73
- package/src/subgraph/graph-cli-worker.mjs +0 -35
- package/src/subgraph/graph-cli.ts +0 -900
- package/src/subgraph/graph-node-decimal.ts +0 -199
- package/src/subgraph/graph-ts-enums.ts +0 -28
- package/src/subgraph/graph-ts-types/VERSION +0 -2
- package/src/subgraph/graph-ts-types/chain/arweave.d.ts +0 -70
- package/src/subgraph/graph-ts-types/chain/cosmos.d.ts +0 -327
- package/src/subgraph/graph-ts-types/chain/ethereum.d.ts +0 -233
- package/src/subgraph/graph-ts-types/chain/near.d.ts +0 -253
- package/src/subgraph/graph-ts-types/chain/starknet.d.ts +0 -32
- package/src/subgraph/graph-ts-types/common/collections.d.ts +0 -136
- package/src/subgraph/graph-ts-types/common/conversion.d.ts +0 -11
- package/src/subgraph/graph-ts-types/common/datasource.d.ts +0 -30
- package/src/subgraph/graph-ts-types/common/eager-offset.d.ts +0 -0
- package/src/subgraph/graph-ts-types/common/json.d.ts +0 -17
- package/src/subgraph/graph-ts-types/common/numbers.d.ts +0 -120
- package/src/subgraph/graph-ts-types/common/value.d.ts +0 -120
- package/src/subgraph/graph-ts-types/common/yaml.d.ts +0 -90
- package/src/subgraph/graph-ts-types/global/global.d.ts +0 -194
- package/src/subgraph/graph-ts-types/helper-functions.d.ts +0 -22
- package/src/subgraph/graph-ts-types/index.d.ts +0 -102
- package/src/subgraph/graph-ts.ts +0 -4280
- package/src/subgraph/hosts.ts +0 -554
- package/src/subgraph/log.ts +0 -28
- package/src/subgraph/receipts.ts +0 -184
- package/src/subgraph/register-slots.ts +0 -93
- package/src/subgraph/rollup.ts +0 -109
- package/src/subgraph/rpc.ts +0 -337
- package/src/subgraph/runtime.ts +0 -2060
- package/src/subgraph/scope.ts +0 -177
- package/src/subgraph/stats.ts +0 -42
- package/src/subgraph/template-instances.ts +0 -66
- package/src/subgraph/toolchain.ts +0 -327
- package/src/subgraph/transient.ts +0 -176
|
@@ -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,36 +108,18 @@ 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>,
|
|
161
115
|
addresses: addresses,
|
|
162
|
-
keptEffectCaches?: array<string>,
|
|
163
116
|
}
|
|
164
117
|
|
|
165
118
|
type addChain = {
|
|
166
119
|
chain: chainConfig,
|
|
167
|
-
partitions: array<partition>,
|
|
168
120
|
addresses: addresses,
|
|
169
121
|
}
|
|
170
122
|
|
|
171
|
-
type resume = {
|
|
172
|
-
sequence: CheckpointSequence.t,
|
|
173
|
-
// Every entity table.
|
|
174
|
-
tables: array<int>,
|
|
175
|
-
// The chains this run drives, which are the only ones trimmed.
|
|
176
|
-
chainIds: array<ChainId.t>,
|
|
177
|
-
}
|
|
178
|
-
|
|
179
123
|
type storedChain = {
|
|
180
124
|
id: float,
|
|
181
125
|
ecosystem: string,
|
|
@@ -204,11 +148,11 @@ type resumedChain = {
|
|
|
204
148
|
// Unix seconds.
|
|
205
149
|
progressBlockTime?: float,
|
|
206
150
|
sourceBlock: int,
|
|
207
|
-
checkpointId:
|
|
151
|
+
checkpointId: bigint,
|
|
208
152
|
}
|
|
209
153
|
|
|
210
154
|
type reorgCheckpoint = {
|
|
211
|
-
id:
|
|
155
|
+
id: bigint,
|
|
212
156
|
chainId: float,
|
|
213
157
|
blockNumber: int,
|
|
214
158
|
blockHash: string,
|
|
@@ -228,57 +172,40 @@ type progressDiff = {
|
|
|
228
172
|
|
|
229
173
|
type rollbackData = {removed: queryResult, restored: queryResult}
|
|
230
174
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// Rows of a batch: staged into an arena, or one rendered parameter per cell,
|
|
237
|
-
// every row's first column first.
|
|
238
|
-
type rows = {
|
|
239
|
-
staged?: int,
|
|
240
|
-
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,
|
|
241
180
|
rows: int,
|
|
242
181
|
}
|
|
243
182
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
sets?: rows,
|
|
247
|
-
setCheckpointIds: array<string>,
|
|
248
|
-
deleteIds: array<string>,
|
|
249
|
-
deleteCheckpointIds: array<string>,
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
type postgresEntityWrite = {
|
|
253
|
-
sets?: rows,
|
|
254
|
-
deletes: array<string>,
|
|
255
|
-
history?: historyWrite,
|
|
256
|
-
}
|
|
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.
|
|
257
185
|
|
|
258
|
-
|
|
259
|
-
|
|
186
|
+
// One entity's changes within one chain scope, staged.
|
|
187
|
+
type changes = {
|
|
188
|
+
entity: int,
|
|
260
189
|
chainId?: ChainId.t,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
clickhouse?: int,
|
|
190
|
+
keepsHistory: bool,
|
|
191
|
+
changes: int,
|
|
264
192
|
}
|
|
265
193
|
|
|
266
194
|
type diffCheckpoint = {
|
|
267
195
|
chainId: ChainId.t,
|
|
268
|
-
checkpointId:
|
|
196
|
+
checkpointId: bigint,
|
|
269
197
|
blockNumber: int,
|
|
270
198
|
}
|
|
271
199
|
|
|
272
200
|
type rollbackWrite = {
|
|
273
201
|
bounds: bounds,
|
|
274
|
-
tables: array<int>,
|
|
275
202
|
progress: array<progress>,
|
|
276
203
|
removedAddresses: addresses,
|
|
277
204
|
diffCheckpoints: array<diffCheckpoint>,
|
|
278
205
|
}
|
|
279
206
|
|
|
280
207
|
type checkpoints = {
|
|
281
|
-
ids: array<
|
|
208
|
+
ids: array<bigint>,
|
|
282
209
|
chainIds: array<ChainId.t>,
|
|
283
210
|
blockNumbers: array<int>,
|
|
284
211
|
blockHashes: array<Null.t<string>>,
|
|
@@ -286,17 +213,15 @@ type checkpoints = {
|
|
|
286
213
|
keepsHistory: array<bool>,
|
|
287
214
|
}
|
|
288
215
|
|
|
289
|
-
type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<
|
|
290
|
-
|
|
291
|
-
type tableWrite = {table: int, rows: rows}
|
|
216
|
+
type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<bigint>}
|
|
292
217
|
|
|
293
|
-
type effectCacheWrite = {table:
|
|
218
|
+
type effectCacheWrite = {table: string, create: bool, rows: int}
|
|
294
219
|
|
|
295
220
|
type batch = {
|
|
296
221
|
rollback?: rollbackWrite,
|
|
297
222
|
progress: array<progress>,
|
|
298
|
-
rawEvents?:
|
|
299
|
-
|
|
223
|
+
rawEvents?: int,
|
|
224
|
+
changes: array<changes>,
|
|
300
225
|
chainMeta: array<chainMeta>,
|
|
301
226
|
addresses: addresses,
|
|
302
227
|
frontier: frontier,
|
|
@@ -306,37 +231,31 @@ type batch = {
|
|
|
306
231
|
|
|
307
232
|
type writeTiming = {store: store, seconds: float}
|
|
308
233
|
|
|
309
|
-
// What a build was for, which decides how much an existing index has to match.
|
|
310
|
-
type indexPurpose = | @as("Query") Query | @as("Schema") Schema
|
|
311
|
-
|
|
312
|
-
@tag("kind")
|
|
313
|
-
type indexEvent =
|
|
314
|
-
| Invalid({names: array<string>})
|
|
315
|
-
| Planned({declared: int, missing: array<string>, rebuilt: array<string>})
|
|
316
|
-
| Building({purpose: indexPurpose, name: string, tableName: string, isRebuild: bool})
|
|
317
|
-
| Built({purpose: indexPurpose, name: string, seconds: float})
|
|
318
|
-
| Failed({
|
|
319
|
-
purpose: indexPurpose,
|
|
320
|
-
name: string,
|
|
321
|
-
tableName: string,
|
|
322
|
-
columns: array<string>,
|
|
323
|
-
error: string,
|
|
324
|
-
code?: string,
|
|
325
|
-
})
|
|
326
|
-
| ResyncFailed({name: string, error: string, code?: string})
|
|
327
|
-
| Committed({count: int, seconds: float})
|
|
328
|
-
|
|
329
|
-
@send
|
|
330
|
-
external classCreate: (Core.storageCtor, options, indexEvent => unit, string => unit) => t =
|
|
331
|
-
"create"
|
|
332
|
-
|
|
333
|
-
let make = (options, ~onIndexEvent, ~onWarning) =>
|
|
334
|
-
Core.getAddon().storage->classCreate(options, onIndexEvent, onWarning)
|
|
335
|
-
|
|
336
|
-
@send external registerTable: (t, tableInput) => registeredTable = "registerTable"
|
|
337
|
-
|
|
338
234
|
@send
|
|
339
|
-
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"
|
|
340
259
|
|
|
341
260
|
@send
|
|
342
261
|
external growStage: (
|
|
@@ -354,8 +273,8 @@ external commitStage: (t, ~handle: int, ~buffers: array<ArrayBuffer.t>) => unit
|
|
|
354
273
|
|
|
355
274
|
@send external discardStaged: (t, array<int>) => unit = "discardStaged"
|
|
356
275
|
|
|
357
|
-
let arena = (client,
|
|
358
|
-
beginStage: (~
|
|
276
|
+
let arena = (client, begin): Staging.arena => {
|
|
277
|
+
beginStage: (~rows) => begin(~rows),
|
|
359
278
|
growStage: (~handle, ~column, ~needed, ~stale) =>
|
|
360
279
|
client->growStage(~handle, ~column, ~needed, ~stale),
|
|
361
280
|
commitStage: (~handle, ~buffers) => client->commitStage(~handle, ~buffers),
|
|
@@ -392,13 +311,26 @@ let queryForTests = async (client, sql, ~params=[]) =>
|
|
|
392
311
|
@send
|
|
393
312
|
external loadWhereRaw: (t, int, array<LoadCondition.t>) => promise<queryResult> = "loadWhere"
|
|
394
313
|
|
|
395
|
-
let loadWhere = async (client, ~
|
|
396
|
-
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))
|
|
397
329
|
|
|
398
330
|
@send external historyForTestsRaw: (t, int) => promise<queryResult> = "historyForTests"
|
|
399
331
|
|
|
400
|
-
let historyForTests = async (client, ~
|
|
401
|
-
client->read(await client->historyForTestsRaw(
|
|
332
|
+
let historyForTests = async (client, ~entity) =>
|
|
333
|
+
client->read(await client->historyForTestsRaw(entity))
|
|
402
334
|
|
|
403
335
|
// What the storage holds before anything is initialized or resumed.
|
|
404
336
|
type holding =
|
|
@@ -420,49 +352,49 @@ type holding =
|
|
|
420
352
|
|
|
421
353
|
@send external readStoredConfig: t => promise<storedConfig> = "readStoredConfig"
|
|
422
354
|
|
|
423
|
-
|
|
355
|
+
// Resumes the chains this run drives, the only ones ClickHouse trims.
|
|
356
|
+
@send external resume: (t, array<ChainId.t>) => promise<resumed> = "resume"
|
|
424
357
|
|
|
425
358
|
@send external setChainMeta: (t, array<chainMeta>) => promise<unit> = "setChainMeta"
|
|
426
359
|
|
|
360
|
+
// Builds every index the schema promises for the chains, then stamps them
|
|
361
|
+
// ready at the given unix milliseconds.
|
|
427
362
|
@send
|
|
428
|
-
external finalizeBackfill: (t, array<
|
|
429
|
-
"finalizeBackfill"
|
|
363
|
+
external finalizeBackfill: (t, array<ChainId.t>, float) => promise<unit> = "finalizeBackfill"
|
|
430
364
|
|
|
431
|
-
@send
|
|
432
|
-
external ensureSchemaIndexes: (t, array<Core.pgIndexInput>) => promise<unit> = "ensureSchemaIndexes"
|
|
365
|
+
@send external ensureSchemaIndexes: (t, array<ChainId.t>) => promise<unit> = "ensureSchemaIndexes"
|
|
433
366
|
|
|
434
367
|
// Null when the indexes are already there, which is every call but the first,
|
|
435
|
-
// and every call for
|
|
368
|
+
// and every call for an entity Postgres doesn't keep.
|
|
436
369
|
@send
|
|
437
|
-
external ensureQueryIndexes: (
|
|
438
|
-
|
|
370
|
+
external ensureQueryIndexes: (
|
|
371
|
+
t,
|
|
372
|
+
~entity: int,
|
|
373
|
+
~chainId: Null.t<ChainId.t>,
|
|
374
|
+
~columns: array<string>,
|
|
375
|
+
) => Null.t<promise<unit>> = "ensureQueryIndexes"
|
|
439
376
|
|
|
440
377
|
@send external pruneCheckpoints: (t, bounds) => promise<unit> = "pruneCheckpoints"
|
|
441
378
|
|
|
442
379
|
@send external pruneHistory: (t, int, bounds) => promise<unit> = "pruneHistory"
|
|
443
380
|
|
|
444
381
|
@send
|
|
445
|
-
external rollbackTargetCheckpoint: (
|
|
446
|
-
|
|
447
|
-
ChainId.t,
|
|
448
|
-
int,
|
|
449
|
-
CheckpointSequence.t,
|
|
450
|
-
) => promise<Nullable.t<string>> = "rollbackTargetCheckpoint"
|
|
382
|
+
external rollbackTargetCheckpoint: (t, ChainId.t, int) => promise<Nullable.t<bigint>> =
|
|
383
|
+
"rollbackTargetCheckpoint"
|
|
451
384
|
|
|
452
385
|
@send
|
|
453
386
|
external rollbackProgressDiff: (t, bounds) => promise<array<progressDiff>> = "rollbackProgressDiff"
|
|
454
387
|
|
|
455
388
|
@send external rollbackData: (t, int, bounds) => promise<rollbackData> = "rollbackData"
|
|
456
389
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
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"
|
|
464
395
|
|
|
465
|
-
|
|
396
|
+
// Never rejects: a dump that doesn't finish is logged.
|
|
397
|
+
@send external dumpEffectCache: (t, string) => promise<unit> = "dumpEffectCache"
|
|
466
398
|
|
|
467
399
|
@send external reset: t => promise<unit> = "reset"
|
|
468
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
|
-
}
|