dolphindb 2.0.501 → 2.0.504
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 +37 -32
- package/README.zh.md +29 -24
- package/browser.d.ts +52 -14
- package/browser.js +130 -26
- package/browser.js.map +1 -1
- package/index.d.ts +49 -13
- package/index.js +127 -25
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/test.d.ts +0 -1
- package/test.js +0 -38
- package/test.js.map +0 -1
package/index.d.ts
CHANGED
|
@@ -189,18 +189,27 @@ export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
|
|
|
189
189
|
export declare class DdbVectorInt extends DdbObj<Int32Array> {
|
|
190
190
|
constructor(ints: (number | null)[] | Int32Array, name?: string);
|
|
191
191
|
}
|
|
192
|
-
export declare class DdbVectorString extends DdbObj<string[]> {
|
|
193
|
-
constructor(strings: string[], name?: string);
|
|
194
|
-
}
|
|
195
192
|
export declare class DdbVectorDouble extends DdbObj<Float64Array> {
|
|
196
193
|
constructor(doubles: (number | null)[] | Float64Array, name?: string);
|
|
197
194
|
}
|
|
195
|
+
export declare class DdbVectorString extends DdbObj<string[]> {
|
|
196
|
+
constructor(strings: string[], name?: string);
|
|
197
|
+
}
|
|
198
198
|
export declare class DdbVectorAny extends DdbObj {
|
|
199
199
|
constructor(objs: DdbObj<DdbValue>[], name?: string);
|
|
200
200
|
}
|
|
201
201
|
export declare class DdbVectorSymbol extends DdbObj<DdbSymbolExtendedValue> {
|
|
202
202
|
constructor(strings: string[], name?: string);
|
|
203
203
|
}
|
|
204
|
+
export declare class DdbSetInt extends DdbObj<Int32Array> {
|
|
205
|
+
constructor(ints: (number | null)[] | Set<number> | Int32Array);
|
|
206
|
+
}
|
|
207
|
+
export declare class DdbSetDouble extends DdbObj<Float64Array> {
|
|
208
|
+
constructor(doubles: (number | null)[] | Set<number> | Float64Array);
|
|
209
|
+
}
|
|
210
|
+
export declare class DdbSetString extends DdbObj<string[]> {
|
|
211
|
+
constructor(strings: string[] | Set<string>);
|
|
212
|
+
}
|
|
204
213
|
export declare class DdbTable extends DdbObj<DdbObj[]> {
|
|
205
214
|
constructor(columns: DdbObj[], name?: string);
|
|
206
215
|
}
|
|
@@ -252,6 +261,12 @@ export declare class DDB {
|
|
|
252
261
|
le: boolean;
|
|
253
262
|
/** little endian (client) */
|
|
254
263
|
static le_client: boolean;
|
|
264
|
+
/** 是否在建立连接后自动登录,默认 true */
|
|
265
|
+
autologin: boolean;
|
|
266
|
+
/** DolphinDB 登录用户名 */
|
|
267
|
+
username: string;
|
|
268
|
+
/** DolphinDB 登录密码 */
|
|
269
|
+
password: string;
|
|
255
270
|
/** python session flag (2048) */
|
|
256
271
|
python: boolean;
|
|
257
272
|
message_hook: (message: Uint8Array) => any;
|
|
@@ -265,22 +280,43 @@ export declare class DDB {
|
|
|
265
280
|
/**
|
|
266
281
|
Initialize an instance of DolphinDB Client using the WebSocket URL
|
|
267
282
|
(without establishing an actual network connection)
|
|
283
|
+
- url: DolphinDB WebSocket URL. e.g.:`ws://127.0.0.1:8848`
|
|
284
|
+
- options?:
|
|
285
|
+
- autologin?: Whether to log in automatically after establishing a connection, default `true`
|
|
286
|
+
- username?: DolphinDB username, default `'admin'`
|
|
287
|
+
- password?: DolphinDB password, default `'123456'`
|
|
288
|
+
- python?: set python session flag, default `false`
|
|
289
|
+
|
|
268
290
|
@example
|
|
269
291
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
270
|
-
|
|
292
|
+
|
|
293
|
+
// 使用 HTTPS 加密
|
|
294
|
+
let ddbsecure = new DDB('wss://dolphindb.com', {
|
|
295
|
+
autologin: true,
|
|
296
|
+
username: 'admin',
|
|
297
|
+
password: '123456',
|
|
298
|
+
python: false
|
|
299
|
+
})
|
|
300
|
+
*/
|
|
301
|
+
constructor(url: string, options?: {
|
|
302
|
+
autologin?: boolean;
|
|
303
|
+
username?: string;
|
|
304
|
+
password?: string;
|
|
305
|
+
python?: boolean;
|
|
306
|
+
});
|
|
307
|
+
/** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
|
|
308
|
+
- options?:
|
|
309
|
+
- url?: DolphinDB WebSocket URL. By default, the WebSocket URL passed in when the instance is initialized is used
|
|
310
|
+
- autologin?: Whether to log in automatically after establishing a connection, default `true`
|
|
311
|
+
- username?: DolphinDB username, default `'admin'`
|
|
312
|
+
- password?: DolphinDB password, default `'123456'`
|
|
313
|
+
- python?: set python session flag, default `false`
|
|
271
314
|
*/
|
|
272
|
-
|
|
273
|
-
/** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL */
|
|
274
|
-
connect({ url, login, username, password, python, }?: {
|
|
275
|
-
/** By default, the WebSocket URL passed in when the instance is initialized is used */
|
|
315
|
+
connect(options?: {
|
|
276
316
|
url?: string;
|
|
277
|
-
|
|
278
|
-
login?: boolean;
|
|
279
|
-
/** DolphinDB username */
|
|
317
|
+
autologin?: boolean;
|
|
280
318
|
username?: string;
|
|
281
|
-
/** DolphinDB password */
|
|
282
319
|
password?: string;
|
|
283
|
-
/** set python session flag */
|
|
284
320
|
python?: boolean;
|
|
285
321
|
}): Promise<void>;
|
|
286
322
|
get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbTable = exports.DdbVectorSymbol = exports.DdbVectorAny = exports.
|
|
3
|
+
exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbTable = exports.DdbSetString = exports.DdbSetDouble = exports.DdbSetInt = exports.DdbVectorSymbol = exports.DdbVectorAny = exports.DdbVectorString = exports.DdbVectorDouble = exports.DdbVectorInt = exports.DdbFunction = exports.DdbPair = exports.DdbNanoTimeStamp = exports.DdbTimeStamp = exports.DdbDateTime = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbChar = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbFunctionType = exports.ddb_sizes = exports.DdbType = exports.DdbForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const ws_1 = require("ws");
|
|
6
6
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
@@ -1094,20 +1094,6 @@ class DdbVectorInt extends DdbObj {
|
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
1096
|
exports.DdbVectorInt = DdbVectorInt;
|
|
1097
|
-
class DdbVectorString extends DdbObj {
|
|
1098
|
-
constructor(strings, name) {
|
|
1099
|
-
super({
|
|
1100
|
-
form: DdbForm.vector,
|
|
1101
|
-
type: DdbType.string,
|
|
1102
|
-
length: 0,
|
|
1103
|
-
rows: strings.length,
|
|
1104
|
-
cols: 1,
|
|
1105
|
-
value: strings,
|
|
1106
|
-
name,
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
exports.DdbVectorString = DdbVectorString;
|
|
1111
1097
|
class DdbVectorDouble extends DdbObj {
|
|
1112
1098
|
constructor(doubles, name) {
|
|
1113
1099
|
super({
|
|
@@ -1128,6 +1114,20 @@ class DdbVectorDouble extends DdbObj {
|
|
|
1128
1114
|
}
|
|
1129
1115
|
}
|
|
1130
1116
|
exports.DdbVectorDouble = DdbVectorDouble;
|
|
1117
|
+
class DdbVectorString extends DdbObj {
|
|
1118
|
+
constructor(strings, name) {
|
|
1119
|
+
super({
|
|
1120
|
+
form: DdbForm.vector,
|
|
1121
|
+
type: DdbType.string,
|
|
1122
|
+
length: 0,
|
|
1123
|
+
rows: strings.length,
|
|
1124
|
+
cols: 1,
|
|
1125
|
+
value: strings,
|
|
1126
|
+
name,
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
exports.DdbVectorString = DdbVectorString;
|
|
1131
1131
|
class DdbVectorAny extends DdbObj {
|
|
1132
1132
|
constructor(objs, name) {
|
|
1133
1133
|
super({
|
|
@@ -1173,6 +1173,65 @@ class DdbVectorSymbol extends DdbObj {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
}
|
|
1175
1175
|
exports.DdbVectorSymbol = DdbVectorSymbol;
|
|
1176
|
+
class DdbSetInt extends DdbObj {
|
|
1177
|
+
constructor(ints) {
|
|
1178
|
+
super({
|
|
1179
|
+
form: DdbForm.set,
|
|
1180
|
+
type: DdbType.int,
|
|
1181
|
+
length: 0,
|
|
1182
|
+
rows: ints instanceof Set ?
|
|
1183
|
+
ints.size
|
|
1184
|
+
:
|
|
1185
|
+
ints.length,
|
|
1186
|
+
cols: 1,
|
|
1187
|
+
value: ints instanceof Int32Array ?
|
|
1188
|
+
ints
|
|
1189
|
+
:
|
|
1190
|
+
Int32Array.from(ints, v => v === null ?
|
|
1191
|
+
exports.nulls.int32
|
|
1192
|
+
:
|
|
1193
|
+
v),
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
exports.DdbSetInt = DdbSetInt;
|
|
1198
|
+
class DdbSetDouble extends DdbObj {
|
|
1199
|
+
constructor(doubles) {
|
|
1200
|
+
super({
|
|
1201
|
+
form: DdbForm.set,
|
|
1202
|
+
type: DdbType.double,
|
|
1203
|
+
length: 0,
|
|
1204
|
+
rows: doubles instanceof Set ?
|
|
1205
|
+
doubles.size
|
|
1206
|
+
:
|
|
1207
|
+
doubles.length,
|
|
1208
|
+
cols: 1,
|
|
1209
|
+
value: doubles instanceof Int32Array ?
|
|
1210
|
+
doubles
|
|
1211
|
+
:
|
|
1212
|
+
Int32Array.from(doubles, v => v === null ?
|
|
1213
|
+
exports.nulls.int32
|
|
1214
|
+
:
|
|
1215
|
+
v),
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
exports.DdbSetDouble = DdbSetDouble;
|
|
1220
|
+
class DdbSetString extends DdbObj {
|
|
1221
|
+
constructor(strings) {
|
|
1222
|
+
if (strings instanceof Set)
|
|
1223
|
+
strings = [...strings];
|
|
1224
|
+
super({
|
|
1225
|
+
form: DdbForm.set,
|
|
1226
|
+
type: DdbType.string,
|
|
1227
|
+
length: 0,
|
|
1228
|
+
rows: strings.length,
|
|
1229
|
+
cols: 1,
|
|
1230
|
+
value: strings
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
exports.DdbSetString = DdbSetString;
|
|
1176
1235
|
class DdbTable extends DdbObj {
|
|
1177
1236
|
constructor(columns, name = '') {
|
|
1178
1237
|
super({
|
|
@@ -1280,11 +1339,25 @@ class DDB {
|
|
|
1280
1339
|
/**
|
|
1281
1340
|
Initialize an instance of DolphinDB Client using the WebSocket URL
|
|
1282
1341
|
(without establishing an actual network connection)
|
|
1342
|
+
- url: DolphinDB WebSocket URL. e.g.:`ws://127.0.0.1:8848`
|
|
1343
|
+
- options?:
|
|
1344
|
+
- autologin?: Whether to log in automatically after establishing a connection, default `true`
|
|
1345
|
+
- username?: DolphinDB username, default `'admin'`
|
|
1346
|
+
- password?: DolphinDB password, default `'123456'`
|
|
1347
|
+
- python?: set python session flag, default `false`
|
|
1348
|
+
|
|
1283
1349
|
@example
|
|
1284
1350
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
1285
|
-
|
|
1351
|
+
|
|
1352
|
+
// 使用 HTTPS 加密
|
|
1353
|
+
let ddbsecure = new DDB('wss://dolphindb.com', {
|
|
1354
|
+
autologin: true,
|
|
1355
|
+
username: 'admin',
|
|
1356
|
+
password: '123456',
|
|
1357
|
+
python: false
|
|
1358
|
+
})
|
|
1286
1359
|
*/
|
|
1287
|
-
constructor(url) {
|
|
1360
|
+
constructor(url, options = {}) {
|
|
1288
1361
|
/** 当前的 session id (http 或 tcp) */
|
|
1289
1362
|
this.sid = '0';
|
|
1290
1363
|
/** utf-8 text decoder */
|
|
@@ -1294,11 +1367,25 @@ class DDB {
|
|
|
1294
1367
|
this.websocket = null;
|
|
1295
1368
|
/** little endian (server) */
|
|
1296
1369
|
this.le = true;
|
|
1370
|
+
/** 是否在建立连接后自动登录,默认 true */
|
|
1371
|
+
this.autologin = true;
|
|
1372
|
+
/** DolphinDB 登录用户名 */
|
|
1373
|
+
this.username = 'admin';
|
|
1374
|
+
/** DolphinDB 登录密码 */
|
|
1375
|
+
this.password = '123456';
|
|
1297
1376
|
/** python session flag (2048) */
|
|
1298
1377
|
this.python = false;
|
|
1299
1378
|
this.message_hook = null;
|
|
1300
1379
|
this.presult = Promise.resolve(null);
|
|
1301
1380
|
this.url = url;
|
|
1381
|
+
if (options.autologin !== undefined)
|
|
1382
|
+
this.autologin = options.autologin;
|
|
1383
|
+
if (options.username !== undefined)
|
|
1384
|
+
this.username = options.username;
|
|
1385
|
+
if (options.password !== undefined)
|
|
1386
|
+
this.password = options.password;
|
|
1387
|
+
if (options.python !== undefined)
|
|
1388
|
+
this.python = options.python;
|
|
1302
1389
|
}
|
|
1303
1390
|
/** print message handler */
|
|
1304
1391
|
printer(message) {
|
|
@@ -1310,12 +1397,27 @@ class DDB {
|
|
|
1310
1397
|
get connected() {
|
|
1311
1398
|
return this.websocket?.readyState === ws_1.WebSocket.OPEN;
|
|
1312
1399
|
}
|
|
1313
|
-
/** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1400
|
+
/** Establish the actual WebSocket connection to the DolphinDB corresponding to the URL
|
|
1401
|
+
- options?:
|
|
1402
|
+
- url?: DolphinDB WebSocket URL. By default, the WebSocket URL passed in when the instance is initialized is used
|
|
1403
|
+
- autologin?: Whether to log in automatically after establishing a connection, default `true`
|
|
1404
|
+
- username?: DolphinDB username, default `'admin'`
|
|
1405
|
+
- password?: DolphinDB password, default `'123456'`
|
|
1406
|
+
- python?: set python session flag, default `false`
|
|
1407
|
+
*/
|
|
1408
|
+
async connect(options = {}) {
|
|
1409
|
+
if (options.url !== undefined)
|
|
1410
|
+
this.url = options.url;
|
|
1411
|
+
if (options.autologin !== undefined)
|
|
1412
|
+
this.autologin = options.autologin;
|
|
1413
|
+
if (options.username !== undefined)
|
|
1414
|
+
this.username = options.username;
|
|
1415
|
+
if (options.password !== undefined)
|
|
1416
|
+
this.password = options.password;
|
|
1417
|
+
if (options.python !== undefined)
|
|
1418
|
+
this.python = options.python;
|
|
1317
1419
|
this.disconnect();
|
|
1318
|
-
let websocket = new ws_1.WebSocket(url, python ? ['python'] : [], {
|
|
1420
|
+
let websocket = new ws_1.WebSocket(this.url, this.python ? ['python'] : [], {
|
|
1319
1421
|
maxPayload: 2 ** 33 // 8 GB
|
|
1320
1422
|
});
|
|
1321
1423
|
// https://stackoverflow.com/questions/11821096/what-is-the-difference-between-an-arraybuffer-and-a-blob/39951543
|
|
@@ -1369,11 +1471,11 @@ class DDB {
|
|
|
1369
1471
|
' add_node_alias\n' +
|
|
1370
1472
|
' )\n' +
|
|
1371
1473
|
'}\n', { urgent: true });
|
|
1372
|
-
if (
|
|
1474
|
+
if (this.autologin)
|
|
1373
1475
|
if (this.python)
|
|
1374
|
-
await this.eval(`login(${username.quote('double')}, ${password.quote('double')})`, { urgent: true });
|
|
1476
|
+
await this.eval(`login(${this.username.quote('double')}, ${this.password.quote('double')})`, { urgent: true });
|
|
1375
1477
|
else
|
|
1376
|
-
await this.call('login', [username, password], { urgent: true });
|
|
1478
|
+
await this.call('login', [this.username, this.password], { urgent: true });
|
|
1377
1479
|
}
|
|
1378
1480
|
get_rpc_options({ urgent = false, secondary = false, async: _async = false, pickle = false, clear = false, api = false, compress = false, cancellable = true, priority = urgent ? 8 : 4, parallelism = 8, root_id = '', limit, } = {}) {
|
|
1379
1481
|
let flag = 0;
|