@sentio/runtime 2.57.12-rc.j → 2.57.13-rc.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.
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _sentio_protos from '@sentio/protos';
2
- import { DeepPartial as DeepPartial$1, ProcessStreamResponse, DBResponse, DBRequest_DBUpsert, DBRequest, HandlerType, ProcessConfigResponse, StartRequest, DataBinding, PreparedData, ProcessResult, PreprocessResult, EthCallParam, ProcessorServiceImplementation, ProcessConfigRequest, Empty, ProcessBindingsRequest, ProcessBindingResponse, ProcessStreamRequest, PreprocessStreamRequest, PreprocessStreamResponse } from '@sentio/protos';
2
+ import { DeepPartial as DeepPartial$1, DBResponse, ProcessStreamResponse, DBRequest_DBUpsert, DBRequest, HandlerType, ProcessConfigResponse, StartRequest, DataBinding, PreparedData, ProcessResult, PreprocessResult, TemplateInstance, EthCallParam, ProcessorServiceImplementation, ProcessConfigRequest, Empty, ProcessBindingsRequest, ProcessBindingResponse, ProcessStreamRequest, PreprocessStreamRequest, PreprocessStreamResponse } from '@sentio/protos';
3
3
  import { Subject } from 'rxjs';
4
4
  import { AsyncLocalStorage } from 'node:async_hooks';
5
5
  import { Required } from 'utility-types';
@@ -13,15 +13,25 @@ import { Counter, Attributes, Gauge, Histogram } from '@opentelemetry/api';
13
13
  type Request = Omit<DBRequest, 'opId'>;
14
14
  type RequestType = keyof Request;
15
15
  declare const timeoutError: Error;
16
- declare class StoreContext {
17
- readonly subject: Subject<DeepPartial$1<ProcessStreamResponse>>;
16
+ interface IStoreContext {
17
+ sendRequest(request: DeepPartial$1<Request>, timeoutSecs?: number): Promise<DBResponse>;
18
+ result(dbResult: DBResponse): void;
19
+ error(processId: number, e: any): void;
20
+ close(): void;
21
+ }
22
+ declare abstract class AbstractStoreContext implements IStoreContext {
18
23
  readonly processId: number;
19
24
  private static opCounter;
20
- private defers;
25
+ protected defers: Map<bigint, {
26
+ resolve: (value: any) => void;
27
+ reject: (reason?: any) => void;
28
+ requestType?: RequestType;
29
+ }>;
21
30
  private statsInterval;
22
31
  private pendings;
23
- constructor(subject: Subject<DeepPartial$1<ProcessStreamResponse>>, processId: number);
32
+ constructor(processId: number);
24
33
  newPromise<T>(opId: bigint, requestType?: RequestType): Promise<T>;
34
+ abstract doSend(resp: DeepPartial$1<ProcessStreamResponse>): void;
25
35
  sendRequest(request: DeepPartial$1<Request>, timeoutSecs?: number): Promise<DBResponse>;
26
36
  result(dbResult: DBResponse): void;
27
37
  error(processId: number, e: any): void;
@@ -36,6 +46,11 @@ declare class StoreContext {
36
46
  private sendBatch;
37
47
  awaitPendings(): Promise<void>;
38
48
  }
49
+ declare class StoreContext extends AbstractStoreContext {
50
+ readonly subject: Subject<DeepPartial$1<ProcessStreamResponse>>;
51
+ constructor(subject: Subject<DeepPartial$1<ProcessStreamResponse>>, processId: number);
52
+ doSend(resp: DeepPartial$1<ProcessStreamResponse>): void;
53
+ }
39
54
 
40
55
  declare abstract class Plugin {
41
56
  name: string;
@@ -62,7 +77,7 @@ declare abstract class Plugin {
62
77
  }
63
78
  declare class PluginManager {
64
79
  static INSTANCE: PluginManager;
65
- dbContextLocalStorage: AsyncLocalStorage<StoreContext | undefined>;
80
+ dbContextLocalStorage: AsyncLocalStorage<IStoreContext | undefined>;
66
81
  plugins: Plugin[];
67
82
  typesToPlugin: Map<HandlerType, Plugin>;
68
83
  register(plugin: Plugin): void;
@@ -74,7 +89,7 @@ declare class PluginManager {
74
89
  * @deprecated The method should not be used, use ctx.states instead
75
90
  */
76
91
  stateDiff(config: ProcessConfigResponse): boolean;
77
- processBinding(request: DataBinding, preparedData: PreparedData | undefined, dbContext?: StoreContext): Promise<ProcessResult>;
92
+ processBinding(request: DataBinding, preparedData: PreparedData | undefined, dbContext?: IStoreContext): Promise<ProcessResult>;
78
93
  preprocessBinding(request: DataBinding, preprocessStore: {
79
94
  [k: string]: any;
80
95
  }, dbContext?: StoreContext): Promise<PreprocessResult>;
@@ -103,6 +118,11 @@ declare abstract class ListStateStorage<T> extends StateStorage<T[]> {
103
118
  getValues(): T[];
104
119
  addValue(value: T): T;
105
120
  }
121
+ declare class TemplateInstanceState extends ListStateStorage<TemplateInstance> {
122
+ static INSTANCE: TemplateInstanceState;
123
+ constructor();
124
+ addValue(value: TemplateInstance): TemplateInstance;
125
+ }
106
126
 
107
127
  declare function mergeProcessResults(results: ProcessResult[]): Required<ProcessResult, 'states'>;
108
128
  declare function errorString(e: Error): string;
@@ -462,7 +482,7 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
462
482
  } | undefined;
463
483
  } | undefined;
464
484
  }, void, undefined>;
465
- private handleRequests;
485
+ protected handleRequests(requests: AsyncIterable<ProcessStreamRequest>, subject: Subject<DeepPartial$1<ProcessStreamResponse>>): Promise<void>;
466
486
  }
467
487
  declare function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType): void;
468
488
 
@@ -661,4 +681,4 @@ declare const processMetrics: {
661
681
  };
662
682
  declare const metricsStorage: AsyncLocalStorage<string>;
663
683
 
664
- export { type ChainConfig, DummyProvider, Endpoints, GLOBAL_CONFIG, type GlobalConfig, ListStateStorage, MapStateStorage, Plugin, PluginManager, ProcessorServiceImpl, QueuedStaticJsonRpcProvider, type Semver, State, StateStorage, StoreContext, USER_PROCESSOR, compareSemver, configureEndpoints, dbMetrics, errorString, getProvider, makeEthCallKey, mergeProcessResults, metricsStorage, parseSemver, processMetrics, providerMetrics, recordRuntimeInfo, timeoutError };
684
+ export { AbstractStoreContext, type ChainConfig, DummyProvider, Endpoints, GLOBAL_CONFIG, type GlobalConfig, type IStoreContext, ListStateStorage, MapStateStorage, Plugin, PluginManager, ProcessorServiceImpl, QueuedStaticJsonRpcProvider, type Semver, State, StateStorage, StoreContext, TemplateInstanceState, USER_PROCESSOR, compareSemver, configureEndpoints, dbMetrics, errorString, getProvider, makeEthCallKey, mergeProcessResults, metricsStorage, parseSemver, processMetrics, providerMetrics, recordRuntimeInfo, timeoutError };
package/lib/index.js CHANGED
@@ -1,5 +1,13 @@
1
1
  import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
2
2
  import {
3
+ ListStateStorage,
4
+ MapStateStorage,
5
+ State,
6
+ StateStorage,
7
+ TemplateInstanceState
8
+ } from "./chunk-6XHWJ2VS.js";
9
+ import {
10
+ AbstractStoreContext,
3
11
  DummyProvider,
4
12
  Endpoints,
5
13
  GLOBAL_CONFIG,
@@ -20,80 +28,11 @@ import {
20
28
  providerMetrics,
21
29
  recordRuntimeInfo,
22
30
  timeoutError
23
- } from "./chunk-PDTC7P7O.js";
31
+ } from "./chunk-NLEBXJPP.js";
24
32
  import {
25
33
  Plugin,
26
34
  PluginManager
27
- } from "./chunk-XR3EZ6FB.js";
28
-
29
- // src/state.ts
30
- var State = class _State {
31
- stateMap = /* @__PURE__ */ new Map();
32
- static INSTANCE = new _State();
33
- static reset() {
34
- _State.INSTANCE = new _State();
35
- }
36
- };
37
- var StateStorage = class {
38
- // TODO learn how to define single instance for all subclasses
39
- constructor() {
40
- }
41
- key() {
42
- return this.constructor.name;
43
- }
44
- getOrRegister() {
45
- let metricState = State.INSTANCE.stateMap.get(this.key());
46
- if (!metricState) {
47
- metricState = this.initValue();
48
- State.INSTANCE.stateMap.set(this.key(), metricState);
49
- }
50
- return metricState;
51
- }
52
- unregister() {
53
- const value = State.INSTANCE.stateMap.get(this.key());
54
- State.INSTANCE.stateMap.delete(this.key());
55
- return value;
56
- }
57
- };
58
- var MapStateStorage = class extends StateStorage {
59
- initValue() {
60
- return /* @__PURE__ */ new Map();
61
- }
62
- getValue(key) {
63
- const m = this.getOrRegister();
64
- return m.get(key);
65
- }
66
- getValues() {
67
- const m = this.getOrRegister();
68
- return Array.from(m.values());
69
- }
70
- getOrSetValue(key, value) {
71
- const m = this.getOrRegister();
72
- const oldValue = m.get(key);
73
- if (oldValue) {
74
- if (oldValue !== value) {
75
- console.warn(key, "has been registered twice, use the previous one");
76
- }
77
- return oldValue;
78
- }
79
- m.set(key, value);
80
- return value;
81
- }
82
- };
83
- var ListStateStorage = class extends StateStorage {
84
- initValue() {
85
- return [];
86
- }
87
- getValues() {
88
- return this.getOrRegister();
89
- }
90
- addValue(value) {
91
- const m = this.getOrRegister();
92
- m.push(value);
93
- return value;
94
- }
95
- };
96
- import("node:process").then((p) => p.stdout.write(""));
35
+ } from "./chunk-ZUTD563J.js";
97
36
 
98
37
  // src/chain-config.ts
99
38
  import("node:process").then((p) => p.stdout.write(""));
@@ -101,6 +40,7 @@ import("node:process").then((p) => p.stdout.write(""));
101
40
  // src/index.ts
102
41
  import("node:process").then((p) => p.stdout.write(""));
103
42
  export {
43
+ AbstractStoreContext,
104
44
  DummyProvider,
105
45
  Endpoints,
106
46
  GLOBAL_CONFIG,
@@ -113,6 +53,7 @@ export {
113
53
  State,
114
54
  StateStorage,
115
55
  StoreContext,
56
+ TemplateInstanceState,
116
57
  USER_PROCESSOR,
117
58
  compareSemver,
118
59
  configureEndpoints,
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/state.ts","../src/chain-config.ts","../src/index.ts"],"sourcesContent":["export class State {\n stateMap = new Map<string, any>()\n\n static INSTANCE = new State()\n\n static reset() {\n State.INSTANCE = new State()\n }\n}\n\nexport abstract class StateStorage<T> {\n // TODO learn how to define single instance for all subclasses\n\n protected constructor() {\n //\n }\n\n abstract initValue(): T\n\n key(): string {\n return this.constructor.name\n }\n\n getOrRegister(): T {\n let metricState: T = State.INSTANCE.stateMap.get(this.key())\n if (!metricState) {\n metricState = this.initValue()\n State.INSTANCE.stateMap.set(this.key(), metricState)\n }\n return metricState\n }\n\n unregister(): T {\n const value = State.INSTANCE.stateMap.get(this.key())\n State.INSTANCE.stateMap.delete(this.key())\n return value\n }\n}\n\nexport abstract class MapStateStorage<T> extends StateStorage<Map<string, T>> {\n initValue() {\n return new Map<string, T>()\n }\n\n getValue(key: string): T | undefined {\n const m = this.getOrRegister()\n return m.get(key)\n }\n\n getValues(): T[] {\n const m = this.getOrRegister()\n return Array.from(m.values())\n }\n\n getOrSetValue(key: string, value: T): T {\n const m = this.getOrRegister()\n const oldValue = m.get(key)\n if (oldValue) {\n if (oldValue !== value) {\n console.warn(key, 'has been registered twice, use the previous one')\n }\n return oldValue\n }\n m.set(key, value)\n return value\n }\n}\n\nexport abstract class ListStateStorage<T> extends StateStorage<T[]> {\n initValue() {\n return []\n }\n\n getValues(): T[] {\n return this.getOrRegister()\n }\n\n addValue(value: T): T {\n const m = this.getOrRegister()\n m.push(value)\n return value\n }\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export interface ChainConfig {\n ChainID: string\n Https?: string[]\n ChainServer?: string\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './plugin.js'\nexport * from './state.js'\nexport * from './utils.js'\nexport * from './endpoints.js'\nexport * from './chain-config.js'\nexport * from './service.js'\nexport { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'\nexport * from './db-context.js'\nexport * from './provider.js'\nexport * from './metrics.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,QAAN,MAAM,OAAM;AAAA,EACjB,WAAW,oBAAI,IAAiB;AAAA,EAEhC,OAAO,WAAW,IAAI,OAAM;AAAA,EAE5B,OAAO,QAAQ;AACb,WAAM,WAAW,IAAI,OAAM;AAAA,EAC7B;AACF;AAEO,IAAe,eAAf,MAA+B;AAAA;AAAA,EAG1B,cAAc;AAAA,EAExB;AAAA,EAIA,MAAc;AACZ,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEA,gBAAmB;AACjB,QAAI,cAAiB,MAAM,SAAS,SAAS,IAAI,KAAK,IAAI,CAAC;AAC3D,QAAI,CAAC,aAAa;AAChB,oBAAc,KAAK,UAAU;AAC7B,YAAM,SAAS,SAAS,IAAI,KAAK,IAAI,GAAG,WAAW;AAAA,IACrD;AAC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-config.ts","../src/index.ts"],"sourcesContent":["export interface ChainConfig {\n ChainID: string\n Https?: string[]\n ChainServer?: string\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './plugin.js'\nexport * from './state.js'\nexport * from './utils.js'\nexport * from './endpoints.js'\nexport * from './chain-config.js'\nexport * from './service.js'\nexport { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'\nexport * from './db-context.js'\nexport * from './provider.js'\nexport * from './metrics.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;;;ACKrD,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
@@ -11,12 +11,6 @@ declare const optionDefinitions: ({
11
11
  type: StringConstructor;
12
12
  defaultValue: string;
13
13
  defaultOption?: undefined;
14
- } | {
15
- name: string;
16
- type: NumberConstructor;
17
- defaultValue: number;
18
- defaultOption?: undefined;
19
- alias?: undefined;
20
14
  } | {
21
15
  name: string;
22
16
  type: StringConstructor;
@@ -29,6 +23,12 @@ declare const optionDefinitions: ({
29
23
  defaultValue: boolean;
30
24
  defaultOption?: undefined;
31
25
  alias?: undefined;
26
+ } | {
27
+ name: string;
28
+ type: NumberConstructor;
29
+ defaultValue: string | number;
30
+ defaultOption?: undefined;
31
+ alias?: undefined;
32
32
  })[];
33
33
 
34
34
  export { optionDefinitions };