dolphindb 2.0.505 → 2.0.508
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/browser.d.ts +37 -27
- package/browser.js +153 -106
- package/browser.js.map +1 -1
- package/index.d.ts +51 -40
- package/index.js +178 -128
- package/index.js.map +1 -1
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -78,7 +78,12 @@ export interface DdbArrayVectorBlock {
|
|
|
78
78
|
lengths: Uint8Array | Uint16Array | Uint32Array;
|
|
79
79
|
data: DdbVectorValue;
|
|
80
80
|
}
|
|
81
|
-
export
|
|
81
|
+
export interface DdbMatrixValue {
|
|
82
|
+
rows: DdbObj;
|
|
83
|
+
cols: DdbObj;
|
|
84
|
+
data: DdbVectorValue;
|
|
85
|
+
}
|
|
86
|
+
export declare type DdbValue = null | boolean | number | [number, number] | bigint | string | string[] | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbFunctionDefValue | DdbSymbolExtendedValue | DdbArrayVectorBlock[] | DdbMatrixValue;
|
|
82
87
|
export declare type DdbVectorValue = string | string[] | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
83
88
|
export declare const nulls: {
|
|
84
89
|
readonly int8: -128;
|
|
@@ -123,23 +128,20 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
123
128
|
rows?: number;
|
|
124
129
|
/** 第 2 维 */
|
|
125
130
|
cols?: number;
|
|
126
|
-
/** matrix 中值的类型,仅 matrix 才有 */
|
|
127
|
-
datatype?: DdbType;
|
|
128
131
|
/** 实际数据。不同的 DdbForm, DdbType 使用 DdbValue 中不同的类型来表示实际数据 */
|
|
129
132
|
value: T;
|
|
130
|
-
/**
|
|
133
|
+
/** 原始二进制数据,仅在 parse_object 为 false 时通过 parse_message 生成的顶层对象有这个属性 */
|
|
131
134
|
buffer?: Uint8Array;
|
|
132
135
|
constructor(data: Partial<DdbObj> & {
|
|
133
136
|
form: DdbForm;
|
|
134
137
|
type: DdbType;
|
|
135
|
-
length: number;
|
|
136
138
|
});
|
|
137
139
|
static parse(buf: Uint8Array, le: boolean): DdbObj<DdbValue>;
|
|
138
140
|
static parse_scalar(buf: Uint8Array, le: boolean, type: DdbType): [number, DdbValue];
|
|
139
141
|
/** parse: rows, cols, items
|
|
140
142
|
返回的 ddbobj.length 不包括 vector 的 type 和 form
|
|
141
143
|
*/
|
|
142
|
-
static parse_vector(buf: Uint8Array, le: boolean, type: DdbType): DdbObj
|
|
144
|
+
static parse_vector(buf: Uint8Array, le: boolean, type: DdbType): DdbObj<DdbVectorValue>;
|
|
143
145
|
/** 有可能没有字节对齐,不能直接使用原有 message 的 arraybuffer, 统一复制出来,让原有 arraybuffer 被回收掉比较好 */
|
|
144
146
|
static parse_vector_items(buf: Uint8Array, le: boolean, type: DdbType, length: number): [
|
|
145
147
|
number,
|
|
@@ -252,7 +254,6 @@ export declare class DDB {
|
|
|
252
254
|
/** utf-8 text decoder */
|
|
253
255
|
dec: TextDecoder;
|
|
254
256
|
enc: TextEncoder;
|
|
255
|
-
print_buffer: boolean;
|
|
256
257
|
/** DolphinDB WebSocket URL
|
|
257
258
|
e.g. `ws://127.0.0.1:8848/`, `wss://dolphindb.com`
|
|
258
259
|
*/
|
|
@@ -270,13 +271,13 @@ export declare class DDB {
|
|
|
270
271
|
password: string;
|
|
271
272
|
/** python session flag (2048) */
|
|
272
273
|
python: boolean;
|
|
274
|
+
print_message_buffer: boolean;
|
|
275
|
+
print_object_buffer: boolean;
|
|
276
|
+
print_message: boolean;
|
|
273
277
|
parse_object: boolean;
|
|
274
|
-
/**
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
presolver(message: DdbMessage): void;
|
|
278
|
-
prejector(error: Error): void;
|
|
279
|
-
presult: Promise<DdbMessage>;
|
|
278
|
+
/** DdbMessage listeners */
|
|
279
|
+
listeners: DdbMessageListener[];
|
|
280
|
+
promise: Promise<any>;
|
|
280
281
|
get connected(): boolean;
|
|
281
282
|
/**
|
|
282
283
|
Initialize an instance of DolphinDB Client using the WebSocket URL
|
|
@@ -305,6 +306,7 @@ export declare class DDB {
|
|
|
305
306
|
password?: string;
|
|
306
307
|
python?: boolean;
|
|
307
308
|
});
|
|
309
|
+
private on_message;
|
|
308
310
|
/** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
|
|
309
311
|
- options?:
|
|
310
312
|
- url?: DolphinDB WebSocket URL. By default, the WebSocket URL passed in when the instance is initialized is used
|
|
@@ -349,52 +351,54 @@ export declare class DDB {
|
|
|
349
351
|
- options:
|
|
350
352
|
- urgent?: 决定 `行为标识` 那一行字符串的取值(只适用于 script 和 function)
|
|
351
353
|
- vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
|
|
352
|
-
-
|
|
354
|
+
- handler?: Process messages during this rpc (DdbMessage)
|
|
353
355
|
- parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
|
|
354
356
|
不做解析,以便后续转发、序列化
|
|
355
357
|
*/
|
|
356
|
-
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, listener, parse_object, }: {
|
|
357
359
|
script?: string;
|
|
358
360
|
func?: string;
|
|
359
361
|
args?: (DdbObj | string | boolean)[];
|
|
360
362
|
vars?: string[];
|
|
361
363
|
urgent?: boolean;
|
|
362
|
-
|
|
364
|
+
listener?: DdbMessageListener;
|
|
363
365
|
parse_object?: boolean;
|
|
364
366
|
}): Promise<T>;
|
|
365
367
|
/** eval script through websocket (script command)
|
|
366
|
-
- script?:
|
|
367
|
-
- options?:
|
|
368
|
-
- urgent?:
|
|
369
|
-
-
|
|
370
|
-
- parse_object?:
|
|
371
|
-
|
|
368
|
+
- script?: Script to execute
|
|
369
|
+
- options?: execution options
|
|
370
|
+
- urgent?: Urgent flag to ensure that submitted scripts are processed by urgent workers to prevent being blocked by other jobs
|
|
371
|
+
- listener?: Process messages during this rpc (DdbMessage)
|
|
372
|
+
- parse_object?: Set parse_object during this rpc, and restore the original after the end.
|
|
373
|
+
When it is false, the returned DdbObj only contains buffer and le without parsing,
|
|
374
|
+
so as to facilitate subsequent forwarding and serialization
|
|
372
375
|
*/
|
|
373
|
-
eval<T extends DdbObj>(script: string, { urgent,
|
|
376
|
+
eval<T extends DdbObj>(script: string, { urgent, listener, parse_object, }?: {
|
|
374
377
|
urgent?: boolean;
|
|
375
|
-
|
|
378
|
+
listener?: DdbMessageListener;
|
|
376
379
|
parse_object?: boolean;
|
|
377
380
|
}): Promise<T>;
|
|
378
381
|
/** call function through websocket (function command)
|
|
379
|
-
- func:
|
|
380
|
-
- args?: `[ ]`
|
|
381
|
-
- options?:
|
|
382
|
-
- urgent?:
|
|
383
|
-
- node?:
|
|
384
|
-
- nodes?:
|
|
385
|
-
- func_type?:
|
|
386
|
-
- add_node_alias?:
|
|
387
|
-
-
|
|
388
|
-
- parse_object?:
|
|
389
|
-
|
|
382
|
+
- func: function name
|
|
383
|
+
- args?: `[ ]` Call parameters (the incoming native string and boolean will be automatically converted to DdbObj<string> and DdbObj<boolean>)
|
|
384
|
+
- options?: call options
|
|
385
|
+
- urgent?: Emergency flag. Use urgent worker execution to prevent being blocked by other jobs
|
|
386
|
+
- node?: When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
|
|
387
|
+
- nodes?: When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
|
|
388
|
+
- func_type?: It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
|
|
389
|
+
- add_node_alias?: Select to pass when setting the nodes parameter, otherwise not pass
|
|
390
|
+
- listener?: Process messages during this rpc (DdbMessage)
|
|
391
|
+
- parse_object?: Set parse_object during this rpc, and restore the original after the end.
|
|
392
|
+
When it is false, the returned DdbObj only contains buffer and le without parsing,
|
|
393
|
+
so as to facilitate subsequent forwarding and serialization
|
|
390
394
|
*/
|
|
391
|
-
call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias,
|
|
395
|
+
call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias, listener, parse_object, }?: {
|
|
392
396
|
urgent?: boolean;
|
|
393
397
|
node?: string;
|
|
394
398
|
nodes?: string[];
|
|
395
399
|
func_type?: DdbFunctionType;
|
|
396
400
|
add_node_alias?: boolean;
|
|
397
|
-
|
|
401
|
+
listener?: DdbMessageListener;
|
|
398
402
|
parse_object?: boolean;
|
|
399
403
|
}): Promise<T>;
|
|
400
404
|
/** upload variable through websocket (variable command) */
|
|
@@ -402,8 +406,8 @@ export declare class DDB {
|
|
|
402
406
|
/** Uploaded variables' name */
|
|
403
407
|
vars: string[],
|
|
404
408
|
/** Uploaded variables' value */
|
|
405
|
-
args: (DdbObj | string | boolean)[], {
|
|
406
|
-
|
|
409
|
+
args: (DdbObj | string | boolean)[], { listener, parse_object, }?: {
|
|
410
|
+
listener?: DdbMessageListener;
|
|
407
411
|
parse_object?: boolean;
|
|
408
412
|
}): Promise<DdbObj<DdbValue>>;
|
|
409
413
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
@@ -413,6 +417,9 @@ export declare class DDB {
|
|
|
413
417
|
/** 转换 js 数组为 DdbObj[] */
|
|
414
418
|
to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
|
|
415
419
|
}
|
|
420
|
+
export interface DdbMessageListener {
|
|
421
|
+
(message: DdbMessage, _this: DDB): any;
|
|
422
|
+
}
|
|
416
423
|
export interface DdbPrintMessage {
|
|
417
424
|
type: 'print';
|
|
418
425
|
data: string;
|
|
@@ -421,5 +428,9 @@ export interface DdbObjectMessage {
|
|
|
421
428
|
type: 'object';
|
|
422
429
|
data: DdbObj;
|
|
423
430
|
}
|
|
424
|
-
export
|
|
431
|
+
export interface DdbErrorMessage {
|
|
432
|
+
type: 'error';
|
|
433
|
+
data: Error;
|
|
434
|
+
}
|
|
435
|
+
export declare type DdbMessage = DdbPrintMessage | DdbObjectMessage | DdbErrorMessage;
|
|
425
436
|
export default DDB;
|