@sentio/runtime 2.60.0-rc.1 → 2.60.0-rc.11

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.
@@ -5,8 +5,9 @@ import {
5
5
  } from "./chunk-6XHWJ2VS.js";
6
6
  import {
7
7
  setupLogger
8
- } from "./chunk-RJMWLF3Q.js";
8
+ } from "./chunk-CYS2DAE4.js";
9
9
  import {
10
+ DataBindingContext,
10
11
  DiagConsoleLogger,
11
12
  DiagLogLevel,
12
13
  GLOBAL_CONFIG,
@@ -26,8 +27,10 @@ import {
26
27
  createContextKey,
27
28
  createNoopMeter,
28
29
  diag,
30
+ errorString,
29
31
  es_exports,
30
32
  esm_exports,
33
+ from,
31
34
  init_es,
32
35
  init_esm,
33
36
  isSpanContextValid,
@@ -35,20 +38,28 @@ import {
35
38
  isValidTraceId,
36
39
  metrics,
37
40
  parseSemver,
41
+ processMetrics,
38
42
  propagation,
43
+ recordRuntimeInfo,
44
+ require_cjs,
39
45
  require_lib,
40
46
  require_lib2,
41
47
  require_lib3,
42
48
  require_lib4,
43
49
  require_lodash,
44
50
  require_src,
45
- trace
46
- } from "./chunk-7JPTCCHQ.js";
51
+ trace,
52
+ withAbort
53
+ } from "./chunk-BOHR42T4.js";
47
54
  import {
48
55
  ExecutionConfig,
56
+ HandlerType,
57
+ InitResponse,
49
58
  PluginManager,
50
59
  ProcessConfigResponse,
60
+ ProcessResult,
51
61
  ProcessorDefinition,
62
+ ProcessorV3Definition,
52
63
  StartRequest,
53
64
  __commonJS,
54
65
  __esm,
@@ -57,7 +68,7 @@ import {
57
68
  __toCommonJS,
58
69
  __toESM,
59
70
  require_minimal2 as require_minimal
60
- } from "./chunk-AQYRWO7H.js";
71
+ } from "./chunk-TC6OWLVA.js";
61
72
 
62
73
  // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.25.1/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js
63
74
  // @__NO_SIDE_EFFECTS__
@@ -4498,14 +4509,14 @@ var init_callback = __esm({
4498
4509
  }
4499
4510
  return ar;
4500
4511
  };
4501
- __spreadArray = function(to, from, pack) {
4502
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4503
- if (ar || !(i in from)) {
4504
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4505
- ar[i] = from[i];
4512
+ __spreadArray = function(to, from2, pack) {
4513
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
4514
+ if (ar || !(i in from2)) {
4515
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
4516
+ ar[i] = from2[i];
4506
4517
  }
4507
4518
  }
4508
- return to.concat(ar || Array.prototype.slice.call(from));
4519
+ return to.concat(ar || Array.prototype.slice.call(from2));
4509
4520
  };
4510
4521
  BindOnceFuture = /** @class */
4511
4522
  function() {
@@ -5361,14 +5372,14 @@ var init_utils3 = __esm({
5361
5372
  }
5362
5373
  return ar;
5363
5374
  };
5364
- __spreadArray2 = function(to, from, pack) {
5365
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
5366
- if (ar || !(i in from)) {
5367
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5368
- ar[i] = from[i];
5375
+ __spreadArray2 = function(to, from2, pack) {
5376
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
5377
+ if (ar || !(i in from2)) {
5378
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
5379
+ ar[i] = from2[i];
5369
5380
  }
5370
5381
  }
5371
- return to.concat(ar || Array.prototype.slice.call(from));
5382
+ return to.concat(ar || Array.prototype.slice.call(from2));
5372
5383
  };
5373
5384
  __values5 = function(o) {
5374
5385
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
@@ -5684,14 +5695,14 @@ var init_Buckets = __esm({
5684
5695
  }
5685
5696
  return ar;
5686
5697
  };
5687
- __spreadArray3 = function(to, from, pack) {
5688
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
5689
- if (ar || !(i in from)) {
5690
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5691
- ar[i] = from[i];
5698
+ __spreadArray3 = function(to, from2, pack) {
5699
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
5700
+ if (ar || !(i in from2)) {
5701
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
5702
+ ar[i] = from2[i];
5692
5703
  }
5693
5704
  }
5694
- return to.concat(ar || Array.prototype.slice.call(from));
5705
+ return to.concat(ar || Array.prototype.slice.call(from2));
5695
5706
  };
5696
5707
  Buckets = /** @class */
5697
5708
  function() {
@@ -5857,11 +5868,11 @@ var init_Buckets = __esm({
5857
5868
  tmp.splice.apply(tmp, __spreadArray3([0, oldPositiveLimit], __read8(this._counts.slice(0, oldPositiveLimit)), false));
5858
5869
  this._counts = tmp;
5859
5870
  };
5860
- BucketsBacking2.prototype.reverse = function(from, limit) {
5861
- var num = Math.floor((from + limit) / 2) - from;
5871
+ BucketsBacking2.prototype.reverse = function(from2, limit) {
5872
+ var num = Math.floor((from2 + limit) / 2) - from2;
5862
5873
  for (var i = 0; i < num; i++) {
5863
- var tmp = this._counts[from + i];
5864
- this._counts[from + i] = this._counts[limit - i - 1];
5874
+ var tmp = this._counts[from2 + i];
5875
+ this._counts[from2 + i] = this._counts[limit - i - 1];
5865
5876
  this._counts[limit - i - 1] = tmp;
5866
5877
  }
5867
5878
  };
@@ -7109,14 +7120,14 @@ var init_MetricReader = __esm({
7109
7120
  }
7110
7121
  return ar;
7111
7122
  };
7112
- __spreadArray4 = function(to, from, pack) {
7113
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
7114
- if (ar || !(i in from)) {
7115
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
7116
- ar[i] = from[i];
7123
+ __spreadArray4 = function(to, from2, pack) {
7124
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
7125
+ if (ar || !(i in from2)) {
7126
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
7127
+ ar[i] = from2[i];
7117
7128
  }
7118
7129
  }
7119
- return to.concat(ar || Array.prototype.slice.call(from));
7130
+ return to.concat(ar || Array.prototype.slice.call(from2));
7120
7131
  };
7121
7132
  MetricReader = /** @class */
7122
7133
  function() {
@@ -7397,14 +7408,14 @@ var init_PeriodicExportingMetricReader = __esm({
7397
7408
  }
7398
7409
  return ar;
7399
7410
  };
7400
- __spreadArray5 = function(to, from, pack) {
7401
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
7402
- if (ar || !(i in from)) {
7403
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
7404
- ar[i] = from[i];
7411
+ __spreadArray5 = function(to, from2, pack) {
7412
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
7413
+ if (ar || !(i in from2)) {
7414
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
7415
+ ar[i] = from2[i];
7405
7416
  }
7406
7417
  }
7407
- return to.concat(ar || Array.prototype.slice.call(from));
7418
+ return to.concat(ar || Array.prototype.slice.call(from2));
7408
7419
  };
7409
7420
  PeriodicExportingMetricReader = /** @class */
7410
7421
  function(_super) {
@@ -8890,14 +8901,14 @@ var init_ObservableRegistry = __esm({
8890
8901
  }
8891
8902
  return ar;
8892
8903
  };
8893
- __spreadArray6 = function(to, from, pack) {
8894
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
8895
- if (ar || !(i in from)) {
8896
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
8897
- ar[i] = from[i];
8904
+ __spreadArray6 = function(to, from2, pack) {
8905
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
8906
+ if (ar || !(i in from2)) {
8907
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
8908
+ ar[i] = from2[i];
8898
8909
  }
8899
8910
  }
8900
- return to.concat(ar || Array.prototype.slice.call(from));
8911
+ return to.concat(ar || Array.prototype.slice.call(from2));
8901
8912
  };
8902
8913
  ObservableRegistry = /** @class */
8903
8914
  function() {
@@ -9549,14 +9560,14 @@ var init_MetricCollector = __esm({
9549
9560
  }
9550
9561
  return ar;
9551
9562
  };
9552
- __spreadArray7 = function(to, from, pack) {
9553
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
9554
- if (ar || !(i in from)) {
9555
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9556
- ar[i] = from[i];
9563
+ __spreadArray7 = function(to, from2, pack) {
9564
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
9565
+ if (ar || !(i in from2)) {
9566
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
9567
+ ar[i] = from2[i];
9557
9568
  }
9558
9569
  }
9559
- return to.concat(ar || Array.prototype.slice.call(from));
9570
+ return to.concat(ar || Array.prototype.slice.call(from2));
9560
9571
  };
9561
9572
  MetricCollector = /** @class */
9562
9573
  function() {
@@ -21446,14 +21457,14 @@ var init_Span = __esm({
21446
21457
  }
21447
21458
  return ar;
21448
21459
  };
21449
- __spreadArray8 = function(to, from, pack) {
21450
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
21451
- if (ar || !(i in from)) {
21452
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21453
- ar[i] = from[i];
21460
+ __spreadArray8 = function(to, from2, pack) {
21461
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
21462
+ if (ar || !(i in from2)) {
21463
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
21464
+ ar[i] = from2[i];
21454
21465
  }
21455
21466
  }
21456
- return to.concat(ar || Array.prototype.slice.call(from));
21467
+ return to.concat(ar || Array.prototype.slice.call(from2));
21457
21468
  };
21458
21469
  Span = /** @class */
21459
21470
  function() {
@@ -22506,14 +22517,14 @@ var init_BasicTracerProvider = __esm({
22506
22517
  }
22507
22518
  return ar;
22508
22519
  };
22509
- __spreadArray9 = function(to, from, pack) {
22510
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
22511
- if (ar || !(i in from)) {
22512
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22513
- ar[i] = from[i];
22520
+ __spreadArray9 = function(to, from2, pack) {
22521
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
22522
+ if (ar || !(i in from2)) {
22523
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
22524
+ ar[i] = from2[i];
22514
22525
  }
22515
22526
  }
22516
- return to.concat(ar || Array.prototype.slice.call(from));
22527
+ return to.concat(ar || Array.prototype.slice.call(from2));
22517
22528
  };
22518
22529
  (function(ForceFlushState2) {
22519
22530
  ForceFlushState2[ForceFlushState2["resolved"] = 0] = "resolved";
@@ -22783,14 +22794,14 @@ var init_InMemorySpanExporter = __esm({
22783
22794
  }
22784
22795
  return ar;
22785
22796
  };
22786
- __spreadArray10 = function(to, from, pack) {
22787
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
22788
- if (ar || !(i in from)) {
22789
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22790
- ar[i] = from[i];
22797
+ __spreadArray10 = function(to, from2, pack) {
22798
+ if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
22799
+ if (ar || !(i in from2)) {
22800
+ if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
22801
+ ar[i] = from2[i];
22791
22802
  }
22792
22803
  }
22793
- return to.concat(ar || Array.prototype.slice.call(from));
22804
+ return to.concat(ar || Array.prototype.slice.call(from2));
22794
22805
  };
22795
22806
  InMemorySpanExporter = /** @class */
22796
22807
  function() {
@@ -24204,17 +24215,17 @@ var require_range = __commonJS({
24204
24215
  debug("replaceGTE0", comp, options2);
24205
24216
  return comp.trim().replace(re2[options2.includePrerelease ? t.GTE0PRE : t.GTE0], "");
24206
24217
  };
24207
- var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
24218
+ var hyphenReplace = (incPr) => ($0, from2, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
24208
24219
  if (isX(fM)) {
24209
- from = "";
24220
+ from2 = "";
24210
24221
  } else if (isX(fm)) {
24211
- from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
24222
+ from2 = `>=${fM}.0.0${incPr ? "-0" : ""}`;
24212
24223
  } else if (isX(fp)) {
24213
- from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
24224
+ from2 = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
24214
24225
  } else if (fpr) {
24215
- from = `>=${from}`;
24226
+ from2 = `>=${from2}`;
24216
24227
  } else {
24217
- from = `>=${from}${incPr ? "-0" : ""}`;
24228
+ from2 = `>=${from2}${incPr ? "-0" : ""}`;
24218
24229
  }
24219
24230
  if (isX(tM)) {
24220
24231
  to = "";
@@ -24229,7 +24240,7 @@ var require_range = __commonJS({
24229
24240
  } else {
24230
24241
  to = `<=${to}`;
24231
24242
  }
24232
- return `${from} ${to}`.trim();
24243
+ return `${from2} ${to}`.trim();
24233
24244
  };
24234
24245
  var testSet = (set, version, options2) => {
24235
24246
  for (let i = 0; i < set.length; i++) {
@@ -25987,87 +25998,14 @@ function locatePackageJson(pkgId) {
25987
25998
  const content = import_fs_extra.default.readFileSync(path.join(dir, "package.json"), "utf-8");
25988
25999
  return JSON.parse(content);
25989
26000
  }
25990
- var FullProcessorServiceImpl = class {
25991
- constructor(instance) {
25992
- this.instance = instance;
26001
+ var RuntimeServicePatcher = class {
26002
+ sdkVersion;
26003
+ constructor() {
25993
26004
  const sdkPackageJson = locatePackageJson("@sentio/sdk");
25994
26005
  const runtimePackageJson = locatePackageJson("@sentio/runtime");
25995
26006
  console.log("Runtime version:", runtimePackageJson.version, "SDK version:", sdkPackageJson.version);
25996
26007
  this.sdkVersion = parseSemver(sdkPackageJson.version);
25997
26008
  }
25998
- instance;
25999
- sdkVersion;
26000
- async getConfig(request3, context2) {
26001
- const config = await this.instance.getConfig(request3, context2);
26002
- config.executionConfig = ExecutionConfig.fromPartial(GLOBAL_CONFIG.execution);
26003
- if (config.contractConfigs) {
26004
- for (const contract of config.contractConfigs) {
26005
- if (compareSemver(this.sdkVersion, FUEL_PROTO_NO_FUEL_TRANSACTION_AS_CALL_VERSION) < 0 && contract.fuelCallConfigs) {
26006
- contract.fuelTransactionConfigs = contract.fuelCallConfigs;
26007
- contract.fuelCallConfigs = void 0;
26008
- }
26009
- if (contract.fuelLogConfigs) {
26010
- contract.fuelReceiptConfigs = contract.fuelLogConfigs.map((e) => ({
26011
- handlerId: e.handlerId,
26012
- handlerName: e.handlerName,
26013
- log: {
26014
- logIds: e.logIds
26015
- }
26016
- }));
26017
- }
26018
- if (contract.aptosCallConfigs) {
26019
- contract.moveCallConfigs = contract.aptosCallConfigs;
26020
- }
26021
- if (contract.aptosEventConfigs) {
26022
- contract.moveEventConfigs = contract.aptosEventConfigs;
26023
- }
26024
- }
26025
- }
26026
- if (compareSemver(this.sdkVersion, MOVE_USE_RAW_VERSION) < 0) {
26027
- PROCESSED_MOVE_EVENT_TX_HANDLER.clear();
26028
- }
26029
- return config;
26030
- }
26031
- async start(request3, context2) {
26032
- return await this.instance.start(request3, context2);
26033
- }
26034
- async stop(request3, context2) {
26035
- return await this.instance.stop(request3, context2);
26036
- }
26037
- async processBindings(request3, options2) {
26038
- for (const binding of request3.bindings) {
26039
- this.adjustDataBinding(binding);
26040
- }
26041
- try {
26042
- const result = await this.instance.processBindings(request3, options2);
26043
- this.adjustResult(result.result);
26044
- if (!result.configUpdated && result.result?.states?.configUpdated) {
26045
- result.configUpdated = result.result?.states?.configUpdated;
26046
- }
26047
- return result;
26048
- } catch (e) {
26049
- if (this.sdkVersion.minor <= 16) {
26050
- if (e.code === os.constants.errno.ECONNRESET || e.code === os.constants.errno.ECONNREFUSED || e.code === os.constants.errno.ECONNABORTED) {
26051
- process.exit(1);
26052
- }
26053
- }
26054
- throw e;
26055
- }
26056
- }
26057
- async *adjustBindingsStream(requests) {
26058
- for await (const request3 of requests) {
26059
- this.adjustDataBinding(request3.binding);
26060
- yield request3;
26061
- }
26062
- }
26063
- async *processBindingsStream(requests, context2) {
26064
- yield* this.instance.processBindingsStream(this.adjustBindingsStream(requests), context2);
26065
- }
26066
- async *preprocessBindingsStream(requests, context2) {
26067
- yield* this.instance.preprocessBindingsStream(this.adjustBindingsStream(requests), context2);
26068
- }
26069
- adjustResult(res) {
26070
- }
26071
26009
  adjustDataBinding(dataBinding) {
26072
26010
  const isBeforeMoveUseRawVersion = compareSemver(this.sdkVersion, MOVE_USE_RAW_VERSION) < 0;
26073
26011
  if (!dataBinding) {
@@ -26208,6 +26146,117 @@ var FullProcessorServiceImpl = class {
26208
26146
  break;
26209
26147
  }
26210
26148
  }
26149
+ patchConfig(config) {
26150
+ config.executionConfig = ExecutionConfig.fromPartial(GLOBAL_CONFIG.execution);
26151
+ if (config.contractConfigs) {
26152
+ for (const contract of config.contractConfigs) {
26153
+ if (compareSemver(this.sdkVersion, FUEL_PROTO_NO_FUEL_TRANSACTION_AS_CALL_VERSION) < 0 && contract.fuelCallConfigs) {
26154
+ contract.fuelTransactionConfigs = contract.fuelCallConfigs;
26155
+ contract.fuelCallConfigs = void 0;
26156
+ }
26157
+ if (contract.fuelLogConfigs) {
26158
+ contract.fuelReceiptConfigs = contract.fuelLogConfigs.map((e) => ({
26159
+ handlerId: e.handlerId,
26160
+ handlerName: e.handlerName,
26161
+ log: {
26162
+ logIds: e.logIds
26163
+ }
26164
+ }));
26165
+ }
26166
+ if (contract.aptosCallConfigs) {
26167
+ contract.moveCallConfigs = contract.aptosCallConfigs;
26168
+ }
26169
+ if (contract.aptosEventConfigs) {
26170
+ contract.moveEventConfigs = contract.aptosEventConfigs;
26171
+ }
26172
+ }
26173
+ }
26174
+ }
26175
+ };
26176
+ var FullProcessorServiceImpl = class {
26177
+ constructor(instance) {
26178
+ this.instance = instance;
26179
+ const sdkPackageJson = locatePackageJson("@sentio/sdk");
26180
+ const runtimePackageJson = locatePackageJson("@sentio/runtime");
26181
+ console.log("Runtime version:", runtimePackageJson.version, "SDK version:", sdkPackageJson.version);
26182
+ this.sdkVersion = parseSemver(sdkPackageJson.version);
26183
+ }
26184
+ instance;
26185
+ sdkVersion;
26186
+ patcher = new RuntimeServicePatcher();
26187
+ async getConfig(request3, context2) {
26188
+ const config = await this.instance.getConfig(request3, context2);
26189
+ this.patcher.patchConfig(config);
26190
+ if (compareSemver(this.sdkVersion, MOVE_USE_RAW_VERSION) < 0) {
26191
+ PROCESSED_MOVE_EVENT_TX_HANDLER.clear();
26192
+ }
26193
+ return config;
26194
+ }
26195
+ async start(request3, context2) {
26196
+ return await this.instance.start(request3, context2);
26197
+ }
26198
+ async stop(request3, context2) {
26199
+ return await this.instance.stop(request3, context2);
26200
+ }
26201
+ async processBindings(request3, options2) {
26202
+ for (const binding of request3.bindings) {
26203
+ this.patcher.adjustDataBinding(binding);
26204
+ }
26205
+ try {
26206
+ const result = await this.instance.processBindings(request3, options2);
26207
+ this.adjustResult(result.result);
26208
+ if (!result.configUpdated && result.result?.states?.configUpdated) {
26209
+ result.configUpdated = result.result?.states?.configUpdated;
26210
+ }
26211
+ return result;
26212
+ } catch (e) {
26213
+ if (this.sdkVersion.minor <= 16) {
26214
+ if (e.code === os.constants.errno.ECONNRESET || e.code === os.constants.errno.ECONNREFUSED || e.code === os.constants.errno.ECONNABORTED) {
26215
+ process.exit(1);
26216
+ }
26217
+ }
26218
+ throw e;
26219
+ }
26220
+ }
26221
+ async *adjustBindingsStream(requests) {
26222
+ for await (const request3 of requests) {
26223
+ this.patcher.adjustDataBinding(request3.binding);
26224
+ yield request3;
26225
+ }
26226
+ }
26227
+ async *processBindingsStream(requests, context2) {
26228
+ yield* this.instance.processBindingsStream(this.adjustBindingsStream(requests), context2);
26229
+ }
26230
+ async *preprocessBindingsStream(requests, context2) {
26231
+ yield* this.instance.preprocessBindingsStream(this.adjustBindingsStream(requests), context2);
26232
+ }
26233
+ adjustResult(res) {
26234
+ }
26235
+ };
26236
+ var FullProcessorServiceV3Impl = class {
26237
+ constructor(instance) {
26238
+ this.instance = instance;
26239
+ }
26240
+ patcher = new RuntimeServicePatcher();
26241
+ async init(request3, context2) {
26242
+ const resp = await this.instance.init(request3, context2);
26243
+ resp.executionConfig = ExecutionConfig.fromPartial(GLOBAL_CONFIG.execution);
26244
+ return resp;
26245
+ }
26246
+ async configureHandlers(request3, context2) {
26247
+ const config = await this.instance.configureHandlers(request3, context2);
26248
+ this.patcher.patchConfig(config);
26249
+ return config;
26250
+ }
26251
+ async *processBindingsStream(requests, context2) {
26252
+ yield* this.instance.processBindingsStream(this.adjustBindingsStream(requests), context2);
26253
+ }
26254
+ async *adjustBindingsStream(requests) {
26255
+ for await (const request3 of requests) {
26256
+ this.patcher.adjustDataBinding(request3.binding);
26257
+ yield request3;
26258
+ }
26259
+ }
26211
26260
  };
26212
26261
  import("node:process").then((p) => p.stdout.write(""));
26213
26262
 
@@ -26436,6 +26485,159 @@ import("node:process").then((p) => p.stdout.write(""));
26436
26485
 
26437
26486
  // src/processor-runner.ts
26438
26487
  import path2 from "path";
26488
+
26489
+ // src/service-v3.ts
26490
+ var import_rxjs = __toESM(require_cjs(), 1);
26491
+ var { process_binding_count, process_binding_time, process_binding_error } = processMetrics;
26492
+ var ProcessorServiceImplV3 = class {
26493
+ enablePartition;
26494
+ loader;
26495
+ shutdownHandler;
26496
+ constructor(loader2, options2, shutdownHandler) {
26497
+ this.loader = loader2;
26498
+ this.shutdownHandler = shutdownHandler;
26499
+ this.enablePartition = options2?.["enable-partition"] == true;
26500
+ }
26501
+ async init(request3, context2) {
26502
+ await this.loader();
26503
+ const resp = InitResponse.fromPartial({
26504
+ chainIds: []
26505
+ });
26506
+ await PluginManager.INSTANCE.init(resp);
26507
+ resp.chainIds = Array.from(new Set(resp.chainIds));
26508
+ return resp;
26509
+ }
26510
+ async *processBindingsStream(requests, context2) {
26511
+ const subject = new import_rxjs.Subject();
26512
+ let lastBinding = void 0;
26513
+ for await (const request3 of requests) {
26514
+ try {
26515
+ if (request3.binding) {
26516
+ lastBinding = request3.binding;
26517
+ }
26518
+ this.handleRequest(request3, lastBinding, subject);
26519
+ } catch (e) {
26520
+ console.error("unexpect error during handle loop", e);
26521
+ }
26522
+ }
26523
+ yield* from(subject).pipe(withAbort(context2.signal));
26524
+ }
26525
+ contexts = new Contexts2();
26526
+ async handleRequest(request3, lastBinding, subject) {
26527
+ if (request3.binding) {
26528
+ process_binding_count.add(1);
26529
+ if (request3.binding.handlerType === HandlerType.UNKNOWN) {
26530
+ subject.next({
26531
+ processId: request3.processId,
26532
+ result: ProcessResult.create()
26533
+ });
26534
+ return;
26535
+ }
26536
+ if (this.enablePartition) {
26537
+ try {
26538
+ const partitions = await PluginManager.INSTANCE.partition(request3.binding);
26539
+ subject.next({
26540
+ processId: request3.processId,
26541
+ partitions
26542
+ });
26543
+ } catch (e) {
26544
+ console.error("Partition error:", e);
26545
+ subject.error(new Error("Partition error: " + errorString(e)));
26546
+ return;
26547
+ }
26548
+ } else {
26549
+ this.startProcess(request3.processId, request3.binding, subject);
26550
+ }
26551
+ }
26552
+ if (request3.start) {
26553
+ if (!lastBinding) {
26554
+ console.error("start request received without binding");
26555
+ subject.error(new Error("start request received without binding"));
26556
+ return;
26557
+ }
26558
+ this.startProcess(request3.processId, lastBinding, subject);
26559
+ }
26560
+ if (request3.dbResult) {
26561
+ const context2 = this.contexts.get(request3.processId);
26562
+ try {
26563
+ context2?.result(request3.dbResult);
26564
+ } catch (e) {
26565
+ subject.error(new Error("db result error, process should stop"));
26566
+ }
26567
+ }
26568
+ }
26569
+ startProcess(processId, binding, subject) {
26570
+ const context2 = this.contexts.new(processId, subject);
26571
+ const start = Date.now();
26572
+ PluginManager.INSTANCE.processBinding(binding, void 0, context2).then(async (result) => {
26573
+ await context2.awaitPendings();
26574
+ for (const ts of result.timeseriesResult) {
26575
+ subject.next({
26576
+ processId,
26577
+ tsRequest: {
26578
+ data: [ts]
26579
+ }
26580
+ });
26581
+ }
26582
+ if (result.states?.configUpdated) {
26583
+ subject.next({
26584
+ processId,
26585
+ tplRequest: {
26586
+ templates: TemplateInstanceState.INSTANCE.getValues()
26587
+ }
26588
+ });
26589
+ }
26590
+ subject.next({
26591
+ result: {
26592
+ states: result.states,
26593
+ exports: result.exports
26594
+ },
26595
+ processId
26596
+ });
26597
+ recordRuntimeInfo(result, binding.handlerType);
26598
+ }).catch((e) => {
26599
+ console.error(e, e.stack);
26600
+ context2.error(processId, e);
26601
+ process_binding_error.add(1);
26602
+ }).finally(() => {
26603
+ const cost = Date.now() - start;
26604
+ process_binding_time.add(cost);
26605
+ this.contexts.delete(processId);
26606
+ });
26607
+ }
26608
+ async configureHandlers(request3, context2) {
26609
+ await PluginManager.INSTANCE.start(
26610
+ StartRequest.fromPartial({
26611
+ templateInstances: request3.templateInstances
26612
+ })
26613
+ );
26614
+ const newConfig = ProcessConfigResponse.fromPartial({});
26615
+ await PluginManager.INSTANCE.configure(newConfig, request3.chainId);
26616
+ return {
26617
+ accountConfigs: newConfig.accountConfigs,
26618
+ contractConfigs: newConfig.contractConfigs
26619
+ };
26620
+ }
26621
+ };
26622
+ var Contexts2 = class {
26623
+ contexts = /* @__PURE__ */ new Map();
26624
+ get(processId) {
26625
+ return this.contexts.get(processId);
26626
+ }
26627
+ new(processId, subject) {
26628
+ const context2 = new DataBindingContext(processId, subject);
26629
+ this.contexts.set(processId, context2);
26630
+ return context2;
26631
+ }
26632
+ delete(processId) {
26633
+ const context2 = this.get(processId);
26634
+ context2?.close();
26635
+ this.contexts.delete(processId);
26636
+ }
26637
+ };
26638
+ import("node:process").then((p) => p.stdout.write(""));
26639
+
26640
+ // src/processor-runner.ts
26439
26641
  var workerNum = 1;
26440
26642
  try {
26441
26643
  workerNum = parseInt(process.env["PROCESSOR_WORKER"]?.trim() ?? "1");
@@ -26500,6 +26702,10 @@ if (options["start-action-server"]) {
26500
26702
  }
26501
26703
  const service = new FullProcessorServiceImpl(baseService);
26502
26704
  server.add(ProcessorDefinition, service);
26705
+ server.add(
26706
+ ProcessorV3Definition,
26707
+ new FullProcessorServiceV3Impl(new ProcessorServiceImplV3(loader, options, server.shutdown))
26708
+ );
26503
26709
  server.listen("0.0.0.0:" + options.port);
26504
26710
  console.log("Processor Server Started at:", options.port);
26505
26711
  }