@kevisual/noco
Version:
```ts const nocoAPi = new NocoApi({ baseURL: config.NOCODB_URL, token: config.NOCODB_API_KEY, });
82 lines (79 loc) • 1.93 kB
TypeScript
type MakeRequestOptions = {
params?: Record<string, any>;
data?: Record<string, any>;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
json?: boolean;
};
declare class Query {
baseURL: string;
token: string;
constructor({ baseURL, token }: {
baseURL: string;
token: string;
});
makeRequest(endpoint: string, options: MakeRequestOptions): Promise<any>;
}
type NocoApiOptions = {
table?: string;
token?: string;
baseURL?: string;
};
declare class NocoApi {
query: Query;
record: Record$1;
constructor(options?: NocoApiOptions);
}
type QueryParams = {
/**
* fields=field1,field2
*/
fields?: string | string[];
/**
* sort=field1,-field2
*/
sort?: string | string[];
/**
* where=(field1,eq,value1)~and(field2,eq,value2)
*/
where?: string;
offset?: number;
limit?: number;
viewId?: string;
[key: string]: any;
};
type ResultList<T = any> = {
code: number;
list: T[];
pageInfo?: {
totalRows?: number;
page?: number;
pageSize?: number;
isFirstPage?: boolean;
isLastPage?: boolean;
};
};
type Id = string | number;
/**
* @url https://nocodb.com/apis/v2/data#tag/Table-Records
*/
declare class Record$1 {
query: Query;
table: string;
constructor(query: Query, table: string);
list<T = any>(params?: QueryParams): Promise<ResultList<T>>;
create(data: any): Promise<any>;
read(id: Id): Promise<any>;
update(data: {
Id?: Id;
[key: string]: any;
}): Promise<any>;
delete(data: {
Id?: Id;
}): Promise<any>;
count(): Promise<any>;
listLinks(linkFieldId: Id, Id: Id): Promise<any>;
updateLinks(linkFieldId: Id, Id: Id, data: any): Promise<any>;
deleteLinks(linkFieldId: Id, Id: Id): Promise<any>;
}
export { NocoApi };
export type { NocoApiOptions };