MCPcopy
hub / github.com/brimdata/zui / QueryLoader

Class QueryLoader

apps/zui/src/domain/loads/query-loader.ts:4–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import {Loader} from "./types"
3
4export class QueryLoader implements Loader {
5 constructor(private ctx: LoadContext) {}
6
7 when() {
8 return this.ctx.files.length === 0 && !!this.ctx.query
9 }
10
11 async run() {
12 this.ctx.setProgress(Infinity)
13 const client = await this.ctx.createClient()
14 await client
15 .query(this.loadQuery, {signal: this.ctx.signal})
16 .then((r) => r.js())
17 this.ctx.setProgress(1)
18 }
19
20 private get loadQuery() {
21 // This is the load op syntax
22 // load <pool>[@<branch>] [author <author>] [message <message>] [meta <meta>]
23 return [
24 this.ctx.query,
25 "| load",
26 this.ctx.poolId + "@" + this.ctx.branch,
27 "author " + JSON.stringify(this.ctx.author),
28 "message " + JSON.stringify(this.ctx.body),
29 ].join(" ")
30 }
31}
32
33export function addLoad(query: string, poolId) {
34 return query + " | load " + poolId

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected