Fix search API break.
This commit is contained in:
parent
e3256cb005
commit
f475454bce
|
@ -79,8 +79,8 @@ export class QueryBuilder<T> {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
setSource(sourceId: string) {
|
setTable(tableId: string) {
|
||||||
this.#query.equal!.tableId = sourceId
|
this.#query.equal!.tableId = tableId
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,8 +637,8 @@ async function recursiveSearch<T>(
|
||||||
.setSortOrder(params.sortOrder)
|
.setSortOrder(params.sortOrder)
|
||||||
.setSortType(params.sortType)
|
.setSortType(params.sortType)
|
||||||
|
|
||||||
if (params.sourceId) {
|
if (params.tableId) {
|
||||||
queryBuilder.setSource(params.sourceId)
|
queryBuilder.setTable(params.tableId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const page = await queryBuilder.run()
|
const page = await queryBuilder.run()
|
||||||
|
@ -671,8 +671,8 @@ export async function paginatedSearch<T>(
|
||||||
if (params.version) {
|
if (params.version) {
|
||||||
search.setVersion(params.version)
|
search.setVersion(params.version)
|
||||||
}
|
}
|
||||||
if (params.sourceId) {
|
if (params.tableId) {
|
||||||
search.setSource(params.sourceId)
|
search.setTable(params.tableId)
|
||||||
}
|
}
|
||||||
if (params.sort) {
|
if (params.sort) {
|
||||||
search
|
search
|
||||||
|
@ -694,8 +694,8 @@ export async function paginatedSearch<T>(
|
||||||
// Try fetching 1 row in the next page to see if another page of results
|
// Try fetching 1 row in the next page to see if another page of results
|
||||||
// exists or not
|
// exists or not
|
||||||
search.setBookmark(searchResults.bookmark).setLimit(1)
|
search.setBookmark(searchResults.bookmark).setLimit(1)
|
||||||
if (params.sourceId) {
|
if (params.tableId) {
|
||||||
search.setSource(params.sourceId)
|
search.setTable(params.tableId)
|
||||||
}
|
}
|
||||||
const nextResults = await search.run()
|
const nextResults = await search.run()
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ describe("lucene", () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sourceId: TABLE_ID,
|
tableId: TABLE_ID,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
sort: "property",
|
sort: "property",
|
||||||
sortType: SortType.STRING,
|
sortType: SortType.STRING,
|
||||||
|
@ -390,7 +390,7 @@ describe("lucene", () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sourceId: TABLE_ID,
|
tableId: TABLE_ID,
|
||||||
query: {},
|
query: {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -221,7 +221,8 @@ export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
|
||||||
const searchParams: RowSearchParams = {
|
const searchParams: RowSearchParams = {
|
||||||
...ctx.request.body,
|
...ctx.request.body,
|
||||||
query: enrichedQuery,
|
query: enrichedQuery,
|
||||||
sourceId: viewId || tableId,
|
tableId,
|
||||||
|
viewId,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
|
|
|
@ -3,8 +3,6 @@ import {
|
||||||
ViewV2,
|
ViewV2,
|
||||||
SearchRowResponse,
|
SearchRowResponse,
|
||||||
SearchViewRowRequest,
|
SearchViewRowRequest,
|
||||||
RequiredKeys,
|
|
||||||
RowSearchParams,
|
|
||||||
SearchFilterKey,
|
SearchFilterKey,
|
||||||
LogicalOperator,
|
LogicalOperator,
|
||||||
Aggregation,
|
Aggregation,
|
||||||
|
@ -83,9 +81,9 @@ export async function searchView(
|
||||||
field,
|
field,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const searchOptions: RequiredKeys<SearchViewRowRequest> &
|
const result = await sdk.rows.search({
|
||||||
RequiredKeys<Pick<RowSearchParams, "sourceId" | "query" | "fields">> = {
|
viewId: view.id,
|
||||||
sourceId: view.id,
|
tableId: view.tableId,
|
||||||
query: enrichedQuery,
|
query: enrichedQuery,
|
||||||
fields: viewFields,
|
fields: viewFields,
|
||||||
...getSortOptions(body, view),
|
...getSortOptions(body, view),
|
||||||
|
@ -94,9 +92,8 @@ export async function searchView(
|
||||||
paginate: body.paginate,
|
paginate: body.paginate,
|
||||||
countRows: body.countRows,
|
countRows: body.countRows,
|
||||||
aggregations,
|
aggregations,
|
||||||
}
|
})
|
||||||
|
|
||||||
const result = await sdk.rows.search(searchOptions)
|
|
||||||
result.rows.forEach(r => (r._viewId = view.id))
|
result.rows.forEach(r => (r._viewId = view.id))
|
||||||
ctx.body = result
|
ctx.body = result
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,11 @@ describe.each([
|
||||||
if (isInMemory) {
|
if (isInMemory) {
|
||||||
return dataFilters.search(_.cloneDeep(rows), this.query)
|
return dataFilters.search(_.cloneDeep(rows), this.query)
|
||||||
} else {
|
} else {
|
||||||
return config.api.row.search(this.query.sourceId, this.query)
|
const sourceId = this.query.viewId || this.query.tableId
|
||||||
|
if (!sourceId) {
|
||||||
|
throw new Error("No source ID provided")
|
||||||
|
}
|
||||||
|
return config.api.row.search(sourceId, this.query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +331,8 @@ describe.each([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectSearch(query: Omit<RowSearchParams, "sourceId">) {
|
function expectSearch(query: Omit<RowSearchParams, "tableId">) {
|
||||||
return new SearchAssertion({ ...query, sourceId: table._id! })
|
return new SearchAssertion({ ...query, tableId: table._id! })
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectQuery(query: SearchFilters) {
|
function expectQuery(query: SearchFilters) {
|
||||||
|
@ -1898,7 +1902,7 @@ describe.each([
|
||||||
let { rows: fullRowList } = await config.api.row.search(
|
let { rows: fullRowList } = await config.api.row.search(
|
||||||
table._id!,
|
table._id!,
|
||||||
{
|
{
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {},
|
query: {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -1909,7 +1913,7 @@ describe.each([
|
||||||
rowCount: number = 0
|
rowCount: number = 0
|
||||||
do {
|
do {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
paginate: true,
|
paginate: true,
|
||||||
query: {},
|
query: {},
|
||||||
|
@ -1933,7 +1937,7 @@ describe.each([
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
limit: 3,
|
limit: 3,
|
||||||
query: {},
|
query: {},
|
||||||
bookmark,
|
bookmark,
|
||||||
|
|
|
@ -113,7 +113,7 @@ describe("/templates", () => {
|
||||||
expect(users.name).toBe("Users")
|
expect(users.name).toBe("Users")
|
||||||
|
|
||||||
const { rows } = await config.api.row.search(agencyProjects._id!, {
|
const { rows } = await config.api.row.search(agencyProjects._id!, {
|
||||||
sourceId: agencyProjects._id!,
|
tableId: agencyProjects._id!,
|
||||||
query: {},
|
query: {},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ describe("Google Sheets Integration", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
let resp = await config.api.row.search(table._id!, {
|
let resp = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {},
|
query: {},
|
||||||
paginate: true,
|
paginate: true,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
@ -228,7 +228,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
while (resp.hasNextPage) {
|
while (resp.hasNextPage) {
|
||||||
resp = await config.api.row.search(table._id!, {
|
resp = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {},
|
query: {},
|
||||||
paginate: true,
|
paginate: true,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
@ -637,7 +637,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
it("should be able to find rows with equals filter", async () => {
|
it("should be able to find rows with equals filter", async () => {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
equal: {
|
equal: {
|
||||||
name: "Foo",
|
name: "Foo",
|
||||||
|
@ -651,7 +651,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
it("should be able to find rows with not equals filter", async () => {
|
it("should be able to find rows with not equals filter", async () => {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
notEqual: {
|
notEqual: {
|
||||||
name: "Foo",
|
name: "Foo",
|
||||||
|
@ -666,7 +666,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
it("should be able to find rows with empty filter", async () => {
|
it("should be able to find rows with empty filter", async () => {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
empty: {
|
empty: {
|
||||||
name: null,
|
name: null,
|
||||||
|
@ -679,7 +679,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
it("should be able to find rows with not empty filter", async () => {
|
it("should be able to find rows with not empty filter", async () => {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
notEmpty: {
|
notEmpty: {
|
||||||
name: null,
|
name: null,
|
||||||
|
@ -692,7 +692,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
it("should be able to find rows with one of filter", async () => {
|
it("should be able to find rows with one of filter", async () => {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
oneOf: {
|
oneOf: {
|
||||||
name: ["Foo", "Bar"],
|
name: ["Foo", "Bar"],
|
||||||
|
@ -707,7 +707,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
it("should be able to find rows with fuzzy filter", async () => {
|
it("should be able to find rows with fuzzy filter", async () => {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
fuzzy: {
|
fuzzy: {
|
||||||
name: "oo",
|
name: "oo",
|
||||||
|
@ -721,7 +721,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
it("should be able to find rows with range filter", async () => {
|
it("should be able to find rows with range filter", async () => {
|
||||||
const response = await config.api.row.search(table._id!, {
|
const response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
range: {
|
range: {
|
||||||
name: {
|
name: {
|
||||||
|
@ -750,7 +750,7 @@ describe("Google Sheets Integration", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
let response = await config.api.row.search(table._id!, {
|
let response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: { equal: { name: "Unique value!" } },
|
query: { equal: { name: "Unique value!" } },
|
||||||
paginate: true,
|
paginate: true,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
@ -759,7 +759,7 @@ describe("Google Sheets Integration", () => {
|
||||||
|
|
||||||
while (response.hasNextPage) {
|
while (response.hasNextPage) {
|
||||||
response = await config.api.row.search(table._id!, {
|
response = await config.api.row.search(table._id!, {
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: { equal: { name: "Unique value!" } },
|
query: { equal: { name: "Unique value!" } },
|
||||||
paginate: true,
|
paginate: true,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { ExportRowsParams, ExportRowsResult } from "./search/types"
|
||||||
import { dataFilters } from "@budibase/shared-core"
|
import { dataFilters } from "@budibase/shared-core"
|
||||||
import sdk from "../../index"
|
import sdk from "../../index"
|
||||||
import { searchInputMapping } from "./search/utils"
|
import { searchInputMapping } from "./search/utils"
|
||||||
import { features, docIds } from "@budibase/backend-core"
|
import { features } from "@budibase/backend-core"
|
||||||
import tracer from "dd-trace"
|
import tracer from "dd-trace"
|
||||||
import { getQueryableFields, removeInvalidFilters } from "./queryUtils"
|
import { getQueryableFields, removeInvalidFilters } from "./queryUtils"
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ export async function search(
|
||||||
): Promise<SearchResponse<Row>> {
|
): Promise<SearchResponse<Row>> {
|
||||||
return await tracer.trace("search", async span => {
|
return await tracer.trace("search", async span => {
|
||||||
span?.addTags({
|
span?.addTags({
|
||||||
sourceId: options.sourceId,
|
tableId: options.tableId,
|
||||||
|
viewId: options.viewId,
|
||||||
query: options.query,
|
query: options.query,
|
||||||
sort: options.sort,
|
sort: options.sort,
|
||||||
sortOrder: options.sortOrder,
|
sortOrder: options.sortOrder,
|
||||||
|
@ -76,20 +77,16 @@ export async function search(
|
||||||
|
|
||||||
let source: Table | ViewV2
|
let source: Table | ViewV2
|
||||||
let table: Table
|
let table: Table
|
||||||
if (docIds.isTableId(options.sourceId)) {
|
if (options.viewId) {
|
||||||
source = await sdk.tables.getTable(options.sourceId)
|
source = await sdk.views.get(options.viewId)
|
||||||
table = source
|
table = await sdk.views.getTable(source)
|
||||||
options = searchInputMapping(source, options)
|
options = searchInputMapping(table, options)
|
||||||
} else if (docIds.isViewId(options.sourceId)) {
|
} else if (options.tableId) {
|
||||||
source = await sdk.views.get(options.sourceId)
|
source = await sdk.tables.getTable(options.tableId)
|
||||||
table = await sdk.tables.getTable(source.tableId)
|
table = source
|
||||||
options = searchInputMapping(table, options)
|
options = searchInputMapping(table, options)
|
||||||
|
|
||||||
span.addTags({
|
|
||||||
tableId: table._id,
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Invalid source ID: ${options.sourceId}`)
|
throw new Error(`Invalid source ID: ${options.viewId || options.tableId}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.query) {
|
if (options.query) {
|
||||||
|
|
|
@ -200,7 +200,7 @@ export async function exportRows(
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await search(
|
let result = await search(
|
||||||
{ sourceId: table._id!, query: requestQuery, sort, sortOrder },
|
{ tableId: table._id!, query: requestQuery, sort, sortOrder },
|
||||||
table
|
table
|
||||||
)
|
)
|
||||||
let rows: Row[] = []
|
let rows: Row[] = []
|
||||||
|
|
|
@ -64,7 +64,7 @@ export async function exportRows(
|
||||||
result = await outputProcessing(table, response)
|
result = await outputProcessing(table, response)
|
||||||
} else if (query) {
|
} else if (query) {
|
||||||
let searchResponse = await sdk.rows.search({
|
let searchResponse = await sdk.rows.search({
|
||||||
sourceId: tableId,
|
tableId,
|
||||||
query,
|
query,
|
||||||
sort,
|
sort,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
|
|
|
@ -19,8 +19,6 @@ export async function search(
|
||||||
options: RowSearchParams,
|
options: RowSearchParams,
|
||||||
source: Table | ViewV2
|
source: Table | ViewV2
|
||||||
): Promise<SearchResponse<Row>> {
|
): Promise<SearchResponse<Row>> {
|
||||||
const { sourceId } = options
|
|
||||||
|
|
||||||
let table: Table
|
let table: Table
|
||||||
if (sdk.views.isView(source)) {
|
if (sdk.views.isView(source)) {
|
||||||
table = await sdk.views.getTable(source.id)
|
table = await sdk.views.getTable(source.id)
|
||||||
|
@ -31,7 +29,8 @@ export async function search(
|
||||||
const { paginate, query } = options
|
const { paginate, query } = options
|
||||||
|
|
||||||
const params: RowSearchParams = {
|
const params: RowSearchParams = {
|
||||||
sourceId: table._id!,
|
tableId: options.tableId,
|
||||||
|
viewId: options.viewId,
|
||||||
sort: options.sort,
|
sort: options.sort,
|
||||||
sortOrder: options.sortOrder,
|
sortOrder: options.sortOrder,
|
||||||
sortType: options.sortType,
|
sortType: options.sortType,
|
||||||
|
@ -59,7 +58,7 @@ export async function search(
|
||||||
// Enrich search results with relationships
|
// Enrich search results with relationships
|
||||||
if (response.rows && response.rows.length) {
|
if (response.rows && response.rows.length) {
|
||||||
// enrich with global users if from users table
|
// enrich with global users if from users table
|
||||||
if (sourceId === InternalTables.USER_METADATA) {
|
if (table._id === InternalTables.USER_METADATA) {
|
||||||
response.rows = await getGlobalUsersFromMetadata(response.rows as User[])
|
response.rows = await getGlobalUsersFromMetadata(response.rows as User[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ describe.each([
|
||||||
it("querying by fields will always return data attribute columns", async () => {
|
it("querying by fields will always return data attribute columns", async () => {
|
||||||
await config.doInContext(config.appId, async () => {
|
await config.doInContext(config.appId, async () => {
|
||||||
const { rows } = await search({
|
const { rows } = await search({
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {},
|
query: {},
|
||||||
fields: ["name", "age"],
|
fields: ["name", "age"],
|
||||||
})
|
})
|
||||||
|
@ -142,7 +142,7 @@ describe.each([
|
||||||
it("will decode _id in oneOf query", async () => {
|
it("will decode _id in oneOf query", async () => {
|
||||||
await config.doInContext(config.appId, async () => {
|
await config.doInContext(config.appId, async () => {
|
||||||
const result = await search({
|
const result = await search({
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
oneOf: {
|
oneOf: {
|
||||||
_id: ["%5B1%5D", "%5B4%5D", "%5B8%5D"],
|
_id: ["%5B1%5D", "%5B4%5D", "%5B8%5D"],
|
||||||
|
@ -174,7 +174,7 @@ describe.each([
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const result = await search({
|
const result = await search({
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {},
|
query: {},
|
||||||
})
|
})
|
||||||
expect(result.rows).toHaveLength(10)
|
expect(result.rows).toHaveLength(10)
|
||||||
|
@ -205,7 +205,7 @@ describe.each([
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const result = await search({
|
const result = await search({
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {},
|
query: {},
|
||||||
fields: ["name", "age"],
|
fields: ["name", "age"],
|
||||||
})
|
})
|
||||||
|
@ -229,7 +229,7 @@ describe.each([
|
||||||
async (queryFields, expectedRows) => {
|
async (queryFields, expectedRows) => {
|
||||||
await config.doInContext(config.appId, async () => {
|
await config.doInContext(config.appId, async () => {
|
||||||
const { rows } = await search({
|
const { rows } = await search({
|
||||||
sourceId: table._id!,
|
tableId: table._id!,
|
||||||
query: {
|
query: {
|
||||||
$or: {
|
$or: {
|
||||||
conditions: [
|
conditions: [
|
||||||
|
|
|
@ -48,7 +48,7 @@ describe.each([tableWithUserCol, tableWithUsersCol])(
|
||||||
|
|
||||||
it("should be able to map ro_ to global user IDs", () => {
|
it("should be able to map ro_ to global user IDs", () => {
|
||||||
const params: RowSearchParams = {
|
const params: RowSearchParams = {
|
||||||
sourceId: tableId,
|
tableId: tableId,
|
||||||
query: {
|
query: {
|
||||||
equal: {
|
equal: {
|
||||||
"1:user": userMedataId,
|
"1:user": userMedataId,
|
||||||
|
@ -61,7 +61,7 @@ describe.each([tableWithUserCol, tableWithUsersCol])(
|
||||||
|
|
||||||
it("should handle array of user IDs", () => {
|
it("should handle array of user IDs", () => {
|
||||||
const params: RowSearchParams = {
|
const params: RowSearchParams = {
|
||||||
sourceId: tableId,
|
tableId: tableId,
|
||||||
query: {
|
query: {
|
||||||
oneOf: {
|
oneOf: {
|
||||||
"1:user": [userMedataId, globalUserId],
|
"1:user": [userMedataId, globalUserId],
|
||||||
|
@ -78,7 +78,7 @@ describe.each([tableWithUserCol, tableWithUsersCol])(
|
||||||
it("shouldn't change any other input", () => {
|
it("shouldn't change any other input", () => {
|
||||||
const email = "test@example.com"
|
const email = "test@example.com"
|
||||||
const params: RowSearchParams = {
|
const params: RowSearchParams = {
|
||||||
sourceId: tableId,
|
tableId: tableId,
|
||||||
query: {
|
query: {
|
||||||
equal: {
|
equal: {
|
||||||
"1:user": email,
|
"1:user": email,
|
||||||
|
@ -91,7 +91,7 @@ describe.each([tableWithUserCol, tableWithUsersCol])(
|
||||||
|
|
||||||
it("shouldn't error if no query supplied", () => {
|
it("shouldn't error if no query supplied", () => {
|
||||||
// @ts-expect-error - intentionally passing in a bad type
|
// @ts-expect-error - intentionally passing in a bad type
|
||||||
const output = searchInputMapping(col, { sourceId: tableId })
|
const output = searchInputMapping(col, { tableId })
|
||||||
expect(output.query).toBeUndefined()
|
expect(output.query).toBeUndefined()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,8 @@ export interface Aggregation {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SearchParams {
|
export interface SearchParams {
|
||||||
sourceId?: string
|
tableId?: string
|
||||||
|
viewId?: string
|
||||||
query?: SearchFilters
|
query?: SearchFilters
|
||||||
paginate?: boolean
|
paginate?: boolean
|
||||||
bookmark?: string | number
|
bookmark?: string | number
|
||||||
|
@ -29,7 +30,7 @@ export interface SearchParams {
|
||||||
|
|
||||||
// when searching for rows we want a more extensive search type that requires certain properties
|
// when searching for rows we want a more extensive search type that requires certain properties
|
||||||
export interface RowSearchParams
|
export interface RowSearchParams
|
||||||
extends WithRequired<SearchParams, "sourceId" | "query"> {}
|
extends WithRequired<SearchParams, "tableId" | "query"> {}
|
||||||
|
|
||||||
export interface SearchResponse<T> {
|
export interface SearchResponse<T> {
|
||||||
rows: T[]
|
rows: T[]
|
||||||
|
|
Loading…
Reference in New Issue