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/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
|
-
|
|
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:
|
|
105
|
-
cols:
|
|
128
|
+
rows: DdbVectorObj;
|
|
129
|
+
cols: DdbVectorObj;
|
|
106
130
|
data: DdbVectorValue;
|
|
107
131
|
}
|
|
108
|
-
export declare type DdbDictValue = [
|
|
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:
|
|
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<
|
|
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:
|
|
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):
|
|
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(
|
|
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;
|
|
@@ -224,7 +262,7 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
224
262
|
to_cols(): {
|
|
225
263
|
title: string;
|
|
226
264
|
dataIndex: string;
|
|
227
|
-
render
|
|
265
|
+
render: (value: any) => string;
|
|
228
266
|
}[];
|
|
229
267
|
to_rows<T extends Record<string, any> = Record<string, any>>(): T[];
|
|
230
268
|
/** Automatically convert dict<string, any> to js object (Record<string, any>)
|
|
@@ -241,13 +279,19 @@ 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;
|
|
286
|
+
/** `false` 决定 null 值如何返回. nullstr ? 'null' : '' */
|
|
287
|
+
nullstr?: boolean;
|
|
288
|
+
/** `false` 决定 string, symbol, char 类型是否加引号 */
|
|
289
|
+
quote?: boolean;
|
|
246
290
|
}
|
|
247
291
|
/** Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
248
292
|
export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
|
|
249
|
-
/**
|
|
250
|
-
export declare function formati(obj:
|
|
293
|
+
/** formatted vector, the index-th item in the collection is a string */
|
|
294
|
+
export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
|
|
251
295
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
252
296
|
constructor();
|
|
253
297
|
}
|
|
@@ -314,7 +358,7 @@ export declare class DdbSetString extends DdbObj<string[]> {
|
|
|
314
358
|
*/
|
|
315
359
|
export declare class DdbDict extends DdbObj<DdbDictValue> {
|
|
316
360
|
constructor(obj: Record<string, boolean | string | DdbObj>);
|
|
317
|
-
constructor(keys:
|
|
361
|
+
constructor(keys: DdbVectorObj, values: DdbVectorObj);
|
|
318
362
|
}
|
|
319
363
|
export declare class DdbTable extends DdbObj<DdbObj[]> {
|
|
320
364
|
constructor(columns: DdbObj[], name?: string);
|
|
@@ -370,6 +414,42 @@ export declare function str2nanotimestamp(str: string, format?: string): bigint;
|
|
|
370
414
|
export declare function ipaddr2str(buffer: Uint8Array, le?: boolean, ipv6?: boolean): string;
|
|
371
415
|
export declare function uuid2str(buffer: Uint8Array, le?: boolean): string;
|
|
372
416
|
export declare function int1282str(buffer: Uint8Array, le?: boolean): string;
|
|
417
|
+
export interface StreamingParams {
|
|
418
|
+
table: string;
|
|
419
|
+
action?: string;
|
|
420
|
+
handler(message: StreamingData): any;
|
|
421
|
+
}
|
|
422
|
+
export interface StreamingData extends StreamingParams {
|
|
423
|
+
/**
|
|
424
|
+
The time the server sent the message (nano seconds since epoch)
|
|
425
|
+
std::chrono::system_clock::now().time_since_epoch() / std::chrono::nanoseconds(1)
|
|
426
|
+
*/
|
|
427
|
+
time: bigint;
|
|
428
|
+
/** message id */
|
|
429
|
+
id: bigint;
|
|
430
|
+
colnames: string[];
|
|
431
|
+
/** Subscription topic, which is the name of a subscription.
|
|
432
|
+
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 `/`
|
|
433
|
+
*/
|
|
434
|
+
topic: string;
|
|
435
|
+
/** 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 */
|
|
436
|
+
schema: DdbTableObj;
|
|
437
|
+
/** 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 */
|
|
438
|
+
data: DdbObj<DdbVectorObj[]>;
|
|
439
|
+
window: {
|
|
440
|
+
/** The establishment of the connection starts offset = 0, and gradually increases as the window moves */
|
|
441
|
+
offset: number;
|
|
442
|
+
/** sum of segment.row in segments */
|
|
443
|
+
rows: number;
|
|
444
|
+
/** An array of data received each time */
|
|
445
|
+
segments: DdbObj<DdbVectorObj[]>[];
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
export declare const winsize: 40;
|
|
449
|
+
export declare class ConnectionError extends Error {
|
|
450
|
+
ddb: DDB;
|
|
451
|
+
constructor(ddb: DDB);
|
|
452
|
+
}
|
|
373
453
|
export declare class DDB {
|
|
374
454
|
/** 当前的 session id (http 或 tcp) */
|
|
375
455
|
sid: string;
|
|
@@ -393,6 +473,8 @@ export declare class DDB {
|
|
|
393
473
|
password: string;
|
|
394
474
|
/** python session flag (2048) */
|
|
395
475
|
python: boolean;
|
|
476
|
+
/** Whether it is a streaming data connection, this field is always null for non-streaming data */
|
|
477
|
+
streaming: StreamingData;
|
|
396
478
|
print_message_buffer: boolean;
|
|
397
479
|
print_object_buffer: boolean;
|
|
398
480
|
print_message: boolean;
|
|
@@ -413,6 +495,7 @@ export declare class DDB {
|
|
|
413
495
|
- username?: DolphinDB username, default `'admin'`
|
|
414
496
|
- password?: DolphinDB password, default `'123456'`
|
|
415
497
|
- python?: set python session flag, default `false`
|
|
498
|
+
- streaming?: When this option is set, the WebSocket connection is only used for streaming data
|
|
416
499
|
|
|
417
500
|
@example
|
|
418
501
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
@@ -430,23 +513,13 @@ export declare class DDB {
|
|
|
430
513
|
username?: string;
|
|
431
514
|
password?: string;
|
|
432
515
|
python?: boolean;
|
|
516
|
+
streaming?: StreamingParams;
|
|
433
517
|
});
|
|
434
518
|
private on_message;
|
|
435
|
-
/** Establish
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
- username?: DolphinDB username, default `'admin'`
|
|
440
|
-
- password?: DolphinDB password, default `'123456'`
|
|
441
|
-
- python?: set python session flag, default `false`
|
|
442
|
-
*/
|
|
443
|
-
connect(options?: {
|
|
444
|
-
url?: string;
|
|
445
|
-
autologin?: boolean;
|
|
446
|
-
username?: string;
|
|
447
|
-
password?: string;
|
|
448
|
-
python?: boolean;
|
|
449
|
-
}): Promise<void>;
|
|
519
|
+
/** Establish a actual websocket connection to the DolphindB corresponding to the URL
|
|
520
|
+
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
|
|
521
|
+
this.autologin automatically log in when it is true */
|
|
522
|
+
connect(): Promise<void>;
|
|
450
523
|
get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
|
|
451
524
|
urgent?: boolean;
|
|
452
525
|
/** API 提交的任务, secondary 必须为 false */
|
|
@@ -472,6 +545,7 @@ export declare class DDB {
|
|
|
472
545
|
}): string;
|
|
473
546
|
disconnect(): void;
|
|
474
547
|
/** rpc through websocket (function/script/variable command)
|
|
548
|
+
When the DDB is not connected, the call will be automatically connected. When the connection is disconnected, the call will throw the Connectionerror
|
|
475
549
|
- type: API 类型: 'script' | 'function' | 'variable'
|
|
476
550
|
- options:
|
|
477
551
|
- urgent?: 决定 `行为标识` 那一行字符串的取值(只适用于 script 和 function)
|
|
@@ -535,8 +609,12 @@ export declare class DDB {
|
|
|
535
609
|
listener?: DdbMessageListener;
|
|
536
610
|
parse_object?: boolean;
|
|
537
611
|
}): Promise<DdbObj<DdbValue>>;
|
|
612
|
+
/** Cancel all console jobs corresponding to the current session id */
|
|
613
|
+
cancel(): Promise<void>;
|
|
538
614
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
539
615
|
parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
|
|
616
|
+
/** Internal stream subscription method */
|
|
617
|
+
subscribe(): Promise<DdbTableObj>;
|
|
540
618
|
}
|
|
541
619
|
export interface DdbMessageListener {
|
|
542
620
|
(message: DdbMessage, _this: DDB): any;
|
|
@@ -555,4 +633,3 @@ export interface DdbErrorMessage {
|
|
|
555
633
|
}
|
|
556
634
|
export declare type DdbMessage = DdbPrintMessage | DdbObjectMessage | DdbErrorMessage;
|
|
557
635
|
export declare let ddb: DDB;
|
|
558
|
-
export {};
|