dolphindb 2.0.1000 → 2.0.1002
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 +14 -0
- package/README.zh.md +15 -0
- package/browser.d.ts +10 -0
- package/browser.js +26 -12
- package/browser.js.map +1 -1
- package/docs.zh.json +4106 -337
- package/index.d.ts +10 -0
- package/index.js +26 -12
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -375,11 +375,18 @@ export declare class DdbDatabaseError extends Error {
|
|
|
375
375
|
options: DdbRpcOptions;
|
|
376
376
|
constructor(message: string, ddb: DDB, type: DdbRpcType, options: DdbRpcOptions);
|
|
377
377
|
}
|
|
378
|
+
/** SQL Standrd 标准类型 */
|
|
379
|
+
export declare enum SqlStandard {
|
|
380
|
+
DolphinDB = 0,
|
|
381
|
+
Oracle = 1,
|
|
382
|
+
MySQL = 2
|
|
383
|
+
}
|
|
378
384
|
export interface DdbOptions {
|
|
379
385
|
autologin?: boolean;
|
|
380
386
|
username?: string;
|
|
381
387
|
password?: string;
|
|
382
388
|
python?: boolean;
|
|
389
|
+
sql?: SqlStandard;
|
|
383
390
|
streaming?: StreamingParams;
|
|
384
391
|
verbose?: boolean;
|
|
385
392
|
}
|
|
@@ -407,6 +414,8 @@ export declare class DDB {
|
|
|
407
414
|
password: string;
|
|
408
415
|
/** python session flag (2048) */
|
|
409
416
|
python: boolean;
|
|
417
|
+
/** 表示本次会话执行的 SQL 标准 */
|
|
418
|
+
sql: SqlStandard;
|
|
410
419
|
/** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
|
|
411
420
|
streaming: StreamingData;
|
|
412
421
|
/** 是否打印每个 rpc 的信息用于调试 */
|
|
@@ -440,6 +449,7 @@ export declare class DDB {
|
|
|
440
449
|
- python?: 设置 python session flag,默认 `false` set python session flag, default `false`
|
|
441
450
|
- streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
|
|
442
451
|
- verbose?: 是否打印每个 rpc 的信息用于调试
|
|
452
|
+
- sql?: 设置当前会话执行的 sql 标准, 请使用 SqlStandard 枚举进行传参,默认 `DolphinDB`
|
|
443
453
|
|
|
444
454
|
@example
|
|
445
455
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
package/index.js
CHANGED
|
@@ -1217,10 +1217,12 @@ export class DdbObj {
|
|
|
1217
1217
|
}
|
|
1218
1218
|
}
|
|
1219
1219
|
/** 整数一定用这个 number formatter, InspectOptions.decimals 不传也用这个 */
|
|
1220
|
-
let default_formatter = Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
1220
|
+
let default_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
1221
1221
|
let _decimals = 20;
|
|
1222
1222
|
/** 缓存,为了优化性能,通常 options.decimals 都是不变的 */
|
|
1223
|
-
let _formatter = Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
1223
|
+
let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
1224
|
+
/** 用来处理时差 To deal with jet lag */
|
|
1225
|
+
let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC' });
|
|
1224
1226
|
/** 根据 DdbType 格式化单个元素 (value) 为字符串,空值返回 'null' 字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
1225
1227
|
export function format(type, value, le, options = {}) {
|
|
1226
1228
|
const { decimals } = options;
|
|
@@ -1229,7 +1231,7 @@ export function format(type, value, le, options = {}) {
|
|
|
1229
1231
|
return default_formatter;
|
|
1230
1232
|
if (decimals !== _decimals) {
|
|
1231
1233
|
_decimals = decimals;
|
|
1232
|
-
_formatter = Intl.NumberFormat('en-US', { maximumFractionDigits: decimals, minimumFractionDigits: decimals });
|
|
1234
|
+
_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: decimals, minimumFractionDigits: decimals });
|
|
1233
1235
|
}
|
|
1234
1236
|
return _formatter;
|
|
1235
1237
|
})();
|
|
@@ -1922,8 +1924,8 @@ export function second2str(second, format = 'HH:mm:ss') {
|
|
|
1922
1924
|
export function datetime2ms(datetime) {
|
|
1923
1925
|
if (datetime === null || datetime === nulls.int32)
|
|
1924
1926
|
return null;
|
|
1925
|
-
const
|
|
1926
|
-
return
|
|
1927
|
+
const date = new Date(1000 * datetime);
|
|
1928
|
+
return dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
|
|
1927
1929
|
}
|
|
1928
1930
|
export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
1929
1931
|
return (datetime === null || datetime === nulls.int32) ?
|
|
@@ -1934,8 +1936,8 @@ export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
|
1934
1936
|
export function timestamp2ms(timestamp) {
|
|
1935
1937
|
if (timestamp === null || timestamp === nulls.int64)
|
|
1936
1938
|
return null;
|
|
1937
|
-
const
|
|
1938
|
-
return
|
|
1939
|
+
const date = new Date(Number(timestamp));
|
|
1940
|
+
return dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
|
|
1939
1941
|
}
|
|
1940
1942
|
/** format timestamp (bigint) to string
|
|
1941
1943
|
- timestamp: bigint value
|
|
@@ -1998,8 +2000,8 @@ export function nanotime2str(nanotime, format = 'HH:mm:ss.SSSSSSSSS') {
|
|
|
1998
2000
|
export function nanotimestamp2ns(nanotimestamp) {
|
|
1999
2001
|
if (nanotimestamp === null || nanotimestamp === nulls.int64)
|
|
2000
2002
|
return null;
|
|
2001
|
-
const
|
|
2002
|
-
return BigInt(
|
|
2003
|
+
const date = new Date(Number(nanotimestamp / 1000000n));
|
|
2004
|
+
return BigInt(dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf()) * 1000000n + nanotimestamp % 1000000n;
|
|
2003
2005
|
}
|
|
2004
2006
|
/** format nanotimestamp value (bigint) to string
|
|
2005
2007
|
- nanotimestamp: bigint value
|
|
@@ -2025,9 +2027,7 @@ export function nanotimestamp2str(nanotimestamp, format = 'YYYY.MM.DD HH:mm:ss.S
|
|
|
2025
2027
|
const remainder = nanotimestamp % 1000000000n;
|
|
2026
2028
|
const borrow = remainder < 0n;
|
|
2027
2029
|
const ms = Number(nanotimestamp / 1000000n);
|
|
2028
|
-
return (dayjs(
|
|
2029
|
-
// 去掉 9 位的纳秒部分,转化为毫秒
|
|
2030
|
-
Number((nanotimestamp - remainder + (borrow ? -1000000000n : 0n)) / 1000000n)).format(format.slice(0, i_second_end)) +
|
|
2030
|
+
return (dayjs(_datetime_formatter.format(new Date(ms))).format(format.slice(0, i_second_end)) +
|
|
2031
2031
|
format.slice(i_second_end, i_nanosecond_start) +
|
|
2032
2032
|
String(borrow ?
|
|
2033
2033
|
(remainder + 1000000000n) % 1000000000n
|
|
@@ -2104,6 +2104,13 @@ export class DdbDatabaseError extends Error {
|
|
|
2104
2104
|
this.options = options;
|
|
2105
2105
|
}
|
|
2106
2106
|
}
|
|
2107
|
+
/** SQL Standrd 标准类型 */
|
|
2108
|
+
export var SqlStandard;
|
|
2109
|
+
(function (SqlStandard) {
|
|
2110
|
+
SqlStandard[SqlStandard["DolphinDB"] = 0] = "DolphinDB";
|
|
2111
|
+
SqlStandard[SqlStandard["Oracle"] = 1] = "Oracle";
|
|
2112
|
+
SqlStandard[SqlStandard["MySQL"] = 2] = "MySQL";
|
|
2113
|
+
})(SqlStandard || (SqlStandard = {}));
|
|
2107
2114
|
export class DDB {
|
|
2108
2115
|
/** 当前的 session id (http 或 tcp) */
|
|
2109
2116
|
sid = '0';
|
|
@@ -2133,6 +2140,8 @@ export class DDB {
|
|
|
2133
2140
|
password = '123456';
|
|
2134
2141
|
/** python session flag (2048) */
|
|
2135
2142
|
python = false;
|
|
2143
|
+
/** 表示本次会话执行的 SQL 标准 */
|
|
2144
|
+
sql = SqlStandard.DolphinDB;
|
|
2136
2145
|
/** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
|
|
2137
2146
|
streaming = null;
|
|
2138
2147
|
/** 是否打印每个 rpc 的信息用于调试 */
|
|
@@ -2171,6 +2180,7 @@ export class DDB {
|
|
|
2171
2180
|
- python?: 设置 python session flag,默认 `false` set python session flag, default `false`
|
|
2172
2181
|
- streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
|
|
2173
2182
|
- verbose?: 是否打印每个 rpc 的信息用于调试
|
|
2183
|
+
- sql?: 设置当前会话执行的 sql 标准, 请使用 SqlStandard 枚举进行传参,默认 `DolphinDB`
|
|
2174
2184
|
|
|
2175
2185
|
@example
|
|
2176
2186
|
let ddb = new DDB('ws://127.0.0.1:8848')
|
|
@@ -2194,6 +2204,8 @@ export class DDB {
|
|
|
2194
2204
|
this.password = options.password;
|
|
2195
2205
|
if (options.python !== undefined)
|
|
2196
2206
|
this.python = options.python;
|
|
2207
|
+
if (options.sql !== undefined)
|
|
2208
|
+
this.sql = options.sql;
|
|
2197
2209
|
if (options.streaming !== undefined)
|
|
2198
2210
|
this.streaming = options.streaming;
|
|
2199
2211
|
}
|
|
@@ -2282,6 +2294,8 @@ export class DDB {
|
|
|
2282
2294
|
// python session
|
|
2283
2295
|
if (this.python)
|
|
2284
2296
|
flag += 2048;
|
|
2297
|
+
// sql standrd
|
|
2298
|
+
flag += 2 ** 19 * this.sql;
|
|
2285
2299
|
const options = [
|
|
2286
2300
|
flag,
|
|
2287
2301
|
cancellable ? 1 : 0,
|