@eclesia/indexer-engine 2.9.9 → 2.10.0-next.1

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 (65) hide show
  1. package/dist/constants.cjs +74 -0
  2. package/dist/constants.cjs.map +1 -0
  3. package/dist/constants.d.cts +68 -0
  4. package/dist/constants.d.cts.map +1 -0
  5. package/dist/constants.d.ts +68 -0
  6. package/dist/constants.d.ts.map +1 -0
  7. package/dist/constants.js +64 -0
  8. package/dist/constants.js.map +1 -0
  9. package/dist/emitter/index.cjs +0 -1
  10. package/dist/emitter/index.cjs.map +1 -1
  11. package/dist/errors/index.cjs +107 -0
  12. package/dist/errors/index.cjs.map +1 -0
  13. package/dist/errors/index.d.cts +75 -0
  14. package/dist/errors/index.d.cts.map +1 -0
  15. package/dist/errors/index.d.ts +75 -0
  16. package/dist/errors/index.d.ts.map +1 -0
  17. package/dist/errors/index.js +100 -0
  18. package/dist/errors/index.js.map +1 -0
  19. package/dist/index.cjs +38 -10
  20. package/dist/index.d.cts +5 -1
  21. package/dist/index.d.ts +5 -1
  22. package/dist/index.js +5 -1
  23. package/dist/indexer/index.cjs +51 -27
  24. package/dist/indexer/index.cjs.map +1 -1
  25. package/dist/indexer/index.d.cts +1 -0
  26. package/dist/indexer/index.d.cts.map +1 -1
  27. package/dist/indexer/index.d.ts +1 -0
  28. package/dist/indexer/index.d.ts.map +1 -1
  29. package/dist/indexer/index.js +51 -20
  30. package/dist/indexer/index.js.map +1 -1
  31. package/dist/metrics/index.cjs +146 -0
  32. package/dist/metrics/index.cjs.map +1 -0
  33. package/dist/metrics/index.d.cts +56 -0
  34. package/dist/metrics/index.d.cts.map +1 -0
  35. package/dist/metrics/index.d.ts +56 -0
  36. package/dist/metrics/index.d.ts.map +1 -0
  37. package/dist/metrics/index.js +145 -0
  38. package/dist/metrics/index.js.map +1 -0
  39. package/dist/promise-queue/index.cjs +6 -4
  40. package/dist/promise-queue/index.cjs.map +1 -1
  41. package/dist/promise-queue/index.d.cts +6 -2
  42. package/dist/promise-queue/index.d.cts.map +1 -1
  43. package/dist/promise-queue/index.d.ts +6 -2
  44. package/dist/promise-queue/index.d.ts.map +1 -1
  45. package/dist/promise-queue/index.js +6 -4
  46. package/dist/promise-queue/index.js.map +1 -1
  47. package/dist/types/index.cjs.map +1 -1
  48. package/dist/types/index.d.cts +6 -0
  49. package/dist/types/index.d.cts.map +1 -1
  50. package/dist/types/index.d.ts +6 -0
  51. package/dist/types/index.d.ts.map +1 -1
  52. package/dist/types/index.js.map +1 -1
  53. package/dist/utils/bech32.cjs +0 -1
  54. package/dist/utils/bech32.cjs.map +1 -1
  55. package/dist/utils/index.cjs.map +1 -1
  56. package/dist/utils/index.js.map +1 -1
  57. package/dist/validation/index.cjs +150 -0
  58. package/dist/validation/index.cjs.map +1 -0
  59. package/dist/validation/index.d.cts +52 -0
  60. package/dist/validation/index.d.cts.map +1 -0
  61. package/dist/validation/index.d.ts +52 -0
  62. package/dist/validation/index.d.ts.map +1 -0
  63. package/dist/validation/index.js +140 -0
  64. package/dist/validation/index.js.map +1 -0
  65. package/package.json +3 -1
@@ -0,0 +1,145 @@
1
+ import { Counter, Gauge, Histogram, Registry, collectDefaultMetrics } from "prom-client";
2
+
3
+ //#region src/metrics/index.ts
4
+ /**
5
+ * Prometheus metrics for monitoring indexer performance and health
6
+ * Exposes metrics for blocks indexed, queue depth, errors, and processing times
7
+ */
8
+ /** Prometheus metrics registry */
9
+ var IndexerMetrics = class {
10
+ constructor() {
11
+ this.registry = new Registry();
12
+ collectDefaultMetrics({ register: this.registry });
13
+ this.blocksIndexed = new Counter({
14
+ name: "indexer_blocks_indexed_total",
15
+ help: "Total number of blocks indexed",
16
+ registers: [this.registry]
17
+ });
18
+ this.currentHeight = new Gauge({
19
+ name: "indexer_current_height",
20
+ help: "Current block height being processed",
21
+ registers: [this.registry]
22
+ });
23
+ this.latestHeight = new Gauge({
24
+ name: "indexer_latest_chain_height",
25
+ help: "Latest block height on the chain",
26
+ registers: [this.registry]
27
+ });
28
+ this.blocksBehind = new Gauge({
29
+ name: "indexer_blocks_behind",
30
+ help: "Number of blocks behind chain tip",
31
+ registers: [this.registry]
32
+ });
33
+ this.queueDepth = new Gauge({
34
+ name: "indexer_queue_depth",
35
+ help: "Current depth of block processing queue",
36
+ registers: [this.registry]
37
+ });
38
+ this.errors = new Counter({
39
+ name: "indexer_errors_total",
40
+ help: "Total number of indexer errors",
41
+ labelNames: ["type"],
42
+ registers: [this.registry]
43
+ });
44
+ this.rpcErrors = new Counter({
45
+ name: "indexer_rpc_errors_total",
46
+ help: "Total number of RPC errors",
47
+ registers: [this.registry]
48
+ });
49
+ this.databaseErrors = new Counter({
50
+ name: "indexer_database_errors_total",
51
+ help: "Total number of database errors",
52
+ registers: [this.registry]
53
+ });
54
+ this.blockProcessingDuration = new Histogram({
55
+ name: "indexer_block_processing_duration_seconds",
56
+ help: "Time spent processing a single block",
57
+ buckets: [
58
+ .001,
59
+ .005,
60
+ .01,
61
+ .05,
62
+ .1,
63
+ .5,
64
+ 1,
65
+ 2,
66
+ 5
67
+ ],
68
+ registers: [this.registry]
69
+ });
70
+ this.rpcCallDuration = new Histogram({
71
+ name: "indexer_rpc_call_duration_seconds",
72
+ help: "Duration of RPC calls",
73
+ buckets: [
74
+ .01,
75
+ .05,
76
+ .1,
77
+ .5,
78
+ 1,
79
+ 2,
80
+ 5,
81
+ 10
82
+ ],
83
+ labelNames: ["method"],
84
+ registers: [this.registry]
85
+ });
86
+ this.databaseQueryDuration = new Histogram({
87
+ name: "indexer_database_query_duration_seconds",
88
+ help: "Duration of database queries",
89
+ buckets: [
90
+ .001,
91
+ .005,
92
+ .01,
93
+ .05,
94
+ .1,
95
+ .5,
96
+ 1
97
+ ],
98
+ labelNames: ["query_type"],
99
+ registers: [this.registry]
100
+ });
101
+ this.retryCount = new Gauge({
102
+ name: "indexer_retry_count",
103
+ help: "Current number of retry attempts",
104
+ registers: [this.registry]
105
+ });
106
+ this.transactionsProcessed = new Counter({
107
+ name: "indexer_transactions_processed_total",
108
+ help: "Total number of transactions processed",
109
+ registers: [this.registry]
110
+ });
111
+ }
112
+ /**
113
+ * Updates block indexing metrics
114
+ * @param currentHeight - Current height being processed
115
+ * @param latestHeight - Latest height on chain
116
+ * @param queueSize - Current queue depth
117
+ */
118
+ updateBlockMetrics(currentHeight, latestHeight, queueSize) {
119
+ this.blocksIndexed.inc();
120
+ this.currentHeight.set(currentHeight);
121
+ this.latestHeight.set(latestHeight);
122
+ this.blocksBehind.set(latestHeight - currentHeight);
123
+ this.queueDepth.set(queueSize);
124
+ }
125
+ /**
126
+ * Records an error occurrence
127
+ * @param type - Error type (rpc, database, processing, etc.)
128
+ */
129
+ recordError(type) {
130
+ this.errors.inc({ type });
131
+ if (type === "rpc") this.rpcErrors.inc();
132
+ else if (type === "database") this.databaseErrors.inc();
133
+ }
134
+ /**
135
+ * Gets metrics in Prometheus format
136
+ * @returns Prometheus metrics string
137
+ */
138
+ async getMetrics() {
139
+ return this.registry.metrics();
140
+ }
141
+ };
142
+
143
+ //#endregion
144
+ export { IndexerMetrics };
145
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/metrics/index.ts"],"sourcesContent":["/**\n * Prometheus metrics for monitoring indexer performance and health\n * Exposes metrics for blocks indexed, queue depth, errors, and processing times\n */\n\nimport {\n collectDefaultMetrics, Counter, Gauge, Histogram, Registry,\n} from \"prom-client\";\n\n/** Prometheus metrics registry */\nexport class IndexerMetrics {\n /** Prometheus registry instance */\n public readonly registry: Registry;\n\n /** Counter for total blocks indexed */\n public readonly blocksIndexed: Counter;\n\n /** Gauge for current block height */\n public readonly currentHeight: Gauge;\n\n /** Gauge for latest chain block height */\n public readonly latestHeight: Gauge;\n\n /** Gauge for blocks behind chain tip */\n public readonly blocksBehind: Gauge;\n\n /** Gauge for block queue depth */\n public readonly queueDepth: Gauge;\n\n /** Counter for total errors */\n public readonly errors: Counter;\n\n /** Counter for RPC errors */\n public readonly rpcErrors: Counter;\n\n /** Counter for database errors */\n public readonly databaseErrors: Counter;\n\n /** Histogram for block processing duration */\n public readonly blockProcessingDuration: Histogram;\n\n /** Histogram for RPC call duration */\n public readonly rpcCallDuration: Histogram;\n\n /** Histogram for database query duration */\n public readonly databaseQueryDuration: Histogram;\n\n /** Gauge for retry count */\n public readonly retryCount: Gauge;\n\n /** Counter for total transactions processed */\n public readonly transactionsProcessed: Counter;\n\n constructor() {\n this.registry = new Registry();\n\n // Collect default Node.js metrics (memory, CPU, etc.)\n collectDefaultMetrics({\n register: this.registry,\n });\n\n // Block indexing metrics\n this.blocksIndexed = new Counter({\n name: \"indexer_blocks_indexed_total\",\n help: \"Total number of blocks indexed\",\n registers: [this.registry],\n });\n\n this.currentHeight = new Gauge({\n name: \"indexer_current_height\",\n help: \"Current block height being processed\",\n registers: [this.registry],\n });\n\n this.latestHeight = new Gauge({\n name: \"indexer_latest_chain_height\",\n help: \"Latest block height on the chain\",\n registers: [this.registry],\n });\n\n this.blocksBehind = new Gauge({\n name: \"indexer_blocks_behind\",\n help: \"Number of blocks behind chain tip\",\n registers: [this.registry],\n });\n\n this.queueDepth = new Gauge({\n name: \"indexer_queue_depth\",\n help: \"Current depth of block processing queue\",\n registers: [this.registry],\n });\n\n // Error metrics\n this.errors = new Counter({\n name: \"indexer_errors_total\",\n help: \"Total number of indexer errors\",\n labelNames: [\"type\"],\n registers: [this.registry],\n });\n\n this.rpcErrors = new Counter({\n name: \"indexer_rpc_errors_total\",\n help: \"Total number of RPC errors\",\n registers: [this.registry],\n });\n\n this.databaseErrors = new Counter({\n name: \"indexer_database_errors_total\",\n help: \"Total number of database errors\",\n registers: [this.registry],\n });\n\n // Performance metrics\n this.blockProcessingDuration = new Histogram({\n name: \"indexer_block_processing_duration_seconds\",\n help: \"Time spent processing a single block\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5],\n registers: [this.registry],\n });\n\n this.rpcCallDuration = new Histogram({\n name: \"indexer_rpc_call_duration_seconds\",\n help: \"Duration of RPC calls\",\n buckets: [0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10],\n labelNames: [\"method\"],\n registers: [this.registry],\n });\n\n this.databaseQueryDuration = new Histogram({\n name: \"indexer_database_query_duration_seconds\",\n help: \"Duration of database queries\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1],\n labelNames: [\"query_type\"],\n registers: [this.registry],\n });\n\n // Operational metrics\n this.retryCount = new Gauge({\n name: \"indexer_retry_count\",\n help: \"Current number of retry attempts\",\n registers: [this.registry],\n });\n\n this.transactionsProcessed = new Counter({\n name: \"indexer_transactions_processed_total\",\n help: \"Total number of transactions processed\",\n registers: [this.registry],\n });\n }\n\n /**\n * Updates block indexing metrics\n * @param currentHeight - Current height being processed\n * @param latestHeight - Latest height on chain\n * @param queueSize - Current queue depth\n */\n updateBlockMetrics(currentHeight: number, latestHeight: number, queueSize: number) {\n this.blocksIndexed.inc();\n this.currentHeight.set(currentHeight);\n this.latestHeight.set(latestHeight);\n this.blocksBehind.set(latestHeight - currentHeight);\n this.queueDepth.set(queueSize);\n }\n\n /**\n * Records an error occurrence\n * @param type - Error type (rpc, database, processing, etc.)\n */\n recordError(type: string) {\n this.errors.inc({\n type,\n });\n\n if (type === \"rpc\") {\n this.rpcErrors.inc();\n }\n else if (type === \"database\") {\n this.databaseErrors.inc();\n }\n }\n\n /**\n * Gets metrics in Prometheus format\n * @returns Prometheus metrics string\n */\n async getMetrics(): Promise<string> {\n return this.registry.metrics();\n }\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,iBAAb,MAA4B;CA2C1B,cAAc;AACZ,OAAK,WAAW,IAAI,UAAU;AAG9B,wBAAsB,EACpB,UAAU,KAAK,UAChB,CAAC;AAGF,OAAK,gBAAgB,IAAI,QAAQ;GAC/B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,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C;AAGF,OAAK,aAAa,IAAI,MAAM;GAC1B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,wBAAwB,IAAI,QAAQ;GACvC,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;;;;;;;;CASJ,mBAAmB,eAAuB,cAAsB,WAAmB;AACjF,OAAK,cAAc,KAAK;AACxB,OAAK,cAAc,IAAI,cAAc;AACrC,OAAK,aAAa,IAAI,aAAa;AACnC,OAAK,aAAa,IAAI,eAAe,cAAc;AACnD,OAAK,WAAW,IAAI,UAAU;;;;;;CAOhC,YAAY,MAAc;AACxB,OAAK,OAAO,IAAI,EACd,MACD,CAAC;AAEF,MAAI,SAAS,MACX,MAAK,UAAU,KAAK;WAEb,SAAS,WAChB,MAAK,eAAe,KAAK;;;;;;CAQ7B,MAAM,aAA8B;AAClC,SAAO,KAAK,SAAS,SAAS"}
@@ -7,12 +7,13 @@
7
7
  * - size() is always at minimum 1 item which is the promise for the next enqueued item
8
8
  */
9
9
  var PromiseQueue = class {
10
- constructor(batchSize) {
10
+ constructor(batchSize, errorHandler) {
11
11
  this.synced = false;
12
12
  const nextVal = new Promise((resolve, _reject) => {
13
13
  this.enqueuer = resolve;
14
14
  });
15
15
  this.batchSize = batchSize;
16
+ this.errorHandler = errorHandler;
16
17
  this.continuePromise = new Promise((resolve, _reject) => {
17
18
  this.batcher = resolve;
18
19
  });
@@ -30,7 +31,7 @@ var PromiseQueue = class {
30
31
  this.batcher = resolve;
31
32
  });
32
33
  } catch (e) {
33
- console.error("Enqueing rejected data: " + e);
34
+ if (this.errorHandler) this.errorHandler(e);
34
35
  }
35
36
  }
36
37
  clear() {
@@ -68,7 +69,7 @@ var PromiseQueue = class {
68
69
  * Used by the indexer for managing block processing queues
69
70
  */
70
71
  var CircularBuffer = class {
71
- constructor(batchSize) {
72
+ constructor(batchSize, errorHandler) {
72
73
  this.count = 0;
73
74
  this.next = 0;
74
75
  this.synced = false;
@@ -79,6 +80,7 @@ var CircularBuffer = class {
79
80
  });
80
81
  this.items = new Array(batchSize);
81
82
  this.batchSize = batchSize;
83
+ this.errorHandler = errorHandler;
82
84
  this.items[this.nextAvail] = nextVal;
83
85
  this.count = 1;
84
86
  this.nextAvail++;
@@ -102,7 +104,7 @@ var CircularBuffer = class {
102
104
  this.batcher = resolve;
103
105
  });
104
106
  } catch (e) {
105
- console.error("Enqueing rejected data: " + e);
107
+ if (this.errorHandler) this.errorHandler(e);
106
108
  }
107
109
  }
108
110
  dequeue() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":["/**\n * Implements an \"infinite\" FIFO queue of fixed size using promises\n * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)\n * - await `dequeue()` to pop an item (resolves when next item is available)\n * - size() is always at minimum 1 item which is the promise for the next enqueued item\n */\nexport class PromiseQueue<T> {\n /** Array of promises representing queued items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the queue is synced with the data source */\n public synced = false;\n\n /** Maximum number of items to keep in the queue */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n constructor(batchSize: number) {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.batchSize = batchSize;\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items.push(nextVal);\n if (this.size() > this.batchSize) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n console.error(\"Enqueing rejected data: \" + e);\n }\n }\n\n clear() {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n dequeue() {\n const item = this.items.shift();\n if (this.size() <= this.batchSize) {\n this.batcher(true);\n }\n\n return item as Promise<T>;\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.items.length == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.items.length;\n }\n}\n\n/**\n * Circular buffer implementation using promises for efficient memory usage\n * Reuses array slots in a circular fashion to maintain constant memory footprint\n * Used by the indexer for managing block processing queues\n */\nexport class CircularBuffer<T> {\n /** Fixed-size array of promises representing buffered items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Current number of items in the buffer */\n private count: number = 0;\n\n /** Index of the next item to dequeue */\n private next: number = 0;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the buffer is synced with the data source */\n public synced = false;\n\n /** Maximum number of items the buffer can hold */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n /** Index of the next available slot for enqueueing */\n private nextAvail: number = 0;\n\n constructor(batchSize: number) {\n if (batchSize <= 1) {\n throw new Error(\"Batch size must be greater than 1\");\n }\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(batchSize);\n this.batchSize = batchSize;\n this.items[this.nextAvail] = nextVal;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items[this.nextAvail] = nextVal;\n this.count++;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n if (this.nextAvail == this.next) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n console.error(\"Enqueing rejected data: \" + e);\n }\n }\n\n dequeue() {\n const item = this.items[this.next];\n this.next++;\n this.count--;\n if (this.next >= this.batchSize) {\n this.next = 0;\n }\n if (this.count <= this.batchSize) {\n this.batcher(true);\n }\n return item;\n }\n\n clear() {\n this.next = 0;\n this.nextAvail = 0;\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(this.batchSize);\n this.items[this.nextAvail] = nextVal;\n this.synced = false;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.count == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.count;\n }\n}\n"],"mappings":";;;;;;;;AAMA,IAAa,eAAb,MAA6B;CAmB3B,YAAY,WAAmB;OARxB,SAAS;EASd,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,YAAY;AACjB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;AAClB,OAAK,QAAQ,CAAC,QAAQ;;CAGxB,QAAQ,MAA0B;AAChC,MAAI;AACF,QAAK,SAAS,KAAK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pB,QAAQ,MAA0B;AAChC,MAAI;AACF,QAAK,SAAS,KAAK;GACnB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,SAAK,WAAW;KAChB;AACF,QAAK,MAAM,KAAK,aAAa;AAC7B,QAAK;AACL,QAAK;AACL,OAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAI,KAAK,aAAa,KAAK,KACzB,MAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,SAAK,UAAU;KACf;WAGC,GAAG;AACR,WAAQ,MAAM,6BAA6B,EAAE;;;CAIjD,UAAU;EACR,MAAM,OAAO,KAAK,MAAM,KAAK;AAC7B,OAAK;AACL,OAAK;AACL,MAAI,KAAK,QAAQ,KAAK,UACpB,MAAK,OAAO;AAEd,MAAI,KAAK,SAAS,KAAK,UACrB,MAAK,QAAQ,KAAK;AAEpB,SAAO;;CAGT,QAAQ;AACN,OAAK,OAAO;AACZ,OAAK,YAAY;EACjB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,QAAQ,IAAI,MAAkB,KAAK,UAAU;AAClD,OAAK,MAAM,KAAK,aAAa;AAC7B,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK;AACL,MAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;;CAGpB,WAAW;AACT,SAAO,KAAK;;CAGd,YAAY;AACV,OAAK,SAAS;;CAGhB,UAAU;AACR,MAAI,KAAK,SAAS,EAChB,QAAO;MAGP,QAAO;;CAIX,OAAO;AACL,SAAO,KAAK"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":["/**\n * Implements an \"infinite\" FIFO queue of fixed size using promises\n * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)\n * - await `dequeue()` to pop an item (resolves when next item is available)\n * - size() is always at minimum 1 item which is the promise for the next enqueued item\n */\nexport class PromiseQueue<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n /** Array of promises representing queued items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the queue is synced with the data source */\n public synced = false;\n\n /** Maximum number of items to keep in the queue */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items.push(nextVal);\n if (this.size() > this.batchSize) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n clear() {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n dequeue() {\n const item = this.items.shift();\n if (this.size() <= this.batchSize) {\n this.batcher(true);\n }\n\n return item as Promise<T>;\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.items.length == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.items.length;\n }\n}\n\n/**\n * Circular buffer implementation using promises for efficient memory usage\n * Reuses array slots in a circular fashion to maintain constant memory footprint\n * Used by the indexer for managing block processing queues\n */\nexport class CircularBuffer<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n\n /** Fixed-size array of promises representing buffered items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Current number of items in the buffer */\n private count: number = 0;\n\n /** Index of the next item to dequeue */\n private next: number = 0;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the buffer is synced with the data source */\n public synced = false;\n\n /** Maximum number of items the buffer can hold */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n /** Index of the next available slot for enqueueing */\n private nextAvail: number = 0;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n if (batchSize <= 1) {\n throw new Error(\"Batch size must be greater than 1\");\n }\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(batchSize);\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.items[this.nextAvail] = nextVal;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items[this.nextAvail] = nextVal;\n this.count++;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n if (this.nextAvail == this.next) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n dequeue() {\n const item = this.items[this.next];\n this.next++;\n this.count--;\n if (this.next >= this.batchSize) {\n this.next = 0;\n }\n if (this.count <= this.batchSize) {\n this.batcher(true);\n }\n return item;\n }\n\n clear() {\n this.next = 0;\n this.nextAvail = 0;\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(this.batchSize);\n this.items[this.nextAvail] = nextVal;\n this.synced = false;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.count == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.count;\n }\n}\n"],"mappings":";;;;;;;;AAMA,IAAa,eAAb,MAA6B;CAqB3B,YAAY,WAAmB,cAAyC;OARjE,SAAS;EASd,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,YAAY;AACjB,OAAK,eAAe;AACpB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;AAClB,OAAK,QAAQ,CAAC,QAAQ;;CAGxB,QAAQ,MAA0B;AAChC,MAAI;AACF,QAAK,SAAS,KAAK;GACnB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,SAAK,WAAW;KAChB;AACF,QAAK,MAAM,KAAK,QAAQ;AACxB,OAAI,KAAK,MAAM,GAAG,KAAK,UACrB,MAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,SAAK,UAAU;KACf;WAGC,GAAG;AACR,OAAI,KAAK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AK,UACzB,MAAK,YAAY;AAGnB,OAAI,KAAK,aAAa,KAAK,KACzB,MAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,SAAK,UAAU;KACf;WAGC,GAAG;AACR,OAAI,KAAK,aACP,MAAK,aAAa,EAAE;;;CAM1B,UAAU;EACR,MAAM,OAAO,KAAK,MAAM,KAAK;AAC7B,OAAK;AACL,OAAK;AACL,MAAI,KAAK,QAAQ,KAAK,UACpB,MAAK,OAAO;AAEd,MAAI,KAAK,SAAS,KAAK,UACrB,MAAK,QAAQ,KAAK;AAEpB,SAAO;;CAGT,QAAQ;AACN,OAAK,OAAO;AACZ,OAAK,YAAY;EACjB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,QAAQ,IAAI,MAAkB,KAAK,UAAU;AAClD,OAAK,MAAM,KAAK,aAAa;AAC7B,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK;AACL,MAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;;CAGpB,WAAW;AACT,SAAO,KAAK;;CAGd,YAAY;AACV,OAAK,SAAS;;CAGhB,UAAU;AACR,MAAI,KAAK,SAAS,EAChB,QAAO;MAGP,QAAO;;CAIX,OAAO;AACL,SAAO,KAAK"}
@@ -6,6 +6,8 @@
6
6
  * - size() is always at minimum 1 item which is the promise for the next enqueued item
7
7
  */
8
8
  declare class PromiseQueue<T> {
9
+ /** Optional error handler for enqueue failures */
10
+ private errorHandler?;
9
11
  /** Array of promises representing queued items */
10
12
  private items;
11
13
  /** Function to resolve the next enqueued promise */
@@ -18,7 +20,7 @@ declare class PromiseQueue<T> {
18
20
  private batchSize;
19
21
  /** Promise that resolves when it's safe to enqueue more items */
20
22
  private continuePromise;
21
- constructor(batchSize: number);
23
+ constructor(batchSize: number, errorHandler?: (error: unknown) => void);
22
24
  enqueue(item: T | PromiseLike<T>): void;
23
25
  clear(): void;
24
26
  dequeue(): Promise<T>;
@@ -33,6 +35,8 @@ declare class PromiseQueue<T> {
33
35
  * Used by the indexer for managing block processing queues
34
36
  */
35
37
  declare class CircularBuffer<T> {
38
+ /** Optional error handler for enqueue failures */
39
+ private errorHandler?;
36
40
  /** Fixed-size array of promises representing buffered items */
37
41
  private items;
38
42
  /** Function to resolve the next enqueued promise */
@@ -51,7 +55,7 @@ declare class CircularBuffer<T> {
51
55
  private continuePromise;
52
56
  /** Index of the next available slot for enqueueing */
53
57
  private nextAvail;
54
- constructor(batchSize: number);
58
+ constructor(batchSize: number, errorHandler?: (error: unknown) => void);
55
59
  enqueue(item: T | PromiseLike<T>): void;
56
60
  dequeue(): Promise<T>;
57
61
  clear(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":[],"mappings":";;AAMA;;;;;AAkE2B,cAlEd,YAkEc,CAAA,CAAA,CAAA,CAAA;;UAGjB,KAAA;EAAA;EA2BG,QAAA,QAAA;EAAc;UAkDX,OAAA;;QAAI,EAAA,OAAA;;UAwBX,SAAA;;EAkCC,QAAA,eAAA;;gBA7KM,IAAI,YAAY;;aAmCb,QAAQ;cAGjB;;;;;;;;;;cA2BG;;;;;;;;;;;;;;;;;;;;gBAkDG,IAAI,YAAY;aAwBvB,QAAA;;cAkCC"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":[],"mappings":";;AAMA;;;;;AAwE2B,cAxEd,YAwEc,CAAA,CAAA,CAAA,CAAA;;UAGjB,YAAA;EAAA;EA2BG,QAAA,KAAA;EAAc;UAsDX,QAAA;;UAAI,OAAA;;QA2BX,EAAA,OAAA;;EAkCC,QAAA,SAAA;;;;gBAvLM,IAAI,YAAY;;aAsCb,QAAQ;cAGjB;;;;;;;;;;cA2BG;;;;;;;;;;;;;;;;;;;;;;gBAsDG,IAAI,YAAY;aA2BvB,QAAA;;cAkCC"}
@@ -6,6 +6,8 @@
6
6
  * - size() is always at minimum 1 item which is the promise for the next enqueued item
7
7
  */
8
8
  declare class PromiseQueue<T> {
9
+ /** Optional error handler for enqueue failures */
10
+ private errorHandler?;
9
11
  /** Array of promises representing queued items */
10
12
  private items;
11
13
  /** Function to resolve the next enqueued promise */
@@ -18,7 +20,7 @@ declare class PromiseQueue<T> {
18
20
  private batchSize;
19
21
  /** Promise that resolves when it's safe to enqueue more items */
20
22
  private continuePromise;
21
- constructor(batchSize: number);
23
+ constructor(batchSize: number, errorHandler?: (error: unknown) => void);
22
24
  enqueue(item: T | PromiseLike<T>): void;
23
25
  clear(): void;
24
26
  dequeue(): Promise<T>;
@@ -33,6 +35,8 @@ declare class PromiseQueue<T> {
33
35
  * Used by the indexer for managing block processing queues
34
36
  */
35
37
  declare class CircularBuffer<T> {
38
+ /** Optional error handler for enqueue failures */
39
+ private errorHandler?;
36
40
  /** Fixed-size array of promises representing buffered items */
37
41
  private items;
38
42
  /** Function to resolve the next enqueued promise */
@@ -51,7 +55,7 @@ declare class CircularBuffer<T> {
51
55
  private continuePromise;
52
56
  /** Index of the next available slot for enqueueing */
53
57
  private nextAvail;
54
- constructor(batchSize: number);
58
+ constructor(batchSize: number, errorHandler?: (error: unknown) => void);
55
59
  enqueue(item: T | PromiseLike<T>): void;
56
60
  dequeue(): Promise<T>;
57
61
  clear(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":[],"mappings":";;AAMA;;;;;AAkE2B,cAlEd,YAkEc,CAAA,CAAA,CAAA,CAAA;;UAGjB,KAAA;EAAA;EA2BG,QAAA,QAAA;EAAc;UAkDX,OAAA;;QAAI,EAAA,OAAA;;UAwBX,SAAA;;EAkCC,QAAA,eAAA;;gBA7KM,IAAI,YAAY;;aAmCb,QAAQ;cAGjB;;;;;;;;;;cA2BG;;;;;;;;;;;;;;;;;;;;gBAkDG,IAAI,YAAY;aAwBvB,QAAA;;cAkCC"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":[],"mappings":";;AAMA;;;;;AAwE2B,cAxEd,YAwEc,CAAA,CAAA,CAAA,CAAA;;UAGjB,YAAA;EAAA;EA2BG,QAAA,KAAA;EAAc;UAsDX,QAAA;;UAAI,OAAA;;QA2BX,EAAA,OAAA;;EAkCC,QAAA,SAAA;;;;gBAvLM,IAAI,YAAY;;aAsCb,QAAQ;cAGjB;;;;;;;;;;cA2BG;;;;;;;;;;;;;;;;;;;;;;gBAsDG,IAAI,YAAY;aA2BvB,QAAA;;cAkCC"}
@@ -6,12 +6,13 @@
6
6
  * - size() is always at minimum 1 item which is the promise for the next enqueued item
7
7
  */
8
8
  var PromiseQueue = class {
9
- constructor(batchSize) {
9
+ constructor(batchSize, errorHandler) {
10
10
  this.synced = false;
11
11
  const nextVal = new Promise((resolve, _reject) => {
12
12
  this.enqueuer = resolve;
13
13
  });
14
14
  this.batchSize = batchSize;
15
+ this.errorHandler = errorHandler;
15
16
  this.continuePromise = new Promise((resolve, _reject) => {
16
17
  this.batcher = resolve;
17
18
  });
@@ -29,7 +30,7 @@ var PromiseQueue = class {
29
30
  this.batcher = resolve;
30
31
  });
31
32
  } catch (e) {
32
- console.error("Enqueing rejected data: " + e);
33
+ if (this.errorHandler) this.errorHandler(e);
33
34
  }
34
35
  }
35
36
  clear() {
@@ -67,7 +68,7 @@ var PromiseQueue = class {
67
68
  * Used by the indexer for managing block processing queues
68
69
  */
69
70
  var CircularBuffer = class {
70
- constructor(batchSize) {
71
+ constructor(batchSize, errorHandler) {
71
72
  this.count = 0;
72
73
  this.next = 0;
73
74
  this.synced = false;
@@ -78,6 +79,7 @@ var CircularBuffer = class {
78
79
  });
79
80
  this.items = new Array(batchSize);
80
81
  this.batchSize = batchSize;
82
+ this.errorHandler = errorHandler;
81
83
  this.items[this.nextAvail] = nextVal;
82
84
  this.count = 1;
83
85
  this.nextAvail++;
@@ -101,7 +103,7 @@ var CircularBuffer = class {
101
103
  this.batcher = resolve;
102
104
  });
103
105
  } catch (e) {
104
- console.error("Enqueing rejected data: " + e);
106
+ if (this.errorHandler) this.errorHandler(e);
105
107
  }
106
108
  }
107
109
  dequeue() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":["/**\n * Implements an \"infinite\" FIFO queue of fixed size using promises\n * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)\n * - await `dequeue()` to pop an item (resolves when next item is available)\n * - size() is always at minimum 1 item which is the promise for the next enqueued item\n */\nexport class PromiseQueue<T> {\n /** Array of promises representing queued items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the queue is synced with the data source */\n public synced = false;\n\n /** Maximum number of items to keep in the queue */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n constructor(batchSize: number) {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.batchSize = batchSize;\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items.push(nextVal);\n if (this.size() > this.batchSize) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n console.error(\"Enqueing rejected data: \" + e);\n }\n }\n\n clear() {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n dequeue() {\n const item = this.items.shift();\n if (this.size() <= this.batchSize) {\n this.batcher(true);\n }\n\n return item as Promise<T>;\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.items.length == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.items.length;\n }\n}\n\n/**\n * Circular buffer implementation using promises for efficient memory usage\n * Reuses array slots in a circular fashion to maintain constant memory footprint\n * Used by the indexer for managing block processing queues\n */\nexport class CircularBuffer<T> {\n /** Fixed-size array of promises representing buffered items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Current number of items in the buffer */\n private count: number = 0;\n\n /** Index of the next item to dequeue */\n private next: number = 0;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the buffer is synced with the data source */\n public synced = false;\n\n /** Maximum number of items the buffer can hold */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n /** Index of the next available slot for enqueueing */\n private nextAvail: number = 0;\n\n constructor(batchSize: number) {\n if (batchSize <= 1) {\n throw new Error(\"Batch size must be greater than 1\");\n }\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(batchSize);\n this.batchSize = batchSize;\n this.items[this.nextAvail] = nextVal;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items[this.nextAvail] = nextVal;\n this.count++;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n if (this.nextAvail == this.next) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n console.error(\"Enqueing rejected data: \" + e);\n }\n }\n\n dequeue() {\n const item = this.items[this.next];\n this.next++;\n this.count--;\n if (this.next >= this.batchSize) {\n this.next = 0;\n }\n if (this.count <= this.batchSize) {\n this.batcher(true);\n }\n return item;\n }\n\n clear() {\n this.next = 0;\n this.nextAvail = 0;\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(this.batchSize);\n this.items[this.nextAvail] = nextVal;\n this.synced = false;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.count == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.count;\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,eAAb,MAA6B;CAmB3B,YAAY,WAAmB;OARxB,SAAS;EASd,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,YAAY;AACjB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;AAClB,OAAK,QAAQ,CAAC,QAAQ;;CAGxB,QAAQ,MAA0B;AAChC,MAAI;AACF,QAAK,SAAS,KAAK;GACnB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,SAAK,WAAW;KAChB;AACF,QAAK,MAAM,KAAK,QAAQ;AACxB,OAAI,KAAK,MAAM,GAAG,KAAK,UACrB,MAAK,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a;AAC7B,QAAK;AACL,QAAK;AACL,OAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAI,KAAK,aAAa,KAAK,KACzB,MAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,SAAK,UAAU;KACf;WAGC,GAAG;AACR,WAAQ,MAAM,6BAA6B,EAAE;;;CAIjD,UAAU;EACR,MAAM,OAAO,KAAK,MAAM,KAAK;AAC7B,OAAK;AACL,OAAK;AACL,MAAI,KAAK,QAAQ,KAAK,UACpB,MAAK,OAAO;AAEd,MAAI,KAAK,SAAS,KAAK,UACrB,MAAK,QAAQ,KAAK;AAEpB,SAAO;;CAGT,QAAQ;AACN,OAAK,OAAO;AACZ,OAAK,YAAY;EACjB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,QAAQ,IAAI,MAAkB,KAAK,UAAU;AAClD,OAAK,MAAM,KAAK,aAAa;AAC7B,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK;AACL,MAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;;CAGpB,WAAW;AACT,SAAO,KAAK;;CAGd,YAAY;AACV,OAAK,SAAS;;CAGhB,UAAU;AACR,MAAI,KAAK,SAAS,EAChB,QAAO;MAGP,QAAO;;CAIX,OAAO;AACL,SAAO,KAAK"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":["/**\n * Implements an \"infinite\" FIFO queue of fixed size using promises\n * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)\n * - await `dequeue()` to pop an item (resolves when next item is available)\n * - size() is always at minimum 1 item which is the promise for the next enqueued item\n */\nexport class PromiseQueue<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n /** Array of promises representing queued items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the queue is synced with the data source */\n public synced = false;\n\n /** Maximum number of items to keep in the queue */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items.push(nextVal);\n if (this.size() > this.batchSize) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n clear() {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n dequeue() {\n const item = this.items.shift();\n if (this.size() <= this.batchSize) {\n this.batcher(true);\n }\n\n return item as Promise<T>;\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.items.length == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.items.length;\n }\n}\n\n/**\n * Circular buffer implementation using promises for efficient memory usage\n * Reuses array slots in a circular fashion to maintain constant memory footprint\n * Used by the indexer for managing block processing queues\n */\nexport class CircularBuffer<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n\n /** Fixed-size array of promises representing buffered items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Current number of items in the buffer */\n private count: number = 0;\n\n /** Index of the next item to dequeue */\n private next: number = 0;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the buffer is synced with the data source */\n public synced = false;\n\n /** Maximum number of items the buffer can hold */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n /** Index of the next available slot for enqueueing */\n private nextAvail: number = 0;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n if (batchSize <= 1) {\n throw new Error(\"Batch size must be greater than 1\");\n }\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(batchSize);\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.items[this.nextAvail] = nextVal;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items[this.nextAvail] = nextVal;\n this.count++;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n if (this.nextAvail == this.next) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n dequeue() {\n const item = this.items[this.next];\n this.next++;\n this.count--;\n if (this.next >= this.batchSize) {\n this.next = 0;\n }\n if (this.count <= this.batchSize) {\n this.batcher(true);\n }\n return item;\n }\n\n clear() {\n this.next = 0;\n this.nextAvail = 0;\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(this.batchSize);\n this.items[this.nextAvail] = nextVal;\n this.synced = false;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.count == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.count;\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,eAAb,MAA6B;CAqB3B,YAAY,WAAmB,cAAyC;OARjE,SAAS;EASd,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,YAAY;AACjB,OAAK,eAAe;AACpB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;AAClB,OAAK,QAAQ,CAAC,QAAQ;;CAGxB,QAAQ,MAA0B;AAChC,MAAI;AACF,QAAK,SAAS,KAAK;GACnB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,SAAK,WAAW;KAChB;AACF,QAAK,MAAM,KAAK,QAAQ;AACxB,OAAI,KAAK,MAAM,GAAG,KAAK,UACrB,MAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,SAAK,UAAU;KACf;WAGC,GAAG;AACR,OAAI,KAAK,aACP,MAAK,aAAa,EAAE;;;CAM1B,QAAQ;EACN,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY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,aACP,MAAK,aAAa,EAAE;;;CAM1B,UAAU;EACR,MAAM,OAAO,KAAK,MAAM,KAAK;AAC7B,OAAK;AACL,OAAK;AACL,MAAI,KAAK,QAAQ,KAAK,UACpB,MAAK,OAAO;AAEd,MAAI,KAAK,SAAS,KAAK,UACrB,MAAK,QAAQ,KAAK;AAEpB,SAAO;;CAGT,QAAQ;AACN,OAAK,OAAO;AACZ,OAAK,YAAY;EACjB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,QAAQ,IAAI,MAAkB,KAAK,UAAU;AAClD,OAAK,MAAM,KAAK,aAAa;AAC7B,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK;AACL,MAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;;CAGpB,WAAW;AACT,SAAO,KAAK;;CAGd,YAAY;AACV,OAAK,SAAS;;CAGhB,UAAU;AACR,MAAI,KAAK,SAAS,EAChB,QAAO;MAGP,QAAO;;CAIX,OAAO;AACL,SAAO,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void> // Function to end database transaction\n};\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n [K in keyof T]: T[K] & {\n uuid?: string // Unique identifier for event tracking\n height?: number // Block height when event occurred\n timestamp?: string // Block timestamp when event occurred\n };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n t: K,\n e: WithHeightAndUUID<EventMap>[K]\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n message: string\n};\nexport type UUIDEvent = {\n uuid: string\n error?: string\n status: boolean\n};\nexport type Events = {\n log: LogEvent\n uuid: UUIDEvent\n begin_block: {\n value: {\n events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n validators: Validator[] | undefined\n }\n }\n\n block: {\n value: {\n block: BlockResponse\n block_results: BlockResultsResponse | BlockResultsResponse38\n }\n }\n end_block: {\n value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n }\n tx_events: {\n value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n }\n tx_memo: {\n value: {\n txHash: string\n txBody: TxBody\n }\n }\n _unhandled: {\n type: string\n event: unknown\n }\n \"periodic/50\": {\n value: null\n }\n \"periodic/100\": {\n value: null\n }\n \"periodic/1000\": {\n value: null\n }\n};\nexport type TxResult<T> = {\n tx: T\n events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n indexer: EcleciaIndexer // Reference to the main indexer instance\n name: string // Unique module name\n depends: string[] // Array of module names this module depends on\n provides: string[] // Array of capabilities this module provides\n setup: () => Promise<void> // Async setup function for database schema initialization\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n init: (...args: any[]) => void // Initialization function called by the indexer\n}\n"],"mappings":""}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n healthCheckPort?: number // Port for health check HTTP server (default: 8080)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void> // Function to end database transaction\n};\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n [K in keyof T]: T[K] & {\n uuid?: string // Unique identifier for event tracking\n height?: number // Block height when event occurred\n timestamp?: string // Block timestamp when event occurred\n };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n t: K,\n e: WithHeightAndUUID<EventMap>[K]\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n message: string\n};\nexport type UUIDEvent = {\n uuid: string\n error?: string\n status: boolean\n};\nexport type Events = {\n log: LogEvent\n uuid: UUIDEvent\n \"fatal-error\": {\n error: Error\n message: string\n retryCount?: number\n }\n begin_block: {\n value: {\n events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n validators: Validator[] | undefined\n }\n }\n\n block: {\n value: {\n block: BlockResponse\n block_results: BlockResultsResponse | BlockResultsResponse38\n }\n }\n end_block: {\n value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n }\n tx_events: {\n value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n }\n tx_memo: {\n value: {\n txHash: string\n txBody: TxBody\n }\n }\n _unhandled: {\n type: string\n event: unknown\n }\n \"periodic/50\": {\n value: null\n }\n \"periodic/100\": {\n value: null\n }\n \"periodic/1000\": {\n value: null\n }\n};\nexport type TxResult<T> = {\n tx: T\n events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n indexer: EcleciaIndexer // Reference to the main indexer instance\n name: string // Unique module name\n depends: string[] // Array of module names this module depends on\n provides: string[] // Array of capabilities this module provides\n setup: () => Promise<void> // Async setup function for database schema initialization\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n init: (...args: any[]) => void // Initialization function called by the indexer\n}\n"],"mappings":""}
@@ -23,6 +23,7 @@ type EcleciaIndexerConfig = {
23
23
  usePolling?: boolean;
24
24
  pollingInterval?: number;
25
25
  minimal?: boolean;
26
+ healthCheckPort?: number;
26
27
  init?: () => Promise<void>;
27
28
  beginTransaction: () => Promise<void>;
28
29
  endTransaction: (status: boolean) => Promise<void>;
@@ -53,6 +54,11 @@ type UUIDEvent = {
53
54
  type Events = {
54
55
  log: LogEvent;
55
56
  uuid: UUIDEvent;
57
+ "fatal-error": {
58
+ error: Error;
59
+ message: string;
60
+ retryCount?: number;
61
+ };
56
62
  begin_block: {
57
63
  value: {
58
64
  events: BlockResultsResponse["beginBlockEvents"] | BlockResultsResponse$1["finalizeBlockEvents"];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAsBY,oBAAA;;;;;gCAKoB;;;8BAGF;;;;;eAKf;0BACW;EAdd,cAAA,EAAA,CAAA,MAAoB,EAAA,OAAA,EAAA,GAeO,OAfP,CAAA,IA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tC,CAAA,qBAAA,CAAA;;WACI,EAAA;IAML,KAAA,EAQF,oBARE,CAAA,SAAA,CAAA,GAQgC,sBARhC,CAAA,SAAA,CAAA;;SAC+B,EAAA;IAIjC,KAAA,EAAA;MAAyC,MAAA,EAAA,MAAA;MAGzC,MAAA,EAKG,MALH;IAAkC,CAAA;;EAKzB,UAAA,EAAA;IAiBR,IAAA,EAAA,MAAQ;IAAA,KAAA,EAAA,OAAA;;eAEV,EAAA;IAAK,KAAA,EAAA,IAAA;EAIE,CAAA;EAAc,cAAA,EAAA;IACpB,KAAA,EAAA,IAAA;;EAIW,eAAA,EAAA;;;;KAXV;MACN;UACI;;;UAIO,cAAA;WACN;;;;eAII"}
@@ -23,6 +23,7 @@ type EcleciaIndexerConfig = {
23
23
  usePolling?: boolean;
24
24
  pollingInterval?: number;
25
25
  minimal?: boolean;
26
+ healthCheckPort?: number;
26
27
  init?: () => Promise<void>;
27
28
  beginTransaction: () => Promise<void>;
28
29
  endTransaction: (status: boolean) => Promise<void>;
@@ -53,6 +54,11 @@ type UUIDEvent = {
53
54
  type Events = {
54
55
  log: LogEvent;
55
56
  uuid: UUIDEvent;
57
+ "fatal-error": {
58
+ error: Error;
59
+ message: string;
60
+ retryCount?: number;
61
+ };
56
62
  begin_block: {
57
63
  value: {
58
64
  events: BlockResultsResponse["beginBlockEvents"] | BlockResultsResponse$1["finalizeBlockEvents"];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAsBY,oBAAA;;;;;gCAKoB;;;8BAGF;;;;;eAKf;0BACW;EAdd,cAAA,EAAA,CAAA,MAAoB,EAAA,OAAA,EAAA,GAeO,OAfP,CAAA,IAAA,CAAA;CAAA;;AAQF,KAWlB,cAAA,GAAiB,cAXC,CAAA,CAWe,aAXf,EAW8B,oBAX9B,EAWoD,UAXpD,CAAA,CAAA;;AAMJ,KAQd,iBAAA,GAAoB,cARN,CAA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C,MAAA,EAAA,MAAA;MAGzC,MAAA,EAKG,MALH;IAAkC,CAAA;;EAKzB,UAAA,EAAA;IAiBR,IAAA,EAAA,MAAQ;IAAA,KAAA,EAAA,OAAA;;eAEV,EAAA;IAAK,KAAA,EAAA,IAAA;EAIE,CAAA;EAAc,cAAA,EAAA;IACpB,KAAA,EAAA,IAAA;;EAIW,eAAA,EAAA;;;;KAXV;MACN;UACI;;;UAIO,cAAA;WACN;;;;eAII"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void> // Function to end database transaction\n};\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n [K in keyof T]: T[K] & {\n uuid?: string // Unique identifier for event tracking\n height?: number // Block height when event occurred\n timestamp?: string // Block timestamp when event occurred\n };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n t: K,\n e: WithHeightAndUUID<EventMap>[K]\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n message: string\n};\nexport type UUIDEvent = {\n uuid: string\n error?: string\n status: boolean\n};\nexport type Events = {\n log: LogEvent\n uuid: UUIDEvent\n begin_block: {\n value: {\n events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n validators: Validator[] | undefined\n }\n }\n\n block: {\n value: {\n block: BlockResponse\n block_results: BlockResultsResponse | BlockResultsResponse38\n }\n }\n end_block: {\n value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n }\n tx_events: {\n value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n }\n tx_memo: {\n value: {\n txHash: string\n txBody: TxBody\n }\n }\n _unhandled: {\n type: string\n event: unknown\n }\n \"periodic/50\": {\n value: null\n }\n \"periodic/100\": {\n value: null\n }\n \"periodic/1000\": {\n value: null\n }\n};\nexport type TxResult<T> = {\n tx: T\n events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n indexer: EcleciaIndexer // Reference to the main indexer instance\n name: string // Unique module name\n depends: string[] // Array of module names this module depends on\n provides: string[] // Array of capabilities this module provides\n setup: () => Promise<void> // Async setup function for database schema initialization\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n init: (...args: any[]) => void // Initialization function called by the indexer\n}\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n healthCheckPort?: number // Port for health check HTTP server (default: 8080)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void> // Function to end database transaction\n};\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n [K in keyof T]: T[K] & {\n uuid?: string // Unique identifier for event tracking\n height?: number // Block height when event occurred\n timestamp?: string // Block timestamp when event occurred\n };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n t: K,\n e: WithHeightAndUUID<EventMap>[K]\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n message: string\n};\nexport type UUIDEvent = {\n uuid: string\n error?: string\n status: boolean\n};\nexport type Events = {\n log: LogEvent\n uuid: UUIDEvent\n \"fatal-error\": {\n error: Error\n message: string\n retryCount?: number\n }\n begin_block: {\n value: {\n events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n validators: Validator[] | undefined\n }\n }\n\n block: {\n value: {\n block: BlockResponse\n block_results: BlockResultsResponse | BlockResultsResponse38\n }\n }\n end_block: {\n value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n }\n tx_events: {\n value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n }\n tx_memo: {\n value: {\n txHash: string\n txBody: TxBody\n }\n }\n _unhandled: {\n type: string\n event: unknown\n }\n \"periodic/50\": {\n value: null\n }\n \"periodic/100\": {\n value: null\n }\n \"periodic/1000\": {\n value: null\n }\n};\nexport type TxResult<T> = {\n tx: T\n events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n indexer: EcleciaIndexer // Reference to the main indexer instance\n name: string // Unique module name\n depends: string[] // Array of module names this module depends on\n provides: string[] // Array of capabilities this module provides\n setup: () => Promise<void> // Async setup function for database schema initialization\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n init: (...args: any[]) => void // Initialization function called by the indexer\n}\n"],"mappings":""}
@@ -1,6 +1,5 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  let bech32 = require("bech32");
3
- bech32 = require_rolldown_runtime.__toESM(bech32);
4
3
 
5
4
  //#region src/utils/bech32.ts
6
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bech32.cjs","names":[],"sources":["../../src/utils/bech32.ts"],"sourcesContent":["import {\n bech32,\n} from \"bech32\";\n\n/**\n * Converts a byte array to a hexadecimal string representation\n * @param byteArray - Array of bytes to convert\n * @returns Hexadecimal string\n */\nfunction toHexString(byteArray: number[]) {\n return Array.prototype.map\n .call(\n byteArray, (byte) => {\n return (\"0\" + (byte & 0xff).toString(16)).slice(-2);\n },\n )\n .join(\"\");\n}\n\n/**\n * Extracts the key hash from a bech32-encoded address\n * @param address - Bech32-encoded address string\n * @returns Hexadecimal key hash\n * @throws Error if address cannot be decoded\n */\nfunction keyHashfromAddress(address: string): string {\n try {\n return toHexString(bech32.fromWords(bech32.decode(address).words));\n }\n catch (_e) {\n throw new Error(\"Could not decode address\");\n }\n}\n\n/**\n * Creates a bech32-encoded address from a key hash and prefix\n * @param prefix - Address prefix (e.g., \"cosmos\", \"cosmosvalcons\")\n * @param keyhash - Hexadecimal key hash\n * @returns Bech32-encoded address or empty string if keyhash is empty\n */\nfunction chainAddressfromKeyhash(prefix: string, keyhash: string) {\n const words = bech32.toWords(Buffer.from(\n keyhash, \"hex\",\n ));\n\n return keyhash !== \"\"\n ? bech32.encode(\n prefix, words,\n )\n : \"\";\n}\n\nexport {\n chainAddressfromKeyhash, keyHashfromAddress, toHexString,\n};\n"],"mappings":";;;;;;;;;;AASA,SAAS,YAAY,WAAqB;AACxC,QAAO,MAAM,UAAU,IACpB,KACC,YAAY,SAAS;AACnB,UAAQ,OAAO,OAAO,KAAM,SAAS,GAAG,EAAE,MAAM,GAAG;GAEtD,CACA,KAAK,GAAG;;;;;;;;AASb,SAAS,mBAAmB,SAAyB;AACnD,KAAI;AACF,SAAO,YAAY,cAAO,UAAU,cAAO,OAAO,QAAQ,CAAC,MAAM,CAAC;UAE7D,IAAI;AACT,QAAM,IAAI,MAAM,2BAA2B;;;;;;;;;AAU/C,SAAS,wBAAwB,QAAgB,SAAiB;CAChE,MAAM,QAAQ,cAAO,QAAQ,OAAO,KAClC,SAAS,MACV,CAAC;AAEF,QAAO,YAAY,KACf,cAAO,OACP,QAAQ,MACT,GACC"}
1
+ {"version":3,"file":"bech32.cjs","names":[],"sources":["../../src/utils/bech32.ts"],"sourcesContent":["import {\n bech32,\n} from \"bech32\";\n\n/**\n * Converts a byte array to a hexadecimal string representation\n * @param byteArray - Array of bytes to convert\n * @returns Hexadecimal string\n */\nfunction toHexString(byteArray: number[]) {\n return Array.prototype.map\n .call(\n byteArray, (byte) => {\n return (\"0\" + (byte & 0xff).toString(16)).slice(-2);\n },\n )\n .join(\"\");\n}\n\n/**\n * Extracts the key hash from a bech32-encoded address\n * @param address - Bech32-encoded address string\n * @returns Hexadecimal key hash\n * @throws Error if address cannot be decoded\n */\nfunction keyHashfromAddress(address: string): string {\n try {\n return toHexString(bech32.fromWords(bech32.decode(address).words));\n }\n catch (_e) {\n throw new Error(\"Could not decode address\");\n }\n}\n\n/**\n * Creates a bech32-encoded address from a key hash and prefix\n * @param prefix - Address prefix (e.g., \"cosmos\", \"cosmosvalcons\")\n * @param keyhash - Hexadecimal key hash\n * @returns Bech32-encoded address or empty string if keyhash is empty\n */\nfunction chainAddressfromKeyhash(prefix: string, keyhash: string) {\n const words = bech32.toWords(Buffer.from(\n keyhash, \"hex\",\n ));\n\n return keyhash !== \"\"\n ? bech32.encode(\n prefix, words,\n )\n : \"\";\n}\n\nexport {\n chainAddressfromKeyhash, keyHashfromAddress, toHexString,\n};\n"],"mappings":";;;;;;;;;AASA,SAAS,YAAY,WAAqB;AACxC,QAAO,MAAM,UAAU,IACpB,KACC,YAAY,SAAS;AACnB,UAAQ,OAAO,OAAO,KAAM,SAAS,GAAG,EAAE,MAAM,GAAG;GAEtD,CACA,KAAK,GAAG;;;;;;;;AASb,SAAS,mBAAmB,SAAyB;AACnD,KAAI;AACF,SAAO,YAAY,cAAO,UAAU,cAAO,OAAO,QAAQ,CAAC,MAAM,CAAC;UAE7D,IAAI;AACT,QAAM,IAAI,MAAM,2BAA2B;;;;;;;;;AAU/C,SAAS,wBAAwB,QAAgB,SAAiB;CAChE,MAAM,QAAQ,cAAO,QAAQ,OAAO,KAClC,SAAS,MACV,CAAC;AAEF,QAAO,YAAY,KACf,cAAO,OACP,QAAQ,MACT,GACC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["// Utility function exports\nexport * from \"./bech32\"; // Bech32 address encoding/decoding utilities\nexport * from \"./bigint\"; // BigInt handling utilities\nexport * from \"./text\"; // Text processing and encoding utilities\n"],"mappings":""}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\n// Utility function exports\nexport * from \"./bech32\"; // Bech32 address encoding/decoding utilities\nexport * from \"./bigint\"; // BigInt handling utilities\nexport * from \"./text\"; // Text processing and encoding utilities\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["// Utility function exports\nexport * from \"./bech32\"; // Bech32 address encoding/decoding utilities\nexport * from \"./bigint\"; // BigInt handling utilities\nexport * from \"./text\"; // Text processing and encoding utilities\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\n// Utility function exports\nexport * from \"./bech32\"; // Bech32 address encoding/decoding utilities\nexport * from \"./bigint\"; // BigInt handling utilities\nexport * from \"./text\"; // Text processing and encoding utilities\n"],"mappings":""}