envio 3.0.0-alpha.21 → 3.0.0-alpha.22
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/bin.mjs +2 -48
- package/evm.schema.json +67 -0
- package/fuel.schema.json +67 -0
- package/index.d.ts +822 -38
- package/index.js +5 -3
- package/package.json +10 -8
- package/rescript.json +5 -9
- package/src/Address.res +4 -5
- package/src/Address.res.mjs +9 -12
- package/src/Api.res +15 -0
- package/src/Api.res.mjs +20 -0
- package/src/Batch.res +32 -34
- package/src/Batch.res.mjs +172 -187
- package/src/Bin.res +89 -0
- package/src/Bin.res.mjs +97 -0
- package/src/ChainFetcher.res +33 -57
- package/src/ChainFetcher.res.mjs +197 -227
- package/src/ChainManager.res +6 -14
- package/src/ChainManager.res.mjs +74 -85
- package/src/ChainMap.res +14 -16
- package/src/ChainMap.res.mjs +38 -38
- package/src/Config.res +193 -135
- package/src/Config.res.mjs +566 -592
- package/src/Core.res +182 -0
- package/src/Core.res.mjs +207 -0
- package/src/Ecosystem.res +25 -4
- package/src/Ecosystem.res.mjs +12 -13
- package/src/Env.res +20 -13
- package/src/Env.res.mjs +124 -113
- package/src/EnvSafe.res +269 -0
- package/src/EnvSafe.res.mjs +296 -0
- package/src/EnvSafe.resi +18 -0
- package/src/Envio.res +37 -26
- package/src/Envio.res.mjs +59 -60
- package/src/ErrorHandling.res +2 -2
- package/src/ErrorHandling.res.mjs +15 -15
- package/src/EventConfigBuilder.res +219 -81
- package/src/EventConfigBuilder.res.mjs +259 -202
- package/src/EventProcessing.res +27 -38
- package/src/EventProcessing.res.mjs +165 -183
- package/src/EventUtils.res +11 -11
- package/src/EventUtils.res.mjs +21 -22
- package/src/EvmTypes.res +0 -1
- package/src/EvmTypes.res.mjs +5 -5
- package/src/FetchState.res +360 -256
- package/src/FetchState.res.mjs +958 -914
- package/src/GlobalState.res +365 -351
- package/src/GlobalState.res.mjs +958 -992
- package/src/GlobalStateManager.res +1 -2
- package/src/GlobalStateManager.res.mjs +36 -44
- package/src/HandlerLoader.res +107 -23
- package/src/HandlerLoader.res.mjs +128 -38
- package/src/HandlerRegister.res +127 -103
- package/src/HandlerRegister.res.mjs +164 -164
- package/src/HandlerRegister.resi +12 -4
- package/src/Hasura.res +35 -22
- package/src/Hasura.res.mjs +158 -167
- package/src/InMemoryStore.res +20 -27
- package/src/InMemoryStore.res.mjs +64 -80
- package/src/InMemoryTable.res +34 -39
- package/src/InMemoryTable.res.mjs +165 -170
- package/src/Internal.res +52 -33
- package/src/Internal.res.mjs +84 -81
- package/src/LazyLoader.res.mjs +55 -61
- package/src/LoadLayer.res +77 -78
- package/src/LoadLayer.res.mjs +160 -189
- package/src/LoadManager.res +16 -21
- package/src/LoadManager.res.mjs +79 -84
- package/src/LogSelection.res +236 -68
- package/src/LogSelection.res.mjs +211 -141
- package/src/Logging.res +13 -9
- package/src/Logging.res.mjs +130 -143
- package/src/Main.res +428 -51
- package/src/Main.res.mjs +528 -271
- package/src/Persistence.res +77 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +291 -167
- package/src/PgStorage.res.mjs +797 -817
- package/src/Prometheus.res +50 -58
- package/src/Prometheus.res.mjs +345 -373
- package/src/ReorgDetection.res +22 -24
- package/src/ReorgDetection.res.mjs +100 -106
- package/src/SafeCheckpointTracking.res +7 -7
- package/src/SafeCheckpointTracking.res.mjs +40 -43
- package/src/SimulateItems.res +41 -49
- package/src/SimulateItems.res.mjs +257 -272
- package/src/Sink.res +2 -2
- package/src/Sink.res.mjs +22 -26
- package/src/TableIndices.res +1 -2
- package/src/TableIndices.res.mjs +42 -48
- package/src/TestIndexer.res +196 -189
- package/src/TestIndexer.res.mjs +536 -536
- package/src/TestIndexerProxyStorage.res +15 -16
- package/src/TestIndexerProxyStorage.res.mjs +98 -122
- package/src/TestIndexerWorker.res +4 -0
- package/src/TestIndexerWorker.res.mjs +7 -0
- package/src/Throttler.res +3 -3
- package/src/Throttler.res.mjs +23 -24
- package/src/Time.res +1 -1
- package/src/Time.res.mjs +18 -21
- package/src/TopicFilter.res +3 -3
- package/src/TopicFilter.res.mjs +29 -30
- package/src/UserContext.res +93 -54
- package/src/UserContext.res.mjs +197 -182
- package/src/Utils.res +141 -86
- package/src/Utils.res.mjs +334 -295
- package/src/bindings/BigDecimal.res +0 -2
- package/src/bindings/BigDecimal.res.mjs +19 -23
- package/src/bindings/ClickHouse.res +28 -27
- package/src/bindings/ClickHouse.res.mjs +243 -240
- package/src/bindings/DateFns.res +11 -11
- package/src/bindings/DateFns.res.mjs +7 -7
- package/src/bindings/EventSource.res.mjs +2 -2
- package/src/bindings/Express.res +2 -5
- package/src/bindings/Hrtime.res +2 -2
- package/src/bindings/Hrtime.res.mjs +30 -32
- package/src/bindings/Lodash.res.mjs +1 -1
- package/src/bindings/NodeJs.res +14 -9
- package/src/bindings/NodeJs.res.mjs +20 -20
- package/src/bindings/Pino.res +8 -10
- package/src/bindings/Pino.res.mjs +40 -43
- package/src/bindings/Postgres.res +2 -5
- package/src/bindings/Postgres.res.mjs +9 -9
- package/src/bindings/PromClient.res +17 -2
- package/src/bindings/PromClient.res.mjs +30 -7
- package/src/bindings/SDSL.res.mjs +2 -2
- package/src/bindings/Viem.res +4 -4
- package/src/bindings/Viem.res.mjs +20 -22
- package/src/bindings/Vitest.res +1 -1
- package/src/bindings/Vitest.res.mjs +2 -2
- package/src/bindings/WebSocket.res +1 -1
- package/src/db/EntityHistory.res +9 -3
- package/src/db/EntityHistory.res.mjs +84 -59
- package/src/db/InternalTable.res +62 -60
- package/src/db/InternalTable.res.mjs +271 -203
- package/src/db/Schema.res +1 -2
- package/src/db/Schema.res.mjs +28 -32
- package/src/db/Table.res +28 -27
- package/src/db/Table.res.mjs +276 -292
- package/src/sources/EventRouter.res +21 -16
- package/src/sources/EventRouter.res.mjs +55 -57
- package/src/sources/Evm.res +17 -1
- package/src/sources/Evm.res.mjs +16 -8
- package/src/sources/EvmChain.res +15 -17
- package/src/sources/EvmChain.res.mjs +40 -42
- package/src/sources/Fuel.res +14 -1
- package/src/sources/Fuel.res.mjs +16 -8
- package/src/sources/FuelSDK.res +1 -1
- package/src/sources/FuelSDK.res.mjs +6 -8
- package/src/sources/HyperFuel.res +8 -10
- package/src/sources/HyperFuel.res.mjs +113 -123
- package/src/sources/HyperFuelClient.res.mjs +6 -7
- package/src/sources/HyperFuelSource.res +19 -20
- package/src/sources/HyperFuelSource.res.mjs +339 -356
- package/src/sources/HyperSync.res +11 -13
- package/src/sources/HyperSync.res.mjs +206 -220
- package/src/sources/HyperSyncClient.res +5 -7
- package/src/sources/HyperSyncClient.res.mjs +70 -75
- package/src/sources/HyperSyncHeightStream.res +8 -9
- package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
- package/src/sources/HyperSyncJsonApi.res +18 -15
- package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
- package/src/sources/HyperSyncSource.res +17 -21
- package/src/sources/HyperSyncSource.res.mjs +268 -290
- package/src/sources/Rpc.res +5 -5
- package/src/sources/Rpc.res.mjs +168 -192
- package/src/sources/RpcSource.res +166 -167
- package/src/sources/RpcSource.res.mjs +972 -1046
- package/src/sources/RpcWebSocketHeightStream.res +10 -11
- package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
- package/src/sources/SimulateSource.res +1 -1
- package/src/sources/SimulateSource.res.mjs +35 -38
- package/src/sources/Source.res +1 -1
- package/src/sources/Source.res.mjs +3 -3
- package/src/sources/SourceManager.res +39 -20
- package/src/sources/SourceManager.res.mjs +340 -371
- package/src/sources/SourceManager.resi +2 -1
- package/src/sources/Svm.res +12 -5
- package/src/sources/Svm.res.mjs +44 -41
- package/src/tui/Tui.res +23 -12
- package/src/tui/Tui.res.mjs +292 -290
- package/src/tui/bindings/Ink.res +2 -4
- package/src/tui/bindings/Ink.res.mjs +35 -41
- package/src/tui/components/BufferedProgressBar.res +7 -7
- package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
- package/src/tui/components/CustomHooks.res +1 -2
- package/src/tui/components/CustomHooks.res.mjs +102 -122
- package/src/tui/components/Messages.res +1 -2
- package/src/tui/components/Messages.res.mjs +38 -42
- package/src/tui/components/SyncETA.res +10 -11
- package/src/tui/components/SyncETA.res.mjs +178 -196
- package/src/tui/components/TuiData.res +1 -1
- package/src/tui/components/TuiData.res.mjs +7 -6
- package/src/vendored/Rest.res +52 -66
- package/src/vendored/Rest.res.mjs +324 -364
- package/svm.schema.json +67 -0
- package/src/Address.gen.ts +0 -8
- package/src/Config.gen.ts +0 -19
- package/src/Envio.gen.ts +0 -55
- package/src/EvmTypes.gen.ts +0 -6
- package/src/InMemoryStore.gen.ts +0 -6
- package/src/Internal.gen.ts +0 -64
- package/src/PgStorage.gen.ts +0 -10
- package/src/PgStorage.res.d.mts +0 -5
- package/src/Types.ts +0 -56
- package/src/bindings/BigDecimal.gen.ts +0 -14
- package/src/bindings/BigDecimal.res.d.mts +0 -5
- package/src/bindings/BigInt.gen.ts +0 -10
- package/src/bindings/BigInt.res +0 -70
- package/src/bindings/BigInt.res.d.mts +0 -5
- package/src/bindings/BigInt.res.mjs +0 -154
- package/src/bindings/Ethers.res.d.mts +0 -5
- package/src/bindings/Pino.gen.ts +0 -17
- package/src/bindings/Postgres.gen.ts +0 -8
- package/src/bindings/Postgres.res.d.mts +0 -5
- package/src/bindings/Promise.res +0 -67
- package/src/bindings/Promise.res.mjs +0 -26
- package/src/db/InternalTable.gen.ts +0 -36
- package/src/sources/HyperSyncClient.gen.ts +0 -19
package/src/bindings/DateFns.res
CHANGED
|
@@ -21,24 +21,24 @@ type dateFormats =
|
|
|
21
21
|
| @as("MMM") Month
|
|
22
22
|
| @as("h:mma") HourMin
|
|
23
23
|
|
|
24
|
-
@module("date-fns") external format: (
|
|
24
|
+
@module("date-fns") external format: (Date.t, dateFormats) => string = "format"
|
|
25
25
|
|
|
26
26
|
type formatDistanceToNowOptions = {includeSeconds: bool}
|
|
27
27
|
@module("date-fns")
|
|
28
|
-
external formatDistanceToNow:
|
|
28
|
+
external formatDistanceToNow: Date.t => string = "formatDistanceToNow"
|
|
29
29
|
|
|
30
30
|
@module("date-fns")
|
|
31
|
-
external formatDistance: (
|
|
31
|
+
external formatDistance: (Date.t, Date.t) => string = "formatDistance"
|
|
32
32
|
|
|
33
33
|
@module("date-fns")
|
|
34
|
-
external formatDistanceWithOptions: (
|
|
34
|
+
external formatDistanceWithOptions: (Date.t, Date.t, formatDistanceToNowOptions) => string =
|
|
35
35
|
"formatDistance"
|
|
36
36
|
|
|
37
37
|
@module("date-fns")
|
|
38
|
-
external formatDistanceToNowWithOptions: (
|
|
38
|
+
external formatDistanceToNowWithOptions: (Date.t, formatDistanceToNowOptions) => string =
|
|
39
39
|
"formatDistanceToNow"
|
|
40
40
|
|
|
41
|
-
let formatDistanceToNowWithSeconds = (date:
|
|
41
|
+
let formatDistanceToNowWithSeconds = (date: Date.t) =>
|
|
42
42
|
date->formatDistanceToNowWithOptions({includeSeconds: true})
|
|
43
43
|
|
|
44
44
|
type durationTimeFormat = {
|
|
@@ -52,14 +52,14 @@ type durationTimeFormat = {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
@module("date-fns")
|
|
55
|
-
external formatRelative: (
|
|
55
|
+
external formatRelative: (Date.t, Date.t) => string = "formatRelative"
|
|
56
56
|
|
|
57
57
|
type durationFormatOutput = {format: array<string>}
|
|
58
58
|
|
|
59
59
|
@module("date-fns")
|
|
60
60
|
external formatDuration: (durationTimeFormat, durationFormatOutput) => string = "formatDuration"
|
|
61
61
|
|
|
62
|
-
type interval = {start:
|
|
62
|
+
type interval = {start: Date.t, end: Date.t}
|
|
63
63
|
|
|
64
64
|
@module("date-fns")
|
|
65
65
|
external intervalToDuration: interval => durationTimeFormat = "intervalToDuration"
|
|
@@ -67,8 +67,8 @@ external intervalToDuration: interval => durationTimeFormat = "intervalToDuratio
|
|
|
67
67
|
//helper to convert millis elapsed to duration object
|
|
68
68
|
let durationFromMillis = (millis: int) =>
|
|
69
69
|
intervalToDuration({
|
|
70
|
-
start: 0->(Utils.magic: int =>
|
|
71
|
-
end: millis->(Utils.magic: int =>
|
|
70
|
+
start: 0->(Utils.magic: int => Date.t),
|
|
71
|
+
end: millis->(Utils.magic: int => Date.t),
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
@module("date-fns") external fromUnixTime: float =>
|
|
74
|
+
@module("date-fns") external fromUnixTime: float => Date.t = "fromUnixTime"
|
|
@@ -4,19 +4,19 @@ import * as DateFns from "date-fns";
|
|
|
4
4
|
|
|
5
5
|
function formatDistanceToNowWithSeconds(date) {
|
|
6
6
|
return DateFns.formatDistanceToNow(date, {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
includeSeconds: true
|
|
8
|
+
});
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function durationFromMillis(millis) {
|
|
12
12
|
return DateFns.intervalToDuration({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
start: 0,
|
|
14
|
+
end: millis
|
|
15
|
+
});
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export {
|
|
19
|
-
formatDistanceToNowWithSeconds
|
|
20
|
-
durationFromMillis
|
|
19
|
+
formatDistanceToNowWithSeconds,
|
|
20
|
+
durationFromMillis,
|
|
21
21
|
}
|
|
22
22
|
/* date-fns Not a pure module */
|
package/src/bindings/Express.res
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
type app
|
|
4
4
|
|
|
5
|
-
// "default" & seem to conflict a bit right now
|
|
6
|
-
// https://github.com/rescript-lang/rescript-compiler/issues/5004
|
|
7
|
-
@module external makeCjs: unit => app = "express"
|
|
8
5
|
@module("express") external make: unit => app = "default"
|
|
9
6
|
|
|
10
7
|
type req = private {
|
|
@@ -28,11 +25,11 @@ type middleware = (req, res, unit => unit) => unit
|
|
|
28
25
|
type server
|
|
29
26
|
|
|
30
27
|
@send external listen: (app, int) => server = "listen"
|
|
31
|
-
@send external onError: (server, @as("error") _,
|
|
28
|
+
@send external onError: (server, @as("error") _, JsExn.t => unit) => unit = "on"
|
|
32
29
|
|
|
33
30
|
// res methods
|
|
34
31
|
@send external sendStatus: (res, int) => unit = "sendStatus"
|
|
35
32
|
@send external set: (res, string, string) => unit = "set"
|
|
36
|
-
@send external json: (res,
|
|
33
|
+
@send external json: (res, JSON.t) => unit = "json"
|
|
37
34
|
@send external endWithData: (res, 'a) => res = "end"
|
|
38
35
|
@send external setHeader: (res, string, string) => unit = "setHeader"
|
package/src/bindings/Hrtime.res
CHANGED
|
@@ -17,8 +17,8 @@ let secToMilli = (sec: seconds): milliseconds => sec *. 1_000.
|
|
|
17
17
|
|
|
18
18
|
let nanoToTimeTuple = (nano: nanoseconds): timeTuple => {
|
|
19
19
|
let factor = 1_000_000_000.
|
|
20
|
-
let seconds =
|
|
21
|
-
let nanos =
|
|
20
|
+
let seconds = Math.floor(nano /. factor)
|
|
21
|
+
let nanos = Float.mod(nano, factor)
|
|
22
22
|
(seconds, nanos)
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -10,20 +10,20 @@ function secToMilli(sec) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function nanoToTimeTuple(nano) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let seconds = Math.floor(nano / 1000000000);
|
|
14
|
+
let nanos = nano % 1000000000;
|
|
15
15
|
return [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
seconds,
|
|
17
|
+
nanos
|
|
18
|
+
];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function timeElapsedToNewRef(elapsed, ref) {
|
|
22
|
-
|
|
22
|
+
let match = nanoToTimeTuple(elapsed[1] + ref[1]);
|
|
23
23
|
return [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
elapsed[0] + ref[0] + match[0],
|
|
25
|
+
match[1]
|
|
26
|
+
];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function toMillis(param) {
|
|
@@ -34,12 +34,10 @@ function toSeconds(param) {
|
|
|
34
34
|
return param[0] + param[1] / 1000000000;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
return toSeconds(elapsed);
|
|
39
|
-
}
|
|
37
|
+
let toSecondsFloat = toSeconds;
|
|
40
38
|
|
|
41
|
-
function toInt(
|
|
42
|
-
return
|
|
39
|
+
function toInt(float) {
|
|
40
|
+
return float | 0;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
function floatFromMillis(v) {
|
|
@@ -66,27 +64,27 @@ function timeSince(prim) {
|
|
|
66
64
|
return process.hrtime(prim);
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
|
|
67
|
+
let intFromMillis = toInt;
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
let intFromNanos = toInt;
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
let intFromSeconds = toInt;
|
|
74
72
|
|
|
75
73
|
export {
|
|
76
|
-
makeTimer
|
|
77
|
-
timeSince
|
|
78
|
-
nanoToMilli
|
|
79
|
-
secToMilli
|
|
80
|
-
timeElapsedToNewRef
|
|
81
|
-
toMillis
|
|
82
|
-
toSeconds
|
|
83
|
-
toSecondsFloat
|
|
84
|
-
intFromMillis
|
|
85
|
-
intFromNanos
|
|
86
|
-
intFromSeconds
|
|
87
|
-
floatFromMillis
|
|
88
|
-
floatFromSeconds
|
|
89
|
-
millisBetween
|
|
90
|
-
secondsBetween
|
|
74
|
+
makeTimer,
|
|
75
|
+
timeSince,
|
|
76
|
+
nanoToMilli,
|
|
77
|
+
secToMilli,
|
|
78
|
+
timeElapsedToNewRef,
|
|
79
|
+
toMillis,
|
|
80
|
+
toSeconds,
|
|
81
|
+
toSecondsFloat,
|
|
82
|
+
intFromMillis,
|
|
83
|
+
intFromNanos,
|
|
84
|
+
intFromSeconds,
|
|
85
|
+
floatFromMillis,
|
|
86
|
+
floatFromSeconds,
|
|
87
|
+
millisBetween,
|
|
88
|
+
secondsBetween,
|
|
91
89
|
}
|
|
92
90
|
/* No side effect */
|
package/src/bindings/NodeJs.res
CHANGED
|
@@ -41,9 +41,10 @@ module Util = {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
module Process = {
|
|
44
|
-
type t = {env:
|
|
44
|
+
type t = {env: dict<string>, execArgv: array<string>}
|
|
45
45
|
@module external process: t = "process"
|
|
46
46
|
@module("process") external cwd: unit => string = "cwd"
|
|
47
|
+
@get external execPath: t => string = "execPath"
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
module ChildProcess = {
|
|
@@ -53,7 +54,7 @@ module ChildProcess = {
|
|
|
53
54
|
shell?: string,
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
type callback = (~error:
|
|
57
|
+
type callback = (~error: Null.t<exn>, ~stdout: string, ~stderr: string) => unit
|
|
57
58
|
|
|
58
59
|
@module("child_process")
|
|
59
60
|
external exec: (string, callback) => unit = "exec"
|
|
@@ -105,17 +106,21 @@ module WorkerThreads = {
|
|
|
105
106
|
@module("worker_threads") external isMainThread: bool = "isMainThread"
|
|
106
107
|
|
|
107
108
|
// Worker data passed from main thread
|
|
108
|
-
@module("worker_threads") external workerData:
|
|
109
|
+
@module("worker_threads") external workerData: Nullable.t<'a> = "workerData"
|
|
109
110
|
|
|
110
111
|
// MessagePort for communication with parent
|
|
111
112
|
type messagePort
|
|
112
|
-
@module("worker_threads") external parentPort:
|
|
113
|
+
@module("worker_threads") external parentPort: Nullable.t<messagePort> = "parentPort"
|
|
113
114
|
@send external postMessage: (messagePort, 'a) => unit = "postMessage"
|
|
114
115
|
@send external onPortMessage: (messagePort, @as("message") _, 'a => unit) => unit = "on"
|
|
115
116
|
|
|
116
117
|
// Worker class for spawning workers
|
|
117
118
|
type worker
|
|
118
|
-
type workerOptions = {
|
|
119
|
+
type workerOptions = {
|
|
120
|
+
workerData?: JSON.t,
|
|
121
|
+
execArgv?: array<string>,
|
|
122
|
+
env?: dict<string>,
|
|
123
|
+
}
|
|
119
124
|
|
|
120
125
|
@new @module("worker_threads")
|
|
121
126
|
external makeWorker: (string, workerOptions) => worker = "Worker"
|
|
@@ -152,10 +157,10 @@ module Fs = {
|
|
|
152
157
|
~filepath: Path.t,
|
|
153
158
|
~content: string,
|
|
154
159
|
~options: writeFileOptions=?,
|
|
155
|
-
) =>
|
|
160
|
+
) => promise<unit> = "appendFile"
|
|
156
161
|
|
|
157
162
|
@module("fs") @scope("promises")
|
|
158
|
-
external access: Path.t =>
|
|
163
|
+
external access: Path.t => promise<unit> = "access"
|
|
159
164
|
|
|
160
165
|
type encoding = | @as("utf8") Utf8
|
|
161
166
|
|
|
@@ -163,9 +168,9 @@ module Fs = {
|
|
|
163
168
|
external readFile: (~filepath: Path.t, ~encoding: encoding) => promise<string> = "readFile"
|
|
164
169
|
|
|
165
170
|
@module("fs") @scope("promises")
|
|
166
|
-
external mkdir: (~path: Path.t, ~options: mkdirOptions=?) =>
|
|
171
|
+
external mkdir: (~path: Path.t, ~options: mkdirOptions=?) => promise<unit> = "mkdir"
|
|
167
172
|
|
|
168
173
|
@module("fs") @scope("promises")
|
|
169
|
-
external readdir: Path.t =>
|
|
174
|
+
external readdir: Path.t => promise<array<string>> = "readdir"
|
|
170
175
|
}
|
|
171
176
|
}
|
|
@@ -6,51 +6,51 @@ import * as Util from "util";
|
|
|
6
6
|
|
|
7
7
|
function inspectObj(a) {
|
|
8
8
|
return Util.inspect(a, {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
showHidden: false,
|
|
10
|
+
depth: null,
|
|
11
|
+
colors: true
|
|
12
|
+
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
let Util$1 = {
|
|
16
16
|
inspectObj: inspectObj
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
let Process = {};
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
let ChildProcess = {};
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
let Url$1 = {};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
let ImportMeta = {};
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
let Module = {};
|
|
28
28
|
|
|
29
29
|
function getDirname(importMeta) {
|
|
30
30
|
return Path.dirname(Url.fileURLToPath(importMeta.url));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
let Path$1 = {
|
|
34
34
|
getDirname: getDirname
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
let WorkerThreads = {};
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
let Promises = {};
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
let Fs = {
|
|
42
42
|
Promises: Promises
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export {
|
|
46
46
|
Util$1 as Util,
|
|
47
|
-
Process
|
|
48
|
-
ChildProcess
|
|
47
|
+
Process,
|
|
48
|
+
ChildProcess,
|
|
49
49
|
Url$1 as Url,
|
|
50
|
-
ImportMeta
|
|
51
|
-
Module
|
|
50
|
+
ImportMeta,
|
|
51
|
+
Module,
|
|
52
52
|
Path$1 as Path,
|
|
53
|
-
WorkerThreads
|
|
54
|
-
Fs
|
|
53
|
+
WorkerThreads,
|
|
54
|
+
Fs,
|
|
55
55
|
}
|
|
56
56
|
/* url Not a pure module */
|
package/src/bindings/Pino.res
CHANGED
|
@@ -7,7 +7,6 @@ type logLevelBuiltin = [
|
|
|
7
7
|
| #fatal
|
|
8
8
|
| #silent
|
|
9
9
|
]
|
|
10
|
-
@genType
|
|
11
10
|
type logLevelUser = [
|
|
12
11
|
| // NOTE: pino does better when these are all lowercase - some parts of the code lower case logs.
|
|
13
12
|
#udebug
|
|
@@ -19,7 +18,6 @@ type logLevel = [logLevelBuiltin | logLevelUser]
|
|
|
19
18
|
|
|
20
19
|
type pinoMessageBlob
|
|
21
20
|
type pinoMessageBlobWithError
|
|
22
|
-
@genType
|
|
23
21
|
type t = {
|
|
24
22
|
trace: pinoMessageBlob => unit,
|
|
25
23
|
debug: pinoMessageBlob => unit,
|
|
@@ -73,12 +71,12 @@ module Transport = {
|
|
|
73
71
|
type hooks = {logMethod: (array<string>, string, logLevel) => unit}
|
|
74
72
|
|
|
75
73
|
type formatters = {
|
|
76
|
-
level: (string, int) =>
|
|
77
|
-
bindings:
|
|
78
|
-
log:
|
|
74
|
+
level: (string, int) => JSON.t,
|
|
75
|
+
bindings: JSON.t => JSON.t,
|
|
76
|
+
log: JSON.t => JSON.t,
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
type serializers = {err:
|
|
79
|
+
type serializers = {err: JSON.t => JSON.t}
|
|
82
80
|
|
|
83
81
|
type options = {
|
|
84
82
|
name?: string,
|
|
@@ -87,14 +85,14 @@ type options = {
|
|
|
87
85
|
useOnlyCustomLevels?: bool,
|
|
88
86
|
depthLimit?: int,
|
|
89
87
|
edgeLimit?: int,
|
|
90
|
-
mixin?: unit =>
|
|
91
|
-
mixinMergeStrategy?: (
|
|
88
|
+
mixin?: unit => JSON.t,
|
|
89
|
+
mixinMergeStrategy?: (JSON.t, JSON.t) => JSON.t,
|
|
92
90
|
redact?: array<string>,
|
|
93
91
|
hooks?: hooks,
|
|
94
92
|
formatters?: formatters,
|
|
95
93
|
serializers?: serializers,
|
|
96
94
|
msgPrefix?: string,
|
|
97
|
-
base?:
|
|
95
|
+
base?: JSON.t,
|
|
98
96
|
enabled?: bool,
|
|
99
97
|
crlf?: bool,
|
|
100
98
|
timestamp?: bool,
|
|
@@ -159,7 +157,7 @@ module MultiStreamLogger = {
|
|
|
159
157
|
|
|
160
158
|
let makeStreams = (~userLogLevel, ~formatter, ~logFile, ~defaultFileLogLevel) => {
|
|
161
159
|
let stream = {
|
|
162
|
-
stream: {write: v => formatter(v)->
|
|
160
|
+
stream: {write: v => formatter(v)->Console.log},
|
|
163
161
|
level: userLogLevel,
|
|
164
162
|
}
|
|
165
163
|
let maybeFileStream = logFile->Belt.Option.mapWithDefault([], dest => [
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Pino from "pino";
|
|
4
4
|
import * as Utils from "../Utils.res.mjs";
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
7
|
-
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
5
|
+
import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.js";
|
|
6
|
+
import * as Belt_Option from "@rescript/runtime/lib/es6/Belt_Option.js";
|
|
8
7
|
import * as PinoPretty from "pino-pretty";
|
|
9
8
|
import EcsPinoFormat from "@elastic/ecs-pino-format";
|
|
10
9
|
|
|
@@ -14,16 +13,16 @@ function createPinoMessage(message) {
|
|
|
14
13
|
|
|
15
14
|
function createPinoMessageWithError(message, err) {
|
|
16
15
|
return {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
msg: message,
|
|
17
|
+
err: Utils.prettifyExn(err)
|
|
18
|
+
};
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
function makeTransportOptions(v) {
|
|
23
22
|
return v;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
let Transport = {
|
|
27
26
|
makeTransportOptions: makeTransportOptions
|
|
28
27
|
};
|
|
29
28
|
|
|
@@ -35,50 +34,48 @@ function make(prim) {
|
|
|
35
34
|
return EcsPinoFormat(prim);
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
let ECS = {
|
|
39
38
|
make: make
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
function makeFormatter(logLevels) {
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
let customColors = "fatal:bgRed,error:red,warn:yellow,info:green,udebug:bgBlue,uinfo:bgGreen,uwarn:bgYellow,uerror:bgRed,debug:blue,trace:gray";
|
|
43
|
+
let match = ("ENVIO_TEST_LOGGING_FORMAT" in process.env);
|
|
45
44
|
return PinoPretty.prettyFactory(match !== undefined ? ({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
customLevels: logLevels,
|
|
46
|
+
customColors: customColors,
|
|
47
|
+
colorize: true
|
|
48
|
+
}) : ({
|
|
49
|
+
customLevels: logLevels,
|
|
50
|
+
customColors: customColors
|
|
51
|
+
}));
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
function makeStreams(userLogLevel, formatter, logFile, defaultFileLogLevel) {
|
|
56
|
-
|
|
57
|
-
write:
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
let stream_stream = {
|
|
56
|
+
write: v => {
|
|
57
|
+
console.log(formatter(v));
|
|
58
|
+
}
|
|
60
59
|
};
|
|
61
|
-
|
|
60
|
+
let stream = {
|
|
62
61
|
stream: stream_stream,
|
|
63
62
|
level: userLogLevel
|
|
64
63
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}];
|
|
74
|
-
}));
|
|
64
|
+
let maybeFileStream = Belt_Option.mapWithDefault(logFile, [], dest => [{
|
|
65
|
+
stream: Pino.destination({
|
|
66
|
+
dest: dest,
|
|
67
|
+
sync: false,
|
|
68
|
+
mkdir: true
|
|
69
|
+
}),
|
|
70
|
+
level: defaultFileLogLevel
|
|
71
|
+
}]);
|
|
75
72
|
return Belt_Array.concat([stream], maybeFileStream);
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
function make$1(userLogLevel, customLevels, logFile, options, defaultFileLogLevel) {
|
|
79
|
-
|
|
76
|
+
let options$1;
|
|
80
77
|
if (options !== undefined) {
|
|
81
|
-
|
|
78
|
+
let newrecord = {...options};
|
|
82
79
|
newrecord.customLevels = customLevels;
|
|
83
80
|
newrecord.level = userLogLevel;
|
|
84
81
|
options$1 = newrecord;
|
|
@@ -88,23 +85,23 @@ function make$1(userLogLevel, customLevels, logFile, options, defaultFileLogLeve
|
|
|
88
85
|
customLevels: customLevels
|
|
89
86
|
};
|
|
90
87
|
}
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
let formatter = makeFormatter(customLevels);
|
|
89
|
+
let ms = Pino.multistream(makeStreams(userLogLevel, formatter, logFile, defaultFileLogLevel));
|
|
93
90
|
return Pino.pino(options$1, ms);
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
|
|
93
|
+
let MultiStreamLogger = {
|
|
97
94
|
makeFormatter: makeFormatter,
|
|
98
95
|
makeStreams: makeStreams,
|
|
99
96
|
make: make$1
|
|
100
97
|
};
|
|
101
98
|
|
|
102
99
|
export {
|
|
103
|
-
createPinoMessage
|
|
104
|
-
createPinoMessageWithError
|
|
105
|
-
Transport
|
|
106
|
-
createChildParams
|
|
107
|
-
ECS
|
|
108
|
-
MultiStreamLogger
|
|
100
|
+
createPinoMessage,
|
|
101
|
+
createPinoMessageWithError,
|
|
102
|
+
Transport,
|
|
103
|
+
createChildParams,
|
|
104
|
+
ECS,
|
|
105
|
+
MultiStreamLogger,
|
|
109
106
|
}
|
|
110
107
|
/* pino Not a pure module */
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Only needed for some old tests
|
|
2
|
-
// Remove @genType in the future
|
|
3
|
-
@genType.import(("postgres", "Sql"))
|
|
4
1
|
type sql
|
|
5
2
|
|
|
6
3
|
type undefinedTransform = | @as(undefined) Undefined | @as(null) Null
|
|
@@ -21,7 +18,7 @@ type buffer
|
|
|
21
18
|
type secureContext
|
|
22
19
|
|
|
23
20
|
type onread = {
|
|
24
|
-
buffer:
|
|
21
|
+
buffer: Nullable.t<array<int>> => array<int>,
|
|
25
22
|
callback: (int, array<int>) => unit,
|
|
26
23
|
}
|
|
27
24
|
|
|
@@ -36,7 +33,7 @@ type tlsConnectOptions = {
|
|
|
36
33
|
pskCallback?: unit => unit,
|
|
37
34
|
@as("ALPNProtocols") alpnProtocols?: array<string>, //| array<Buffer> | array<typedArray> | array<DataView> | Buffer | typedArray | DataView,
|
|
38
35
|
servername?: string,
|
|
39
|
-
checkServerIdentity?: 'a. (string, 'a) => option<
|
|
36
|
+
checkServerIdentity?: 'a. (string, 'a) => option<JsExn.t>,
|
|
40
37
|
session?: buffer,
|
|
41
38
|
minDHSize?: int /* Default: 1024 */,
|
|
42
39
|
highWaterMark?: int /* Default: 16 * 1024 */,
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
let sslOptionsSchema = S$RescriptSchema.$$enum([
|
|
6
|
+
true,
|
|
7
|
+
false,
|
|
8
|
+
"require",
|
|
9
|
+
"allow",
|
|
10
|
+
"prefer",
|
|
11
|
+
"verify-full"
|
|
12
|
+
]);
|
|
13
13
|
|
|
14
14
|
export {
|
|
15
|
-
sslOptionsSchema
|
|
15
|
+
sslOptionsSchema,
|
|
16
16
|
}
|
|
17
17
|
/* sslOptionsSchema Not a pure module */
|
|
@@ -18,10 +18,23 @@ type metricValue = {
|
|
|
18
18
|
type metricInstance = {get: unit => promise<{"values": array<metricValue>}>}
|
|
19
19
|
@send external getSingleMetric: (registry, string) => option<metricInstance> = "getSingleMetric"
|
|
20
20
|
@send external resetMetrics: registry => unit = "resetMetrics"
|
|
21
|
+
@send external clear: registry => unit = "clear"
|
|
22
|
+
|
|
23
|
+
// Idempotent metric creation: if the metric already exists in the
|
|
24
|
+
// registry (e.g., module loaded twice via different pnpm paths),
|
|
25
|
+
// return the existing one instead of throwing.
|
|
26
|
+
let getOrCreate = (name: string, create: unit => 'a): 'a => {
|
|
27
|
+
switch defaultRegister->getSingleMetric(name) {
|
|
28
|
+
| Some(existing) => existing->(Utils.magic: metricInstance => 'a)
|
|
29
|
+
| None => create()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
21
32
|
|
|
22
33
|
module Counter = {
|
|
23
34
|
type counter
|
|
24
|
-
@new @module("prom-client") external
|
|
35
|
+
@new @module("prom-client") external makeCounterUnsafe: customMetric<'a> => counter = "Counter"
|
|
36
|
+
let makeCounter = (config: customMetric<'a>): counter =>
|
|
37
|
+
getOrCreate(config["name"], () => makeCounterUnsafe(config))
|
|
25
38
|
|
|
26
39
|
@send external inc: counter => unit = "inc"
|
|
27
40
|
@send external incMany: (counter, int) => unit = "inc"
|
|
@@ -31,7 +44,9 @@ module Counter = {
|
|
|
31
44
|
|
|
32
45
|
module Gauge = {
|
|
33
46
|
type gauge
|
|
34
|
-
@new @module("prom-client") external
|
|
47
|
+
@new @module("prom-client") external makeGaugeUnsafe: customMetric<'a> => gauge = "Gauge"
|
|
48
|
+
let makeGauge = (config: customMetric<'a>): gauge =>
|
|
49
|
+
getOrCreate(config["name"], () => makeGaugeUnsafe(config))
|
|
35
50
|
|
|
36
51
|
@send external inc: gauge => unit = "inc"
|
|
37
52
|
@send external incMany: (gauge, int) => unit = "inc"
|