Skip to content

Commit

Permalink
fix(type): HttpClient methods type and update some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Jun 20, 2024
1 parent 70a9677 commit 11c7824
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
21 changes: 11 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,20 +477,20 @@ export declare namespace resume_up {
}

/**
* 当前仅支持了同步调用这一不推荐的使用方式,暂不公开具体内部信息,仅供类型匹配使用
* 历史原因其方法当前仅支持了同步调用这一不推荐的使用方式,暂不公开具体内部信息,仅供 TypeScript 类型检查使用。
* 实际不存在这个类,未来会变更为 interface。
*/
abstract class ResumeRecorder {
}

/**
*
* @param baseDirPath 默认值为 `os.tmpdir()`
* @param baseDirPath 默认值为 `os.tmpdir()`,该方法若 baseDirPath 不存在将自动创建
*/
function createResumeRecorder (baseDirPath?: string): Promise<ResumeRecorder>

/**
* TODO: 是否公开这个不推荐的同步实现?
* `createResumeRecorder` 的同步版本
* `createResumeRecorder` 的同步版本,不推荐使用
*/
function createResumeRecorderSync (baseDirPath?: string): ResumeRecorder
}
Expand Down Expand Up @@ -700,17 +700,17 @@ export declare namespace httpc {
middlewares?: middleware.Middleware[];
}

interface GetOptions<T = any> extends ReqOpts<T> {
interface GetOptions<T = any> extends Omit<ReqOpts<T>, 'urllibOptions'> {
params: Record<string, string>;
headers: Record<string, string>;
}

interface PostOptions<T = any> extends ReqOpts<T> {
interface PostOptions<T = any> extends Omit<ReqOpts<T>, 'urllibOptions'> {
data: string | Buffer | Readable;
headers: Record<string, string>;
}

interface PutOptions<T = any> extends ReqOpts<T> {
interface PutOptions<T = any> extends Omit<ReqOpts<T>, 'urllibOptions'> {
data: string | Buffer | Readable;
headers: Record<string, string>
}
Expand All @@ -721,9 +721,9 @@ export declare namespace httpc {
middlewares: middleware.Middleware[];
constructor(options: HttpClientOptions)
sendRequest(requestOptions: ReqOpts): Promise<ResponseWrapper>
get(getOptions: GetOptions): Promise<ResponseWrapper>
post(postOptions: PostOptions): Promise<ResponseWrapper>
put(putOptions: PutOptions): Promise<ResponseWrapper>
get(getOptions: GetOptions, urllibOptions?: RequestOptions): Promise<ResponseWrapper>
post(postOptions: PostOptions, urllibOptions?: RequestOptions): Promise<ResponseWrapper>
put(putOptions: PutOptions, urllibOptions?: RequestOptions): Promise<ResponseWrapper>
}

// endpoint.js
Expand Down Expand Up @@ -1353,6 +1353,7 @@ export declare namespace rs {
* @param callbackFunc
*/
listBucket(callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketsResult>>
listBucket(options: { shared: string, tagCondition: Record<string, string> }, callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketsResult>>

/**
* 创建空间
Expand Down
2 changes: 1 addition & 1 deletion qiniu/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const Config = (function () {
* @constructor
* @param {Object} [options]
* @param {boolean} [options.useHttpsDomain]
* @param {boolean} [options.accelerateUploading] should active the domains before using
* @param {boolean} [options.accelerateUploading] enable accelerate uploading. should active the domains in portal before using
* @param {EndpointsProvider} [options.ucEndpointsProvider]
* @param {EndpointsProvider} [options.queryRegionsEndpointsProvider]
* @param {RegionsProvider} [options.regionsProvider]
Expand Down
2 changes: 2 additions & 0 deletions qiniu/httpc/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ Region.merge = function (...regions) {
const [source, ...rest] = regions;
const target = source.clone();
rest.forEach(s => {
// use Object.values when min version of Node.js update to ≥ v7.5.0
Object.keys(s.services).forEach(n => {
if (!target.services[n]) {
target.services[n] = s.services[n].map(endpoint => endpoint.clone());
Expand All @@ -306,6 +307,7 @@ Region.prototype.getRegions = function () {
};

Region.prototype.clone = function () {
// use Object.entries when min version of Node.js update to ≥ v7.5.0
const services = Object.keys(this.services).reduce((s, n) => {
s[n] = this.services[n].map(endpoint => endpoint.clone());
return s;
Expand Down
2 changes: 1 addition & 1 deletion qiniu/httpc/regionsRetryPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ RegionsRetryPolicy.prototype._initRegions = function (options) {
});
context.alternativeRegions = regions;
} else {
// preferred endpoints is a region, then reorder the regions and services
// preferred endpoints in a known region, then reorder the regions and services
context.alternativeRegions = regions;
[context.region] = context.alternativeRegions.splice(preferredRegionIndex, 1);
context.alternativeServiceNames = this.serviceNames.slice();
Expand Down

0 comments on commit 11c7824

Please sign in to comment.