1- import type { RolldownLogsManager } from '../rolldown/logs-manager '
1+ import type { EntriesToObject , Thenable } from './utils '
22
33/**
44 * Type of the RPC function,
@@ -8,8 +8,6 @@ import type { RolldownLogsManager } from '../rolldown/logs-manager'
88 */
99export type RpcFunctionType = 'static' | 'action' | 'query'
1010
11- export type Thenable < T > = T | Promise < T >
12-
1311export interface RpcFunctionSetupResult <
1412 ARGS extends any [ ] ,
1513 RETURN = void ,
@@ -33,39 +31,16 @@ export interface RpcFunctionDefinition<
3331export interface RpcContext {
3432 cwd : string
3533 mode : 'dev' | 'build'
36- manager : RolldownLogsManager
37- }
38-
39- export type EntriesToObject < T extends readonly [ string , any ] [ ] > = {
40- [ K in T [ number ] as K [ 0 ] ] : K [ 1 ]
34+ meta ?: any
4135}
4236
43- export type DefinitionsToFunctions < T extends readonly RpcFunctionDefinition < any , any , any > [ ] > = EntriesToObject < {
37+ export type RpcDefinitionsToFunctions < T extends readonly RpcFunctionDefinition < any , any , any > [ ] > = EntriesToObject < {
4438 [ K in keyof T ] : [ T [ K ] [ 'name' ] , Awaited < ReturnType < T [ K ] [ 'setup' ] > > [ 'handler' ] ]
4539} >
4640
47- export type FilterDefinitions <
41+ export type RpcDefinitionsFilter <
4842 T extends readonly RpcFunctionDefinition < any , any , any > [ ] ,
4943 Type extends RpcFunctionType ,
5044> = {
5145 [ K in keyof T ] : T [ K ] extends { type : Type } ? T [ K ] : never
5246}
53-
54- // type a = DefinitionsToFunctions<
55- // FilterDefinitions<[
56- // {
57- // name: 'a'
58- // type: 'static'
59- // setup: () => ({
60- // handler: () => void
61- // })
62- // },
63- // {
64- // name: 'b'
65- // type: 'action'
66- // setup: () => ({
67- // handler: (a: string) => void
68- // })
69- // },
70- // ], 'action' | 'static'>
71- // >
0 commit comments