envio 3.15.0 → 3.16.0-subgraph
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 +10 -9
- package/src/Batch.res.mjs +5 -5
- package/src/BatchProcessing.res +1 -0
- package/src/BatchProcessing.res.mjs +1 -0
- package/src/Bin.res +7 -0
- package/src/Bin.res.mjs +8 -0
- package/src/ChainFetching.res +450 -16
- package/src/ChainFetching.res.mjs +403 -32
- package/src/ChainState.res +124 -7
- package/src/ChainState.res.mjs +128 -67
- package/src/ChainState.resi +26 -0
- package/src/Clock.res +57 -0
- package/src/Clock.res.mjs +72 -0
- package/src/Config.res +31 -3
- package/src/Config.res.mjs +15 -4
- package/src/ContractRegisterContext.res +3 -6
- package/src/ContractRegisterContext.res.mjs +4 -2
- package/src/Core.res +95 -36
- package/src/Core.res.mjs +90 -1
- package/src/CrossChainState.res +12 -2
- package/src/CrossChainState.res.mjs +3 -3
- package/src/Ecosystem.res +7 -4
- package/src/Ecosystem.res.mjs +8 -8
- package/src/EffectCacheLookup.res +98 -0
- package/src/EffectCacheLookup.res.mjs +116 -0
- 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 +20 -0
- package/src/Env.res.mjs +16 -0
- package/src/EventProcessing.res +38 -1
- package/src/EventProcessing.res.mjs +28 -1
- package/src/FetchState.res +408 -73
- package/src/FetchState.res.mjs +361 -91
- package/src/FinalizeBackfill.res +2 -4
- package/src/FinalizeBackfill.res.mjs +3 -4
- package/src/HandlerLoader.res +39 -15
- package/src/HandlerLoader.res.mjs +27 -8
- package/src/HandlerRegister.res +4 -0
- package/src/HandlerRegister.res.mjs +5 -2
- package/src/HandlerRegister.resi +2 -0
- 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 +61 -49
- package/src/Internal.res.mjs +36 -80
- package/src/LoadLayer.res +54 -15
- package/src/LoadLayer.res.mjs +75 -45
- package/src/LoadLayer.resi +26 -0
- package/src/Main.res +14 -1
- package/src/Main.res.mjs +4 -3
- package/src/Persistence.res +3 -23
- package/src/Persistence.res.mjs +3 -3
- package/src/PreloadLookahead.res +202 -0
- package/src/PreloadLookahead.res.mjs +218 -0
- package/src/Rollback.res +0 -1
- package/src/Rollback.res.mjs +1 -1
- package/src/RunScope.res +3 -0
- package/src/SafeCheckpointTracking.res +4 -4
- package/src/SafeCheckpointTracking.res.mjs +1 -1
- package/src/SimulateItems.res +42 -26
- package/src/SimulateItems.res.mjs +40 -16
- 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 +303 -948
- package/src/Storage.res.mjs +229 -708
- package/src/SubgraphLog.res +19 -0
- package/src/SubgraphLog.res.mjs +26 -0
- package/src/Supervisor.res +75 -56
- package/src/Supervisor.res.mjs +55 -26
- package/src/SyncWrites.res +107 -0
- package/src/SyncWrites.res.mjs +98 -0
- 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 +419 -46
- package/src/UserContext.res.mjs +318 -30
- package/src/Utils.res +17 -6
- package/src/Utils.res.mjs +12 -6
- 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 +108 -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/AddressSet.res +2 -0
- package/src/sources/AddressStore.res +3 -0
- package/src/sources/CallSource.res +274 -0
- package/src/sources/CallSource.res.mjs +196 -0
- package/src/sources/ChainSources.res +2 -0
- package/src/sources/ChainSources.res.mjs +2 -2
- package/src/sources/EvmChain.res +10 -1
- package/src/sources/EvmChain.res.mjs +6 -3
- 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 +2 -1
- package/src/sources/HyperSync.res.mjs +2 -1
- 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/src/subgraph/abi-types.ts +84 -0
- package/src/subgraph/aggregations.ts +745 -0
- package/src/subgraph/as-package.ts +143 -0
- package/src/subgraph/assemblyscript-regex.ts +67 -0
- package/src/subgraph/assemblyscript.ts +731 -0
- package/src/subgraph/blocks.ts +398 -0
- package/src/subgraph/calls-source.ts +702 -0
- package/src/subgraph/calls.ts +258 -0
- package/src/subgraph/conformance.ts +106 -0
- package/src/subgraph/errors.ts +85 -0
- package/src/subgraph/graft.ts +73 -0
- package/src/subgraph/graph-cli-worker.mjs +35 -0
- package/src/subgraph/graph-cli.ts +900 -0
- package/src/subgraph/graph-node-decimal.ts +199 -0
- package/src/subgraph/graph-ts-enums.ts +28 -0
- package/src/subgraph/graph-ts-types/VERSION +2 -0
- package/src/subgraph/graph-ts-types/chain/arweave.d.ts +70 -0
- package/src/subgraph/graph-ts-types/chain/cosmos.d.ts +327 -0
- package/src/subgraph/graph-ts-types/chain/ethereum.d.ts +233 -0
- package/src/subgraph/graph-ts-types/chain/near.d.ts +253 -0
- package/src/subgraph/graph-ts-types/chain/starknet.d.ts +32 -0
- package/src/subgraph/graph-ts-types/common/collections.d.ts +136 -0
- package/src/subgraph/graph-ts-types/common/conversion.d.ts +11 -0
- package/src/subgraph/graph-ts-types/common/datasource.d.ts +30 -0
- package/src/subgraph/graph-ts-types/common/eager-offset.d.ts +0 -0
- package/src/subgraph/graph-ts-types/common/json.d.ts +17 -0
- package/src/subgraph/graph-ts-types/common/numbers.d.ts +120 -0
- package/src/subgraph/graph-ts-types/common/value.d.ts +120 -0
- package/src/subgraph/graph-ts-types/common/yaml.d.ts +90 -0
- package/src/subgraph/graph-ts-types/global/global.d.ts +194 -0
- package/src/subgraph/graph-ts-types/helper-functions.d.ts +22 -0
- package/src/subgraph/graph-ts-types/index.d.ts +102 -0
- package/src/subgraph/graph-ts.ts +4339 -0
- package/src/subgraph/hosts.ts +554 -0
- package/src/subgraph/log.ts +28 -0
- package/src/subgraph/receipts.ts +184 -0
- package/src/subgraph/register-slots.ts +93 -0
- package/src/subgraph/rollup.ts +109 -0
- package/src/subgraph/rpc.ts +337 -0
- package/src/subgraph/runtime.ts +2059 -0
- package/src/subgraph/scope.ts +176 -0
- package/src/subgraph/stats.ts +42 -0
- package/src/subgraph/template-instances.ts +66 -0
- package/src/subgraph/toolchain.ts +327 -0
- package/src/subgraph/transient.ts +176 -0
- 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,35 +108,19 @@ 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,
|
|
116
|
+
keptEffectCaches?: array<string>,
|
|
162
117
|
}
|
|
163
118
|
|
|
164
119
|
type addChain = {
|
|
165
120
|
chain: chainConfig,
|
|
166
|
-
partitions: array<partition>,
|
|
167
121
|
addresses: addresses,
|
|
168
122
|
}
|
|
169
123
|
|
|
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
124
|
type storedChain = {
|
|
179
125
|
id: float,
|
|
180
126
|
ecosystem: string,
|
|
@@ -203,11 +149,11 @@ type resumedChain = {
|
|
|
203
149
|
// Unix seconds.
|
|
204
150
|
progressBlockTime?: float,
|
|
205
151
|
sourceBlock: int,
|
|
206
|
-
checkpointId:
|
|
152
|
+
checkpointId: bigint,
|
|
207
153
|
}
|
|
208
154
|
|
|
209
155
|
type reorgCheckpoint = {
|
|
210
|
-
id:
|
|
156
|
+
id: bigint,
|
|
211
157
|
chainId: float,
|
|
212
158
|
blockNumber: int,
|
|
213
159
|
blockHash: string,
|
|
@@ -227,57 +173,40 @@ type progressDiff = {
|
|
|
227
173
|
|
|
228
174
|
type rollbackData = {removed: queryResult, restored: queryResult}
|
|
229
175
|
|
|
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>>,
|
|
176
|
+
// `chainId` is left out for a cross-chain cache.
|
|
177
|
+
type storedEffectCache = {
|
|
178
|
+
effectName: string,
|
|
179
|
+
chainId?: ChainId.t,
|
|
180
|
+
tableName: string,
|
|
240
181
|
rows: int,
|
|
241
182
|
}
|
|
242
183
|
|
|
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
|
-
}
|
|
184
|
+
// An optional field is left out rather than null, both ways: the addon refuses
|
|
185
|
+
// a null for one, and leaves out one it has no value for.
|
|
256
186
|
|
|
257
|
-
|
|
258
|
-
|
|
187
|
+
// One entity's changes within one chain scope, staged.
|
|
188
|
+
type changes = {
|
|
189
|
+
entity: int,
|
|
259
190
|
chainId?: ChainId.t,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
clickhouse?: int,
|
|
191
|
+
keepsHistory: bool,
|
|
192
|
+
changes: int,
|
|
263
193
|
}
|
|
264
194
|
|
|
265
195
|
type diffCheckpoint = {
|
|
266
196
|
chainId: ChainId.t,
|
|
267
|
-
checkpointId:
|
|
197
|
+
checkpointId: bigint,
|
|
268
198
|
blockNumber: int,
|
|
269
199
|
}
|
|
270
200
|
|
|
271
201
|
type rollbackWrite = {
|
|
272
202
|
bounds: bounds,
|
|
273
|
-
tables: array<int>,
|
|
274
203
|
progress: array<progress>,
|
|
275
204
|
removedAddresses: addresses,
|
|
276
205
|
diffCheckpoints: array<diffCheckpoint>,
|
|
277
206
|
}
|
|
278
207
|
|
|
279
208
|
type checkpoints = {
|
|
280
|
-
ids: array<
|
|
209
|
+
ids: array<bigint>,
|
|
281
210
|
chainIds: array<ChainId.t>,
|
|
282
211
|
blockNumbers: array<int>,
|
|
283
212
|
blockHashes: array<Null.t<string>>,
|
|
@@ -285,17 +214,15 @@ type checkpoints = {
|
|
|
285
214
|
keepsHistory: array<bool>,
|
|
286
215
|
}
|
|
287
216
|
|
|
288
|
-
type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<
|
|
289
|
-
|
|
290
|
-
type tableWrite = {table: int, rows: rows}
|
|
217
|
+
type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<bigint>}
|
|
291
218
|
|
|
292
|
-
type effectCacheWrite = {table:
|
|
219
|
+
type effectCacheWrite = {table: string, create: bool, rows: int}
|
|
293
220
|
|
|
294
221
|
type batch = {
|
|
295
222
|
rollback?: rollbackWrite,
|
|
296
223
|
progress: array<progress>,
|
|
297
|
-
rawEvents?:
|
|
298
|
-
|
|
224
|
+
rawEvents?: int,
|
|
225
|
+
changes: array<changes>,
|
|
299
226
|
chainMeta: array<chainMeta>,
|
|
300
227
|
addresses: addresses,
|
|
301
228
|
frontier: frontier,
|
|
@@ -305,37 +232,31 @@ type batch = {
|
|
|
305
232
|
|
|
306
233
|
type writeTiming = {store: store, seconds: float}
|
|
307
234
|
|
|
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
235
|
@send
|
|
338
|
-
external
|
|
236
|
+
external classCreate: (
|
|
237
|
+
Core.storageCtor,
|
|
238
|
+
options,
|
|
239
|
+
Null.t<string>,
|
|
240
|
+
Logger.native,
|
|
241
|
+
array<string>,
|
|
242
|
+
) => t = "create"
|
|
243
|
+
|
|
244
|
+
// The storage of the entities `configJson` declares — the config the CLI
|
|
245
|
+
// wrote — or of none. The addon logs through `logger` itself, with the fields
|
|
246
|
+
// bound to it.
|
|
247
|
+
let make = (options, ~configJson=?, ~logger: Logger.t) =>
|
|
248
|
+
Core.getAddon().storage->classCreate(
|
|
249
|
+
options,
|
|
250
|
+
configJson->Null.fromOption,
|
|
251
|
+
logger.output.native,
|
|
252
|
+
logger.boundFieldsJson,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
@send external layouts: t => layouts = "layouts"
|
|
256
|
+
|
|
257
|
+
@send external beginChanges: (t, ~entity: int, ~rows: int) => Staging.begun = "beginChanges"
|
|
258
|
+
|
|
259
|
+
@send external beginRows: (t, ~table: stagedTable, ~rows: int) => Staging.begun = "beginRows"
|
|
339
260
|
|
|
340
261
|
@send
|
|
341
262
|
external growStage: (
|
|
@@ -353,8 +274,8 @@ external commitStage: (t, ~handle: int, ~buffers: array<ArrayBuffer.t>) => unit
|
|
|
353
274
|
|
|
354
275
|
@send external discardStaged: (t, array<int>) => unit = "discardStaged"
|
|
355
276
|
|
|
356
|
-
let arena = (client,
|
|
357
|
-
beginStage: (~
|
|
277
|
+
let arena = (client, begin): Staging.arena => {
|
|
278
|
+
beginStage: (~rows) => begin(~rows),
|
|
358
279
|
growStage: (~handle, ~column, ~needed, ~stale) =>
|
|
359
280
|
client->growStage(~handle, ~column, ~needed, ~stale),
|
|
360
281
|
commitStage: (~handle, ~buffers) => client->commitStage(~handle, ~buffers),
|
|
@@ -391,13 +312,26 @@ let queryForTests = async (client, sql, ~params=[]) =>
|
|
|
391
312
|
@send
|
|
392
313
|
external loadWhereRaw: (t, int, array<LoadCondition.t>) => promise<queryResult> = "loadWhere"
|
|
393
314
|
|
|
394
|
-
let loadWhere = async (client, ~
|
|
395
|
-
client->read(await client->loadWhereRaw(
|
|
315
|
+
let loadWhere = async (client, ~entity, ~conditions) =>
|
|
316
|
+
client->read(await client->loadWhereRaw(entity, conditions))
|
|
317
|
+
|
|
318
|
+
@send
|
|
319
|
+
external loadEffectCacheRaw: (t, string, array<LoadCondition.t>) => promise<queryResult> =
|
|
320
|
+
"loadEffectCache"
|
|
321
|
+
|
|
322
|
+
let loadEffectCache = async (client, ~table, ~conditions) =>
|
|
323
|
+
client->read(await client->loadEffectCacheRaw(table, conditions))
|
|
324
|
+
|
|
325
|
+
@send
|
|
326
|
+
external clickHouseRowsForTestsRaw: (t, int) => promise<queryResult> = "clickhouseRowsForTests"
|
|
327
|
+
|
|
328
|
+
let clickHouseRowsForTests = async (client, ~entity) =>
|
|
329
|
+
client->read(await client->clickHouseRowsForTestsRaw(entity))
|
|
396
330
|
|
|
397
331
|
@send external historyForTestsRaw: (t, int) => promise<queryResult> = "historyForTests"
|
|
398
332
|
|
|
399
|
-
let historyForTests = async (client, ~
|
|
400
|
-
client->read(await client->historyForTestsRaw(
|
|
333
|
+
let historyForTests = async (client, ~entity) =>
|
|
334
|
+
client->read(await client->historyForTestsRaw(entity))
|
|
401
335
|
|
|
402
336
|
// What the storage holds before anything is initialized or resumed.
|
|
403
337
|
type holding =
|
|
@@ -419,49 +353,49 @@ type holding =
|
|
|
419
353
|
|
|
420
354
|
@send external readStoredConfig: t => promise<storedConfig> = "readStoredConfig"
|
|
421
355
|
|
|
422
|
-
|
|
356
|
+
// Resumes the chains this run drives, the only ones ClickHouse trims.
|
|
357
|
+
@send external resume: (t, array<ChainId.t>) => promise<resumed> = "resume"
|
|
423
358
|
|
|
424
359
|
@send external setChainMeta: (t, array<chainMeta>) => promise<unit> = "setChainMeta"
|
|
425
360
|
|
|
361
|
+
// Builds every index the schema promises for the chains, then stamps them
|
|
362
|
+
// ready at the given unix milliseconds.
|
|
426
363
|
@send
|
|
427
|
-
external finalizeBackfill: (t, array<
|
|
428
|
-
"finalizeBackfill"
|
|
364
|
+
external finalizeBackfill: (t, array<ChainId.t>, float) => promise<unit> = "finalizeBackfill"
|
|
429
365
|
|
|
430
|
-
@send
|
|
431
|
-
external ensureSchemaIndexes: (t, array<Core.pgIndexInput>) => promise<unit> = "ensureSchemaIndexes"
|
|
366
|
+
@send external ensureSchemaIndexes: (t, array<ChainId.t>) => promise<unit> = "ensureSchemaIndexes"
|
|
432
367
|
|
|
433
368
|
// Null when the indexes are already there, which is every call but the first,
|
|
434
|
-
// and every call for
|
|
369
|
+
// and every call for an entity Postgres doesn't keep.
|
|
435
370
|
@send
|
|
436
|
-
external ensureQueryIndexes: (
|
|
437
|
-
|
|
371
|
+
external ensureQueryIndexes: (
|
|
372
|
+
t,
|
|
373
|
+
~entity: int,
|
|
374
|
+
~chainId: Null.t<ChainId.t>,
|
|
375
|
+
~columns: array<string>,
|
|
376
|
+
) => Null.t<promise<unit>> = "ensureQueryIndexes"
|
|
438
377
|
|
|
439
378
|
@send external pruneCheckpoints: (t, bounds) => promise<unit> = "pruneCheckpoints"
|
|
440
379
|
|
|
441
380
|
@send external pruneHistory: (t, int, bounds) => promise<unit> = "pruneHistory"
|
|
442
381
|
|
|
443
382
|
@send
|
|
444
|
-
external rollbackTargetCheckpoint: (
|
|
445
|
-
|
|
446
|
-
ChainId.t,
|
|
447
|
-
int,
|
|
448
|
-
CheckpointSequence.t,
|
|
449
|
-
) => promise<Nullable.t<string>> = "rollbackTargetCheckpoint"
|
|
383
|
+
external rollbackTargetCheckpoint: (t, ChainId.t, int) => promise<Nullable.t<bigint>> =
|
|
384
|
+
"rollbackTargetCheckpoint"
|
|
450
385
|
|
|
451
386
|
@send
|
|
452
387
|
external rollbackProgressDiff: (t, bounds) => promise<array<progressDiff>> = "rollbackProgressDiff"
|
|
453
388
|
|
|
454
389
|
@send external rollbackData: (t, int, bounds) => promise<rollbackData> = "rollbackData"
|
|
455
390
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
type cacheDump = {tableName: string, path: string}
|
|
391
|
+
// Uploads the caches saved under the directory first when `upload` says to,
|
|
392
|
+
// logging how that went.
|
|
393
|
+
@send
|
|
394
|
+
external restoreEffectCache: (t, string, bool) => promise<array<storedEffectCache>> =
|
|
395
|
+
"restoreEffectCache"
|
|
463
396
|
|
|
464
|
-
|
|
397
|
+
// Never rejects: a dump that doesn't finish is logged.
|
|
398
|
+
@send external dumpEffectCache: (t, string) => promise<unit> = "dumpEffectCache"
|
|
465
399
|
|
|
466
400
|
@send external reset: t => promise<unit> = "reset"
|
|
467
401
|
|
|
@@ -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
|
-
}
|