Start types
This commit is contained in:
parent
36410aac0b
commit
eea9eade5c
|
@ -17,6 +17,7 @@ import {
|
||||||
GetRowResponse,
|
GetRowResponse,
|
||||||
PatchRowRequest,
|
PatchRowRequest,
|
||||||
PatchRowResponse,
|
PatchRowResponse,
|
||||||
|
RequiredKeys,
|
||||||
Row,
|
Row,
|
||||||
RowAttachment,
|
RowAttachment,
|
||||||
RowSearchParams,
|
RowSearchParams,
|
||||||
|
@ -211,15 +212,17 @@ export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
|
||||||
|
|
||||||
await context.ensureSnippetContext(true)
|
await context.ensureSnippetContext(true)
|
||||||
|
|
||||||
|
const searchRequest = ctx.request.body
|
||||||
|
|
||||||
const enrichedQuery = await utils.enrichSearchContext(
|
const enrichedQuery = await utils.enrichSearchContext(
|
||||||
{ ...ctx.request.body.query },
|
{ ...searchRequest.query },
|
||||||
{
|
{
|
||||||
user: sdk.users.getUserContextBindings(ctx.user),
|
user: sdk.users.getUserContextBindings(ctx.user),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const searchParams: RowSearchParams = {
|
const searchParams: RequiredKeys<RowSearchParams> = {
|
||||||
...ctx.request.body,
|
...searchRequest,
|
||||||
query: enrichedQuery,
|
query: enrichedQuery,
|
||||||
tableId,
|
tableId,
|
||||||
viewId,
|
viewId,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { SearchFilters, RowSearchParams } from "../../../sdk"
|
import { SearchFilters, RowSearchParams } from "../../../sdk"
|
||||||
import { Row } from "../../../documents"
|
import { Row } from "../../../documents"
|
||||||
import { PaginationResponse, SortOrder } from "../../../api"
|
import { PaginationResponse, SortOrder, SortType } from "../../../api"
|
||||||
import { ReadStream } from "fs"
|
import { ReadStream } from "fs"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
export interface SaveRowRequest extends Row {}
|
export interface SaveRowRequest extends Row {}
|
||||||
|
|
||||||
|
@ -13,7 +14,29 @@ export interface PatchRowRequest extends Row {
|
||||||
|
|
||||||
export interface PatchRowResponse 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
|
export interface SearchViewRowRequest
|
||||||
extends Pick<
|
extends Pick<
|
||||||
|
|
Loading…
Reference in New Issue