gitflarePublicPartly agent-ready50
cf-workflows-pipeline
Durable content pipeline on Cloudflare Workflows: ingest, extract, summarise with Workers AI via AI Gateway, human approval, publish.
- LicenseApache-2.0
- LanguageTypeScript
- Last landed
629b2faOct 20, 2026
Fix pipeline runs failing at ingest (steps.attempt NOT NULL)
629b2faimport { describe, it, expect, vi } from "vitest";vi.mock("cloudflare:workers", () => ({ WorkflowEntrypoint: class {} }));import { handle } from "../src/index";import { extractiveSummary } from "../src/lib/fallback";import { validateUrl } from "../src/lib/validate";import { parsePlan, shouldFail } from "../src/lib/inject";import { extract } from "../src/lib/extract";import type { Env } from "../src/env"; const env = { DB: {}, ASSETS: { fetch: async () => new Response("a") } } as unknown as Env;describe("api shape", () => { it("error shape + security headers", async () => { const r = await handle(new Request("http://x/api/runs", { method: "POST", body: "nope" }), env); expect(r.status).toBe(400); expect(await r.json()).toMatchObject({ error: { code: "bad_request" } }); expect(r.headers.get("x-content-type-options")).toBe("nosniff"); }); it("rejects private url", async () => { const r = await handle(new Request("http://x/api/runs", { method: "POST", body: JSON.stringify({ url: "http://127.0.0.1/" }) }), env); expect(r.status).toBe(400); });});describe("libs", () => { it("fallback summary", () => { expect(extractiveSummary("One. Two. Three.", "short")).toBe("One. Two."); }); it("validate", () => { expect(validateUrl("ftp://a.com").ok).toBe(false); expect(validateUrl("http://localhost").ok).toBe(false); expect(validateUrl("https://example.com").ok).toBe(true); }); it("inject", () => { const p = parsePlan({ extract: 2 }); expect(shouldFail(p, "extract", 2)).toBe(true); expect(shouldFail(p, "extract", 3)).toBe(false); }); it("extract", () => { expect(extract("<title>T</title><nav>x</nav><article>Hi there</article>")).toEqual({ title: "T", text: "Hi there" }); });});