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.
Files changed (219) hide show
  1. package/bin.mjs +2 -48
  2. package/evm.schema.json +67 -0
  3. package/fuel.schema.json +67 -0
  4. package/index.d.ts +822 -38
  5. package/index.js +5 -3
  6. package/package.json +10 -8
  7. package/rescript.json +5 -9
  8. package/src/Address.res +4 -5
  9. package/src/Address.res.mjs +9 -12
  10. package/src/Api.res +15 -0
  11. package/src/Api.res.mjs +20 -0
  12. package/src/Batch.res +32 -34
  13. package/src/Batch.res.mjs +172 -187
  14. package/src/Bin.res +89 -0
  15. package/src/Bin.res.mjs +97 -0
  16. package/src/ChainFetcher.res +33 -57
  17. package/src/ChainFetcher.res.mjs +197 -227
  18. package/src/ChainManager.res +6 -14
  19. package/src/ChainManager.res.mjs +74 -85
  20. package/src/ChainMap.res +14 -16
  21. package/src/ChainMap.res.mjs +38 -38
  22. package/src/Config.res +193 -135
  23. package/src/Config.res.mjs +566 -592
  24. package/src/Core.res +182 -0
  25. package/src/Core.res.mjs +207 -0
  26. package/src/Ecosystem.res +25 -4
  27. package/src/Ecosystem.res.mjs +12 -13
  28. package/src/Env.res +20 -13
  29. package/src/Env.res.mjs +124 -113
  30. package/src/EnvSafe.res +269 -0
  31. package/src/EnvSafe.res.mjs +296 -0
  32. package/src/EnvSafe.resi +18 -0
  33. package/src/Envio.res +37 -26
  34. package/src/Envio.res.mjs +59 -60
  35. package/src/ErrorHandling.res +2 -2
  36. package/src/ErrorHandling.res.mjs +15 -15
  37. package/src/EventConfigBuilder.res +219 -81
  38. package/src/EventConfigBuilder.res.mjs +259 -202
  39. package/src/EventProcessing.res +27 -38
  40. package/src/EventProcessing.res.mjs +165 -183
  41. package/src/EventUtils.res +11 -11
  42. package/src/EventUtils.res.mjs +21 -22
  43. package/src/EvmTypes.res +0 -1
  44. package/src/EvmTypes.res.mjs +5 -5
  45. package/src/FetchState.res +360 -256
  46. package/src/FetchState.res.mjs +958 -914
  47. package/src/GlobalState.res +365 -351
  48. package/src/GlobalState.res.mjs +958 -992
  49. package/src/GlobalStateManager.res +1 -2
  50. package/src/GlobalStateManager.res.mjs +36 -44
  51. package/src/HandlerLoader.res +107 -23
  52. package/src/HandlerLoader.res.mjs +128 -38
  53. package/src/HandlerRegister.res +127 -103
  54. package/src/HandlerRegister.res.mjs +164 -164
  55. package/src/HandlerRegister.resi +12 -4
  56. package/src/Hasura.res +35 -22
  57. package/src/Hasura.res.mjs +158 -167
  58. package/src/InMemoryStore.res +20 -27
  59. package/src/InMemoryStore.res.mjs +64 -80
  60. package/src/InMemoryTable.res +34 -39
  61. package/src/InMemoryTable.res.mjs +165 -170
  62. package/src/Internal.res +52 -33
  63. package/src/Internal.res.mjs +84 -81
  64. package/src/LazyLoader.res.mjs +55 -61
  65. package/src/LoadLayer.res +77 -78
  66. package/src/LoadLayer.res.mjs +160 -189
  67. package/src/LoadManager.res +16 -21
  68. package/src/LoadManager.res.mjs +79 -84
  69. package/src/LogSelection.res +236 -68
  70. package/src/LogSelection.res.mjs +211 -141
  71. package/src/Logging.res +13 -9
  72. package/src/Logging.res.mjs +130 -143
  73. package/src/Main.res +428 -51
  74. package/src/Main.res.mjs +528 -271
  75. package/src/Persistence.res +77 -84
  76. package/src/Persistence.res.mjs +131 -132
  77. package/src/PgStorage.res +291 -167
  78. package/src/PgStorage.res.mjs +797 -817
  79. package/src/Prometheus.res +50 -58
  80. package/src/Prometheus.res.mjs +345 -373
  81. package/src/ReorgDetection.res +22 -24
  82. package/src/ReorgDetection.res.mjs +100 -106
  83. package/src/SafeCheckpointTracking.res +7 -7
  84. package/src/SafeCheckpointTracking.res.mjs +40 -43
  85. package/src/SimulateItems.res +41 -49
  86. package/src/SimulateItems.res.mjs +257 -272
  87. package/src/Sink.res +2 -2
  88. package/src/Sink.res.mjs +22 -26
  89. package/src/TableIndices.res +1 -2
  90. package/src/TableIndices.res.mjs +42 -48
  91. package/src/TestIndexer.res +196 -189
  92. package/src/TestIndexer.res.mjs +536 -536
  93. package/src/TestIndexerProxyStorage.res +15 -16
  94. package/src/TestIndexerProxyStorage.res.mjs +98 -122
  95. package/src/TestIndexerWorker.res +4 -0
  96. package/src/TestIndexerWorker.res.mjs +7 -0
  97. package/src/Throttler.res +3 -3
  98. package/src/Throttler.res.mjs +23 -24
  99. package/src/Time.res +1 -1
  100. package/src/Time.res.mjs +18 -21
  101. package/src/TopicFilter.res +3 -3
  102. package/src/TopicFilter.res.mjs +29 -30
  103. package/src/UserContext.res +93 -54
  104. package/src/UserContext.res.mjs +197 -182
  105. package/src/Utils.res +141 -86
  106. package/src/Utils.res.mjs +334 -295
  107. package/src/bindings/BigDecimal.res +0 -2
  108. package/src/bindings/BigDecimal.res.mjs +19 -23
  109. package/src/bindings/ClickHouse.res +28 -27
  110. package/src/bindings/ClickHouse.res.mjs +243 -240
  111. package/src/bindings/DateFns.res +11 -11
  112. package/src/bindings/DateFns.res.mjs +7 -7
  113. package/src/bindings/EventSource.res.mjs +2 -2
  114. package/src/bindings/Express.res +2 -5
  115. package/src/bindings/Hrtime.res +2 -2
  116. package/src/bindings/Hrtime.res.mjs +30 -32
  117. package/src/bindings/Lodash.res.mjs +1 -1
  118. package/src/bindings/NodeJs.res +14 -9
  119. package/src/bindings/NodeJs.res.mjs +20 -20
  120. package/src/bindings/Pino.res +8 -10
  121. package/src/bindings/Pino.res.mjs +40 -43
  122. package/src/bindings/Postgres.res +2 -5
  123. package/src/bindings/Postgres.res.mjs +9 -9
  124. package/src/bindings/PromClient.res +17 -2
  125. package/src/bindings/PromClient.res.mjs +30 -7
  126. package/src/bindings/SDSL.res.mjs +2 -2
  127. package/src/bindings/Viem.res +4 -4
  128. package/src/bindings/Viem.res.mjs +20 -22
  129. package/src/bindings/Vitest.res +1 -1
  130. package/src/bindings/Vitest.res.mjs +2 -2
  131. package/src/bindings/WebSocket.res +1 -1
  132. package/src/db/EntityHistory.res +9 -3
  133. package/src/db/EntityHistory.res.mjs +84 -59
  134. package/src/db/InternalTable.res +62 -60
  135. package/src/db/InternalTable.res.mjs +271 -203
  136. package/src/db/Schema.res +1 -2
  137. package/src/db/Schema.res.mjs +28 -32
  138. package/src/db/Table.res +28 -27
  139. package/src/db/Table.res.mjs +276 -292
  140. package/src/sources/EventRouter.res +21 -16
  141. package/src/sources/EventRouter.res.mjs +55 -57
  142. package/src/sources/Evm.res +17 -1
  143. package/src/sources/Evm.res.mjs +16 -8
  144. package/src/sources/EvmChain.res +15 -17
  145. package/src/sources/EvmChain.res.mjs +40 -42
  146. package/src/sources/Fuel.res +14 -1
  147. package/src/sources/Fuel.res.mjs +16 -8
  148. package/src/sources/FuelSDK.res +1 -1
  149. package/src/sources/FuelSDK.res.mjs +6 -8
  150. package/src/sources/HyperFuel.res +8 -10
  151. package/src/sources/HyperFuel.res.mjs +113 -123
  152. package/src/sources/HyperFuelClient.res.mjs +6 -7
  153. package/src/sources/HyperFuelSource.res +19 -20
  154. package/src/sources/HyperFuelSource.res.mjs +339 -356
  155. package/src/sources/HyperSync.res +11 -13
  156. package/src/sources/HyperSync.res.mjs +206 -220
  157. package/src/sources/HyperSyncClient.res +5 -7
  158. package/src/sources/HyperSyncClient.res.mjs +70 -75
  159. package/src/sources/HyperSyncHeightStream.res +8 -9
  160. package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
  161. package/src/sources/HyperSyncJsonApi.res +18 -15
  162. package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
  163. package/src/sources/HyperSyncSource.res +17 -21
  164. package/src/sources/HyperSyncSource.res.mjs +268 -290
  165. package/src/sources/Rpc.res +5 -5
  166. package/src/sources/Rpc.res.mjs +168 -192
  167. package/src/sources/RpcSource.res +166 -167
  168. package/src/sources/RpcSource.res.mjs +972 -1046
  169. package/src/sources/RpcWebSocketHeightStream.res +10 -11
  170. package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
  171. package/src/sources/SimulateSource.res +1 -1
  172. package/src/sources/SimulateSource.res.mjs +35 -38
  173. package/src/sources/Source.res +1 -1
  174. package/src/sources/Source.res.mjs +3 -3
  175. package/src/sources/SourceManager.res +39 -20
  176. package/src/sources/SourceManager.res.mjs +340 -371
  177. package/src/sources/SourceManager.resi +2 -1
  178. package/src/sources/Svm.res +12 -5
  179. package/src/sources/Svm.res.mjs +44 -41
  180. package/src/tui/Tui.res +23 -12
  181. package/src/tui/Tui.res.mjs +292 -290
  182. package/src/tui/bindings/Ink.res +2 -4
  183. package/src/tui/bindings/Ink.res.mjs +35 -41
  184. package/src/tui/components/BufferedProgressBar.res +7 -7
  185. package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
  186. package/src/tui/components/CustomHooks.res +1 -2
  187. package/src/tui/components/CustomHooks.res.mjs +102 -122
  188. package/src/tui/components/Messages.res +1 -2
  189. package/src/tui/components/Messages.res.mjs +38 -42
  190. package/src/tui/components/SyncETA.res +10 -11
  191. package/src/tui/components/SyncETA.res.mjs +178 -196
  192. package/src/tui/components/TuiData.res +1 -1
  193. package/src/tui/components/TuiData.res.mjs +7 -6
  194. package/src/vendored/Rest.res +52 -66
  195. package/src/vendored/Rest.res.mjs +324 -364
  196. package/svm.schema.json +67 -0
  197. package/src/Address.gen.ts +0 -8
  198. package/src/Config.gen.ts +0 -19
  199. package/src/Envio.gen.ts +0 -55
  200. package/src/EvmTypes.gen.ts +0 -6
  201. package/src/InMemoryStore.gen.ts +0 -6
  202. package/src/Internal.gen.ts +0 -64
  203. package/src/PgStorage.gen.ts +0 -10
  204. package/src/PgStorage.res.d.mts +0 -5
  205. package/src/Types.ts +0 -56
  206. package/src/bindings/BigDecimal.gen.ts +0 -14
  207. package/src/bindings/BigDecimal.res.d.mts +0 -5
  208. package/src/bindings/BigInt.gen.ts +0 -10
  209. package/src/bindings/BigInt.res +0 -70
  210. package/src/bindings/BigInt.res.d.mts +0 -5
  211. package/src/bindings/BigInt.res.mjs +0 -154
  212. package/src/bindings/Ethers.res.d.mts +0 -5
  213. package/src/bindings/Pino.gen.ts +0 -17
  214. package/src/bindings/Postgres.gen.ts +0 -8
  215. package/src/bindings/Postgres.res.d.mts +0 -5
  216. package/src/bindings/Promise.res +0 -67
  217. package/src/bindings/Promise.res.mjs +0 -26
  218. package/src/db/InternalTable.gen.ts +0 -36
  219. package/src/sources/HyperSyncClient.gen.ts +0 -19
@@ -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: (Js.Date.t, dateFormats) => string = "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: Js.Date.t => string = "formatDistanceToNow"
28
+ external formatDistanceToNow: Date.t => string = "formatDistanceToNow"
29
29
 
30
30
  @module("date-fns")
31
- external formatDistance: (Js.Date.t, Js.Date.t) => string = "formatDistance"
31
+ external formatDistance: (Date.t, Date.t) => string = "formatDistance"
32
32
 
33
33
  @module("date-fns")
34
- external formatDistanceWithOptions: (Js.Date.t, Js.Date.t, formatDistanceToNowOptions) => string =
34
+ external formatDistanceWithOptions: (Date.t, Date.t, formatDistanceToNowOptions) => string =
35
35
  "formatDistance"
36
36
 
37
37
  @module("date-fns")
38
- external formatDistanceToNowWithOptions: (Js.Date.t, formatDistanceToNowOptions) => string =
38
+ external formatDistanceToNowWithOptions: (Date.t, formatDistanceToNowOptions) => string =
39
39
  "formatDistanceToNow"
40
40
 
41
- let formatDistanceToNowWithSeconds = (date: Js.Date.t) =>
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: (Js.Date.t, Js.Date.t) => string = "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: Js_date.t, end: Js_date.t}
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 => Js_date.t),
71
- end: millis->(Utils.magic: int => Js_date.t),
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 => Js.Date.t = "fromUnixTime"
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
- includeSeconds: true
8
- });
7
+ includeSeconds: true
8
+ });
9
9
  }
10
10
 
11
11
  function durationFromMillis(millis) {
12
12
  return DateFns.intervalToDuration({
13
- start: 0,
14
- end: millis
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 */
@@ -1,9 +1,9 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
 
4
- var Fetch = {};
4
+ let Fetch = {};
5
5
 
6
6
  export {
7
- Fetch ,
7
+ Fetch,
8
8
  }
9
9
  /* No side effect */
@@ -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") _, Js.Exn.t => unit) => unit = "on"
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, Js.Json.t) => unit = "json"
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"
@@ -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 = Js.Math.floor_float(nano /. factor)
21
- let nanos = mod_float(nano, factor)
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
- var seconds = Math.floor(nano / 1000000000);
14
- var nanos = nano % 1000000000;
13
+ let seconds = Math.floor(nano / 1000000000);
14
+ let nanos = nano % 1000000000;
15
15
  return [
16
- seconds,
17
- nanos
18
- ];
16
+ seconds,
17
+ nanos
18
+ ];
19
19
  }
20
20
 
21
21
  function timeElapsedToNewRef(elapsed, ref) {
22
- var match = nanoToTimeTuple(elapsed[1] + ref[1]);
22
+ let match = nanoToTimeTuple(elapsed[1] + ref[1]);
23
23
  return [
24
- elapsed[0] + ref[0] + match[0],
25
- match[1]
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
- function toSecondsFloat(elapsed) {
38
- return toSeconds(elapsed);
39
- }
37
+ let toSecondsFloat = toSeconds;
40
38
 
41
- function toInt($$float) {
42
- return $$float | 0;
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
- var intFromMillis = toInt;
67
+ let intFromMillis = toInt;
70
68
 
71
- var intFromNanos = toInt;
69
+ let intFromNanos = toInt;
72
70
 
73
- var intFromSeconds = toInt;
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 */
@@ -7,6 +7,6 @@ function cloneDeep(prim) {
7
7
  }
8
8
 
9
9
  export {
10
- cloneDeep ,
10
+ cloneDeep,
11
11
  }
12
12
  /* ./vendored-lodash-fns.js Not a pure module */
@@ -41,9 +41,10 @@ module Util = {
41
41
  }
42
42
 
43
43
  module Process = {
44
- type t = {env: Js.Dict.t<string>, execArgv: array<string>}
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: Js.null<exn>, ~stdout: string, ~stderr: string) => unit
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: Js.Nullable.t<'a> = "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: Js.Nullable.t<messagePort> = "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 = {workerData?: Js.Json.t, execArgv?: array<string>}
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
- ) => Js.Promise.t<unit> = "appendFile"
160
+ ) => promise<unit> = "appendFile"
156
161
 
157
162
  @module("fs") @scope("promises")
158
- external access: Path.t => Js.Promise.t<unit> = "access"
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=?) => Js.Promise.t<unit> = "mkdir"
171
+ external mkdir: (~path: Path.t, ~options: mkdirOptions=?) => promise<unit> = "mkdir"
167
172
 
168
173
  @module("fs") @scope("promises")
169
- external readdir: Path.t => Js.Promise.t<array<string>> = "readdir"
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
- showHidden: false,
10
- depth: null,
11
- colors: true
12
- });
9
+ showHidden: false,
10
+ depth: null,
11
+ colors: true
12
+ });
13
13
  }
14
14
 
15
- var Util$1 = {
15
+ let Util$1 = {
16
16
  inspectObj: inspectObj
17
17
  };
18
18
 
19
- var Process = {};
19
+ let Process = {};
20
20
 
21
- var ChildProcess = {};
21
+ let ChildProcess = {};
22
22
 
23
- var Url$1 = {};
23
+ let Url$1 = {};
24
24
 
25
- var ImportMeta = {};
25
+ let ImportMeta = {};
26
26
 
27
- var Module = {};
27
+ let Module = {};
28
28
 
29
29
  function getDirname(importMeta) {
30
30
  return Path.dirname(Url.fileURLToPath(importMeta.url));
31
31
  }
32
32
 
33
- var Path$1 = {
33
+ let Path$1 = {
34
34
  getDirname: getDirname
35
35
  };
36
36
 
37
- var WorkerThreads = {};
37
+ let WorkerThreads = {};
38
38
 
39
- var Promises = {};
39
+ let Promises = {};
40
40
 
41
- var Fs = {
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 */
@@ -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) => Js.Json.t,
77
- bindings: Js.Json.t => Js.Json.t,
78
- log: Js.Json.t => Js.Json.t,
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: Js.Json.t => Js.Json.t}
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 => Js.Json.t,
91
- mixinMergeStrategy?: (Js.Json.t, Js.Json.t) => Js.Json.t,
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?: Js.Json.t,
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)->Js.log},
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 Caml_obj from "rescript/lib/es6/caml_obj.js";
6
- import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
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
- msg: message,
18
- err: Utils.prettifyExn(err)
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
- var Transport = {
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
- var ECS = {
37
+ let ECS = {
39
38
  make: make
40
39
  };
41
40
 
42
41
  function makeFormatter(logLevels) {
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);
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
- customLevels: logLevels,
47
- customColors: customColors,
48
- colorize: true
49
- }) : ({
50
- customLevels: logLevels,
51
- customColors: customColors
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
- var stream_stream = {
57
- write: (function (v) {
58
- console.log(formatter(v));
59
- })
55
+ let stream_stream = {
56
+ write: v => {
57
+ console.log(formatter(v));
58
+ }
60
59
  };
61
- var stream = {
60
+ let stream = {
62
61
  stream: stream_stream,
63
62
  level: userLogLevel
64
63
  };
65
- var maybeFileStream = Belt_Option.mapWithDefault(logFile, [], (function (dest) {
66
- return [{
67
- stream: Pino.destination({
68
- dest: dest,
69
- sync: false,
70
- mkdir: true
71
- }),
72
- level: defaultFileLogLevel
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
- var options$1;
76
+ let options$1;
80
77
  if (options !== undefined) {
81
- var newrecord = Caml_obj.obj_dup(options);
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
- var formatter = makeFormatter(customLevels);
92
- var ms = Pino.multistream(makeStreams(userLogLevel, formatter, logFile, defaultFileLogLevel));
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
- var MultiStreamLogger = {
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: Js.Nullable.t<array<int>> => array<int>,
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<Js.Exn.t>,
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
- var sslOptionsSchema = S$RescriptSchema.$$enum([
6
- true,
7
- false,
8
- "require",
9
- "allow",
10
- "prefer",
11
- "verify-full"
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 makeCounter: customMetric<'a> => counter = "Counter"
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 makeGauge: customMetric<'a> => gauge = "Gauge"
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"