Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : SPIDER — Universal Web Intelligence Engine8 * File : sdk/typescript/src/routes.ts9 * Module : Sdk10 * Repository : https://git.spboucher.ai/spider11 * Project Website : Not specified12 * Created : 2026-12-0413 * Last Modified : 2026-12-0414 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : ISC34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243/**44 * The routes of the SPIDER API used by the SDK: one entry per typed method.45 * `test/contract.test.mjs` checks every entry against `docs/openapi.json`.46 *47 * Retry class:48 * - `safe`: repeating the request has no additional effect (reads, cancel, pause);49 * - `keyed`: creates a job; the SDK always sends an `Idempotency-Key` and reuses it across retries;50 * - `unsafe`: creates something and the API takes no idempotency key; retried only when the request51 * provably did not reach the application (connection never established, or 429).52 */53export type RetryClass = "safe" | "keyed" | "unsafe";5455export interface Route {56 readonly method: "GET" | "POST" | "PUT" | "DELETE";57 readonly path: string;58 readonly retry: RetryClass;59}6061const r = (method: Route["method"], path: string, retry: RetryClass): Route => ({ method, path, retry });6263export const ROUTES = {64 scrape: r("POST", "/v1/scrape", "keyed"),65 crawl: r("POST", "/v1/crawl", "keyed"),66 map: r("POST", "/v1/map", "keyed"),67 screenshot: r("POST", "/v1/screenshot", "keyed"),68 deepCapture: r("POST", "/v1/deep-capture", "keyed"),69 extract: r("POST", "/v1/extract", "keyed"),70 ocr: r("POST", "/v1/ocr", "keyed"),71 vision: r("POST", "/v1/vision", "keyed"),72 batch: r("POST", "/v1/batch", "keyed"),73 createMonitor: r("POST", "/v1/monitor", "unsafe"),74 diff: r("POST", "/v1/diff", "safe"),75 search: r("POST", "/v1/search", "safe"),76 listJobs: r("GET", "/v1/jobs", "safe"),77 getJob: r("GET", "/v1/jobs/{job_id}", "safe"),78 cancelJob: r("POST", "/v1/jobs/{job_id}/cancel", "safe"),79 pauseJob: r("POST", "/v1/jobs/{job_id}/pause", "safe"),80 retryJob: r("POST", "/v1/jobs/{job_id}/retry", "unsafe"),81 getResults: r("GET", "/v1/jobs/{job_id}/results", "safe"),82 streamEvents: r("GET", "/v1/jobs/{job_id}/events", "safe"),83 export: r("GET", "/v1/jobs/{job_id}/export", "safe"),84 getArtifact: r("GET", "/v1/artifacts/{artifact_id}", "safe"),85 getSnapshot: r("GET", "/v1/snapshots/{snapshot_id}", "safe"),86 snapshotHistory: r("GET", "/v1/snapshots", "safe"),87 listSites: r("GET", "/v1/sites", "safe"),88 siteGraph: r("GET", "/v1/sites/{site_id}/graph", "safe"),89 siteCoverage: r("GET", "/v1/sites/{site_id}/coverage", "safe"),90 health: r("GET", "/v1/health", "safe"),91 me: r("GET", "/v1/me", "safe"),92 listMonitors: r("GET", "/v1/monitors", "safe"),93 monitorAction: r("POST", "/v1/monitors/{schedule_id}/{action}", "unsafe"),94 listChanges: r("GET", "/v1/changes", "safe"),95 webhookSecret: r("GET", "/v1/webhook-secret", "safe"),96} as const satisfies Record<string, Route>;9798export type RouteName = keyof typeof ROUTES;99100export const JOB_STATES = ["queued", "running", "partial", "succeeded", "failed", "cancelled", "blocked"] as const;101export const TERMINAL_JOB_STATES = ["partial", "succeeded", "failed", "cancelled", "blocked"] as const;102