@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/chunk-6XHWJ2VS.js +92 -0
- package/lib/chunk-6XHWJ2VS.js.map +1 -0
- package/lib/chunk-BPGFX5S5.js +10975 -0
- package/lib/chunk-BPGFX5S5.js.map +1 -0
- package/lib/{chunk-PDTC7P7O.js → chunk-NLEBXJPP.js} +24 -20
- package/lib/{chunk-PDTC7P7O.js.map → chunk-NLEBXJPP.js.map} +1 -1
- package/lib/{chunk-XR3EZ6FB.js → chunk-ZUTD563J.js} +60 -7
- package/lib/{chunk-XR3EZ6FB.js.map → chunk-ZUTD563J.js.map} +1 -1
- package/lib/index.d.ts +29 -9
- package/lib/index.js +12 -71
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.d.ts +6 -6
- package/lib/processor-runner.js +330 -11308
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.d.ts +4 -1
- package/lib/service-worker.js +37 -10
- package/lib/service-worker.js.map +1 -1
- package/lib/test-processor.test.js.map +1 -1
- package/package.json +1 -1
- package/src/db-context.ts +39 -18
- package/src/logger.ts +3 -2
- package/src/plugin.ts +3 -3
- package/src/processor-runner.ts +3 -5
- package/src/service-manager.ts +110 -137
- package/src/service-worker.ts +52 -9
- package/src/service.ts +1 -1
- package/src/state.ts +19 -0
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,
|
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
|
-
|
17
|
-
|
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
|
-
|
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(
|
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<
|
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?:
|
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
|
-
|
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-
|
31
|
+
} from "./chunk-NLEBXJPP.js";
|
24
32
|
import {
|
25
33
|
Plugin,
|
26
34
|
PluginManager
|
27
|
-
} from "./chunk-
|
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/
|
1
|
+
{"version":3,"sources":["../src/chain-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 };
|