dolphindb 2.0.921 → 2.0.923

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 ADDED
@@ -0,0 +1,667 @@
1
+ import 'xshell/prototype.browser.js';
2
+ export declare enum DdbForm {
3
+ scalar = 0,
4
+ vector = 1,
5
+ pair = 2,
6
+ matrix = 3,
7
+ set = 4,
8
+ dict = 5,
9
+ table = 6,
10
+ chart = 7,
11
+ /** 结点内部通信可能会使用,调用函数执行脚本一般不会返回这种类型
12
+ Node internal communication may be used, calling function execution script generally does not return this type */
13
+ chunk = 8,
14
+ /** sysobj */
15
+ object = 9
16
+ }
17
+ /** DolphinDB DataType
18
+ 对应的 array vector 类型为 64 + 基本类型 The corresponding array vector type is 64 + base type
19
+ 对应的 extended 类型为 128 + 基本类型 The corresponding extended type is 128 + base type
20
+ */
21
+ export declare enum DdbType {
22
+ void = 0,
23
+ bool = 1,
24
+ char = 2,
25
+ short = 3,
26
+ int = 4,
27
+ long = 5,
28
+ date = 6,
29
+ month = 7,
30
+ time = 8,
31
+ minute = 9,
32
+ second = 10,
33
+ datetime = 11,
34
+ timestamp = 12,
35
+ nanotime = 13,
36
+ nanotimestamp = 14,
37
+ float = 15,
38
+ double = 16,
39
+ symbol = 17,
40
+ string = 18,
41
+ uuid = 19,
42
+ functiondef = 20,
43
+ handle = 21,
44
+ code = 22,
45
+ datasource = 23,
46
+ resource = 24,
47
+ any = 25,
48
+ compress = 26,
49
+ dict = 27,
50
+ datehour = 28,
51
+ ipaddr = 30,
52
+ int128 = 31,
53
+ blob = 32,
54
+ complex = 34,
55
+ point = 35,
56
+ duration = 36,
57
+ decimal32 = 37,
58
+ decimal64 = 38,
59
+ decimal128 = 39,
60
+ object = 40,
61
+ pynone = 41,
62
+ symbol_extended = 145
63
+ }
64
+ export declare enum DdbFunctionType {
65
+ SystemFunc = 0,
66
+ SystemProc = 1,
67
+ OperatorFunc = 2,
68
+ UserDefinedFunc = 3,
69
+ PartialFunc = 4,
70
+ DynamicFunc = 5,
71
+ PiecewiseFunc = 6,
72
+ JitFunc = 7,
73
+ JitPartialFunc = 8
74
+ }
75
+ export declare enum DdbDurationUnit {
76
+ ns = 0,
77
+ us = 1,
78
+ ms = 2,
79
+ s = 3,
80
+ m = 4,
81
+ H = 5,
82
+ d = 6,
83
+ w = 7,
84
+ M = 8,
85
+ y = 9,
86
+ B = 10
87
+ }
88
+ export interface DdbFunctionDefValue {
89
+ type: DdbFunctionType;
90
+ name: string;
91
+ }
92
+ export interface DdbDurationValue {
93
+ unit: DdbDurationUnit;
94
+ /** int32 */
95
+ data: number;
96
+ }
97
+ export interface DdbDecimal32Value {
98
+ /** int32, data 需要除以 10^scale 得到原值 data needs to be divided by 10^scale to get the original value */
99
+ scale: number;
100
+ /** int32, 空值为 null ddb null is js null */
101
+ data: number | null;
102
+ }
103
+ export interface DdbDecimal64Value {
104
+ /** int32, data 需要除以 10^scale 得到原值 data needs to be divided by 10^scale to get the original value */
105
+ scale: number;
106
+ /** int64, 空值为 null empty value is null */
107
+ data: bigint | null;
108
+ }
109
+ export interface DdbDecimal32VectorValue {
110
+ scale: number;
111
+ data: Int32Array;
112
+ }
113
+ export interface DdbDecimal64VectorValue {
114
+ scale: number;
115
+ data: BigInt64Array;
116
+ }
117
+ export interface DdbSymbolExtendedValue {
118
+ base_id: number;
119
+ base: string[];
120
+ data: Uint32Array;
121
+ }
122
+ export interface DdbArrayVectorBlock {
123
+ unit: 1 | 2 | 4;
124
+ rows: number;
125
+ lengths: Uint8Array | Uint16Array | Uint32Array;
126
+ data: Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array;
127
+ }
128
+ export type DdbArrayVectorValue = DdbArrayVectorBlock[] & /* decimal32, decimal64 会有这个属性 */ {
129
+ scale?: number;
130
+ };
131
+ export interface DdbMatrixValue {
132
+ rows: DdbVectorObj;
133
+ cols: DdbVectorObj;
134
+ data: DdbVectorValue;
135
+ }
136
+ export type DdbDictValue = [DdbVectorObj, DdbVectorObj];
137
+ export declare enum DdbChartType {
138
+ area = 0,
139
+ bar = 1,
140
+ column = 2,
141
+ histogram = 3,
142
+ line = 4,
143
+ pie = 5,
144
+ scatter = 6,
145
+ trend = 7,
146
+ kline = 8
147
+ }
148
+ export interface DdbChartValue {
149
+ /** 原属性 chartType original: chartType */
150
+ type: DdbChartType;
151
+ stacking: boolean;
152
+ /** 直方图 (Histogram), plotHist 函数返回的 chart 可能具有该属性
153
+ 原属性 binStart
154
+ 数值类型的 DdbObj 都有可能?
155
+ */
156
+ bin_start?: DdbObj;
157
+ /** 原属性 binEnd */
158
+ bin_end?: DdbObj;
159
+ /** 原属性 binCount */
160
+ bin_count?: DdbObj;
161
+ titles: {
162
+ chart: string;
163
+ x_axis: string;
164
+ y_axis: string;
165
+ };
166
+ extras?: {
167
+ multi_y_axes: boolean;
168
+ };
169
+ data: DdbMatrixObj;
170
+ }
171
+ export type DdbScalarValue = null | boolean | number | bigint | string | Uint8Array | // uuid, ipaddr, int128, blob
172
+ [
173
+ number,
174
+ number
175
+ ] | // complex, point
176
+ DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value;
177
+ export type DdbVectorValue = Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | // string[]
178
+ Uint8Array[] | // blob
179
+ DdbObj[] | // any
180
+ DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue;
181
+ export type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue;
182
+ export type DdbStringObj = DdbObj<string>;
183
+ export type DdbVectorObj = DdbObj<DdbVectorValue>;
184
+ export type DdbVectorAnyObj = DdbObj<DdbObj[]>;
185
+ export type DdbVectorStringObj = DdbObj<string[]>;
186
+ export type DdbTableObj = DdbObj<DdbVectorObj[]>;
187
+ export type DdbDictObj = DdbObj<[DdbVectorObj, DdbVectorObj]>;
188
+ export type DdbMatrixObj = DdbObj<DdbMatrixValue>;
189
+ export type DdbChartObj = DdbObj<DdbChartValue>;
190
+ export declare const nulls: {
191
+ readonly int8: -128;
192
+ readonly int16: -32768;
193
+ readonly int32: -2147483648;
194
+ readonly int64: -9223372036854775808n;
195
+ readonly float32: -3.4028234663852886e+38;
196
+ /** -Number.MAX_VALUE */
197
+ readonly double: number;
198
+ readonly bytes16: Uint8Array;
199
+ };
200
+ /** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
201
+ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
202
+ static dec: TextDecoder;
203
+ static enc: TextEncoder;
204
+ /** 维护已解析的 symbol base,比如流数据中后续的 symbol 向量可能只发送一个 base.id, base.size == 0, 依赖之前发送的 symbol base ?
205
+ 只是暂存,如果一张表有多个 symbol 列,可能这个 symbol base 会被复用,不同的对象之间 symbol base 一般不复用
206
+ */
207
+ static symbol_bases: Record<number, string[]>;
208
+ /** little endian (client) */
209
+ static le_client: boolean;
210
+ /** 是否为小端 (little endian) */
211
+ le: boolean;
212
+ /** 数据形式 https://www.dolphindb.cn/cn/help/DataTypesandStructures/DataForms/index.html */
213
+ form: DdbForm;
214
+ /** 数据类型 https://www.dolphindb.cn/cn/help/DataTypesandStructures/DataTypes/index.html */
215
+ type: DdbType;
216
+ /** 占用 parse 时传入的 buf 的长度 */
217
+ length: number;
218
+ /** table name / column name */
219
+ name?: string;
220
+ /**
221
+ 最低维、第 1 维
222
+ - vector: rows = n, cols = 1
223
+ - pair: rows = 2, cols = 1
224
+ - matrix: rows = n, cols = m
225
+ - set: 同 vector
226
+ - dict: 包含 keys, values 向量
227
+ - table: 同 matrix
228
+ */
229
+ rows?: number;
230
+ /** 第 2 维 */
231
+ cols?: number;
232
+ /** 实际数据。不同的 DdbForm, DdbType 使用 DdbValue 中不同的类型来表示实际数据
233
+ The actual data. Different DdbForm, DdbType use different types in DdbValue to represent actual data */
234
+ value: TValue;
235
+ /** 原始二进制数据,仅在 parse_object 为 false 时通过 parse_message 生成的顶层对象有这个属性 */
236
+ buffer?: Uint8Array;
237
+ constructor(data: Partial<DdbObj> & {
238
+ form: DdbForm;
239
+ type: DdbType;
240
+ });
241
+ static parse(buf: Uint8Array, le: boolean): DdbObj<DdbValue>;
242
+ static parse_scalar(buf: Uint8Array, le: boolean, type: DdbType): [number, DdbScalarValue];
243
+ /** parse: rows, cols, items
244
+ 返回的 ddbobj.length 不包括 vector 的 type 和 form
245
+ */
246
+ static parse_vector(buf: Uint8Array, le: boolean, type: DdbType): DdbVectorObj;
247
+ /** 有可能没有字节对齐,不能直接使用原有 message 的 arraybuffer, 统一复制出来,让原有 arraybuffer 被回收掉比较好 */
248
+ static parse_vector_items(buf: Uint8Array, le: boolean, type: DdbType, length: number): [
249
+ number,
250
+ DdbVectorValue
251
+ ];
252
+ pack(): Uint8Array;
253
+ static pack_vector_body(value: DdbVectorValue, type: DdbType, length: number): ArrayBufferView[];
254
+ toString(options?: InspectOptions): string;
255
+ inspect_type(): string;
256
+ /** 自动转换 js string, boolean 为 DdbObj */
257
+ static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
258
+ /** 转换 js 数组为 DdbObj[] */
259
+ static to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
260
+ to_cols(): {
261
+ title: string;
262
+ dataIndex: string;
263
+ render: (value: any) => string;
264
+ }[];
265
+ to_rows<T extends Record<string, any> = Record<string, any>>(): T[];
266
+ /** 将 dict<string, any> 自动转换为 js object (Record<string, any>) Automatically convert dict<string, any> to js object (Record<string, any>)
267
+ - options?:
268
+ - strip?: `false` 是否将 DdbObj 中的 value 直接提取、剥离出来作为 js object 的 value (丢弃 DdbObj 中的其余信息,只保留 value)
269
+ Whether to directly extract and strip the value in DdbObj as the value of js object (discard the rest of the information in DdbObj, only keep the value)
270
+ - deep?: `false` 是否递归转换
271
+ Whether to convert recursively
272
+ */
273
+ to_dict<T extends Record<string, DdbObj> = Record<string, DdbObj>>(): T;
274
+ to_dict<T extends Record<string, any> = Record<string, any>>(options: {
275
+ strip: true;
276
+ }): T;
277
+ to_dict<T extends Record<string, any> = Record<string, any>>(options?: {
278
+ strip?: boolean;
279
+ deep?: boolean;
280
+ }): T;
281
+ }
282
+ export interface InspectOptions {
283
+ colors?: boolean;
284
+ /** `null` decimal places 小数位数 */
285
+ decimals?: number;
286
+ /** `false` 决定 null 值如何返回. nullstr ? 'null' : '' */
287
+ nullstr?: boolean;
288
+ /** `false` 决定 string, symbol, char 类型是否加引号 */
289
+ quote?: boolean;
290
+ }
291
+ /** 根据 DdbType 格式化单个元素 (value) 为字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
292
+ export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
293
+ /** 格式化向量、集合中的第 index 项为字符串 formatted vector, the index-th item in the collection is a string */
294
+ export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
295
+ export declare class DdbVoid extends DdbObj<undefined> {
296
+ constructor();
297
+ }
298
+ export declare class DdbBool extends DdbObj<boolean> {
299
+ constructor(value: boolean | null);
300
+ }
301
+ export declare class DdbChar extends DdbObj<string> {
302
+ constructor(value: string | number | null);
303
+ }
304
+ export declare class DdbInt extends DdbObj<number> {
305
+ constructor(value: number | null);
306
+ }
307
+ export declare class DdbString extends DdbObj<string> {
308
+ constructor(value: string);
309
+ }
310
+ export declare class DdbLong extends DdbObj<bigint> {
311
+ constructor(value: bigint | null);
312
+ }
313
+ export declare class DdbDouble extends DdbObj<number> {
314
+ constructor(value: number | null);
315
+ }
316
+ export declare class DdbDateTime extends DdbObj<number> {
317
+ constructor(value: number | null);
318
+ }
319
+ export declare class DdbTimeStamp extends DdbObj<bigint> {
320
+ constructor(value: bigint | null);
321
+ }
322
+ export declare class DdbNanoTimeStamp extends DdbObj<bigint> {
323
+ constructor(value: bigint | null);
324
+ }
325
+ export declare class DdbPair extends DdbObj<Int32Array> {
326
+ constructor(l: number | null, r?: number | null);
327
+ }
328
+ export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
329
+ constructor(name: string, type: DdbFunctionType);
330
+ }
331
+ export declare class DdbVectorInt extends DdbObj<Int32Array> {
332
+ constructor(ints: (number | null)[] | Int32Array, name?: string);
333
+ }
334
+ export declare class DdbVectorDouble extends DdbObj<Float64Array> {
335
+ constructor(doubles: (number | null)[] | Float64Array, name?: string);
336
+ }
337
+ export declare class DdbVectorString extends DdbObj<string[]> {
338
+ constructor(strings: string[], name?: string);
339
+ }
340
+ export declare class DdbVectorAny extends DdbObj {
341
+ constructor(objs: (DdbObj | string | boolean)[], name?: string);
342
+ }
343
+ export declare class DdbVectorSymbol extends DdbObj<DdbSymbolExtendedValue> {
344
+ constructor(strings: string[], name?: string);
345
+ }
346
+ export declare class DdbSetInt extends DdbObj<Int32Array> {
347
+ constructor(ints: (number | null)[] | Set<number> | Int32Array);
348
+ }
349
+ export declare class DdbSetDouble extends DdbObj<Float64Array> {
350
+ constructor(doubles: (number | null)[] | Set<number> | Float64Array);
351
+ }
352
+ export declare class DdbSetString extends DdbObj<string[]> {
353
+ constructor(strings: string[] | Set<string>);
354
+ }
355
+ /** 构造 DdbDict 对象,支持两种用法: Constructs a DdbDict object, which supports two usages:
356
+ - 传入类型是 DdbVectorObj 的 keys, values 两个参数直接组成 dict<keys.type, values.type> 的 DdbDict
357
+ The incoming type is the keys of DdbObj<DdbVectorValue>, and the two parameters of values directly form the DdbDict of dict<keys.type, values.type>
358
+ - 传入 js object (类型是 Record<string, boolean | string | DdbObj>), 自动转换为 dict<string, any> 的 DdbDict
359
+ Pass in js object (type is Record<string, boolean | string | DdbObj>), automatically converted to DdbDict of dict<string, any> */
360
+ export declare class DdbDict extends DdbObj<DdbDictValue> {
361
+ constructor(obj: Record<string, boolean | string | DdbObj>);
362
+ constructor(keys: DdbVectorObj, values: DdbVectorObj);
363
+ }
364
+ export declare class DdbTable extends DdbObj<DdbObj[]> {
365
+ constructor(columns: DdbObj[], name?: string);
366
+ }
367
+ export declare function date2ms(date: number | null): number;
368
+ export declare function date2str(date: number | null, format?: string): string;
369
+ export declare function month2ms(month: number | null): number | null;
370
+ export declare function month2str(month: number | null): string;
371
+ export declare function time2ms(time: number | null): number | null;
372
+ export declare function time2str(time: number | null, format?: string): string;
373
+ export declare function minute2ms(minute: number | null): number | null;
374
+ export declare function minute2str(minute: number | null, format?: string): string;
375
+ export declare function second2ms(second: number | null): number | null;
376
+ export declare function second2str(second: number | null, format?: string): string;
377
+ export declare function datetime2ms(datetime: number | null): number | null;
378
+ export declare function datetime2str(datetime: number | null, format?: string): string;
379
+ export declare function timestamp2ms(timestamp: bigint | null): number | null;
380
+ /** format timestamp (bigint) to string
381
+ - timestamp: bigint value
382
+ - format?:
383
+ 格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS` format string, default to `YYYY.MM.DD HH:mm:ss.SSS`
384
+ https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
385
+ */
386
+ export declare function timestamp2str(timestamp: bigint | null, format?: string): string;
387
+ export declare function datehour2ms(datehour: number | null): number | null;
388
+ export declare function datehour2str(datehour: number | null, format?: string): string;
389
+ /** parse timestamp string to bigint value
390
+ - str: timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
391
+ timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
392
+ - format?:
393
+ 对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS`
394
+ The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
395
+ https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
396
+ */
397
+ export declare function str2timestamp(str: string, format?: string): bigint;
398
+ export declare function nanotime2ns(nanotime: bigint | null): bigint | null;
399
+ export declare function nanotime2str(nanotime: bigint | null, format?: string): string;
400
+ export declare function nanotimestamp2ns(nanotimestamp: bigint | null): bigint | null;
401
+ /** format nanotimestamp value (bigint) to string
402
+ - nanotimestamp: bigint value
403
+ - format?:
404
+ 格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSSSSSSSS` format string, default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
405
+ 秒的格式为 ss (必须包含); 纳秒的格式为 SSSSSSSSS (必须包含) Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
406
+ https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
407
+ */
408
+ export declare function nanotimestamp2str(nanotimestamp: bigint | null, format?: string): string;
409
+ /** parse nano timestamp string to bigint value
410
+ - str: nano timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
411
+ nano timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
412
+ - format?:
413
+ 对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
414
+ 秒的格式为 ss (必须包含); 纳秒的格式为 SSSSSSSSS (必须包含)
415
+ https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
416
+ The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
417
+ Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included) */
418
+ export declare function str2nanotimestamp(str: string, format?: string): bigint;
419
+ export declare function ipaddr2str(buffer: Uint8Array, le?: boolean, ipv6?: boolean): string;
420
+ export declare function uuid2str(buffer: Uint8Array, le?: boolean): string;
421
+ export declare function int1282str(buffer: Uint8Array, le?: boolean): string;
422
+ export interface StreamingParams {
423
+ table: string;
424
+ action?: string;
425
+ handler(message: StreamingData): any;
426
+ }
427
+ export interface StreamingData extends StreamingParams {
428
+ /** server 发送消息的时间 (nano seconds since epoch) The time the server sent the message (nano seconds since epoch)
429
+ std::chrono::system_clock::now().time_since_epoch() / std::chrono::nanoseconds(1) */
430
+ time: bigint;
431
+ /** message id */
432
+ id: bigint;
433
+ colnames: string[];
434
+ /** 订阅主题,即一个订阅的名称。 Subscription topic, which is the name of a subscription.
435
+ 它是一个字符串,由订阅表所在节点的别名、流数据表名称和订阅任务名称(如果指定了 actionName)组合而成,使用 `/` 分隔
436
+ 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 `/` */
437
+ topic: string;
438
+ /** 流数据,类型是 any vector, 其中的每一个元素对应被订阅表的一个列 (没有 name),列 (DdbObj<DdbVectorValue>) 中的内容是新增的数据值
439
+ 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 */
440
+ data: DdbObj<DdbVectorObj[]>;
441
+ /** 新增的流数据行数 Number of new streaming data rows */
442
+ rows: number;
443
+ window: {
444
+ /** 建立连接开始 offset = 0, 随着 window 的移动逐渐增加 The establishment of the connection starts offset = 0, and gradually increases as the window moves */
445
+ offset: number;
446
+ /** segments 中 segment.row 的总和 sum of segment.row in segments */
447
+ rows: number;
448
+ /** 每次接收到的 data 组成的数组 An array of data received each time */
449
+ segments: DdbObj<DdbVectorObj[]>[];
450
+ };
451
+ /** 成功订阅后,后续推送过来的 message 解析错误,则会设置 error 并调用 handler
452
+ After successfully subscribed, if the subsequently pushed message is parsed incorrectly, the error will be set and the handler will be called. */
453
+ error?: Error;
454
+ }
455
+ export declare const winsize: 100000;
456
+ type DdbRpcType = 'script' | 'function' | 'variable' | 'connect';
457
+ export interface DdbRpcOptions {
458
+ script?: string;
459
+ func?: string;
460
+ args?: (DdbObj | string | boolean)[];
461
+ vars?: string[];
462
+ urgent?: boolean;
463
+ listener?: DdbMessageListener;
464
+ parse_object?: boolean;
465
+ }
466
+ export declare class DdbConnectionError extends Error {
467
+ name: string;
468
+ ddb: DDB;
469
+ constructor(ddb: DDB, error_options?: ErrorOptions);
470
+ }
471
+ export declare class DdbDatabaseError extends Error {
472
+ name: string;
473
+ ddb: DDB;
474
+ type: DdbRpcType;
475
+ options: DdbRpcOptions;
476
+ constructor(message: string, ddb: DDB, type: DdbRpcType, options: DdbRpcOptions);
477
+ }
478
+ export declare class DDB {
479
+ /** 当前的 session id (http 或 tcp) */
480
+ sid: string;
481
+ /** utf-8 text decoder */
482
+ dec: TextDecoder;
483
+ enc: TextEncoder;
484
+ /** DolphinDB WebSocket URL
485
+ e.g. `ws://127.0.0.1:8848/`, `wss://dolphindb.com`
486
+ */
487
+ url: string;
488
+ websocket: WebSocket;
489
+ /** little endian (server) */
490
+ le: boolean;
491
+ /** little endian (client) */
492
+ static le_client: boolean;
493
+ /** 是否在建立连接后自动登录,默认 true Whether to automatically log in after the connection is established, the default is true */
494
+ autologin: boolean;
495
+ /** DolphinDB 登录用户名 DolphinDB username */
496
+ username: string;
497
+ /** DolphinDB 登录密码 DolphinDB password */
498
+ password: string;
499
+ /** python session flag (2048) */
500
+ python: boolean;
501
+ /** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
502
+ streaming: StreamingData;
503
+ print_message_buffer: boolean;
504
+ print_object_buffer: boolean;
505
+ print_message: boolean;
506
+ parse_object: boolean;
507
+ pnode_run_defined: boolean;
508
+ /** DdbMessage listeners */
509
+ listeners: DdbMessageListener[];
510
+ pconnect: Promise<void>;
511
+ ppnoderun: Promise<void>;
512
+ presult: Promise<any>;
513
+ get connected(): boolean;
514
+ /**
515
+ 使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
516
+ Initialize an instance of DolphinDB Client using the WebSocket URL (without establishing an actual network connection)
517
+ - url?: DolphinDB WebSocket URL,如:`ws://127.0.0.1:8848`, 默认为当前页面 URL
518
+ DolphinDB WebSocket URL. e.g.:`ws://127.0.0.1:8848`, Defaults to the current page URL
519
+ - options?:
520
+ - autologin?: 是否在建立连接后自动登录,默认 `true` Whether to log in automatically after establishing a connection, default `true`
521
+ - username?: DolphinDB 登录用户名,默认 `'admin'` DolphinDB username, default `'admin'`
522
+ - password?: DolphinDB 登录密码,默认 `'123456'` DolphinDB password, default `'123456'`
523
+ - python?: 设置 python session flag,默认 `false` set python session flag, default `false`
524
+ - streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
525
+
526
+ @example
527
+ let ddb = new DDB('ws://127.0.0.1:8848')
528
+
529
+ // 使用 HTTPS 加密 Encrypt with HTTPS
530
+ let ddbsecure = new DDB('wss://dolphindb.com', {
531
+ autologin: true,
532
+ username: 'admin',
533
+ password: '123456',
534
+ python: false
535
+ })
536
+ */
537
+ constructor(url?: string, options?: {
538
+ autologin?: boolean;
539
+ username?: string;
540
+ password?: string;
541
+ python?: boolean;
542
+ streaming?: StreamingParams;
543
+ });
544
+ private on_message;
545
+ /** 建立实际的 WebSocket 连接到 URL 对应的 DolphinDB Establish a actual websocket connection to the DolphindB corresponding to the URL
546
+ 是幂等的,调用后会确保已连接到数据库 (确保 websocket.readyState 为 open),否则报错 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
547
+ this.autologin 为 true 时自动登录 this.autologin automatically log in when it is true */
548
+ connect(): Promise<void>;
549
+ get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
550
+ urgent?: boolean;
551
+ /** API 提交的任务, secondary 必须为 false */
552
+ secondary?: boolean;
553
+ /** 是否异步任务(不返回结果) */
554
+ async?: boolean;
555
+ /** 让服务端以 pickle 协议返回数据 */
556
+ pickle?: boolean;
557
+ /** 本次任务完成后 clear session memory */
558
+ clear?: boolean;
559
+ /** 是否为 api client */
560
+ api?: boolean;
561
+ compress?: boolean;
562
+ /** 任务是否可以取消 */
563
+ cancellable?: boolean;
564
+ priority?: number;
565
+ /** `8` 0 ~ 64, 指定本任务并行度 */
566
+ parallelism?: number;
567
+ /** 根任务编号,内部使用,API中固定为空 */
568
+ root_id?: string;
569
+ /** 指定分块返回的块大小 */
570
+ limit?: boolean;
571
+ }): string;
572
+ disconnect(): void;
573
+ /** rpc through websocket (function/script/variable command)
574
+ 未连接到 DDB 时调用会自动连接,连接断开时调用会抛出 DdbConnectionError
575
+ When the DDB is not connected, the call will be automatically connected. When the connection is disconnected, the call will throw the DdbConnectionError
576
+ - type: API 类型: 'script' | 'function' | 'variable'
577
+ - options:
578
+ - urgent?: 决定 `行为标识` 那一行字符串的取值(只适用于 script 和 function)
579
+ - vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
580
+ - listener?: 处理本次 rpc 期间的消息 (DdbMessage)
581
+ - parse_object?: 在本次 rpc 期间设置 parse_object, 结束后恢复原有
582
+ 为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化
583
+ */
584
+ rpc<T extends DdbObj = DdbObj>(type: DdbRpcType, options: DdbRpcOptions): Promise<T>;
585
+ /** eval script through websocket (script command)
586
+ - script?: 执行的脚本 Script to execute
587
+ - options?: 执行选项 execution options
588
+ - urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
589
+ Urgent flag to ensure that submitted scripts are processed by urgent workers to prevent being blocked by other jobs
590
+ - listener?: 处理本次 rpc 期间的消息 (DdbMessage) Process messages during this rpc (DdbMessage)
591
+ - parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
592
+ 不做解析,以便后续转发、序列化
593
+ Set parse_object during this rpc, and restore the original after the end.
594
+ When it is false, the returned DdbObj only contains buffer and le without parsing,
595
+ so as to facilitate subsequent forwarding and serialization
596
+ */
597
+ eval<T extends DdbObj>(script: string, { urgent, listener, parse_object, }?: {
598
+ urgent?: boolean;
599
+ listener?: DdbMessageListener;
600
+ parse_object?: boolean;
601
+ }): Promise<T>;
602
+ /** call function through websocket (function command)
603
+ - func: 函数名 function name
604
+ - args?: `[ ]` 调用参数 (传入的原生 string 和 boolean 会被自动转换为 DdbObj<string> 和 DdbObj<boolean>)
605
+ Call parameters (the incoming native string and boolean will be automatically converted to DdbObj<string> and DdbObj<boolean>)
606
+ - options?: 调用选项 call options
607
+ - urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
608
+ Emergency flag. Use urgent worker execution to prevent being blocked by other jobs
609
+ - node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
610
+ When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
611
+ - nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
612
+ When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
613
+ - func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
614
+ It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
615
+ - add_node_alias?: 设置 nodes 参数时选传,其它情况不传
616
+ Select to pass when setting the nodes parameter, otherwise not pass
617
+ - listener?: 处理本次 rpc 期间的消息 (DdbMessage)
618
+ Process messages during this rpc (DdbMessage)
619
+ - parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
620
+ 不做解析,以便后续转发、序列化
621
+ Set parse_object during this rpc, and restore the original after the end.
622
+ When it is false, the returned DdbObj only contains buffer and le without parsing,
623
+ so as to facilitate subsequent forwarding and serialization
624
+ */
625
+ call<T extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias, listener, parse_object, }?: {
626
+ urgent?: boolean;
627
+ node?: string;
628
+ nodes?: string[];
629
+ func_type?: DdbFunctionType;
630
+ add_node_alias?: boolean;
631
+ listener?: DdbMessageListener;
632
+ parse_object?: boolean;
633
+ }): Promise<T>;
634
+ /** upload variable through websocket (variable command) */
635
+ upload(
636
+ /** 上传的变量名 Uploaded variables' name */
637
+ vars: string[],
638
+ /** 上传的变量值 Uploaded variables' value */
639
+ args: (DdbObj | string | boolean)[], { listener, parse_object, }?: {
640
+ listener?: DdbMessageListener;
641
+ parse_object?: boolean;
642
+ }): Promise<DdbObj<DdbValue>>;
643
+ /** 取消当前 session id 对应的所有 console jobs Cancel all console jobs corresponding to the current session id */
644
+ cancel(): Promise<void>;
645
+ /** 解析服务端响应报文,返回去掉 header 的 data buf */
646
+ parse_message(buf: Uint8Array, error: DdbDatabaseError): DdbMessage;
647
+ /** 内部的流订阅方法 Internal stream subscription method */
648
+ subscribe(): Promise<StreamingData>;
649
+ }
650
+ export interface DdbMessageListener {
651
+ (message: DdbMessage, _this: DDB): any;
652
+ }
653
+ export interface DdbPrintMessage {
654
+ type: 'print';
655
+ data: string;
656
+ }
657
+ export interface DdbObjectMessage {
658
+ type: 'object';
659
+ data: DdbObj;
660
+ }
661
+ export interface DdbErrorMessage {
662
+ type: 'error';
663
+ data: Error;
664
+ }
665
+ export type DdbMessage = DdbPrintMessage | DdbObjectMessage | DdbErrorMessage;
666
+ export declare let ddb: DDB;
667
+ export {};