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 }),
4import { EXPIRY } from "https://esm.town/v/websandbox/config";
5
6export default async function(interval: Interval) {
7 for (const b of await blob.list("play_")) {
8 if ((new Date(b.lastModified).valueOf() + EXPIRY) < Date.now()) {
19type Constraint = { cell: Cell; value: Val };
20
21function constrainRow(possible_values: PossibleValues, row: number, value: Val): Constraint[] {
22 const constrained: Constraint[] = [];
23 for (let col = 0; col < 9; col++) {
31}
32
33function constrainCol(possible_values: PossibleValues, col: number, value: Val): Constraint[] {
34 const constrained: Constraint[] = [];
35 for (let row = 0; row < 9; row++) {
43}
44
45function constrainBox(possible_values: PossibleValues, row: number, col: number, value: Val): Constraint[] {
46 const constrained: Constraint[] = [];
47 const box_row = Math.floor(row / 3);
59}
60
61function undoConstraints(possible_values: PossibleValues, constraints: Constraint[]) {
62 for (const { cell: { row, col }, value } of constraints) {
63 possible_values[row][col]!.add(value);
66
67// Lets try a "solve like a human" algorithm.
68export function solve(sudoku: Sudoku): Sudoku | null {
69 sudoku = Sudoku.parse(sudoku);
70
10export type Sudoku = z.infer<typeof Sudoku>;
11
12export function print(sudoku: Sudoku) {
13 sudoku = Sudoku.parse(sudoku);
14 for (let row = 0; row < ROWS; row++) {
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`);
2import { db } from "https://esm.town/v/sqlite/db?v=9";
3
4export default async function(req: Request) {
5 const url = new URL(req.url);
6 if (!url.searchParams.has("query")) {
17const COOKIE_NAME = "AUTH_ID_TOKEN";
18
19export function authId(url: string) {
20 const SCOPES = {
21 id: "provides proof that you are you",
25 const NAME = "@" + slug;
26
27 async function emailSignInLink(clientToken: string) {
28 const minutes = 15;
29 const token = await generate({
45 }
46
47 async function handler(req: Request) {
48 const { searchParams: qs } = new URL(req.url);
49
280}
281
282export function getAuthCookie(req: Request) {
283 return getCookies(req.headers)[COOKIE_NAME];
284}
285
286export function setAuthCookie(res: Response, token: string | undefined) {
287 if (token === undefined) {
288 setCookie(res.headers, {
306}
307
308export function getScopeUrl(scope: string) {
309 return getValUrlFromName(scope.split("/").slice(0, 2).join("/"), "val.town");
310}
311
312export function getScopeLink(scope: string) {
313 const name = scope.split("/").slice(0, 2).join("/");
314 return html`