dolphindb 0.0.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/README.md +273 -0
- package/browser.d.ts +249 -0
- package/browser.js +1140 -0
- package/browser.js.map +1 -0
- package/ddb.svg +1 -0
- package/index.d.ts +252 -0
- package/index.js +1143 -0
- package/index.js.map +1 -0
- package/package.json +42 -0
- package/test.d.ts +1 -0
- package/test.js +10 -0
- package/test.js.map +1 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { inspect } from 'xshell/utils.js';
|
|
2
|
+
export declare enum DdbForm {
|
|
3
|
+
scalar = 0,
|
|
4
|
+
vector = 1,
|
|
5
|
+
pair = 2,
|
|
6
|
+
matrix = 3,
|
|
7
|
+
set = 4,
|
|
8
|
+
dict = 5,
|
|
9
|
+
table = 6,
|
|
10
|
+
chart = 7,
|
|
11
|
+
chunk = 8
|
|
12
|
+
}
|
|
13
|
+
export declare enum DdbType {
|
|
14
|
+
void = 0,
|
|
15
|
+
bool = 1,
|
|
16
|
+
char = 2,
|
|
17
|
+
short = 3,
|
|
18
|
+
int = 4,
|
|
19
|
+
long = 5,
|
|
20
|
+
date = 6,
|
|
21
|
+
month = 7,
|
|
22
|
+
time = 8,
|
|
23
|
+
minute = 9,
|
|
24
|
+
second = 10,
|
|
25
|
+
datetime = 11,
|
|
26
|
+
timestamp = 12,
|
|
27
|
+
nanotime = 13,
|
|
28
|
+
nanotimestamp = 14,
|
|
29
|
+
float = 15,
|
|
30
|
+
double = 16,
|
|
31
|
+
symbol = 17,
|
|
32
|
+
string = 18,
|
|
33
|
+
uuid = 19,
|
|
34
|
+
functiondef = 20,
|
|
35
|
+
handle = 21,
|
|
36
|
+
code = 22,
|
|
37
|
+
datasource = 23,
|
|
38
|
+
resource = 24,
|
|
39
|
+
any = 25,
|
|
40
|
+
compress = 26,
|
|
41
|
+
dict = 27,
|
|
42
|
+
datehour = 28,
|
|
43
|
+
ipaddr = 30,
|
|
44
|
+
int128 = 31,
|
|
45
|
+
blob = 32,
|
|
46
|
+
complex = 34,
|
|
47
|
+
point = 35,
|
|
48
|
+
duration = 36,
|
|
49
|
+
symbol_extended = 145
|
|
50
|
+
}
|
|
51
|
+
export declare const ddb_sizes: readonly [0, 1, 1, 2, 4, 8, 4, 4, 4, 4, 4, 4, 8, 8, 8, 4, 8, 0, 0, 16, 0, 0, 0, 0, 0, 0, 1, 0, 0, 16, 16, 0, 0, 0, 0];
|
|
52
|
+
export declare enum DdbFunctionType {
|
|
53
|
+
SystemFunc = 0,
|
|
54
|
+
SystemProc = 1,
|
|
55
|
+
OperatorFunc = 2,
|
|
56
|
+
UserDefinedFunc = 3,
|
|
57
|
+
PartialFunc = 4,
|
|
58
|
+
DynamicFunc = 5,
|
|
59
|
+
PiecewiseFunc = 6,
|
|
60
|
+
JitFunc = 7,
|
|
61
|
+
JitPartialFunc = 8
|
|
62
|
+
}
|
|
63
|
+
export interface DdbFunctionDefValue {
|
|
64
|
+
type: DdbFunctionType;
|
|
65
|
+
name: string;
|
|
66
|
+
}
|
|
67
|
+
export interface DdbSymbolExtendedValue {
|
|
68
|
+
base_id: number;
|
|
69
|
+
base: string[];
|
|
70
|
+
value: Uint32Array;
|
|
71
|
+
}
|
|
72
|
+
export declare type DdbValue = null | boolean | number | [number, number] | bigint | string | string[] | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbFunctionDefValue | DdbSymbolExtendedValue;
|
|
73
|
+
export declare type DdbVectorValue = string | string[] | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbSymbolExtendedValue;
|
|
74
|
+
export declare const nulls: {
|
|
75
|
+
readonly char: "";
|
|
76
|
+
readonly int16: -32768;
|
|
77
|
+
readonly int32: -2147483648;
|
|
78
|
+
readonly int64: -9223372036854775808n;
|
|
79
|
+
};
|
|
80
|
+
export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
81
|
+
static dec: TextDecoder;
|
|
82
|
+
static enc: TextEncoder;
|
|
83
|
+
/** 维护已解析的 symbol base,比如流数据中后续的 symbol 向量可能只发送一个 base.id, base.size == 0, 依赖之前发送的 symbol base */
|
|
84
|
+
static symbol_bases: Record<number, string[]>;
|
|
85
|
+
/** little endian (client) */
|
|
86
|
+
static le_client: boolean;
|
|
87
|
+
/** 是否为小端 (little endian) */
|
|
88
|
+
le: boolean;
|
|
89
|
+
/** 数据形式 https://www.dolphindb.cn/cn/help/DataTypesandStructures/DataForms/index.html */
|
|
90
|
+
form: DdbForm;
|
|
91
|
+
/** 数据类型 https://www.dolphindb.cn/cn/help/DataTypesandStructures/DataTypes/index.html */
|
|
92
|
+
type: DdbType;
|
|
93
|
+
/** 占用 parse 时传入的 buf 的长度 */
|
|
94
|
+
length: number;
|
|
95
|
+
/** table name / column name */
|
|
96
|
+
name?: string;
|
|
97
|
+
/**
|
|
98
|
+
最低维、第 1 维
|
|
99
|
+
- vector: rows = n, cols = 1
|
|
100
|
+
- pair: rows = 2, cols = 1
|
|
101
|
+
- matrix: rows = n, cols = m
|
|
102
|
+
- set: 同 vector
|
|
103
|
+
- dict: 包含 keys, values 向量
|
|
104
|
+
- table: 同 matrix
|
|
105
|
+
*/
|
|
106
|
+
rows?: number;
|
|
107
|
+
/** 第 2 维 */
|
|
108
|
+
cols?: number;
|
|
109
|
+
/** matrix 中值的类型,仅 matrix 才有 */
|
|
110
|
+
datatype?: DdbType;
|
|
111
|
+
/** 实际数据。不同的 DdbForm, DdbType 使用 DdbValue 中不同的类型来表示实际数据 */
|
|
112
|
+
value: T;
|
|
113
|
+
constructor(data: Partial<DdbObj> & {
|
|
114
|
+
form: DdbForm;
|
|
115
|
+
type: DdbType;
|
|
116
|
+
length: number;
|
|
117
|
+
});
|
|
118
|
+
static parse(buf: Uint8Array, le: boolean): DdbObj<DdbValue>;
|
|
119
|
+
static parse_scalar(buf: Uint8Array, le: boolean, type: DdbType): [number, DdbValue];
|
|
120
|
+
/** parse: rows, cols, items
|
|
121
|
+
返回的 ddbobj.length 不包括 vector 的 type 和 form
|
|
122
|
+
*/
|
|
123
|
+
static parse_vector(buf: Uint8Array, le: boolean, type: DdbType): DdbObj;
|
|
124
|
+
/** 有可能没有字节对齐,不能直接使用原有 message 的 arraybuffer, 统一复制出来,让原有 arraybuffer 被回收掉比较好 */
|
|
125
|
+
static parse_vector_items(buf: Uint8Array, le: boolean, type: DdbType, length: number): [
|
|
126
|
+
number,
|
|
127
|
+
DdbVectorValue
|
|
128
|
+
];
|
|
129
|
+
pack(): Uint8Array;
|
|
130
|
+
static pack_vector_body(value: DdbVectorValue, type: DdbType, length: number): ArrayBufferView[];
|
|
131
|
+
[inspect.custom](): string;
|
|
132
|
+
}
|
|
133
|
+
export declare class DdbVoid extends DdbObj<undefined> {
|
|
134
|
+
constructor();
|
|
135
|
+
}
|
|
136
|
+
export declare class DdbBool extends DdbObj<boolean> {
|
|
137
|
+
constructor(value: boolean);
|
|
138
|
+
}
|
|
139
|
+
export declare class DdbInt extends DdbObj<number> {
|
|
140
|
+
constructor(value: number);
|
|
141
|
+
}
|
|
142
|
+
export declare class DdbString extends DdbObj<string> {
|
|
143
|
+
constructor(value: string);
|
|
144
|
+
}
|
|
145
|
+
export declare class DdbLong extends DdbObj<bigint> {
|
|
146
|
+
constructor(value: bigint);
|
|
147
|
+
}
|
|
148
|
+
export declare class DdbDouble extends DdbObj<number> {
|
|
149
|
+
constructor(value: number);
|
|
150
|
+
}
|
|
151
|
+
export declare class DdbVectorInt extends DdbObj<Int32Array> {
|
|
152
|
+
constructor(value: number[]);
|
|
153
|
+
}
|
|
154
|
+
export declare class DdbVectorString extends DdbObj<string[]> {
|
|
155
|
+
constructor(value: string[]);
|
|
156
|
+
}
|
|
157
|
+
export declare class DdbVectorDouble extends DdbObj<Float64Array> {
|
|
158
|
+
constructor(value: number[]);
|
|
159
|
+
}
|
|
160
|
+
export declare class DdbVectorAny extends DdbObj {
|
|
161
|
+
constructor(value: DdbObj<DdbValue>[]);
|
|
162
|
+
}
|
|
163
|
+
export declare class DdbPair extends DdbObj<Int32Array> {
|
|
164
|
+
constructor(l: number, r?: number);
|
|
165
|
+
}
|
|
166
|
+
export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
|
|
167
|
+
constructor(name: string, type: DdbFunctionType);
|
|
168
|
+
}
|
|
169
|
+
export declare class DDB {
|
|
170
|
+
port: number;
|
|
171
|
+
/** 当前的 session id (http 或 tcp) */
|
|
172
|
+
sid: string;
|
|
173
|
+
/** utf-8 text decoder */
|
|
174
|
+
dec: TextDecoder;
|
|
175
|
+
enc: TextEncoder;
|
|
176
|
+
print_buffer: boolean;
|
|
177
|
+
ws_url: string;
|
|
178
|
+
ws: WebSocket;
|
|
179
|
+
/** little endian (server) */
|
|
180
|
+
le: boolean;
|
|
181
|
+
/** little endian (client) */
|
|
182
|
+
static le_client: boolean;
|
|
183
|
+
/** resolver, rejector, promise of last rpc */
|
|
184
|
+
presolver(buf: Uint8Array): void;
|
|
185
|
+
prejector(error: Error): void;
|
|
186
|
+
presult: Promise<Uint8Array>;
|
|
187
|
+
constructor(ws_url: string);
|
|
188
|
+
/** 连接到 DolphinDB Server */
|
|
189
|
+
connect({ ws_url, login, username, password, }?: {
|
|
190
|
+
/** 默认使用实例初始化时传入的 WebSocket 链接地址 */
|
|
191
|
+
ws_url?: string;
|
|
192
|
+
/** 是否在建立连接后自动登录,默认 true */
|
|
193
|
+
login?: boolean;
|
|
194
|
+
/** DolphinDB 登录用户名 */
|
|
195
|
+
username?: string;
|
|
196
|
+
/** DolphinDB 登录密码 */
|
|
197
|
+
password?: string;
|
|
198
|
+
}): Promise<void>;
|
|
199
|
+
disconnect(): void;
|
|
200
|
+
/** rpc through websocket (function command)
|
|
201
|
+
- type: API 类型: 'script' | 'function' | 'variable'
|
|
202
|
+
- options:
|
|
203
|
+
- urgent?: 决定 `行为标识` 那一行字符串的取值(只适用于 script 和 function)
|
|
204
|
+
- vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
|
|
205
|
+
*/
|
|
206
|
+
rpc<T extends DdbObj = DdbObj>(type: 'script' | 'function' | 'variable', { script, func, args, vars, urgent, }: {
|
|
207
|
+
script?: string;
|
|
208
|
+
func?: string;
|
|
209
|
+
args?: (DdbObj | string | boolean)[];
|
|
210
|
+
vars?: string[];
|
|
211
|
+
urgent?: boolean;
|
|
212
|
+
}): Promise<T>;
|
|
213
|
+
/** eval script through websocket (script command) */
|
|
214
|
+
eval<T extends DdbObj>(
|
|
215
|
+
/** 执行的脚本 */
|
|
216
|
+
script: string,
|
|
217
|
+
/** 执行选项 */
|
|
218
|
+
{ urgent }?: {
|
|
219
|
+
/** 紧急 flag,使用 urgent worker 处理,防止被其它作业阻塞 */
|
|
220
|
+
urgent?: boolean;
|
|
221
|
+
}): Promise<T>;
|
|
222
|
+
/** call function through websocket (function command)
|
|
223
|
+
- func: 函数名
|
|
224
|
+
- args?: `[ ]` 调用参数 (传入的原生 string 和 boolean 会被自动转换为 DdbObj<string> 和 DdbObj<boolean>)
|
|
225
|
+
- options?: 调用选项
|
|
226
|
+
- urgent?: 紧急 flag,使用 urgent worker 处理,防止被其它作业阻塞
|
|
227
|
+
- node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
|
|
228
|
+
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
229
|
+
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
230
|
+
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
231
|
+
*/
|
|
232
|
+
call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias }?: {
|
|
233
|
+
urgent?: boolean;
|
|
234
|
+
node?: string;
|
|
235
|
+
nodes?: string[];
|
|
236
|
+
func_type?: DdbFunctionType;
|
|
237
|
+
add_node_alias?: boolean;
|
|
238
|
+
}): Promise<T>;
|
|
239
|
+
/** upload variable through websocket (variable command) */
|
|
240
|
+
upload(
|
|
241
|
+
/** 上传的变量名 */
|
|
242
|
+
vars: string[],
|
|
243
|
+
/** 上传的变量值 */
|
|
244
|
+
args: (DdbObj | string | boolean)[]): Promise<DdbObj<DdbValue>>;
|
|
245
|
+
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
246
|
+
parse_message(buf: Uint8Array): Uint8Array;
|
|
247
|
+
/** 自动转换 js string, boolean 为 DdbObj */
|
|
248
|
+
to_ddbobj(value: DdbObj | string | boolean): DdbObj;
|
|
249
|
+
/** 转换 js 数组为 DdbObj[] (in place, 会修改原数组) */
|
|
250
|
+
to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
|
|
251
|
+
}
|
|
252
|
+
export default DDB;
|