envio 3.0.0-alpha.2 → 3.0.0-alpha.21
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 +164 -30
- package/bin.mjs +49 -0
- package/evm.schema.json +79 -169
- package/fuel.schema.json +50 -21
- package/index.d.ts +578 -1
- package/index.js +4 -0
- package/package.json +47 -31
- package/rescript.json +4 -1
- package/src/Batch.res +11 -8
- package/src/Batch.res.mjs +11 -9
- package/src/ChainFetcher.res +531 -0
- package/src/ChainFetcher.res.mjs +339 -0
- package/src/ChainManager.res +190 -0
- package/src/ChainManager.res.mjs +166 -0
- package/src/Change.res +3 -3
- package/src/Config.gen.ts +19 -0
- package/src/Config.res +725 -25
- package/src/Config.res.mjs +692 -26
- package/src/{Indexer.res → Ctx.res} +1 -1
- package/src/Ecosystem.res +9 -124
- package/src/Ecosystem.res.mjs +19 -160
- package/src/Env.res +33 -73
- package/src/Env.res.mjs +29 -85
- package/src/Envio.gen.ts +3 -1
- package/src/Envio.res +77 -9
- package/src/Envio.res.mjs +39 -1
- package/src/EventConfigBuilder.res +408 -0
- package/src/EventConfigBuilder.res.mjs +376 -0
- package/src/EventProcessing.res +469 -0
- package/src/EventProcessing.res.mjs +337 -0
- package/src/EvmTypes.gen.ts +6 -0
- package/src/EvmTypes.res +1 -0
- package/src/FetchState.res +1256 -639
- package/src/FetchState.res.mjs +1135 -612
- package/src/GlobalState.res +1224 -0
- package/src/GlobalState.res.mjs +1291 -0
- package/src/GlobalStateManager.res +68 -0
- package/src/GlobalStateManager.res.mjs +75 -0
- package/src/GlobalStateManager.resi +7 -0
- package/src/HandlerLoader.res +89 -0
- package/src/HandlerLoader.res.mjs +79 -0
- package/src/HandlerRegister.res +357 -0
- package/src/HandlerRegister.res.mjs +299 -0
- package/src/HandlerRegister.resi +30 -0
- package/src/Hasura.res +111 -175
- package/src/Hasura.res.mjs +88 -150
- package/src/InMemoryStore.res +1 -1
- package/src/InMemoryStore.res.mjs +3 -3
- package/src/InMemoryTable.res +1 -1
- package/src/InMemoryTable.res.mjs +1 -1
- package/src/Internal.gen.ts +6 -0
- package/src/Internal.res +265 -12
- package/src/Internal.res.mjs +115 -1
- package/src/LoadLayer.res +444 -0
- package/src/LoadLayer.res.mjs +296 -0
- package/src/LoadLayer.resi +32 -0
- package/src/LogSelection.res +33 -27
- package/src/LogSelection.res.mjs +6 -0
- package/src/Logging.res +21 -7
- package/src/Logging.res.mjs +16 -8
- package/src/Main.res +390 -0
- package/src/Main.res.mjs +341 -0
- package/src/Persistence.res +7 -21
- package/src/Persistence.res.mjs +3 -3
- package/src/PgStorage.gen.ts +10 -0
- package/src/PgStorage.res +116 -69
- package/src/PgStorage.res.d.mts +5 -0
- package/src/PgStorage.res.mjs +93 -50
- package/src/Prometheus.res +294 -224
- package/src/Prometheus.res.mjs +353 -340
- package/src/ReorgDetection.res +6 -10
- package/src/ReorgDetection.res.mjs +6 -6
- package/src/SafeCheckpointTracking.res +4 -4
- package/src/SafeCheckpointTracking.res.mjs +2 -2
- package/src/SimulateItems.res +353 -0
- package/src/SimulateItems.res.mjs +335 -0
- package/src/Sink.res +4 -2
- package/src/Sink.res.mjs +2 -1
- package/src/TableIndices.res +0 -1
- package/src/TestIndexer.res +913 -0
- package/src/TestIndexer.res.mjs +698 -0
- package/src/TestIndexerProxyStorage.res +205 -0
- package/src/TestIndexerProxyStorage.res.mjs +151 -0
- package/src/TopicFilter.res +1 -1
- package/src/Types.ts +1 -1
- package/src/UserContext.res +424 -0
- package/src/UserContext.res.mjs +279 -0
- package/src/Utils.res +97 -26
- package/src/Utils.res.mjs +91 -44
- package/src/bindings/BigInt.res +10 -0
- package/src/bindings/BigInt.res.mjs +15 -0
- package/src/bindings/ClickHouse.res +120 -23
- package/src/bindings/ClickHouse.res.mjs +118 -28
- package/src/bindings/DateFns.res +74 -0
- package/src/bindings/DateFns.res.mjs +22 -0
- package/src/bindings/EventSource.res +11 -2
- package/src/bindings/EventSource.res.mjs +8 -1
- package/src/bindings/Express.res +1 -0
- package/src/bindings/Hrtime.res +14 -1
- package/src/bindings/Hrtime.res.mjs +22 -2
- package/src/bindings/Hrtime.resi +4 -0
- package/src/bindings/Lodash.res +0 -1
- package/src/bindings/NodeJs.res +49 -3
- package/src/bindings/NodeJs.res.mjs +11 -3
- package/src/bindings/Pino.res +24 -10
- package/src/bindings/Pino.res.mjs +14 -8
- package/src/bindings/Postgres.gen.ts +8 -0
- package/src/bindings/Postgres.res +5 -1
- package/src/bindings/Postgres.res.d.mts +5 -0
- package/src/bindings/PromClient.res +0 -10
- package/src/bindings/PromClient.res.mjs +0 -3
- package/src/bindings/Vitest.res +144 -0
- package/src/bindings/Vitest.res.mjs +9 -0
- package/src/bindings/WebSocket.res +27 -0
- package/src/bindings/WebSocket.res.mjs +2 -0
- package/src/bindings/Yargs.res +8 -0
- package/src/bindings/Yargs.res.mjs +2 -0
- package/src/db/EntityHistory.res +7 -7
- package/src/db/EntityHistory.res.mjs +9 -9
- package/src/db/InternalTable.res +59 -111
- package/src/db/InternalTable.res.mjs +73 -104
- package/src/db/Table.res +27 -8
- package/src/db/Table.res.mjs +25 -14
- package/src/sources/Evm.res +84 -0
- package/src/sources/Evm.res.mjs +105 -0
- package/src/sources/EvmChain.res +94 -0
- package/src/sources/EvmChain.res.mjs +60 -0
- package/src/sources/Fuel.res +19 -34
- package/src/sources/Fuel.res.mjs +34 -16
- package/src/sources/FuelSDK.res +38 -0
- package/src/sources/FuelSDK.res.mjs +29 -0
- package/src/sources/HyperFuel.res +2 -2
- package/src/sources/HyperFuel.resi +1 -1
- package/src/sources/HyperFuelClient.res +2 -2
- package/src/sources/HyperFuelSource.res +35 -13
- package/src/sources/HyperFuelSource.res.mjs +26 -16
- package/src/sources/HyperSync.res +61 -60
- package/src/sources/HyperSync.res.mjs +53 -67
- package/src/sources/HyperSync.resi +6 -4
- package/src/sources/HyperSyncClient.res +29 -2
- package/src/sources/HyperSyncClient.res.mjs +9 -0
- package/src/sources/HyperSyncHeightStream.res +76 -118
- package/src/sources/HyperSyncHeightStream.res.mjs +68 -75
- package/src/sources/HyperSyncSource.res +122 -143
- package/src/sources/HyperSyncSource.res.mjs +106 -121
- package/src/sources/Rpc.res +86 -14
- package/src/sources/Rpc.res.mjs +101 -9
- package/src/sources/RpcSource.res +731 -364
- package/src/sources/RpcSource.res.mjs +845 -410
- package/src/sources/RpcWebSocketHeightStream.res +181 -0
- package/src/sources/RpcWebSocketHeightStream.res.mjs +196 -0
- package/src/sources/SimulateSource.res +59 -0
- package/src/sources/SimulateSource.res.mjs +50 -0
- package/src/sources/Source.res +7 -5
- package/src/sources/SourceManager.res +358 -221
- package/src/sources/SourceManager.res.mjs +346 -171
- package/src/sources/SourceManager.resi +17 -6
- package/src/sources/Svm.res +81 -0
- package/src/sources/Svm.res.mjs +90 -0
- package/src/tui/Tui.res +247 -0
- package/src/tui/Tui.res.mjs +337 -0
- package/src/tui/bindings/Ink.res +371 -0
- package/src/tui/bindings/Ink.res.mjs +72 -0
- package/src/tui/bindings/Style.res +123 -0
- package/src/tui/bindings/Style.res.mjs +2 -0
- package/src/tui/components/BufferedProgressBar.res +40 -0
- package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
- package/src/tui/components/CustomHooks.res +122 -0
- package/src/tui/components/CustomHooks.res.mjs +179 -0
- package/src/tui/components/Messages.res +41 -0
- package/src/tui/components/Messages.res.mjs +75 -0
- package/src/tui/components/SyncETA.res +174 -0
- package/src/tui/components/SyncETA.res.mjs +263 -0
- package/src/tui/components/TuiData.res +47 -0
- package/src/tui/components/TuiData.res.mjs +34 -0
- package/svm.schema.json +112 -0
- package/bin.js +0 -48
- package/src/EventRegister.res +0 -241
- package/src/EventRegister.res.mjs +0 -240
- package/src/EventRegister.resi +0 -30
- package/src/bindings/Ethers.gen.ts +0 -14
- package/src/bindings/Ethers.res +0 -204
- package/src/bindings/Ethers.res.mjs +0 -130
- /package/src/{Indexer.res.mjs → Ctx.res.mjs} +0 -0
|
@@ -30,18 +30,34 @@ function toMillis(param) {
|
|
|
30
30
|
return param[0] * 1000 + param[1] / 1000000;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function toSeconds(param) {
|
|
34
|
+
return param[0] + param[1] / 1000000000;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function toSecondsFloat(elapsed) {
|
|
38
|
+
return toSeconds(elapsed);
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
function toInt($$float) {
|
|
34
42
|
return $$float | 0;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
function floatFromMillis(
|
|
38
|
-
return
|
|
45
|
+
function floatFromMillis(v) {
|
|
46
|
+
return v;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function floatFromSeconds(v) {
|
|
50
|
+
return v;
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
function millisBetween(from, to) {
|
|
42
54
|
return (toMillis(to) | 0) - (toMillis(from) | 0) | 0;
|
|
43
55
|
}
|
|
44
56
|
|
|
57
|
+
function secondsBetween(from, to) {
|
|
58
|
+
return toSeconds(to) - toSeconds(from);
|
|
59
|
+
}
|
|
60
|
+
|
|
45
61
|
function makeTimer(prim) {
|
|
46
62
|
return process.hrtime();
|
|
47
63
|
}
|
|
@@ -63,10 +79,14 @@ export {
|
|
|
63
79
|
secToMilli ,
|
|
64
80
|
timeElapsedToNewRef ,
|
|
65
81
|
toMillis ,
|
|
82
|
+
toSeconds ,
|
|
83
|
+
toSecondsFloat ,
|
|
66
84
|
intFromMillis ,
|
|
67
85
|
intFromNanos ,
|
|
68
86
|
intFromSeconds ,
|
|
69
87
|
floatFromMillis ,
|
|
88
|
+
floatFromSeconds ,
|
|
70
89
|
millisBetween ,
|
|
90
|
+
secondsBetween ,
|
|
71
91
|
}
|
|
72
92
|
/* No side effect */
|
package/src/bindings/Hrtime.resi
CHANGED
|
@@ -17,10 +17,14 @@ let secToMilli: seconds => milliseconds
|
|
|
17
17
|
|
|
18
18
|
let timeElapsedToNewRef: (timeElapsed, timeRef) => timeRef
|
|
19
19
|
let toMillis: timeElapsed => milliseconds
|
|
20
|
+
let toSeconds: timeElapsed => seconds
|
|
21
|
+
let toSecondsFloat: timeElapsed => float
|
|
20
22
|
|
|
21
23
|
let intFromMillis: milliseconds => int
|
|
22
24
|
let intFromNanos: nanoseconds => int
|
|
23
25
|
let intFromSeconds: seconds => int
|
|
24
26
|
let floatFromMillis: milliseconds => float
|
|
27
|
+
let floatFromSeconds: seconds => float
|
|
25
28
|
|
|
26
29
|
let millisBetween: (~from: timeRef, ~to: timeRef) => int
|
|
30
|
+
let secondsBetween: (~from: timeRef, ~to: timeRef) => float
|
package/src/bindings/Lodash.res
CHANGED
package/src/bindings/NodeJs.res
CHANGED
|
@@ -3,6 +3,11 @@ type t
|
|
|
3
3
|
@send external exit: (t, unit) => unit = "exit"
|
|
4
4
|
type exitCode = | @as(0) Success | @as(1) Failure
|
|
5
5
|
@send external exitWithCode: (t, exitCode) => unit = "exit"
|
|
6
|
+
// Use @val to access the global `process` object for EventEmitter methods like `on`.
|
|
7
|
+
// The @module binding above compiles to `import * as Process from "process"` (a namespace import),
|
|
8
|
+
// which exposes named exports (exit, cwd) but not EventEmitter prototype methods (on, off, emit).
|
|
9
|
+
@val external globalProcess: t = "process"
|
|
10
|
+
@send external onUnhandledRejection: (t, @as("unhandledRejection") _, exn => unit) => unit = "on"
|
|
6
11
|
|
|
7
12
|
module Util = {
|
|
8
13
|
@unboxed
|
|
@@ -36,8 +41,9 @@ module Util = {
|
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
module Process = {
|
|
39
|
-
type t = {env: Js.Dict.t<string>}
|
|
44
|
+
type t = {env: Js.Dict.t<string>, execArgv: array<string>}
|
|
40
45
|
@module external process: t = "process"
|
|
46
|
+
@module("process") external cwd: unit => string = "cwd"
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
module ChildProcess = {
|
|
@@ -59,11 +65,24 @@ module ChildProcess = {
|
|
|
59
65
|
module Url = {
|
|
60
66
|
type t
|
|
61
67
|
@module("url") external fileURLToPath: t => string = "fileURLToPath"
|
|
68
|
+
@module("url") external fileURLToPathFromString: string => string = "fileURLToPath"
|
|
69
|
+
// Convert a file path to a file:// URL string (for dynamic imports)
|
|
70
|
+
@module("url") external pathToFileURL: string => t = "pathToFileURL"
|
|
71
|
+
@send external toString: t => string = "toString"
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
module ImportMeta = {
|
|
65
75
|
type t = {url: Url.t}
|
|
66
76
|
@val external importMeta: t = "import.meta"
|
|
77
|
+
// Get import.meta.url as string for module registration
|
|
78
|
+
@val external url: string = "import.meta.url"
|
|
79
|
+
// Resolve module specifier to file:// URL
|
|
80
|
+
@val external resolve: string => string = "import.meta.resolve"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module Module = {
|
|
84
|
+
// Register ESM loader hooks (e.g., for TypeScript support via tsx)
|
|
85
|
+
@module("node:module") external register: (string, string) => unit = "register"
|
|
67
86
|
}
|
|
68
87
|
|
|
69
88
|
module Path = {
|
|
@@ -77,8 +96,35 @@ module Path = {
|
|
|
77
96
|
|
|
78
97
|
external toString: t => string = "%identity"
|
|
79
98
|
|
|
80
|
-
// ESM-compatible __dirname replacement
|
|
81
|
-
let
|
|
99
|
+
// ESM-compatible __dirname replacement - accepts importMeta from calling file
|
|
100
|
+
let getDirname = (importMeta: ImportMeta.t) => dirname(Url.fileURLToPath(importMeta.url))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
module WorkerThreads = {
|
|
104
|
+
// Check if we're in the main thread or a worker
|
|
105
|
+
@module("worker_threads") external isMainThread: bool = "isMainThread"
|
|
106
|
+
|
|
107
|
+
// Worker data passed from main thread
|
|
108
|
+
@module("worker_threads") external workerData: Js.Nullable.t<'a> = "workerData"
|
|
109
|
+
|
|
110
|
+
// MessagePort for communication with parent
|
|
111
|
+
type messagePort
|
|
112
|
+
@module("worker_threads") external parentPort: Js.Nullable.t<messagePort> = "parentPort"
|
|
113
|
+
@send external postMessage: (messagePort, 'a) => unit = "postMessage"
|
|
114
|
+
@send external onPortMessage: (messagePort, @as("message") _, 'a => unit) => unit = "on"
|
|
115
|
+
|
|
116
|
+
// Worker class for spawning workers
|
|
117
|
+
type worker
|
|
118
|
+
type workerOptions = {workerData?: Js.Json.t, execArgv?: array<string>}
|
|
119
|
+
|
|
120
|
+
@new @module("worker_threads")
|
|
121
|
+
external makeWorker: (string, workerOptions) => worker = "Worker"
|
|
122
|
+
|
|
123
|
+
@send external onMessage: (worker, @as("message") _, 'a => unit) => unit = "on"
|
|
124
|
+
@send external onError: (worker, @as("error") _, exn => unit) => unit = "on"
|
|
125
|
+
@send external onExit: (worker, @as("exit") _, int => unit) => unit = "on"
|
|
126
|
+
@send external terminate: worker => promise<int> = "terminate"
|
|
127
|
+
@send external workerPostMessage: (worker, 'a) => unit = "postMessage"
|
|
82
128
|
}
|
|
83
129
|
|
|
84
130
|
module Fs = {
|
|
@@ -24,12 +24,18 @@ var Url$1 = {};
|
|
|
24
24
|
|
|
25
25
|
var ImportMeta = {};
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var Module = {};
|
|
28
|
+
|
|
29
|
+
function getDirname(importMeta) {
|
|
30
|
+
return Path.dirname(Url.fileURLToPath(importMeta.url));
|
|
31
|
+
}
|
|
28
32
|
|
|
29
33
|
var Path$1 = {
|
|
30
|
-
|
|
34
|
+
getDirname: getDirname
|
|
31
35
|
};
|
|
32
36
|
|
|
37
|
+
var WorkerThreads = {};
|
|
38
|
+
|
|
33
39
|
var Promises = {};
|
|
34
40
|
|
|
35
41
|
var Fs = {
|
|
@@ -42,7 +48,9 @@ export {
|
|
|
42
48
|
ChildProcess ,
|
|
43
49
|
Url$1 as Url,
|
|
44
50
|
ImportMeta ,
|
|
51
|
+
Module ,
|
|
45
52
|
Path$1 as Path,
|
|
53
|
+
WorkerThreads ,
|
|
46
54
|
Fs ,
|
|
47
55
|
}
|
|
48
|
-
/*
|
|
56
|
+
/* url Not a pure module */
|
package/src/bindings/Pino.res
CHANGED
|
@@ -5,6 +5,7 @@ type logLevelBuiltin = [
|
|
|
5
5
|
| #warn
|
|
6
6
|
| #error
|
|
7
7
|
| #fatal
|
|
8
|
+
| #silent
|
|
8
9
|
]
|
|
9
10
|
@genType
|
|
10
11
|
type logLevelUser = [
|
|
@@ -39,21 +40,21 @@ external levels: t => 'a = "levels"
|
|
|
39
40
|
@set external setLevel: (t, logLevel) => unit = "level"
|
|
40
41
|
|
|
41
42
|
@ocaml.doc(`Identity function to help co-erce any type to a pino log message`)
|
|
42
|
-
let createPinoMessage = (message): pinoMessageBlob => Utils.magic
|
|
43
|
+
let createPinoMessage = (message): pinoMessageBlob => message->(Utils.magic: 'a => pinoMessageBlob)
|
|
43
44
|
let createPinoMessageWithError = (message, err): pinoMessageBlobWithError => {
|
|
44
45
|
//See https://github.com/pinojs/pino-std-serializers for standard pino serializers
|
|
45
46
|
//for common objects. We have also defined the serializer in this format in the
|
|
46
47
|
// serializers type below: `type serializers = {err: Js.Json.t => Js.Json.t}`
|
|
47
|
-
|
|
48
|
+
{
|
|
48
49
|
"msg": message,
|
|
49
50
|
"err": err->Utils.prettifyExn,
|
|
50
|
-
})
|
|
51
|
+
}->(Utils.magic: 'a => pinoMessageBlobWithError)
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
module Transport = {
|
|
54
55
|
type t
|
|
55
56
|
type optionsObject
|
|
56
|
-
let makeTransportOptions: 'a => optionsObject = Utils.magic
|
|
57
|
+
let makeTransportOptions: 'a => optionsObject = v => v->(Utils.magic: 'a => optionsObject)
|
|
57
58
|
|
|
58
59
|
// NOTE: this config is pretty polymorphic - so keeping this as all optional fields.
|
|
59
60
|
type rec transportTarget = {
|
|
@@ -104,7 +105,7 @@ type options = {
|
|
|
104
105
|
@module("pino") external makeWithOptionsAndTransport: (options, Transport.t) => t = "pino"
|
|
105
106
|
|
|
106
107
|
type childParams
|
|
107
|
-
let createChildParams: 'a => childParams = Utils.magic
|
|
108
|
+
let createChildParams: 'a => childParams = v => v->(Utils.magic: 'a => childParams)
|
|
108
109
|
@send external child: (t, childParams) => t = "child"
|
|
109
110
|
|
|
110
111
|
module ECS = {
|
|
@@ -132,15 +133,28 @@ module MultiStreamLogger = {
|
|
|
132
133
|
}
|
|
133
134
|
@module("pino") external destination: destinationOpts => stream = "destination"
|
|
134
135
|
|
|
135
|
-
type prettyFactoryOpts = {...options, customColors?: string}
|
|
136
|
+
type prettyFactoryOpts = {...options, customColors?: string, colorize?: bool}
|
|
136
137
|
@module("pino-pretty")
|
|
137
138
|
external prettyFactory: prettyFactoryOpts => string => string = "prettyFactory"
|
|
138
139
|
|
|
139
140
|
let makeFormatter = logLevels => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
let customColors = "fatal:bgRed,error:red,warn:yellow,info:green,udebug:bgBlue,uinfo:bgGreen,uwarn:bgYellow,uerror:bgRed,debug:blue,trace:gray"
|
|
142
|
+
// Force colors when running for logs format test
|
|
143
|
+
let options = switch %raw(`"ENVIO_TEST_LOGGING_FORMAT" in process.env`) {
|
|
144
|
+
| Some(_) => {
|
|
145
|
+
customLevels: logLevels,
|
|
146
|
+
customColors,
|
|
147
|
+
colorize: true,
|
|
148
|
+
}
|
|
149
|
+
// For some reason setting colorize as undefined,
|
|
150
|
+
// makes it behave as false.
|
|
151
|
+
| None => {
|
|
152
|
+
customLevels: logLevels,
|
|
153
|
+
customColors,
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
prettyFactory(options)
|
|
144
158
|
}
|
|
145
159
|
|
|
146
160
|
let makeStreams = (~userLogLevel, ~formatter, ~logFile, ~defaultFileLogLevel) => {
|
|
@@ -19,16 +19,16 @@ function createPinoMessageWithError(message, err) {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function makeTransportOptions(
|
|
23
|
-
return
|
|
22
|
+
function makeTransportOptions(v) {
|
|
23
|
+
return v;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
var Transport = {
|
|
27
27
|
makeTransportOptions: makeTransportOptions
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
function createChildParams(
|
|
31
|
-
return
|
|
30
|
+
function createChildParams(v) {
|
|
31
|
+
return v;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function make(prim) {
|
|
@@ -40,10 +40,16 @@ var ECS = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
function makeFormatter(logLevels) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
var customColors = "fatal:bgRed,error:red,warn:yellow,info:green,udebug:bgBlue,uinfo:bgGreen,uwarn:bgYellow,uerror:bgRed,debug:blue,trace:gray";
|
|
44
|
+
var match = ("ENVIO_TEST_LOGGING_FORMAT" in process.env);
|
|
45
|
+
return PinoPretty.prettyFactory(match !== undefined ? ({
|
|
46
|
+
customLevels: logLevels,
|
|
47
|
+
customColors: customColors,
|
|
48
|
+
colorize: true
|
|
49
|
+
}) : ({
|
|
50
|
+
customLevels: logLevels,
|
|
51
|
+
customColors: customColors
|
|
52
|
+
}));
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
function makeStreams(userLogLevel, formatter, logFile, defaultFileLogLevel) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Only needed for some old tests
|
|
2
|
+
// Remove @genType in the future
|
|
3
|
+
@genType.import(("postgres", "Sql"))
|
|
1
4
|
type sql
|
|
2
5
|
|
|
3
6
|
type undefinedTransform = | @as(undefined) Undefined | @as(null) Null
|
|
@@ -75,7 +78,6 @@ type poolConfig = {
|
|
|
75
78
|
idleTimeout?: int, // Idle connection timeout in seconds (default: 0)
|
|
76
79
|
connectTimeout?: int, // Connect timeout in seconds (default: 30)
|
|
77
80
|
prepare?: bool, // Automatic creation of prepared statements (default: true)
|
|
78
|
-
// types?: array<'a>, // Array of custom types, see more below (default: [])
|
|
79
81
|
onnotice?: string => unit, // Default console.log, set false to silence NOTICE (default: fn)
|
|
80
82
|
onParameter?: (string, string) => unit, // (key, value) when server param change (default: fn)
|
|
81
83
|
debug?: (~connection: unknown, ~query: unknown, ~params: unknown, ~types: unknown) => unit, // Is called with (connection, query, params, types)
|
|
@@ -96,6 +98,7 @@ external makeSql: (~config: poolConfig) => sql = "default"
|
|
|
96
98
|
// external sql: array<string> => (sql, array<string>) => int = "sql"
|
|
97
99
|
|
|
98
100
|
@send external unsafe: (sql, string) => promise<'a> = "unsafe"
|
|
101
|
+
@send external unpreparedUnsafe: (sql, string, unknown) => promise<'a> = "unsafe"
|
|
99
102
|
@send
|
|
100
103
|
external preparedUnsafe: (sql, string, unknown, @as(json`{prepare: true}`) _) => promise<'a> =
|
|
101
104
|
"unsafe"
|
|
@@ -109,6 +112,7 @@ type columnType =
|
|
|
109
112
|
| @as("DOUBLE PRECISION") DoublePrecision
|
|
110
113
|
| @as("TEXT") Text
|
|
111
114
|
| @as("SERIAL") Serial
|
|
115
|
+
| @as("BIGSERIAL") BigSerial
|
|
112
116
|
| @as("JSONB") JsonB
|
|
113
117
|
| @as("TIMESTAMP WITH TIME ZONE") TimestampWithTimezone
|
|
114
118
|
| @as("TIMESTAMP WITH TIME ZONE NULL") TimestampWithTimezoneNull
|
|
@@ -48,16 +48,6 @@ module Gauge = {
|
|
|
48
48
|
@send external get: gauge => promise<{"values": array<dict<string>>}> = "get"
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
module Histogram = {
|
|
52
|
-
type histogram
|
|
53
|
-
@new @module("prom-client") external make: customMetric<'a> => histogram = "Histogram"
|
|
54
|
-
|
|
55
|
-
@send external observe: (histogram, float) => unit = "observe"
|
|
56
|
-
@send external startTimer: histogram => unit => unit = "startTimer"
|
|
57
|
-
|
|
58
|
-
@send external labels: (histogram, 'labelsObject) => histogram = "labels"
|
|
59
|
-
}
|
|
60
|
-
|
|
61
51
|
module Summary = {
|
|
62
52
|
type summary
|
|
63
53
|
@new @module("prom-client") external makeSummary: customMetric<'a> => summary = "Summary"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Vitest bindings for ReScript
|
|
2
|
+
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Expectation object returned by expect()
|
|
5
|
+
// ============================================================================
|
|
6
|
+
|
|
7
|
+
type rec expectation<'a> = {
|
|
8
|
+
// Equality matchers
|
|
9
|
+
toBe: 'a => unit,
|
|
10
|
+
toEqual: 'a => unit,
|
|
11
|
+
toStrictEqual: 'a => unit,
|
|
12
|
+
// Truthiness matchers
|
|
13
|
+
toBeTruthy: unit => unit,
|
|
14
|
+
toBeFalsy: unit => unit,
|
|
15
|
+
toBeNull: unit => unit,
|
|
16
|
+
toBeUndefined: unit => unit,
|
|
17
|
+
toBeDefined: unit => unit,
|
|
18
|
+
// Number matchers
|
|
19
|
+
toBeGreaterThan: 'a => unit,
|
|
20
|
+
toBeGreaterThanOrEqual: 'a => unit,
|
|
21
|
+
toBeLessThan: 'a => unit,
|
|
22
|
+
toBeLessThanOrEqual: 'a => unit,
|
|
23
|
+
toBeCloseTo: (float, ~numDigits: int=?) => unit,
|
|
24
|
+
toBeNaN: unit => unit,
|
|
25
|
+
// String matchers
|
|
26
|
+
toContain: string => unit,
|
|
27
|
+
toMatch: Js.Re.t => unit,
|
|
28
|
+
toMatchString: string => unit,
|
|
29
|
+
// Array matchers
|
|
30
|
+
toContainItem: 'a => unit,
|
|
31
|
+
toHaveLength: int => unit,
|
|
32
|
+
// Object matchers
|
|
33
|
+
toHaveProperty: string => unit,
|
|
34
|
+
toHavePropertyValue: 'b. (string, 'b) => unit,
|
|
35
|
+
// Exception matchers
|
|
36
|
+
toThrow: unit => unit,
|
|
37
|
+
toThrowError: string => unit,
|
|
38
|
+
// Snapshot matchers
|
|
39
|
+
toMatchSnapshot: unit => unit,
|
|
40
|
+
// Negation
|
|
41
|
+
not: expectation<'a>,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Test context passed to test callbacks
|
|
45
|
+
type testContext = {expect: 'a. ('a, ~message: string=?) => expectation<'a>}
|
|
46
|
+
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Test Suite Functions
|
|
49
|
+
// ============================================================================
|
|
50
|
+
|
|
51
|
+
@module("vitest")
|
|
52
|
+
external describe: (string, unit => unit) => unit = "describe"
|
|
53
|
+
|
|
54
|
+
@module("vitest") @scope("describe")
|
|
55
|
+
external describe_only: (string, unit => unit) => unit = "only"
|
|
56
|
+
|
|
57
|
+
@module("vitest") @scope("describe")
|
|
58
|
+
external describe_skip: (string, unit => unit) => unit = "skip"
|
|
59
|
+
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// Test Functions (sync)
|
|
62
|
+
// ============================================================================
|
|
63
|
+
|
|
64
|
+
@module("vitest")
|
|
65
|
+
external it: (string, testContext => unit) => unit = "it"
|
|
66
|
+
|
|
67
|
+
@module("vitest") @scope("it")
|
|
68
|
+
external it_only: (string, testContext => unit) => unit = "only"
|
|
69
|
+
|
|
70
|
+
@module("vitest") @scope("it")
|
|
71
|
+
external it_skip: (string, testContext => unit) => unit = "skip"
|
|
72
|
+
|
|
73
|
+
@module("vitest")
|
|
74
|
+
external test: (string, testContext => unit) => unit = "test"
|
|
75
|
+
|
|
76
|
+
@module("vitest") @scope("test")
|
|
77
|
+
external test_only: (string, testContext => unit) => unit = "only"
|
|
78
|
+
|
|
79
|
+
@module("vitest") @scope("test")
|
|
80
|
+
external test_skip: (string, testContext => unit) => unit = "skip"
|
|
81
|
+
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// Setup and Teardown
|
|
84
|
+
// ============================================================================
|
|
85
|
+
|
|
86
|
+
@module("vitest")
|
|
87
|
+
external beforeAll: (unit => unit) => unit = "beforeAll"
|
|
88
|
+
|
|
89
|
+
@module("vitest")
|
|
90
|
+
external afterAll: (unit => unit) => unit = "afterAll"
|
|
91
|
+
|
|
92
|
+
@module("vitest")
|
|
93
|
+
external beforeEach: (unit => unit) => unit = "beforeEach"
|
|
94
|
+
|
|
95
|
+
@module("vitest")
|
|
96
|
+
external afterEach: (unit => unit) => unit = "afterEach"
|
|
97
|
+
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// Async Module
|
|
100
|
+
// ============================================================================
|
|
101
|
+
|
|
102
|
+
type options = {retry?: int}
|
|
103
|
+
|
|
104
|
+
module Async = {
|
|
105
|
+
@module("vitest")
|
|
106
|
+
external it: (string, testContext => promise<unit>, ~timeout: int=?) => unit = "it"
|
|
107
|
+
|
|
108
|
+
@module("vitest")
|
|
109
|
+
external itWithOptions: (string, options, testContext => promise<unit>) => unit = "it"
|
|
110
|
+
|
|
111
|
+
@module("vitest") @scope("it")
|
|
112
|
+
external it_only: (string, testContext => promise<unit>) => unit = "only"
|
|
113
|
+
|
|
114
|
+
@module("vitest") @scope("it")
|
|
115
|
+
external it_skip: (string, testContext => promise<unit>) => unit = "skip"
|
|
116
|
+
|
|
117
|
+
@module("vitest")
|
|
118
|
+
external test: (string, testContext => promise<unit>) => unit = "test"
|
|
119
|
+
|
|
120
|
+
@module("vitest") @scope("test")
|
|
121
|
+
external test_only: (string, testContext => promise<unit>) => unit = "only"
|
|
122
|
+
|
|
123
|
+
@module("vitest") @scope("test")
|
|
124
|
+
external test_skip: (string, testContext => promise<unit>) => unit = "skip"
|
|
125
|
+
|
|
126
|
+
@module("vitest")
|
|
127
|
+
external beforeAll: (unit => promise<unit>) => unit = "beforeAll"
|
|
128
|
+
|
|
129
|
+
@module("vitest")
|
|
130
|
+
external afterAll: (unit => promise<unit>) => unit = "afterAll"
|
|
131
|
+
|
|
132
|
+
@module("vitest")
|
|
133
|
+
external beforeEach: (unit => promise<unit>) => unit = "beforeEach"
|
|
134
|
+
|
|
135
|
+
@module("vitest")
|
|
136
|
+
external afterEach: (unit => promise<unit>) => unit = "afterEach"
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// Expect
|
|
141
|
+
// ============================================================================
|
|
142
|
+
|
|
143
|
+
@module("vitest")
|
|
144
|
+
external expect: ('a, ~message: string=?) => expectation<'a> = "expect"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Binding to the built-in Node.js WebSocket API (available in Node.js >= 22).
|
|
3
|
+
Used for eth_subscribe("newHeads") real-time block tracking.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
type t
|
|
7
|
+
|
|
8
|
+
@new external create: string => t = "WebSocket"
|
|
9
|
+
|
|
10
|
+
@unboxed
|
|
11
|
+
type readyState =
|
|
12
|
+
| @as(0) Connecting
|
|
13
|
+
| @as(1) Open
|
|
14
|
+
| @as(2) Closing
|
|
15
|
+
| @as(3) Closed
|
|
16
|
+
|
|
17
|
+
@get external readyState: t => readyState = "readyState"
|
|
18
|
+
|
|
19
|
+
@set external onopen: (t, unit => unit) => unit = "onopen"
|
|
20
|
+
@set external onerror: (t, Js.Exn.t => unit) => unit = "onerror"
|
|
21
|
+
@set external onclose: (t, unit => unit) => unit = "onclose"
|
|
22
|
+
|
|
23
|
+
type messageEvent = {data: string}
|
|
24
|
+
@set external onmessage: (t, messageEvent => unit) => unit = "onmessage"
|
|
25
|
+
|
|
26
|
+
@send external send: (t, string) => unit = "send"
|
|
27
|
+
@send external close: t => unit = "close"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type arg = string
|
|
2
|
+
|
|
3
|
+
type parsedArgs<'a> = 'a
|
|
4
|
+
|
|
5
|
+
@module("yargs/yargs") external yargs: array<arg> => parsedArgs<'a> = "default"
|
|
6
|
+
@module("yargs/helpers") external hideBin: array<arg> => array<arg> = "hideBin"
|
|
7
|
+
|
|
8
|
+
@get external argv: parsedArgs<'a> => 'a = "argv"
|
package/src/db/EntityHistory.res
CHANGED
|
@@ -15,7 +15,7 @@ module RowAction = {
|
|
|
15
15
|
// Prefix with envio_ to avoid colleasions
|
|
16
16
|
let changeFieldName = "envio_change"
|
|
17
17
|
let checkpointIdFieldName = "envio_checkpoint_id"
|
|
18
|
-
let checkpointIdFieldType =
|
|
18
|
+
let checkpointIdFieldType = UInt64
|
|
19
19
|
let changeFieldType = Enum({config: RowAction.config->Table.fromGenericEnumConfig})
|
|
20
20
|
|
|
21
21
|
let unsafeCheckpointIdSchema =
|
|
@@ -23,11 +23,11 @@ let unsafeCheckpointIdSchema =
|
|
|
23
23
|
->S.setName("CheckpointId")
|
|
24
24
|
->S.transform(s => {
|
|
25
25
|
parser: string =>
|
|
26
|
-
switch
|
|
27
|
-
| Some(float) => float
|
|
26
|
+
switch BigInt.fromString(string) {
|
|
28
27
|
| None => s.fail("The string is not valid CheckpointId")
|
|
28
|
+
| Some(v) => v
|
|
29
29
|
},
|
|
30
|
-
serializer:
|
|
30
|
+
serializer: bigint => bigint->BigInt.toString,
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
let makeSetUpdateSchema: S.t<'entity> => S.t<Change.t<'entity>> = entitySchema => {
|
|
@@ -112,7 +112,7 @@ let pruneStaleEntityHistory = (
|
|
|
112
112
|
): promise<unit> => {
|
|
113
113
|
sql->Postgres.preparedUnsafe(
|
|
114
114
|
makePruneStaleEntityHistoryQuery(~entityName, ~entityIndex, ~pgSchema),
|
|
115
|
-
[safeCheckpointId]->Utils.magic,
|
|
115
|
+
[safeCheckpointId->BigInt.toString]->(Utils.magic: array<string> => unknown),
|
|
116
116
|
)
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -144,14 +144,14 @@ let backfillHistory = (sql, ~pgSchema, ~entityName, ~entityIndex, ~ids: array<st
|
|
|
144
144
|
->Promise.ignoreValue
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
let rollback = (sql, ~pgSchema, ~entityName, ~entityIndex, ~rollbackTargetCheckpointId:
|
|
147
|
+
let rollback = (sql, ~pgSchema, ~entityName, ~entityIndex, ~rollbackTargetCheckpointId: Internal.checkpointId) => {
|
|
148
148
|
sql
|
|
149
149
|
->Postgres.preparedUnsafe(
|
|
150
150
|
`DELETE FROM "${pgSchema}"."${historyTableName(
|
|
151
151
|
~entityName,
|
|
152
152
|
~entityIndex,
|
|
153
153
|
)}" WHERE "${checkpointIdFieldName}" > $1;`,
|
|
154
|
-
[rollbackTargetCheckpointId]->Utils.magic,
|
|
154
|
+
[rollbackTargetCheckpointId->BigInt.toString]->(Utils.magic: array<string> => unknown),
|
|
155
155
|
)
|
|
156
156
|
->Promise.ignoreValue
|
|
157
157
|
}
|