Files
agency/.pnpm-store/v3/files/c3/83a739f3b1861e512ec5842aba3b61929c40678ea2a03ad293c46c87bb239c059eb6da752ea6fe71851017ff21ec0e293109b0a1450ba9b17b87ad95fd91a3
hanzo-agent 5af6960b87 run project
Run: sess_f37640604ae254cb4d11dc6217f7b721
2026-09-30 00:04:56 +00:00

105 lines
3.0 KiB
Plaintext

//#region src/client.ts
var e = class {
baseUrl;
prefix;
fetchFn;
constructor(e = {}) {
this.baseUrl = (e.baseUrl ?? (typeof window < "u" ? window.location.origin : "")).replace(/\/$/, ""), this.prefix = (e.pathPrefix ?? "").replace(/\/$/, ""), this.fetchFn = e.fetch ?? (typeof fetch < "u" ? fetch.bind(globalThis) : (() => {
throw Error("fetch is not available");
})());
}
url(e) {
return `${this.baseUrl}${this.prefix}/v1/waitlist${e}`;
}
async join(e) {
let t = await this.fetchFn(this.url("/join"), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(e)
});
return this.parse(t);
}
async status(e) {
let t = new URLSearchParams({
waitlist: e.waitlist,
email: e.email
}), n = await this.fetchFn(this.url(`/status?${t}`), { method: "GET" });
return this.parse(n);
}
async list(e) {
let t = new URLSearchParams({ waitlist: e.waitlist });
e.page && t.set("page", String(e.page)), e.pageSize && t.set("pageSize", String(e.pageSize));
let n = await this.fetchFn(this.url(`/list?${t}`), { method: "GET" });
return this.parseGeneric(n);
}
async neighborhood(e) {
let t = new URLSearchParams({
waitlist: e.waitlist,
email: e.email
});
e.window && t.set("window", String(e.window));
let n = await this.fetchFn(this.url(`/neighborhood?${t}`), { method: "GET" });
return this.parseGeneric(n);
}
async trackShare(e) {
let t = await this.fetchFn(this.url("/track-share"), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(e)
});
return this.parseGeneric(t);
}
async invite(e) {
let t = await this.fetchFn(this.url("/invite"), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(e)
});
return this.parseGeneric(t);
}
async activity(e) {
let t = new URLSearchParams({ waitlist: e.waitlist });
e.limit && t.set("limit", String(e.limit)), e.types?.length && t.set("types", e.types.join(","));
let n = await this.fetchFn(this.url(`/activity?${t}`), { method: "GET" });
return this.parseGeneric(n);
}
async exportCsv(e, t = {}) {
let n = new URLSearchParams({ waitlist: e }), r = {};
t.authorization && (r.Authorization = t.authorization);
let i = await this.fetchFn(this.url(`/export?${n}`), {
method: "GET",
headers: r
});
if (!i.ok) throw Error(`export failed: ${i.status} ${await i.text()}`);
return i.text();
}
async parse(e) {
return this.parseGeneric(e);
}
async parseGeneric(e) {
let t = null;
try {
t = await e.json();
} catch {}
if (!e.ok) {
let n = t && typeof t == "object" && "message" in t && typeof t.message == "string" ? t.message : `request failed with ${e.status}`;
return {
ok: !1,
status: e.status,
message: n,
data: t
};
}
return t;
}
};
async function t(t, n) {
return new e(n).join(t);
}
async function n(t, n) {
return new e(n).status(t);
}
//#endregion
export { e as WaitlistClient, t as join, n as status };
//# sourceMappingURL=client.js.map