in src/api/api/sql.ts [302:351]
async query (this: That, params?: T.SqlQueryRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SqlQueryResponse>
async query (this: That, params?: T.SqlQueryRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SqlQueryResponse, unknown>>
async query (this: That, params?: T.SqlQueryRequest, options?: TransportRequestOptions): Promise<T.SqlQueryResponse>
async query (this: That, params?: T.SqlQueryRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['sql.query']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {}
for (const key in params) {
if (acceptedBody.includes(key)) {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
const method = body != null ? 'POST' : 'GET'
const path = '/_sql'
const meta: TransportRequestMetadata = {
name: 'sql.query'
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}