envio 2.16.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "envio",
3
- "version": "v2.16.0",
3
+ "version": "v2.17.0",
4
4
  "description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
5
5
  "bin": "./bin.js",
6
+ "types": "index.d.ts",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "git+https://github.com/enviodev/hyperindex.git"
@@ -23,10 +24,10 @@
23
24
  },
24
25
  "homepage": "https://envio.dev",
25
26
  "optionalDependencies": {
26
- "envio-linux-x64": "v2.16.0",
27
- "envio-linux-arm64": "v2.16.0",
28
- "envio-darwin-x64": "v2.16.0",
29
- "envio-darwin-arm64": "v2.16.0"
27
+ "envio-linux-x64": "v2.17.0",
28
+ "envio-linux-arm64": "v2.17.0",
29
+ "envio-darwin-x64": "v2.17.0",
30
+ "envio-darwin-arm64": "v2.17.0"
30
31
  },
31
32
  "dependencies": {
32
33
  "@envio-dev/hypersync-client": "0.6.3",
@@ -3,6 +3,6 @@
3
3
  /* eslint-disable */
4
4
  /* tslint:disable */
5
5
 
6
- import type {Address as $$t} from './bindings/OpaqueTypes.ts';
6
+ import type {Address as $$t} from './Types.ts';
7
7
 
8
8
  export type t = $$t;
package/src/Address.res CHANGED
@@ -1,4 +1,4 @@
1
- @genType.import(("./bindings/OpaqueTypes.ts", "Address"))
1
+ @genType.import(("./Types.ts", "Address"))
2
2
  type t
3
3
 
4
4
  let schema = S.string->S.setName("Address")->(Utils.magic: S.t<string> => S.t<t>)
@@ -0,0 +1,8 @@
1
+ /* TypeScript file generated from Envio.res by genType. */
2
+
3
+ /* eslint-disable */
4
+ /* tslint:disable */
5
+
6
+ import type {Logger as $$logger} from './Types.ts';
7
+
8
+ export type logger = $$logger;
package/src/Envio.res ADDED
@@ -0,0 +1,12 @@
1
+ // The file with public API.
2
+ // Should be an entry point after we get rid of the generated project.
3
+ // Don't forget to keep index.d.ts in sync with this file.
4
+
5
+ @genType.import(("./Types.ts", "Logger"))
6
+ type logger = {
7
+ debug: 'params. (string, ~params: {..} as 'params=?) => unit,
8
+ info: 'params. (string, ~params: {..} as 'params=?) => unit,
9
+ warn: 'params. (string, ~params: {..} as 'params=?) => unit,
10
+ error: 'params. (string, ~params: {..} as 'params=?) => unit,
11
+ errorWithExn: (string, exn) => unit,
12
+ }
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable */
4
4
  /* tslint:disable */
5
5
 
6
- import type {invalid as $$noEventFilters} from './bindings/OpaqueTypes.ts';
6
+ import type {Invalid as $$noEventFilters} from './Types.ts';
7
7
 
8
8
  import type {t as Address_t} from './Address.gen';
9
9
 
package/src/Internal.res CHANGED
@@ -159,5 +159,12 @@ let fuelTransferParamsSchema = S.schema(s => {
159
159
 
160
160
  type entity = private {id: string}
161
161
 
162
- @genType.import(("./bindings/OpaqueTypes.ts", "invalid"))
162
+ @genType.import(("./Types.ts", "Invalid"))
163
163
  type noEventFilters
164
+
165
+ let prettifyExn = exn => {
166
+ switch exn->Js.Exn.anyToExnInternal {
167
+ | Js.Exn.Error(e) => e->(Utils.magic: Js.Exn.t => exn)
168
+ | exn => exn
169
+ }
170
+ }
package/src/Types.ts ADDED
@@ -0,0 +1,22 @@
1
+ export type Invalid = never;
2
+
3
+ export type Address = 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
+ };
@@ -7,7 +7,11 @@ type app
7
7
  @module external makeCjs: unit => app = "express"
8
8
  @module("express") external make: unit => app = "default"
9
9
 
10
- type req
10
+ type req = private {
11
+ headers: dict<string>,
12
+ method: Rest.method,
13
+ query: dict<string>,
14
+ }
11
15
  type res
12
16
 
13
17
  type handler = (req, res) => unit
@@ -16,14 +20,18 @@ type middleware = (req, res, unit => unit) => unit
16
20
  @module("express") external jsonMiddleware: unit => middleware = "json"
17
21
 
18
22
  @send external use: (app, middleware) => unit = "use"
23
+ @send external useFor: (app, string, middleware) => unit = "use"
19
24
 
20
25
  @send external get: (app, string, handler) => unit = "get"
26
+ @send external post: (app, string, handler) => unit = "post"
21
27
 
22
28
  type server
23
29
 
24
30
  @send external listen: (app, int) => server = "listen"
25
31
 
26
32
  // res methods
27
- @send external sendStatus: (res, int) => res = "sendStatus"
33
+ @send external sendStatus: (res, int) => unit = "sendStatus"
28
34
  @send external set: (res, string, string) => unit = "set"
35
+ @send external json: (res, Js.Json.t) => unit = "json"
29
36
  @send external endWithData: (res, 'a) => res = "end"
37
+ @send external setHeader: (res, string, string) => unit = "setHeader"
@@ -0,0 +1,81 @@
1
+ type t
2
+ @module external process: t = "process"
3
+ @send external exit: (t, unit) => unit = "exit"
4
+ type exitCode = | @as(0) Success | @as(1) Failure
5
+ @send external exitWithCode: (t, exitCode) => unit = "exit"
6
+
7
+ module Util = {
8
+ @unboxed
9
+ type depth = Int(int) | @as(null) Null
10
+ @unboxed
11
+ type compact = Bool(bool) | Int(int)
12
+ @unboxed
13
+ type sorted = Bool(bool) | Fn((string, string) => int)
14
+ @unboxed
15
+ type getters = | @as(true) True | @as(false) False | @as("get") Get | @as("set") Set
16
+
17
+ @unbox
18
+ type inspectOptions = {
19
+ showHidden?: bool,
20
+ depth?: depth,
21
+ colors?: bool,
22
+ customInspect?: bool,
23
+ showProxy?: bool,
24
+ maxArrayLength?: int,
25
+ maxStringLength?: int,
26
+ breakLength?: int,
27
+ @as("compact") compact?: compact,
28
+ sorted?: sorted,
29
+ getters?: string,
30
+ numericSeparator?: bool,
31
+ }
32
+
33
+ @module("util") external inspect: ('a, inspectOptions) => string = "inspect"
34
+
35
+ let inspectObj = a => inspect(a, {showHidden: false, depth: Null, colors: true})
36
+ }
37
+
38
+ module Path = {
39
+ type t
40
+
41
+ @module("path") @variadic
42
+ external resolve: array<string> => t = "resolve"
43
+
44
+ @module("path") external join: (t, string) => t = "join"
45
+
46
+ external toString: t => string = "%identity"
47
+
48
+ external __dirname: t = "__dirname"
49
+ }
50
+
51
+ module Fs = {
52
+ type writeFileOptions = {
53
+ mode?: int,
54
+ // flag?: Flag.t,
55
+ encoding?: string,
56
+ }
57
+
58
+ module Promises = {
59
+ @module("fs") @scope("promises")
60
+ external writeFile: (
61
+ ~filepath: Path.t,
62
+ ~content: string,
63
+ ~options: writeFileOptions=?,
64
+ ) => promise<unit> = "writeFile"
65
+
66
+ @module("fs") @scope("promises")
67
+ external appendFile: (
68
+ ~filepath: Path.t,
69
+ ~content: string,
70
+ ~options: writeFileOptions=?,
71
+ ) => Js.Promise.t<unit> = "appendFile"
72
+
73
+ @module("fs") @scope("promises")
74
+ external access: Path.t => Js.Promise.t<unit> = "access"
75
+
76
+ type encoding = | @as("utf8") Utf8
77
+
78
+ @module("fs") @scope("promises")
79
+ external readFile: (~filepath: Path.t, ~encoding: encoding) => promise<string> = "readFile"
80
+ }
81
+ }
@@ -1,2 +0,0 @@
1
- export type Address = string;
2
- export type invalid = never;