16};
17
18export function sqliteUniverseWithOptions(options: SqliteUniverseOptions) {
19 return {
20 execute(statement: InStatement) {
27}
28
29async function execute(
30 statement: InStatement,
31 options: SqliteUniverseOptions = {},
35}
36
37async function batch(
38 statements: InStatement[],
39 options: SqliteUniverseOptions = {},
83}
84
85async function createSqliteFromEndpointTables(
86 endpointTableMap: EndpointTableMap,
87 { interfaces = defaultInterfaces }: SqliteUniverseOptions = {},
90 let sqlite = await interfaces.exact?.[endpoint];
91
92 if (sqlite instanceof Function) {
93 sqlite = await sqlite({ endpoint, tables });
94 }
3
4export let duckdbExample = (async () => {
5 async function createWorker(url: string) {
6 const workerScript = await fetch(url);
7 const workerURL = URL.createObjectURL(await workerScript.blob());
83}
84
85export function Statement(
86 strings: TemplateStringsArray,
87 ...replacements: (InValue | StatementInstance)[]
2import ts from "npm:typescript";
3
4export function extractImports(code: string): string[] {
5 const sourceFile = ts.createSourceFile(
6 "val.ts",
10 const imports = [];
11
12 function visitNode(node: ts.Node) {
13 if (ts.isImportDeclaration(node)) {
14 const importClause = node.importClause;
8});
9
10export default async function(req: Request): Promise<Response> {
11 if (req.method === "GET") {
12 return Response.json({ ignored: true });
2import { getValEndpointFromName } from "https://esm.town/v/postpostscript/meta";
3
4export default function(req: Request) {
5 const { author, name } = extractValInfo(import.meta.url);
6 const blogEndpoint = getValEndpointFromName(`@${author}/blog`);
7At least these are how we use them in the `webhookHandler`
8
9| Function | Mux Event | Note |
10|------------------|-------------------|-------------------------------|
11| `createVideo()` | `video.upload.created` | Triggered when a direct upload is initially created |
1export default async function() {
2 const res = await fetch("https://api.manifold.markets/request-loan", {
3 headers: {
33);`;
34
35function valToRow(val: Val) {
36 return [
37 val.id,
49}
50
51async function insertRows(rows, options: { sqlite: SqliteInterface } = { sqlite }) {
52 const query =
53 sql`INSERT OR REPLACE INTO vals (id, name, code, version, privacy, public, run_start_at, run_end_at, created_at, author_id, author_username) VALUES ${
58}
59
60export async function valtownToSQLite(options: { sqlite: SqliteInterface } = { sqlite }) {
61 await options.sqlite.execute(createQuery);
62 let url = "https://api.val.town/v1/search/vals?query=%20&limit=100";
1export async function create({ code, token }: { code: string; token: string }) {
2 const { error, details, url } = await (await fetch("https://websandbox-createAPI.web.val.run", {
3 body: JSON.stringify({ code, token }),
Simple functional CSS library for Val Town
A helper function to build a file's email
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.