Files
windmill/cli/src/core/client.ts
T
Ruben FiszelandClaude Opus 5 633d7bcb2e feat: add trigger_history table with source tracking (#10696)
* feat: add trigger_history table with source tracking

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: gate trigger history reads on scopes and harden its writers

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: filter trigger history scopes in SQL and match the cleared-handler diff

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: record a trigger restore from the trashbin in its history

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: record bulk http trigger creates and document the recording boundary

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: lock the trigger row when capturing its history preimage

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: only record an auto-disable that actually flipped the schedule

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore: state the auto-disable invariant once instead of at four call sites

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat: render trigger history changes as a structured field diff

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: make a server-initiated disable atomic with its history row

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs: note that the auto-disable savepoint takes no pool connection

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs: note the flow fallback is the last chance to disable

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: never leave a trigger enabled because its history row failed

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: retry the disable history row instead of dropping it on first failure

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: use the design-system Button for the change-value expander

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: hold the trigger row lock across its disable history row

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: keep the history-loss alert out of the listener cancellation race

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: read the history workspace through the trigger-workspace seam

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 17:57:11 +02:00

41 lines
1.5 KiB
TypeScript

import { OpenAPI } from "../../gen/index.ts";
/**
* Mark every subsequent request as applying a state computed elsewhere rather
* than authoring one in the target workspace (the fork tally reads the header to
* decide whether a removal was deliberate).
*
* Belongs to the commands that apply and nothing that authors: `sync push`
* (including the git-sync auto-pull, which runs it inside a job) and the
* parent-to-fork half of `workspace merge`.
*/
export function markRequestsAsSyncOrigin() {
const existing = typeof OpenAPI.HEADERS === "object" ? OpenAPI.HEADERS : {};
OpenAPI.HEADERS = { ...existing, "X-Windmill-Deploy-Origin": "sync" };
}
/**
* Name this process as the CLI on every subsequent request, so a trigger the
* CLI created or disabled is attributed to `cli` rather than to a bare API
* call in `trigger_history`. Attribution only — nothing on the server grants
* anything on the strength of it.
*/
export function markRequestsAsCliClient() {
const existing = typeof OpenAPI.HEADERS === "object" ? OpenAPI.HEADERS : {};
OpenAPI.HEADERS = { ...existing, "X-Windmill-Client": "cli" };
}
export function setClient(token?: string, baseUrl?: string) {
if (baseUrl === undefined) {
baseUrl = process.env["BASE_INTERNAL_URL"] ??
process.env["BASE_URL"] ??
"http://localhost:8000";
}
if (token === undefined) {
token = process.env["WM_TOKEN"] ?? "no_token";
}
OpenAPI.WITH_CREDENTIALS = true;
OpenAPI.TOKEN = token;
OpenAPI.BASE = baseUrl + "/api";
}