Files
windmill/frontend/src/lib/components/scripts/WacExportDrawer.svelte
T
e7fc1b2e2e feat: restricted job tokens per script and flow (#11484)
* feat: restricted job tokens (job_token_scopes on scripts and flows)

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

* fix: admit flow-run reads, skip dedicated workers, gate on worker version

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

* fix: keep restricted jobs off flow runners, preserve scopes on rename and promotion

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

* fix: keep restricted jobs off every dedicated handoff, confine progress flow id

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

* fix: exclude restricted runnables from dedicated worker startup

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

* fix: gate restrictions on the release after 1.821.0

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

* fix: store per-job scopes on job_perms instead of v2_job, pin inline runs to the checked version

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

* feat: step-level job_token_scopes for flow steps and agent tools

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: fail closed on perms read errors, refuse restricted queue imports, gate step scopes in previews

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: carry a job's scopes on its completion so a re-run keeps the caller's cap

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: carry a zombie job's scopes into its completion

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: leave a zombie for the next sweep when its scopes cannot be read

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* docs: correct the QueuedJobV2 completion comment

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: validate step scopes in batch flows, fail closed on unvalidated step scopes

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: refuse flows with step or tool restrictions at push while an older worker is live

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: apply the step-scope worker gate to flow restarts

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: list the job token toggle with the other step and flow settings

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* chore: pin the EE companion merged with EE main

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* perf: skip scope lookups for unrestricted jobs; list job token setting last

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* style: rustfmt scopes tests

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* fix: confine restricted job tokens to their own run lineage; drop remaining extra lookups

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL

* chore: update ee-repo-ref to 259ad3bfeef5285ba80eedc86309b11dca001220

This commit updates the EE repository reference after PR #843 was merged in windmill-ee-private.

Previous ee-repo-ref: 2b77c0225dca441235daf7bf0a06ba968df0c927

New ee-repo-ref: 259ad3bfeef5285ba80eedc86309b11dca001220

Automated by sync-ee-ref workflow.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-10-03 09:33:44 +02:00

115 lines
4.5 KiB
Svelte

<script lang="ts">
import Drawer from '$lib/components/common/drawer/Drawer.svelte'
import DrawerContent from '$lib/components/common/drawer/DrawerContent.svelte'
import { copyToClipboard } from '$lib/utils'
import { Highlight } from 'svelte-highlight'
import json from 'svelte-highlight/languages/json'
import { yaml } from 'svelte-highlight/languages'
import YAML from 'yaml'
import { Button } from '$lib/components/common'
import { Copy, Download } from 'lucide-svelte'
import Tabs from '$lib/components/common/tabs/Tabs.svelte'
import Tab from '$lib/components/common/tabs/Tab.svelte'
import HighlightTheme from '$lib/components/HighlightTheme.svelte'
import type { NewScript } from '$lib/gen'
let drawer: Drawer | undefined = $state()
let scriptData: Record<string, any> | undefined = $state(undefined)
let rawType: 'json' | 'yaml' = $state('yaml')
export function open(script: NewScript & { modules?: Record<string, any> | null }) {
const exportData: Record<string, any> = {}
// Export all meaningful fields
if (script.summary) exportData.summary = script.summary
if (script.description) exportData.description = script.description
exportData.content = script.content
exportData.language = script.language
if (script.schema) exportData.schema = script.schema
if (script.kind && script.kind !== 'script') exportData.kind = script.kind
if (script.is_template) exportData.is_template = script.is_template
if (script.tag) exportData.tag = script.tag
if (script.envs?.length) exportData.envs = script.envs
if (script.concurrent_limit != null) exportData.concurrent_limit = script.concurrent_limit
if (script.concurrency_time_window_s != null)
exportData.concurrency_time_window_s = script.concurrency_time_window_s
if (script.cache_ttl != null) exportData.cache_ttl = script.cache_ttl
if (script.dedicated_worker) exportData.dedicated_worker = script.dedicated_worker
if (script.ws_error_handler_muted) exportData.ws_error_handler_muted = script.ws_error_handler_muted
if (script.priority != null) exportData.priority = script.priority
if (script.restart_unless_cancelled) exportData.restart_unless_cancelled = script.restart_unless_cancelled
if (script.timeout != null) exportData.timeout = script.timeout
if (script.concurrency_key) exportData.concurrency_key = script.concurrency_key
if (script.debounce_key) exportData.debounce_key = script.debounce_key
if (script.debounce_delay_s != null) exportData.debounce_delay_s = script.debounce_delay_s
if (script.debounce_args_to_accumulate?.length)
exportData.debounce_args_to_accumulate = script.debounce_args_to_accumulate
if (script.visible_to_runner_only) exportData.visible_to_runner_only = script.visible_to_runner_only
if (script.auto_kind) exportData.auto_kind = script.auto_kind
if (script.has_preprocessor) exportData.has_preprocessor = script.has_preprocessor
if (script.job_token_scopes != null) exportData.job_token_scopes = script.job_token_scopes
if (script.modules && Object.keys(script.modules).length > 0) exportData.modules = script.modules
scriptData = exportData
drawer?.toggleDrawer()
}
function getContent(): string {
if (rawType === 'yaml') {
return YAML.stringify(scriptData ?? {})
}
return JSON.stringify(scriptData ?? {}, null, 4)
}
function downloadFile() {
const content = getContent()
const ext = rawType === 'yaml' ? 'yaml' : 'json'
const blob = new Blob([content], { type: 'text/plain' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `wac-script.${ext}`
a.click()
URL.revokeObjectURL(url)
}
</script>
<HighlightTheme />
<Drawer bind:this={drawer} size="800px">
<DrawerContent title="Export Workflow-as-Code" on:close={() => drawer?.toggleDrawer()}>
<div>
<Tabs bind:selected={rawType}>
<Tab value="yaml" label="YAML" />
<Tab value="json" label="JSON" />
{#snippet content()}
<div class="relative pt-2">
<div class="absolute top-2 right-2 z-20 flex gap-1">
<Button
on:click={() => copyToClipboard(getContent())}
variant="accent"
size="sm"
startIcon={{ icon: Copy }}
iconOnly
/>
<Button
on:click={downloadFile}
variant="accent"
size="sm"
startIcon={{ icon: Download }}
iconOnly
/>
</div>
{#key rawType}
<Highlight
class="overflow-auto px-1 flex-1"
language={rawType === 'yaml' ? yaml : json}
code={getContent()}
/>
{/key}
</div>
{/snippet}
</Tabs>
</div>
</DrawerContent>
</Drawer>