feat: add script generator TypeScript types
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -87,3 +87,5 @@ export type {
|
|||||||
KBCommitResponse,
|
KBCommitResponse,
|
||||||
KBQuotaResponse,
|
KBQuotaResponse,
|
||||||
} from './kbAccelerator'
|
} from './kbAccelerator'
|
||||||
|
|
||||||
|
export * from './scripts'
|
||||||
|
|||||||
96
frontend/src/types/scripts.ts
Normal file
96
frontend/src/types/scripts.ts
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
export interface ScriptCategoryResponse {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
slug: string
|
||||||
|
description: string | null
|
||||||
|
icon: string | null
|
||||||
|
sort_order: number
|
||||||
|
template_count: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptTemplateListItem {
|
||||||
|
id: string
|
||||||
|
category_id: string
|
||||||
|
team_id: string | null
|
||||||
|
name: string
|
||||||
|
slug: string
|
||||||
|
description: string | null
|
||||||
|
tags: string[]
|
||||||
|
complexity: 'beginner' | 'intermediate' | 'advanced' // must match backend ScriptComplexity enum exactly
|
||||||
|
estimated_runtime: string | null
|
||||||
|
requires_elevation: boolean
|
||||||
|
requires_modules: string[]
|
||||||
|
is_verified: boolean
|
||||||
|
usage_count: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptParameterOption {
|
||||||
|
value: string
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptParameterValidation {
|
||||||
|
min_value?: number // matches backend field name (not 'min')
|
||||||
|
max_value?: number // matches backend field name (not 'max')
|
||||||
|
pattern?: string
|
||||||
|
min_length?: number
|
||||||
|
max_length?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptParameter {
|
||||||
|
key: string
|
||||||
|
label: string
|
||||||
|
type: 'text' | 'password' | 'select' | 'boolean' | 'multi_text' | 'number' | 'textarea'
|
||||||
|
required: boolean
|
||||||
|
placeholder: string | null
|
||||||
|
group: string | null
|
||||||
|
order: number
|
||||||
|
help_text: string | null
|
||||||
|
options: ScriptParameterOption[] | null // for select type
|
||||||
|
default: string | boolean | number | null
|
||||||
|
validation: ScriptParameterValidation | null
|
||||||
|
sensitive: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptParametersSchema {
|
||||||
|
parameters: ScriptParameter[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptTemplateDetail extends ScriptTemplateListItem {
|
||||||
|
use_case: string | null
|
||||||
|
script_body: string
|
||||||
|
// NOTE: backend types this as `dict` — arrives as unknown at runtime.
|
||||||
|
// Always access via cast: (detail.parameters_schema as ScriptParametersSchema).parameters ?? []
|
||||||
|
parameters_schema: ScriptParametersSchema
|
||||||
|
default_values: Record<string, unknown> // template-level metadata; not used in Phase 2
|
||||||
|
validation_rules: Record<string, unknown> // template-level metadata; not used in Phase 2
|
||||||
|
version: number
|
||||||
|
created_at: string
|
||||||
|
updated_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptGenerateRequest {
|
||||||
|
template_id: string
|
||||||
|
parameters: Record<string, unknown>
|
||||||
|
session_id?: string // Phase 3: passed when generating inside a session
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptGenerateResponse {
|
||||||
|
id: string // generation UUID
|
||||||
|
script: string // rendered PowerShell
|
||||||
|
warnings: string[]
|
||||||
|
metadata: {
|
||||||
|
template_name: string
|
||||||
|
template_version: number
|
||||||
|
requires_elevation: boolean
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScriptGenerationRecord {
|
||||||
|
id: string
|
||||||
|
template_id: string
|
||||||
|
template_name: string
|
||||||
|
parameters_used: Record<string, unknown> // sensitive values already redacted by backend
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user