dolphindb 2.0.603 → 2.0.801
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 +109 -32
- package/browser.js +502 -290
- package/browser.js.map +1 -1
- package/docs.en.json +13062 -2118
- package/docs.zh.json +5224 -1600
- package/index.d.ts +110 -33
- package/index.js +390 -218
- 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,
|
|
@@ -217,7 +255,7 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
217
255
|
];
|
|
218
256
|
pack(): Uint8Array;
|
|
219
257
|
static pack_vector_body(value: DdbVectorValue, type: DdbType, length: number): ArrayBufferView[];
|
|
220
|
-
[inspect.custom](depth: number,
|
|
258
|
+
[inspect.custom](depth: number, _options: InspectOptions, _inspect: any): string;
|
|
221
259
|
inspect_type(): string;
|
|
222
260
|
/** 自动转换 js string, boolean 为 DdbObj */
|
|
223
261
|
static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
|
|
@@ -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,42 @@ 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;
|
|
442
|
+
export declare class ConnectionError extends Error {
|
|
443
|
+
ddb: DDB;
|
|
444
|
+
constructor(ddb: DDB);
|
|
445
|
+
}
|
|
367
446
|
export declare class DDB {
|
|
368
447
|
/** 当前的 session id (http 或 tcp) */
|
|
369
448
|
sid: string;
|
|
@@ -387,6 +466,8 @@ export declare class DDB {
|
|
|
387
466
|
password: string;
|
|
388
467
|
/** python session flag (2048) */
|
|
389
468
|
python: boolean;
|
|
469
|
+
/** Whether it is a streaming data connection, this field is always null for non-streaming data */
|
|
470
|
+
streaming: StreamingData;
|
|
390
471
|
print_message_buffer: boolean;
|
|
391
472
|
print_object_buffer: boolean;
|
|
392
473
|
print_message: boolean;
|
|
@@ -407,11 +488,12 @@ export declare class DDB {
|
|
|
407
488
|
- username?: DolphinDB username, default `'admin'`
|
|
408
489
|
- password?: DolphinDB password, default `'123456'`
|
|
409
490
|
- python?: set python session flag, default `false`
|
|
491
|
+
- streaming?: When this option is set, the WebSocket connection is only used for streaming data
|
|
410
492
|
|
|
411
493
|
@example
|
|
412
494
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
413
495
|
|
|
414
|
-
//
|
|
496
|
+
// Encrypt with HTTPS
|
|
415
497
|
let ddbsecure = new DDB('wss://dolphindb.com', {
|
|
416
498
|
autologin: true,
|
|
417
499
|
username: 'admin',
|
|
@@ -424,23 +506,13 @@ export declare class DDB {
|
|
|
424
506
|
username?: string;
|
|
425
507
|
password?: string;
|
|
426
508
|
python?: boolean;
|
|
509
|
+
streaming?: StreamingParams;
|
|
427
510
|
});
|
|
428
511
|
private on_message;
|
|
429
|
-
/** Establish
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
- username?: DolphinDB username, default `'admin'`
|
|
434
|
-
- password?: DolphinDB password, default `'123456'`
|
|
435
|
-
- python?: set python session flag, default `false`
|
|
436
|
-
*/
|
|
437
|
-
connect(options?: {
|
|
438
|
-
url?: string;
|
|
439
|
-
autologin?: boolean;
|
|
440
|
-
username?: string;
|
|
441
|
-
password?: string;
|
|
442
|
-
python?: boolean;
|
|
443
|
-
}): Promise<void>;
|
|
512
|
+
/** Establish a actual websocket connection to the DolphindB corresponding to the URL
|
|
513
|
+
It is a power, and after calling, it will ensure that it has been connected to the database (ensure that websocket.ReadyState is open), otherwise an error will be reported
|
|
514
|
+
this.autologin automatically log in when it is true */
|
|
515
|
+
connect(): Promise<void>;
|
|
444
516
|
get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
|
|
445
517
|
urgent?: boolean;
|
|
446
518
|
/** API 提交的任务, secondary 必须为 false */
|
|
@@ -466,6 +538,7 @@ export declare class DDB {
|
|
|
466
538
|
}): string;
|
|
467
539
|
disconnect(): void;
|
|
468
540
|
/** rpc through websocket (function/script/variable command)
|
|
541
|
+
When the DDB is not connected, the call will be automatically connected. When the connection is disconnected, the call will throw the Connectionerror
|
|
469
542
|
- type: API 类型: 'script' | 'function' | 'variable'
|
|
470
543
|
- options:
|
|
471
544
|
- urgent?: 决定 `行为标识` 那一行字符串的取值(只适用于 script 和 function)
|
|
@@ -529,8 +602,12 @@ export declare class DDB {
|
|
|
529
602
|
listener?: DdbMessageListener;
|
|
530
603
|
parse_object?: boolean;
|
|
531
604
|
}): Promise<DdbObj<DdbValue>>;
|
|
605
|
+
/** Cancel all console jobs corresponding to the current session id */
|
|
606
|
+
cancel(): Promise<void>;
|
|
532
607
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
533
608
|
parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
|
|
609
|
+
/** Internal stream subscription method */
|
|
610
|
+
subscribe(): Promise<DdbTableObj>;
|
|
534
611
|
}
|
|
535
612
|
export interface DdbMessageListener {
|
|
536
613
|
(message: DdbMessage, _this: DDB): any;
|