dolphindb 2.0.503 → 2.0.506
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 +37 -32
- package/README.zh.md +29 -24
- package/browser.d.ts +82 -38
- package/browser.js +233 -108
- package/browser.js.map +1 -1
- package/index.d.ts +72 -31
- package/index.js +222 -108
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -78,11 +78,10 @@ export interface DdbArrayVectorBlock {
|
|
|
78
78
|
lengths: Uint8Array | Uint16Array | Uint32Array;
|
|
79
79
|
data: DdbVectorValue;
|
|
80
80
|
}
|
|
81
|
-
export declare type DdbValue = null | boolean | number | [number, number] | bigint | string | string[] | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbFunctionDefValue | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
82
|
-
export declare type DdbVectorValue = string | string[] | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
81
|
+
export declare type DdbValue = null | boolean | number | [number, number] | bigint | string | string[] | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbFunctionDefValue | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
82
|
+
export declare type DdbVectorValue = string | string[] | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
83
83
|
export declare const nulls: {
|
|
84
|
-
readonly
|
|
85
|
-
readonly char: "";
|
|
84
|
+
readonly int8: -128;
|
|
86
85
|
readonly int16: -32768;
|
|
87
86
|
readonly int32: -2147483648;
|
|
88
87
|
readonly int64: -9223372036854775808n;
|
|
@@ -128,6 +127,8 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
128
127
|
datatype?: DdbType;
|
|
129
128
|
/** 实际数据。不同的 DdbForm, DdbType 使用 DdbValue 中不同的类型来表示实际数据 */
|
|
130
129
|
value: T;
|
|
130
|
+
/** 原始二进制数据 */
|
|
131
|
+
buffer?: Uint8Array;
|
|
131
132
|
constructor(data: Partial<DdbObj> & {
|
|
132
133
|
form: DdbForm;
|
|
133
134
|
type: DdbType;
|
|
@@ -157,7 +158,7 @@ export declare class DdbBool extends DdbObj<boolean> {
|
|
|
157
158
|
constructor(value: boolean | null);
|
|
158
159
|
}
|
|
159
160
|
export declare class DdbChar extends DdbObj<string> {
|
|
160
|
-
constructor(value: string | null);
|
|
161
|
+
constructor(value: string | number | null);
|
|
161
162
|
}
|
|
162
163
|
export declare class DdbInt extends DdbObj<number> {
|
|
163
164
|
constructor(value: number | null);
|
|
@@ -189,18 +190,27 @@ export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
|
|
|
189
190
|
export declare class DdbVectorInt extends DdbObj<Int32Array> {
|
|
190
191
|
constructor(ints: (number | null)[] | Int32Array, name?: string);
|
|
191
192
|
}
|
|
192
|
-
export declare class DdbVectorString extends DdbObj<string[]> {
|
|
193
|
-
constructor(strings: string[], name?: string);
|
|
194
|
-
}
|
|
195
193
|
export declare class DdbVectorDouble extends DdbObj<Float64Array> {
|
|
196
194
|
constructor(doubles: (number | null)[] | Float64Array, name?: string);
|
|
197
195
|
}
|
|
196
|
+
export declare class DdbVectorString extends DdbObj<string[]> {
|
|
197
|
+
constructor(strings: string[], name?: string);
|
|
198
|
+
}
|
|
198
199
|
export declare class DdbVectorAny extends DdbObj {
|
|
199
200
|
constructor(objs: DdbObj<DdbValue>[], name?: string);
|
|
200
201
|
}
|
|
201
202
|
export declare class DdbVectorSymbol extends DdbObj<DdbSymbolExtendedValue> {
|
|
202
203
|
constructor(strings: string[], name?: string);
|
|
203
204
|
}
|
|
205
|
+
export declare class DdbSetInt extends DdbObj<Int32Array> {
|
|
206
|
+
constructor(ints: (number | null)[] | Set<number> | Int32Array);
|
|
207
|
+
}
|
|
208
|
+
export declare class DdbSetDouble extends DdbObj<Float64Array> {
|
|
209
|
+
constructor(doubles: (number | null)[] | Set<number> | Float64Array);
|
|
210
|
+
}
|
|
211
|
+
export declare class DdbSetString extends DdbObj<string[]> {
|
|
212
|
+
constructor(strings: string[] | Set<string>);
|
|
213
|
+
}
|
|
204
214
|
export declare class DdbTable extends DdbObj<DdbObj[]> {
|
|
205
215
|
constructor(columns: DdbObj[], name?: string);
|
|
206
216
|
}
|
|
@@ -242,7 +252,6 @@ export declare class DDB {
|
|
|
242
252
|
/** utf-8 text decoder */
|
|
243
253
|
dec: TextDecoder;
|
|
244
254
|
enc: TextEncoder;
|
|
245
|
-
print_buffer: boolean;
|
|
246
255
|
/** DolphinDB WebSocket URL
|
|
247
256
|
e.g. `ws://127.0.0.1:8848/`, `wss://dolphindb.com`
|
|
248
257
|
*/
|
|
@@ -260,13 +269,16 @@ export declare class DDB {
|
|
|
260
269
|
password: string;
|
|
261
270
|
/** python session flag (2048) */
|
|
262
271
|
python: boolean;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
272
|
+
print_message_buffer: boolean;
|
|
273
|
+
print_object_buffer: boolean;
|
|
274
|
+
print_message: boolean;
|
|
275
|
+
parse_object: boolean;
|
|
276
|
+
/** message handlers */
|
|
277
|
+
handlers: DdbMessageHandler[];
|
|
266
278
|
/** resolver, rejector, promise of last rpc */
|
|
267
|
-
presolver(
|
|
279
|
+
presolver(ddbobj: DdbObj): void;
|
|
268
280
|
prejector(error: Error): void;
|
|
269
|
-
presult: Promise<
|
|
281
|
+
presult: Promise<DdbObj<DdbValue>>;
|
|
270
282
|
get connected(): boolean;
|
|
271
283
|
/**
|
|
272
284
|
Initialize an instance of DolphinDB Client using the WebSocket URL
|
|
@@ -280,6 +292,8 @@ export declare class DDB {
|
|
|
280
292
|
|
|
281
293
|
@example
|
|
282
294
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
295
|
+
|
|
296
|
+
// 使用 HTTPS 加密
|
|
283
297
|
let ddbsecure = new DDB('wss://dolphindb.com', {
|
|
284
298
|
autologin: true,
|
|
285
299
|
username: 'admin',
|
|
@@ -337,22 +351,31 @@ export declare class DDB {
|
|
|
337
351
|
- options:
|
|
338
352
|
- urgent?: 决定 `行为标识` 那一行字符串的取值(只适用于 script 和 function)
|
|
339
353
|
- vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
|
|
354
|
+
- handler?: 处理本次 rpc 期间的消息
|
|
355
|
+
- parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
|
|
356
|
+
不做解析,以便后续转发、序列化
|
|
340
357
|
*/
|
|
341
|
-
rpc<T extends DdbObj = DdbObj>(type: 'script' | 'function' | 'variable' | 'connect', { script, func, args, vars, urgent, }: {
|
|
358
|
+
rpc<T extends DdbObj = DdbObj>(type: 'script' | 'function' | 'variable' | 'connect', { script, func, args, vars, urgent, handler, parse_object, }: {
|
|
342
359
|
script?: string;
|
|
343
360
|
func?: string;
|
|
344
361
|
args?: (DdbObj | string | boolean)[];
|
|
345
362
|
vars?: string[];
|
|
346
363
|
urgent?: boolean;
|
|
364
|
+
handler?: DdbMessageHandler;
|
|
365
|
+
parse_object?: boolean;
|
|
347
366
|
}): Promise<T>;
|
|
348
|
-
/** eval script through websocket (script command)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
367
|
+
/** eval script through websocket (script command)
|
|
368
|
+
- script?: 执行的脚本
|
|
369
|
+
- options?: 执行选项
|
|
370
|
+
- urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
|
|
371
|
+
- handler?: 处理本次 rpc 期间的消息
|
|
372
|
+
- parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
|
|
373
|
+
不做解析,以便后续转发、序列化
|
|
374
|
+
*/
|
|
375
|
+
eval<T extends DdbObj>(script: string, { urgent, handler, parse_object, }?: {
|
|
355
376
|
urgent?: boolean;
|
|
377
|
+
handler?: DdbMessageHandler;
|
|
378
|
+
parse_object?: boolean;
|
|
356
379
|
}): Promise<T>;
|
|
357
380
|
/** call function through websocket (function command)
|
|
358
381
|
- func: 函数名
|
|
@@ -363,31 +386,49 @@ export declare class DDB {
|
|
|
363
386
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
364
387
|
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
365
388
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
389
|
+
- handler?: 处理本次 rpc 期间的消息
|
|
390
|
+
- parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
|
|
391
|
+
不做解析,以便后续转发、序列化
|
|
366
392
|
*/
|
|
367
|
-
call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias }?: {
|
|
393
|
+
call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias, handler, parse_object, }?: {
|
|
368
394
|
urgent?: boolean;
|
|
369
395
|
node?: string;
|
|
370
396
|
nodes?: string[];
|
|
371
397
|
func_type?: DdbFunctionType;
|
|
372
398
|
add_node_alias?: boolean;
|
|
399
|
+
handler?: DdbMessageHandler;
|
|
400
|
+
parse_object?: boolean;
|
|
373
401
|
}): Promise<T>;
|
|
374
402
|
/** upload variable through websocket (variable command) */
|
|
375
403
|
upload(
|
|
376
404
|
/** Uploaded variables' name */
|
|
377
405
|
vars: string[],
|
|
378
406
|
/** Uploaded variables' value */
|
|
379
|
-
args: (DdbObj | string | boolean)[]
|
|
407
|
+
args: (DdbObj | string | boolean)[], { handler, parse_object, }?: {
|
|
408
|
+
handler?: DdbMessageHandler;
|
|
409
|
+
parse_object?: boolean;
|
|
410
|
+
}): Promise<DdbObj<DdbValue>>;
|
|
380
411
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
381
|
-
parse_message(buf: Uint8Array):
|
|
382
|
-
type: "message";
|
|
383
|
-
data: string;
|
|
384
|
-
} | {
|
|
385
|
-
type: "object";
|
|
386
|
-
data: Uint8Array;
|
|
387
|
-
};
|
|
412
|
+
parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
|
|
388
413
|
/** 自动转换 js string, boolean 为 DdbObj */
|
|
389
414
|
to_ddbobj(value: DdbObj | string | boolean): DdbObj;
|
|
390
415
|
/** 转换 js 数组为 DdbObj[] */
|
|
391
416
|
to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
|
|
392
417
|
}
|
|
418
|
+
export interface DdbMessageHandler {
|
|
419
|
+
(message: DdbMessage, _this: DDB): any;
|
|
420
|
+
}
|
|
421
|
+
export interface DdbPrintMessage {
|
|
422
|
+
type: 'print';
|
|
423
|
+
data: string;
|
|
424
|
+
}
|
|
425
|
+
export interface DdbObjectMessage {
|
|
426
|
+
type: 'object';
|
|
427
|
+
data: DdbObj;
|
|
428
|
+
}
|
|
429
|
+
export interface DdbErrorMessage {
|
|
430
|
+
type: 'error';
|
|
431
|
+
data: Error;
|
|
432
|
+
}
|
|
433
|
+
export declare type DdbMessage = DdbPrintMessage | DdbObjectMessage | DdbErrorMessage;
|
|
393
434
|
export default DDB;
|