import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api'; import { JsonObject } from '@backstage/types'; import { FormProps } from '@rjsf/core'; import { UiSchema, ErrorSchema } from '@rjsf/utils'; import { JSONSchema7 } from 'json-schema'; import { AuthTokenDescriptor } from '@red-hat-developer-hub/backstage-plugin-orchestrator-common'; /** /** * @public * */ type OrchestratorFormContextProps = { schema: JSONSchema7; updateSchema: OrchestratorFormSchemaUpdater; numStepsInMultiStepSchema?: number; uiSchema: UiSchema; formData: JsonObject; setFormData: (data: JsonObject) => void; children: React.ReactNode; onSubmit: (formData: JsonObject) => void; setAuthTokenDescriptors: (authTokenDescriptors: AuthTokenDescriptor[]) => void; getIsChangedByUser: (id: string) => boolean; setIsChangedByUser: (id: string, isChangedByUser: boolean) => void; handleFetchStarted?: () => void; handleFetchEnded?: () => void; onSamlSsoError?: (error: Error) => void; }; /** * @public * FormDecoratorProps * * Type definition for properties passed to a form decorator component. * This interface extends selected fields from `FormProps` provided by `react-jsonschema-form`, * with additional custom functionality. * * @see {@link https://rjsf-team.github.io/react-jsonschema-form/docs/api-reference/form-props|RJSF Form Props Documentation} * * Core properties include: * - formData: The form's current data * - formContext: Contextual data shared across form components * - widgets: Custom widget components for form fields * - onChange: Handler for form data changes * - customValidate: Custom validation function * * Additional properties: * - getExtraErrors: Async function to fetch additional validation errors. * This replaces the static 'extraErrors' prop from react-jsonschema-form, which can't be used as is, since onSubmit isn't exposed. * The orchestrator form component will call getExtraErrors when running onSubmit. */ type FormDecoratorProps = Pick, 'formData' | 'formContext' | 'widgets' | 'onChange' | 'customValidate' | 'templates'> & { getExtraErrors?: (formData: JsonObject, uiSchema: OrchestratorFormContextProps['uiSchema']) => Promise> | undefined; }; /** * @public * OrchestratorFormDecorator * */ type OrchestratorFormDecorator = (FormComponent: React.ComponentType) => React.ComponentType; /** * @public * * Expected response received by fetch:url of the SchemaUpdater widget. * * Key is the JSON Schema placeholder identifier, * Value is content the key will be newly assigned to. */ type SchemaChunksResponse = { [key: string]: JsonObject; }; /** * @public * * Function provided by the Orchestrator down to the OrchestratorFormApi to update the form's JSON Schema on the fly. */ type OrchestratorFormSchemaUpdater = (chunks: SchemaChunksResponse, scopeId?: string) => void; /** * @public * ReviewComponentProps * * Type definition for properties passed to a custom review page component. */ type ReviewComponentProps = { /** Whether the workflow execution is in progress */ busy: boolean; /** The JSON Schema for the workflow form */ schema: JSONSchema7; /** The form data to be reviewed before submission */ data: JsonObject; /** Go back to the previous wizard step (same behavior as the default review page) */ handleBack: () => void; /** Callback to execute the workflow */ handleExecute: () => void; /** Label for the primary execute button (default review UI falls back to translated "Run") */ executeLabel?: string; /** Optional second action to execute as an event-style (e.g. Kafka) workflow */ handleExecuteAsEvent?: () => void; /** Label for the event execute control when `handleExecuteAsEvent` is set */ executeAsEventLabel?: string; }; /** * @public * OrchestratorFormApi * API to be implemented by factory in a custom plugin */ interface OrchestratorFormApi { /** * @public * Context wrapping the RJSF form on Workflow execution page, making it available for the custom widgets. * * Must be created by the API to share just a single instance within both the OrchestratorFormApi and * the Orchestrator where the context is actually provided (see OrchestratorFormWrapper). */ /** * @public * getFormDecorator * return the form decorator */ getFormDecorator(): OrchestratorFormDecorator; /** * @public * getReviewComponent * return a custom review page component to replace the default review step * @returns A React component that accepts ReviewComponentProps, or undefined to use the default review page */ getReviewComponent?(): React.ComponentType | undefined; } /** * @public * OrchestratorFormApiRef * */ declare const orchestratorFormApiRef: _backstage_frontend_plugin_api.ApiRef; declare const useOrchestratorFormApiOrDefault: () => OrchestratorFormApi; export { type FormDecoratorProps, type OrchestratorFormApi, type OrchestratorFormContextProps, type OrchestratorFormDecorator, type OrchestratorFormSchemaUpdater, type ReviewComponentProps, type SchemaChunksResponse, orchestratorFormApiRef, useOrchestratorFormApiOrDefault };