Update types
This commit is contained in:
parent
19c32299b1
commit
482f8aa820
|
@ -1,14 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { Pagination, ProgressCircle } from "@budibase/bbui"
|
import { Pagination, ProgressCircle } from "@budibase/bbui"
|
||||||
import {
|
import { fetchData, QueryUtils } from "@budibase/frontend-core"
|
||||||
fetchData,
|
|
||||||
QueryUtils,
|
|
||||||
DataFetchOptions,
|
|
||||||
DataFetchDatasource,
|
|
||||||
UserDatasource,
|
|
||||||
GroupUserDatasource,
|
|
||||||
} from "@budibase/frontend-core"
|
|
||||||
import {
|
import {
|
||||||
LogicalOperator,
|
LogicalOperator,
|
||||||
EmptyFilterOption,
|
EmptyFilterOption,
|
||||||
|
@ -16,6 +9,10 @@
|
||||||
SortOrder,
|
SortOrder,
|
||||||
SearchFilters,
|
SearchFilters,
|
||||||
UISearchFilter,
|
UISearchFilter,
|
||||||
|
DataFetchDatasource,
|
||||||
|
UserDatasource,
|
||||||
|
GroupUserDatasource,
|
||||||
|
DataFetchOptions,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { SDK, Component } from "../../index"
|
import { SDK, Component } from "../../index"
|
||||||
|
|
||||||
|
@ -76,7 +73,7 @@
|
||||||
column: string
|
column: string
|
||||||
order: SortOrder | undefined
|
order: SortOrder | undefined
|
||||||
}) => {
|
}) => {
|
||||||
let newOptions: Partial<DataFetchOptions<never>> = {}
|
let newOptions: Partial<DataFetchOptions> = {}
|
||||||
if (column) {
|
if (column) {
|
||||||
newOptions.sortColumn = column
|
newOptions.sortColumn = column
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { Store as StoreContext } from ".."
|
import { Store as StoreContext } from ".."
|
||||||
import { DatasourceTableActions } from "."
|
import { DatasourceTableActions } from "."
|
||||||
import { TableFetch } from "@budibase/frontend-core"
|
import TableFetch from "../../../../fetch/TableFetch"
|
||||||
|
|
||||||
const SuppressErrors = true
|
const SuppressErrors = true
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { Store as StoreContext } from ".."
|
import { Store as StoreContext } from ".."
|
||||||
import { DatasourceViewActions } from "."
|
import { DatasourceViewActions } from "."
|
||||||
import { ViewV2Fetch } from "@budibase/frontend-core"
|
import ViewV2Fetch from "../../../../fetch/ViewV2Fetch"
|
||||||
|
|
||||||
const SuppressErrors = true
|
const SuppressErrors = true
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
|
import { CustomDatasource } from "@budibase/types"
|
||||||
import BaseDataFetch from "./DataFetch"
|
import BaseDataFetch from "./DataFetch"
|
||||||
|
|
||||||
export interface CustomDatasource {
|
|
||||||
type: "custom"
|
|
||||||
data: any
|
|
||||||
}
|
|
||||||
|
|
||||||
type CustomDefinition = Record<string, any>
|
type CustomDefinition = Record<string, any>
|
||||||
|
|
||||||
export default class CustomFetch extends BaseDataFetch<
|
export default class CustomFetch extends BaseDataFetch<
|
||||||
|
|
|
@ -3,14 +3,13 @@ import { cloneDeep } from "lodash/fp"
|
||||||
import { QueryUtils } from "../utils"
|
import { QueryUtils } from "../utils"
|
||||||
import { convertJSONSchemaToTableSchema } from "../utils/json"
|
import { convertJSONSchemaToTableSchema } from "../utils/json"
|
||||||
import {
|
import {
|
||||||
|
DataFetchOptions,
|
||||||
FieldType,
|
FieldType,
|
||||||
LegacyFilter,
|
|
||||||
Row,
|
Row,
|
||||||
SearchFilters,
|
SearchFilters,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
SortType,
|
SortType,
|
||||||
TableSchema,
|
TableSchema,
|
||||||
UISearchFilter,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { APIClient } from "../api/types"
|
import { APIClient } from "../api/types"
|
||||||
import { DataFetchType } from "."
|
import { DataFetchType } from "."
|
||||||
|
@ -51,18 +50,6 @@ export interface DataFetchParams<TDatasource, TQuery = SearchFilters> {
|
||||||
options?: Partial<DataFetchOptions<TQuery>>
|
options?: Partial<DataFetchOptions<TQuery>>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DataFetchOptions<TQuery = SearchFilters> {
|
|
||||||
// Search config
|
|
||||||
filter: UISearchFilter | LegacyFilter[] | null
|
|
||||||
query: TQuery
|
|
||||||
// Sorting config
|
|
||||||
sortColumn: string | null
|
|
||||||
sortOrder: SortOrder
|
|
||||||
// Pagination config
|
|
||||||
limit: number
|
|
||||||
paginate: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent class which handles the implementation of fetching data from an
|
* Parent class which handles the implementation of fetching data from an
|
||||||
* internal table or datasource plus.
|
* internal table or datasource plus.
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
import { Row } from "@budibase/types"
|
import {
|
||||||
|
FieldDatasource,
|
||||||
|
JSONArrayFieldDatasource,
|
||||||
|
QueryArrayFieldDatasource,
|
||||||
|
Row,
|
||||||
|
} from "@budibase/types"
|
||||||
import BaseDataFetch from "./DataFetch"
|
import BaseDataFetch from "./DataFetch"
|
||||||
|
|
||||||
type Types = "field" | "queryarray" | "jsonarray"
|
|
||||||
|
|
||||||
export interface FieldDatasource<TType extends Types> {
|
|
||||||
type: TType
|
|
||||||
tableId: string
|
|
||||||
fieldType: "attachment" | "array"
|
|
||||||
value: string[] | Row[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FieldDefinition {
|
export interface FieldDefinition {
|
||||||
schema?: Record<string, { type: string }> | null
|
schema?: Record<string, { type: string }> | null
|
||||||
}
|
}
|
||||||
|
@ -18,10 +14,12 @@ function isArrayOfStrings(value: string[] | Row[]): value is string[] {
|
||||||
return Array.isArray(value) && !!value[0] && typeof value[0] !== "object"
|
return Array.isArray(value) && !!value[0] && typeof value[0] !== "object"
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class FieldFetch<TType extends Types> extends BaseDataFetch<
|
export default class FieldFetch<
|
||||||
FieldDatasource<TType>,
|
TDatasource extends
|
||||||
FieldDefinition
|
| FieldDatasource
|
||||||
> {
|
| QueryArrayFieldDatasource
|
||||||
|
| JSONArrayFieldDatasource = FieldDatasource
|
||||||
|
> extends BaseDataFetch<TDatasource, FieldDefinition> {
|
||||||
async getDefinition(): Promise<FieldDefinition | null> {
|
async getDefinition(): Promise<FieldDefinition | null> {
|
||||||
const { datasource } = this.options
|
const { datasource } = this.options
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import BaseDataFetch, { DataFetchParams } from "./DataFetch"
|
import BaseDataFetch, { DataFetchParams } from "./DataFetch"
|
||||||
import { TableNames } from "../constants"
|
import { GroupUserDatasource, InternalTable } from "@budibase/types"
|
||||||
|
|
||||||
interface GroupUserQuery {
|
interface GroupUserQuery {
|
||||||
groupId: string
|
groupId: string
|
||||||
emailSearch: string
|
emailSearch: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupUserDatasource {
|
|
||||||
type: "groupUser"
|
|
||||||
tableId: TableNames.USERS
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GroupUserDefinition {
|
interface GroupUserDefinition {
|
||||||
schema?: Record<string, any> | null
|
schema?: Record<string, any> | null
|
||||||
primaryDisplay?: string
|
primaryDisplay?: string
|
||||||
|
@ -27,7 +22,7 @@ export default class GroupUserFetch extends BaseDataFetch<
|
||||||
...opts,
|
...opts,
|
||||||
datasource: {
|
datasource: {
|
||||||
type: "groupUser",
|
type: "groupUser",
|
||||||
tableId: TableNames.USERS,
|
tableId: InternalTable.USER_METADATA,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import FieldFetch from "./FieldFetch"
|
import FieldFetch from "./FieldFetch"
|
||||||
import { getJSONArrayDatasourceSchema } from "../utils/json"
|
import { getJSONArrayDatasourceSchema } from "../utils/json"
|
||||||
|
import { JSONArrayFieldDatasource } from "@budibase/types"
|
||||||
|
|
||||||
export default class JSONArrayFetch extends FieldFetch<"jsonarray"> {
|
export default class JSONArrayFetch extends FieldFetch<JSONArrayFieldDatasource> {
|
||||||
async getDefinition() {
|
async getDefinition() {
|
||||||
const { datasource } = this.options
|
const { datasource } = this.options
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
import { Row, TableSchema } from "@budibase/types"
|
import { NestedProviderDatasource, TableSchema } from "@budibase/types"
|
||||||
import BaseDataFetch from "./DataFetch"
|
import BaseDataFetch from "./DataFetch"
|
||||||
|
|
||||||
export interface NestedProviderDatasource {
|
|
||||||
type: "provider"
|
|
||||||
value?: {
|
|
||||||
schema: TableSchema
|
|
||||||
primaryDisplay: string
|
|
||||||
rows: Row[]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NestedProviderDefinition {
|
interface NestedProviderDefinition {
|
||||||
schema?: TableSchema
|
schema?: TableSchema
|
||||||
primaryDisplay?: string
|
primaryDisplay?: string
|
||||||
|
|
|
@ -3,8 +3,9 @@ import {
|
||||||
getJSONArrayDatasourceSchema,
|
getJSONArrayDatasourceSchema,
|
||||||
generateQueryArraySchemas,
|
generateQueryArraySchemas,
|
||||||
} from "../utils/json"
|
} from "../utils/json"
|
||||||
|
import { QueryArrayFieldDatasource } from "@budibase/types"
|
||||||
|
|
||||||
export default class QueryArrayFetch extends FieldFetch<"queryarray"> {
|
export default class QueryArrayFetch extends FieldFetch<QueryArrayFieldDatasource> {
|
||||||
async getDefinition() {
|
async getDefinition() {
|
||||||
const { datasource } = this.options
|
const { datasource } = this.options
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,8 @@
|
||||||
import BaseDataFetch from "./DataFetch"
|
import BaseDataFetch from "./DataFetch"
|
||||||
import { Helpers } from "@budibase/bbui"
|
import { Helpers } from "@budibase/bbui"
|
||||||
import { ExecuteQueryRequest, Query } from "@budibase/types"
|
import { ExecuteQueryRequest, Query, QueryDatasource } from "@budibase/types"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
|
|
||||||
export interface QueryDatasource {
|
|
||||||
type: "query"
|
|
||||||
_id: string
|
|
||||||
fields: Record<string, any> & {
|
|
||||||
pagination?: {
|
|
||||||
type: string
|
|
||||||
location: string
|
|
||||||
pageParam: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
queryParams?: Record<string, string>
|
|
||||||
parameters: { name: string; default: string }[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class QueryFetch extends BaseDataFetch<QueryDatasource, Query> {
|
export default class QueryFetch extends BaseDataFetch<QueryDatasource, Query> {
|
||||||
async determineFeatureFlags() {
|
async determineFeatureFlags() {
|
||||||
const definition = await this.getDefinition()
|
const definition = await this.getDefinition()
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
import { Table } from "@budibase/types"
|
import { RelationshipDatasource, Table } from "@budibase/types"
|
||||||
import BaseDataFetch from "./DataFetch"
|
import BaseDataFetch from "./DataFetch"
|
||||||
|
|
||||||
export interface RelationshipDatasource {
|
|
||||||
type: "link"
|
|
||||||
tableId: string
|
|
||||||
rowId: string
|
|
||||||
rowTableId: string
|
|
||||||
fieldName: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class RelationshipFetch extends BaseDataFetch<
|
export default class RelationshipFetch extends BaseDataFetch<
|
||||||
RelationshipDatasource,
|
RelationshipDatasource,
|
||||||
Table
|
Table
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import BaseDataFetch from "./DataFetch"
|
import BaseDataFetch from "./DataFetch"
|
||||||
import { SortOrder, Table } from "@budibase/types"
|
import { SortOrder, Table, TableDatasource } from "@budibase/types"
|
||||||
|
|
||||||
export interface TableDatasource {
|
|
||||||
type: "table"
|
|
||||||
tableId: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class TableFetch extends BaseDataFetch<TableDatasource, Table> {
|
export default class TableFetch extends BaseDataFetch<TableDatasource, Table> {
|
||||||
async determineFeatureFlags() {
|
async determineFeatureFlags() {
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import BaseDataFetch, { DataFetchParams } from "./DataFetch"
|
import BaseDataFetch, { DataFetchParams } from "./DataFetch"
|
||||||
import { TableNames } from "../constants"
|
|
||||||
import { utils } from "@budibase/shared-core"
|
import { utils } from "@budibase/shared-core"
|
||||||
import { SearchFilters, SearchUsersRequest } from "@budibase/types"
|
import {
|
||||||
|
InternalTable,
|
||||||
|
SearchFilters,
|
||||||
|
SearchUsersRequest,
|
||||||
|
UserDatasource,
|
||||||
|
} from "@budibase/types"
|
||||||
|
|
||||||
interface UserFetchQuery {
|
interface UserFetchQuery {
|
||||||
appId: string
|
appId: string
|
||||||
paginated: boolean
|
paginated: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserDatasource {
|
|
||||||
type: "user"
|
|
||||||
tableId: TableNames.USERS
|
|
||||||
}
|
|
||||||
|
|
||||||
interface UserDefinition {
|
interface UserDefinition {
|
||||||
schema?: Record<string, any> | null
|
schema?: Record<string, any> | null
|
||||||
primaryDisplay?: string
|
primaryDisplay?: string
|
||||||
|
@ -29,7 +28,7 @@ export default class UserFetch extends BaseDataFetch<
|
||||||
...opts,
|
...opts,
|
||||||
datasource: {
|
datasource: {
|
||||||
type: "user",
|
type: "user",
|
||||||
tableId: TableNames.USERS,
|
tableId: InternalTable.USER_METADATA,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
import { Table } from "@budibase/types"
|
import { Table, ViewV1Datasource } from "@budibase/types"
|
||||||
import BaseDataFetch from "./DataFetch"
|
import BaseDataFetch from "./DataFetch"
|
||||||
|
|
||||||
export type ViewV1Datasource = {
|
|
||||||
type: "view"
|
|
||||||
name: string
|
|
||||||
tableId: string
|
|
||||||
calculation: string
|
|
||||||
field: string
|
|
||||||
groupBy: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class ViewFetch extends BaseDataFetch<ViewV1Datasource, Table> {
|
export default class ViewFetch extends BaseDataFetch<ViewV1Datasource, Table> {
|
||||||
async getDefinition() {
|
async getDefinition() {
|
||||||
const { datasource } = this.options
|
const { datasource } = this.options
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { SortOrder, ViewV2Enriched, ViewV2Type } from "@budibase/types"
|
import {
|
||||||
|
SortOrder,
|
||||||
|
ViewDatasource,
|
||||||
|
ViewV2Enriched,
|
||||||
|
ViewV2Type,
|
||||||
|
} from "@budibase/types"
|
||||||
import BaseDataFetch from "./DataFetch"
|
import BaseDataFetch from "./DataFetch"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { helpers } from "@budibase/shared-core"
|
import { helpers } from "@budibase/shared-core"
|
||||||
|
|
||||||
export interface ViewDatasource {
|
|
||||||
type: "viewV2"
|
|
||||||
id: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class ViewV2Fetch extends BaseDataFetch<
|
export default class ViewV2Fetch extends BaseDataFetch<
|
||||||
ViewDatasource,
|
ViewDatasource,
|
||||||
ViewV2Enriched
|
ViewV2Enriched
|
||||||
|
|
|
@ -1,30 +1,20 @@
|
||||||
import TableFetch, { TableDatasource } from "./TableFetch"
|
import TableFetch from "./TableFetch"
|
||||||
import ViewFetch, { ViewV1Datasource } from "./ViewFetch"
|
import ViewFetch from "./ViewFetch"
|
||||||
import ViewV2Fetch, { ViewDatasource } from "./ViewV2Fetch"
|
import ViewV2Fetch from "./ViewV2Fetch"
|
||||||
import QueryFetch, { QueryDatasource } from "./QueryFetch"
|
import QueryFetch from "./QueryFetch"
|
||||||
import RelationshipFetch, { RelationshipDatasource } from "./RelationshipFetch"
|
import RelationshipFetch from "./RelationshipFetch"
|
||||||
import NestedProviderFetch, {
|
import NestedProviderFetch from "./NestedProviderFetch"
|
||||||
NestedProviderDatasource,
|
import FieldFetch from "./FieldFetch"
|
||||||
} from "./NestedProviderFetch"
|
|
||||||
import FieldFetch, { FieldDatasource } from "./FieldFetch"
|
|
||||||
import JSONArrayFetch from "./JSONArrayFetch"
|
import JSONArrayFetch from "./JSONArrayFetch"
|
||||||
import UserFetch, { UserDatasource } from "./UserFetch"
|
import UserFetch from "./UserFetch"
|
||||||
import GroupUserFetch, { GroupUserDatasource } from "./GroupUserFetch"
|
import GroupUserFetch from "./GroupUserFetch"
|
||||||
import CustomFetch, { CustomDatasource } from "./CustomFetch"
|
import CustomFetch from "./CustomFetch"
|
||||||
import QueryArrayFetch from "./QueryArrayFetch"
|
import QueryArrayFetch from "./QueryArrayFetch"
|
||||||
import { APIClient } from "../api/types"
|
import { APIClient } from "../api/types"
|
||||||
import { Table, ViewV2Enriched } from "@budibase/types"
|
import { DataFetchDatasource, Table, ViewV2Enriched } from "@budibase/types"
|
||||||
|
|
||||||
export type DataFetchType = keyof typeof DataFetchMap
|
export type DataFetchType = keyof typeof DataFetchMap
|
||||||
|
|
||||||
export type { default as TableFetch } from "./TableFetch"
|
|
||||||
export type { default as ViewFetch } from "./ViewFetch"
|
|
||||||
export type { default as ViewV2Fetch } from "./ViewV2Fetch"
|
|
||||||
|
|
||||||
export type { DataFetchOptions } from "./DataFetch"
|
|
||||||
export type { UserDatasource } from "./UserFetch"
|
|
||||||
export type { GroupUserDatasource } from "./GroupUserFetch"
|
|
||||||
|
|
||||||
export const DataFetchMap = {
|
export const DataFetchMap = {
|
||||||
table: TableFetch,
|
table: TableFetch,
|
||||||
view: ViewFetch,
|
view: ViewFetch,
|
||||||
|
@ -37,7 +27,7 @@ export const DataFetchMap = {
|
||||||
|
|
||||||
// Client specific datasource types
|
// Client specific datasource types
|
||||||
provider: NestedProviderFetch,
|
provider: NestedProviderFetch,
|
||||||
field: FieldFetch<"field">,
|
field: FieldFetch,
|
||||||
jsonarray: JSONArrayFetch,
|
jsonarray: JSONArrayFetch,
|
||||||
queryarray: QueryArrayFetch,
|
queryarray: QueryArrayFetch,
|
||||||
}
|
}
|
||||||
|
@ -54,7 +44,7 @@ export interface DataFetchClassMap {
|
||||||
|
|
||||||
// Client specific datasource types
|
// Client specific datasource types
|
||||||
provider: NestedProviderFetch
|
provider: NestedProviderFetch
|
||||||
field: FieldFetch<"field">
|
field: FieldFetch
|
||||||
jsonarray: JSONArrayFetch
|
jsonarray: JSONArrayFetch
|
||||||
queryarray: QueryArrayFetch
|
queryarray: QueryArrayFetch
|
||||||
}
|
}
|
||||||
|
@ -69,22 +59,10 @@ export type DataFetch =
|
||||||
| GroupUserFetch
|
| GroupUserFetch
|
||||||
| CustomFetch
|
| CustomFetch
|
||||||
| NestedProviderFetch
|
| NestedProviderFetch
|
||||||
| FieldFetch<"field">
|
| FieldFetch
|
||||||
| JSONArrayFetch
|
| JSONArrayFetch
|
||||||
| QueryArrayFetch
|
| QueryArrayFetch
|
||||||
|
|
||||||
export type DataFetchDatasource =
|
|
||||||
| TableDatasource
|
|
||||||
| ViewV1Datasource
|
|
||||||
| ViewDatasource
|
|
||||||
| QueryDatasource
|
|
||||||
| RelationshipDatasource
|
|
||||||
| UserDatasource
|
|
||||||
| GroupUserDatasource
|
|
||||||
| CustomDatasource
|
|
||||||
| NestedProviderDatasource
|
|
||||||
| FieldDatasource<"field" | "queryarray" | "jsonarray">
|
|
||||||
|
|
||||||
export type DataFetchDefinition =
|
export type DataFetchDefinition =
|
||||||
| Table
|
| Table
|
||||||
| ViewV2Enriched
|
| ViewV2Enriched
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
export { createAPIClient } from "./api"
|
export { createAPIClient } from "./api"
|
||||||
export type { APIClient } from "./api"
|
export type { APIClient } from "./api"
|
||||||
export { fetchData, DataFetchMap } from "./fetch"
|
export { fetchData, DataFetchMap } from "./fetch"
|
||||||
export type {
|
|
||||||
DataFetchType,
|
|
||||||
TableFetch,
|
|
||||||
ViewFetch,
|
|
||||||
ViewV2Fetch,
|
|
||||||
DataFetchOptions,
|
|
||||||
DataFetchDatasource,
|
|
||||||
UserDatasource,
|
|
||||||
GroupUserDatasource,
|
|
||||||
} from "./fetch"
|
|
||||||
export * as Constants from "./constants"
|
export * as Constants from "./constants"
|
||||||
export * from "./stores"
|
export * from "./stores"
|
||||||
export * from "./utils"
|
export * from "./utils"
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
import { InternalTable, Row, TableSchema } from "../../documents"
|
||||||
|
|
||||||
|
export type DataFetchDatasource =
|
||||||
|
| TableDatasource
|
||||||
|
| ViewV1Datasource
|
||||||
|
| ViewDatasource
|
||||||
|
| QueryDatasource
|
||||||
|
| RelationshipDatasource
|
||||||
|
| UserDatasource
|
||||||
|
| GroupUserDatasource
|
||||||
|
| CustomDatasource
|
||||||
|
| NestedProviderDatasource
|
||||||
|
| FieldDatasource
|
||||||
|
| QueryArrayFieldDatasource
|
||||||
|
| JSONArrayFieldDatasource
|
||||||
|
|
||||||
|
export interface TableDatasource {
|
||||||
|
type: "table"
|
||||||
|
tableId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ViewV1Datasource = {
|
||||||
|
type: "view"
|
||||||
|
name: string
|
||||||
|
tableId: string
|
||||||
|
calculation: string
|
||||||
|
field: string
|
||||||
|
groupBy: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ViewDatasource {
|
||||||
|
type: "viewV2"
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QueryDatasource {
|
||||||
|
type: "query"
|
||||||
|
_id: string
|
||||||
|
fields: Record<string, any> & {
|
||||||
|
pagination?: {
|
||||||
|
type: string
|
||||||
|
location: string
|
||||||
|
pageParam: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queryParams?: Record<string, string>
|
||||||
|
parameters: { name: string; default: string }[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RelationshipDatasource {
|
||||||
|
type: "link"
|
||||||
|
tableId: string
|
||||||
|
rowId: string
|
||||||
|
rowTableId: string
|
||||||
|
fieldName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserDatasource {
|
||||||
|
type: "user"
|
||||||
|
tableId: InternalTable.USER_METADATA
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GroupUserDatasource {
|
||||||
|
type: "groupUser"
|
||||||
|
tableId: InternalTable.USER_METADATA
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CustomDatasource {
|
||||||
|
type: "custom"
|
||||||
|
data: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NestedProviderDatasource {
|
||||||
|
type: "provider"
|
||||||
|
value?: {
|
||||||
|
schema: TableSchema
|
||||||
|
primaryDisplay: string
|
||||||
|
rows: Row[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BaseFieldDatasource<
|
||||||
|
TType extends "field" | "queryarray" | "jsonarray"
|
||||||
|
> {
|
||||||
|
type: TType
|
||||||
|
tableId: string
|
||||||
|
fieldType: "attachment" | "array"
|
||||||
|
value: string[] | Row[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FieldDatasource = BaseFieldDatasource<"field">
|
||||||
|
export type QueryArrayFieldDatasource = BaseFieldDatasource<"queryarray">
|
||||||
|
export type JSONArrayFieldDatasource = BaseFieldDatasource<"jsonarray">
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { LegacyFilter, SortOrder, UISearchFilter } from "../../api"
|
||||||
|
import { SearchFilters } from "../../sdk"
|
||||||
|
|
||||||
|
export * from "./datasources"
|
||||||
|
|
||||||
|
export interface DataFetchOptions<TQuery = SearchFilters> {
|
||||||
|
// Search config
|
||||||
|
filter: UISearchFilter | LegacyFilter[] | null
|
||||||
|
query: TQuery
|
||||||
|
// Sorting config
|
||||||
|
sortColumn: string | null
|
||||||
|
sortOrder: SortOrder
|
||||||
|
// Pagination config
|
||||||
|
limit: number
|
||||||
|
paginate: boolean
|
||||||
|
}
|
|
@ -1 +1,2 @@
|
||||||
export * from "./stores"
|
export * from "./stores"
|
||||||
|
export * from "./dataFetch"
|
||||||
|
|
Loading…
Reference in New Issue