dolphindb 2.0.1027 → 2.0.1029
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 +6 -0
- package/browser.js +7 -2
- package/browser.js.map +1 -1
- package/index.d.ts +6 -0
- package/index.js +7 -2
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -321,6 +321,12 @@ export declare function int1282str(buffer: Uint8Array, le?: boolean): string;
|
|
|
321
321
|
export interface StreamingParams {
|
|
322
322
|
table: string;
|
|
323
323
|
action?: string;
|
|
324
|
+
filters?: {
|
|
325
|
+
/** https://docs.dolphindb.cn/zh/help/FunctionsandCommands/FunctionReferences/s/subscribeTable.html#:~:text=%E8%BF%9E%E6%8E%A5%E6%96%B0%E7%9A%84%20leader%E3%80%82-,filter%20%E5%8F%82%E6%95%B0%E9%9C%80%E8%A6%81%E9%85%8D%E5%90%88,-setStreamTableFilterColumn%20%E5%87%BD%E6%95%B0%E4%B8%80%E8%B5%B7 */
|
|
326
|
+
column?: DdbObj;
|
|
327
|
+
/** 过滤条件的 DolphinDB 表达式 https://dolphindb1.atlassian.net/wiki/spaces/dev/pages/760840447/WebSocketConsole */
|
|
328
|
+
expression?: string;
|
|
329
|
+
};
|
|
324
330
|
handler(message: StreamingMessage): any;
|
|
325
331
|
}
|
|
326
332
|
export interface StreamingMessage extends StreamingParams {
|
package/index.js
CHANGED
|
@@ -2290,8 +2290,11 @@ export class DDB {
|
|
|
2290
2290
|
reject(this.error /* 一定有,不需要再 || new DdbConnectionError(this) */);
|
|
2291
2291
|
};
|
|
2292
2292
|
try {
|
|
2293
|
+
let url = new URL(this.url);
|
|
2294
|
+
if (this.streaming?.filters?.expression)
|
|
2295
|
+
url.searchParams.set('filter', this.streaming.filters.expression.trim());
|
|
2293
2296
|
// 连接建立之前应该不会有别的调用占用 this.lwebsocket
|
|
2294
|
-
this.lwebsocket.resource = await connect_websocket(
|
|
2297
|
+
this.lwebsocket.resource = await connect_websocket(url, {
|
|
2295
2298
|
protocols: this.streaming ? ['streaming'] : this.python ? ['python'] : undefined,
|
|
2296
2299
|
on_message: (buffer, websocket) => {
|
|
2297
2300
|
this.on_message(new Uint8Array(buffer), websocket);
|
|
@@ -2690,6 +2693,7 @@ export class DDB {
|
|
|
2690
2693
|
segments: [],
|
|
2691
2694
|
};
|
|
2692
2695
|
let schema;
|
|
2696
|
+
let first_message = true;
|
|
2693
2697
|
const { value: colnames } = await this.call('publishTable', [
|
|
2694
2698
|
'localhost',
|
|
2695
2699
|
new DdbInt(0),
|
|
@@ -2707,8 +2711,9 @@ export class DDB {
|
|
|
2707
2711
|
const i_topic_end = buffer.indexOf(0, 17);
|
|
2708
2712
|
// 首个 message 一定是 table schema, 后续消息是 column 片段组成的 any vector
|
|
2709
2713
|
const data = DdbObj.parse(buffer.subarray(i_topic_end + 1), this.le);
|
|
2710
|
-
if (
|
|
2714
|
+
if (first_message) {
|
|
2711
2715
|
schema = data;
|
|
2716
|
+
first_message = false;
|
|
2712
2717
|
return;
|
|
2713
2718
|
}
|
|
2714
2719
|
assert(schema, t('流数据订阅后一定先返回 schema'));
|