dolphindb 2.0.603 → 2.0.800

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
@@ -53,7 +53,11 @@ export declare enum DdbType {
53
53
  complex = 34,
54
54
  point = 35,
55
55
  duration = 36,
56
- object = 37,
56
+ decimal32 = 37,
57
+ decimal64 = 38,
58
+ decimal128 = 39,
59
+ object = 40,
60
+ pynone = 41,
57
61
  symbol_extended = 145
58
62
  }
59
63
  export declare enum DdbFunctionType {
@@ -89,6 +93,26 @@ export interface DdbDurationValue {
89
93
  /** int32 */
90
94
  data: number;
91
95
  }
96
+ export interface DdbDecimal32Value {
97
+ /** int32, data needs to be divided by 10^scale to get the original value */
98
+ scale: number;
99
+ /** int32, 空值为 null */
100
+ data: number | null;
101
+ }
102
+ export interface DdbDecimal64Value {
103
+ /** int32, data needs to be divided by 10^scale to get the original value */
104
+ scale: number;
105
+ /** int64, 空值为 null */
106
+ data: bigint | null;
107
+ }
108
+ export interface DdbDecimal32VectorValue {
109
+ scale: number;
110
+ data: Int32Array;
111
+ }
112
+ export interface DdbDecimal64VectorValue {
113
+ scale: number;
114
+ data: BigInt64Array;
115
+ }
92
116
  export interface DdbSymbolExtendedValue {
93
117
  base_id: number;
94
118
  base: string[];
@@ -101,11 +125,11 @@ export interface DdbArrayVectorBlock {
101
125
  data: Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array;
102
126
  }
103
127
  export interface DdbMatrixValue {
104
- rows: DdbObj<DdbVectorValue>;
105
- cols: DdbObj<DdbVectorValue>;
128
+ rows: DdbVectorObj;
129
+ cols: DdbVectorObj;
106
130
  data: DdbVectorValue;
107
131
  }
108
- export declare type DdbDictValue = [DdbObj<DdbVectorValue>, DdbObj<DdbVectorValue>];
132
+ export declare type DdbDictValue = [DdbVectorObj, DdbVectorObj];
109
133
  export declare enum DdbChartType {
110
134
  area = 0,
111
135
  bar = 1,
@@ -138,19 +162,26 @@ export interface DdbChartValue {
138
162
  extras?: {
139
163
  multi_y_axes: boolean;
140
164
  };
141
- data: DdbObj<DdbMatrixValue>;
165
+ data: DdbMatrixObj;
142
166
  }
143
167
  export declare type DdbScalarValue = null | boolean | number | bigint | string | Uint8Array | // uuid, ipaddr, int128, blob
144
168
  [
145
169
  number,
146
170
  number
147
171
  ] | // complex, point
148
- DdbFunctionDefValue | DdbDurationValue;
172
+ DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value;
149
173
  export declare type DdbVectorValue = Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | // string[]
150
174
  Uint8Array[] | // blob
151
175
  DdbObj[] | // any
152
- DdbSymbolExtendedValue | DdbArrayVectorBlock[];
176
+ DdbSymbolExtendedValue | DdbArrayVectorBlock[] | DdbDecimal32VectorValue | DdbDecimal64VectorValue;
153
177
  export declare type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue;
178
+ export declare type DdbVectorObj = DdbObj<DdbVectorValue>;
179
+ export declare type DdbVectorAnyObj = DdbObj<DdbObj[]>;
180
+ export declare type DdbVectorStringObj = DdbObj<string[]>;
181
+ export declare type DdbTableObj = DdbObj<DdbVectorObj[]>;
182
+ export declare type DdbDictObj = DdbObj<[DdbVectorObj, DdbVectorObj]>;
183
+ export declare type DdbMatrixObj = DdbObj<DdbMatrixValue>;
184
+ export declare type DdbChartObj = DdbObj<DdbChartValue>;
154
185
  export declare const nulls: {
155
186
  readonly int8: -128;
156
187
  readonly int16: -32768;
@@ -162,8 +193,15 @@ export declare const nulls: {
162
193
  readonly bytes16: Uint8Array;
163
194
  };
164
195
  export declare const timezone_offset: number;
196
+ export declare enum StreamingStatusCode {
197
+ ok = 0,
198
+ connection_existed = 1,
199
+ not_leader = 2,
200
+ other = 3,
201
+ error = 4
202
+ }
165
203
  /** 可以表示所有 DolphinDB 数据库中的数据类型 */
166
- export declare class DdbObj<T extends DdbValue = DdbValue> {
204
+ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
167
205
  static dec: TextDecoder;
168
206
  static enc: TextEncoder;
169
207
  /** 维护已解析的 symbol base,比如流数据中后续的 symbol 向量可能只发送一个 base.id, base.size == 0, 依赖之前发送的 symbol base ?
@@ -195,7 +233,7 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
195
233
  /** 第 2 维 */
196
234
  cols?: number;
197
235
  /** 实际数据。不同的 DdbForm, DdbType 使用 DdbValue 中不同的类型来表示实际数据 */
198
- value: T;
236
+ value: TValue;
199
237
  /** 原始二进制数据,仅在 parse_object 为 false 时通过 parse_message 生成的顶层对象有这个属性 */
200
238
  buffer?: Uint8Array;
201
239
  constructor(data: Partial<DdbObj> & {
@@ -207,7 +245,7 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
207
245
  /** parse: rows, cols, items
208
246
  返回的 ddbobj.length 不包括 vector 的 type 和 form
209
247
  */
210
- static parse_vector(buf: Uint8Array, le: boolean, type: DdbType): DdbObj<DdbVectorValue>;
248
+ static parse_vector(buf: Uint8Array, le: boolean, type: DdbType): DdbVectorObj;
211
249
  /** 有可能没有字节对齐,不能直接使用原有 message 的 arraybuffer, 统一复制出来,让原有 arraybuffer 被回收掉比较好 */
212
250
  static parse_vector_items(buf: Uint8Array, le: boolean, type: DdbType, length: number): [
213
251
  number,
@@ -215,7 +253,7 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
215
253
  ];
216
254
  pack(): Uint8Array;
217
255
  static pack_vector_body(value: DdbVectorValue, type: DdbType, length: number): ArrayBufferView[];
218
- toString(colors?: boolean): any;
256
+ toString(options?: InspectOptions): string;
219
257
  inspect_type(): string;
220
258
  /** 自动转换 js string, boolean 为 DdbObj */
221
259
  static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
@@ -241,13 +279,15 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
241
279
  deep?: boolean;
242
280
  }): T;
243
281
  }
244
- interface InspectOptions {
282
+ export interface InspectOptions {
245
283
  colors?: boolean;
284
+ /** decimal places */
285
+ decimals?: number;
246
286
  }
247
287
  /** Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
248
288
  export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
249
- /** Format vector, the index-th item in the collection is a string, a null value returns a 'null' string */
250
- export declare function formati(obj: DdbObj, index: number, options?: InspectOptions): string;
289
+ /** formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
290
+ export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
251
291
  export declare class DdbVoid extends DdbObj<undefined> {
252
292
  constructor();
253
293
  }
@@ -314,7 +354,7 @@ export declare class DdbSetString extends DdbObj<string[]> {
314
354
  */
315
355
  export declare class DdbDict extends DdbObj<DdbDictValue> {
316
356
  constructor(obj: Record<string, boolean | string | DdbObj>);
317
- constructor(keys: DdbObj<DdbVectorValue>, values: DdbObj<DdbVectorValue>);
357
+ constructor(keys: DdbVectorObj, values: DdbVectorObj);
318
358
  }
319
359
  export declare class DdbTable extends DdbObj<DdbObj[]> {
320
360
  constructor(columns: DdbObj[], name?: string);
@@ -370,6 +410,38 @@ export declare function str2nanotimestamp(str: string, format?: string): bigint;
370
410
  export declare function ipaddr2str(buffer: Uint8Array, le?: boolean, ipv6?: boolean): string;
371
411
  export declare function uuid2str(buffer: Uint8Array, le?: boolean): string;
372
412
  export declare function int1282str(buffer: Uint8Array, le?: boolean): string;
413
+ export interface StreamingParams {
414
+ table: string;
415
+ action?: string;
416
+ handler(message: StreamingData): any;
417
+ }
418
+ export interface StreamingData extends StreamingParams {
419
+ /**
420
+ The time the server sent the message (nano seconds since epoch)
421
+ std::chrono::system_clock::now().time_since_epoch() / std::chrono::nanoseconds(1)
422
+ */
423
+ time: bigint;
424
+ /** message id */
425
+ id: bigint;
426
+ colnames: string[];
427
+ /** Subscription topic, which is the name of a subscription.
428
+ It is a string consisting of the alias of the node where the subscription table is located, the stream data table name, and the subscription task name (if actionName is specified), separated by `/`
429
+ */
430
+ topic: string;
431
+ /** The schema of the flow table, the type is table, there is no data in the column vector (rows === 0), only the column name and type */
432
+ schema: DdbTableObj;
433
+ /** Stream data, the type is any vector, each element of which corresponds to a column (without name) of the subscribed table, and the content in the column (DdbObj<DdbVectorValue>) is the new data value */
434
+ data: DdbObj<DdbVectorObj[]>;
435
+ window: {
436
+ /** The establishment of the connection starts offset = 0, and gradually increases as the window moves */
437
+ offset: number;
438
+ /** sum of segment.row in segments */
439
+ rows: number;
440
+ /** An array of data received each time */
441
+ segments: DdbObj<DdbVectorObj[]>[];
442
+ };
443
+ }
444
+ export declare const winsize: 40;
373
445
  export declare class DDB {
374
446
  /** 当前的 session id (http 或 tcp) */
375
447
  sid: string;
@@ -393,6 +465,8 @@ export declare class DDB {
393
465
  password: string;
394
466
  /** python session flag (2048) */
395
467
  python: boolean;
468
+ /** Whether it is a streaming data connection, this field is always null for non-streaming data */
469
+ streaming: StreamingData;
396
470
  print_message_buffer: boolean;
397
471
  print_object_buffer: boolean;
398
472
  print_message: boolean;
@@ -413,6 +487,7 @@ export declare class DDB {
413
487
  - username?: DolphinDB username, default `'admin'`
414
488
  - password?: DolphinDB password, default `'123456'`
415
489
  - python?: set python session flag, default `false`
490
+ - streaming?: When this option is set, the WebSocket connection is only used for streaming data
416
491
 
417
492
  @example
418
493
  let ddb = new DDB('ws://127.0.0.1:8848')
@@ -430,6 +505,7 @@ export declare class DDB {
430
505
  username?: string;
431
506
  password?: string;
432
507
  python?: boolean;
508
+ streaming?: StreamingParams;
433
509
  });
434
510
  private on_message;
435
511
  /** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
@@ -439,13 +515,15 @@ export declare class DDB {
439
515
  - username?: DolphinDB username, default `'admin'`
440
516
  - password?: DolphinDB password, default `'123456'`
441
517
  - python?: set python session flag, default `false`
518
+ - streaming?: When this option is set, the WebSocket connection is only used for streaming data
442
519
  */
443
- connect(options?: {
520
+ connect({ url, autologin, username, password, python, streaming }?: {
444
521
  url?: string;
445
522
  autologin?: boolean;
446
523
  username?: string;
447
524
  password?: string;
448
525
  python?: boolean;
526
+ streaming?: StreamingParams;
449
527
  }): Promise<void>;
450
528
  get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
451
529
  urgent?: boolean;
@@ -535,8 +613,12 @@ export declare class DDB {
535
613
  listener?: DdbMessageListener;
536
614
  parse_object?: boolean;
537
615
  }): Promise<DdbObj<DdbValue>>;
616
+ /** Cancel all console jobs corresponding to the current session id */
617
+ cancel(): Promise<void>;
538
618
  /** 解析服务端响应报文,返回去掉 header 的 data buf */
539
619
  parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
620
+ /** Internal stream subscription method */
621
+ subscribe(): Promise<DdbTableObj>;
540
622
  }
541
623
  export interface DdbMessageListener {
542
624
  (message: DdbMessage, _this: DDB): any;
@@ -555,4 +637,3 @@ export interface DdbErrorMessage {
555
637
  }
556
638
  export declare type DdbMessage = DdbPrintMessage | DdbObjectMessage | DdbErrorMessage;
557
639
  export declare let ddb: DDB;
558
- export {};