@cloudbase/node-sdk 3.14.0 → 3.14.2
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 +7 -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 +8 -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;
|
|
@@ -171,6 +172,9 @@ class CloudBase {
|
|
|
171
172
|
this.mysql = (options) => {
|
|
172
173
|
return getEntity(options)(options);
|
|
173
174
|
};
|
|
175
|
+
this.rdb = (options) => {
|
|
176
|
+
return getEntity(options)(options);
|
|
177
|
+
};
|
|
174
178
|
}
|
|
175
179
|
catch (e) {
|
|
176
180
|
// ignore
|
|
@@ -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
|
@@ -82,6 +82,7 @@ export class CloudBase {
|
|
|
82
82
|
public models: OrmClient & OrmRawQueryClient
|
|
83
83
|
|
|
84
84
|
public mysql: IMySqlClient
|
|
85
|
+
public rdb: IMySqlClient
|
|
85
86
|
|
|
86
87
|
public constructor(config?: ICloudBaseConfig) {
|
|
87
88
|
this.init(config)
|
|
@@ -161,8 +162,8 @@ export class CloudBase {
|
|
|
161
162
|
token: (await this.auth().getClientCredential()).access_token
|
|
162
163
|
})
|
|
163
164
|
return result.body
|
|
164
|
-
}, buildCommonOpenApiUrlWithPath({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/model' }), {
|
|
165
|
-
sqlBaseUrl: buildCommonOpenApiUrlWithPath({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/sql' })
|
|
165
|
+
}, buildCommonOpenApiUrlWithPath({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/model', region: this.config.region }), {
|
|
166
|
+
sqlBaseUrl: buildCommonOpenApiUrlWithPath({ serviceUrl: this.config.serviceUrl, envId, path: '/v1/sql', region: this.config.region })
|
|
166
167
|
})
|
|
167
168
|
|
|
168
169
|
this.models = httpClient
|
|
@@ -183,7 +184,8 @@ export class CloudBase {
|
|
|
183
184
|
mysqlBaseUrl: buildCommonOpenApiUrlWithPath({
|
|
184
185
|
serviceUrl: this.config.serviceUrl,
|
|
185
186
|
envId,
|
|
186
|
-
path: '/v1/rdb/rest'
|
|
187
|
+
path: '/v1/rdb/rest',
|
|
188
|
+
region: this.config.region
|
|
187
189
|
}),
|
|
188
190
|
|
|
189
191
|
fetch: async (url: RequestInfo | URL, options: RequestInit) => {
|
|
@@ -237,6 +239,9 @@ export class CloudBase {
|
|
|
237
239
|
this.mysql = (options: IMySqlOptions) => {
|
|
238
240
|
return getEntity(options)(options)
|
|
239
241
|
}
|
|
242
|
+
this.rdb = (options: IMySqlOptions) => {
|
|
243
|
+
return getEntity(options)(options)
|
|
244
|
+
}
|
|
240
245
|
} catch (e) {
|
|
241
246
|
// ignore
|
|
242
247
|
}
|
|
@@ -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