envio 3.0.0-alpha.21 → 3.0.0-alpha.23

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 (220) hide show
  1. package/README.md +3 -3
  2. package/bin.mjs +2 -48
  3. package/evm.schema.json +67 -0
  4. package/fuel.schema.json +67 -0
  5. package/index.d.ts +822 -38
  6. package/index.js +5 -3
  7. package/package.json +10 -8
  8. package/rescript.json +5 -9
  9. package/src/Address.res +4 -5
  10. package/src/Address.res.mjs +9 -12
  11. package/src/Api.res +15 -0
  12. package/src/Api.res.mjs +20 -0
  13. package/src/Batch.res +32 -34
  14. package/src/Batch.res.mjs +172 -187
  15. package/src/Bin.res +89 -0
  16. package/src/Bin.res.mjs +97 -0
  17. package/src/ChainFetcher.res +33 -57
  18. package/src/ChainFetcher.res.mjs +197 -227
  19. package/src/ChainManager.res +6 -14
  20. package/src/ChainManager.res.mjs +74 -85
  21. package/src/ChainMap.res +14 -16
  22. package/src/ChainMap.res.mjs +38 -38
  23. package/src/Config.res +193 -135
  24. package/src/Config.res.mjs +566 -592
  25. package/src/Core.res +182 -0
  26. package/src/Core.res.mjs +207 -0
  27. package/src/Ecosystem.res +25 -4
  28. package/src/Ecosystem.res.mjs +12 -13
  29. package/src/Env.res +20 -13
  30. package/src/Env.res.mjs +124 -113
  31. package/src/EnvSafe.res +269 -0
  32. package/src/EnvSafe.res.mjs +296 -0
  33. package/src/EnvSafe.resi +18 -0
  34. package/src/Envio.res +37 -26
  35. package/src/Envio.res.mjs +59 -60
  36. package/src/ErrorHandling.res +2 -2
  37. package/src/ErrorHandling.res.mjs +15 -15
  38. package/src/EventConfigBuilder.res +219 -81
  39. package/src/EventConfigBuilder.res.mjs +259 -202
  40. package/src/EventProcessing.res +27 -38
  41. package/src/EventProcessing.res.mjs +165 -183
  42. package/src/EventUtils.res +11 -11
  43. package/src/EventUtils.res.mjs +21 -22
  44. package/src/EvmTypes.res +0 -1
  45. package/src/EvmTypes.res.mjs +5 -5
  46. package/src/FetchState.res +360 -256
  47. package/src/FetchState.res.mjs +958 -914
  48. package/src/GlobalState.res +365 -351
  49. package/src/GlobalState.res.mjs +958 -992
  50. package/src/GlobalStateManager.res +1 -2
  51. package/src/GlobalStateManager.res.mjs +36 -44
  52. package/src/HandlerLoader.res +107 -23
  53. package/src/HandlerLoader.res.mjs +128 -38
  54. package/src/HandlerRegister.res +127 -103
  55. package/src/HandlerRegister.res.mjs +164 -164
  56. package/src/HandlerRegister.resi +12 -4
  57. package/src/Hasura.res +35 -22
  58. package/src/Hasura.res.mjs +158 -167
  59. package/src/InMemoryStore.res +20 -27
  60. package/src/InMemoryStore.res.mjs +64 -80
  61. package/src/InMemoryTable.res +34 -39
  62. package/src/InMemoryTable.res.mjs +165 -170
  63. package/src/Internal.res +52 -33
  64. package/src/Internal.res.mjs +84 -81
  65. package/src/LazyLoader.res.mjs +55 -61
  66. package/src/LoadLayer.res +77 -78
  67. package/src/LoadLayer.res.mjs +160 -189
  68. package/src/LoadManager.res +16 -21
  69. package/src/LoadManager.res.mjs +79 -84
  70. package/src/LogSelection.res +236 -68
  71. package/src/LogSelection.res.mjs +211 -141
  72. package/src/Logging.res +13 -9
  73. package/src/Logging.res.mjs +130 -143
  74. package/src/Main.res +430 -51
  75. package/src/Main.res.mjs +530 -271
  76. package/src/Persistence.res +80 -84
  77. package/src/Persistence.res.mjs +131 -132
  78. package/src/PgStorage.res +294 -167
  79. package/src/PgStorage.res.mjs +799 -817
  80. package/src/Prometheus.res +50 -58
  81. package/src/Prometheus.res.mjs +345 -373
  82. package/src/ReorgDetection.res +22 -24
  83. package/src/ReorgDetection.res.mjs +100 -106
  84. package/src/SafeCheckpointTracking.res +7 -7
  85. package/src/SafeCheckpointTracking.res.mjs +40 -43
  86. package/src/SimulateItems.res +41 -49
  87. package/src/SimulateItems.res.mjs +257 -272
  88. package/src/Sink.res +2 -2
  89. package/src/Sink.res.mjs +22 -26
  90. package/src/TableIndices.res +1 -2
  91. package/src/TableIndices.res.mjs +42 -48
  92. package/src/TestIndexer.res +196 -189
  93. package/src/TestIndexer.res.mjs +536 -536
  94. package/src/TestIndexerProxyStorage.res +16 -16
  95. package/src/TestIndexerProxyStorage.res.mjs +99 -122
  96. package/src/TestIndexerWorker.res +4 -0
  97. package/src/TestIndexerWorker.res.mjs +7 -0
  98. package/src/Throttler.res +3 -3
  99. package/src/Throttler.res.mjs +23 -24
  100. package/src/Time.res +1 -1
  101. package/src/Time.res.mjs +18 -21
  102. package/src/TopicFilter.res +3 -3
  103. package/src/TopicFilter.res.mjs +29 -30
  104. package/src/UserContext.res +93 -54
  105. package/src/UserContext.res.mjs +197 -182
  106. package/src/Utils.res +141 -86
  107. package/src/Utils.res.mjs +334 -295
  108. package/src/bindings/BigDecimal.res +0 -2
  109. package/src/bindings/BigDecimal.res.mjs +19 -23
  110. package/src/bindings/ClickHouse.res +28 -27
  111. package/src/bindings/ClickHouse.res.mjs +243 -240
  112. package/src/bindings/DateFns.res +11 -11
  113. package/src/bindings/DateFns.res.mjs +7 -7
  114. package/src/bindings/EventSource.res.mjs +2 -2
  115. package/src/bindings/Express.res +2 -5
  116. package/src/bindings/Hrtime.res +2 -2
  117. package/src/bindings/Hrtime.res.mjs +30 -32
  118. package/src/bindings/Lodash.res.mjs +1 -1
  119. package/src/bindings/NodeJs.res +14 -9
  120. package/src/bindings/NodeJs.res.mjs +20 -20
  121. package/src/bindings/Pino.res +8 -10
  122. package/src/bindings/Pino.res.mjs +40 -43
  123. package/src/bindings/Postgres.res +7 -5
  124. package/src/bindings/Postgres.res.mjs +9 -9
  125. package/src/bindings/PromClient.res +17 -2
  126. package/src/bindings/PromClient.res.mjs +30 -7
  127. package/src/bindings/SDSL.res.mjs +2 -2
  128. package/src/bindings/Viem.res +4 -4
  129. package/src/bindings/Viem.res.mjs +20 -22
  130. package/src/bindings/Vitest.res +1 -1
  131. package/src/bindings/Vitest.res.mjs +2 -2
  132. package/src/bindings/WebSocket.res +1 -1
  133. package/src/db/EntityHistory.res +9 -3
  134. package/src/db/EntityHistory.res.mjs +84 -59
  135. package/src/db/InternalTable.res +62 -60
  136. package/src/db/InternalTable.res.mjs +271 -203
  137. package/src/db/Schema.res +1 -2
  138. package/src/db/Schema.res.mjs +28 -32
  139. package/src/db/Table.res +28 -27
  140. package/src/db/Table.res.mjs +276 -292
  141. package/src/sources/EventRouter.res +21 -16
  142. package/src/sources/EventRouter.res.mjs +55 -57
  143. package/src/sources/Evm.res +17 -1
  144. package/src/sources/Evm.res.mjs +16 -8
  145. package/src/sources/EvmChain.res +15 -17
  146. package/src/sources/EvmChain.res.mjs +40 -42
  147. package/src/sources/Fuel.res +14 -1
  148. package/src/sources/Fuel.res.mjs +16 -8
  149. package/src/sources/FuelSDK.res +1 -1
  150. package/src/sources/FuelSDK.res.mjs +6 -8
  151. package/src/sources/HyperFuel.res +8 -10
  152. package/src/sources/HyperFuel.res.mjs +113 -123
  153. package/src/sources/HyperFuelClient.res.mjs +6 -7
  154. package/src/sources/HyperFuelSource.res +19 -20
  155. package/src/sources/HyperFuelSource.res.mjs +339 -356
  156. package/src/sources/HyperSync.res +11 -13
  157. package/src/sources/HyperSync.res.mjs +206 -220
  158. package/src/sources/HyperSyncClient.res +5 -7
  159. package/src/sources/HyperSyncClient.res.mjs +70 -75
  160. package/src/sources/HyperSyncHeightStream.res +8 -9
  161. package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
  162. package/src/sources/HyperSyncJsonApi.res +18 -15
  163. package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
  164. package/src/sources/HyperSyncSource.res +17 -21
  165. package/src/sources/HyperSyncSource.res.mjs +268 -290
  166. package/src/sources/Rpc.res +5 -5
  167. package/src/sources/Rpc.res.mjs +168 -192
  168. package/src/sources/RpcSource.res +166 -167
  169. package/src/sources/RpcSource.res.mjs +972 -1046
  170. package/src/sources/RpcWebSocketHeightStream.res +10 -11
  171. package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
  172. package/src/sources/SimulateSource.res +1 -1
  173. package/src/sources/SimulateSource.res.mjs +35 -38
  174. package/src/sources/Source.res +1 -1
  175. package/src/sources/Source.res.mjs +3 -3
  176. package/src/sources/SourceManager.res +39 -20
  177. package/src/sources/SourceManager.res.mjs +340 -371
  178. package/src/sources/SourceManager.resi +2 -1
  179. package/src/sources/Svm.res +12 -5
  180. package/src/sources/Svm.res.mjs +44 -41
  181. package/src/tui/Tui.res +23 -12
  182. package/src/tui/Tui.res.mjs +292 -290
  183. package/src/tui/bindings/Ink.res +2 -4
  184. package/src/tui/bindings/Ink.res.mjs +35 -41
  185. package/src/tui/components/BufferedProgressBar.res +7 -7
  186. package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
  187. package/src/tui/components/CustomHooks.res +1 -2
  188. package/src/tui/components/CustomHooks.res.mjs +102 -122
  189. package/src/tui/components/Messages.res +1 -2
  190. package/src/tui/components/Messages.res.mjs +38 -42
  191. package/src/tui/components/SyncETA.res +10 -11
  192. package/src/tui/components/SyncETA.res.mjs +178 -196
  193. package/src/tui/components/TuiData.res +1 -1
  194. package/src/tui/components/TuiData.res.mjs +7 -6
  195. package/src/vendored/Rest.res +52 -66
  196. package/src/vendored/Rest.res.mjs +324 -364
  197. package/svm.schema.json +67 -0
  198. package/src/Address.gen.ts +0 -8
  199. package/src/Config.gen.ts +0 -19
  200. package/src/Envio.gen.ts +0 -55
  201. package/src/EvmTypes.gen.ts +0 -6
  202. package/src/InMemoryStore.gen.ts +0 -6
  203. package/src/Internal.gen.ts +0 -64
  204. package/src/PgStorage.gen.ts +0 -10
  205. package/src/PgStorage.res.d.mts +0 -5
  206. package/src/Types.ts +0 -56
  207. package/src/bindings/BigDecimal.gen.ts +0 -14
  208. package/src/bindings/BigDecimal.res.d.mts +0 -5
  209. package/src/bindings/BigInt.gen.ts +0 -10
  210. package/src/bindings/BigInt.res +0 -70
  211. package/src/bindings/BigInt.res.d.mts +0 -5
  212. package/src/bindings/BigInt.res.mjs +0 -154
  213. package/src/bindings/Ethers.res.d.mts +0 -5
  214. package/src/bindings/Pino.gen.ts +0 -17
  215. package/src/bindings/Postgres.gen.ts +0 -8
  216. package/src/bindings/Postgres.res.d.mts +0 -5
  217. package/src/bindings/Promise.res +0 -67
  218. package/src/bindings/Promise.res.mjs +0 -26
  219. package/src/db/InternalTable.gen.ts +0 -36
  220. package/src/sources/HyperSyncClient.gen.ts +0 -19
package/svm.schema.json CHANGED
@@ -45,6 +45,17 @@
45
45
  "format": "uint64",
46
46
  "minimum": 0
47
47
  },
48
+ "storage": {
49
+ "description": "Configuration for the storage backends the indexer writes to. Defaults to `postgres: true` when omitted. ClickHouse requires Postgres to be enabled (it is not supported as a single storage yet), and at least one backend must be enabled.",
50
+ "anyOf": [
51
+ {
52
+ "$ref": "#/$defs/StorageConfig"
53
+ },
54
+ {
55
+ "type": "null"
56
+ }
57
+ ]
58
+ },
48
59
  "ecosystem": {
49
60
  "description": "Ecosystem of the project.",
50
61
  "$ref": "#/$defs/EcosystemTag"
@@ -64,6 +75,62 @@
64
75
  "chains"
65
76
  ],
66
77
  "$defs": {
78
+ "StorageConfig": {
79
+ "type": "object",
80
+ "properties": {
81
+ "postgres": {
82
+ "description": "Whether to use Postgres as a storage backend (default: true).",
83
+ "type": [
84
+ "boolean",
85
+ "null"
86
+ ]
87
+ },
88
+ "clickhouse": {
89
+ "description": "Whether to additionally sync the indexed data to ClickHouse. Requires Postgres to be enabled (default: false).",
90
+ "type": [
91
+ "boolean",
92
+ "null"
93
+ ]
94
+ }
95
+ },
96
+ "additionalProperties": false,
97
+ "allOf": [
98
+ {
99
+ "not": {
100
+ "properties": {
101
+ "postgres": {
102
+ "const": false
103
+ }
104
+ },
105
+ "required": [
106
+ "postgres"
107
+ ]
108
+ }
109
+ },
110
+ {
111
+ "if": {
112
+ "properties": {
113
+ "clickhouse": {
114
+ "const": true
115
+ }
116
+ },
117
+ "required": [
118
+ "clickhouse"
119
+ ]
120
+ },
121
+ "then": {
122
+ "properties": {
123
+ "postgres": {
124
+ "const": true
125
+ }
126
+ },
127
+ "required": [
128
+ "postgres"
129
+ ]
130
+ }
131
+ }
132
+ ]
133
+ },
67
134
  "EcosystemTag": {
68
135
  "type": "string",
69
136
  "enum": [
@@ -1,8 +0,0 @@
1
- /* TypeScript file generated from Address.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- import type {Address as $$t} from './Types.ts';
7
-
8
- export type t = $$t;
package/src/Config.gen.ts DELETED
@@ -1,19 +0,0 @@
1
- /* TypeScript file generated from Config.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- import type {t as Address_t} from './Address.gen.js';
7
-
8
- export type DynamicContractRegistry_t = {
9
- readonly id: string;
10
- readonly chain_id: number;
11
- readonly registering_event_block_number: number;
12
- readonly registering_event_log_index: number;
13
- readonly registering_event_block_timestamp: number;
14
- readonly registering_event_contract_name: string;
15
- readonly registering_event_name: string;
16
- readonly registering_event_src_address: Address_t;
17
- readonly contract_address: Address_t;
18
- readonly contract_name: string
19
- };
package/src/Envio.gen.ts DELETED
@@ -1,55 +0,0 @@
1
- /* TypeScript file generated from Envio.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- import type {EffectContext as $$effectContext} from './Types.ts';
7
-
8
- import type {Effect as $$effect} from './Types.ts';
9
-
10
- import type {Logger as $$logger} from './Types.ts';
11
-
12
- import type {S_t as RescriptSchema_S_t} from 'rescript-schema/RescriptSchema.gen.js';
13
-
14
- export type blockEvent = { readonly number: number };
15
-
16
- export type fuelBlockEvent = { readonly height: number };
17
-
18
- export type svmOnBlockArgs<context> = { readonly slot: number; readonly context: context };
19
-
20
- export type onBlockArgs<block,context> = { readonly block: block; readonly context: context };
21
-
22
- export type onBlockOptions<chain> = {
23
- readonly name: string;
24
- readonly chain: chain;
25
- readonly interval?: number;
26
- readonly startBlock?: number;
27
- readonly endBlock?: number
28
- };
29
-
30
- export type logger = $$logger;
31
-
32
- export type effect<input,output> = $$effect<input,output>;
33
-
34
- export type rateLimitDuration = "second" | "minute" | number;
35
-
36
- export type rateLimit =
37
- false
38
- | { readonly calls: number; readonly per: rateLimitDuration };
39
-
40
- export type effectOptions<input,output> = {
41
- /** The name of the effect. Used for logging and debugging. */
42
- readonly name: string;
43
- /** The input schema of the effect. */
44
- readonly input: RescriptSchema_S_t<input>;
45
- /** The output schema of the effect. */
46
- readonly output: RescriptSchema_S_t<output>;
47
- /** Rate limit for the effect. Set to false to disable or provide {calls: number, per: "second" | "minute"} to enable. */
48
- readonly rateLimit: rateLimit;
49
- /** Whether the effect should be cached. */
50
- readonly cache?: boolean
51
- };
52
-
53
- export type effectContext = $$effectContext;
54
-
55
- export type effectArgs<input> = { readonly input: input; readonly context: effectContext };
@@ -1,6 +0,0 @@
1
- /* TypeScript file generated from EvmTypes.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- export abstract class Abi_t { protected opaque!: any }; /* simulate opaque types */
@@ -1,6 +0,0 @@
1
- /* TypeScript file generated from InMemoryStore.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- export type rawEventsKey = { readonly chainId: number; readonly eventId: string };
@@ -1,64 +0,0 @@
1
- /* TypeScript file generated from Internal.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- import type {GenericContractRegister as $$genericContractRegister} from './Types.ts';
7
-
8
- import type {Invalid as $$noEventFilters} from './Types.ts';
9
-
10
- import type {t as Address_t} from './Address.gen.js';
11
-
12
- export type genericEvent<params,block,transaction> = {
13
- readonly contractName: string;
14
- readonly eventName: string;
15
- readonly params: params;
16
- readonly chainId: number;
17
- readonly srcAddress: Address_t;
18
- readonly logIndex: number;
19
- readonly transaction: transaction;
20
- readonly block: block
21
- };
22
-
23
- export type genericLoaderArgs<event,context> = { readonly event: event; readonly context: context };
24
-
25
- export type genericLoader<args,loaderReturn> = (_1:args) => Promise<loaderReturn>;
26
-
27
- export type genericContractRegisterArgs<event,context> = { readonly event: event; readonly context: context };
28
-
29
- export type genericContractRegister<args> = $$genericContractRegister<args>;
30
-
31
- export type genericHandlerArgs<event,context> = { readonly event: event; readonly context: context };
32
-
33
- export type genericHandler<args> = (_1:args) => Promise<void>;
34
-
35
- export type entityHandlerContext<entity> = {
36
- readonly get: (_1:string) => Promise<(undefined | entity)>;
37
- readonly getOrThrow: (_1:string, message:(undefined | string)) => Promise<entity>;
38
- readonly getOrCreate: (_1:entity) => Promise<entity>;
39
- readonly set: (_1:entity) => void;
40
- readonly deleteUnsafe: (_1:string) => void
41
- };
42
-
43
- export type genericHandlerWithLoader<loader,handler,eventFilters> = {
44
- readonly loader: loader;
45
- readonly handler: handler;
46
- readonly wildcard?: boolean;
47
- readonly eventFilters?: eventFilters
48
- };
49
-
50
- export abstract class fuelEventConfig { protected opaque!: any }; /* simulate opaque types */
51
-
52
- export abstract class evmEventConfig { protected opaque!: any }; /* simulate opaque types */
53
-
54
- export type eventOptions<eventFilters> = { readonly wildcard?: boolean; readonly eventFilters?: eventFilters };
55
-
56
- export type fuelSupplyParams = { readonly subId: string; readonly amount: bigint };
57
-
58
- export type fuelTransferParams = {
59
- readonly to: Address_t;
60
- readonly assetId: string;
61
- readonly amount: bigint
62
- };
63
-
64
- export type noEventFilters = $$noEventFilters;
@@ -1,10 +0,0 @@
1
- /* TypeScript file generated from PgStorage.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- import * as PgStorageJS from './PgStorage.res.mjs';
7
-
8
- import type {sql as Postgres_sql} from '../src/bindings/Postgres.gen.js';
9
-
10
- export const makeClient: () => Postgres_sql = PgStorageJS.makeClient as any;
@@ -1,5 +0,0 @@
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 const makeClient: any;
package/src/Types.ts DELETED
@@ -1,56 +0,0 @@
1
- export type Invalid = never;
2
-
3
- export type Address = `0x${string}`;
4
-
5
- export type Logger = {
6
- readonly debug: (
7
- message: string,
8
- params?: Record<string, unknown> | Error
9
- ) => void;
10
- readonly info: (
11
- message: string,
12
- params?: Record<string, unknown> | Error
13
- ) => void;
14
- readonly warn: (
15
- message: string,
16
- params?: Record<string, unknown> | Error
17
- ) => void;
18
- readonly error: (
19
- message: string,
20
- params?: Record<string, unknown> | Error
21
- ) => void;
22
- };
23
-
24
- export abstract class Effect<I, O> {
25
- protected opaque!: I | O;
26
- }
27
-
28
- export type EffectCaller = <I, O>(
29
- effect: Effect<I, O>,
30
- // This is a hack to make the call complain on undefined
31
- // when it's not needed, instead of extending the input type.
32
- // Might be not needed if I misunderstand something in TS.
33
- input: I extends undefined ? undefined : I
34
- ) => Promise<O>;
35
-
36
- export type EffectContext = {
37
- /**
38
- * Access the logger instance with event as a context. The logs will be displayed in the console and Envio Hosted Service.
39
- */
40
- readonly log: Logger;
41
- /**
42
- * Call the provided Effect with the given input.
43
- * Effects are the best for external calls with automatic deduplication, error handling and caching.
44
- * Define a new Effect using createEffect outside of the handler.
45
- */
46
- readonly effect: EffectCaller;
47
- /**
48
- * Whether to cache the result of the effect. Defaults to the effect's cache configuration.
49
- * Set to false to disable caching for this specific call.
50
- */
51
- cache: boolean;
52
- };
53
-
54
- export type GenericContractRegister<Args> = (
55
- args: Args
56
- ) => void | Promise<void>;
@@ -1,14 +0,0 @@
1
- /* TypeScript file generated from BigDecimal.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- import * as BigDecimalJS from './BigDecimal.res.mjs';
7
-
8
- import type {S_t as RescriptSchema_S_t} from 'rescript-schema/RescriptSchema.gen.js';
9
-
10
- import type {default as $$t} from 'bignumber.js';
11
-
12
- export type t = $$t;
13
-
14
- export const schema: RescriptSchema_S_t<t> = BigDecimalJS.schema as any;
@@ -1,5 +0,0 @@
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 const schema: any;
@@ -1,10 +0,0 @@
1
- /* TypeScript file generated from BigInt.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- import * as BigIntJS from './BigInt.res.mjs';
7
-
8
- import type {S_t as RescriptSchema_S_t} from 'rescript-schema/RescriptSchema.gen.js';
9
-
10
- export const schema: RescriptSchema_S_t<bigint> = BigIntJS.schema as any;
@@ -1,70 +0,0 @@
1
- %%private(
2
- @inline
3
- let unsafeToOption: (unit => 'a) => option<'a> = unsafeFunc => {
4
- try {
5
- unsafeFunc()->Some
6
- } catch {
7
- | Js.Exn.Error(_obj) => None
8
- }
9
- }
10
- )
11
-
12
- // constructors and methods
13
- @val external fromInt: int => bigint = "BigInt"
14
- @val external fromStringUnsafe: string => bigint = "BigInt"
15
- @val external fromUnknownUnsafe: unknown => bigint = "BigInt"
16
- let fromString = str => unsafeToOption(() => str->fromStringUnsafe)
17
- @send external toString: bigint => string = "toString"
18
- let toInt = (b: bigint): option<int> => b->toString->Belt.Int.fromString
19
-
20
- //silence unused var warnings for raw bindings
21
- @@warning("-27")
22
- // operation
23
- let add = (a: bigint, b: bigint): bigint => %raw("a + b")
24
- let sub = (a: bigint, b: bigint): bigint => %raw("a - b")
25
- let mul = (a: bigint, b: bigint): bigint => %raw("a * b")
26
- let div = (a: bigint, b: bigint): bigint => %raw("b > 0n ? a / b : 0n")
27
- let pow = (a: bigint, b: bigint): bigint => %raw("a ** b")
28
- let mod = (a: bigint, b: bigint): bigint => %raw("b > 0n ? a % b : 0n")
29
-
30
- // comparison
31
- let eq = (a: bigint, b: bigint): bool => %raw("a === b")
32
- let neq = (a: bigint, b: bigint): bool => %raw("a !== b")
33
- let gt = (a: bigint, b: bigint): bool => %raw("a > b")
34
- let gte = (a: bigint, b: bigint): bool => %raw("a >= b")
35
- let lt = (a: bigint, b: bigint): bool => %raw("a < b")
36
- let lte = (a: bigint, b: bigint): bool => %raw("a <= b")
37
-
38
- module Bitwise = {
39
- let shift_left = (a: bigint, b: bigint): bigint => %raw("a << b")
40
- let shift_right = (a: bigint, b: bigint): bigint => %raw("a >> b")
41
- let logor = (a: bigint, b: bigint): bigint => %raw("a | b")
42
- let logand = (a: bigint, b: bigint): bigint => %raw("a & b")
43
- }
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
-
53
- let zero = fromInt(0)
54
- let toFloat: bigint => float = %raw(`(n) => Number(n)`)
55
- let toIntUnsafe: bigint => int = %raw(`(n) => Number(n)`)
56
-
57
- @genType
58
- let schema =
59
- S.string
60
- ->S.setName("BigInt")
61
- ->S.transform(s => {
62
- parser: string =>
63
- switch string->fromString {
64
- | Some(bigInt) => bigInt
65
- | None => s.fail("The string is not valid BigInt")
66
- },
67
- serializer: bigint => bigint->toString,
68
- })
69
-
70
- let nativeSchema = S.bigint
@@ -1,5 +0,0 @@
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 const schema: any;
@@ -1,154 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Js_exn from "rescript/lib/es6/js_exn.js";
4
- import * as Belt_Int from "rescript/lib/es6/belt_Int.js";
5
- import * as Caml_option from "rescript/lib/es6/caml_option.js";
6
- import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
7
- import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
8
-
9
- function fromString(str) {
10
- try {
11
- return Caml_option.some((function () {
12
- return BigInt(str);
13
- })());
14
- }
15
- catch (raw__obj){
16
- var _obj = Caml_js_exceptions.internalToOCamlException(raw__obj);
17
- if (_obj.RE_EXN_ID === Js_exn.$$Error) {
18
- return ;
19
- }
20
- throw _obj;
21
- }
22
- }
23
-
24
- function toInt(b) {
25
- return Belt_Int.fromString(b.toString());
26
- }
27
-
28
- function add(a, b) {
29
- return (a + b);
30
- }
31
-
32
- function sub(a, b) {
33
- return (a - b);
34
- }
35
-
36
- function mul(a, b) {
37
- return (a * b);
38
- }
39
-
40
- function div(a, b) {
41
- return (b > 0n ? a / b : 0n);
42
- }
43
-
44
- function pow(a, b) {
45
- return (a ** b);
46
- }
47
-
48
- function mod(a, b) {
49
- return (b > 0n ? a % b : 0n);
50
- }
51
-
52
- function eq(a, b) {
53
- return (a === b);
54
- }
55
-
56
- function neq(a, b) {
57
- return (a !== b);
58
- }
59
-
60
- function gt(a, b) {
61
- return (a > b);
62
- }
63
-
64
- function gte(a, b) {
65
- return (a >= b);
66
- }
67
-
68
- function lt(a, b) {
69
- return (a < b);
70
- }
71
-
72
- function lte(a, b) {
73
- return (a <= b);
74
- }
75
-
76
- function shift_left(a, b) {
77
- return (a << b);
78
- }
79
-
80
- function shift_right(a, b) {
81
- return (a >> b);
82
- }
83
-
84
- function logor(a, b) {
85
- return (a | b);
86
- }
87
-
88
- function logand(a, b) {
89
- return (a & b);
90
- }
91
-
92
- var Bitwise = {
93
- shift_left: shift_left,
94
- shift_right: shift_right,
95
- logor: logor,
96
- logand: logand
97
- };
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
-
107
- var zero = BigInt(0);
108
-
109
- var toFloat = ((n) => Number(n));
110
-
111
- var toIntUnsafe = ((n) => Number(n));
112
-
113
- var schema = S$RescriptSchema.transform(S$RescriptSchema.setName(S$RescriptSchema.string, "BigInt"), (function (s) {
114
- return {
115
- p: (function (string) {
116
- var bigInt = fromString(string);
117
- if (bigInt !== undefined) {
118
- return bigInt;
119
- } else {
120
- return s.fail("The string is not valid BigInt", undefined);
121
- }
122
- }),
123
- s: (function (bigint) {
124
- return bigint.toString();
125
- })
126
- };
127
- }));
128
-
129
- var nativeSchema = S$RescriptSchema.bigint;
130
-
131
- export {
132
- fromString ,
133
- toInt ,
134
- add ,
135
- sub ,
136
- mul ,
137
- div ,
138
- pow ,
139
- mod ,
140
- eq ,
141
- neq ,
142
- gt ,
143
- gte ,
144
- lt ,
145
- lte ,
146
- Bitwise ,
147
- arrayToStringArray ,
148
- zero ,
149
- toFloat ,
150
- toIntUnsafe ,
151
- schema ,
152
- nativeSchema ,
153
- }
154
- /* zero Not a pure module */
@@ -1,5 +0,0 @@
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 const Addresses: any;
@@ -1,17 +0,0 @@
1
- /* TypeScript file generated from Pino.res by genType. */
2
-
3
- /* eslint-disable */
4
- /* tslint:disable */
5
-
6
- export type logLevelUser = "udebug" | "uinfo" | "uwarn" | "uerror";
7
-
8
- export abstract class pinoMessageBlob { protected opaque!: any }; /* simulate opaque types */
9
-
10
- export type t = {
11
- readonly trace: (_1:pinoMessageBlob) => void;
12
- readonly debug: (_1:pinoMessageBlob) => void;
13
- readonly info: (_1:pinoMessageBlob) => void;
14
- readonly warn: (_1:pinoMessageBlob) => void;
15
- readonly error: (_1:pinoMessageBlob) => void;
16
- readonly fatal: (_1:pinoMessageBlob) => void
17
- };
@@ -1,8 +0,0 @@
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,5 +0,0 @@
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;