#!/usr/bin/env node /** * Do apicity's fal request schemas still hold what fal's live input schemas say? * * pnpm run check:fal-schema-drift # every endpoint, free and keyless * pnpm run check:fal-schema-drift -- --endpoint # one endpoint * pnpm run check:fal-schema-drift -- --cache # reuse documents a rerun already fetched * pnpm run check:fal-schema-drift -- --out # write the JSON report * pnpm run check:fal-schema-drift -- --json # print the JSON report * * For every endpoint in FAL_ENDPOINT_REQUEST_SCHEMAS it GETs fal's public queue * OpenAPI document (no key, no account header, a generic User-Agent, one request * at a time with a pause) and compares the input component field by field with * our zod schema: see scripts/lib/fal-schema-drift.mjs for the classes and what * is compared. * * Exit 0 when no endpoint differs, 1 when a STRICTER, LOOSER, MISSING, EXTRA or * GONE line was found, 2 when the check could not run. UNMAPPED lines (the * platform endpoints, which have no endpoint id) never change the exit code. * CI replays with no network, so this is a routine to run, not a gate. */ import { writeFile } from "node:fs/promises"; import { parseArgs } from "node:util"; import { createFal } from "../packages/provider/fal/src/index.ts"; import { FAL_ENDPOINT_REQUEST_SCHEMAS } from "../packages/provider/fal/src/zod.ts"; import { CLASS_MEANINGS, DEFAULT_DELAY_MS, DRIFT_CLASSES, DRIFT_USER_AGENT, exitCodeFor, FAL_QUEUE_OPENAPI_URL, fetchDocuments, oursJsonSchema, pairEndpoints, schemaDrift, } from "./lib/fal-schema-drift.mjs"; function show(value) { if (value === null || value === undefined) return "none"; return typeof value === "string" ? value : JSON.stringify(value); } function describe(diff) { if (diff.class === "GONE" || diff.class === "UNMAPPED") { return `${diff.class} ${diff.endpoint}: ${diff.reason}`; } const detail = diff.detail ? ` ${JSON.stringify(diff.detail)}` : ""; return `${diff.class} ${diff.endpoint} | ${diff.field} ${diff.facet} | ours ${show(diff.ours)} | live ${show(diff.live)}${detail}`; } async function main() { const { values } = parseArgs({ // `pnpm run