2022-01-05 04:02:43 +13:00
|
|
|
import FieldFetch from "./FieldFetch.js"
|
2022-01-18 22:39:19 +13:00
|
|
|
import { getJSONArrayDatasourceSchema } from "../utils/json"
|
2022-01-05 04:02:43 +13:00
|
|
|
|
|
|
|
export default class JSONArrayFetch extends FieldFetch {
|
2022-01-21 00:50:18 +13:00
|
|
|
async getDefinition(datasource) {
|
2022-01-05 04:02:43 +13:00
|
|
|
// JSON arrays need their table definitions fetched.
|
|
|
|
// We can then extract their schema as a subset of the table schema.
|
2022-01-20 22:40:53 +13:00
|
|
|
try {
|
|
|
|
const table = await this.API.fetchTableDefinition(datasource.tableId)
|
|
|
|
const schema = getJSONArrayDatasourceSchema(table?.schema, datasource)
|
|
|
|
return { schema }
|
|
|
|
} catch (error) {
|
|
|
|
return null
|
|
|
|
}
|
2022-01-05 04:02:43 +13:00
|
|
|
}
|
|
|
|
}
|