Start types
This commit is contained in:
parent
36410aac0b
commit
eea9eade5c
|
@ -17,6 +17,7 @@ import {
|
|||
GetRowResponse,
|
||||
PatchRowRequest,
|
||||
PatchRowResponse,
|
||||
RequiredKeys,
|
||||
Row,
|
||||
RowAttachment,
|
||||
RowSearchParams,
|
||||
|
@ -211,15 +212,17 @@ export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
|
|||
|
||||
await context.ensureSnippetContext(true)
|
||||
|
||||
const searchRequest = ctx.request.body
|
||||
|
||||
const enrichedQuery = await utils.enrichSearchContext(
|
||||
{ ...ctx.request.body.query },
|
||||
{ ...searchRequest.query },
|
||||
{
|
||||
user: sdk.users.getUserContextBindings(ctx.user),
|
||||
}
|
||||
)
|
||||
|
||||
const searchParams: RowSearchParams = {
|
||||
...ctx.request.body,
|
||||
const searchParams: RequiredKeys<RowSearchParams> = {
|
||||
...searchRequest,
|
||||
query: enrichedQuery,
|
||||
tableId,
|
||||
viewId,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { SearchFilters, RowSearchParams } from "../../../sdk"
|
||||
import { Row } from "../../../documents"
|
||||
import { PaginationResponse, SortOrder } from "../../../api"
|
||||
import { PaginationResponse, SortOrder, SortType } from "../../../api"
|
||||
import { ReadStream } from "fs"
|
||||
import { z } from "zod"
|
||||
|
||||
export interface SaveRowRequest extends Row {}
|
||||
|
||||
|
@ -13,7 +14,29 @@ export interface PatchRowRequest extends Row {
|
|||
|
||||
export interface PatchRowResponse extends Row {}
|
||||
|
||||
export interface SearchRowRequest extends Omit<RowSearchParams, "tableId"> {}
|
||||
const searchRowRequest = z.object({
|
||||
table: z.string(),
|
||||
query: z.object({
|
||||
allOr: z.boolean().optional(),
|
||||
}),
|
||||
paginate: z.boolean().optional(),
|
||||
bookmark: z.union([z.string(), z.number()]).optional(),
|
||||
limit: z.number().optional(),
|
||||
sort: z.string().optional(),
|
||||
sortOrder: z.nativeEnum(SortOrder).optional(),
|
||||
sortType: z.nativeEnum(SortType).optional(),
|
||||
version: z.string().optional(),
|
||||
disableEscaping: z.boolean().optional(),
|
||||
countRows: z.boolean().optional(),
|
||||
|
||||
// viewId?: string
|
||||
// query?: SearchFilters
|
||||
|
||||
// fields?: string[]
|
||||
// indexer?: () => Promise<any>
|
||||
// rows?: Row[]
|
||||
})
|
||||
export type SearchRowRequest = z.infer<typeof searchRowRequest>
|
||||
|
||||
export interface SearchViewRowRequest
|
||||
extends Pick<
|
||||
|
|
Loading…
Reference in New Issue