envio 2.26.0-alpha.9 → 2.26.0-rc.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/evm.schema.json +0 -7
- package/fuel.schema.json +0 -7
- package/index.d.ts +0 -2
- package/package.json +5 -5
- package/src/Envio.gen.ts +1 -3
- package/src/Envio.res +0 -3
- package/src/Envio.res.js +0 -2
- package/src/FetchState.res +4 -1
- package/src/Internal.res +0 -1
- package/src/Logging.res +0 -8
- package/src/Logging.res.js +0 -29
- package/src/Persistence.res +19 -46
- package/src/Persistence.res.js +13 -23
- package/src/PgStorage.res +84 -214
- package/src/PgStorage.res.js +54 -153
- package/src/Utils.res +0 -17
- package/src/db/EntityHistory.res +28 -5
- package/src/db/EntityHistory.res.js +23 -4
- package/src/db/Table.res +61 -3
- package/src/db/Table.res.js +42 -3
package/evm.schema.json
CHANGED
|
@@ -33,13 +33,6 @@
|
|
|
33
33
|
"null"
|
|
34
34
|
]
|
|
35
35
|
},
|
|
36
|
-
"output": {
|
|
37
|
-
"description": "Path where the generated directory will be placed. By default it's 'generated' relative to the current working directory. If set, it'll be a path relative to the config file location.",
|
|
38
|
-
"type": [
|
|
39
|
-
"string",
|
|
40
|
-
"null"
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
36
|
"contracts": {
|
|
44
37
|
"description": "Global contract definitions that must contain all definitions except addresses. You can share a single handler/abi/event definitions for contracts across multiple chains.",
|
|
45
38
|
"type": [
|
package/fuel.schema.json
CHANGED
|
@@ -26,13 +26,6 @@
|
|
|
26
26
|
"null"
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
|
-
"output": {
|
|
30
|
-
"description": "Path where the generated directory will be placed. By default it's 'generated' relative to the current working directory. If set, it'll be a path relative to the config file location.",
|
|
31
|
-
"type": [
|
|
32
|
-
"string",
|
|
33
|
-
"null"
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
29
|
"contracts": {
|
|
37
30
|
"description": "Global contract definitions that must contain all definitions except addresses. You can share a single handler/abi/event definitions for contracts across multiple chains.",
|
|
38
31
|
"type": [
|
package/index.d.ts
CHANGED
|
@@ -105,8 +105,6 @@ export function experimental_createEffect<
|
|
|
105
105
|
readonly input: IS;
|
|
106
106
|
/** The output schema of the effect. */
|
|
107
107
|
readonly output: OS;
|
|
108
|
-
/** Whether the effect should be cached. */
|
|
109
|
-
readonly cache?: boolean;
|
|
110
108
|
},
|
|
111
109
|
handler: (args: EffectArgs<I>) => Promise<R>
|
|
112
110
|
): Effect<I, O>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envio",
|
|
3
|
-
"version": "v2.26.0-
|
|
3
|
+
"version": "v2.26.0-rc.0",
|
|
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.26.0-
|
|
29
|
-
"envio-linux-arm64": "v2.26.0-
|
|
30
|
-
"envio-darwin-x64": "v2.26.0-
|
|
31
|
-
"envio-darwin-arm64": "v2.26.0-
|
|
28
|
+
"envio-linux-x64": "v2.26.0-rc.0",
|
|
29
|
+
"envio-linux-arm64": "v2.26.0-rc.0",
|
|
30
|
+
"envio-darwin-x64": "v2.26.0-rc.0",
|
|
31
|
+
"envio-darwin-arm64": "v2.26.0-rc.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@envio-dev/hypersync-client": "0.6.5",
|
package/src/Envio.gen.ts
CHANGED
|
@@ -21,9 +21,7 @@ export type effectOptions<input,output> = {
|
|
|
21
21
|
/** The input schema of the effect. */
|
|
22
22
|
readonly input: RescriptSchema_S_t<input>;
|
|
23
23
|
/** The output schema of the effect. */
|
|
24
|
-
readonly output: RescriptSchema_S_t<output
|
|
25
|
-
/** Whether the effect should be cached. */
|
|
26
|
-
readonly cache?: boolean
|
|
24
|
+
readonly output: RescriptSchema_S_t<output>
|
|
27
25
|
};
|
|
28
26
|
|
|
29
27
|
export type effectContext = $$effectContext;
|
package/src/Envio.res
CHANGED
|
@@ -22,8 +22,6 @@ and effectOptions<'input, 'output> = {
|
|
|
22
22
|
input: S.t<'input>,
|
|
23
23
|
/** The output schema of the effect. */
|
|
24
24
|
output: S.t<'output>,
|
|
25
|
-
/** Whether the effect should be cached. */
|
|
26
|
-
cache?: bool,
|
|
27
25
|
}
|
|
28
26
|
@genType.import(("./Types.ts", "EffectContext"))
|
|
29
27
|
and effectContext = {
|
|
@@ -50,6 +48,5 @@ let experimental_createEffect = (
|
|
|
50
48
|
>
|
|
51
49
|
),
|
|
52
50
|
callsCount: 0,
|
|
53
|
-
cache: options.cache->Belt.Option.getWithDefault(false),
|
|
54
51
|
}->(Utils.magic: Internal.effect => effect<'input, 'output>)
|
|
55
52
|
}
|
package/src/Envio.res.js
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var Prometheus = require("./Prometheus.res.js");
|
|
5
|
-
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
6
5
|
|
|
7
6
|
function experimental_createEffect(options, handler) {
|
|
8
7
|
Prometheus.EffectCallsCount.set(0, options.name);
|
|
9
8
|
return {
|
|
10
9
|
name: options.name,
|
|
11
10
|
handler: handler,
|
|
12
|
-
cache: Belt_Option.getWithDefault(options.cache, false),
|
|
13
11
|
callsCount: 0
|
|
14
12
|
};
|
|
15
13
|
}
|
package/src/FetchState.res
CHANGED
|
@@ -901,7 +901,10 @@ let queueItemIsInReorgThreshold = (
|
|
|
901
901
|
if currentBlockHeight === 0 {
|
|
902
902
|
false
|
|
903
903
|
} else {
|
|
904
|
-
queueItem
|
|
904
|
+
switch queueItem {
|
|
905
|
+
| Item(_) => queueItem->queueItemBlockNumber > highestBlockBelowThreshold
|
|
906
|
+
| NoItem(_) => queueItem->queueItemBlockNumber > highestBlockBelowThreshold
|
|
907
|
+
}
|
|
905
908
|
}
|
|
906
909
|
}
|
|
907
910
|
|
package/src/Internal.res
CHANGED
package/src/Logging.res
CHANGED
|
@@ -168,14 +168,6 @@ let logForItem = (eventItem, level: Pino.logLevel, message: string, ~params=?) =
|
|
|
168
168
|
(eventItem->getEventLogger->Utils.magic->Js.Dict.unsafeGet((level :> string)))(params, message)
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
let noopLogger: Envio.logger = {
|
|
172
|
-
info: (_message: string, ~params as _=?) => (),
|
|
173
|
-
debug: (_message: string, ~params as _=?) => (),
|
|
174
|
-
warn: (_message: string, ~params as _=?) => (),
|
|
175
|
-
error: (_message: string, ~params as _=?) => (),
|
|
176
|
-
errorWithExn: (_message: string, _exn) => (),
|
|
177
|
-
}
|
|
178
|
-
|
|
179
171
|
let getUserLogger = (eventItem): Envio.logger => {
|
|
180
172
|
info: (message: string, ~params=?) => eventItem->logForItem(#uinfo, message, ~params?),
|
|
181
173
|
debug: (message: string, ~params=?) => eventItem->logForItem(#udebug, message, ~params?),
|
package/src/Logging.res.js
CHANGED
|
@@ -197,34 +197,6 @@ function logForItem(eventItem, level, message, params) {
|
|
|
197
197
|
return getEventLogger(eventItem)[level](params, message);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
function noopLogger_debug(_message, param) {
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function noopLogger_info(_message, param) {
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function noopLogger_warn(_message, param) {
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function noopLogger_error(_message, param) {
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function noopLogger_errorWithExn(_message, _exn) {
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
var noopLogger = {
|
|
221
|
-
debug: noopLogger_debug,
|
|
222
|
-
info: noopLogger_info,
|
|
223
|
-
warn: noopLogger_warn,
|
|
224
|
-
error: noopLogger_error,
|
|
225
|
-
errorWithExn: noopLogger_errorWithExn
|
|
226
|
-
};
|
|
227
|
-
|
|
228
200
|
function getUserLogger(eventItem) {
|
|
229
201
|
return {
|
|
230
202
|
debug: (function (message, params) {
|
|
@@ -271,6 +243,5 @@ exports.createChild = createChild;
|
|
|
271
243
|
exports.createChildFrom = createChildFrom;
|
|
272
244
|
exports.getEventLogger = getEventLogger;
|
|
273
245
|
exports.logForItem = logForItem;
|
|
274
|
-
exports.noopLogger = noopLogger;
|
|
275
246
|
exports.getUserLogger = getUserLogger;
|
|
276
247
|
/* logLevels Not a pure module */
|
package/src/Persistence.res
CHANGED
|
@@ -5,18 +5,6 @@
|
|
|
5
5
|
// Currently there are quite many code spread across
|
|
6
6
|
// DbFunctions, Db, Migrations, InMemoryStore modules which use codegen code directly.
|
|
7
7
|
|
|
8
|
-
// The type reflects an effect cache table in the db
|
|
9
|
-
// It might be present even if the effect is not used in the application
|
|
10
|
-
type effectCache = {
|
|
11
|
-
name: string,
|
|
12
|
-
// Number of rows in the table
|
|
13
|
-
mutable size: int,
|
|
14
|
-
// Lazily attached table definition when effect is used in the application
|
|
15
|
-
mutable table: option<Table.table>,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type operator = [#">" | #"="]
|
|
19
|
-
|
|
20
8
|
type storage = {
|
|
21
9
|
// Should return true if we already have persisted data
|
|
22
10
|
// and we can skip initialization
|
|
@@ -27,8 +15,9 @@ type storage = {
|
|
|
27
15
|
~entities: array<Internal.entityConfig>=?,
|
|
28
16
|
~generalTables: array<Table.table>=?,
|
|
29
17
|
~enums: array<Internal.enumConfig<Internal.enum>>=?,
|
|
18
|
+
// If true, the storage should clear existing data
|
|
19
|
+
~cleanRun: bool=?,
|
|
30
20
|
) => promise<unit>,
|
|
31
|
-
loadEffectCaches: unit => promise<array<effectCache>>,
|
|
32
21
|
@raises("StorageError")
|
|
33
22
|
loadByIdsOrThrow: 'item. (
|
|
34
23
|
~ids: array<string>,
|
|
@@ -36,15 +25,6 @@ type storage = {
|
|
|
36
25
|
~rowsSchema: S.t<array<'item>>,
|
|
37
26
|
) => promise<array<'item>>,
|
|
38
27
|
@raises("StorageError")
|
|
39
|
-
loadByFieldOrThrow: 'item 'value. (
|
|
40
|
-
~fieldName: string,
|
|
41
|
-
~fieldSchema: S.t<'value>,
|
|
42
|
-
~fieldValue: 'value,
|
|
43
|
-
~operator: operator,
|
|
44
|
-
~table: Table.table,
|
|
45
|
-
~rowsSchema: S.t<array<'item>>,
|
|
46
|
-
) => promise<array<'item>>,
|
|
47
|
-
@raises("StorageError")
|
|
48
28
|
setOrThrow: 'item. (
|
|
49
29
|
~items: array<'item>,
|
|
50
30
|
~table: Table.table,
|
|
@@ -57,7 +37,7 @@ exception StorageError({message: string, reason: exn})
|
|
|
57
37
|
type storageStatus =
|
|
58
38
|
| Unknown
|
|
59
39
|
| Initializing(promise<unit>)
|
|
60
|
-
| Ready({cleanRun: bool
|
|
40
|
+
| Ready({cleanRun: bool})
|
|
61
41
|
|
|
62
42
|
type t = {
|
|
63
43
|
userEntities: array<Internal.entityConfig>,
|
|
@@ -67,6 +47,7 @@ type t = {
|
|
|
67
47
|
mutable storageStatus: storageStatus,
|
|
68
48
|
storage: storage,
|
|
69
49
|
onStorageInitialize: option<unit => promise<unit>>,
|
|
50
|
+
cacheStorage: storage,
|
|
70
51
|
}
|
|
71
52
|
|
|
72
53
|
let entityHistoryActionEnumConfig: Internal.enumConfig<EntityHistory.RowAction.t> = {
|
|
@@ -83,6 +64,7 @@ let make = (
|
|
|
83
64
|
~allEnums,
|
|
84
65
|
~staticTables,
|
|
85
66
|
~storage,
|
|
67
|
+
~cacheStorage,
|
|
86
68
|
~onStorageInitialize=?,
|
|
87
69
|
) => {
|
|
88
70
|
let allEntities = userEntities->Js.Array2.concat([dcRegistryEntityConfig])
|
|
@@ -96,10 +78,18 @@ let make = (
|
|
|
96
78
|
storageStatus: Unknown,
|
|
97
79
|
storage,
|
|
98
80
|
onStorageInitialize,
|
|
81
|
+
cacheStorage,
|
|
99
82
|
}
|
|
100
83
|
}
|
|
101
84
|
|
|
102
|
-
let init = async (
|
|
85
|
+
let init = async (
|
|
86
|
+
persistence,
|
|
87
|
+
// There are not much sense in the option,
|
|
88
|
+
// but this is how the runUpMigration used to work
|
|
89
|
+
// and we want to keep the upsert behavior without breaking changes.
|
|
90
|
+
~skipIsInitializedCheck=false,
|
|
91
|
+
~reset=false,
|
|
92
|
+
) => {
|
|
103
93
|
try {
|
|
104
94
|
let shouldRun = switch persistence.storageStatus {
|
|
105
95
|
| Unknown => true
|
|
@@ -115,37 +105,20 @@ let init = async (persistence, ~reset=false) => {
|
|
|
115
105
|
resolveRef := resolve
|
|
116
106
|
})
|
|
117
107
|
persistence.storageStatus = Initializing(promise)
|
|
118
|
-
if reset ||
|
|
108
|
+
if !(reset || skipIsInitializedCheck) && (await persistence.storage.isInitialized()) {
|
|
109
|
+
persistence.storageStatus = Ready({cleanRun: false})
|
|
110
|
+
} else {
|
|
119
111
|
let _ = await persistence.storage.initialize(
|
|
120
112
|
~entities=persistence.allEntities,
|
|
121
113
|
~generalTables=persistence.staticTables,
|
|
122
114
|
~enums=persistence.allEnums,
|
|
115
|
+
~cleanRun=reset || !skipIsInitializedCheck,
|
|
123
116
|
)
|
|
124
|
-
|
|
125
|
-
persistence.storageStatus = Ready({
|
|
126
|
-
cleanRun: true,
|
|
127
|
-
effectCaches: Js.Dict.empty(),
|
|
128
|
-
})
|
|
117
|
+
persistence.storageStatus = Ready({cleanRun: true})
|
|
129
118
|
switch persistence.onStorageInitialize {
|
|
130
119
|
| Some(onStorageInitialize) => await onStorageInitialize()
|
|
131
120
|
| None => ()
|
|
132
121
|
}
|
|
133
|
-
} else if (
|
|
134
|
-
// In case of a race condition,
|
|
135
|
-
// we want to set the initial status to Ready only once.
|
|
136
|
-
switch persistence.storageStatus {
|
|
137
|
-
| Initializing(_) => true
|
|
138
|
-
| _ => false
|
|
139
|
-
}
|
|
140
|
-
) {
|
|
141
|
-
let effectCaches = Js.Dict.empty()
|
|
142
|
-
(await persistence.storage.loadEffectCaches())->Js.Array2.forEach(effectCache => {
|
|
143
|
-
effectCaches->Js.Dict.set(effectCache.name, effectCache)
|
|
144
|
-
})
|
|
145
|
-
persistence.storageStatus = Ready({
|
|
146
|
-
cleanRun: false,
|
|
147
|
-
effectCaches,
|
|
148
|
-
})
|
|
149
122
|
}
|
|
150
123
|
resolveRef.contents()
|
|
151
124
|
}
|
package/src/Persistence.res.js
CHANGED
|
@@ -22,7 +22,7 @@ var entityHistoryActionEnumConfig = {
|
|
|
22
22
|
default: "SET"
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
function make(userEntities, dcRegistryEntityConfig, allEnums, staticTables, storage, onStorageInitialize) {
|
|
25
|
+
function make(userEntities, dcRegistryEntityConfig, allEnums, staticTables, storage, cacheStorage, onStorageInitialize) {
|
|
26
26
|
var allEntities = userEntities.concat([dcRegistryEntityConfig]);
|
|
27
27
|
var allEnums$1 = allEnums.concat([entityHistoryActionEnumConfig]);
|
|
28
28
|
return {
|
|
@@ -32,11 +32,13 @@ function make(userEntities, dcRegistryEntityConfig, allEnums, staticTables, stor
|
|
|
32
32
|
allEnums: allEnums$1,
|
|
33
33
|
storageStatus: "Unknown",
|
|
34
34
|
storage: storage,
|
|
35
|
-
onStorageInitialize: onStorageInitialize
|
|
35
|
+
onStorageInitialize: onStorageInitialize,
|
|
36
|
+
cacheStorage: cacheStorage
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
async function init(persistence, resetOpt) {
|
|
40
|
+
async function init(persistence, skipIsInitializedCheckOpt, resetOpt) {
|
|
41
|
+
var skipIsInitializedCheck = skipIsInitializedCheckOpt !== undefined ? skipIsInitializedCheckOpt : false;
|
|
40
42
|
var reset = resetOpt !== undefined ? resetOpt : false;
|
|
41
43
|
try {
|
|
42
44
|
var promise = persistence.storageStatus;
|
|
@@ -62,34 +64,22 @@ async function init(persistence, resetOpt) {
|
|
|
62
64
|
TAG: "Initializing",
|
|
63
65
|
_0: promise$1
|
|
64
66
|
};
|
|
65
|
-
if (reset ||
|
|
66
|
-
await persistence.storage.initialize(persistence.allEntities, persistence.staticTables, persistence.allEnums);
|
|
67
|
+
if (!(reset || skipIsInitializedCheck) && await persistence.storage.isInitialized()) {
|
|
67
68
|
persistence.storageStatus = {
|
|
68
69
|
TAG: "Ready",
|
|
69
|
-
cleanRun:
|
|
70
|
-
|
|
70
|
+
cleanRun: false
|
|
71
|
+
};
|
|
72
|
+
} else {
|
|
73
|
+
await persistence.storage.initialize(persistence.allEntities, persistence.staticTables, persistence.allEnums, reset || !skipIsInitializedCheck);
|
|
74
|
+
persistence.storageStatus = {
|
|
75
|
+
TAG: "Ready",
|
|
76
|
+
cleanRun: true
|
|
71
77
|
};
|
|
72
78
|
var onStorageInitialize = persistence.onStorageInitialize;
|
|
73
79
|
if (onStorageInitialize !== undefined) {
|
|
74
80
|
await onStorageInitialize();
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
} else {
|
|
78
|
-
var match = persistence.storageStatus;
|
|
79
|
-
var tmp;
|
|
80
|
-
tmp = typeof match !== "object" || match.TAG !== "Initializing" ? false : true;
|
|
81
|
-
if (tmp) {
|
|
82
|
-
var effectCaches = {};
|
|
83
|
-
(await persistence.storage.loadEffectCaches()).forEach(function (effectCache) {
|
|
84
|
-
effectCaches[effectCache.name] = effectCache;
|
|
85
|
-
});
|
|
86
|
-
persistence.storageStatus = {
|
|
87
|
-
TAG: "Ready",
|
|
88
|
-
cleanRun: false,
|
|
89
|
-
effectCaches: effectCaches
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
83
|
}
|
|
94
84
|
return resolveRef.contents();
|
|
95
85
|
}
|