Skip to content

Commit

Permalink
auto: apply newest APITable commit
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 1, 2023
1 parent 9204ecd commit d819600
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/apitable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosInstance } from "axios";
// import mpAdapter from 'axios-miniprogram-adapter';
import qs from "qs";
import { DEFAULT_HOST, DEFAULT_REQUEST_TIMEOUT, DEFAULT_VERSION_PREFIX, FUSION_PATH_PREFIX } from "./const";
import { DEFAULT_HOST, DEFAULT_REQUEST_TIMEOUT, DATA_BUS_VERSION_PREFIX, DEFAULT_VERSION_PREFIX, FUSION_PATH_PREFIX } from "./const";
import { Datasheet } from "./datasheet";
import { IHttpResponse, IVikaClientConfig } from "./interface";
import { NodeManager } from "./node";
Expand Down Expand Up @@ -75,12 +75,18 @@ export class Vika {
timeout?: number;
}): Promise<IHttpResponse<T>> {
const { path, params, method, data, headers, timeout } = config;
let urlPath = '';
if (params?.isV3){
urlPath = path.includes(FUSION_PATH_PREFIX) ? path : DATA_BUS_VERSION_PREFIX.concat(path);
}else {
urlPath = path.includes(FUSION_PATH_PREFIX) ? path : DEFAULT_VERSION_PREFIX.concat(path);
}
let result: IHttpResponse<T>;
try {
result = (
await this.axios.request<IHttpResponse<T>>({
timeout,
url: path.includes(FUSION_PATH_PREFIX) ? path : DEFAULT_VERSION_PREFIX.concat(path),
url: urlPath,
method,
params: {
fieldKey: this.config.fieldKey,
Expand Down Expand Up @@ -145,4 +151,8 @@ export class Vika {
space(spaceId: string) {
return new SpaceManager(this, spaceId);
}

public isV3() {
return true;
}
}
1 change: 1 addition & 0 deletions lib/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const DST_MAX_RECORDS = 50000; // Maximum number of records in a single d
export const DEFAULT_HOST = 'https://api.vika.cn';
export const FUSION_PATH_PREFIX = '/fusion';
export const DEFAULT_VERSION_PREFIX = '/fusion/v1';
export const DATA_BUS_VERSION_PREFIX = '/fusion/v3';
export const DEFAULT_REQUEST_TIMEOUT = 60000;
export const MAX_WRITE_SIZE_PER_REQ = 10;

Expand Down
5 changes: 5 additions & 0 deletions lib/interface/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export interface IGetRecordsReqParams {
* return method (using id will avoid code failure due to column name changes).
*/
fieldKey?: 'name' | 'id';

/**
* use databus fusion api
* */
isV3?: boolean;
}


Expand Down

0 comments on commit d819600

Please sign in to comment.