dolphindb 2.0.502 → 2.0.505
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 +110 -49
- package/browser.js +242 -102
- package/browser.js.map +1 -1
- package/index.d.ts +97 -40
- package/index.js +221 -95
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/test/index.d.ts +0 -1
- package/test/index.js +0 -20
- package/test/index.js.map +0 -1
- package/test/print.d.ts +0 -2
- package/test/print.js +0 -20
- package/test/print.js.map +0 -1
- package/test/types.d.ts +0 -2
- package/test/types.js +0 -24
- package/test/types.js.map +0 -1
- package/test.d.ts +0 -1
- package/test.js +0 -38
- package/test.js.map +0 -1
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
|
}
|
|
@@ -252,35 +262,62 @@ export declare class DDB {
|
|
|
252
262
|
le: boolean;
|
|
253
263
|
/** little endian (client) */
|
|
254
264
|
static le_client: boolean;
|
|
265
|
+
/** 是否在建立连接后自动登录,默认 true */
|
|
266
|
+
autologin: boolean;
|
|
267
|
+
/** DolphinDB 登录用户名 */
|
|
268
|
+
username: string;
|
|
269
|
+
/** DolphinDB 登录密码 */
|
|
270
|
+
password: string;
|
|
255
271
|
/** python session flag (2048) */
|
|
256
272
|
python: boolean;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
|
|
273
|
+
parse_object: boolean;
|
|
274
|
+
/** message handler */
|
|
275
|
+
on_message({ type, data }: DdbMessage, _this: DDB): void;
|
|
260
276
|
/** resolver, rejector, promise of last rpc */
|
|
261
|
-
presolver(
|
|
277
|
+
presolver(message: DdbMessage): void;
|
|
262
278
|
prejector(error: Error): void;
|
|
263
|
-
presult: Promise<
|
|
279
|
+
presult: Promise<DdbMessage>;
|
|
264
280
|
get connected(): boolean;
|
|
265
281
|
/**
|
|
266
282
|
Initialize an instance of DolphinDB Client using the WebSocket URL
|
|
267
283
|
(without establishing an actual network connection)
|
|
284
|
+
- url: DolphinDB WebSocket URL. e.g.:`ws://127.0.0.1:8848`
|
|
285
|
+
- options?:
|
|
286
|
+
- autologin?: Whether to log in automatically after establishing a connection, default `true`
|
|
287
|
+
- username?: DolphinDB username, default `'admin'`
|
|
288
|
+
- password?: DolphinDB password, default `'123456'`
|
|
289
|
+
- python?: set python session flag, default `false`
|
|
290
|
+
|
|
268
291
|
@example
|
|
269
292
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
270
|
-
|
|
293
|
+
|
|
294
|
+
// 使用 HTTPS 加密
|
|
295
|
+
let ddbsecure = new DDB('wss://dolphindb.com', {
|
|
296
|
+
autologin: true,
|
|
297
|
+
username: 'admin',
|
|
298
|
+
password: '123456',
|
|
299
|
+
python: false
|
|
300
|
+
})
|
|
271
301
|
*/
|
|
272
|
-
constructor(url: string
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
302
|
+
constructor(url: string, options?: {
|
|
303
|
+
autologin?: boolean;
|
|
304
|
+
username?: string;
|
|
305
|
+
password?: string;
|
|
306
|
+
python?: boolean;
|
|
307
|
+
});
|
|
308
|
+
/** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
|
|
309
|
+
- options?:
|
|
310
|
+
- url?: DolphinDB WebSocket URL. By default, the WebSocket URL passed in when the instance is initialized is used
|
|
311
|
+
- autologin?: Whether to log in automatically after establishing a connection, default `true`
|
|
312
|
+
- username?: DolphinDB username, default `'admin'`
|
|
313
|
+
- password?: DolphinDB password, default `'123456'`
|
|
314
|
+
- python?: set python session flag, default `false`
|
|
315
|
+
*/
|
|
316
|
+
connect(options?: {
|
|
276
317
|
url?: string;
|
|
277
|
-
|
|
278
|
-
login?: boolean;
|
|
279
|
-
/** DolphinDB username */
|
|
318
|
+
autologin?: boolean;
|
|
280
319
|
username?: string;
|
|
281
|
-
/** DolphinDB password */
|
|
282
320
|
password?: string;
|
|
283
|
-
/** set python session flag */
|
|
284
321
|
python?: boolean;
|
|
285
322
|
}): Promise<void>;
|
|
286
323
|
get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
|
|
@@ -312,22 +349,31 @@ export declare class DDB {
|
|
|
312
349
|
- options:
|
|
313
350
|
- urgent?: 决定 `行为标识` 那一行字符串的取值(只适用于 script 和 function)
|
|
314
351
|
- vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
|
|
352
|
+
- on_message?: 在该次 rpc 期间设置 message handler, 结束后恢复原有
|
|
353
|
+
- parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
|
|
354
|
+
不做解析,以便后续转发、序列化
|
|
315
355
|
*/
|
|
316
|
-
rpc<T extends DdbObj = DdbObj>(type: 'script' | 'function' | 'variable' | 'connect', { script, func, args, vars, urgent, }: {
|
|
356
|
+
rpc<T extends DdbObj = DdbObj>(type: 'script' | 'function' | 'variable' | 'connect', { script, func, args, vars, urgent, on_message, parse_object, }: {
|
|
317
357
|
script?: string;
|
|
318
358
|
func?: string;
|
|
319
359
|
args?: (DdbObj | string | boolean)[];
|
|
320
360
|
vars?: string[];
|
|
321
361
|
urgent?: boolean;
|
|
362
|
+
on_message?: DDB['on_message'];
|
|
363
|
+
parse_object?: boolean;
|
|
322
364
|
}): Promise<T>;
|
|
323
|
-
/** eval script through websocket (script command)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
365
|
+
/** eval script through websocket (script command)
|
|
366
|
+
- script?: 执行的脚本
|
|
367
|
+
- options?: 执行选项
|
|
368
|
+
- urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
|
|
369
|
+
- on_message?: 在该次 rpc 期间设置 message handler, 结束后恢复原有
|
|
370
|
+
- parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
|
|
371
|
+
不做解析,以便后续转发、序列化
|
|
372
|
+
*/
|
|
373
|
+
eval<T extends DdbObj>(script: string, { urgent, on_message, parse_object, }?: {
|
|
330
374
|
urgent?: boolean;
|
|
375
|
+
on_message?: DDB['on_message'];
|
|
376
|
+
parse_object?: boolean;
|
|
331
377
|
}): Promise<T>;
|
|
332
378
|
/** call function through websocket (function command)
|
|
333
379
|
- func: 函数名
|
|
@@ -338,31 +384,42 @@ export declare class DDB {
|
|
|
338
384
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
339
385
|
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
340
386
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
387
|
+
- on_message?: 在该次 rpc 期间设置 message handler, 结束后恢复原有
|
|
388
|
+
- parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
|
|
389
|
+
不做解析,以便后续转发、序列化
|
|
341
390
|
*/
|
|
342
|
-
call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias }?: {
|
|
391
|
+
call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias, on_message, parse_object, }?: {
|
|
343
392
|
urgent?: boolean;
|
|
344
393
|
node?: string;
|
|
345
394
|
nodes?: string[];
|
|
346
395
|
func_type?: DdbFunctionType;
|
|
347
396
|
add_node_alias?: boolean;
|
|
397
|
+
on_message?: DDB['on_message'];
|
|
398
|
+
parse_object?: boolean;
|
|
348
399
|
}): Promise<T>;
|
|
349
400
|
/** upload variable through websocket (variable command) */
|
|
350
401
|
upload(
|
|
351
402
|
/** Uploaded variables' name */
|
|
352
403
|
vars: string[],
|
|
353
404
|
/** Uploaded variables' value */
|
|
354
|
-
args: (DdbObj | string | boolean)[]
|
|
405
|
+
args: (DdbObj | string | boolean)[], { on_message, parse_object, }?: {
|
|
406
|
+
on_message?: DDB['on_message'];
|
|
407
|
+
parse_object?: boolean;
|
|
408
|
+
}): Promise<DdbObj<DdbValue>>;
|
|
355
409
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
356
|
-
parse_message(buf: Uint8Array):
|
|
357
|
-
type: "message";
|
|
358
|
-
data: string;
|
|
359
|
-
} | {
|
|
360
|
-
type: "object";
|
|
361
|
-
data: Uint8Array;
|
|
362
|
-
};
|
|
410
|
+
parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
|
|
363
411
|
/** 自动转换 js string, boolean 为 DdbObj */
|
|
364
412
|
to_ddbobj(value: DdbObj | string | boolean): DdbObj;
|
|
365
413
|
/** 转换 js 数组为 DdbObj[] */
|
|
366
414
|
to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
|
|
367
415
|
}
|
|
416
|
+
export interface DdbPrintMessage {
|
|
417
|
+
type: 'print';
|
|
418
|
+
data: string;
|
|
419
|
+
}
|
|
420
|
+
export interface DdbObjectMessage {
|
|
421
|
+
type: 'object';
|
|
422
|
+
data: DdbObj;
|
|
423
|
+
}
|
|
424
|
+
export declare type DdbMessage = DdbPrintMessage | DdbObjectMessage;
|
|
368
425
|
export default DDB;
|