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.
Files changed (184) hide show
  1. package/README.md +164 -30
  2. package/bin.mjs +49 -0
  3. package/evm.schema.json +79 -169
  4. package/fuel.schema.json +50 -21
  5. package/index.d.ts +578 -1
  6. package/index.js +4 -0
  7. package/package.json +47 -31
  8. package/rescript.json +4 -1
  9. package/src/Batch.res +11 -8
  10. package/src/Batch.res.mjs +11 -9
  11. package/src/ChainFetcher.res +531 -0
  12. package/src/ChainFetcher.res.mjs +339 -0
  13. package/src/ChainManager.res +190 -0
  14. package/src/ChainManager.res.mjs +166 -0
  15. package/src/Change.res +3 -3
  16. package/src/Config.gen.ts +19 -0
  17. package/src/Config.res +725 -25
  18. package/src/Config.res.mjs +692 -26
  19. package/src/{Indexer.res → Ctx.res} +1 -1
  20. package/src/Ecosystem.res +9 -124
  21. package/src/Ecosystem.res.mjs +19 -160
  22. package/src/Env.res +33 -73
  23. package/src/Env.res.mjs +29 -85
  24. package/src/Envio.gen.ts +3 -1
  25. package/src/Envio.res +77 -9
  26. package/src/Envio.res.mjs +39 -1
  27. package/src/EventConfigBuilder.res +408 -0
  28. package/src/EventConfigBuilder.res.mjs +376 -0
  29. package/src/EventProcessing.res +469 -0
  30. package/src/EventProcessing.res.mjs +337 -0
  31. package/src/EvmTypes.gen.ts +6 -0
  32. package/src/EvmTypes.res +1 -0
  33. package/src/FetchState.res +1256 -639
  34. package/src/FetchState.res.mjs +1135 -612
  35. package/src/GlobalState.res +1224 -0
  36. package/src/GlobalState.res.mjs +1291 -0
  37. package/src/GlobalStateManager.res +68 -0
  38. package/src/GlobalStateManager.res.mjs +75 -0
  39. package/src/GlobalStateManager.resi +7 -0
  40. package/src/HandlerLoader.res +89 -0
  41. package/src/HandlerLoader.res.mjs +79 -0
  42. package/src/HandlerRegister.res +357 -0
  43. package/src/HandlerRegister.res.mjs +299 -0
  44. package/src/HandlerRegister.resi +30 -0
  45. package/src/Hasura.res +111 -175
  46. package/src/Hasura.res.mjs +88 -150
  47. package/src/InMemoryStore.res +1 -1
  48. package/src/InMemoryStore.res.mjs +3 -3
  49. package/src/InMemoryTable.res +1 -1
  50. package/src/InMemoryTable.res.mjs +1 -1
  51. package/src/Internal.gen.ts +6 -0
  52. package/src/Internal.res +265 -12
  53. package/src/Internal.res.mjs +115 -1
  54. package/src/LoadLayer.res +444 -0
  55. package/src/LoadLayer.res.mjs +296 -0
  56. package/src/LoadLayer.resi +32 -0
  57. package/src/LogSelection.res +33 -27
  58. package/src/LogSelection.res.mjs +6 -0
  59. package/src/Logging.res +21 -7
  60. package/src/Logging.res.mjs +16 -8
  61. package/src/Main.res +390 -0
  62. package/src/Main.res.mjs +341 -0
  63. package/src/Persistence.res +7 -21
  64. package/src/Persistence.res.mjs +3 -3
  65. package/src/PgStorage.gen.ts +10 -0
  66. package/src/PgStorage.res +116 -69
  67. package/src/PgStorage.res.d.mts +5 -0
  68. package/src/PgStorage.res.mjs +93 -50
  69. package/src/Prometheus.res +294 -224
  70. package/src/Prometheus.res.mjs +353 -340
  71. package/src/ReorgDetection.res +6 -10
  72. package/src/ReorgDetection.res.mjs +6 -6
  73. package/src/SafeCheckpointTracking.res +4 -4
  74. package/src/SafeCheckpointTracking.res.mjs +2 -2
  75. package/src/SimulateItems.res +353 -0
  76. package/src/SimulateItems.res.mjs +335 -0
  77. package/src/Sink.res +4 -2
  78. package/src/Sink.res.mjs +2 -1
  79. package/src/TableIndices.res +0 -1
  80. package/src/TestIndexer.res +913 -0
  81. package/src/TestIndexer.res.mjs +698 -0
  82. package/src/TestIndexerProxyStorage.res +205 -0
  83. package/src/TestIndexerProxyStorage.res.mjs +151 -0
  84. package/src/TopicFilter.res +1 -1
  85. package/src/Types.ts +1 -1
  86. package/src/UserContext.res +424 -0
  87. package/src/UserContext.res.mjs +279 -0
  88. package/src/Utils.res +97 -26
  89. package/src/Utils.res.mjs +91 -44
  90. package/src/bindings/BigInt.res +10 -0
  91. package/src/bindings/BigInt.res.mjs +15 -0
  92. package/src/bindings/ClickHouse.res +120 -23
  93. package/src/bindings/ClickHouse.res.mjs +118 -28
  94. package/src/bindings/DateFns.res +74 -0
  95. package/src/bindings/DateFns.res.mjs +22 -0
  96. package/src/bindings/EventSource.res +11 -2
  97. package/src/bindings/EventSource.res.mjs +8 -1
  98. package/src/bindings/Express.res +1 -0
  99. package/src/bindings/Hrtime.res +14 -1
  100. package/src/bindings/Hrtime.res.mjs +22 -2
  101. package/src/bindings/Hrtime.resi +4 -0
  102. package/src/bindings/Lodash.res +0 -1
  103. package/src/bindings/NodeJs.res +49 -3
  104. package/src/bindings/NodeJs.res.mjs +11 -3
  105. package/src/bindings/Pino.res +24 -10
  106. package/src/bindings/Pino.res.mjs +14 -8
  107. package/src/bindings/Postgres.gen.ts +8 -0
  108. package/src/bindings/Postgres.res +5 -1
  109. package/src/bindings/Postgres.res.d.mts +5 -0
  110. package/src/bindings/PromClient.res +0 -10
  111. package/src/bindings/PromClient.res.mjs +0 -3
  112. package/src/bindings/Vitest.res +144 -0
  113. package/src/bindings/Vitest.res.mjs +9 -0
  114. package/src/bindings/WebSocket.res +27 -0
  115. package/src/bindings/WebSocket.res.mjs +2 -0
  116. package/src/bindings/Yargs.res +8 -0
  117. package/src/bindings/Yargs.res.mjs +2 -0
  118. package/src/db/EntityHistory.res +7 -7
  119. package/src/db/EntityHistory.res.mjs +9 -9
  120. package/src/db/InternalTable.res +59 -111
  121. package/src/db/InternalTable.res.mjs +73 -104
  122. package/src/db/Table.res +27 -8
  123. package/src/db/Table.res.mjs +25 -14
  124. package/src/sources/Evm.res +84 -0
  125. package/src/sources/Evm.res.mjs +105 -0
  126. package/src/sources/EvmChain.res +94 -0
  127. package/src/sources/EvmChain.res.mjs +60 -0
  128. package/src/sources/Fuel.res +19 -34
  129. package/src/sources/Fuel.res.mjs +34 -16
  130. package/src/sources/FuelSDK.res +38 -0
  131. package/src/sources/FuelSDK.res.mjs +29 -0
  132. package/src/sources/HyperFuel.res +2 -2
  133. package/src/sources/HyperFuel.resi +1 -1
  134. package/src/sources/HyperFuelClient.res +2 -2
  135. package/src/sources/HyperFuelSource.res +35 -13
  136. package/src/sources/HyperFuelSource.res.mjs +26 -16
  137. package/src/sources/HyperSync.res +61 -60
  138. package/src/sources/HyperSync.res.mjs +53 -67
  139. package/src/sources/HyperSync.resi +6 -4
  140. package/src/sources/HyperSyncClient.res +29 -2
  141. package/src/sources/HyperSyncClient.res.mjs +9 -0
  142. package/src/sources/HyperSyncHeightStream.res +76 -118
  143. package/src/sources/HyperSyncHeightStream.res.mjs +68 -75
  144. package/src/sources/HyperSyncSource.res +122 -143
  145. package/src/sources/HyperSyncSource.res.mjs +106 -121
  146. package/src/sources/Rpc.res +86 -14
  147. package/src/sources/Rpc.res.mjs +101 -9
  148. package/src/sources/RpcSource.res +731 -364
  149. package/src/sources/RpcSource.res.mjs +845 -410
  150. package/src/sources/RpcWebSocketHeightStream.res +181 -0
  151. package/src/sources/RpcWebSocketHeightStream.res.mjs +196 -0
  152. package/src/sources/SimulateSource.res +59 -0
  153. package/src/sources/SimulateSource.res.mjs +50 -0
  154. package/src/sources/Source.res +7 -5
  155. package/src/sources/SourceManager.res +358 -221
  156. package/src/sources/SourceManager.res.mjs +346 -171
  157. package/src/sources/SourceManager.resi +17 -6
  158. package/src/sources/Svm.res +81 -0
  159. package/src/sources/Svm.res.mjs +90 -0
  160. package/src/tui/Tui.res +247 -0
  161. package/src/tui/Tui.res.mjs +337 -0
  162. package/src/tui/bindings/Ink.res +371 -0
  163. package/src/tui/bindings/Ink.res.mjs +72 -0
  164. package/src/tui/bindings/Style.res +123 -0
  165. package/src/tui/bindings/Style.res.mjs +2 -0
  166. package/src/tui/components/BufferedProgressBar.res +40 -0
  167. package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
  168. package/src/tui/components/CustomHooks.res +122 -0
  169. package/src/tui/components/CustomHooks.res.mjs +179 -0
  170. package/src/tui/components/Messages.res +41 -0
  171. package/src/tui/components/Messages.res.mjs +75 -0
  172. package/src/tui/components/SyncETA.res +174 -0
  173. package/src/tui/components/SyncETA.res.mjs +263 -0
  174. package/src/tui/components/TuiData.res +47 -0
  175. package/src/tui/components/TuiData.res.mjs +34 -0
  176. package/svm.schema.json +112 -0
  177. package/bin.js +0 -48
  178. package/src/EventRegister.res +0 -241
  179. package/src/EventRegister.res.mjs +0 -240
  180. package/src/EventRegister.resi +0 -30
  181. package/src/bindings/Ethers.gen.ts +0 -14
  182. package/src/bindings/Ethers.res +0 -204
  183. package/src/bindings/Ethers.res.mjs +0 -130
  184. /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(prim) {
38
- return prim;
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 */
@@ -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
@@ -1,3 +1,2 @@
1
1
  // TODO: Remove this file once we have our own impl of cloneDeep or it is no longer needed
2
2
  @module("./vendored-lodash-fns.js") external cloneDeep: 'a => 'a = "cloneDeep"
3
-
@@ -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 __dirname = dirname(Url.fileURLToPath(ImportMeta.importMeta.url))
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 $$__dirname = Path.dirname(Url.fileURLToPath(import.meta.url));
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
- $$__dirname: $$__dirname
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
- /* __dirname Not a pure module */
56
+ /* url Not a pure module */
@@ -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(message)
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
- Utils.magic({
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
- prettyFactory({
141
- customLevels: logLevels,
142
- customColors: "fatal:bgRed,error:red,warn:yellow,info:green,udebug:bgBlue,uinfo:bgGreen,uwarn:bgYellow,uerror:bgRed,debug:blue,trace:gray",
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(prim) {
23
- return prim;
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(prim) {
31
- return prim;
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
- return PinoPretty.prettyFactory({
44
- customLevels: logLevels,
45
- customColors: "fatal:bgRed,error:red,warn:yellow,info:green,udebug:bgBlue,uinfo:bgGreen,uwarn:bgYellow,uerror:bgRed,debug:blue,trace:gray"
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) {
@@ -0,0 +1,8 @@
1
+ /* TypeScript file generated from Postgres.res by genType. */
2
+
3
+ /* eslint-disable */
4
+ /* tslint:disable */
5
+
6
+ import type {Sql as $$sql} from 'postgres';
7
+
8
+ export type sql = $$sql;
@@ -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
@@ -0,0 +1,5 @@
1
+ // This is to prevent tsc --noEmit from failing
2
+ // when importing code from .res.mjs files in genType .ts files
3
+ // After we upgrade GenType and it starts to include ts-ignore,
4
+ // the line can be removed.
5
+ export type sql = any;
@@ -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"
@@ -5,14 +5,11 @@ var Counter = {};
5
5
 
6
6
  var Gauge = {};
7
7
 
8
- var Histogram = {};
9
-
10
8
  var Summary = {};
11
9
 
12
10
  export {
13
11
  Counter ,
14
12
  Gauge ,
15
- Histogram ,
16
13
  Summary ,
17
14
  }
18
15
  /* No side effect */
@@ -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,9 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+
4
+ var Async = {};
5
+
6
+ export {
7
+ Async ,
8
+ }
9
+ /* No side effect */
@@ -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,2 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
@@ -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"
@@ -0,0 +1,2 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
@@ -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 = Uint32
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 string->Belt.Float.fromString {
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: float => float->Belt.Float.toString,
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: float) => {
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
  }