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
@@ -1,21 +1,21 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Utils from "./Utils.res.mjs";
4
- import * as Js_exn from "rescript/lib/es6/js_exn.js";
5
4
  import * as Lodash from "./bindings/Lodash.res.mjs";
6
- import * as Js_dict from "rescript/lib/es6/js_dict.js";
7
- import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
8
- import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
9
- import * as Caml_option from "rescript/lib/es6/caml_option.js";
5
+ import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.js";
6
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
10
7
  import * as TableIndices from "./TableIndices.res.mjs";
11
8
  import * as ErrorHandling from "./ErrorHandling.res.mjs";
12
- import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
9
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
10
+ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
11
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
12
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
13
13
 
14
14
  function make(hash) {
15
15
  return {
16
- dict: {},
17
- hash: hash
18
- };
16
+ dict: {},
17
+ hash: hash
18
+ };
19
19
  }
20
20
 
21
21
  function set(self, key, value) {
@@ -39,115 +39,116 @@ function get(self, key) {
39
39
  }
40
40
 
41
41
  function values(self) {
42
- return Js_dict.values(self.dict);
42
+ return Object.values(self.dict);
43
43
  }
44
44
 
45
45
  function clone(self) {
46
46
  return {
47
- dict: Lodash.cloneDeep(self.dict),
48
- hash: self.hash
49
- };
47
+ dict: Lodash.cloneDeep(self.dict),
48
+ hash: self.hash
49
+ };
50
50
  }
51
51
 
52
- var UnexpectedIdNotDefinedOnEntity = /* @__PURE__ */Caml_exceptions.create("InMemoryTable.Entity.UnexpectedIdNotDefinedOnEntity");
52
+ let UnexpectedIdNotDefinedOnEntity = /* @__PURE__ */Primitive_exceptions.create("InMemoryTable.Entity.UnexpectedIdNotDefinedOnEntity");
53
53
 
54
54
  function getEntityIdUnsafe(entity) {
55
- var id = entity.id;
55
+ let id = entity.id;
56
56
  if (id !== undefined) {
57
57
  return id;
58
58
  } else {
59
59
  return ErrorHandling.mkLogAndRaise(undefined, "Property 'id' does not exist on expected entity object", {
60
- RE_EXN_ID: UnexpectedIdNotDefinedOnEntity
61
- });
60
+ RE_EXN_ID: UnexpectedIdNotDefinedOnEntity
61
+ });
62
62
  }
63
63
  }
64
64
 
65
65
  function makeIndicesSerializedToValue(index, relatedEntityIdsOpt) {
66
- var relatedEntityIds = relatedEntityIdsOpt !== undefined ? Caml_option.valFromOption(relatedEntityIdsOpt) : new Set();
67
- var empty_dict = {};
68
- var empty_hash = TableIndices.Index.toString;
69
- var empty = {
66
+ let relatedEntityIds = relatedEntityIdsOpt !== undefined ? Primitive_option.valFromOption(relatedEntityIdsOpt) : new Set();
67
+ let empty_dict = {};
68
+ let empty_hash = TableIndices.Index.toString;
69
+ let empty = {
70
70
  dict: empty_dict,
71
71
  hash: empty_hash
72
72
  };
73
73
  set(empty, index, [
74
- index,
75
- relatedEntityIds
76
- ]);
74
+ index,
75
+ relatedEntityIds
76
+ ]);
77
77
  return empty;
78
78
  }
79
79
 
80
80
  function make$1() {
81
81
  return {
82
- table: {
83
- dict: {},
84
- hash: (function (str) {
85
- return str;
86
- })
87
- },
88
- fieldNameIndices: {
89
- dict: {},
90
- hash: TableIndices.Index.getFieldName
91
- }
92
- };
82
+ table: {
83
+ dict: {},
84
+ hash: str => str
85
+ },
86
+ fieldNameIndices: {
87
+ dict: {},
88
+ hash: TableIndices.Index.getFieldName
89
+ }
90
+ };
93
91
  }
94
92
 
95
- var UndefinedKey = /* @__PURE__ */Caml_exceptions.create("InMemoryTable.Entity.UndefinedKey");
93
+ let UndefinedKey = /* @__PURE__ */Primitive_exceptions.create("InMemoryTable.Entity.UndefinedKey");
96
94
 
97
95
  function updateIndices(self, entity, entityIndices) {
98
- entityIndices.forEach(function (index) {
99
- var fieldName = TableIndices.Index.getFieldName(index);
100
- var fieldValue = Js_dict.get(entity, fieldName);
101
- if (!TableIndices.Index.evaluate(index, fieldName, fieldValue)) {
102
- entityIndices.delete(index);
103
- return ;
104
- }
105
-
96
+ entityIndices.forEach(index => {
97
+ let fieldName = TableIndices.Index.getFieldName(index);
98
+ let fieldValue = entity[fieldName];
99
+ if (!TableIndices.Index.evaluate(index, fieldName, fieldValue)) {
100
+ entityIndices.delete(index);
101
+ return;
102
+ }
103
+ });
104
+ Object.keys(self.fieldNameIndices.dict).forEach(fieldName => {
105
+ let match = entity[fieldName];
106
+ let match$1 = self.fieldNameIndices.dict[fieldName];
107
+ if (match === undefined) {
108
+ return ErrorHandling.mkLogAndRaise(undefined, "Expected field name to exist on the referenced index and the provided entity", {
109
+ RE_EXN_ID: UndefinedKey,
110
+ _1: fieldName
106
111
  });
107
- Belt_Array.forEach(Object.keys(self.fieldNameIndices.dict), (function (fieldName) {
108
- var match = Js_dict.get(entity, fieldName);
109
- var match$1 = Js_dict.get(self.fieldNameIndices.dict, fieldName);
110
- if (match !== undefined && match$1 !== undefined) {
111
- var fieldValue = Caml_option.valFromOption(match);
112
- return Belt_Array.forEach(Js_dict.values(match$1.dict), (function (param) {
113
- var relatedEntityIds = param[1];
114
- var index = param[0];
115
- if (TableIndices.Index.evaluate(index, fieldName, fieldValue)) {
116
- relatedEntityIds.add(getEntityIdUnsafe(entity));
117
- entityIndices.add(index);
118
- } else {
119
- relatedEntityIds.delete(getEntityIdUnsafe(entity));
120
- }
121
- }));
122
- }
123
- ErrorHandling.mkLogAndRaise(undefined, "Expected field name to exist on the referenced index and the provided entity", {
124
- RE_EXN_ID: UndefinedKey,
125
- _1: fieldName
126
- });
127
- }));
112
+ }
113
+ if (match$1 === undefined) {
114
+ return ErrorHandling.mkLogAndRaise(undefined, "Expected field name to exist on the referenced index and the provided entity", {
115
+ RE_EXN_ID: UndefinedKey,
116
+ _1: fieldName
117
+ });
118
+ }
119
+ let fieldValue = Primitive_option.valFromOption(match);
120
+ Object.values(match$1.dict).forEach(param => {
121
+ let relatedEntityIds = param[1];
122
+ let index = param[0];
123
+ if (TableIndices.Index.evaluate(index, fieldName, fieldValue)) {
124
+ relatedEntityIds.add(getEntityIdUnsafe(entity));
125
+ entityIndices.add(index);
126
+ } else {
127
+ relatedEntityIds.delete(getEntityIdUnsafe(entity));
128
+ }
129
+ });
130
+ });
128
131
  }
129
132
 
130
133
  function deleteEntityFromIndices(self, entityId, entityIndices) {
131
- entityIndices.forEach(function (index) {
132
- var match = Belt_Option.flatMap(get(self.fieldNameIndices, index), (function (__x) {
133
- return get(__x, index);
134
- }));
135
- if (match !== undefined) {
136
- match[1].delete(entityId);
137
- }
138
- entityIndices.delete(index);
139
- });
134
+ entityIndices.forEach(index => {
135
+ let match = Stdlib_Option.flatMap(get(self.fieldNameIndices, index), __x => get(__x, index));
136
+ if (match !== undefined) {
137
+ match[1].delete(entityId);
138
+ }
139
+ entityIndices.delete(index);
140
+ });
140
141
  }
141
142
 
142
143
  function initValue(inMemTable, key, entity, allowOverWriteEntityOpt) {
143
- var allowOverWriteEntity = allowOverWriteEntityOpt !== undefined ? allowOverWriteEntityOpt : false;
144
- var shouldWriteEntity = allowOverWriteEntity || Belt_Option.isNone(Js_dict.get(inMemTable.table.dict, inMemTable.table.hash(key)));
144
+ let allowOverWriteEntity = allowOverWriteEntityOpt !== undefined ? allowOverWriteEntityOpt : false;
145
+ let shouldWriteEntity = allowOverWriteEntity || Stdlib_Option.isNone(inMemTable.table.dict[inMemTable.table.hash(key)]);
145
146
  if (!shouldWriteEntity) {
146
- return ;
147
+ return;
147
148
  }
148
- var entityIndices = new Set();
149
+ let entityIndices = new Set();
149
150
  if (entity !== undefined) {
150
- updateIndices(inMemTable, Caml_option.valFromOption(entity), entityIndices);
151
+ updateIndices(inMemTable, Primitive_option.valFromOption(entity), entityIndices);
151
152
  }
152
153
  inMemTable.table.dict[inMemTable.table.hash(key)] = {
153
154
  latest: entity,
@@ -157,14 +158,14 @@ function initValue(inMemTable, key, entity, allowOverWriteEntityOpt) {
157
158
  }
158
159
 
159
160
  function set$1(inMemTable, change, shouldSaveHistory, containsRollbackDiffChangeOpt) {
160
- var containsRollbackDiffChange = containsRollbackDiffChangeOpt !== undefined ? containsRollbackDiffChangeOpt : false;
161
- var latest;
162
- latest = change.type === "SET" ? Caml_option.some(change.entity) : undefined;
163
- var match = get(inMemTable.table, change.entityId);
164
- var updatedEntityRecord;
161
+ let containsRollbackDiffChange = containsRollbackDiffChangeOpt !== undefined ? containsRollbackDiffChangeOpt : false;
162
+ let latest;
163
+ latest = change.type === "SET" ? Primitive_option.some(change.entity) : undefined;
164
+ let match = get(inMemTable.table, change.entityId);
165
+ let updatedEntityRecord;
165
166
  if (match !== undefined) {
166
- var previous_values = match.status;
167
- if (typeof previous_values !== "object") {
167
+ let previous_values = match.status;
168
+ if (previous_values === "Loaded") {
168
169
  updatedEntityRecord = {
169
170
  latest: latest,
170
171
  status: {
@@ -175,13 +176,13 @@ function set$1(inMemTable, change, shouldSaveHistory, containsRollbackDiffChange
175
176
  entityIndices: match.entityIndices
176
177
  };
177
178
  } else {
178
- var newStatus = {
179
+ let newStatus = {
179
180
  latestChange: change,
180
181
  history: shouldSaveHistory ? (
181
182
  previous_values.latestChange.checkpointId === change.checkpointId ? Utils.$$Array.setIndexImmutable(previous_values.history, previous_values.history.length - 1 | 0, change) : Belt_Array.concatMany([
182
- previous_values.history,
183
- [change]
184
- ])
183
+ previous_values.history,
184
+ [change]
185
+ ])
185
186
  ) : previous_values.history,
186
187
  containsRollbackDiffChange: previous_values.containsRollbackDiffChange
187
188
  };
@@ -215,125 +216,119 @@ function rowToEntity(row) {
215
216
  }
216
217
 
217
218
  function getUnsafe(inMemTable) {
218
- return function (key) {
219
- return inMemTable.table.dict[key].latest;
220
- };
219
+ return key => inMemTable.table.dict[key].latest;
221
220
  }
222
221
 
223
222
  function hasIndex(inMemTable, fieldName, operator) {
224
- return function (fieldValueHash) {
225
- var indicesSerializedToValue = inMemTable.fieldNameIndices.dict[fieldName];
223
+ return fieldValueHash => {
224
+ let indicesSerializedToValue = inMemTable.fieldNameIndices.dict[fieldName];
226
225
  if (indicesSerializedToValue === undefined) {
227
226
  return false;
228
227
  }
229
- var key = fieldName + ":" + operator + ":" + fieldValueHash;
228
+ let key = fieldName + `:` + operator + `:` + fieldValueHash;
230
229
  return indicesSerializedToValue.dict[key] !== undefined;
231
230
  };
232
231
  }
233
232
 
234
233
  function getUnsafeOnIndex(inMemTable, fieldName, operator) {
235
- var getEntity = getUnsafe(inMemTable);
236
- return function (fieldValueHash) {
237
- var indicesSerializedToValue = inMemTable.fieldNameIndices.dict[fieldName];
234
+ let getEntity = getUnsafe(inMemTable);
235
+ return fieldValueHash => {
236
+ let indicesSerializedToValue = inMemTable.fieldNameIndices.dict[fieldName];
238
237
  if (indicesSerializedToValue === undefined) {
239
- return Js_exn.raiseError("Unexpected error. Must have an index on field " + fieldName);
238
+ return Stdlib_JsError.throwWithMessage(`Unexpected error. Must have an index on field ` + fieldName);
240
239
  }
241
- var key = fieldName + ":" + operator + ":" + fieldValueHash;
242
- var match = indicesSerializedToValue.dict[key];
240
+ let key = fieldName + `:` + operator + `:` + fieldValueHash;
241
+ let match = indicesSerializedToValue.dict[key];
243
242
  if (match !== undefined) {
244
- return Belt_Array.keepMap(Array.from(match[1]), (function (entityId) {
245
- if (hasByHash(inMemTable.table, entityId)) {
246
- return getEntity(entityId);
247
- }
248
-
249
- }));
243
+ return Stdlib_Array.filterMap(Array.from(match[1]), entityId => {
244
+ if (hasByHash(inMemTable.table, entityId)) {
245
+ return getEntity(entityId);
246
+ }
247
+ });
250
248
  } else {
251
- return Js_exn.raiseError("Unexpected error. Must have an index for the value " + fieldValueHash + " on field " + fieldName);
249
+ return Stdlib_JsError.throwWithMessage(`Unexpected error. Must have an index for the value ` + fieldValueHash + ` on field ` + fieldName);
252
250
  }
253
251
  };
254
252
  }
255
253
 
256
254
  function addEmptyIndex(inMemTable, index) {
257
- var fieldName = TableIndices.Index.getFieldName(index);
258
- var relatedEntityIds = new Set();
259
- Belt_Array.forEach(Js_dict.values(inMemTable.table.dict), (function (row) {
260
- var entity = row.latest;
261
- if (entity === undefined) {
262
- return ;
263
- }
264
- var entity$1 = Caml_option.valFromOption(entity);
265
- var fieldValue = entity$1[fieldName];
266
- if (TableIndices.Index.evaluate(index, fieldName, fieldValue)) {
267
- row.entityIndices.add(index);
268
- relatedEntityIds.add(getEntityIdUnsafe(entity$1));
269
- return ;
270
- }
271
-
272
- }));
273
- var indicesSerializedToValue = get(inMemTable.fieldNameIndices, index);
255
+ let fieldName = TableIndices.Index.getFieldName(index);
256
+ let relatedEntityIds = new Set();
257
+ Object.values(inMemTable.table.dict).forEach(row => {
258
+ let entity = row.latest;
259
+ if (entity === undefined) {
260
+ return;
261
+ }
262
+ let entity$1 = Primitive_option.valFromOption(entity);
263
+ let fieldValue = entity$1[fieldName];
264
+ if (TableIndices.Index.evaluate(index, fieldName, fieldValue)) {
265
+ row.entityIndices.add(index);
266
+ relatedEntityIds.add(getEntityIdUnsafe(entity$1));
267
+ return;
268
+ }
269
+ });
270
+ let indicesSerializedToValue = get(inMemTable.fieldNameIndices, index);
274
271
  if (indicesSerializedToValue === undefined) {
275
- return set(inMemTable.fieldNameIndices, index, makeIndicesSerializedToValue(index, Caml_option.some(relatedEntityIds)));
272
+ return set(inMemTable.fieldNameIndices, index, makeIndicesSerializedToValue(index, Primitive_option.some(relatedEntityIds)));
276
273
  }
277
- var match = get(indicesSerializedToValue, index);
274
+ let match = get(indicesSerializedToValue, index);
278
275
  if (match !== undefined) {
279
- return ;
276
+ return;
280
277
  } else {
281
278
  return set(indicesSerializedToValue, index, [
282
- index,
283
- relatedEntityIds
284
- ]);
279
+ index,
280
+ relatedEntityIds
281
+ ]);
285
282
  }
286
283
  }
287
284
 
288
285
  function addIdToIndex(inMemTable, index, entityId) {
289
- var indicesSerializedToValue = get(inMemTable.fieldNameIndices, index);
286
+ let indicesSerializedToValue = get(inMemTable.fieldNameIndices, index);
290
287
  if (indicesSerializedToValue === undefined) {
291
- return set(inMemTable.fieldNameIndices, index, makeIndicesSerializedToValue(index, Caml_option.some(new Set().add(entityId))));
288
+ return set(inMemTable.fieldNameIndices, index, makeIndicesSerializedToValue(index, Primitive_option.some(new Set().add(entityId))));
292
289
  }
293
- var match = get(indicesSerializedToValue, index);
290
+ let match = get(indicesSerializedToValue, index);
294
291
  if (match !== undefined) {
295
292
  match[1].add(entityId);
296
- return ;
293
+ return;
297
294
  } else {
298
295
  return set(indicesSerializedToValue, index, [
299
- index,
300
- new Set().add(entityId)
301
- ]);
296
+ index,
297
+ new Set().add(entityId)
298
+ ]);
302
299
  }
303
300
  }
304
301
 
305
302
  function updates(inMemTable) {
306
- return Belt_Array.keepMapU(Js_dict.values(inMemTable.table.dict), (function (v) {
307
- var update = v.status;
308
- if (typeof update !== "object") {
309
- return ;
310
- } else {
311
- return update;
312
- }
313
- }));
303
+ return Stdlib_Array.filterMap(Object.values(inMemTable.table.dict), v => {
304
+ let update = v.status;
305
+ if (update === "Loaded") {
306
+ return;
307
+ } else {
308
+ return update;
309
+ }
310
+ });
314
311
  }
315
312
 
316
313
  function values$1(inMemTable) {
317
- return Belt_Array.keepMap(Js_dict.values(inMemTable.table.dict), rowToEntity);
314
+ return Stdlib_Array.filterMap(Object.values(inMemTable.table.dict), rowToEntity);
318
315
  }
319
316
 
320
317
  function clone$1(param) {
321
- var fieldNameIndices = param.fieldNameIndices;
318
+ let fieldNameIndices = param.fieldNameIndices;
322
319
  return {
323
- table: clone(param.table),
324
- fieldNameIndices: {
325
- dict: Js_dict.fromArray(Belt_Array.map(Js_dict.entries(fieldNameIndices.dict), (function (param) {
326
- return [
327
- param[0],
328
- clone(param[1])
329
- ];
330
- }))),
331
- hash: fieldNameIndices.hash
332
- }
333
- };
320
+ table: clone(param.table),
321
+ fieldNameIndices: {
322
+ dict: Object.fromEntries(Object.entries(fieldNameIndices.dict).map(param => [
323
+ param[0],
324
+ clone(param[1])
325
+ ])),
326
+ hash: fieldNameIndices.hash
327
+ }
328
+ };
334
329
  }
335
330
 
336
- var Entity = {
331
+ let Entity = {
337
332
  UnexpectedIdNotDefinedOnEntity: UnexpectedIdNotDefinedOnEntity,
338
333
  getEntityIdUnsafe: getEntityIdUnsafe,
339
334
  makeIndicesSerializedToValue: makeIndicesSerializedToValue,
@@ -357,14 +352,14 @@ var Entity = {
357
352
  };
358
353
 
359
354
  export {
360
- make ,
361
- set ,
362
- setByHash ,
363
- hasByHash ,
364
- getUnsafeByHash ,
365
- get ,
366
- values ,
367
- clone ,
368
- Entity ,
355
+ make,
356
+ set,
357
+ setByHash,
358
+ hasByHash,
359
+ getUnsafeByHash,
360
+ get,
361
+ values,
362
+ clone,
363
+ Entity,
369
364
  }
370
365
  /* Utils Not a pure module */