dolphindb 2.0.602 → 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/README.md +1 -0
- package/browser.d.ts +109 -17
- package/browser.js +389 -183
- package/browser.js.map +1 -1
- package/docs.en.json +2046 -552
- package/docs.zh.json +1311 -737
- package/index.d.ts +114 -18
- package/index.js +406 -196
- 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,
|
|
@@ -123,6 +147,15 @@ export interface DdbChartValue {
|
|
|
123
147
|
/** original: chartType */
|
|
124
148
|
type: DdbChartType;
|
|
125
149
|
stacking: boolean;
|
|
150
|
+
/** 直方图 (Histogram), plotHist 函数返回的 chart 可能具有该属性
|
|
151
|
+
原属性 binStart
|
|
152
|
+
数值类型的 DdbObj 都有可能?
|
|
153
|
+
*/
|
|
154
|
+
bin_start?: DdbObj;
|
|
155
|
+
/** 原属性 binEnd */
|
|
156
|
+
bin_end?: DdbObj;
|
|
157
|
+
/** 原属性 binCount */
|
|
158
|
+
bin_count?: DdbObj;
|
|
126
159
|
titles: {
|
|
127
160
|
chart: string;
|
|
128
161
|
x_axis: string;
|
|
@@ -131,19 +164,26 @@ export interface DdbChartValue {
|
|
|
131
164
|
extras?: {
|
|
132
165
|
multi_y_axes: boolean;
|
|
133
166
|
};
|
|
134
|
-
data:
|
|
167
|
+
data: DdbMatrixObj;
|
|
135
168
|
}
|
|
136
169
|
export declare type DdbScalarValue = null | boolean | number | bigint | string | Uint8Array | // uuid, ipaddr, int128, blob
|
|
137
170
|
[
|
|
138
171
|
number,
|
|
139
172
|
number
|
|
140
173
|
] | // complex, point
|
|
141
|
-
DdbFunctionDefValue | DdbDurationValue;
|
|
174
|
+
DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value;
|
|
142
175
|
export declare type DdbVectorValue = Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | // string[]
|
|
143
176
|
Uint8Array[] | // blob
|
|
144
177
|
DdbObj[] | // any
|
|
145
|
-
DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
178
|
+
DdbSymbolExtendedValue | DdbArrayVectorBlock[] | DdbDecimal32VectorValue | DdbDecimal64VectorValue;
|
|
146
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>;
|
|
147
187
|
export declare const nulls: {
|
|
148
188
|
readonly int8: -128;
|
|
149
189
|
readonly int16: -32768;
|
|
@@ -155,8 +195,15 @@ export declare const nulls: {
|
|
|
155
195
|
readonly bytes16: Uint8Array;
|
|
156
196
|
};
|
|
157
197
|
export declare const timezone_offset: number;
|
|
158
|
-
|
|
159
|
-
|
|
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> {
|
|
160
207
|
static dec: TextDecoder;
|
|
161
208
|
static enc: TextEncoder;
|
|
162
209
|
/** 维护已解析的 symbol base,比如流数据中后续的 symbol 向量可能只发送一个 base.id, base.size == 0, 依赖之前发送的 symbol base ?
|
|
@@ -187,8 +234,8 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
187
234
|
rows?: number;
|
|
188
235
|
/** 第 2 维 */
|
|
189
236
|
cols?: number;
|
|
190
|
-
/**
|
|
191
|
-
value:
|
|
237
|
+
/** The actual data. Different DdbForm, DdbType use different types in DdbValue to represent actual data */
|
|
238
|
+
value: TValue;
|
|
192
239
|
/** 原始二进制数据,仅在 parse_object 为 false 时通过 parse_message 生成的顶层对象有这个属性 */
|
|
193
240
|
buffer?: Uint8Array;
|
|
194
241
|
constructor(data: Partial<DdbObj> & {
|
|
@@ -200,7 +247,7 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
200
247
|
/** parse: rows, cols, items
|
|
201
248
|
返回的 ddbobj.length 不包括 vector 的 type 和 form
|
|
202
249
|
*/
|
|
203
|
-
static parse_vector(buf: Uint8Array, le: boolean, type: DdbType):
|
|
250
|
+
static parse_vector(buf: Uint8Array, le: boolean, type: DdbType): DdbVectorObj;
|
|
204
251
|
/** 有可能没有字节对齐,不能直接使用原有 message 的 arraybuffer, 统一复制出来,让原有 arraybuffer 被回收掉比较好 */
|
|
205
252
|
static parse_vector_items(buf: Uint8Array, le: boolean, type: DdbType, length: number): [
|
|
206
253
|
number,
|
|
@@ -229,10 +276,15 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
229
276
|
deep?: boolean;
|
|
230
277
|
}): T;
|
|
231
278
|
}
|
|
279
|
+
export interface InspectOptions extends UtilInspectOptions {
|
|
280
|
+
colors?: boolean;
|
|
281
|
+
/** decimal places */
|
|
282
|
+
decimals?: number;
|
|
283
|
+
}
|
|
232
284
|
/** Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
233
|
-
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;
|
|
234
286
|
/** formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
|
|
235
|
-
export declare function formati(obj:
|
|
287
|
+
export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
|
|
236
288
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
237
289
|
constructor();
|
|
238
290
|
}
|
|
@@ -299,7 +351,7 @@ export declare class DdbSetString extends DdbObj<string[]> {
|
|
|
299
351
|
*/
|
|
300
352
|
export declare class DdbDict extends DdbObj<DdbDictValue> {
|
|
301
353
|
constructor(obj: Record<string, boolean | string | DdbObj>);
|
|
302
|
-
constructor(keys:
|
|
354
|
+
constructor(keys: DdbVectorObj, values: DdbVectorObj);
|
|
303
355
|
}
|
|
304
356
|
export declare class DdbTable extends DdbObj<DdbObj[]> {
|
|
305
357
|
constructor(columns: DdbObj[], name?: string);
|
|
@@ -355,6 +407,38 @@ export declare function str2nanotimestamp(str: string, format?: string): bigint;
|
|
|
355
407
|
export declare function ipaddr2str(buffer: Uint8Array, le?: boolean, ipv6?: boolean): string;
|
|
356
408
|
export declare function uuid2str(buffer: Uint8Array, le?: boolean): string;
|
|
357
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;
|
|
358
442
|
export declare class DDB {
|
|
359
443
|
/** 当前的 session id (http 或 tcp) */
|
|
360
444
|
sid: string;
|
|
@@ -378,13 +462,17 @@ export declare class DDB {
|
|
|
378
462
|
password: string;
|
|
379
463
|
/** python session flag (2048) */
|
|
380
464
|
python: boolean;
|
|
465
|
+
/** Whether it is a streaming data connection, this field is always null for non-streaming data */
|
|
466
|
+
streaming: StreamingData;
|
|
381
467
|
print_message_buffer: boolean;
|
|
382
468
|
print_object_buffer: boolean;
|
|
383
469
|
print_message: boolean;
|
|
384
470
|
parse_object: boolean;
|
|
471
|
+
pnode_run_defined: boolean;
|
|
385
472
|
/** DdbMessage listeners */
|
|
386
473
|
listeners: DdbMessageListener[];
|
|
387
474
|
pconnect: Promise<void>;
|
|
475
|
+
ppnoderun: Promise<void>;
|
|
388
476
|
presult: Promise<any>;
|
|
389
477
|
get connected(): boolean;
|
|
390
478
|
/**
|
|
@@ -396,11 +484,12 @@ export declare class DDB {
|
|
|
396
484
|
- username?: DolphinDB username, default `'admin'`
|
|
397
485
|
- password?: DolphinDB password, default `'123456'`
|
|
398
486
|
- python?: set python session flag, default `false`
|
|
487
|
+
- streaming?: When this option is set, the WebSocket connection is only used for streaming data
|
|
399
488
|
|
|
400
489
|
@example
|
|
401
490
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
402
491
|
|
|
403
|
-
//
|
|
492
|
+
// Encrypt with HTTPS
|
|
404
493
|
let ddbsecure = new DDB('wss://dolphindb.com', {
|
|
405
494
|
autologin: true,
|
|
406
495
|
username: 'admin',
|
|
@@ -413,6 +502,7 @@ export declare class DDB {
|
|
|
413
502
|
username?: string;
|
|
414
503
|
password?: string;
|
|
415
504
|
python?: boolean;
|
|
505
|
+
streaming?: StreamingParams;
|
|
416
506
|
});
|
|
417
507
|
private on_message;
|
|
418
508
|
/** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
|
|
@@ -422,13 +512,15 @@ export declare class DDB {
|
|
|
422
512
|
- username?: DolphinDB username, default `'admin'`
|
|
423
513
|
- password?: DolphinDB password, default `'123456'`
|
|
424
514
|
- python?: set python session flag, default `false`
|
|
515
|
+
- streaming?: When this option is set, the WebSocket connection is only used for streaming data
|
|
425
516
|
*/
|
|
426
|
-
connect(
|
|
517
|
+
connect({ url, autologin, username, password, python, streaming }?: {
|
|
427
518
|
url?: string;
|
|
428
519
|
autologin?: boolean;
|
|
429
520
|
username?: string;
|
|
430
521
|
password?: string;
|
|
431
522
|
python?: boolean;
|
|
523
|
+
streaming?: StreamingParams;
|
|
432
524
|
}): Promise<void>;
|
|
433
525
|
get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
|
|
434
526
|
urgent?: boolean;
|
|
@@ -518,8 +610,12 @@ export declare class DDB {
|
|
|
518
610
|
listener?: DdbMessageListener;
|
|
519
611
|
parse_object?: boolean;
|
|
520
612
|
}): Promise<DdbObj<DdbValue>>;
|
|
613
|
+
/** Cancel all console jobs corresponding to the current session id */
|
|
614
|
+
cancel(): Promise<void>;
|
|
521
615
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
522
616
|
parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
|
|
617
|
+
/** Internal stream subscription method */
|
|
618
|
+
subscribe(): Promise<DdbTableObj>;
|
|
523
619
|
}
|
|
524
620
|
export interface DdbMessageListener {
|
|
525
621
|
(message: DdbMessage, _this: DDB): any;
|