Back
Version 93
11/27/2024
import { ValSession } from "https://esm.town/v/maxm/valSession";
import type { TSearchFilter, WideApi } from "https://esm.town/v/maxm/wideApi";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=31";
import { hc } from "npm:hono/client";
const { htmlUrl } = extractValInfo(import.meta.url);
const _client = hc<WideApi>("https://maxm-wideapi.web.val.run/");
export class Wide {
#client: typeof _client;
#sessionToken: string;
constructor(sessionToken: string) {
// TODO: can we use a global client?
this.#client = hc<WideApi>("https://maxm-wideapi.web.val.run/");
this.#sessionToken = sessionToken;
}
async fields(prefix: string) {
const resp = await this.#client.v1.fields.$get({
query: { prefix: `${prefix}%` },
header: { sessiontoken: this.#sessionToken },
});
return await resp.json();
}
async write(data: any[]) {
const resp = await this.#client.v1.write.$post({
json: data,
header: { sessiontoken: this.#sessionToken },
});
return await resp.json();
}
async search({
filters,
start,
end,
limit = 100,
}: {
maxm-wide.web.val.run
Updated: December 13, 2024