Skip to content

Commit

Permalink
compatible with darabonba v2
Browse files Browse the repository at this point in the history
  • Loading branch information
peze authored and yndu13 committed Jan 16, 2025
1 parent 9bd903f commit 36ba0a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 90 deletions.
1 change: 1 addition & 0 deletions ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"dependencies": {
"@alicloud/tea-typescript": "^1.5.1",
"@darabonba/typescript": "^1.0.0",
"kitx": "^2.0.0"
},
"files": [
Expand Down
93 changes: 5 additions & 88 deletions ts/src/client.ts
Original file line number Diff line number Diff line change
@@ -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<Buffer> {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -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<void> {
Expand All @@ -323,7 +240,7 @@ export default class Client {
if (!model) {
return;
}
ret.push($tea.toMap(model));
ret.push($dara.toMap(model));
})
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions ts/test/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 36ba0a0

Please sign in to comment.