2021-12-17 09:22:04 +01:00
|
|
|
import TableFetch from "./TableFetch.js"
|
|
|
|
import ViewFetch from "./ViewFetch.js"
|
2023-07-19 10:16:12 +02:00
|
|
|
import ViewV2Fetch from "./ViewV2Fetch.js"
|
2021-12-17 09:22:04 +01:00
|
|
|
import QueryFetch from "./QueryFetch.js"
|
|
|
|
import RelationshipFetch from "./RelationshipFetch.js"
|
2022-01-04 16:02:43 +01:00
|
|
|
import NestedProviderFetch from "./NestedProviderFetch.js"
|
|
|
|
import FieldFetch from "./FieldFetch.js"
|
|
|
|
import JSONArrayFetch from "./JSONArrayFetch.js"
|
2022-08-05 16:57:21 +02:00
|
|
|
import UserFetch from "./UserFetch.js"
|
2023-05-04 18:38:04 +02:00
|
|
|
import GroupUserFetch from "./GroupUserFetch.js"
|
2021-12-17 09:22:04 +01:00
|
|
|
|
|
|
|
const DataFetchMap = {
|
|
|
|
table: TableFetch,
|
|
|
|
view: ViewFetch,
|
2023-07-19 10:16:12 +02:00
|
|
|
viewV2: ViewV2Fetch,
|
2021-12-17 09:22:04 +01:00
|
|
|
query: QueryFetch,
|
|
|
|
link: RelationshipFetch,
|
2022-08-05 16:57:21 +02:00
|
|
|
user: UserFetch,
|
2023-05-04 18:38:04 +02:00
|
|
|
groupUser: GroupUserFetch,
|
2022-01-18 10:39:19 +01:00
|
|
|
|
|
|
|
// Client specific datasource types
|
2022-01-04 16:02:43 +01:00
|
|
|
provider: NestedProviderFetch,
|
|
|
|
field: FieldFetch,
|
|
|
|
jsonarray: JSONArrayFetch,
|
2021-12-17 09:22:04 +01:00
|
|
|
}
|
|
|
|
|
2022-01-20 10:40:53 +01:00
|
|
|
export const fetchData = ({ API, datasource, options }) => {
|
2021-12-17 09:22:04 +01:00
|
|
|
const Fetch = DataFetchMap[datasource?.type] || TableFetch
|
2022-01-20 10:40:53 +01:00
|
|
|
return new Fetch({ API, datasource, ...options })
|
2021-12-17 09:22:04 +01:00
|
|
|
}
|