envio 3.13.0 → 3.14.0-subgraph

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 (111) hide show
  1. package/bin.mjs +10 -1
  2. package/index.d.ts +11 -0
  3. package/package.json +8 -20
  4. package/rescript.json +1 -4
  5. package/src/Config.res +78 -100
  6. package/src/Config.res.mjs +55 -64
  7. package/src/Core.res +67 -6
  8. package/src/Core.res.mjs +58 -4
  9. package/src/EventConfigBuilder.res +4 -10
  10. package/src/EventConfigBuilder.res.mjs +1 -3
  11. package/src/EventProcessing.res +6 -6
  12. package/src/EventProcessing.res.mjs +8 -6
  13. package/src/ExitOnCaughtUp.res +5 -1
  14. package/src/ExitOnCaughtUp.res.mjs +8 -3
  15. package/src/HandlerLoader.res +98 -36
  16. package/src/HandlerLoader.res.mjs +89 -24
  17. package/src/HandlerTypeCheck.mjs +14 -0
  18. package/src/HandlerTypeCheckWorker.mjs +68 -0
  19. package/src/Internal.res +1 -1
  20. package/src/LoadLayer.res +39 -7
  21. package/src/LoadLayer.res.mjs +65 -38
  22. package/src/LoadLayer.resi +28 -0
  23. package/src/Main.res +17 -12
  24. package/src/Main.res.mjs +9 -3
  25. package/src/NodeVersion.mjs +13 -0
  26. package/src/Persistence.res +79 -38
  27. package/src/Persistence.res.mjs +41 -10
  28. package/src/PgStorage.res +86 -39
  29. package/src/PgStorage.res.mjs +83 -32
  30. package/src/ResumePlan.res +172 -0
  31. package/src/ResumePlan.res.mjs +122 -0
  32. package/src/Supervisor.res +8 -8
  33. package/src/Supervisor.res.mjs +6 -1
  34. package/src/SyncWrites.res +86 -0
  35. package/src/SyncWrites.res.mjs +85 -0
  36. package/src/TestIndexer.res +14 -4
  37. package/src/TestIndexer.res.mjs +3 -2
  38. package/src/TsModuleHooks.mjs +121 -0
  39. package/src/UserContext.res +377 -62
  40. package/src/UserContext.res.mjs +297 -39
  41. package/src/Utils.res +0 -8
  42. package/src/Worker.res +8 -0
  43. package/src/Worker.res.mjs +11 -0
  44. package/src/bindings/NodeJs.res +8 -7
  45. package/src/bindings/NodeJs.res.mjs +0 -3
  46. package/src/bindings/Pino.res +2 -2
  47. package/src/db/InternalTable.res +52 -2
  48. package/src/db/InternalTable.res.mjs +32 -3
  49. package/src/db/Table.res +10 -0
  50. package/src/db/Table.res.mjs +22 -11
  51. package/src/sources/FuelHyperSync.res +2 -0
  52. package/src/sources/FuelHyperSync.res.mjs +1 -0
  53. package/src/sources/FuelHyperSync.resi +1 -0
  54. package/src/sources/FuelHyperSyncClient.res +25 -8
  55. package/src/sources/FuelHyperSyncClient.res.mjs +8 -2
  56. package/src/sources/FuelHyperSyncSource.res +24 -22
  57. package/src/sources/FuelHyperSyncSource.res.mjs +18 -13
  58. package/src/subgraph/abi-types.ts +63 -0
  59. package/src/subgraph/assemblyscript.ts +85 -0
  60. package/src/subgraph/blocks.ts +183 -0
  61. package/src/subgraph/calls.ts +149 -0
  62. package/src/subgraph/conformance.ts +83 -0
  63. package/src/subgraph/errors.ts +96 -0
  64. package/src/subgraph/graph-cli-worker.mjs +26 -0
  65. package/src/subgraph/graph-cli.ts +190 -0
  66. package/src/subgraph/graph-ts-enums.ts +28 -0
  67. package/src/subgraph/graph-ts-types/VERSION +2 -0
  68. package/src/subgraph/graph-ts-types/chain/arweave.d.ts +70 -0
  69. package/src/subgraph/graph-ts-types/chain/cosmos.d.ts +327 -0
  70. package/src/subgraph/graph-ts-types/chain/ethereum.d.ts +233 -0
  71. package/src/subgraph/graph-ts-types/chain/near.d.ts +253 -0
  72. package/src/subgraph/graph-ts-types/chain/starknet.d.ts +32 -0
  73. package/src/subgraph/graph-ts-types/common/collections.d.ts +136 -0
  74. package/src/subgraph/graph-ts-types/common/conversion.d.ts +11 -0
  75. package/src/subgraph/graph-ts-types/common/datasource.d.ts +30 -0
  76. package/src/subgraph/graph-ts-types/common/eager-offset.d.ts +0 -0
  77. package/src/subgraph/graph-ts-types/common/json.d.ts +17 -0
  78. package/src/subgraph/graph-ts-types/common/numbers.d.ts +120 -0
  79. package/src/subgraph/graph-ts-types/common/value.d.ts +120 -0
  80. package/src/subgraph/graph-ts-types/common/yaml.d.ts +90 -0
  81. package/src/subgraph/graph-ts-types/global/global.d.ts +194 -0
  82. package/src/subgraph/graph-ts-types/helper-functions.d.ts +22 -0
  83. package/src/subgraph/graph-ts-types/index.d.ts +102 -0
  84. package/src/subgraph/graph-ts.ts +2285 -0
  85. package/src/subgraph/hosts.ts +158 -0
  86. package/src/subgraph/rpc.ts +65 -0
  87. package/src/subgraph/runtime.ts +595 -0
  88. package/src/subgraph/scope.ts +68 -0
  89. package/src/tui/InitApi.res +85 -0
  90. package/src/tui/{components/CustomHooks.res.mjs → InitApi.res.mjs} +11 -64
  91. package/src/tui/Tui.res +142 -249
  92. package/src/tui/Tui.res.mjs +123 -332
  93. package/src/Js.shim.ts +0 -11
  94. package/src/bindings/DateFns.res +0 -74
  95. package/src/bindings/DateFns.res.mjs +0 -22
  96. package/src/sources/FuelSDK.res +0 -38
  97. package/src/sources/FuelSDK.res.mjs +0 -27
  98. package/src/sources/vendored-fuel-abi-coder.js +0 -1792
  99. package/src/tui/bindings/Ink.res +0 -369
  100. package/src/tui/bindings/Ink.res.mjs +0 -66
  101. package/src/tui/bindings/Style.res +0 -123
  102. package/src/tui/bindings/Style.res.mjs +0 -2
  103. package/src/tui/components/BufferedProgressBar.res +0 -40
  104. package/src/tui/components/BufferedProgressBar.res.mjs +0 -57
  105. package/src/tui/components/CustomHooks.res +0 -122
  106. package/src/tui/components/Messages.res +0 -40
  107. package/src/tui/components/Messages.res.mjs +0 -71
  108. package/src/tui/components/SyncETA.res +0 -179
  109. package/src/tui/components/SyncETA.res.mjs +0 -249
  110. package/src/tui/components/TuiData.res +0 -98
  111. package/src/tui/components/TuiData.res.mjs +0 -73
@@ -0,0 +1,85 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Utils from "./Utils.res.mjs";
4
+ import * as EntityId from "./EntityId.res.mjs";
5
+ import * as EntityFilter from "./db/EntityFilter.res.mjs";
6
+ import * as IndexerState from "./IndexerState.res.mjs";
7
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
8
+ import * as InMemoryStore from "./InMemoryStore.res.mjs";
9
+ import * as InMemoryTable from "./InMemoryTable.res.mjs";
10
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
11
+
12
+ function make() {
13
+ return {};
14
+ }
15
+
16
+ function record(writes, entityConfig, scope, change) {
17
+ let table = writes[entityConfig.name];
18
+ let table$1;
19
+ if (table !== undefined) {
20
+ table$1 = table;
21
+ } else {
22
+ let table_changes = {};
23
+ let table$2 = {
24
+ entityConfig: entityConfig,
25
+ scope: scope,
26
+ changes: table_changes
27
+ };
28
+ writes[entityConfig.name] = table$2;
29
+ table$1 = table$2;
30
+ }
31
+ table$1.changes[EntityId.toKey(change.entityId)] = change;
32
+ }
33
+
34
+ function changesOf(writes, entityConfig) {
35
+ let match = writes[entityConfig.name];
36
+ if (match !== undefined) {
37
+ return match.changes;
38
+ }
39
+ }
40
+
41
+ function getById(writes, entityConfig, entityId) {
42
+ let changes = changesOf(writes, entityConfig);
43
+ if (changes !== undefined) {
44
+ return Stdlib_Option.map(changes[entityId], InMemoryTable.Entity.mapChangeToEntity);
45
+ }
46
+ }
47
+
48
+ function overlayFilter(writes, entities, entityConfig, filter) {
49
+ let changes = changesOf(writes, entityConfig);
50
+ if (changes === undefined) {
51
+ return entities;
52
+ }
53
+ let matches = EntityFilter.makeMatcher(filter, entityConfig.table);
54
+ let untouched = entities.filter(entity => !(InMemoryTable.Entity.getEntityIdUnsafe(entity) in changes));
55
+ let written = Stdlib_Array.filterMap(Object.values(changes), change => {
56
+ let entity = InMemoryTable.Entity.mapChangeToEntity(change);
57
+ if (entity !== undefined && matches(entity)) {
58
+ return entity;
59
+ }
60
+ });
61
+ return untouched.concat(written);
62
+ }
63
+
64
+ function write(indexerState, entityConfig, scope, change) {
65
+ InMemoryTable.Entity.set(InMemoryStore.getInMemTable(indexerState, entityConfig, scope), IndexerState.committedCheckpointIdFor(indexerState, scope), change);
66
+ }
67
+
68
+ function commit(writes, indexerState) {
69
+ Utils.Dict.forEach(writes, param => {
70
+ let scope = param.scope;
71
+ let entityConfig = param.entityConfig;
72
+ Utils.Dict.forEach(param.changes, change => write(indexerState, entityConfig, scope, change));
73
+ });
74
+ }
75
+
76
+ export {
77
+ make,
78
+ record,
79
+ changesOf,
80
+ getById,
81
+ overlayFilter,
82
+ write,
83
+ commit,
84
+ }
85
+ /* Utils Not a pure module */
@@ -275,7 +275,6 @@ let makeInitialState = (
275
275
  {
276
276
  cleanRun: true,
277
277
  contractMapping,
278
- envioInfo: Some(JSON.Encode.object(Dict.make())),
279
278
  cache: Dict.make(),
280
279
  chains,
281
280
  checkpointFrontier: Frontier.empty(),
@@ -567,7 +566,7 @@ let makeInMemoryStorage = (~state: testIndexerState): Persistence.storage => {
567
566
  isInitialized: async () => true,
568
567
  // The runner injects the config-derived initial state by setting
569
568
  // `persistence.storageStatus = Ready(...)` directly, bypassing `Persistence.init`,
570
- // so neither of these is reached.
569
+ // so none of these is reached.
571
570
  initialize: async (
572
571
  ~chainConfigs as _=?,
573
572
  ~entities as _=?,
@@ -578,7 +577,15 @@ let makeInMemoryStorage = (~state: testIndexerState): Persistence.storage => {
578
577
  JsError.throwWithMessage(
579
578
  "TestIndexer: initialize should not be called; the initial state is derived from config.",
580
579
  ),
581
- resumeInitialState: async (~entities as _, ~chainIds as _, ~throwIfIncompatible as _) =>
580
+ readStoredConfig: async () =>
581
+ JsError.throwWithMessage(
582
+ "TestIndexer: readStoredConfig should not be called; the initial state is derived from config.",
583
+ ),
584
+ addChain: async (~chainConfig as _, ~entities as _, ~contractMapping as _) =>
585
+ JsError.throwWithMessage(
586
+ "TestIndexer: addChain should not be called; the initial state is derived from config.",
587
+ ),
588
+ resumeInitialState: async (~entities as _, ~chainIds as _, ~contractMapping as _) =>
582
589
  JsError.throwWithMessage(
583
590
  "TestIndexer: resumeInitialState should not be called; the initial state is derived from config.",
584
591
  ),
@@ -666,7 +673,10 @@ let getRegistrations = (~config) =>
666
673
  switch registrationsRef.contents {
667
674
  | Some(promise) => promise
668
675
  | None =>
669
- let promise = HandlerLoader.registerAllHandlers(~config)
676
+ let promise =
677
+ HandlerLoader.getAutoLoadFiles(~config)->Promise.then(autoLoadFiles =>
678
+ HandlerLoader.registerAllHandlers(~config, ~autoLoadFiles)
679
+ )
670
680
  registrationsRef := Some(promise)
671
681
  promise
672
682
  }
@@ -195,7 +195,6 @@ function makeInitialState(config, processConfigChains, addressRowsByChain, contr
195
195
  return {
196
196
  cleanRun: true,
197
197
  contractMapping: contractMapping,
198
- envioInfo: {},
199
198
  cache: {},
200
199
  chains: chains,
201
200
  checkpointFrontier: Frontier.empty(),
@@ -388,6 +387,8 @@ function makeInMemoryStorage(state) {
388
387
  name: "test-inmemory",
389
388
  isInitialized: async () => true,
390
389
  initialize: async (param, param$1, param$2, param$3, param$4) => Stdlib_JsError.throwWithMessage("TestIndexer: initialize should not be called; the initial state is derived from config."),
390
+ readStoredConfig: async () => Stdlib_JsError.throwWithMessage("TestIndexer: readStoredConfig should not be called; the initial state is derived from config."),
391
+ addChain: async (param, param$1, param$2) => Stdlib_JsError.throwWithMessage("TestIndexer: addChain should not be called; the initial state is derived from config."),
391
392
  resumeInitialState: async (param, param$1, param$2) => Stdlib_JsError.throwWithMessage("TestIndexer: resumeInitialState should not be called; the initial state is derived from config."),
392
393
  loadOrThrow: async (filter, table) => handleLoad(state, table.tableName, filter),
393
394
  ensureQueryIndexes: async (param, param$1, param$2) => {},
@@ -427,7 +428,7 @@ function getRegistrations(config) {
427
428
  if (promise !== undefined) {
428
429
  return promise;
429
430
  }
430
- let promise$1 = HandlerLoader.registerAllHandlers(config);
431
+ let promise$1 = HandlerLoader.getAutoLoadFiles(config).then(autoLoadFiles => HandlerLoader.registerAllHandlers(config, autoLoadFiles));
431
432
  registrationsRef.contents = promise$1;
432
433
  return promise$1;
433
434
  }
@@ -0,0 +1,121 @@
1
+ import module from "node:module";
2
+ import { fileURLToPath } from "node:url";
3
+ import { unsupportedNodeMessage } from "./NodeVersion.mjs";
4
+
5
+ const TS_URL = /\.[cm]?tsx?$/;
6
+ const JSON_URL = /\.json($|\?)/;
7
+ const NOT_FOUND_CODES = new Set([
8
+ "ERR_MODULE_NOT_FOUND",
9
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
10
+ "ERR_UNSUPPORTED_DIR_IMPORT",
11
+ ]);
12
+
13
+ let registered = false;
14
+
15
+ // Node's own resolver still resolves every candidate the addon offers, so
16
+ // package exports and conditions behave as they do without the hooks.
17
+ export const register = (addon) => {
18
+ if (registered) return;
19
+ registered = true;
20
+
21
+ // The CLI checks this first thing; a test indexer gets here without it.
22
+ const unsupported = unsupportedNodeMessage();
23
+ if (unsupported !== undefined) throw new Error(unsupported);
24
+
25
+ // Node ignores the source maps `loadTs` inlines unless this is on.
26
+ module.setSourceMapsSupport(true);
27
+
28
+ // What legacy decorators lower to; tslib's `__decorate`, `__param` and
29
+ // `__metadata`.
30
+ const helpers = (globalThis.babelHelpers ??= {});
31
+ // A function rather than an arrow: the argument count tells a class
32
+ // decorator from a member's.
33
+ helpers.decorate ??= function (decorators, target, key, descriptor) {
34
+ const argumentCount = arguments.length;
35
+ let result =
36
+ argumentCount < 3
37
+ ? target
38
+ : descriptor === null
39
+ ? (descriptor = Object.getOwnPropertyDescriptor(target, key))
40
+ : descriptor;
41
+ for (let index = decorators.length - 1; index >= 0; index--) {
42
+ const decorator = decorators[index];
43
+ if (decorator) {
44
+ result =
45
+ (argumentCount < 3
46
+ ? decorator(result)
47
+ : argumentCount > 3
48
+ ? decorator(target, key, result)
49
+ : decorator(target, key)) || result;
50
+ }
51
+ }
52
+ if (argumentCount > 3 && result) Object.defineProperty(target, key, result);
53
+ return result;
54
+ };
55
+ helpers.decorateParam ??= (index, decorator) => (target, key) => decorator(target, key, index);
56
+ helpers.decorateMetadata ??= (key, value) =>
57
+ typeof Reflect === "object" && typeof Reflect.metadata === "function"
58
+ ? Reflect.metadata(key, value)
59
+ : undefined;
60
+
61
+ const firstResolved = (candidates, context, nextResolve) => {
62
+ for (const candidate of candidates) {
63
+ try {
64
+ return nextResolve(candidate, context);
65
+ } catch (error) {
66
+ if (!NOT_FOUND_CODES.has(error?.code)) throw error;
67
+ }
68
+ }
69
+ return undefined;
70
+ };
71
+
72
+ module.registerHooks({
73
+ resolve(specifier, context, nextResolve) {
74
+ // Handlers are ES modules, so `require()` only comes from dependencies,
75
+ // including the one Node makes to read a CommonJS module's named
76
+ // exports. It resolves as it would without the hooks.
77
+ if (specifier.startsWith("node:") || context.conditions?.includes("require")) {
78
+ return nextResolve(specifier, context);
79
+ }
80
+ const [path, query] = specifier.split("?");
81
+ let resolved = firstResolved(
82
+ addon.tsResolveCandidates(path, context.parentURL ?? null),
83
+ context,
84
+ nextResolve
85
+ );
86
+ if (resolved === undefined) {
87
+ try {
88
+ resolved = nextResolve(path, context);
89
+ } catch (error) {
90
+ resolved =
91
+ NOT_FOUND_CODES.has(error?.code) &&
92
+ firstResolved(
93
+ addon.tsNotFoundCandidates(error.code, error.url ?? null, error.message),
94
+ context,
95
+ nextResolve
96
+ );
97
+ if (!resolved) throw error;
98
+ }
99
+ }
100
+ const url = query ? `${resolved.url}?${query}` : resolved.url;
101
+ // TypeScript's `resolveJsonModule` imports JSON without the
102
+ // `type: "json"` attribute Node requires.
103
+ if (JSON_URL.test(url) && context.importAttributes?.type === undefined) {
104
+ return {
105
+ ...resolved,
106
+ url,
107
+ importAttributes: { ...context.importAttributes, type: "json" },
108
+ shortCircuit: true,
109
+ };
110
+ }
111
+ return { ...resolved, url, shortCircuit: true };
112
+ },
113
+
114
+ load(url, context, nextLoad) {
115
+ if (!url.startsWith("file:") || !TS_URL.test(new URL(url).pathname)) {
116
+ return nextLoad(url, context);
117
+ }
118
+ return { format: "module", source: addon.loadTs(fileURLToPath(url)), shortCircuit: true };
119
+ },
120
+ });
121
+ };