dolphindb 3.1.2 → 3.1.5
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 +18 -4
- package/browser.js +74 -26
- package/browser.js.map +1 -1
- package/common.d.ts +24 -3
- package/common.js +54 -23
- package/common.js.map +1 -1
- package/i18n/dict.json +6 -0
- package/index.d.ts +18 -3
- package/index.js +74 -26
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/test.js.map +1 -1
package/browser.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Dayjs } from 'dayjs';
|
|
2
|
-
import 'xshell/prototype.browser.js';
|
|
3
2
|
import { Lock } from 'xshell/utils.browser.js';
|
|
4
3
|
import { type WebSocketConnectionError } from 'xshell/net.browser.js';
|
|
5
|
-
import { DdbChartType, DdbForm, DdbFunctionType, DdbType, DdbVoidType, type ConvertOptions, type DdbDecimal32Value, type DdbDecimal32VectorValue, type DdbDecimal64Value, type DdbDecimal64VectorValue, type DdbDurationValue, type DdbDurationVectorValue, type DdbFunctionDefValue, type DdbRpcType, type DdbScalarValue, type DdbSymbolExtendedValue, type DdbTableData, type DdbTensorValue, type IotVectorItemValue, type TensorData } from './common.ts';
|
|
4
|
+
import { DdbChartType, DdbForm, DdbFunctionType, DdbType, DdbVoidType, type ConvertOptions, type DdbDecimal32Value, type DdbDecimal32VectorValue, type DdbDecimal64Value, type DdbDecimal64VectorValue, type DdbDurationValue, type DdbDurationVectorValue, type DdbFunctionDefValue, type DdbRpcType, type DdbScalarValue, type DdbSymbolExtendedValue, type DdbTableData, type DdbTensorValue, type IotVectorItemValue, type TensorData, type DdbExtObjValue, type ConvertableDdbTimeValue } from './common.ts';
|
|
6
5
|
export * from './common.ts';
|
|
7
6
|
export interface DdbDecimal128VectorValue {
|
|
8
7
|
scale: number;
|
|
@@ -51,7 +50,7 @@ export interface DdbChartValue {
|
|
|
51
50
|
};
|
|
52
51
|
data: DdbMatrixObj;
|
|
53
52
|
}
|
|
54
|
-
export type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue | DdbTensorValue;
|
|
53
|
+
export type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue | DdbTensorValue | DdbExtObjValue;
|
|
55
54
|
export type DdbStringObj = DdbObj<string>;
|
|
56
55
|
export type DdbVectorObj<TValue extends DdbVectorValue = DdbVectorValue> = DdbObj<TValue>;
|
|
57
56
|
export type DdbVectorAnyObj = DdbVectorObj<DdbObj[]>;
|
|
@@ -185,7 +184,7 @@ export interface InspectOptions {
|
|
|
185
184
|
export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
|
|
186
185
|
/** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
|
|
187
186
|
export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
|
|
188
|
-
export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean |
|
|
187
|
+
export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | string[] | number[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbSymbolExtendedValue | DdbExtObjValue | DdbTensorValue | Uint8Array<ArrayBufferLike> | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbArrayVectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue;
|
|
189
188
|
/** 转换一个向量到 js 原生数组 */
|
|
190
189
|
export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
|
|
191
190
|
/** 构造 void 类型,默认为 `DdbVoidType.undefined` */
|
|
@@ -252,6 +251,21 @@ export declare class DdbVectorSymbol extends DdbObj<DdbSymbolExtendedValue> {
|
|
|
252
251
|
export declare class DdbVectorChar extends DdbObj<Int8Array> {
|
|
253
252
|
constructor(chars?: Uint8Array | Int8Array | ArrayBuffer, name?: string);
|
|
254
253
|
}
|
|
254
|
+
export declare class DdbVectorBool extends DdbObj<Int8Array> {
|
|
255
|
+
constructor(bools?: (boolean | null)[], name?: string);
|
|
256
|
+
}
|
|
257
|
+
export declare class DdbVectorDatetime extends DdbObj<Int32Array> {
|
|
258
|
+
constructor(datetimes: ConvertableDdbTimeValue[], name?: string);
|
|
259
|
+
}
|
|
260
|
+
export declare class DdbVectorTimeStamp extends DdbObj<BigInt64Array> {
|
|
261
|
+
constructor(timestamps: ConvertableDdbTimeValue[], name?: string);
|
|
262
|
+
}
|
|
263
|
+
export declare class DdbVectorNanoTimeStamp extends DdbObj<BigInt64Array> {
|
|
264
|
+
constructor(nanotimestamps: ConvertableDdbTimeValue[], name?: string);
|
|
265
|
+
}
|
|
266
|
+
export declare class DdbVectorDate extends DdbObj<BigInt64Array> {
|
|
267
|
+
constructor(dates: ConvertableDdbTimeValue[], name?: string);
|
|
268
|
+
}
|
|
255
269
|
export declare class DdbSetInt extends DdbObj<Int32Array> {
|
|
256
270
|
constructor(ints: (number | null)[] | Set<number> | Int32Array);
|
|
257
271
|
}
|
package/browser.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import 'xshell/prototype.browser.js';
|
|
1
|
+
import { empty } from 'xshell/prototype.browser.js';
|
|
2
2
|
import { blue, cyan, green, grey, magenta } from 'xshell/chalk.browser.js';
|
|
3
3
|
import { concat, assert, Lock, genid, seq, zip_object, decode, delay, check } from 'xshell/utils.browser.js';
|
|
4
4
|
import { connect_websocket } from 'xshell/net.browser.js';
|
|
5
5
|
import { t } from "./i18n/index.js";
|
|
6
|
-
import { date2str, datehour2str, datetime2str, ddb_tensor_bytes, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType, dictables, function_definition_pattern, generate_array_type, get_big_int_128,
|
|
6
|
+
import { date2str, datehour2str, datetime2str, ddb_tensor_bytes, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType, dictables, function_definition_pattern, generate_array_type, get_big_int_128, get_time_ddbobj, get_duration_unit, get_type_name, int1282str, ipaddr2str, is_decimal_null_value, is_decimal_type, minute2str, month2str, nanotime2str, nanotimestamp2str, nulls, second2str, set_big_int_128, time2str, timestamp2str, uuid2str, get_times_ddbobj } from "./common.js";
|
|
7
7
|
export * from "./common.js";
|
|
8
8
|
/** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
|
|
9
9
|
export class DdbObj {
|
|
@@ -283,6 +283,23 @@ export class DdbObj {
|
|
|
283
283
|
}
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
|
+
case DdbForm.extobj: {
|
|
287
|
+
const dv = new DataView(buf_data.buffer, buf_data.byteOffset, buf_data.byteLength);
|
|
288
|
+
const version_and_size = dv.getUint32(4, le);
|
|
289
|
+
const length = version_and_size & 0x00ffffff;
|
|
290
|
+
return new this({
|
|
291
|
+
le,
|
|
292
|
+
form,
|
|
293
|
+
type,
|
|
294
|
+
// 低 24 位为 size
|
|
295
|
+
length: i_data + 8 + length,
|
|
296
|
+
value: {
|
|
297
|
+
type: buf_data.subarray(0, 4),
|
|
298
|
+
version: (version_and_size >>> 24) & 0xff,
|
|
299
|
+
data: buf_data.subarray(8, 8 + length)
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
286
303
|
default:
|
|
287
304
|
return new this({
|
|
288
305
|
le,
|
|
@@ -989,8 +1006,14 @@ export class DdbObj {
|
|
|
989
1006
|
uint8Array.set(data, dataStart);
|
|
990
1007
|
return [uint8Array];
|
|
991
1008
|
}
|
|
1009
|
+
case DdbForm.extobj: {
|
|
1010
|
+
const { data, type: exttype, version } = value;
|
|
1011
|
+
let version_and_size = new Uint8Array(4);
|
|
1012
|
+
version_and_size.dataview.setUint32(0, (version << 24) | data.length, this.le);
|
|
1013
|
+
return [exttype, version_and_size, data];
|
|
1014
|
+
}
|
|
992
1015
|
default:
|
|
993
|
-
throw new Error(t('
|
|
1016
|
+
throw new Error(t('{{form}} 暂不支持序列化', { form: DdbForm[form] || `form ${form}` }));
|
|
994
1017
|
}
|
|
995
1018
|
})();
|
|
996
1019
|
if (!body)
|
|
@@ -1148,7 +1171,7 @@ export class DdbObj {
|
|
|
1148
1171
|
case DdbForm.tensor: {
|
|
1149
1172
|
const { data_type, tensor_type, device_type, tensor_flags, dimensions, shape, strides, preserve_value, elem_count, data, } = this.value;
|
|
1150
1173
|
const dataByte = ddb_tensor_bytes[data_type];
|
|
1151
|
-
|
|
1174
|
+
return {
|
|
1152
1175
|
data_type,
|
|
1153
1176
|
tensor_type,
|
|
1154
1177
|
device_type,
|
|
@@ -1160,10 +1183,12 @@ export class DdbObj {
|
|
|
1160
1183
|
elem_count,
|
|
1161
1184
|
data: DdbObj.parse_tensor({ currentDim: 0, dimensions, rawData: data, le: this.le, dataByte, dataType: data_type, shape, strides })
|
|
1162
1185
|
};
|
|
1163
|
-
return returnData;
|
|
1164
1186
|
}
|
|
1187
|
+
case DdbForm.extobj:
|
|
1188
|
+
// return (this.value as DdbExtObjValue).data as TResult
|
|
1189
|
+
return `ExtObj<${get_type_name(type)}>`;
|
|
1165
1190
|
default:
|
|
1166
|
-
throw new Error(t('{{form}} {{type}} 暂不支持 data()', { form, type: get_type_name(type) }));
|
|
1191
|
+
throw new Error(t('{{form}} {{type}} 暂不支持 data()', { form: DdbForm[form] || form, type: get_type_name(type) }));
|
|
1167
1192
|
}
|
|
1168
1193
|
}
|
|
1169
1194
|
/** 构建 Tensor
|
|
@@ -2072,38 +2097,22 @@ export class DdbDouble extends DdbObj {
|
|
|
2072
2097
|
}
|
|
2073
2098
|
export class DdbDateTime extends DdbObj {
|
|
2074
2099
|
constructor(value) {
|
|
2075
|
-
super(
|
|
2076
|
-
form: DdbForm.scalar,
|
|
2077
|
-
type: DdbType.datetime,
|
|
2078
|
-
value: get_ddb_time_value('DdbDateTime', value)
|
|
2079
|
-
});
|
|
2100
|
+
super(get_time_ddbobj(DdbType.datetime, value));
|
|
2080
2101
|
}
|
|
2081
2102
|
}
|
|
2082
2103
|
export class DdbTimeStamp extends DdbObj {
|
|
2083
2104
|
constructor(value) {
|
|
2084
|
-
super(
|
|
2085
|
-
form: DdbForm.scalar,
|
|
2086
|
-
type: DdbType.timestamp,
|
|
2087
|
-
value: get_ddb_time_value('DdbTimeStamp', value)
|
|
2088
|
-
});
|
|
2105
|
+
super(get_time_ddbobj(DdbType.timestamp, value));
|
|
2089
2106
|
}
|
|
2090
2107
|
}
|
|
2091
2108
|
export class DdbNanoTimeStamp extends DdbObj {
|
|
2092
2109
|
constructor(value) {
|
|
2093
|
-
super(
|
|
2094
|
-
form: DdbForm.scalar,
|
|
2095
|
-
type: DdbType.nanotimestamp,
|
|
2096
|
-
value: get_ddb_time_value('DdbNanoTimeStamp', value)
|
|
2097
|
-
});
|
|
2110
|
+
super(get_time_ddbobj(DdbType.nanotimestamp, value));
|
|
2098
2111
|
}
|
|
2099
2112
|
}
|
|
2100
2113
|
export class DdbDate extends DdbObj {
|
|
2101
2114
|
constructor(value) {
|
|
2102
|
-
super(
|
|
2103
|
-
form: DdbForm.scalar,
|
|
2104
|
-
type: DdbType.date,
|
|
2105
|
-
value: get_ddb_time_value('DdbDate', value)
|
|
2106
|
-
});
|
|
2115
|
+
super(get_time_ddbobj(DdbType.date, value));
|
|
2107
2116
|
}
|
|
2108
2117
|
}
|
|
2109
2118
|
export class DdbBlob extends DdbObj {
|
|
@@ -2266,6 +2275,45 @@ export class DdbVectorChar extends DdbObj {
|
|
|
2266
2275
|
});
|
|
2267
2276
|
}
|
|
2268
2277
|
}
|
|
2278
|
+
export class DdbVectorBool extends DdbObj {
|
|
2279
|
+
constructor(bools, name) {
|
|
2280
|
+
const length = bools?.length || 0;
|
|
2281
|
+
let value = new Int8Array(length);
|
|
2282
|
+
if (length)
|
|
2283
|
+
for (let i = 0; i < length; ++i) {
|
|
2284
|
+
const x = bools[i];
|
|
2285
|
+
value[i] = empty(x) ? nulls.int8 : x ? 1 : 0;
|
|
2286
|
+
}
|
|
2287
|
+
super({
|
|
2288
|
+
form: DdbForm.vector,
|
|
2289
|
+
type: DdbType.bool,
|
|
2290
|
+
rows: length,
|
|
2291
|
+
cols: 1,
|
|
2292
|
+
value,
|
|
2293
|
+
name
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
export class DdbVectorDatetime extends DdbObj {
|
|
2298
|
+
constructor(datetimes, name) {
|
|
2299
|
+
super(get_times_ddbobj(DdbType.datetime, datetimes, name));
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
export class DdbVectorTimeStamp extends DdbObj {
|
|
2303
|
+
constructor(timestamps, name) {
|
|
2304
|
+
super(get_times_ddbobj(DdbType.timestamp, timestamps, name));
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
export class DdbVectorNanoTimeStamp extends DdbObj {
|
|
2308
|
+
constructor(nanotimestamps, name) {
|
|
2309
|
+
super(get_times_ddbobj(DdbType.nanotimestamp, nanotimestamps, name));
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
export class DdbVectorDate extends DdbObj {
|
|
2313
|
+
constructor(dates, name) {
|
|
2314
|
+
super(get_times_ddbobj(DdbType.date, dates, name));
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2269
2317
|
export class DdbSetInt extends DdbObj {
|
|
2270
2318
|
constructor(ints) {
|
|
2271
2319
|
super({
|