Skip to content

Commit

Permalink
[fix] Single Query options of BI Data Table model
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Jan 30, 2024
1 parent 35e9570 commit 47cabe3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobx-lark",
"version": "2.0.0-rc.0",
"version": "2.0.0-rc.1",
"license": "LGPL-3.0",
"author": "shiy2008@gmail.com",
"description": "Unofficial TypeScript SDK for FeiShu/Lark API, which is based on MobX-RESTful.",
Expand Down
23 changes: 16 additions & 7 deletions src/module/BITable/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DataObject, Filter, ListModel, Stream, toggle } from 'mobx-restful';
import { isEmpty } from 'web-utility';
import { buildURLData, isEmpty } from 'web-utility';

import { UserIdType } from '../../type';
import { createPageStream } from '../base';
import {
BITable,
Expand Down Expand Up @@ -49,6 +50,14 @@ export const normalizeText = (

export type BiBaseData = Omit<TableRecord<{}>, 'record_id' | 'fields'>;

export interface BiDataQueryOptions {
text_field_as_array?: boolean;
automatic_fields?: boolean;
display_formula_ref?: boolean;
with_shared_url?: boolean;
user_id_type?: UserIdType;
}

/**
* @see {@link https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/bitable-overview}
*/
Expand All @@ -61,6 +70,10 @@ export function BiDataTable<

sort: Partial<Record<keyof T, 'ASC' | 'DESC'>> = {};

queryOptions: BiDataQueryOptions = {
text_field_as_array: true,
automatic_fields: true
};
currentViewId?: string;

constructor(appId: string, tableId: string) {
Expand All @@ -78,7 +91,7 @@ export function BiDataTable<
@toggle('downloading')
async getOne(id: string) {
const { body } = await this.client.get<TableRecordData<T>>(
`${this.baseURI}/${id}`
`${this.baseURI}/${id}?${buildURLData(this.queryOptions)}`
);
return (this.currentOne = this.normalize(body!.data!.record));
}
Expand Down Expand Up @@ -133,11 +146,7 @@ export function BiDataTable<
this.client,
this.baseURI,
total => (this.totalCount = total),
{
...searchParams,
text_field_as_array: true,
automatic_fields: true
}
{ ...searchParams, ...this.queryOptions }
);
for await (const item of stream) yield this.normalize(item);
}
Expand Down

0 comments on commit 47cabe3

Please sign in to comment.