2022-08-05 16:57:21 +02:00
|
|
|
import { get } from "svelte/store"
|
|
|
|
import DataFetch from "./DataFetch.js"
|
|
|
|
import { TableNames } from "../constants"
|
|
|
|
|
|
|
|
export default class UserFetch extends DataFetch {
|
|
|
|
constructor(opts) {
|
|
|
|
super({
|
|
|
|
...opts,
|
|
|
|
datasource: {
|
|
|
|
tableId: TableNames.USERS,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
determineFeatureFlags() {
|
|
|
|
return {
|
|
|
|
supportsSearch: true,
|
|
|
|
supportsSort: false,
|
|
|
|
supportsPagination: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-08 17:40:32 +02:00
|
|
|
async getDefinition() {
|
|
|
|
return {
|
|
|
|
schema: {},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-05 16:57:21 +02:00
|
|
|
async getData() {
|
|
|
|
const { cursor, query } = get(this.store)
|
|
|
|
try {
|
|
|
|
// "query" normally contains a lucene query, but users uses a non-standard
|
|
|
|
// search endpoint so we use query uniquely here
|
|
|
|
const res = await this.API.searchUsers({
|
|
|
|
page: cursor,
|
|
|
|
email: query.email,
|
|
|
|
appId: query.appId,
|
2023-02-28 10:37:03 +01:00
|
|
|
paginated: query.paginated,
|
2022-08-05 16:57:21 +02:00
|
|
|
})
|
|
|
|
return {
|
|
|
|
rows: res?.data || [],
|
|
|
|
hasNextPage: res?.hasNextPage || false,
|
|
|
|
cursor: res?.nextPage || null,
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
return {
|
|
|
|
rows: [],
|
|
|
|
hasNextPage: false,
|
|
|
|
error,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|