@cloudbase/node-sdk 3.14.0-alpha.0 → 3.14.1
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/dist/cloudbase.js +4 -3
- package/dist/utils/tcbopenapicommonrequester.js +2 -1
- package/dist/utils/tcbopenapiendpoint.js +11 -2
- package/dist/utils/tcbopenapirequester.js +1 -1
- package/package.json +1 -1
- package/src/cloudbase.ts +4 -3
- package/src/utils/tcbopenapicommonrequester.ts +2 -1
- package/src/utils/tcbopenapiendpoint.ts +19 -3
- package/src/utils/tcbopenapirequester.ts +1 -1
- package/types/index.d.ts +1 -0
package/dist/cloudbase.js
CHANGED
|
@@ -115,8 +115,8 @@ class CloudBase {
|
|
|
115
115
|
token: (await this.auth().getClientCredential()).access_token
|
|
116
116
|
});
|
|
117
117
|
return result.body;
|
|
118
|
-
}, (0, tcbopenapiendpoint_1.buildCommonOpenApiUrlWithPath)({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/model' }), {
|
|
119
|
-
sqlBaseUrl: (0, tcbopenapiendpoint_1.buildCommonOpenApiUrlWithPath)({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/sql' })
|
|
118
|
+
}, (0, tcbopenapiendpoint_1.buildCommonOpenApiUrlWithPath)({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/model', region: this.config.region }), {
|
|
119
|
+
sqlBaseUrl: (0, tcbopenapiendpoint_1.buildCommonOpenApiUrlWithPath)({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/sql', region: this.config.region })
|
|
120
120
|
});
|
|
121
121
|
this.models = httpClient;
|
|
122
122
|
}
|
|
@@ -133,7 +133,8 @@ class CloudBase {
|
|
|
133
133
|
mysqlBaseUrl: (0, tcbopenapiendpoint_1.buildCommonOpenApiUrlWithPath)({
|
|
134
134
|
serviceUrl: this.config.serviceUrl,
|
|
135
135
|
envId,
|
|
136
|
-
path: '/v1/rdb/rest'
|
|
136
|
+
path: '/v1/rdb/rest',
|
|
137
|
+
region: this.config.region
|
|
137
138
|
}),
|
|
138
139
|
fetch: async (url, options) => {
|
|
139
140
|
var _a;
|
|
@@ -88,7 +88,8 @@ class TcbOpenApiHttpCommonRequester {
|
|
|
88
88
|
: args.config.envName;
|
|
89
89
|
const url = args.url || (0, tcbopenapiendpoint_1.buildCommonOpenApiUrlWithPath)({
|
|
90
90
|
envId,
|
|
91
|
-
path: args.path
|
|
91
|
+
path: args.path,
|
|
92
|
+
region: config.region
|
|
92
93
|
});
|
|
93
94
|
const timeout = ((_a = this.args.opts) === null || _a === void 0 ? void 0 : _a.timeout) || this.config.timeout || this.defaultTimeout;
|
|
94
95
|
const opts = {
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildCommonOpenApiUrlWithPath = exports.buildUrl = void 0;
|
|
4
|
+
const ZONE_CHINA = ['ap-shanghai', 'ap-guangzhou', 'ap-shenzhen-fsi', 'ap-shanghai-fsi', 'ap-nanjing', 'ap-beijing', 'ap-chengdu', 'ap-chongqing', 'ap-hongkong'];
|
|
4
5
|
/* eslint-disable complexity */
|
|
5
6
|
function buildUrl(options) {
|
|
6
|
-
const endpoint = `https://${options
|
|
7
|
+
const endpoint = `https://${getGatewayUrl(options)}/v1/cloudrun/${options.name}`;
|
|
7
8
|
const path = options.path.startsWith('/') ? options.path : `/${options.path}`;
|
|
8
9
|
return `${endpoint}${path}`;
|
|
9
10
|
}
|
|
10
11
|
exports.buildUrl = buildUrl;
|
|
11
12
|
function buildCommonOpenApiUrlWithPath(options) {
|
|
12
|
-
return `${options.protocol || 'https'}://${options.serviceUrl ||
|
|
13
|
+
return `${options.protocol || 'https'}://${options.serviceUrl || getGatewayUrl(options)}${options.path}`;
|
|
13
14
|
}
|
|
14
15
|
exports.buildCommonOpenApiUrlWithPath = buildCommonOpenApiUrlWithPath;
|
|
16
|
+
function getGatewayUrl(options) {
|
|
17
|
+
const region = options.region || 'ap-shanghai';
|
|
18
|
+
let baseUrl = `${options.envId}.api.tcloudbasegateway.com`;
|
|
19
|
+
if (!ZONE_CHINA.includes(region)) {
|
|
20
|
+
baseUrl = `${options.envId}.api.intl.tcloudbasegateway.com`;
|
|
21
|
+
}
|
|
22
|
+
return baseUrl;
|
|
23
|
+
}
|
|
@@ -88,7 +88,7 @@ class TcbOpenApiHttpRequester {
|
|
|
88
88
|
: args.config.envName;
|
|
89
89
|
const url = (0, tcbopenapiendpoint_1.buildUrl)({
|
|
90
90
|
envId,
|
|
91
|
-
|
|
91
|
+
region: this.config.region,
|
|
92
92
|
// protocol: this.config.protocol || 'https',
|
|
93
93
|
// serviceUrl: this.config.serviceUrl,
|
|
94
94
|
// seqId: this.tracingInfo.seqId,
|
package/package.json
CHANGED
package/src/cloudbase.ts
CHANGED
|
@@ -161,8 +161,8 @@ export class CloudBase {
|
|
|
161
161
|
token: (await this.auth().getClientCredential()).access_token
|
|
162
162
|
})
|
|
163
163
|
return result.body
|
|
164
|
-
}, buildCommonOpenApiUrlWithPath({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/model' }), {
|
|
165
|
-
sqlBaseUrl: buildCommonOpenApiUrlWithPath({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/sql' })
|
|
164
|
+
}, buildCommonOpenApiUrlWithPath({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/model', region: this.config.region }), {
|
|
165
|
+
sqlBaseUrl: buildCommonOpenApiUrlWithPath({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/sql', region: this.config.region })
|
|
166
166
|
})
|
|
167
167
|
|
|
168
168
|
this.models = httpClient
|
|
@@ -183,7 +183,8 @@ export class CloudBase {
|
|
|
183
183
|
mysqlBaseUrl: buildCommonOpenApiUrlWithPath({
|
|
184
184
|
serviceUrl: this.config.serviceUrl,
|
|
185
185
|
envId,
|
|
186
|
-
path: '/v1/rdb/rest'
|
|
186
|
+
path: '/v1/rdb/rest',
|
|
187
|
+
region: this.config.region
|
|
187
188
|
}),
|
|
188
189
|
|
|
189
190
|
fetch: async (url: RequestInfo | URL, options: RequestInit) => {
|
|
@@ -91,7 +91,8 @@ export class TcbOpenApiHttpCommonRequester {
|
|
|
91
91
|
|
|
92
92
|
const url = args.url || buildCommonOpenApiUrlWithPath({
|
|
93
93
|
envId,
|
|
94
|
-
path: args.path
|
|
94
|
+
path: args.path,
|
|
95
|
+
region: config.region
|
|
95
96
|
})
|
|
96
97
|
|
|
97
98
|
const timeout = this.args.opts?.timeout || this.config.timeout || this.defaultTimeout
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const ZONE_CHINA = ['ap-shanghai', 'ap-guangzhou', 'ap-shenzhen-fsi', 'ap-shanghai-fsi', 'ap-nanjing', 'ap-beijing', 'ap-chengdu', 'ap-chongqing', 'ap-hongkong']
|
|
2
|
+
|
|
1
3
|
/* eslint-disable complexity */
|
|
2
4
|
export function buildUrl(options: {
|
|
3
|
-
envId
|
|
5
|
+
envId: string
|
|
4
6
|
region?: string
|
|
5
7
|
protocol?: 'http' | 'https'
|
|
6
8
|
serviceUrl?: string
|
|
@@ -9,7 +11,7 @@ export function buildUrl(options: {
|
|
|
9
11
|
name: string
|
|
10
12
|
path: string
|
|
11
13
|
}): string {
|
|
12
|
-
const endpoint = `https://${options
|
|
14
|
+
const endpoint = `https://${getGatewayUrl(options)}/v1/cloudrun/${options.name}`
|
|
13
15
|
const path = options.path.startsWith('/') ? options.path : `/${options.path}`
|
|
14
16
|
return `${endpoint}${path}`
|
|
15
17
|
}
|
|
@@ -19,6 +21,20 @@ export function buildCommonOpenApiUrlWithPath(options: {
|
|
|
19
21
|
protocol?: 'http' | 'https'
|
|
20
22
|
path: string
|
|
21
23
|
serviceUrl?: string
|
|
24
|
+
region?: string
|
|
22
25
|
}): string {
|
|
23
|
-
return `${options.protocol || 'https'}://${options.serviceUrl ||
|
|
26
|
+
return `${options.protocol || 'https'}://${options.serviceUrl || getGatewayUrl(options)}${options.path}`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getGatewayUrl(options: {
|
|
30
|
+
envId: string
|
|
31
|
+
region?: string
|
|
32
|
+
}): string {
|
|
33
|
+
const region = options.region || 'ap-shanghai'
|
|
34
|
+
let baseUrl = `${options.envId}.api.tcloudbasegateway.com`
|
|
35
|
+
|
|
36
|
+
if (!ZONE_CHINA.includes(region)) {
|
|
37
|
+
baseUrl = `${options.envId}.api.intl.tcloudbasegateway.com`
|
|
38
|
+
}
|
|
39
|
+
return baseUrl
|
|
24
40
|
}
|
|
@@ -93,7 +93,7 @@ export class TcbOpenApiHttpRequester {
|
|
|
93
93
|
|
|
94
94
|
const url = buildUrl({
|
|
95
95
|
envId,
|
|
96
|
-
|
|
96
|
+
region: this.config.region,
|
|
97
97
|
// protocol: this.config.protocol || 'https',
|
|
98
98
|
// serviceUrl: this.config.serviceUrl,
|
|
99
99
|
// seqId: this.tracingInfo.seqId,
|
package/types/index.d.ts
CHANGED