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
package/src/Utils.res CHANGED
@@ -1,6 +1,7 @@
1
1
  @@directive("import packageJson from '../package.json' with { type: 'json' }")
2
2
 
3
3
  external magic: 'a => 'b = "%identity"
4
+ @val external floatToInt: float => int = "Math.trunc"
4
5
 
5
6
  @val external importPath: string => promise<unknown> = "import"
6
7
 
@@ -32,6 +33,19 @@ module Object = {
32
33
 
33
34
  @val @scope("Object")
34
35
  external defineProperty: ('obj, string, propertyDescriptor<'a>) => 'obj = "defineProperty"
36
+
37
+ // Property descriptor with required value field (no boxing)
38
+ type enumerablePropertyDescriptor<'a> = {
39
+ enumerable: bool,
40
+ value: 'a,
41
+ }
42
+
43
+ @val @scope("Object")
44
+ external definePropertyWithValue: ('obj, string, enumerablePropertyDescriptor<'a>) => 'obj =
45
+ "defineProperty"
46
+
47
+ @val @scope("Object")
48
+ external createNullObject: (@as(json`null`) _, unit) => 'a = "create"
35
49
  }
36
50
 
37
51
  module Error = {
@@ -82,6 +96,17 @@ module Dict = {
82
96
  */
83
97
  external dangerouslyGetNonOption: (dict<'a>, string) => option<'a> = ""
84
98
 
99
+ let getOrInsertEmptyDict = (dict, key) => {
100
+ switch dict->dangerouslyGetNonOption(key) {
101
+ | Some(d) => d
102
+ | None => {
103
+ let d = Js.Dict.empty()
104
+ dict->Js.Dict.set(key, d)
105
+ d
106
+ }
107
+ }
108
+ }
109
+
85
110
  @get_index
86
111
  /**
87
112
  It's the same as `Js.Dict.get` but it doesn't have runtime overhead to check if the key exists.
@@ -175,6 +200,15 @@ module Dict = {
175
200
  }
176
201
  `)
177
202
 
203
+ let unsafeDeleteUndefinedFieldsInPlace: 'a => unit = %raw(`(dict) => {
204
+ for (var key in dict) {
205
+ if (dict[key] === undefined) {
206
+ delete dict[key];
207
+ }
208
+ }
209
+ }
210
+ `)
211
+
178
212
  let updateImmutable: (
179
213
  dict<'a>,
180
214
  string,
@@ -194,7 +228,7 @@ module Dict = {
194
228
  module Math = {
195
229
  let minOptInt = (a, b) =>
196
230
  switch (a, b) {
197
- | (Some(a), Some(b)) => Pervasives.min(a, b)->Some
231
+ | (Some(a), Some(b)) => Some(a < b ? a : b)
198
232
  | (Some(a), None) => Some(a)
199
233
  | (None, Some(b)) => Some(b)
200
234
  | (None, None) => None
@@ -325,8 +359,10 @@ Helper to check if a value exists in an array
325
359
  }
326
360
 
327
361
  let last = (arr: array<'a>): option<'a> => arr->Belt.Array.get(arr->Array.length - 1)
362
+ let first = (arr: array<'a>): option<'a> => arr->Belt.Array.get(0)
328
363
 
329
364
  let lastUnsafe = (arr: array<'a>): 'a => arr->Belt.Array.getUnsafe(arr->Array.length - 1)
365
+ let firstUnsafe = (arr: array<'a>): 'a => arr->Js.Array2.unsafe_get(0)
330
366
 
331
367
  let findReverseWithIndex = (arr: array<'a>, fn: 'a => bool): option<('a, int)> => {
332
368
  let rec loop = (index: int) => {
@@ -413,6 +449,28 @@ String.replaceAll("the cat and the dog", "the", "this") == "this cat and this do
413
449
  external replaceAll: (string, string, string) => string = "replaceAll"
414
450
  }
415
451
 
452
+ module Url = {
453
+ /**
454
+ Extracts the hostname from a URL string.
455
+ Returns None if the URL doesn't have a valid http:// or https:// protocol.
456
+ */
457
+ let getHostFromUrl = (url: string) => {
458
+ // Regular expression requiring protocol and capturing hostname
459
+ // - (https?:\/\/) : Required http:// or https:// (capturing group)
460
+ // - ([^\/?]+) : Capture hostname (one or more characters that aren't / or ?)
461
+ // - .* : Match rest of the string
462
+ let regex = %re("/https?:\/\/([^\/?]+).*/")
463
+ switch Js.Re.exec_(regex, url) {
464
+ | Some(result) =>
465
+ switch Js.Re.captures(result)->Belt.Array.get(1) {
466
+ | Some(host) => host->Js.Nullable.toOption
467
+ | None => None
468
+ }
469
+ | None => None
470
+ }
471
+ }
472
+ }
473
+
416
474
  module Result = {
417
475
  let forEach = (result, fn) => {
418
476
  switch result {
@@ -440,31 +498,6 @@ external queueMicrotask: (unit => unit) => unit = "queueMicrotask"
440
498
  module Schema = {
441
499
  let variantTag = S.union([S.string, S.object(s => s.field("TAG", S.string))])
442
500
 
443
- let getNonOptionalFieldNames = schema => {
444
- let acc = []
445
- switch schema->S.classify {
446
- | Object({items}) =>
447
- items->Js.Array2.forEach(item => {
448
- switch item.schema->S.classify {
449
- // Check for null, since we generate S.null schema for db serializing
450
- // In the future it should be changed to Option only
451
- | Null(_) => ()
452
- | Option(_) => ()
453
- | _ => acc->Js.Array2.push(item.location)->ignore
454
- }
455
- })
456
- | _ => ()
457
- }
458
- acc
459
- }
460
-
461
- let getCapitalizedFieldNames = schema => {
462
- switch schema->S.classify {
463
- | Object({items}) => items->Js.Array2.map(item => item.location->String.capitalize)
464
- | _ => []
465
- }
466
- }
467
-
468
501
  // Don't use S.unknown, since it's not serializable to json
469
502
  // In a nutshell, this is completely unsafe.
470
503
  let dbDate =
@@ -472,6 +505,12 @@ module Schema = {
472
505
  ->(magic: S.t<Js.Json.t> => S.t<Js.Date.t>)
473
506
  ->S.preprocess(_ => {serializer: date => date->magic->Js.Date.toISOString})
474
507
 
508
+ // ClickHouse expects timestamps as numbers (milliseconds), not ISO strings
509
+ let clickHouseDate =
510
+ S.json(~validate=false)
511
+ ->(magic: S.t<Js.Json.t> => S.t<Js.Date.t>)
512
+ ->S.preprocess(_ => {serializer: date => date->magic->Js.Date.getTime})
513
+
475
514
  // When trying to serialize data to Json pg type, it will fail with
476
515
  // PostgresError: column "params" is of type json but expression is of type boolean
477
516
  // If there's bool or null on the root level. It works fine as object field values.
@@ -545,6 +584,13 @@ module Set = {
545
584
 
546
585
  external toArray: t<'a> => array<'a> = "Array.from"
547
586
 
587
+ @send
588
+ external intersection: (t<'value>, t<'value>) => t<'value> = "intersection"
589
+
590
+ let immutableAdd: (t<'a>, 'a) => t<'a> = %raw(`(set, value) => {
591
+ return new Set([...set, value])
592
+ }`)
593
+
548
594
  /*
549
595
  * Iteration methods
550
596
  */
@@ -578,6 +624,18 @@ external entries: t<'value> => Js_iterator.t<('value, 'value)> = "entries"
578
624
  external forEachWithSet: (t<'value>, ('value, 'value, t<'value>) => unit) => unit = "forEach"
579
625
  }
580
626
 
627
+ // Typed-key dictionary backed by Js.Dict. Keys must be @unboxed string variants.
628
+ module Record = {
629
+ type t<'key, 'value>
630
+
631
+ external fromDict: Js.Dict.t<'value> => t<'key, 'value> = "%identity"
632
+ let fromArray: array<('key, 'value)> => t<'key, 'value> = pairs =>
633
+ pairs->(magic: array<('key, 'value)> => array<(string, 'value)>)->Js.Dict.fromArray->fromDict
634
+
635
+ @get_index external getUnsafe: (t<'key, 'value>, 'key) => 'value = ""
636
+ @get_index external get: (t<'key, 'value>, 'key) => option<'value> = ""
637
+ }
638
+
581
639
  module WeakMap = {
582
640
  type t<'k, 'v> = Js.WeakMap.t<'k, 'v>
583
641
 
@@ -587,6 +645,19 @@ module WeakMap = {
587
645
  @send external unsafeGet: (t<'k, 'v>, 'k) => 'v = "get"
588
646
  @send external has: (t<'k, 'v>, 'k) => bool = "has"
589
647
  @send external set: (t<'k, 'v>, 'k, 'v) => t<'k, 'v> = "set"
648
+
649
+ let memoize = (fn: 'k => 'v): ('k => 'v) => {
650
+ let cache = make()
651
+ key =>
652
+ switch cache->get(key) {
653
+ | Some(v) => v
654
+ | None => {
655
+ let v = fn(key)
656
+ let _ = cache->set(key, v)
657
+ v
658
+ }
659
+ }
660
+ }
590
661
  }
591
662
 
592
663
  module Map = {
package/src/Utils.res.mjs CHANGED
@@ -3,6 +3,7 @@ import packageJson from '../package.json' with { type: 'json' }
3
3
 
4
4
  import * as $$Array from "rescript/lib/es6/array.js";
5
5
  import * as Js_exn from "rescript/lib/es6/js_exn.js";
6
+ import * as Js_dict from "rescript/lib/es6/js_dict.js";
6
7
  import * as Caml_obj from "rescript/lib/es6/caml_obj.js";
7
8
  import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
8
9
  import * as Caml_array from "rescript/lib/es6/caml_array.js";
@@ -71,6 +72,16 @@ var Tuple = {
71
72
  get: get
72
73
  };
73
74
 
75
+ function getOrInsertEmptyDict(dict, key) {
76
+ var d = dict[key];
77
+ if (d !== undefined) {
78
+ return d;
79
+ }
80
+ var d$1 = {};
81
+ dict[key] = d$1;
82
+ return d$1;
83
+ }
84
+
74
85
  var has = ((dict, key) => key in dict);
75
86
 
76
87
  function push(dict, key, value) {
@@ -151,6 +162,14 @@ var deleteInPlace = ((dict, key) => {
151
162
  delete dict[key];
152
163
  });
153
164
 
165
+ var unsafeDeleteUndefinedFieldsInPlace = ((dict) => {
166
+ for (var key in dict) {
167
+ if (dict[key] === undefined) {
168
+ delete dict[key];
169
+ }
170
+ }
171
+ });
172
+
154
173
  var updateImmutable = ((dict, key, value) => ({...dict, [key]: value}));
155
174
 
156
175
  var shallowCopy = ((dict) => ({...dict}));
@@ -160,6 +179,7 @@ var incrementByInt = ((dict, key) => {
160
179
  });
161
180
 
162
181
  var Dict = {
182
+ getOrInsertEmptyDict: getOrInsertEmptyDict,
163
183
  has: has,
164
184
  push: push,
165
185
  pushMany: pushMany,
@@ -172,6 +192,7 @@ var Dict = {
172
192
  size: size,
173
193
  isEmpty: isEmpty,
174
194
  deleteInPlace: deleteInPlace,
195
+ unsafeDeleteUndefinedFieldsInPlace: unsafeDeleteUndefinedFieldsInPlace,
175
196
  updateImmutable: updateImmutable,
176
197
  shallowCopy: shallowCopy,
177
198
  incrementByInt: incrementByInt
@@ -186,11 +207,11 @@ function minOptInt(a, b) {
186
207
  }
187
208
  }
188
209
  var a$1 = Caml_option.valFromOption(a);
189
- if (b !== undefined) {
190
- return Caml_option.some(Caml_obj.min(a$1, Caml_option.valFromOption(b)));
191
- } else {
210
+ if (b === undefined) {
192
211
  return Caml_option.some(a$1);
193
212
  }
213
+ var b$1 = Caml_option.valFromOption(b);
214
+ return Caml_option.some(Caml_obj.lessthan(a$1, b$1) ? a$1 : b$1);
194
215
  }
195
216
 
196
217
  var $$Math = {
@@ -310,10 +331,18 @@ function last(arr) {
310
331
  return Belt_Array.get(arr, arr.length - 1 | 0);
311
332
  }
312
333
 
334
+ function first(arr) {
335
+ return Belt_Array.get(arr, 0);
336
+ }
337
+
313
338
  function lastUnsafe(arr) {
314
339
  return arr[arr.length - 1 | 0];
315
340
  }
316
341
 
342
+ function firstUnsafe(arr) {
343
+ return arr[0];
344
+ }
345
+
317
346
  function findReverseWithIndex(arr, fn) {
318
347
  var _index = arr.length - 1 | 0;
319
348
  while(true) {
@@ -366,7 +395,9 @@ var $$Array$1 = {
366
395
  awaitEach: awaitEach,
367
396
  removeAtIndex: removeAtIndex,
368
397
  last: last,
398
+ first: first,
369
399
  lastUnsafe: lastUnsafe,
400
+ firstUnsafe: firstUnsafe,
370
401
  findReverseWithIndex: findReverseWithIndex,
371
402
  interleave: interleave,
372
403
  fromAsyncIterator: fromAsyncIterator
@@ -380,6 +411,23 @@ var $$String = {
380
411
  capitalize: capitalize
381
412
  };
382
413
 
414
+ function getHostFromUrl(url) {
415
+ var regex = /https?:\/\/([^\/?]+).*/;
416
+ var result = regex.exec(url);
417
+ if (result === null) {
418
+ return ;
419
+ }
420
+ var host = Belt_Array.get(result, 1);
421
+ if (host !== undefined) {
422
+ return Caml_option.nullable_to_opt(Caml_option.valFromOption(host));
423
+ }
424
+
425
+ }
426
+
427
+ var Url = {
428
+ getHostFromUrl: getHostFromUrl
429
+ };
430
+
383
431
  function forEach$1(result, fn) {
384
432
  if (result.TAG === "Ok") {
385
433
  fn(result._0);
@@ -405,42 +453,6 @@ var variantTag = S$RescriptSchema.union([
405
453
  })
406
454
  ]);
407
455
 
408
- function getNonOptionalFieldNames(schema) {
409
- var acc = [];
410
- var match = schema.t;
411
- if (typeof match === "object" && match.TAG === "object") {
412
- match.items.forEach(function (item) {
413
- var match = item.schema.t;
414
- if (typeof match !== "object") {
415
- acc.push(item.location);
416
- return ;
417
- }
418
- switch (match.TAG) {
419
- case "option" :
420
- case "null" :
421
- return ;
422
- default:
423
- acc.push(item.location);
424
- return ;
425
- }
426
- });
427
- }
428
- return acc;
429
- }
430
-
431
- function getCapitalizedFieldNames(schema) {
432
- var match = schema.t;
433
- if (typeof match !== "object") {
434
- return [];
435
- } else if (match.TAG === "object") {
436
- return match.items.map(function (item) {
437
- return capitalize(item.location);
438
- });
439
- } else {
440
- return [];
441
- }
442
- }
443
-
444
456
  var dbDate = S$RescriptSchema.preprocess(S$RescriptSchema.json(false), (function (param) {
445
457
  return {
446
458
  s: (function (date) {
@@ -449,6 +461,14 @@ var dbDate = S$RescriptSchema.preprocess(S$RescriptSchema.json(false), (function
449
461
  };
450
462
  }));
451
463
 
464
+ var clickHouseDate = S$RescriptSchema.preprocess(S$RescriptSchema.json(false), (function (param) {
465
+ return {
466
+ s: (function (date) {
467
+ return date.getTime();
468
+ })
469
+ };
470
+ }));
471
+
452
472
  function coerceToJsonPgType(schema) {
453
473
  return S$RescriptSchema.preprocess(schema, (function (s) {
454
474
  var match = s.schema.t;
@@ -482,9 +502,8 @@ function coerceToJsonPgType(schema) {
482
502
 
483
503
  var Schema = {
484
504
  variantTag: variantTag,
485
- getNonOptionalFieldNames: getNonOptionalFieldNames,
486
- getCapitalizedFieldNames: getCapitalizedFieldNames,
487
505
  dbDate: dbDate,
506
+ clickHouseDate: clickHouseDate,
488
507
  coerceToJsonPgType: coerceToJsonPgType
489
508
  };
490
509
 
@@ -500,11 +519,37 @@ function addMany(set, values) {
500
519
  });
501
520
  }
502
521
 
522
+ var immutableAdd = ((set, value) => {
523
+ return new Set([...set, value])
524
+ });
525
+
503
526
  var $$Set = {
504
- addMany: addMany
527
+ addMany: addMany,
528
+ immutableAdd: immutableAdd
529
+ };
530
+
531
+ var fromArray = Js_dict.fromArray;
532
+
533
+ var Record = {
534
+ fromArray: fromArray
505
535
  };
506
536
 
507
- var $$WeakMap = {};
537
+ function memoize(fn) {
538
+ var cache = new WeakMap();
539
+ return function (key) {
540
+ var v = cache.get(key);
541
+ if (v !== undefined) {
542
+ return Caml_option.valFromOption(v);
543
+ }
544
+ var v$1 = fn(key);
545
+ cache.set(key, v$1);
546
+ return v$1;
547
+ };
548
+ }
549
+
550
+ var $$WeakMap$1 = {
551
+ memoize: memoize
552
+ };
508
553
 
509
554
  var $$Map = {};
510
555
 
@@ -625,12 +670,14 @@ export {
625
670
  UnsafeIntOperators ,
626
671
  $$Array$1 as $$Array,
627
672
  $$String ,
673
+ Url ,
628
674
  Result ,
629
675
  unwrapResultExn ,
630
676
  Schema ,
631
677
  getVariantsTags ,
632
678
  $$Set ,
633
- $$WeakMap ,
679
+ Record ,
680
+ $$WeakMap$1 as $$WeakMap,
634
681
  $$Map ,
635
682
  $$Proxy ,
636
683
  Hash ,
@@ -42,7 +42,17 @@ module Bitwise = {
42
42
  let logand = (a: bigint, b: bigint): bigint => %raw("a & b")
43
43
  }
44
44
 
45
+ let arrayToStringArray: array<bigint> => array<string> = %raw(`(arr) => {
46
+ const res = new Array(arr.length);
47
+ for (let i = 0; i < arr.length; i++) {
48
+ res[i] = arr[i].toString();
49
+ }
50
+ return res;
51
+ }`)
52
+
45
53
  let zero = fromInt(0)
54
+ let toFloat: bigint => float = %raw(`(n) => Number(n)`)
55
+ let toIntUnsafe: bigint => int = %raw(`(n) => Number(n)`)
46
56
 
47
57
  @genType
48
58
  let schema =
@@ -96,8 +96,20 @@ var Bitwise = {
96
96
  logand: logand
97
97
  };
98
98
 
99
+ var arrayToStringArray = ((arr) => {
100
+ const res = new Array(arr.length);
101
+ for (let i = 0; i < arr.length; i++) {
102
+ res[i] = arr[i].toString();
103
+ }
104
+ return res;
105
+ });
106
+
99
107
  var zero = BigInt(0);
100
108
 
109
+ var toFloat = ((n) => Number(n));
110
+
111
+ var toIntUnsafe = ((n) => Number(n));
112
+
101
113
  var schema = S$RescriptSchema.transform(S$RescriptSchema.setName(S$RescriptSchema.string, "BigInt"), (function (s) {
102
114
  return {
103
115
  p: (function (string) {
@@ -132,7 +144,10 @@ export {
132
144
  lt ,
133
145
  lte ,
134
146
  Bitwise ,
147
+ arrayToStringArray ,
135
148
  zero ,
149
+ toFloat ,
150
+ toIntUnsafe ,
136
151
  schema ,
137
152
  nativeSchema ,
138
153
  }