dolphindb 2.0.504 → 2.0.507

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 CHANGED
@@ -75,11 +75,10 @@ export interface DdbArrayVectorBlock {
75
75
  lengths: Uint8Array | Uint16Array | Uint32Array;
76
76
  data: DdbVectorValue;
77
77
  }
78
- export declare type DdbValue = null | boolean | number | [number, number] | bigint | string | string[] | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbFunctionDefValue | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
79
- export declare type DdbVectorValue = string | string[] | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
78
+ export declare type DdbValue = null | boolean | number | [number, number] | bigint | string | string[] | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbFunctionDefValue | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
79
+ export declare type DdbVectorValue = string | string[] | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
80
80
  export declare const nulls: {
81
- readonly bool: 128;
82
- readonly char: "€";
81
+ readonly int8: -128;
83
82
  readonly int16: -32768;
84
83
  readonly int32: -2147483648;
85
84
  readonly int64: -9223372036854775808n;
@@ -125,10 +124,11 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
125
124
  datatype?: DdbType;
126
125
  /** 实际数据。不同的 DdbForm, DdbType 使用 DdbValue 中不同的类型来表示实际数据 */
127
126
  value: T;
127
+ /** 原始二进制数据,仅在 parse_object 为 false 时通过 parse_message 生成的顶层对象有这个属性 */
128
+ buffer?: Uint8Array;
128
129
  constructor(data: Partial<DdbObj> & {
129
130
  form: DdbForm;
130
131
  type: DdbType;
131
- length: number;
132
132
  });
133
133
  static parse(buf: Uint8Array, le: boolean): DdbObj<DdbValue>;
134
134
  static parse_scalar(buf: Uint8Array, le: boolean, type: DdbType): [number, DdbValue];
@@ -159,7 +159,7 @@ export declare class DdbBool extends DdbObj<boolean> {
159
159
  constructor(value: boolean | null);
160
160
  }
161
161
  export declare class DdbChar extends DdbObj<string> {
162
- constructor(value: string | null);
162
+ constructor(value: string | number | null);
163
163
  }
164
164
  export declare class DdbInt extends DdbObj<number> {
165
165
  constructor(value: number | null);
@@ -270,13 +270,13 @@ export declare class DDB {
270
270
  password: string;
271
271
  /** python session flag (2048) */
272
272
  python: boolean;
273
- message_hook: (message: Uint8Array) => any;
274
- /** print message handler */
275
- printer(message: string): void;
276
- /** resolver, rejector, promise of last rpc */
277
- presolver(buf: Uint8Array): void;
278
- prejector(error: Error): void;
279
- presult: Promise<Uint8Array>;
273
+ print_message_buffer: boolean;
274
+ print_object_buffer: boolean;
275
+ print_message: boolean;
276
+ parse_object: boolean;
277
+ /** DdbMessage listeners */
278
+ listeners: DdbMessageListener[];
279
+ promise: Promise<any>;
280
280
  get connected(): boolean;
281
281
  /**
282
282
  Initialize an instance of DolphinDB Client using the WebSocket URL
@@ -291,7 +291,7 @@ export declare class DDB {
291
291
  @example
292
292
  let ddb = new DDB('ws://127.0.0.1:8848')
293
293
 
294
- // 使用 HTTPS 加密
294
+ // Encrypt with HTTPS
295
295
  let ddbsecure = new DDB('wss://dolphindb.com', {
296
296
  autologin: true,
297
297
  username: 'admin',
@@ -305,6 +305,7 @@ export declare class DDB {
305
305
  password?: string;
306
306
  python?: boolean;
307
307
  });
308
+ private on_message;
308
309
  /** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
309
310
  - options?:
310
311
  - url?: DolphinDB WebSocket URL. By default, the WebSocket URL passed in when the instance is initialized is used
@@ -349,58 +350,87 @@ export declare class DDB {
349
350
  - options:
350
351
  - urgent?: 决定 `行为标识` 那一行字符串的取值(只适用于 script 和 function)
351
352
  - vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
353
+ - listener?: 处理本次 rpc 期间的消息 (DdbMessage)
354
+ - parse_object?: 在本次 rpc 期间设置 parse_object, 结束后恢复原有
355
+ 为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化
352
356
  */
353
- rpc<T extends DdbObj = DdbObj>(type: 'script' | 'function' | 'variable' | 'connect', { script, func, args, vars, urgent, }: {
357
+ rpc<T extends DdbObj = DdbObj>(type: 'script' | 'function' | 'variable' | 'connect', { script, func, args, vars, urgent, listener, parse_object, }: {
354
358
  script?: string;
355
359
  func?: string;
356
360
  args?: (DdbObj | string | boolean)[];
357
361
  vars?: string[];
358
362
  urgent?: boolean;
363
+ listener?: DdbMessageListener;
364
+ parse_object?: boolean;
359
365
  }): Promise<T>;
360
- /** eval script through websocket (script command) */
361
- eval<T extends DdbObj>(
362
- /** 执行的脚本 */
363
- script: string,
364
- /** 执行选项 */
365
- { urgent }?: {
366
- /** 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞 */
366
+ /** eval script through websocket (script command)
367
+ - script?: Script to execute
368
+ - options?: execution options
369
+ - urgent?: Urgent flag to ensure that submitted scripts are processed by urgent workers to prevent being blocked by other jobs
370
+ - listener?: Process messages during this rpc (DdbMessage)
371
+ - parse_object?: Set parse_object during this rpc, and restore the original after the end.
372
+ When it is false, the returned DdbObj only contains buffer and le without parsing,
373
+ so as to facilitate subsequent forwarding and serialization
374
+ */
375
+ eval<T extends DdbObj>(script: string, { urgent, listener, parse_object, }?: {
367
376
  urgent?: boolean;
377
+ listener?: DdbMessageListener;
378
+ parse_object?: boolean;
368
379
  }): Promise<T>;
369
380
  /** call function through websocket (function command)
370
- - func: 函数名
371
- - args?: `[ ]` 调用参数 (传入的原生 string 和 boolean 会被自动转换为 DdbObj<string> 和 DdbObj<boolean>)
372
- - options?: 调用选项
373
- - urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
374
- - node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
375
- - nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
376
- - func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
377
- - add_node_alias?: 设置 nodes 参数时选传,其它情况不传
381
+ - func: function name
382
+ - args?: `[ ]` Call parameters (the incoming native string and boolean will be automatically converted to DdbObj<string> and DdbObj<boolean>)
383
+ - options?: call options
384
+ - urgent?: Emergency flag. Use urgent worker execution to prevent being blocked by other jobs
385
+ - 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)
386
+ - nodes?: When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
387
+ - 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
388
+ - add_node_alias?: Select to pass when setting the nodes parameter, otherwise not pass
389
+ - listener?: Process messages during this rpc (DdbMessage)
390
+ - parse_object?: Set parse_object during this rpc, and restore the original after the end.
391
+ When it is false, the returned DdbObj only contains buffer and le without parsing,
392
+ so as to facilitate subsequent forwarding and serialization
378
393
  */
379
- call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias }?: {
394
+ call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias, listener, parse_object, }?: {
380
395
  urgent?: boolean;
381
396
  node?: string;
382
397
  nodes?: string[];
383
398
  func_type?: DdbFunctionType;
384
399
  add_node_alias?: boolean;
400
+ listener?: DdbMessageListener;
401
+ parse_object?: boolean;
385
402
  }): Promise<T>;
386
403
  /** upload variable through websocket (variable command) */
387
404
  upload(
388
405
  /** Uploaded variables' name */
389
406
  vars: string[],
390
407
  /** Uploaded variables' value */
391
- args: (DdbObj | string | boolean)[]): Promise<DdbObj<DdbValue>>;
408
+ args: (DdbObj | string | boolean)[], { listener, parse_object, }?: {
409
+ listener?: DdbMessageListener;
410
+ parse_object?: boolean;
411
+ }): Promise<DdbObj<DdbValue>>;
392
412
  /** 解析服务端响应报文,返回去掉 header 的 data buf */
393
- parse_message(buf: Uint8Array): {
394
- type: "message";
395
- data: string;
396
- } | {
397
- type: "object";
398
- data: Uint8Array;
399
- };
413
+ parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
400
414
  /** 自动转换 js string, boolean 为 DdbObj */
401
415
  to_ddbobj(value: DdbObj | string | boolean): DdbObj;
402
416
  /** 转换 js 数组为 DdbObj[] */
403
417
  to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
404
418
  }
419
+ export interface DdbMessageListener {
420
+ (message: DdbMessage, _this: DDB): any;
421
+ }
422
+ export interface DdbPrintMessage {
423
+ type: 'print';
424
+ data: string;
425
+ }
426
+ export interface DdbObjectMessage {
427
+ type: 'object';
428
+ data: DdbObj;
429
+ }
430
+ export interface DdbErrorMessage {
431
+ type: 'error';
432
+ data: Error;
433
+ }
434
+ export declare type DdbMessage = DdbPrintMessage | DdbObjectMessage | DdbErrorMessage;
405
435
  export declare let ddb: DDB;
406
436
  export default ddb;