dolphindb 3.1.30 → 3.1.33

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/i18n/dict.json CHANGED
@@ -121,5 +121,8 @@
121
121
  },
122
122
  "value 不能转换为 {{typename}}": {
123
123
  "en": "value cannot be converted to {{typename}}"
124
+ },
125
+ "ddb.cancel 无 ticket,尝试通过密码 login 失败": {
126
+ "en": "ddb.cancel has no ticket, attempt to login using password failed"
124
127
  }
125
128
  }
package/index.d.ts CHANGED
@@ -174,7 +174,7 @@ export interface InspectOptions extends UtilInspectOptions {
174
174
  export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
175
175
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
176
176
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
177
- export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | number[] | string[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbSymbolExtendedValue | DdbExtObjValue | DdbTensorValue | Uint8Array<ArrayBufferLike> | IotVectorItemValue | DdbDurationVectorValue | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | DdbArrayVectorValue | DdbDecimal128VectorValue | DdbMatrixValue | DdbChartValue;
177
+ export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | number[] | Uint8Array<ArrayBufferLike> | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | string[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDurationVectorValue | DdbTensorValue | DdbExtObjValue | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | DdbArrayVectorValue | DdbDecimal128VectorValue | DdbMatrixValue | DdbChartValue;
178
178
  /** 转换一个向量到 js 原生数组 */
179
179
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
180
180
  /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
@@ -607,6 +607,9 @@ export declare class DDB {
607
607
  define(definition: string, { urgent }?: {
608
608
  urgent?: boolean;
609
609
  }): Promise<string>;
610
+ /** 在 undef all, 或运行 test 函数之后,由于函数定义在 server 侧被清空,需要同步清空 api 侧缓存,
611
+ 使得下次调用 invoke, define 能够重新定义函数 */
612
+ reset_definitions(): void;
610
613
  }
611
614
  export interface DdbMessageListener {
612
615
  (message: DdbMessage, _this: DDB): any;
package/index.js CHANGED
@@ -2908,13 +2908,21 @@ export class DDB {
2908
2908
  /** 取消当前 session id 对应的所有 console jobs Cancel all console jobs corresponding to the current session id */
2909
2909
  async cancel() {
2910
2910
  let ddb = new DDB(this.url, {
2911
- autologin: this.autologin,
2911
+ // 如果有 ticket,则认为能够自动登录,并启用,否则禁用,尝试一下用户名密码登录
2912
+ autologin: Boolean(this.ticket),
2912
2913
  ticket: this.ticket,
2913
2914
  username: this.username,
2914
2915
  password: this.password,
2915
2916
  proxy: this.proxy,
2916
2917
  verbose: this.verbose
2917
2918
  });
2919
+ if (!this.ticket)
2920
+ try {
2921
+ await this.invoke('login', [this.username, this.password]);
2922
+ }
2923
+ catch (error) {
2924
+ console.log(t('ddb.cancel 无 ticket,尝试通过密码 login 失败'));
2925
+ }
2918
2926
  try {
2919
2927
  // 因为是新建的连接,而且执行完脚本之后马上就关闭了,所以不用考虑变量泄漏的问题
2920
2928
  await ddb.eval(`jobs = exec rootJobId from getConsoleJobs() where sessionId = ${this.sid}\n` +
@@ -3099,6 +3107,12 @@ export class DDB {
3099
3107
  this.pdefinitions.delete(func_name);
3100
3108
  return func_name;
3101
3109
  }
3110
+ /** 在 undef all, 或运行 test 函数之后,由于函数定义在 server 侧被清空,需要同步清空 api 侧缓存,
3111
+ 使得下次调用 invoke, define 能够重新定义函数 */
3112
+ reset_definitions() {
3113
+ this.definitions.clear();
3114
+ this.pdefinitions.clear();
3115
+ }
3102
3116
  }
3103
3117
  export class BigInt128Array {
3104
3118
  static of(...items) {