From 296cd625d48d5a93d22ac737ca738b8fd748e282 Mon Sep 17 00:00:00 2001 From: peze <954152927@qq.com> Date: Fri, 13 Dec 2024 10:54:24 +0800 Subject: [PATCH 1/2] compatible with darabonba v2 --- ts/package.json | 1 + ts/src/client.ts | 93 +++--------------------------------------- ts/test/client.spec.ts | 4 +- 3 files changed, 8 insertions(+), 90 deletions(-) diff --git a/ts/package.json b/ts/package.json index 5667a56..463030b 100644 --- a/ts/package.json +++ b/ts/package.json @@ -22,6 +22,7 @@ }, "dependencies": { "@alicloud/tea-typescript": "^1.5.1", + "@darabonba/typescript": "^1.0.0", "kitx": "^2.0.0" }, "files": [ diff --git a/ts/src/client.ts b/ts/src/client.ts index 3e0f601..d64e057 100644 --- a/ts/src/client.ts +++ b/ts/src/client.ts @@ -1,95 +1,12 @@ import { Readable } from 'stream'; +import * as $dara from '@darabonba/typescript'; import * as $tea from '@alicloud/tea-typescript'; import * as kitx from 'kitx'; import querystring from 'querystring'; import { platform, arch } from 'os'; -const DEFAULT_USER_AGENT = `AlibabaCloud (${platform()}; ${arch()}) Node.js/${process.version} Core/1.0.1 TeaDSL/1`; - -export class ExtendsParameters extends $tea.Model { - headers?: { [key: string]: string }; - queries?: { [key: string]: string }; - static names(): { [key: string]: string } { - return { - headers: 'headers', - queries: 'queries', - }; - } - - static types(): { [key: string]: any } { - return { - headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' }, - queries: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' }, - }; - } - - constructor(map?: { [key: string]: any }) { - super(map); - } -} +const DEFAULT_USER_AGENT = `AlibabaCloud (${platform()}; ${arch()}) Node.js/${process.version} Core/1.0.1 TeaDSL/2`; -export class RuntimeOptions extends $tea.Model { - autoretry?: boolean; - ignoreSSL?: boolean; - key?: string; - cert?: string; - ca?: string; - maxAttempts?: number; - backoffPolicy?: string; - backoffPeriod?: number; - readTimeout?: number; - connectTimeout?: number; - httpProxy?: string; - httpsProxy?: string; - noProxy?: string; - maxIdleConns?: number; - keepAlive?: boolean; - extendsParameters?: ExtendsParameters; - static names(): { [key: string]: string } { - return { - autoretry: 'autoretry', - ignoreSSL: 'ignoreSSL', - key: 'key', - cert: 'cert', - ca: 'ca', - maxAttempts: 'max_attempts', - backoffPolicy: 'backoff_policy', - backoffPeriod: 'backoff_period', - readTimeout: 'readTimeout', - connectTimeout: 'connectTimeout', - httpProxy: 'httpProxy', - httpsProxy: 'httpsProxy', - noProxy: 'noProxy', - maxIdleConns: 'maxIdleConns', - keepAlive: 'keepAlive', - extendsParameters: 'extendsParameters', - }; - } - - static types(): { [key: string]: any } { - return { - autoretry: 'boolean', - ignoreSSL: 'boolean', - key: 'string', - cert: 'string', - ca: 'string', - maxAttempts: 'number', - backoffPolicy: 'string', - backoffPeriod: 'number', - readTimeout: 'number', - connectTimeout: 'number', - httpProxy: 'string', - httpsProxy: 'string', - noProxy: 'string', - maxIdleConns: 'number', - keepAlive: 'boolean', - extendsParameters: ExtendsParameters, - }; - } - - constructor(map?: { [key: string]: any }) { - super(map); - } -} +export { ExtendsParameters, RuntimeOptions } from '@darabonba/typescript'; function read(readable: Readable): Promise { return new Promise((resolve, reject) => { @@ -303,7 +220,7 @@ export default class Client { } static toMap(inputModel: $tea.Model): { [key: string]: any } { - return $tea.toMap(inputModel); + return $dara.toMap(inputModel); } static async sleep(millisecond: number): Promise { @@ -323,7 +240,7 @@ export default class Client { if (!model) { return; } - ret.push($tea.toMap(model)); + ret.push($dara.toMap(model)); }) return ret; } diff --git a/ts/test/client.spec.ts b/ts/test/client.spec.ts index 3719f11..c2b41ab 100644 --- a/ts/test/client.spec.ts +++ b/ts/test/client.spec.ts @@ -288,8 +288,8 @@ describe('Tea Util', function () { }); it('getUserAgent', function () { - assert.strictEqual(Client.getUserAgent(''), `AlibabaCloud (${platform()}; ${arch()}) Node.js/${process.version} Core/1.0.1 TeaDSL/1`); - assert.strictEqual(Client.getUserAgent('2019'), `AlibabaCloud (${platform()}; ${arch()}) Node.js/${process.version} Core/1.0.1 TeaDSL/1 2019`); + assert.strictEqual(Client.getUserAgent(''), `AlibabaCloud (${platform()}; ${arch()}) Node.js/${process.version} Core/1.0.1 TeaDSL/2`); + assert.strictEqual(Client.getUserAgent('2019'), `AlibabaCloud (${platform()}; ${arch()}) Node.js/${process.version} Core/1.0.1 TeaDSL/2 2019`); }); it('is2xx', function () { From 4b28aa44f1f2712cc36cfb8de4c60540080cdb34 Mon Sep 17 00:00:00 2001 From: peze <954152927@qq.com> Date: Thu, 16 Jan 2025 15:56:05 +0800 Subject: [PATCH 2/2] [ts]Bump 1.4.10 --- ts/ChangeLog.txt | 3 +++ ts/package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ts/ChangeLog.txt b/ts/ChangeLog.txt index d50f9a9..19051e0 100644 --- a/ts/ChangeLog.txt +++ b/ts/ChangeLog.txt @@ -1,3 +1,6 @@ +2025-01-16 Version 1.4.10 +1. Compatible with Darbaonba 2.0 + 2024-07-08 Version 1.4.9 1. Support extends query parameters diff --git a/ts/package.json b/ts/package.json index 463030b..3f13f8d 100644 --- a/ts/package.json +++ b/ts/package.json @@ -1,6 +1,6 @@ { "name": "@alicloud/tea-util", - "version": "1.4.9", + "version": "1.4.10", "description": "", "main": "dist/client.js", "scripts": {