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/browser.d.ts CHANGED
@@ -184,7 +184,7 @@ export interface InspectOptions {
184
184
  export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
185
185
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
186
186
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
187
- 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> | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbArrayVectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue;
187
+ 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 | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | string[] | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue | DdbExtObjValue;
188
188
  /** 转换一个向量到 js 原生数组 */
189
189
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
190
190
  /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
@@ -616,6 +616,9 @@ export declare class DDB {
616
616
  define(definition: string, { urgent }?: {
617
617
  urgent?: boolean;
618
618
  }): Promise<string>;
619
+ /** 在 undef all, 或运行 test 函数之后,由于函数定义在 server 侧被清空,需要同步清空 api 侧缓存,
620
+ 使得下次调用 invoke, define 能够重新定义函数 */
621
+ reset_definitions(): void;
619
622
  }
620
623
  export interface DdbMessageListener {
621
624
  (message: DdbMessage, _this: DDB): any;
package/browser.js CHANGED
@@ -2942,12 +2942,20 @@ export class DDB {
2942
2942
  /** 取消当前 session id 对应的所有 console jobs Cancel all console jobs corresponding to the current session id */
2943
2943
  async cancel() {
2944
2944
  let ddb = new DDB(this.url, {
2945
- autologin: this.autologin,
2945
+ // 如果有 ticket,则认为能够自动登录,并启用,否则禁用,尝试一下用户名密码登录
2946
+ autologin: Boolean(this.ticket),
2946
2947
  ticket: this.ticket,
2947
2948
  username: this.username,
2948
2949
  password: this.password,
2949
2950
  verbose: this.verbose
2950
2951
  });
2952
+ if (!this.ticket)
2953
+ try {
2954
+ await this.invoke('login', [this.username, this.password]);
2955
+ }
2956
+ catch (error) {
2957
+ console.log(t('ddb.cancel 无 ticket,尝试通过密码 login 失败'));
2958
+ }
2951
2959
  try {
2952
2960
  // 因为是新建的连接,而且执行完脚本之后马上就关闭了,所以不用考虑变量泄漏的问题
2953
2961
  await ddb.eval(`jobs = exec rootJobId from getConsoleJobs() where sessionId = ${this.sid}\n` +
@@ -3132,6 +3140,12 @@ export class DDB {
3132
3140
  this.pdefinitions.delete(func_name);
3133
3141
  return func_name;
3134
3142
  }
3143
+ /** 在 undef all, 或运行 test 函数之后,由于函数定义在 server 侧被清空,需要同步清空 api 侧缓存,
3144
+ 使得下次调用 invoke, define 能够重新定义函数 */
3145
+ reset_definitions() {
3146
+ this.definitions.clear();
3147
+ this.pdefinitions.clear();
3148
+ }
3135
3149
  }
3136
3150
  /** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements
3137
3151
  SharedArrayBuffer is disabled by default in most browsers as a security precaution to avoid Spectre attacks.