oox 0.3.0-beta11 → 0.3.0-beta13
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/LICENSE +21 -21
- package/README.md +32 -32
- package/app.js +143 -143
- package/bin/argv.js +70 -70
- package/bin/cli.js +49 -49
- package/bin/configurer.js +64 -64
- package/bin/loader.mjs +459 -459
- package/bin/proxyer.js +66 -66
- package/bin/register.js +55 -55
- package/bin/starter.js +71 -71
- package/index.js +168 -168
- package/index.mjs +4 -4
- package/logger.js +40 -40
- package/modules/http/index.js +192 -192
- package/modules/http/utils.js +73 -73
- package/modules/index.js +88 -88
- package/modules/module.js +16 -16
- package/modules/socketio/client.js +101 -101
- package/modules/socketio/index.js +168 -168
- package/modules/socketio/server.js +136 -136
- package/modules/socketio/socket.js +4 -4
- package/package.json +1 -1
- package/types/app.d.ts +51 -51
- package/types/bin/argv.d.ts +8 -8
- package/types/bin/cli.d.ts +4 -4
- package/types/bin/configurer.d.ts +3 -3
- package/types/bin/proxyer.d.ts +1 -1
- package/types/bin/register.d.ts +1 -1
- package/types/bin/starter.d.ts +3 -3
- package/types/index.d.ts +76 -76
- package/types/logger.d.ts +4 -4
- package/types/modules/http/index.d.ts +47 -47
- package/types/modules/http/utils.d.ts +17 -17
- package/types/modules/index.d.ts +24 -24
- package/types/modules/module.d.ts +13 -13
- package/types/modules/socketio/client.d.ts +23 -23
- package/types/modules/socketio/index.d.ts +37 -37
- package/types/modules/socketio/server.d.ts +35 -35
- package/types/modules/socketio/socket.d.ts +11 -11
- package/types/utils.d.ts +6 -6
- package/utils.js +63 -63
package/types/app.d.ts
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { EventEmitter } from 'node:events';
|
|
4
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
|
-
export * as logger from './logger';
|
|
6
|
-
export interface ReturnsBody {
|
|
7
|
-
traceId: string;
|
|
8
|
-
success: boolean;
|
|
9
|
-
body?: any;
|
|
10
|
-
error?: {
|
|
11
|
-
message: string;
|
|
12
|
-
stack: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export declare class Context {
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
traceId?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare const asyncStore: AsyncLocalStorage<Context>;
|
|
20
|
-
export declare const eventHub: EventEmitter;
|
|
21
|
-
/**
|
|
22
|
-
* the kvMethods is all actions refs [has bind this]
|
|
23
|
-
*/
|
|
24
|
-
export declare const kvMethods: Map<string, Function>;
|
|
25
|
-
export declare const sourceKVMethods: Map<string, Function>;
|
|
26
|
-
export declare function setMethods(methods: any): void;
|
|
27
|
-
export declare function getMethods(): any;
|
|
28
|
-
export declare function on(event: 'app:configured' | 'app:served' | 'app:stopped', listener: () => void): void;
|
|
29
|
-
export declare function on(event: 'request', listener: (action: string, params: any[], context: Context) => void): void;
|
|
30
|
-
export declare function on(event: 'success', listener: (action: string, params: any[], context: Context, result: ReturnsBody) => void): void;
|
|
31
|
-
export declare function on(event: 'fail', listener: (action: string, params: any[], context: Context, error: Error) => void): void;
|
|
32
|
-
export declare function on(event: 'log', listener: (context: Context, tag: string, msgs: any[]) => void): void;
|
|
33
|
-
export declare function on(event: string, listener: (...args: any[]) => void): void;
|
|
34
|
-
export declare function once(event: 'app:configured' | 'app:served' | 'app:stopped', listener: (...args: any[]) => void): void;
|
|
35
|
-
export declare function once(event: 'request', listener: (action: string, params: any[], context: Context) => void): void;
|
|
36
|
-
export declare function once(event: 'success', listener: (action: string, params: any[], context: Context, result: ReturnsBody) => void): void;
|
|
37
|
-
export declare function once(event: 'fail', listener: (action: string, params: any[], context: Context, error: Error) => void): void;
|
|
38
|
-
export declare function once(event: 'log', listener: (context: Context, tag: string, msgs: any[]) => void): void;
|
|
39
|
-
export declare function once(event: string, listener: (...args: any[]) => void): void;
|
|
40
|
-
export declare function off(event: 'app:configured' | 'app:served' | 'app:stopped' | 'request' | 'success' | 'fail' | 'log', listener: (...args: any[]) => void): void;
|
|
41
|
-
export declare function off(event: string, listener: (...args: any[]) => void): void;
|
|
42
|
-
export declare function emit(event: string, ...args: any[]): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Call an Function on RPC server
|
|
45
|
-
* @param action
|
|
46
|
-
* @param params
|
|
47
|
-
* @param context
|
|
48
|
-
* @returns
|
|
49
|
-
*/
|
|
50
|
-
export declare function call(action: string, params: any[], context: Context): Promise<ReturnsBody>;
|
|
51
|
-
export declare function execute(action: string, params: Array<any>, context: Context): Promise<any>;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from 'node:events';
|
|
4
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
|
+
export * as logger from './logger';
|
|
6
|
+
export interface ReturnsBody {
|
|
7
|
+
traceId: string;
|
|
8
|
+
success: boolean;
|
|
9
|
+
body?: any;
|
|
10
|
+
error?: {
|
|
11
|
+
message: string;
|
|
12
|
+
stack: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare class Context {
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
traceId?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const asyncStore: AsyncLocalStorage<Context>;
|
|
20
|
+
export declare const eventHub: EventEmitter;
|
|
21
|
+
/**
|
|
22
|
+
* the kvMethods is all actions refs [has bind this]
|
|
23
|
+
*/
|
|
24
|
+
export declare const kvMethods: Map<string, Function>;
|
|
25
|
+
export declare const sourceKVMethods: Map<string, Function>;
|
|
26
|
+
export declare function setMethods(methods: any): void;
|
|
27
|
+
export declare function getMethods(): any;
|
|
28
|
+
export declare function on(event: 'app:configured' | 'app:served' | 'app:stopped', listener: () => void): void;
|
|
29
|
+
export declare function on(event: 'request', listener: (action: string, params: any[], context: Context) => void): void;
|
|
30
|
+
export declare function on(event: 'success', listener: (action: string, params: any[], context: Context, result: ReturnsBody) => void): void;
|
|
31
|
+
export declare function on(event: 'fail', listener: (action: string, params: any[], context: Context, error: Error) => void): void;
|
|
32
|
+
export declare function on(event: 'log', listener: (context: Context, tag: string, msgs: any[]) => void): void;
|
|
33
|
+
export declare function on(event: string, listener: (...args: any[]) => void): void;
|
|
34
|
+
export declare function once(event: 'app:configured' | 'app:served' | 'app:stopped', listener: (...args: any[]) => void): void;
|
|
35
|
+
export declare function once(event: 'request', listener: (action: string, params: any[], context: Context) => void): void;
|
|
36
|
+
export declare function once(event: 'success', listener: (action: string, params: any[], context: Context, result: ReturnsBody) => void): void;
|
|
37
|
+
export declare function once(event: 'fail', listener: (action: string, params: any[], context: Context, error: Error) => void): void;
|
|
38
|
+
export declare function once(event: 'log', listener: (context: Context, tag: string, msgs: any[]) => void): void;
|
|
39
|
+
export declare function once(event: string, listener: (...args: any[]) => void): void;
|
|
40
|
+
export declare function off(event: 'app:configured' | 'app:served' | 'app:stopped' | 'request' | 'success' | 'fail' | 'log', listener: (...args: any[]) => void): void;
|
|
41
|
+
export declare function off(event: string, listener: (...args: any[]) => void): void;
|
|
42
|
+
export declare function emit(event: string, ...args: any[]): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Call an Function on RPC server
|
|
45
|
+
* @param action
|
|
46
|
+
* @param params
|
|
47
|
+
* @param context
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
export declare function call(action: string, params: any[], context: Context): Promise<ReturnsBody>;
|
|
51
|
+
export declare function execute(action: string, params: Array<any>, context: Context): Promise<any>;
|
package/types/bin/argv.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare function getAllEnvArgs(): {
|
|
2
|
-
[x: string]: any;
|
|
3
|
-
};
|
|
4
|
-
export declare function getEnvArgs(names: string[]): {
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
};
|
|
7
|
-
export declare function getEnvArg(name: string): any;
|
|
8
|
-
export declare function parseEnvArg(value: string): any;
|
|
1
|
+
export declare function getAllEnvArgs(): {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
};
|
|
4
|
+
export declare function getEnvArgs(names: string[]): {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
};
|
|
7
|
+
export declare function getEnvArg(name: string): any;
|
|
8
|
+
export declare function parseEnvArg(value: string): any;
|
package/types/bin/cli.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
import { startup } from './starter';
|
|
3
|
-
export declare const version: string;
|
|
4
|
-
export { startup };
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import { startup } from './starter';
|
|
3
|
+
export declare const version: string;
|
|
4
|
+
export { startup };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function configure(mergeEnv?: {
|
|
2
|
-
[x: string]: any;
|
|
3
|
-
}): Promise<any>;
|
|
1
|
+
export declare function configure(mergeEnv?: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
}): Promise<any>;
|
package/types/bin/proxyer.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function proxyGroup(groupDirectory: string, excludes?: any[]): void;
|
|
1
|
+
export declare function proxyGroup(groupDirectory: string, excludes?: any[]): void;
|
package/types/bin/register.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function registry(urls: string | string[]): Promise<void>;
|
|
1
|
+
export declare function registry(urls: string | string[]): Promise<void>;
|
package/types/bin/starter.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function startup(env?: {
|
|
2
|
-
[x: string]: any;
|
|
3
|
-
}, entryFilename?: string): Promise<void>;
|
|
1
|
+
export declare function startup(env?: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
}, entryFilename?: string): Promise<void>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as app from './app';
|
|
3
|
-
import Module, { ModuleConfig } from './modules/module';
|
|
4
|
-
import Modules from './modules';
|
|
5
|
-
export { ReturnsBody } from './app';
|
|
6
|
-
export { Module, ModuleConfig };
|
|
7
|
-
export declare const modules: Modules;
|
|
8
|
-
export declare const asyncStore: import("async_hooks").AsyncLocalStorage<app.Context>, setMethods: typeof app.setMethods, getMethods: typeof app.getMethods, kvMethods: Map<string, Function>, sourceKVMethods: Map<string, Function>, call: typeof app.call, execute: typeof app.execute, logger: typeof app.logger, on: typeof app.on, once: typeof app.once, off: typeof app.off, emit: typeof app.emit;
|
|
9
|
-
export declare class Context extends app.Context {
|
|
10
|
-
sourceIP: string;
|
|
11
|
-
ip: string;
|
|
12
|
-
caller: string;
|
|
13
|
-
callerId: string;
|
|
14
|
-
connection?: RPCKeepAliveConnection;
|
|
15
|
-
toJSON?(): {} & this;
|
|
16
|
-
}
|
|
17
|
-
export declare class Config {
|
|
18
|
-
[x: string]: any;
|
|
19
|
-
name: string;
|
|
20
|
-
entryFile: {
|
|
21
|
-
path: string;
|
|
22
|
-
group: string;
|
|
23
|
-
};
|
|
24
|
-
host: string;
|
|
25
|
-
port: number;
|
|
26
|
-
origin: string;
|
|
27
|
-
}
|
|
28
|
-
export declare const config: Config;
|
|
29
|
-
export declare function setGenTraceIdFunction(fn: () => string): void;
|
|
30
|
-
/**
|
|
31
|
-
* 生成随机不重复id
|
|
32
|
-
*/
|
|
33
|
-
export declare function genTraceId(): string;
|
|
34
|
-
/**
|
|
35
|
-
* 获取链路跟踪上下文
|
|
36
|
-
*/
|
|
37
|
-
export declare function genContext(context?: Context): Context;
|
|
38
|
-
export declare function getContext(): Context;
|
|
39
|
-
export declare function serve(): Promise<void>;
|
|
40
|
-
export declare function stop(): Promise<void>;
|
|
41
|
-
export interface RPCConnectionAdapter {
|
|
42
|
-
rpc(connection: any, action: string, params: any[], context: Context): Promise<any>;
|
|
43
|
-
}
|
|
44
|
-
export interface RPCKeepAliveConnectionData {
|
|
45
|
-
/**
|
|
46
|
-
* 是否连接成功
|
|
47
|
-
*/
|
|
48
|
-
connected: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* 连接主机地址
|
|
51
|
-
*/
|
|
52
|
-
host: string;
|
|
53
|
-
/**
|
|
54
|
-
* 连接服务名称
|
|
55
|
-
*/
|
|
56
|
-
name: string;
|
|
57
|
-
/**
|
|
58
|
-
* 目标服务网络唯一ID
|
|
59
|
-
*/
|
|
60
|
-
id: string;
|
|
61
|
-
}
|
|
62
|
-
export declare class RPCKeepAliveConnection {
|
|
63
|
-
data: RPCKeepAliveConnectionData;
|
|
64
|
-
nativeConnection: any;
|
|
65
|
-
adapter: RPCConnectionAdapter;
|
|
66
|
-
constructor(adapter: RPCConnectionAdapter, nativeConnection: any, data?: RPCKeepAliveConnectionData);
|
|
67
|
-
}
|
|
68
|
-
export declare const keepAliveConnections: Map<string, Map<string, RPCKeepAliveConnection>>;
|
|
69
|
-
export declare function getKeepAliveConnections(name: string): Map<string, RPCKeepAliveConnection>;
|
|
70
|
-
export declare function getKeepAliveConnection(name: string, id: string): RPCKeepAliveConnection | null;
|
|
71
|
-
export declare function addKeepAliveConnection(connection: RPCKeepAliveConnection): void;
|
|
72
|
-
export declare function removeKeepAliveConnection(connection: RPCKeepAliveConnection): void;
|
|
73
|
-
export declare function removeKeepAliveConnection(name: string, id: string): void;
|
|
74
|
-
export declare function setLoadBalancePolicy(policy: (name: string) => RPCKeepAliveConnection): void;
|
|
75
|
-
export declare function rpc(appName: string, action: string, params: any[], context?: Context): Promise<any>;
|
|
76
|
-
export declare function rpc(connection: RPCKeepAliveConnection, action: string, params: any[], context?: Context): Promise<any>;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as app from './app';
|
|
3
|
+
import Module, { ModuleConfig } from './modules/module';
|
|
4
|
+
import Modules from './modules';
|
|
5
|
+
export { ReturnsBody } from './app';
|
|
6
|
+
export { Module, ModuleConfig };
|
|
7
|
+
export declare const modules: Modules;
|
|
8
|
+
export declare const asyncStore: import("async_hooks").AsyncLocalStorage<app.Context>, setMethods: typeof app.setMethods, getMethods: typeof app.getMethods, kvMethods: Map<string, Function>, sourceKVMethods: Map<string, Function>, call: typeof app.call, execute: typeof app.execute, logger: typeof app.logger, on: typeof app.on, once: typeof app.once, off: typeof app.off, emit: typeof app.emit;
|
|
9
|
+
export declare class Context extends app.Context {
|
|
10
|
+
sourceIP: string;
|
|
11
|
+
ip: string;
|
|
12
|
+
caller: string;
|
|
13
|
+
callerId: string;
|
|
14
|
+
connection?: RPCKeepAliveConnection;
|
|
15
|
+
toJSON?(): {} & this;
|
|
16
|
+
}
|
|
17
|
+
export declare class Config {
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
name: string;
|
|
20
|
+
entryFile: {
|
|
21
|
+
path: string;
|
|
22
|
+
group: string;
|
|
23
|
+
};
|
|
24
|
+
host: string;
|
|
25
|
+
port: number;
|
|
26
|
+
origin: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const config: Config;
|
|
29
|
+
export declare function setGenTraceIdFunction(fn: () => string): void;
|
|
30
|
+
/**
|
|
31
|
+
* 生成随机不重复id
|
|
32
|
+
*/
|
|
33
|
+
export declare function genTraceId(): string;
|
|
34
|
+
/**
|
|
35
|
+
* 获取链路跟踪上下文
|
|
36
|
+
*/
|
|
37
|
+
export declare function genContext(context?: Context): Context;
|
|
38
|
+
export declare function getContext(): Context;
|
|
39
|
+
export declare function serve(): Promise<void>;
|
|
40
|
+
export declare function stop(): Promise<void>;
|
|
41
|
+
export interface RPCConnectionAdapter {
|
|
42
|
+
rpc(connection: any, action: string, params: any[], context: Context): Promise<any>;
|
|
43
|
+
}
|
|
44
|
+
export interface RPCKeepAliveConnectionData {
|
|
45
|
+
/**
|
|
46
|
+
* 是否连接成功
|
|
47
|
+
*/
|
|
48
|
+
connected: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* 连接主机地址
|
|
51
|
+
*/
|
|
52
|
+
host: string;
|
|
53
|
+
/**
|
|
54
|
+
* 连接服务名称
|
|
55
|
+
*/
|
|
56
|
+
name: string;
|
|
57
|
+
/**
|
|
58
|
+
* 目标服务网络唯一ID
|
|
59
|
+
*/
|
|
60
|
+
id: string;
|
|
61
|
+
}
|
|
62
|
+
export declare class RPCKeepAliveConnection {
|
|
63
|
+
data: RPCKeepAliveConnectionData;
|
|
64
|
+
nativeConnection: any;
|
|
65
|
+
adapter: RPCConnectionAdapter;
|
|
66
|
+
constructor(adapter: RPCConnectionAdapter, nativeConnection: any, data?: RPCKeepAliveConnectionData);
|
|
67
|
+
}
|
|
68
|
+
export declare const keepAliveConnections: Map<string, Map<string, RPCKeepAliveConnection>>;
|
|
69
|
+
export declare function getKeepAliveConnections(name: string): Map<string, RPCKeepAliveConnection>;
|
|
70
|
+
export declare function getKeepAliveConnection(name: string, id: string): RPCKeepAliveConnection | null;
|
|
71
|
+
export declare function addKeepAliveConnection(connection: RPCKeepAliveConnection): void;
|
|
72
|
+
export declare function removeKeepAliveConnection(connection: RPCKeepAliveConnection): void;
|
|
73
|
+
export declare function removeKeepAliveConnection(name: string, id: string): void;
|
|
74
|
+
export declare function setLoadBalancePolicy(policy: (name: string) => RPCKeepAliveConnection): void;
|
|
75
|
+
export declare function rpc(appName: string, action: string, params: any[], context?: Context): Promise<any>;
|
|
76
|
+
export declare function rpc(connection: RPCKeepAliveConnection, action: string, params: any[], context?: Context): Promise<any>;
|
package/types/logger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function info(...msgs: any[]): void;
|
|
2
|
-
export declare function warn(...msgs: any[]): void;
|
|
3
|
-
export declare function error(...msgs: any[]): void;
|
|
4
|
-
export declare function trace(name?: string): void;
|
|
1
|
+
export declare function info(...msgs: any[]): void;
|
|
2
|
+
export declare function warn(...msgs: any[]): void;
|
|
3
|
+
export declare function error(...msgs: any[]): void;
|
|
4
|
+
export declare function trace(name?: string): void;
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as http from 'node:http';
|
|
3
|
-
import * as oox from '../../index';
|
|
4
|
-
import Module, { ModuleConfig } from '../module';
|
|
5
|
-
export declare class HTTPConfig extends ModuleConfig {
|
|
6
|
-
port: number;
|
|
7
|
-
path: string;
|
|
8
|
-
origin: string;
|
|
9
|
-
}
|
|
10
|
-
export default class HTTPModule extends Module {
|
|
11
|
-
name: string;
|
|
12
|
-
config: HTTPConfig;
|
|
13
|
-
server: http.Server;
|
|
14
|
-
setConfig(config: HTTPConfig): void;
|
|
15
|
-
getConfig(): HTTPConfig;
|
|
16
|
-
/**
|
|
17
|
-
* start http service
|
|
18
|
-
*/
|
|
19
|
-
serve(): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* stop http service
|
|
22
|
-
*/
|
|
23
|
-
stop(): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* browser cross origin
|
|
26
|
-
*/
|
|
27
|
-
cors(request: http.IncomingMessage, response: http.ServerResponse): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* HTTP-RPC服务器请求监听方法
|
|
30
|
-
*/
|
|
31
|
-
call(request: http.IncomingMessage, response: http.ServerResponse): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* HTTP Response Catch
|
|
34
|
-
*/
|
|
35
|
-
respond(request: http.IncomingMessage, response: http.ServerResponse, format: {
|
|
36
|
-
body?: any;
|
|
37
|
-
success: boolean;
|
|
38
|
-
error?: {
|
|
39
|
-
message: any;
|
|
40
|
-
stack: any;
|
|
41
|
-
};
|
|
42
|
-
}): void;
|
|
43
|
-
/**
|
|
44
|
-
* HTTP RPC
|
|
45
|
-
*/
|
|
46
|
-
rpc(url: string | URL, action: string, params: Array<any>, context?: oox.Context): Promise<any>;
|
|
47
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as http from 'node:http';
|
|
3
|
+
import * as oox from '../../index';
|
|
4
|
+
import Module, { ModuleConfig } from '../module';
|
|
5
|
+
export declare class HTTPConfig extends ModuleConfig {
|
|
6
|
+
port: number;
|
|
7
|
+
path: string;
|
|
8
|
+
origin: string;
|
|
9
|
+
}
|
|
10
|
+
export default class HTTPModule extends Module {
|
|
11
|
+
name: string;
|
|
12
|
+
config: HTTPConfig;
|
|
13
|
+
server: http.Server;
|
|
14
|
+
setConfig(config: HTTPConfig): void;
|
|
15
|
+
getConfig(): HTTPConfig;
|
|
16
|
+
/**
|
|
17
|
+
* start http service
|
|
18
|
+
*/
|
|
19
|
+
serve(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* stop http service
|
|
22
|
+
*/
|
|
23
|
+
stop(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* browser cross origin
|
|
26
|
+
*/
|
|
27
|
+
cors(request: http.IncomingMessage, response: http.ServerResponse): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* HTTP-RPC服务器请求监听方法
|
|
30
|
+
*/
|
|
31
|
+
call(request: http.IncomingMessage, response: http.ServerResponse): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* HTTP Response Catch
|
|
34
|
+
*/
|
|
35
|
+
respond(request: http.IncomingMessage, response: http.ServerResponse, format: {
|
|
36
|
+
body?: any;
|
|
37
|
+
success: boolean;
|
|
38
|
+
error?: {
|
|
39
|
+
message: any;
|
|
40
|
+
stack: any;
|
|
41
|
+
};
|
|
42
|
+
}): void;
|
|
43
|
+
/**
|
|
44
|
+
* HTTP RPC
|
|
45
|
+
*/
|
|
46
|
+
rpc(url: string | URL, action: string, params: Array<any>, context?: oox.Context): Promise<any>;
|
|
47
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import * as http from 'node:http';
|
|
5
|
-
import { Readable } from 'node:stream';
|
|
6
|
-
/**
|
|
7
|
-
* Stream => Buffer
|
|
8
|
-
*/
|
|
9
|
-
export declare function stream2buffer(stream: Readable, totalLength?: number): Promise<Buffer>;
|
|
10
|
-
/**
|
|
11
|
-
* Request => JSONObject
|
|
12
|
-
*/
|
|
13
|
-
export declare function parseHTTPBody(request: http.IncomingMessage): Promise<any>;
|
|
14
|
-
/**
|
|
15
|
-
* http request
|
|
16
|
-
*/
|
|
17
|
-
export declare function httpRequest(url: URL | string, options: http.RequestOptions, body: string): Promise<any>;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import * as http from 'node:http';
|
|
5
|
+
import { Readable } from 'node:stream';
|
|
6
|
+
/**
|
|
7
|
+
* Stream => Buffer
|
|
8
|
+
*/
|
|
9
|
+
export declare function stream2buffer(stream: Readable, totalLength?: number): Promise<Buffer>;
|
|
10
|
+
/**
|
|
11
|
+
* Request => JSONObject
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseHTTPBody(request: http.IncomingMessage): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* http request
|
|
16
|
+
*/
|
|
17
|
+
export declare function httpRequest(url: URL | string, options: http.RequestOptions, body: string): Promise<any>;
|
package/types/modules/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import Module from './module';
|
|
2
|
-
import HTTP from './http';
|
|
3
|
-
import SocketIO from './socketio';
|
|
4
|
-
export default class Modules extends Module {
|
|
5
|
-
#private;
|
|
6
|
-
/**
|
|
7
|
-
* the module unique name
|
|
8
|
-
*/
|
|
9
|
-
name: string;
|
|
10
|
-
/**
|
|
11
|
-
* all builtin modules
|
|
12
|
-
*/
|
|
13
|
-
builtins: {
|
|
14
|
-
http: HTTP;
|
|
15
|
-
socketio: SocketIO;
|
|
16
|
-
};
|
|
17
|
-
constructor();
|
|
18
|
-
add(module: Module): this;
|
|
19
|
-
get(name: string): Module;
|
|
20
|
-
remove(name: string): Promise<void>;
|
|
21
|
-
setConfig(config: any): void;
|
|
22
|
-
serve(): Promise<void>;
|
|
23
|
-
stop(): Promise<void>;
|
|
24
|
-
}
|
|
1
|
+
import Module from './module';
|
|
2
|
+
import HTTP from './http';
|
|
3
|
+
import SocketIO from './socketio';
|
|
4
|
+
export default class Modules extends Module {
|
|
5
|
+
#private;
|
|
6
|
+
/**
|
|
7
|
+
* the module unique name
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* all builtin modules
|
|
12
|
+
*/
|
|
13
|
+
builtins: {
|
|
14
|
+
http: HTTP;
|
|
15
|
+
socketio: SocketIO;
|
|
16
|
+
};
|
|
17
|
+
constructor();
|
|
18
|
+
add(module: Module): this;
|
|
19
|
+
get(name: string): Module;
|
|
20
|
+
remove(name: string): Promise<void>;
|
|
21
|
+
setConfig(config: any): void;
|
|
22
|
+
serve(): Promise<void>;
|
|
23
|
+
stop(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare class ModuleConfig {
|
|
2
|
-
[x: string]: any;
|
|
3
|
-
disabled: boolean;
|
|
4
|
-
}
|
|
5
|
-
export default class Module {
|
|
6
|
-
[x: string]: any;
|
|
7
|
-
config: ModuleConfig;
|
|
8
|
-
name: string;
|
|
9
|
-
setConfig(config: any): void;
|
|
10
|
-
getConfig(): ModuleConfig;
|
|
11
|
-
serve(): Promise<void>;
|
|
12
|
-
stop(): Promise<void>;
|
|
13
|
-
}
|
|
1
|
+
export declare class ModuleConfig {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
}
|
|
5
|
+
export default class Module {
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
config: ModuleConfig;
|
|
8
|
+
name: string;
|
|
9
|
+
setConfig(config: any): void;
|
|
10
|
+
getConfig(): ModuleConfig;
|
|
11
|
+
serve(): Promise<void>;
|
|
12
|
+
stop(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ClientSocket as Socket } from './socket';
|
|
2
|
-
import SocketIOServer from './server';
|
|
3
|
-
export default class SocketIOCore extends SocketIOServer {
|
|
4
|
-
/**
|
|
5
|
-
* connect to <SocketIO RPC> service
|
|
6
|
-
*/
|
|
7
|
-
connect(url: string): Promise<Socket>;
|
|
8
|
-
/**
|
|
9
|
-
* 客户端Socket连接事件
|
|
10
|
-
*/
|
|
11
|
-
clientOnSocketConnection(socket: Socket): void;
|
|
12
|
-
clientOnDisconnect(socket: Socket, reason: any): void;
|
|
13
|
-
clientOnConnection(socket: Socket): void;
|
|
14
|
-
/**
|
|
15
|
-
* 客户端Socket断开事件
|
|
16
|
-
* @param {Socket} socket
|
|
17
|
-
*/
|
|
18
|
-
clientOnSocketDisconnect(socket: Socket, reason: any): void;
|
|
19
|
-
/**
|
|
20
|
-
* 等待socket连接
|
|
21
|
-
*/
|
|
22
|
-
clientWaitConnection(socket: Socket): Promise<void>;
|
|
23
|
-
}
|
|
1
|
+
import { ClientSocket as Socket } from './socket';
|
|
2
|
+
import SocketIOServer from './server';
|
|
3
|
+
export default class SocketIOCore extends SocketIOServer {
|
|
4
|
+
/**
|
|
5
|
+
* connect to <SocketIO RPC> service
|
|
6
|
+
*/
|
|
7
|
+
connect(url: string): Promise<Socket>;
|
|
8
|
+
/**
|
|
9
|
+
* 客户端Socket连接事件
|
|
10
|
+
*/
|
|
11
|
+
clientOnSocketConnection(socket: Socket): void;
|
|
12
|
+
clientOnDisconnect(socket: Socket, reason: any): void;
|
|
13
|
+
clientOnConnection(socket: Socket): void;
|
|
14
|
+
/**
|
|
15
|
+
* 客户端Socket断开事件
|
|
16
|
+
* @param {Socket} socket
|
|
17
|
+
*/
|
|
18
|
+
clientOnSocketDisconnect(socket: Socket, reason: any): void;
|
|
19
|
+
/**
|
|
20
|
+
* 等待socket连接
|
|
21
|
+
*/
|
|
22
|
+
clientWaitConnection(socket: Socket): Promise<void>;
|
|
23
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import SocketIOClient from './client';
|
|
2
|
-
import * as oox from '../../index';
|
|
3
|
-
import { RPCKeepAliveConnectionData, RPCConnectionAdapter } from '../../index';
|
|
4
|
-
import { Socket, sockets, ServerSocket, ClientSocket } from './socket';
|
|
5
|
-
export { Socket, sockets };
|
|
6
|
-
export default class SocketIOModule extends SocketIOClient implements RPCConnectionAdapter {
|
|
7
|
-
sockets: Map<string, Socket>;
|
|
8
|
-
serve(): Promise<void>;
|
|
9
|
-
onSyncConnection(socket: Socket): oox.RPCKeepAliveConnectionData[];
|
|
10
|
-
serverOnDisconnect(socket: ServerSocket, reason: string): void;
|
|
11
|
-
clientOnDisconnect(socket: ClientSocket, reason: any): void;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param socket 是由哪个通道发送过来的
|
|
15
|
-
* @param connectionDatas
|
|
16
|
-
*/
|
|
17
|
-
clientOnSyncConnection(socket: Socket, connectionDatas: RPCKeepAliveConnectionData[]): void;
|
|
18
|
-
onFetchActions(socket: Socket, search: string): string[];
|
|
19
|
-
fetchActions(url: string, search?: string): Promise<RPCKeepAliveConnectionData[]>;
|
|
20
|
-
fetchActions(name: string, search?: string): Promise<RPCKeepAliveConnectionData[]>;
|
|
21
|
-
onConnection(socket: Socket): void;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {Socket} socket
|
|
25
|
-
*/
|
|
26
|
-
serverOnConnection(socket: ServerSocket): void;
|
|
27
|
-
call(action: string, params: any[], context: oox.Context, callback?: (returns: any) => void): Promise<oox.ReturnsBody>;
|
|
28
|
-
clientOnConnection(socket: ClientSocket): void;
|
|
29
|
-
/**
|
|
30
|
-
* socketio emit
|
|
31
|
-
*/
|
|
32
|
-
emit(url: string, action: string, params: any[]): Promise<unknown>;
|
|
33
|
-
/**
|
|
34
|
-
* RPC
|
|
35
|
-
*/
|
|
36
|
-
rpc(url: string, action: string, params: [], context?: oox.Context): Promise<any>;
|
|
37
|
-
}
|
|
1
|
+
import SocketIOClient from './client';
|
|
2
|
+
import * as oox from '../../index';
|
|
3
|
+
import { RPCKeepAliveConnectionData, RPCConnectionAdapter } from '../../index';
|
|
4
|
+
import { Socket, sockets, ServerSocket, ClientSocket } from './socket';
|
|
5
|
+
export { Socket, sockets };
|
|
6
|
+
export default class SocketIOModule extends SocketIOClient implements RPCConnectionAdapter {
|
|
7
|
+
sockets: Map<string, Socket>;
|
|
8
|
+
serve(): Promise<void>;
|
|
9
|
+
onSyncConnection(socket: Socket): oox.RPCKeepAliveConnectionData[];
|
|
10
|
+
serverOnDisconnect(socket: ServerSocket, reason: string): void;
|
|
11
|
+
clientOnDisconnect(socket: ClientSocket, reason: any): void;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param socket 是由哪个通道发送过来的
|
|
15
|
+
* @param connectionDatas
|
|
16
|
+
*/
|
|
17
|
+
clientOnSyncConnection(socket: Socket, connectionDatas: RPCKeepAliveConnectionData[]): void;
|
|
18
|
+
onFetchActions(socket: Socket, search: string): string[];
|
|
19
|
+
fetchActions(url: string, search?: string): Promise<RPCKeepAliveConnectionData[]>;
|
|
20
|
+
fetchActions(name: string, search?: string): Promise<RPCKeepAliveConnectionData[]>;
|
|
21
|
+
onConnection(socket: Socket): void;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {Socket} socket
|
|
25
|
+
*/
|
|
26
|
+
serverOnConnection(socket: ServerSocket): void;
|
|
27
|
+
call(action: string, params: any[], context: oox.Context, callback?: (returns: any) => void): Promise<oox.ReturnsBody>;
|
|
28
|
+
clientOnConnection(socket: ClientSocket): void;
|
|
29
|
+
/**
|
|
30
|
+
* socketio emit
|
|
31
|
+
*/
|
|
32
|
+
emit(url: string, action: string, params: any[]): Promise<unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* RPC
|
|
35
|
+
*/
|
|
36
|
+
rpc(url: string, action: string, params: [], context?: oox.Context): Promise<any>;
|
|
37
|
+
}
|