diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 8221e3a2..6ea816d7 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -87,3 +87,5 @@ export type { KBCommitResponse, KBQuotaResponse, } from './kbAccelerator' + +export * from './scripts' diff --git a/frontend/src/types/scripts.ts b/frontend/src/types/scripts.ts new file mode 100644 index 00000000..4131072c --- /dev/null +++ b/frontend/src/types/scripts.ts @@ -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 // template-level metadata; not used in Phase 2 + validation_rules: Record // template-level metadata; not used in Phase 2 + version: number + created_at: string + updated_at: string +} + +export interface ScriptGenerateRequest { + template_id: string + parameters: Record + 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 // sensitive values already redacted by backend + created_at: string +}