@sentio/runtime 2.60.0-rc.12 → 2.60.0-rc.14
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-CYS2DAE4.js → chunk-26X74ASV.js} +2 -2
- package/lib/{chunk-BOHR42T4.js → chunk-2JZQGMEZ.js} +3 -2
- package/lib/{chunk-BOHR42T4.js.map → chunk-2JZQGMEZ.js.map} +1 -1
- package/lib/{chunk-TC6OWLVA.js → chunk-ZTW66EYL.js} +2 -1
- package/lib/chunk-ZTW66EYL.js.map +1 -0
- package/lib/index.d.ts +10 -147
- package/lib/index.js +2 -2
- package/lib/processor-BDXlufg5.d.ts +900 -0
- package/lib/processor-runner.js +19 -4
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.js +3 -3
- package/lib/test-processor.test.d.ts +14 -1
- package/lib/test-processor.test.js.map +1 -1
- package/package.json +1 -1
- package/src/db-context.ts +1 -0
- package/src/gen/service/common/protos/common.ts +134 -1
- package/src/service-v3.ts +24 -2
- package/lib/chunk-TC6OWLVA.js.map +0 -1
- /package/lib/{chunk-CYS2DAE4.js.map → chunk-26X74ASV.js.map} +0 -0
package/lib/service-worker.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
2
2
|
import {
|
3
3
|
setupLogger
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-26X74ASV.js";
|
5
5
|
import {
|
6
6
|
ProcessorServiceImpl,
|
7
7
|
configureEndpoints,
|
@@ -10,10 +10,10 @@ import {
|
|
10
10
|
require_cjs,
|
11
11
|
require_lib3 as require_lib,
|
12
12
|
require_lib4 as require_lib2
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-2JZQGMEZ.js";
|
14
14
|
import {
|
15
15
|
__toESM
|
16
|
-
} from "./chunk-
|
16
|
+
} from "./chunk-ZTW66EYL.js";
|
17
17
|
|
18
18
|
// src/service-worker.ts
|
19
19
|
var import_nice_grpc = __toESM(require_lib(), 1);
|
@@ -1,2 +1,15 @@
|
|
1
|
+
import { P as Plugin, c as DataBinding, d as ProcessResult, H as HandlerType } from './processor-BDXlufg5.js';
|
2
|
+
import { ProcessStreamResponse_Partitions, InitResponse, ProcessConfigResponse } from '@sentio/protos';
|
3
|
+
import 'rxjs';
|
4
|
+
import 'node:async_hooks';
|
5
|
+
import 'protobufjs/minimal.js';
|
1
6
|
|
2
|
-
|
7
|
+
declare class TestPlugin extends Plugin {
|
8
|
+
processBinding(request: DataBinding): Promise<ProcessResult>;
|
9
|
+
supportedHandlers: HandlerType[];
|
10
|
+
partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions>;
|
11
|
+
init(config: InitResponse): Promise<void>;
|
12
|
+
configure(config: ProcessConfigResponse, forChainId?: string): Promise<void>;
|
13
|
+
}
|
14
|
+
|
15
|
+
export { TestPlugin };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/test-processor.test.ts"],"sourcesContent":["import { Plugin, PluginManager } from './plugin.js'\nimport { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'\nimport { ProcessStreamResponse_Partitions } from '@sentio/protos'\n\
|
1
|
+
{"version":3,"sources":["../src/test-processor.test.ts"],"sourcesContent":["import { Plugin, PluginManager } from './plugin.js'\nimport { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'\nimport { AccountConfig, InitResponse, ProcessConfigResponse, ProcessStreamResponse_Partitions } from '@sentio/protos'\n\nexport class TestPlugin extends Plugin {\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n const dbContext = PluginManager.INSTANCE.dbContextLocalStorage.getStore()\n if (dbContext) {\n await dbContext.sendRequest({\n get: {\n entity: 'Test',\n id: '1'\n }\n })\n }\n\n return ProcessResult.fromPartial({\n states: {\n configUpdated: true\n }\n })\n }\n supportedHandlers = [HandlerType.UNKNOWN, HandlerType.ETH_LOG]\n\n async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {\n return {\n partitions: request.handlerIds.reduce(\n (acc, id) => ({\n ...acc,\n [id]: {\n userValue: 'test'\n }\n }),\n {}\n )\n }\n }\n\n async init(config: InitResponse): Promise<void> {\n config.chainIds = ['1']\n }\n\n async configure(config: ProcessConfigResponse, forChainId?: string): Promise<void> {\n config.accountConfigs = [\n AccountConfig.fromPartial({\n address: '0x',\n chainId: '1'\n })\n ]\n }\n}\n\nPluginManager.INSTANCE.plugins = []\nPluginManager.INSTANCE.register(new TestPlugin())\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;AAIO,IAAM,aAAN,cAAyB,OAAO;AAAA,EACrC,MAAM,eAAe,SAA8C;AACjE,UAAM,YAAY,cAAc,SAAS,sBAAsB,SAAS;AACxE,QAAI,WAAW;AACb,YAAM,UAAU,YAAY;AAAA,QAC1B,KAAK;AAAA,UACH,QAAQ;AAAA,UACR,IAAI;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO,cAAc,YAAY;AAAA,MAC/B,QAAQ;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,oBAAoB,iCAAyC;AAAA,EAE7D,MAAM,UAAU,SAAiE;AAC/E,WAAO;AAAA,MACL,YAAY,QAAQ,WAAW;AAAA,QAC7B,CAAC,KAAK,QAAQ;AAAA,UACZ,GAAG;AAAA,UACH,CAAC,EAAE,GAAG;AAAA,YACJ,WAAW;AAAA,UACb;AAAA,QACF;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,KAAK,QAAqC;AAC9C,WAAO,WAAW,CAAC,GAAG;AAAA,EACxB;AAAA,EAEA,MAAM,UAAU,QAA+B,YAAoC;AACjF,WAAO,iBAAiB;AAAA,MACtB,cAAc,YAAY;AAAA,QACxB,SAAS;AAAA,QACT,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,cAAc,SAAS,UAAU,CAAC;AAClC,cAAc,SAAS,SAAS,IAAI,WAAW,CAAC;AAC/C,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
|
package/package.json
CHANGED
package/src/db-context.ts
CHANGED
@@ -280,6 +280,7 @@ export class DataBindingContext extends AbstractStoreContext implements IDataBin
|
|
280
280
|
}
|
281
281
|
|
282
282
|
doSend(resp: DeepPartial<ProcessStreamResponseV2>) {
|
283
|
+
console.debug('sending db request, processId ', this.processId, 'opId', resp.dbRequest?.opId)
|
283
284
|
this.subject.next({
|
284
285
|
...resp,
|
285
286
|
processId: this.processId
|
@@ -348,6 +348,7 @@ export interface User {
|
|
348
348
|
username: string;
|
349
349
|
accountStatus: User_AccountStatus;
|
350
350
|
tier: Tier;
|
351
|
+
isOrganization: boolean;
|
351
352
|
}
|
352
353
|
|
353
354
|
export enum User_AccountStatus {
|
@@ -517,6 +518,12 @@ export interface Project_ProjectMember {
|
|
517
518
|
export interface CommunityProject {
|
518
519
|
dashAlias: string;
|
519
520
|
curated?: boolean | undefined;
|
521
|
+
chain: { [key: string]: StringList };
|
522
|
+
}
|
523
|
+
|
524
|
+
export interface CommunityProject_ChainEntry {
|
525
|
+
key: string;
|
526
|
+
value: StringList | undefined;
|
520
527
|
}
|
521
528
|
|
522
529
|
export interface ProjectInfo {
|
@@ -2535,6 +2542,7 @@ function createBaseUser(): User {
|
|
2535
2542
|
username: "",
|
2536
2543
|
accountStatus: 0,
|
2537
2544
|
tier: 0,
|
2545
|
+
isOrganization: false,
|
2538
2546
|
};
|
2539
2547
|
}
|
2540
2548
|
|
@@ -2588,6 +2596,9 @@ export const User = {
|
|
2588
2596
|
if (message.tier !== 0) {
|
2589
2597
|
writer.uint32(120).int32(message.tier);
|
2590
2598
|
}
|
2599
|
+
if (message.isOrganization !== false) {
|
2600
|
+
writer.uint32(128).bool(message.isOrganization);
|
2601
|
+
}
|
2591
2602
|
return writer;
|
2592
2603
|
},
|
2593
2604
|
|
@@ -2696,6 +2707,13 @@ export const User = {
|
|
2696
2707
|
|
2697
2708
|
message.tier = reader.int32() as any;
|
2698
2709
|
continue;
|
2710
|
+
case 16:
|
2711
|
+
if (tag !== 128) {
|
2712
|
+
break;
|
2713
|
+
}
|
2714
|
+
|
2715
|
+
message.isOrganization = reader.bool();
|
2716
|
+
continue;
|
2699
2717
|
}
|
2700
2718
|
if ((tag & 7) === 4 || tag === 0) {
|
2701
2719
|
break;
|
@@ -2721,6 +2739,7 @@ export const User = {
|
|
2721
2739
|
username: isSet(object.username) ? globalThis.String(object.username) : "",
|
2722
2740
|
accountStatus: isSet(object.accountStatus) ? user_AccountStatusFromJSON(object.accountStatus) : 0,
|
2723
2741
|
tier: isSet(object.tier) ? tierFromJSON(object.tier) : 0,
|
2742
|
+
isOrganization: isSet(object.isOrganization) ? globalThis.Boolean(object.isOrganization) : false,
|
2724
2743
|
};
|
2725
2744
|
},
|
2726
2745
|
|
@@ -2768,6 +2787,9 @@ export const User = {
|
|
2768
2787
|
if (message.tier !== 0) {
|
2769
2788
|
obj.tier = tierToJSON(message.tier);
|
2770
2789
|
}
|
2790
|
+
if (message.isOrganization !== false) {
|
2791
|
+
obj.isOrganization = message.isOrganization;
|
2792
|
+
}
|
2771
2793
|
return obj;
|
2772
2794
|
},
|
2773
2795
|
|
@@ -2790,6 +2812,7 @@ export const User = {
|
|
2790
2812
|
message.username = object.username ?? "";
|
2791
2813
|
message.accountStatus = object.accountStatus ?? 0;
|
2792
2814
|
message.tier = object.tier ?? 0;
|
2815
|
+
message.isOrganization = object.isOrganization ?? false;
|
2793
2816
|
return message;
|
2794
2817
|
},
|
2795
2818
|
};
|
@@ -3493,7 +3516,7 @@ export const Project_ProjectMember = {
|
|
3493
3516
|
};
|
3494
3517
|
|
3495
3518
|
function createBaseCommunityProject(): CommunityProject {
|
3496
|
-
return { dashAlias: "", curated: undefined };
|
3519
|
+
return { dashAlias: "", curated: undefined, chain: {} };
|
3497
3520
|
}
|
3498
3521
|
|
3499
3522
|
export const CommunityProject = {
|
@@ -3504,6 +3527,9 @@ export const CommunityProject = {
|
|
3504
3527
|
if (message.curated !== undefined) {
|
3505
3528
|
writer.uint32(16).bool(message.curated);
|
3506
3529
|
}
|
3530
|
+
Object.entries(message.chain).forEach(([key, value]) => {
|
3531
|
+
CommunityProject_ChainEntry.encode({ key: key as any, value }, writer.uint32(26).fork()).ldelim();
|
3532
|
+
});
|
3507
3533
|
return writer;
|
3508
3534
|
},
|
3509
3535
|
|
@@ -3528,6 +3554,16 @@ export const CommunityProject = {
|
|
3528
3554
|
|
3529
3555
|
message.curated = reader.bool();
|
3530
3556
|
continue;
|
3557
|
+
case 3:
|
3558
|
+
if (tag !== 26) {
|
3559
|
+
break;
|
3560
|
+
}
|
3561
|
+
|
3562
|
+
const entry3 = CommunityProject_ChainEntry.decode(reader, reader.uint32());
|
3563
|
+
if (entry3.value !== undefined) {
|
3564
|
+
message.chain[entry3.key] = entry3.value;
|
3565
|
+
}
|
3566
|
+
continue;
|
3531
3567
|
}
|
3532
3568
|
if ((tag & 7) === 4 || tag === 0) {
|
3533
3569
|
break;
|
@@ -3541,6 +3577,12 @@ export const CommunityProject = {
|
|
3541
3577
|
return {
|
3542
3578
|
dashAlias: isSet(object.dashAlias) ? globalThis.String(object.dashAlias) : "",
|
3543
3579
|
curated: isSet(object.curated) ? globalThis.Boolean(object.curated) : undefined,
|
3580
|
+
chain: isObject(object.chain)
|
3581
|
+
? Object.entries(object.chain).reduce<{ [key: string]: StringList }>((acc, [key, value]) => {
|
3582
|
+
acc[key] = StringList.fromJSON(value);
|
3583
|
+
return acc;
|
3584
|
+
}, {})
|
3585
|
+
: {},
|
3544
3586
|
};
|
3545
3587
|
},
|
3546
3588
|
|
@@ -3552,6 +3594,15 @@ export const CommunityProject = {
|
|
3552
3594
|
if (message.curated !== undefined) {
|
3553
3595
|
obj.curated = message.curated;
|
3554
3596
|
}
|
3597
|
+
if (message.chain) {
|
3598
|
+
const entries = Object.entries(message.chain);
|
3599
|
+
if (entries.length > 0) {
|
3600
|
+
obj.chain = {};
|
3601
|
+
entries.forEach(([k, v]) => {
|
3602
|
+
obj.chain[k] = StringList.toJSON(v);
|
3603
|
+
});
|
3604
|
+
}
|
3605
|
+
}
|
3555
3606
|
return obj;
|
3556
3607
|
},
|
3557
3608
|
|
@@ -3562,6 +3613,88 @@ export const CommunityProject = {
|
|
3562
3613
|
const message = createBaseCommunityProject();
|
3563
3614
|
message.dashAlias = object.dashAlias ?? "";
|
3564
3615
|
message.curated = object.curated ?? undefined;
|
3616
|
+
message.chain = Object.entries(object.chain ?? {}).reduce<{ [key: string]: StringList }>((acc, [key, value]) => {
|
3617
|
+
if (value !== undefined) {
|
3618
|
+
acc[key] = StringList.fromPartial(value);
|
3619
|
+
}
|
3620
|
+
return acc;
|
3621
|
+
}, {});
|
3622
|
+
return message;
|
3623
|
+
},
|
3624
|
+
};
|
3625
|
+
|
3626
|
+
function createBaseCommunityProject_ChainEntry(): CommunityProject_ChainEntry {
|
3627
|
+
return { key: "", value: undefined };
|
3628
|
+
}
|
3629
|
+
|
3630
|
+
export const CommunityProject_ChainEntry = {
|
3631
|
+
encode(message: CommunityProject_ChainEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
3632
|
+
if (message.key !== "") {
|
3633
|
+
writer.uint32(10).string(message.key);
|
3634
|
+
}
|
3635
|
+
if (message.value !== undefined) {
|
3636
|
+
StringList.encode(message.value, writer.uint32(18).fork()).ldelim();
|
3637
|
+
}
|
3638
|
+
return writer;
|
3639
|
+
},
|
3640
|
+
|
3641
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): CommunityProject_ChainEntry {
|
3642
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
3643
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
3644
|
+
const message = createBaseCommunityProject_ChainEntry();
|
3645
|
+
while (reader.pos < end) {
|
3646
|
+
const tag = reader.uint32();
|
3647
|
+
switch (tag >>> 3) {
|
3648
|
+
case 1:
|
3649
|
+
if (tag !== 10) {
|
3650
|
+
break;
|
3651
|
+
}
|
3652
|
+
|
3653
|
+
message.key = reader.string();
|
3654
|
+
continue;
|
3655
|
+
case 2:
|
3656
|
+
if (tag !== 18) {
|
3657
|
+
break;
|
3658
|
+
}
|
3659
|
+
|
3660
|
+
message.value = StringList.decode(reader, reader.uint32());
|
3661
|
+
continue;
|
3662
|
+
}
|
3663
|
+
if ((tag & 7) === 4 || tag === 0) {
|
3664
|
+
break;
|
3665
|
+
}
|
3666
|
+
reader.skipType(tag & 7);
|
3667
|
+
}
|
3668
|
+
return message;
|
3669
|
+
},
|
3670
|
+
|
3671
|
+
fromJSON(object: any): CommunityProject_ChainEntry {
|
3672
|
+
return {
|
3673
|
+
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
3674
|
+
value: isSet(object.value) ? StringList.fromJSON(object.value) : undefined,
|
3675
|
+
};
|
3676
|
+
},
|
3677
|
+
|
3678
|
+
toJSON(message: CommunityProject_ChainEntry): unknown {
|
3679
|
+
const obj: any = {};
|
3680
|
+
if (message.key !== "") {
|
3681
|
+
obj.key = message.key;
|
3682
|
+
}
|
3683
|
+
if (message.value !== undefined) {
|
3684
|
+
obj.value = StringList.toJSON(message.value);
|
3685
|
+
}
|
3686
|
+
return obj;
|
3687
|
+
},
|
3688
|
+
|
3689
|
+
create(base?: DeepPartial<CommunityProject_ChainEntry>): CommunityProject_ChainEntry {
|
3690
|
+
return CommunityProject_ChainEntry.fromPartial(base ?? {});
|
3691
|
+
},
|
3692
|
+
fromPartial(object: DeepPartial<CommunityProject_ChainEntry>): CommunityProject_ChainEntry {
|
3693
|
+
const message = createBaseCommunityProject_ChainEntry();
|
3694
|
+
message.key = object.key ?? "";
|
3695
|
+
message.value = (object.value !== undefined && object.value !== null)
|
3696
|
+
? StringList.fromPartial(object.value)
|
3697
|
+
: undefined;
|
3565
3698
|
return message;
|
3566
3699
|
},
|
3567
3700
|
};
|
package/src/service-v3.ts
CHANGED
@@ -10,6 +10,7 @@ import {
|
|
10
10
|
ProcessorV3ServiceImplementation,
|
11
11
|
ProcessResult,
|
12
12
|
ProcessStreamRequest,
|
13
|
+
ProcessStreamResponse,
|
13
14
|
ProcessStreamResponseV2,
|
14
15
|
StartRequest
|
15
16
|
} from '@sentio/protos'
|
@@ -52,6 +53,21 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
|
|
52
53
|
|
53
54
|
async *processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext) {
|
54
55
|
const subject = new Subject<DeepPartial<ProcessStreamResponseV2>>()
|
56
|
+
this.handleRequests(requests, subject)
|
57
|
+
.then(() => {
|
58
|
+
subject.complete()
|
59
|
+
})
|
60
|
+
.catch((e) => {
|
61
|
+
console.error(e)
|
62
|
+
subject.error(e)
|
63
|
+
})
|
64
|
+
yield* from(subject).pipe(withAbort(context.signal))
|
65
|
+
}
|
66
|
+
|
67
|
+
protected async handleRequests(
|
68
|
+
requests: AsyncIterable<ProcessStreamRequest>,
|
69
|
+
subject: Subject<DeepPartial<ProcessStreamResponse>>
|
70
|
+
) {
|
55
71
|
let lastBinding: DataBinding | undefined = undefined
|
56
72
|
for await (const request of requests) {
|
57
73
|
try {
|
@@ -65,8 +81,8 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
|
|
65
81
|
console.error('unexpect error during handle loop', e)
|
66
82
|
}
|
67
83
|
}
|
68
|
-
yield* from(subject).pipe(withAbort(context.signal))
|
69
84
|
}
|
85
|
+
|
70
86
|
private contexts = new Contexts()
|
71
87
|
|
72
88
|
async handleRequest(
|
@@ -87,6 +103,7 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
|
|
87
103
|
|
88
104
|
if (this.enablePartition) {
|
89
105
|
try {
|
106
|
+
console.debug('sending partition request', request.binding)
|
90
107
|
const partitions = await PluginManager.INSTANCE.partition(request.binding)
|
91
108
|
subject.next({
|
92
109
|
processId: request.processId,
|
@@ -128,11 +145,13 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
|
|
128
145
|
) {
|
129
146
|
const context = this.contexts.new(processId, subject)
|
130
147
|
const start = Date.now()
|
148
|
+
console.debug('process binding', processId)
|
131
149
|
PluginManager.INSTANCE.processBinding(binding, undefined, context)
|
132
150
|
.then(async (result) => {
|
133
|
-
|
151
|
+
console.debug(`process binding ${processId} done`)
|
134
152
|
await context.awaitPendings()
|
135
153
|
|
154
|
+
console.debug('sending ts data length:', result.timeseriesResult.length)
|
136
155
|
for (const ts of result.timeseriesResult) {
|
137
156
|
subject.next({
|
138
157
|
processId,
|
@@ -143,6 +162,7 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
|
|
143
162
|
}
|
144
163
|
|
145
164
|
if (result.states?.configUpdated) {
|
165
|
+
console.debug('sending tpl updates:')
|
146
166
|
subject.next({
|
147
167
|
processId,
|
148
168
|
tplRequest: {
|
@@ -151,6 +171,7 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
|
|
151
171
|
})
|
152
172
|
}
|
153
173
|
|
174
|
+
console.debug('sending binding result', processId)
|
154
175
|
subject.next({
|
155
176
|
result: {
|
156
177
|
states: result.states,
|
@@ -169,6 +190,7 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
|
|
169
190
|
const cost = Date.now() - start
|
170
191
|
process_binding_time.add(cost)
|
171
192
|
this.contexts.delete(processId)
|
193
|
+
console.debug('process binding done', processId)
|
172
194
|
})
|
173
195
|
}
|
174
196
|
|