@sentio/runtime 4.0.0-rc.9 → 4.0.1-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/dist/esm-CSGQo6hb.js +1773 -0
- package/dist/esm-CSGQo6hb.js.map +1 -0
- package/dist/execAsync-DiFDE921.js +14 -0
- package/dist/execAsync-DiFDE921.js.map +1 -0
- package/dist/getMachineId-bsd-57c_YWfQ.js +30 -0
- package/dist/getMachineId-bsd-57c_YWfQ.js.map +1 -0
- package/dist/getMachineId-darwin-dyf00K_U.js +27 -0
- package/dist/getMachineId-darwin-dyf00K_U.js.map +1 -0
- package/dist/getMachineId-linux-p9niCx07.js +23 -0
- package/dist/getMachineId-linux-p9niCx07.js.map +1 -0
- package/dist/getMachineId-unsupported-hKbFGxhH.js +18 -0
- package/dist/getMachineId-unsupported-hKbFGxhH.js.map +1 -0
- package/dist/getMachineId-win-Bn6Q0xbV.js +29 -0
- package/dist/getMachineId-win-Bn6Q0xbV.js.map +1 -0
- package/dist/index.d.ts +2780 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-BrBSx4KR.d.ts +111 -0
- package/dist/plugin-BrBSx4KR.d.ts.map +1 -0
- package/dist/plugin-Tb-OZb_A.js +6937 -0
- package/dist/plugin-Tb-OZb_A.js.map +1 -0
- package/dist/processor-runner.d.ts +1 -0
- package/dist/processor-runner.js +57749 -0
- package/dist/processor-runner.js.map +1 -0
- package/dist/service-v3-CtXk2PFI.js +12238 -0
- package/dist/service-v3-CtXk2PFI.js.map +1 -0
- package/package.json +9 -8
- package/src/chain-config.ts +1 -1
- package/src/endpoints.ts +5 -5
- package/src/gen/processor/protos/processor_pb.ts +6 -1
- package/src/tsdown.config.ts +29 -0
- package/lib/chunk-7JGO6QCN.js +0 -15174
- package/lib/chunk-7JGO6QCN.js.map +0 -1
- package/lib/chunk-I45UXGDM.js +0 -1697
- package/lib/chunk-I45UXGDM.js.map +0 -1
- package/lib/chunk-JTBA3KXU.js +0 -4988
- package/lib/chunk-JTBA3KXU.js.map +0 -1
- package/lib/chunk-KVSDPGUI.js +0 -50
- package/lib/chunk-KVSDPGUI.js.map +0 -1
- package/lib/chunk-LSYQ34WX.js +0 -21
- package/lib/chunk-LSYQ34WX.js.map +0 -1
- package/lib/getMachineId-bsd-OV63RCBF.js +0 -41
- package/lib/getMachineId-bsd-OV63RCBF.js.map +0 -1
- package/lib/getMachineId-darwin-7BY3RHHX.js +0 -41
- package/lib/getMachineId-darwin-7BY3RHHX.js.map +0 -1
- package/lib/getMachineId-linux-SN23MJRK.js +0 -33
- package/lib/getMachineId-linux-SN23MJRK.js.map +0 -1
- package/lib/getMachineId-unsupported-CQYUAEDB.js +0 -24
- package/lib/getMachineId-unsupported-CQYUAEDB.js.map +0 -1
- package/lib/getMachineId-win-NL4ZQSDA.js +0 -43
- package/lib/getMachineId-win-NL4ZQSDA.js.map +0 -1
- package/lib/index.d.ts +0 -1750
- package/lib/index.js +0 -135
- package/lib/index.js.map +0 -1
- package/lib/plugin-D-rx1WCp.d.ts +0 -108
- package/lib/processor-runner.d.ts +0 -1
- package/lib/processor-runner.js +0 -51178
- package/lib/processor-runner.js.map +0 -1
- package/src/tsup.config.ts +0 -17
package/lib/index.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
AbstractStoreContext,
|
|
4
|
-
DataBindingContext,
|
|
5
|
-
Endpoints,
|
|
6
|
-
GLOBAL_CONFIG,
|
|
7
|
-
ProcessorServiceImplV3,
|
|
8
|
-
StoreContext,
|
|
9
|
-
USER_PROCESSOR,
|
|
10
|
-
compareSemver,
|
|
11
|
-
configureEndpoints,
|
|
12
|
-
dbMetrics,
|
|
13
|
-
errorString,
|
|
14
|
-
locatePackageJson,
|
|
15
|
-
makeEthCallKey,
|
|
16
|
-
mergeProcessResults,
|
|
17
|
-
mergeProcessResultsInPlace,
|
|
18
|
-
metricsStorage,
|
|
19
|
-
parseSemver,
|
|
20
|
-
processMetrics,
|
|
21
|
-
providerMetrics,
|
|
22
|
-
recordRuntimeInfo,
|
|
23
|
-
timeoutError
|
|
24
|
-
} from "./chunk-7JGO6QCN.js";
|
|
25
|
-
import {
|
|
26
|
-
Plugin,
|
|
27
|
-
PluginManager
|
|
28
|
-
} from "./chunk-JTBA3KXU.js";
|
|
29
|
-
import "./chunk-I45UXGDM.js";
|
|
30
|
-
import "./chunk-KVSDPGUI.js";
|
|
31
|
-
|
|
32
|
-
// src/state.ts
|
|
33
|
-
var State = class _State {
|
|
34
|
-
stateMap = /* @__PURE__ */ new Map();
|
|
35
|
-
static INSTANCE = new _State();
|
|
36
|
-
static reset() {
|
|
37
|
-
_State.INSTANCE = new _State();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var StateStorage = class {
|
|
41
|
-
// TODO learn how to define single instance for all subclasses
|
|
42
|
-
constructor() {
|
|
43
|
-
}
|
|
44
|
-
key() {
|
|
45
|
-
return this.constructor.name;
|
|
46
|
-
}
|
|
47
|
-
getOrRegister() {
|
|
48
|
-
let metricState = State.INSTANCE.stateMap.get(this.key());
|
|
49
|
-
if (!metricState) {
|
|
50
|
-
metricState = this.initValue();
|
|
51
|
-
State.INSTANCE.stateMap.set(this.key(), metricState);
|
|
52
|
-
}
|
|
53
|
-
return metricState;
|
|
54
|
-
}
|
|
55
|
-
unregister() {
|
|
56
|
-
const value = State.INSTANCE.stateMap.get(this.key());
|
|
57
|
-
State.INSTANCE.stateMap.delete(this.key());
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var MapStateStorage = class extends StateStorage {
|
|
62
|
-
initValue() {
|
|
63
|
-
return /* @__PURE__ */ new Map();
|
|
64
|
-
}
|
|
65
|
-
getValue(key) {
|
|
66
|
-
const m = this.getOrRegister();
|
|
67
|
-
return m.get(key);
|
|
68
|
-
}
|
|
69
|
-
getValues() {
|
|
70
|
-
const m = this.getOrRegister();
|
|
71
|
-
return Array.from(m.values());
|
|
72
|
-
}
|
|
73
|
-
getOrSetValue(key, value) {
|
|
74
|
-
const m = this.getOrRegister();
|
|
75
|
-
const oldValue = m.get(key);
|
|
76
|
-
if (oldValue) {
|
|
77
|
-
if (oldValue !== value) {
|
|
78
|
-
console.warn(key, "has been registered twice, use the previous one");
|
|
79
|
-
}
|
|
80
|
-
return oldValue;
|
|
81
|
-
}
|
|
82
|
-
m.set(key, value);
|
|
83
|
-
return value;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var ListStateStorage = class extends StateStorage {
|
|
87
|
-
initValue() {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
getValues() {
|
|
91
|
-
return this.getOrRegister();
|
|
92
|
-
}
|
|
93
|
-
addValue(value) {
|
|
94
|
-
const m = this.getOrRegister();
|
|
95
|
-
m.push(value);
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
100
|
-
|
|
101
|
-
// src/chain-config.ts
|
|
102
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
103
|
-
|
|
104
|
-
// src/index.ts
|
|
105
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
106
|
-
export {
|
|
107
|
-
AbstractStoreContext,
|
|
108
|
-
DataBindingContext,
|
|
109
|
-
Endpoints,
|
|
110
|
-
GLOBAL_CONFIG,
|
|
111
|
-
ListStateStorage,
|
|
112
|
-
MapStateStorage,
|
|
113
|
-
Plugin,
|
|
114
|
-
PluginManager,
|
|
115
|
-
ProcessorServiceImplV3,
|
|
116
|
-
State,
|
|
117
|
-
StateStorage,
|
|
118
|
-
StoreContext,
|
|
119
|
-
USER_PROCESSOR,
|
|
120
|
-
compareSemver,
|
|
121
|
-
configureEndpoints,
|
|
122
|
-
dbMetrics,
|
|
123
|
-
errorString,
|
|
124
|
-
locatePackageJson,
|
|
125
|
-
makeEthCallKey,
|
|
126
|
-
mergeProcessResults,
|
|
127
|
-
mergeProcessResultsInPlace,
|
|
128
|
-
metricsStorage,
|
|
129
|
-
parseSemver,
|
|
130
|
-
processMetrics,
|
|
131
|
-
providerMetrics,
|
|
132
|
-
recordRuntimeInfo,
|
|
133
|
-
timeoutError
|
|
134
|
-
};
|
|
135
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 RpcConfig {\n Url: string\n Meta?: Record<string, string>\n}\n\nexport interface ChainConfig {\n ChainID: string\n Https?: string[]\n Rpc?: RpcConfig\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-v3.js'\nexport { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'\nexport * from './db-context.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;AACA,WAAO;AAAA,EACT;AAAA,EAEA,aAAgB;AACd,UAAM,QAAQ,MAAM,SAAS,SAAS,IAAI,KAAK,IAAI,CAAC;AACpD,UAAM,SAAS,SAAS,OAAO,KAAK,IAAI,CAAC;AACzC,WAAO;AAAA,EACT;AACF;AAEO,IAAe,kBAAf,cAA0C,aAA6B;AAAA,EAC5E,YAAY;AACV,WAAO,oBAAI,IAAe;AAAA,EAC5B;AAAA,EAEA,SAAS,KAA4B;AACnC,UAAM,IAAI,KAAK,cAAc;AAC7B,WAAO,EAAE,IAAI,GAAG;AAAA,EAClB;AAAA,EAEA,YAAiB;AACf,UAAM,IAAI,KAAK,cAAc;AAC7B,WAAO,MAAM,KAAK,EAAE,OAAO,CAAC;AAAA,EAC9B;AAAA,EAEA,cAAc,KAAa,OAAa;AACtC,UAAM,IAAI,KAAK,cAAc;AAC7B,UAAM,WAAW,EAAE,IAAI,GAAG;AAC1B,QAAI,UAAU;AACZ,UAAI,aAAa,OAAO;AACtB,gBAAQ,KAAK,KAAK,iDAAiD;AAAA,MACrE;AACA,aAAO;AAAA,IACT;AACA,MAAE,IAAI,KAAK,KAAK;AAChB,WAAO;AAAA,EACT;AACF;AAEO,IAAe,mBAAf,cAA2C,aAAkB;AAAA,EAClE,YAAY;AACV,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,YAAiB;AACf,WAAO,KAAK,cAAc;AAAA,EAC5B;AAAA,EAEA,SAAS,OAAa;AACpB,UAAM,IAAI,KAAK,cAAc;AAC7B,MAAE,KAAK,KAAK;AACZ,WAAO;AAAA,EACT;AACF;AACC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;;;ACzErD,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;;;ACDrD,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
|
package/lib/plugin-D-rx1WCp.d.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { DBResponse, TemplateInstance, TimeseriesResult, DBRequest_DBUpsert, ProcessStreamResponseSchema, ProcessStreamResponseV3Schema, DBRequestSchema, HandlerType, ProcessConfigResponse, StartRequest, DataBinding, PreparedData, ProcessResult, PreprocessResult, ProcessStreamResponse_Partitions, UpdateTemplatesRequest } from '@sentio/protos';
|
|
2
|
-
import { Subject } from 'rxjs';
|
|
3
|
-
import { MessageInitShape } from '@bufbuild/protobuf';
|
|
4
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
|
-
|
|
6
|
-
type ProcessStreamResponseInit = MessageInitShape<typeof ProcessStreamResponseSchema>;
|
|
7
|
-
type ProcessStreamResponseV3Init = MessageInitShape<typeof ProcessStreamResponseV3Schema>;
|
|
8
|
-
type Request = NonNullable<MessageInitShape<typeof DBRequestSchema>['op']>;
|
|
9
|
-
type RequestType = NonNullable<Request['case']>;
|
|
10
|
-
declare const timeoutError: Error;
|
|
11
|
-
interface IStoreContext {
|
|
12
|
-
sendRequest(request: Request, timeoutSecs?: number): Promise<DBResponse>;
|
|
13
|
-
result(dbResult: DBResponse): void;
|
|
14
|
-
error(processId: number, e: any): void;
|
|
15
|
-
close(): void;
|
|
16
|
-
}
|
|
17
|
-
interface IDataBindingContext extends IStoreContext {
|
|
18
|
-
sendTemplateRequest(templates: Array<TemplateInstance>, unbind: boolean): void;
|
|
19
|
-
sendTimeseriesRequest(timeseries: Array<TimeseriesResult>): void;
|
|
20
|
-
}
|
|
21
|
-
declare abstract class AbstractStoreContext implements IStoreContext {
|
|
22
|
-
readonly processId: number;
|
|
23
|
-
private static opCounter;
|
|
24
|
-
protected defers: Map<bigint, {
|
|
25
|
-
resolve: (value: any) => void;
|
|
26
|
-
reject: (reason?: any) => void;
|
|
27
|
-
requestType?: RequestType;
|
|
28
|
-
}>;
|
|
29
|
-
private statsInterval;
|
|
30
|
-
private pendings;
|
|
31
|
-
constructor(processId: number);
|
|
32
|
-
newPromise<T>(opId: bigint, requestType?: RequestType): Promise<T>;
|
|
33
|
-
abstract doSend(resp: ProcessStreamResponseInit | ProcessStreamResponseV3Init): void;
|
|
34
|
-
sendRequest(request: Request, timeoutSecs?: number): Promise<DBResponse>;
|
|
35
|
-
result(dbResult: DBResponse): void;
|
|
36
|
-
error(processId: number, e: any): void;
|
|
37
|
-
close(): void;
|
|
38
|
-
upsertBatch: {
|
|
39
|
-
opId: bigint;
|
|
40
|
-
request: DBRequest_DBUpsert;
|
|
41
|
-
promise: Promise<DBResponse>;
|
|
42
|
-
timer: NodeJS.Timeout;
|
|
43
|
-
} | undefined;
|
|
44
|
-
private sendUpsertInBatch;
|
|
45
|
-
private sendBatch;
|
|
46
|
-
awaitPendings(): Promise<void>;
|
|
47
|
-
}
|
|
48
|
-
declare class StoreContext extends AbstractStoreContext {
|
|
49
|
-
readonly subject: Subject<ProcessStreamResponseInit>;
|
|
50
|
-
constructor(subject: Subject<ProcessStreamResponseInit>, processId: number);
|
|
51
|
-
doSend(resp: ProcessStreamResponseInit): void;
|
|
52
|
-
}
|
|
53
|
-
declare class DataBindingContext extends AbstractStoreContext implements IDataBindingContext {
|
|
54
|
-
readonly processId: number;
|
|
55
|
-
readonly subject: Subject<ProcessStreamResponseV3Init>;
|
|
56
|
-
constructor(processId: number, subject: Subject<ProcessStreamResponseV3Init>);
|
|
57
|
-
sendTemplateRequest(templates: Array<TemplateInstance>, unbind: boolean): void;
|
|
58
|
-
sendTimeseriesRequest(timeseries: Array<TimeseriesResult>): void;
|
|
59
|
-
doSend(resp: ProcessStreamResponseV3Init): void;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
declare abstract class Plugin {
|
|
63
|
-
name: string;
|
|
64
|
-
supportedHandlers: HandlerType[];
|
|
65
|
-
configure(config: ProcessConfigResponse, forChainId?: string): Promise<void>;
|
|
66
|
-
start(start: StartRequest): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated The method should not be used, use ctx.states instead
|
|
69
|
-
*/
|
|
70
|
-
stateDiff(config: ProcessConfigResponse): boolean;
|
|
71
|
-
processBinding(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult>;
|
|
72
|
-
preprocessBinding(request: DataBinding, preprocessStore: {
|
|
73
|
-
[k: string]: any;
|
|
74
|
-
}): Promise<PreprocessResult>;
|
|
75
|
-
partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions>;
|
|
76
|
-
/**
|
|
77
|
-
* method used by action server only
|
|
78
|
-
* @param port
|
|
79
|
-
*/
|
|
80
|
-
startServer(port?: number): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* method used by action server only
|
|
83
|
-
*/
|
|
84
|
-
shutdownServer(): void;
|
|
85
|
-
}
|
|
86
|
-
declare class PluginManager {
|
|
87
|
-
static INSTANCE: PluginManager;
|
|
88
|
-
dbContextLocalStorage: AsyncLocalStorage<IStoreContext | IDataBindingContext | undefined>;
|
|
89
|
-
plugins: Plugin[];
|
|
90
|
-
typesToPlugin: Map<HandlerType, Plugin>;
|
|
91
|
-
register(plugin: Plugin): void;
|
|
92
|
-
configure(config: ProcessConfigResponse): Promise<void>;
|
|
93
|
-
start(start: StartRequest, actionServerPort?: number): Promise<void[]>;
|
|
94
|
-
startServer(port?: number): Promise<void[]>;
|
|
95
|
-
shutdown(): void;
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated The method should not be used, use ctx.states instead
|
|
98
|
-
*/
|
|
99
|
-
stateDiff(config: ProcessConfigResponse): boolean;
|
|
100
|
-
processBinding(request: DataBinding, preparedData: PreparedData | undefined, dbContext?: IDataBindingContext | IStoreContext): Promise<ProcessResult>;
|
|
101
|
-
partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions>;
|
|
102
|
-
preprocessBinding(request: DataBinding, preprocessStore: {
|
|
103
|
-
[k: string]: any;
|
|
104
|
-
}, dbContext?: IDataBindingContext | IStoreContext): Promise<PreprocessResult>;
|
|
105
|
-
updateTemplates(request: UpdateTemplatesRequest): Promise<void>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export { AbstractStoreContext as A, DataBindingContext as D, type IStoreContext as I, Plugin as P, StoreContext as S, PluginManager as a, type IDataBindingContext as b, timeoutError as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|