envio 2.19.0 → 2.19.2

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 (3) hide show
  1. package/index.d.ts +144 -0
  2. package/index.js +37 -0
  3. package/package.json +7 -5
package/index.d.ts ADDED
@@ -0,0 +1,144 @@
1
+ export type {
2
+ logger as Logger,
3
+ effect as Effect,
4
+ effectContext as EffectContext,
5
+ effectArgs as EffectArgs,
6
+ effectOptions as EffectOptions,
7
+ } from "./src/Envio.gen.ts";
8
+ export type { EffectCaller } from "./src/Types.ts";
9
+
10
+ import type {
11
+ effect as Effect,
12
+ effectArgs as EffectArgs,
13
+ } from "./src/Envio.gen.ts";
14
+
15
+ import { schema as bigDecimalSchema } from "./src/bindings/BigDecimal.gen.ts";
16
+ import * as Sury from "rescript-schema";
17
+
18
+ type UnknownToOutput<T> = T extends Sury.Schema<unknown>
19
+ ? Sury.Output<T>
20
+ : T extends (...args: any[]) => any
21
+ ? T
22
+ : T extends unknown[]
23
+ ? { [K in keyof T]: UnknownToOutput<T[K]> }
24
+ : T extends { [k in keyof T]: unknown }
25
+ ? Flatten<
26
+ {
27
+ [k in keyof T as HasUndefined<UnknownToOutput<T[k]>> extends true
28
+ ? k
29
+ : never]?: UnknownToOutput<T[k]>;
30
+ } & {
31
+ [k in keyof T as HasUndefined<UnknownToOutput<T[k]>> extends true
32
+ ? never
33
+ : k]: UnknownToOutput<T[k]>;
34
+ }
35
+ >
36
+ : T;
37
+
38
+ type UnknownToInput<T> = T extends Sury.Schema<unknown>
39
+ ? Sury.Input<T>
40
+ : T extends (...args: any[]) => any
41
+ ? T
42
+ : T extends unknown[]
43
+ ? { [K in keyof T]: UnknownToInput<T[K]> }
44
+ : T extends { [k in keyof T]: unknown }
45
+ ? Flatten<
46
+ {
47
+ [k in keyof T as HasUndefined<UnknownToInput<T[k]>> extends true
48
+ ? k
49
+ : never]?: UnknownToInput<T[k]>;
50
+ } & {
51
+ [k in keyof T as HasUndefined<UnknownToInput<T[k]>> extends true
52
+ ? never
53
+ : k]: UnknownToInput<T[k]>;
54
+ }
55
+ >
56
+ : T;
57
+
58
+ type HasUndefined<T> = [T] extends [undefined]
59
+ ? true
60
+ : undefined extends T
61
+ ? true
62
+ : false;
63
+
64
+ // Utility to flatten the type into a single object
65
+ type Flatten<T> = T extends object
66
+ ? { [K in keyof T as T[K] extends never ? never : K]: T[K] }
67
+ : T;
68
+
69
+ // All the type gymnastics with generics to be able to
70
+ // define schema without an additional `S.schema` call in TS:
71
+ // createEffect({
72
+ // input: undefined,
73
+ // })
74
+ // Instead of:
75
+ // createEffect({
76
+ // input: S.schema(undefined),
77
+ // })
78
+ // Or for objects:
79
+ // createEffect({
80
+ // input: {
81
+ // foo: S.string,
82
+ // },
83
+ // })
84
+ // Instead of:
85
+ // createEffect({
86
+ // input: S.schema({
87
+ // foo: S.string,
88
+ // }),
89
+ // })
90
+ // The behaviour is inspired by Sury code:
91
+ // https://github.com/DZakh/sury/blob/551f8ee32c1af95320936d00c086e5fb337f59fa/packages/sury/src/S.d.ts#L344C1-L355C50
92
+ export function experimental_createEffect<
93
+ IS,
94
+ OS,
95
+ I = UnknownToInput<IS>,
96
+ O = UnknownToOutput<OS>,
97
+ // A hack to enforce that the inferred return type
98
+ // matches the output schema type
99
+ R extends O = O
100
+ >(
101
+ options: {
102
+ /** The name of the effect. Used for logging and debugging. */
103
+ readonly name: string;
104
+ /** The input schema of the effect. */
105
+ readonly input: IS;
106
+ /** The output schema of the effect. */
107
+ readonly output: OS;
108
+ },
109
+ handler: (args: EffectArgs<I>) => Promise<R>
110
+ ): Effect<I, O>;
111
+
112
+ // Important! Should match the index.js file
113
+ export declare namespace S {
114
+ export type Output<T> = Sury.Output<T>;
115
+ export type Input<T> = Sury.Input<T>;
116
+ export type Schema<Output, Input = unknown> = Sury.Schema<Output, Input>;
117
+ export const string: typeof Sury.string;
118
+ export const jsonString: typeof Sury.jsonString;
119
+ export const boolean: typeof Sury.boolean;
120
+ export const int32: typeof Sury.int32;
121
+ export const number: typeof Sury.number;
122
+ export const bigint: typeof Sury.bigint;
123
+ export const never: typeof Sury.never;
124
+ export const union: typeof Sury.union;
125
+ export const object: typeof Sury.object;
126
+ // Might change in a near future
127
+ // export const custom: typeof Sury.custom;
128
+ // Don't expose recursive for now, since it's too advanced
129
+ // export const recursive: typeof Sury.recursive;
130
+ export const transform: typeof Sury.transform;
131
+ export const refine: typeof Sury.refine;
132
+ export const schema: typeof Sury.schema;
133
+ export const record: typeof Sury.record;
134
+ export const array: typeof Sury.array;
135
+ export const tuple: typeof Sury.tuple;
136
+ export const merge: typeof Sury.merge;
137
+ export const optional: typeof Sury.optional;
138
+ export const nullable: typeof Sury.nullable;
139
+ export const bigDecimal: typeof bigDecimalSchema;
140
+ export const unknown: typeof Sury.unknown;
141
+ // Nullish type will change in "sury@10"
142
+ // export const nullish: typeof Sury.nullish;
143
+ export const assertOrThrow: typeof Sury.assertOrThrow;
144
+ }
package/index.js ADDED
@@ -0,0 +1,37 @@
1
+ // This file is needed to have control over TS version exports
2
+ // Some parts like Sury reexport are impossible to implement
3
+ // on the JS side, so we need to do it here
4
+
5
+ const envioGen = require("./src/Envio.bs.js");
6
+ Object.assign(exports, envioGen);
7
+
8
+ const Sury = require("rescript-schema");
9
+ // Important! Should match the index.d.ts file
10
+ exports.S = {
11
+ string: Sury.string,
12
+ jsonString: Sury.jsonString,
13
+ boolean: Sury.boolean,
14
+ int32: Sury.int32,
15
+ number: Sury.number,
16
+ bigint: Sury.bigint,
17
+ never: Sury.never,
18
+ union: Sury.union,
19
+ object: Sury.object,
20
+ // Might change in a near future
21
+ // custom: Sury.custom,
22
+ // Don't expose recursive for now, since it's too advanced
23
+ // recursive: Sury.recursive,
24
+ transform: Sury.transform,
25
+ refine: Sury.refine,
26
+ schema: Sury.schema,
27
+ record: Sury.record,
28
+ array: Sury.array,
29
+ tuple: Sury.tuple,
30
+ merge: Sury.merge,
31
+ optional: Sury.optional,
32
+ nullable: Sury.nullable,
33
+ bigDecimal: require("./src/bindings/BigDecimal.bs.js").schema,
34
+ // Nullish type will change in "sury@10"
35
+ // nullish: Sury.nullish,
36
+ assertOrThrow: Sury.assertOrThrow,
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envio",
3
- "version": "v2.19.0",
3
+ "version": "v2.19.2",
4
4
  "description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
5
5
  "bin": "./bin.js",
6
6
  "main": "./index.js",
@@ -25,10 +25,10 @@
25
25
  },
26
26
  "homepage": "https://envio.dev",
27
27
  "optionalDependencies": {
28
- "envio-linux-x64": "v2.19.0",
29
- "envio-linux-arm64": "v2.19.0",
30
- "envio-darwin-x64": "v2.19.0",
31
- "envio-darwin-arm64": "v2.19.0"
28
+ "envio-linux-x64": "v2.19.2",
29
+ "envio-linux-arm64": "v2.19.2",
30
+ "envio-darwin-x64": "v2.19.2",
31
+ "envio-darwin-arm64": "v2.19.2"
32
32
  },
33
33
  "dependencies": {
34
34
  "@envio-dev/hypersync-client": "0.6.3",
@@ -41,6 +41,8 @@
41
41
  "evm.schema.json",
42
42
  "fuel.schema.json",
43
43
  "rescript.json",
44
+ "index.d.ts",
45
+ "index.js",
44
46
  "src",
45
47
  "!src/**/*.bs.js"
46
48
  ]