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 +98 -17
- package/browser.js +333 -154
- package/browser.js.map +1 -1
- package/docs.en.json +2096 -646
- package/docs.zh.json +1290 -729
- package/index.d.ts +103 -18
- package/index.js +350 -166
- package/index.js.map +1 -1
- package/language.d.ts +2 -2
- package/language.js +5 -3
- package/language.js.map +1 -1
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import type { InspectOptions } from 'util';
|
|
2
|
+
import type { InspectOptions as UtilInspectOptions } from 'util';
|
|
3
3
|
import { inspect } from 'xshell/utils.js';
|
|
4
4
|
export declare enum DdbForm {
|
|
5
5
|
scalar = 0,
|
|
@@ -55,7 +55,11 @@ export declare enum DdbType {
|
|
|
55
55
|
complex = 34,
|
|
56
56
|
point = 35,
|
|
57
57
|
duration = 36,
|
|
58
|
-
|
|
58
|
+
decimal32 = 37,
|
|
59
|
+
decimal64 = 38,
|
|
60
|
+
decimal128 = 39,
|
|
61
|
+
object = 40,
|
|
62
|
+
pynone = 41,
|
|
59
63
|
symbol_extended = 145
|
|
60
64
|
}
|
|
61
65
|
export declare enum DdbFunctionType {
|
|
@@ -91,6 +95,26 @@ export interface DdbDurationValue {
|
|
|
91
95
|
/** int32 */
|
|
92
96
|
data: number;
|
|
93
97
|
}
|
|
98
|
+
export interface DdbDecimal32Value {
|
|
99
|
+
/** int32, data needs to be divided by 10^scale to get the original value */
|
|
100
|
+
scale: number;
|
|
101
|
+
/** int32, ddb null is js null */
|
|
102
|
+
data: number | null;
|
|
103
|
+
}
|
|
104
|
+
export interface DdbDecimal64Value {
|
|
105
|
+
/** int32, data needs to be divided by 10^scale to get the original value */
|
|
106
|
+
scale: number;
|
|
107
|
+
/** int32, ddb null is js null */
|
|
108
|
+
data: bigint | null;
|
|
109
|
+
}
|
|
110
|
+
export interface DdbDecimal32VectorValue {
|
|
111
|
+
scale: number;
|
|
112
|
+
data: Int32Array;
|
|
113
|
+
}
|
|
114
|
+
export interface DdbDecimal64VectorValue {
|
|
115
|
+
scale: number;
|
|
116
|
+
data: BigInt64Array;
|
|
117
|
+
}
|
|
94
118
|
export interface DdbSymbolExtendedValue {
|
|
95
119
|
base_id: number;
|
|
96
120
|
base: string[];
|
|
@@ -103,11 +127,11 @@ export interface DdbArrayVectorBlock {
|
|
|
103
127
|
data: Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array;
|
|
104
128
|
}
|
|
105
129
|
export interface DdbMatrixValue {
|
|
106
|
-
rows:
|
|
107
|
-
cols:
|
|
130
|
+
rows: DdbVectorObj;
|
|
131
|
+
cols: DdbVectorObj;
|
|
108
132
|
data: DdbVectorValue;
|
|
109
133
|
}
|
|
110
|
-
export declare type DdbDictValue = [
|
|
134
|
+
export declare type DdbDictValue = [DdbVectorObj, DdbVectorObj];
|
|
111
135
|
export declare enum DdbChartType {
|
|
112
136
|
area = 0,
|
|
113
137
|
bar = 1,
|
|
@@ -140,19 +164,26 @@ export interface DdbChartValue {
|
|
|
140
164
|
extras?: {
|
|
141
165
|
multi_y_axes: boolean;
|
|
142
166
|
};
|
|
143
|
-
data:
|
|
167
|
+
data: DdbMatrixObj;
|
|
144
168
|
}
|
|
145
169
|
export declare type DdbScalarValue = null | boolean | number | bigint | string | Uint8Array | // uuid, ipaddr, int128, blob
|
|
146
170
|
[
|
|
147
171
|
number,
|
|
148
172
|
number
|
|
149
173
|
] | // complex, point
|
|
150
|
-
DdbFunctionDefValue | DdbDurationValue;
|
|
174
|
+
DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value;
|
|
151
175
|
export declare type DdbVectorValue = Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | // string[]
|
|
152
176
|
Uint8Array[] | // blob
|
|
153
177
|
DdbObj[] | // any
|
|
154
|
-
DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
178
|
+
DdbSymbolExtendedValue | DdbArrayVectorBlock[] | DdbDecimal32VectorValue | DdbDecimal64VectorValue;
|
|
155
179
|
export declare type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue;
|
|
180
|
+
export declare type DdbVectorObj = DdbObj<DdbVectorValue>;
|
|
181
|
+
export declare type DdbVectorAnyObj = DdbObj<DdbObj[]>;
|
|
182
|
+
export declare type DdbVectorStringObj = DdbObj<string[]>;
|
|
183
|
+
export declare type DdbTableObj = DdbObj<DdbVectorObj[]>;
|
|
184
|
+
export declare type DdbDictObj = DdbObj<[DdbVectorObj, DdbVectorObj]>;
|
|
185
|
+
export declare type DdbMatrixObj = DdbObj<DdbMatrixValue>;
|
|
186
|
+
export declare type DdbChartObj = DdbObj<DdbChartValue>;
|
|
156
187
|
export declare const nulls: {
|
|
157
188
|
readonly int8: -128;
|
|
158
189
|
readonly int16: -32768;
|
|
@@ -164,8 +195,15 @@ export declare const nulls: {
|
|
|
164
195
|
readonly bytes16: Uint8Array;
|
|
165
196
|
};
|
|
166
197
|
export declare const timezone_offset: number;
|
|
167
|
-
|
|
168
|
-
|
|
198
|
+
export declare enum StreamingStatusCode {
|
|
199
|
+
ok = 0,
|
|
200
|
+
connection_existed = 1,
|
|
201
|
+
not_leader = 2,
|
|
202
|
+
other = 3,
|
|
203
|
+
error = 4
|
|
204
|
+
}
|
|
205
|
+
/** Can represent data types in all DolphinDB databases */
|
|
206
|
+
export declare class DdbObj<TValue extends DdbValue = DdbValue> {
|
|
169
207
|
static dec: TextDecoder;
|
|
170
208
|
static enc: TextEncoder;
|
|
171
209
|
/** 维护已解析的 symbol base,比如流数据中后续的 symbol 向量可能只发送一个 base.id, base.size == 0, 依赖之前发送的 symbol base ?
|
|
@@ -196,8 +234,8 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
196
234
|
rows?: number;
|
|
197
235
|
/** 第 2 维 */
|
|
198
236
|
cols?: number;
|
|
199
|
-
/**
|
|
200
|
-
value:
|
|
237
|
+
/** The actual data. Different DdbForm, DdbType use different types in DdbValue to represent actual data */
|
|
238
|
+
value: TValue;
|
|
201
239
|
/** 原始二进制数据,仅在 parse_object 为 false 时通过 parse_message 生成的顶层对象有这个属性 */
|
|
202
240
|
buffer?: Uint8Array;
|
|
203
241
|
constructor(data: Partial<DdbObj> & {
|
|
@@ -209,7 +247,7 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
209
247
|
/** parse: rows, cols, items
|
|
210
248
|
返回的 ddbobj.length 不包括 vector 的 type 和 form
|
|
211
249
|
*/
|
|
212
|
-
static parse_vector(buf: Uint8Array, le: boolean, type: DdbType):
|
|
250
|
+
static parse_vector(buf: Uint8Array, le: boolean, type: DdbType): DdbVectorObj;
|
|
213
251
|
/** 有可能没有字节对齐,不能直接使用原有 message 的 arraybuffer, 统一复制出来,让原有 arraybuffer 被回收掉比较好 */
|
|
214
252
|
static parse_vector_items(buf: Uint8Array, le: boolean, type: DdbType, length: number): [
|
|
215
253
|
number,
|
|
@@ -238,10 +276,15 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
238
276
|
deep?: boolean;
|
|
239
277
|
}): T;
|
|
240
278
|
}
|
|
279
|
+
export interface InspectOptions extends UtilInspectOptions {
|
|
280
|
+
colors?: boolean;
|
|
281
|
+
/** decimal places */
|
|
282
|
+
decimals?: number;
|
|
283
|
+
}
|
|
241
284
|
/** Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
242
|
-
export declare function format(type: DdbType, value: DdbValue, le: boolean, options
|
|
285
|
+
export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
|
|
243
286
|
/** formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
|
|
244
|
-
export declare function formati(obj:
|
|
287
|
+
export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
|
|
245
288
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
246
289
|
constructor();
|
|
247
290
|
}
|
|
@@ -308,7 +351,7 @@ export declare class DdbSetString extends DdbObj<string[]> {
|
|
|
308
351
|
*/
|
|
309
352
|
export declare class DdbDict extends DdbObj<DdbDictValue> {
|
|
310
353
|
constructor(obj: Record<string, boolean | string | DdbObj>);
|
|
311
|
-
constructor(keys:
|
|
354
|
+
constructor(keys: DdbVectorObj, values: DdbVectorObj);
|
|
312
355
|
}
|
|
313
356
|
export declare class DdbTable extends DdbObj<DdbObj[]> {
|
|
314
357
|
constructor(columns: DdbObj[], name?: string);
|
|
@@ -364,6 +407,38 @@ export declare function str2nanotimestamp(str: string, format?: string): bigint;
|
|
|
364
407
|
export declare function ipaddr2str(buffer: Uint8Array, le?: boolean, ipv6?: boolean): string;
|
|
365
408
|
export declare function uuid2str(buffer: Uint8Array, le?: boolean): string;
|
|
366
409
|
export declare function int1282str(buffer: Uint8Array, le?: boolean): string;
|
|
410
|
+
export interface StreamingParams {
|
|
411
|
+
table: string;
|
|
412
|
+
action?: string;
|
|
413
|
+
handler(message: StreamingData): any;
|
|
414
|
+
}
|
|
415
|
+
export interface StreamingData extends StreamingParams {
|
|
416
|
+
/**
|
|
417
|
+
The time the server sent the message (nano seconds since epoch)
|
|
418
|
+
std::chrono::system_clock::now().time_since_epoch() / std::chrono::nanoseconds(1)
|
|
419
|
+
*/
|
|
420
|
+
time: bigint;
|
|
421
|
+
/** message id */
|
|
422
|
+
id: bigint;
|
|
423
|
+
colnames: string[];
|
|
424
|
+
/** Subscription topic, which is the name of a subscription.
|
|
425
|
+
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 `/`
|
|
426
|
+
*/
|
|
427
|
+
topic: string;
|
|
428
|
+
/** 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 */
|
|
429
|
+
schema: DdbTableObj;
|
|
430
|
+
/** 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 */
|
|
431
|
+
data: DdbObj<DdbVectorObj[]>;
|
|
432
|
+
window: {
|
|
433
|
+
/** The establishment of the connection starts offset = 0, and gradually increases as the window moves */
|
|
434
|
+
offset: number;
|
|
435
|
+
/** sum of segment.row in segments */
|
|
436
|
+
rows: number;
|
|
437
|
+
/** An array of data received each time */
|
|
438
|
+
segments: DdbObj<DdbVectorObj[]>[];
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
export declare const winsize: 40;
|
|
367
442
|
export declare class DDB {
|
|
368
443
|
/** 当前的 session id (http 或 tcp) */
|
|
369
444
|
sid: string;
|
|
@@ -387,6 +462,8 @@ export declare class DDB {
|
|
|
387
462
|
password: string;
|
|
388
463
|
/** python session flag (2048) */
|
|
389
464
|
python: boolean;
|
|
465
|
+
/** Whether it is a streaming data connection, this field is always null for non-streaming data */
|
|
466
|
+
streaming: StreamingData;
|
|
390
467
|
print_message_buffer: boolean;
|
|
391
468
|
print_object_buffer: boolean;
|
|
392
469
|
print_message: boolean;
|
|
@@ -407,11 +484,12 @@ export declare class DDB {
|
|
|
407
484
|
- username?: DolphinDB username, default `'admin'`
|
|
408
485
|
- password?: DolphinDB password, default `'123456'`
|
|
409
486
|
- python?: set python session flag, default `false`
|
|
487
|
+
- streaming?: When this option is set, the WebSocket connection is only used for streaming data
|
|
410
488
|
|
|
411
489
|
@example
|
|
412
490
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
413
491
|
|
|
414
|
-
//
|
|
492
|
+
// Encrypt with HTTPS
|
|
415
493
|
let ddbsecure = new DDB('wss://dolphindb.com', {
|
|
416
494
|
autologin: true,
|
|
417
495
|
username: 'admin',
|
|
@@ -424,6 +502,7 @@ export declare class DDB {
|
|
|
424
502
|
username?: string;
|
|
425
503
|
password?: string;
|
|
426
504
|
python?: boolean;
|
|
505
|
+
streaming?: StreamingParams;
|
|
427
506
|
});
|
|
428
507
|
private on_message;
|
|
429
508
|
/** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
|
|
@@ -433,13 +512,15 @@ export declare class DDB {
|
|
|
433
512
|
- username?: DolphinDB username, default `'admin'`
|
|
434
513
|
- password?: DolphinDB password, default `'123456'`
|
|
435
514
|
- python?: set python session flag, default `false`
|
|
515
|
+
- streaming?: When this option is set, the WebSocket connection is only used for streaming data
|
|
436
516
|
*/
|
|
437
|
-
connect(
|
|
517
|
+
connect({ url, autologin, username, password, python, streaming }?: {
|
|
438
518
|
url?: string;
|
|
439
519
|
autologin?: boolean;
|
|
440
520
|
username?: string;
|
|
441
521
|
password?: string;
|
|
442
522
|
python?: boolean;
|
|
523
|
+
streaming?: StreamingParams;
|
|
443
524
|
}): Promise<void>;
|
|
444
525
|
get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
|
|
445
526
|
urgent?: boolean;
|
|
@@ -529,8 +610,12 @@ export declare class DDB {
|
|
|
529
610
|
listener?: DdbMessageListener;
|
|
530
611
|
parse_object?: boolean;
|
|
531
612
|
}): Promise<DdbObj<DdbValue>>;
|
|
613
|
+
/** Cancel all console jobs corresponding to the current session id */
|
|
614
|
+
cancel(): Promise<void>;
|
|
532
615
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
533
616
|
parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
|
|
617
|
+
/** Internal stream subscription method */
|
|
618
|
+
subscribe(): Promise<DdbTableObj>;
|
|
534
619
|
}
|
|
535
620
|
export interface DdbMessageListener {
|
|
536
621
|
(message: DdbMessage, _this: DDB): any;
|