envio 2.31.1 → 2.32.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.
@@ -688,19 +688,34 @@ var ProgressBatchCount = {
688
688
  increment: increment$5
689
689
  };
690
690
 
691
+ var gauge$20 = makeOrThrow$1("envio_progress_latency", "The latency in milliseconds between the latest processed event creation and the time it was written to storage.", chainIdLabelsSchema);
692
+
693
+ function set$19(latencyMs, chainId) {
694
+ handleInt$1(gauge$20, chainId, latencyMs);
695
+ }
696
+
697
+ var ProgressLatency = {
698
+ gauge: gauge$20,
699
+ set: set$19
700
+ };
701
+
691
702
  var effectLabelsSchema = S$RescriptSchema.object(function (s) {
692
703
  return s.f("effect", S$RescriptSchema.string);
693
704
  });
694
705
 
695
- var gauge$20 = makeOrThrow$1("envio_effect_calls_count", "The number of calls to the effect. Including both handler execution and cache hits.", effectLabelsSchema);
706
+ var timeCounter$2 = makeOrThrow("envio_effect_calls_time", "Processing time taken to call the Effect function. (milliseconds)", effectLabelsSchema);
696
707
 
697
- function set$19(callsCount, effectName) {
698
- handleInt$1(gauge$20, effectName, callsCount);
699
- }
708
+ var sumTimeCounter = makeOrThrow("envio_effect_calls_sum_time", "Cumulative time spent calling the Effect function during the indexing process. (milliseconds)", effectLabelsSchema);
700
709
 
701
- var EffectCallsCount = {
702
- gauge: gauge$20,
703
- set: set$19
710
+ var totalCallsCount = makeOrThrow("envio_effect_calls_count", "Cumulative number of resolved Effect function calls during the indexing process.", effectLabelsSchema);
711
+
712
+ var activeCallsCount = makeOrThrow$1("envio_effect_active_calls_count", "The number of Effect function calls that are currently running.", effectLabelsSchema);
713
+
714
+ var EffectCalls = {
715
+ timeCounter: timeCounter$2,
716
+ sumTimeCounter: sumTimeCounter,
717
+ totalCallsCount: totalCallsCount,
718
+ activeCallsCount: activeCallsCount
704
719
  };
705
720
 
706
721
  var gauge$21 = makeOrThrow$1("envio_effect_cache_count", "The number of items in the effect cache.", effectLabelsSchema);
@@ -725,13 +740,24 @@ var EffectCacheInvalidationsCount = {
725
740
  increment: increment$6
726
741
  };
727
742
 
743
+ var gauge$22 = makeOrThrow$1("envio_effect_queue_count", "The number of effect calls waiting in the rate limit queue.", effectLabelsSchema);
744
+
745
+ function set$21(count, effectName) {
746
+ handleInt$1(gauge$22, effectName, count);
747
+ }
748
+
749
+ var EffectQueueCount = {
750
+ gauge: gauge$22,
751
+ set: set$21
752
+ };
753
+
728
754
  var operationLabelsSchema = S$RescriptSchema.object(function (s) {
729
755
  return s.f("operation", S$RescriptSchema.string);
730
756
  });
731
757
 
732
- var timeCounter$2 = makeOrThrow("envio_storage_load_time", "Processing time taken to load data from storage. (milliseconds)", operationLabelsSchema);
758
+ var timeCounter$3 = makeOrThrow("envio_storage_load_time", "Processing time taken to load data from storage. (milliseconds)", operationLabelsSchema);
733
759
 
734
- var totalTimeCounter = makeOrThrow("envio_storage_load_total_time", "Cumulative time spent loading data from storage during the indexing process. (milliseconds)", operationLabelsSchema);
760
+ var sumTimeCounter$1 = makeOrThrow("envio_storage_load_sum_time", "Cumulative time spent loading data from storage during the indexing process. (milliseconds)", operationLabelsSchema);
735
761
 
736
762
  var counter$7 = makeOrThrow("envio_storage_load_count", "Cumulative number of successful storage load operations during the indexing process.", operationLabelsSchema);
737
763
 
@@ -758,10 +784,10 @@ function endOperation(timerRef, operation, whereSize, size) {
758
784
  var operationRef = operations[operation];
759
785
  operationRef.pendingCount = operationRef.pendingCount - 1 | 0;
760
786
  if (operationRef.pendingCount === 0) {
761
- handleInt(timeCounter$2, operation, Hrtime.intFromMillis(Hrtime.toMillis(Hrtime.timeSince(operationRef.timerRef))));
787
+ handleInt(timeCounter$3, operation, Hrtime.intFromMillis(Hrtime.toMillis(Hrtime.timeSince(operationRef.timerRef))));
762
788
  Utils.Dict.deleteInPlace(operations, operation);
763
789
  }
764
- handleInt(totalTimeCounter, operation, Hrtime.intFromMillis(Hrtime.toMillis(Hrtime.timeSince(timerRef))));
790
+ handleInt(sumTimeCounter$1, operation, Hrtime.intFromMillis(Hrtime.toMillis(Hrtime.timeSince(timerRef))));
765
791
  increment(counter$7, operation);
766
792
  handleInt(whereSizeCounter, operation, whereSize);
767
793
  handleInt(sizeCounter, operation, size);
@@ -769,8 +795,8 @@ function endOperation(timerRef, operation, whereSize, size) {
769
795
 
770
796
  var StorageLoad = {
771
797
  operationLabelsSchema: operationLabelsSchema,
772
- timeCounter: timeCounter$2,
773
- totalTimeCounter: totalTimeCounter,
798
+ timeCounter: timeCounter$3,
799
+ sumTimeCounter: sumTimeCounter$1,
774
800
  counter: counter$7,
775
801
  whereSizeCounter: whereSizeCounter,
776
802
  sizeCounter: sizeCounter,
@@ -824,9 +850,11 @@ exports.ProcessingMaxBatchSize = ProcessingMaxBatchSize;
824
850
  exports.ProgressBlockNumber = ProgressBlockNumber;
825
851
  exports.ProgressEventsCount = ProgressEventsCount;
826
852
  exports.ProgressBatchCount = ProgressBatchCount;
853
+ exports.ProgressLatency = ProgressLatency;
827
854
  exports.effectLabelsSchema = effectLabelsSchema;
828
- exports.EffectCallsCount = EffectCallsCount;
855
+ exports.EffectCalls = EffectCalls;
829
856
  exports.EffectCacheCount = EffectCacheCount;
830
857
  exports.EffectCacheInvalidationsCount = EffectCacheInvalidationsCount;
858
+ exports.EffectQueueCount = EffectQueueCount;
831
859
  exports.StorageLoad = StorageLoad;
832
860
  /* loadEntitiesDurationCounter Not a pure module */
@@ -0,0 +1,110 @@
1
+ module FieldValue = {
2
+ open Belt
3
+ @unboxed
4
+ type rec tNonOptional =
5
+ | String(string)
6
+ | BigInt(bigint)
7
+ | Int(int)
8
+ | BigDecimal(BigDecimal.t)
9
+ | Bool(bool)
10
+ | Array(array<tNonOptional>)
11
+
12
+ let rec toString = tNonOptional =>
13
+ switch tNonOptional {
14
+ | String(v) => v
15
+ | BigInt(v) => v->BigInt.toString
16
+ | Int(v) => v->Int.toString
17
+ | BigDecimal(v) => v->BigDecimal.toString
18
+ | Bool(v) => v ? "true" : "false"
19
+ | Array(v) => `[${v->Array.joinWith(",", toString)}]`
20
+ }
21
+
22
+ //This needs to be a castable type from any type that we
23
+ //support in entities so that we can create evaluations
24
+ //and serialize the types without parsing/wrapping them
25
+ type t = option<tNonOptional>
26
+
27
+ let toString = (value: t) =>
28
+ switch value {
29
+ | Some(v) => v->toString
30
+ | None => "undefined"
31
+ }
32
+
33
+ external castFrom: 'a => t = "%identity"
34
+ external castTo: t => 'a = "%identity"
35
+
36
+ let eq = (a, b) =>
37
+ switch (a, b) {
38
+ //For big decimal use custom equals operator otherwise let Caml_obj.equal do its magic
39
+ | (Some(BigDecimal(bdA)), Some(BigDecimal(bdB))) => BigDecimal.equals(bdA, bdB)
40
+ | (a, b) => a == b
41
+ }
42
+
43
+ let gt = (a, b) =>
44
+ switch (a, b) {
45
+ //For big decimal use custom equals operator otherwise let Caml_obj.equal do its magic
46
+ | (Some(BigDecimal(bdA)), Some(BigDecimal(bdB))) => BigDecimal.gt(bdA, bdB)
47
+ | (a, b) => a > b
48
+ }
49
+
50
+ let lt = (a, b) =>
51
+ switch (a, b) {
52
+ //For big decimal use custom equals operator otherwise let Caml_obj.equal do its magic
53
+ | (Some(BigDecimal(bdA)), Some(BigDecimal(bdB))) => BigDecimal.lt(bdA, bdB)
54
+ | (a, b) => a < b
55
+ }
56
+ }
57
+
58
+ module Operator = {
59
+ type t = Eq | Gt | Lt
60
+
61
+ let values = [Eq, Gt, Lt]
62
+ }
63
+
64
+ module SingleIndex = {
65
+ type t = {fieldName: string, fieldValue: FieldValue.t, operator: Operator.t}
66
+
67
+ let make = (~fieldName, ~fieldValue: 'a, ~operator) => {
68
+ fieldName,
69
+ fieldValue: FieldValue.castFrom(fieldValue),
70
+ operator,
71
+ }
72
+
73
+ // Should much hashing logic in InMemoryTable
74
+ let toString = ({fieldName, fieldValue, operator}) =>
75
+ `${fieldName}:${(operator :> string)}:${fieldValue->FieldValue.toString}`
76
+
77
+ let evaluate = (self: t, ~fieldName, ~fieldValue) =>
78
+ self.fieldName === fieldName &&
79
+ switch self.operator {
80
+ | Eq => fieldValue->FieldValue.eq(self.fieldValue)
81
+ | Gt => fieldValue->FieldValue.gt(self.fieldValue)
82
+ | Lt => fieldValue->FieldValue.lt(self.fieldValue)
83
+ }
84
+ }
85
+
86
+ module Index = {
87
+ //Next step is to support composite indexes
88
+ @unboxed
89
+ type t = Single(SingleIndex.t) //| Composite(array<SingleIndex.t>)
90
+
91
+ let makeSingle = (~fieldName, ~fieldValue, ~operator) => Single(
92
+ SingleIndex.make(~fieldName, ~fieldValue, ~operator),
93
+ )
94
+
95
+ let getFieldName = index =>
96
+ switch index {
97
+ | Single(index) => index.fieldName
98
+ }
99
+
100
+ let toString = index =>
101
+ switch index {
102
+ | Single(index) => index->SingleIndex.toString
103
+ }
104
+
105
+ let evaluate = (index: t, ~fieldName, ~fieldValue) =>
106
+ switch index {
107
+ | Single(index) => SingleIndex.evaluate(index, ~fieldName, ~fieldValue)
108
+ }
109
+ }
110
+
@@ -0,0 +1,143 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var Caml_obj = require("rescript/lib/js/caml_obj.js");
5
+ var Belt_Array = require("rescript/lib/js/belt_Array.js");
6
+
7
+ function toString(tNonOptional) {
8
+ if (Array.isArray(tNonOptional)) {
9
+ return "[" + Belt_Array.joinWith(tNonOptional, ",", toString) + "]";
10
+ }
11
+ switch (typeof tNonOptional) {
12
+ case "string" :
13
+ return tNonOptional;
14
+ case "number" :
15
+ return String(tNonOptional);
16
+ case "bigint" :
17
+ case "object" :
18
+ return tNonOptional.toString();
19
+ case "boolean" :
20
+ if (tNonOptional) {
21
+ return "true";
22
+ } else {
23
+ return "false";
24
+ }
25
+
26
+ }
27
+ }
28
+
29
+ function toString$1(value) {
30
+ if (value !== undefined) {
31
+ return toString(value);
32
+ } else {
33
+ return "undefined";
34
+ }
35
+ }
36
+
37
+ function eq(a, b) {
38
+ if (a !== undefined && typeof a === "object" && !Array.isArray(a) && b !== undefined && typeof b === "object" && !Array.isArray(b)) {
39
+ return a.isEqualTo(b);
40
+ } else {
41
+ return Caml_obj.equal(a, b);
42
+ }
43
+ }
44
+
45
+ function gt(a, b) {
46
+ if (a !== undefined && typeof a === "object" && !Array.isArray(a) && b !== undefined && typeof b === "object" && !Array.isArray(b)) {
47
+ return a.isGreaterThan(b);
48
+ } else {
49
+ return Caml_obj.greaterthan(a, b);
50
+ }
51
+ }
52
+
53
+ function lt(a, b) {
54
+ if (a !== undefined && typeof a === "object" && !Array.isArray(a) && b !== undefined && typeof b === "object" && !Array.isArray(b)) {
55
+ return a.isLessThan(b);
56
+ } else {
57
+ return Caml_obj.lessthan(a, b);
58
+ }
59
+ }
60
+
61
+ var FieldValue = {
62
+ toString: toString$1,
63
+ eq: eq,
64
+ gt: gt,
65
+ lt: lt
66
+ };
67
+
68
+ var values = [
69
+ "Eq",
70
+ "Gt",
71
+ "Lt"
72
+ ];
73
+
74
+ var Operator = {
75
+ values: values
76
+ };
77
+
78
+ function make(fieldName, fieldValue, operator) {
79
+ return {
80
+ fieldName: fieldName,
81
+ fieldValue: fieldValue,
82
+ operator: operator
83
+ };
84
+ }
85
+
86
+ function toString$2(param) {
87
+ return param.fieldName + ":" + param.operator + ":" + toString$1(param.fieldValue);
88
+ }
89
+
90
+ function evaluate(self, fieldName, fieldValue) {
91
+ if (self.fieldName !== fieldName) {
92
+ return false;
93
+ }
94
+ var match = self.operator;
95
+ switch (match) {
96
+ case "Eq" :
97
+ return eq(fieldValue, self.fieldValue);
98
+ case "Gt" :
99
+ return gt(fieldValue, self.fieldValue);
100
+ case "Lt" :
101
+ return lt(fieldValue, self.fieldValue);
102
+
103
+ }
104
+ }
105
+
106
+ var SingleIndex = {
107
+ make: make,
108
+ toString: toString$2,
109
+ evaluate: evaluate
110
+ };
111
+
112
+ function makeSingle(fieldName, fieldValue, operator) {
113
+ return {
114
+ fieldName: fieldName,
115
+ fieldValue: fieldValue,
116
+ operator: operator
117
+ };
118
+ }
119
+
120
+ function getFieldName(index) {
121
+ return index.fieldName;
122
+ }
123
+
124
+ function toString$3(index) {
125
+ return toString$2(index);
126
+ }
127
+
128
+ function evaluate$1(index, fieldName, fieldValue) {
129
+ return evaluate(index, fieldName, fieldValue);
130
+ }
131
+
132
+ var Index = {
133
+ makeSingle: makeSingle,
134
+ getFieldName: getFieldName,
135
+ toString: toString$3,
136
+ evaluate: evaluate$1
137
+ };
138
+
139
+ exports.FieldValue = FieldValue;
140
+ exports.Operator = Operator;
141
+ exports.SingleIndex = SingleIndex;
142
+ exports.Index = Index;
143
+ /* No side effect */
package/src/Types.ts CHANGED
@@ -44,6 +44,11 @@ export type EffectContext = {
44
44
  * Define a new Effect using createEffect outside of the handler.
45
45
  */
46
46
  readonly effect: EffectCaller;
47
+ /**
48
+ * Whether to cache the result of the effect. Defaults to the effect's cache configuration.
49
+ * Set to false to disable caching for this specific call.
50
+ */
51
+ cache: boolean;
47
52
  };
48
53
 
49
54
  export type GenericContractRegister<Args> = (
@@ -0,0 +1,3 @@
1
+ // TODO: Remove this file once we have our own impl of cloneDeep or it is no longer needed
2
+ @module("./vendored-lodash-fns.js") external cloneDeep: 'a => 'a = "cloneDeep"
3
+
@@ -0,0 +1,11 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var VendoredLodashFnsJs = require("./vendored-lodash-fns.js");
5
+
6
+ function cloneDeep(prim) {
7
+ return VendoredLodashFnsJs.cloneDeep(prim);
8
+ }
9
+
10
+ exports.cloneDeep = cloneDeep;
11
+ /* ./vendored-lodash-fns.js Not a pure module */