import { NodeRequestOptions } from '../data/node-connection'; import { PowerShellCommand } from '../data/powershell'; import { RpcWorkItem } from '../rpc/work-item/rpc-work-item-model'; import { NotificationLinkType } from './notification-link-type'; import { NotificationState } from './notification-state'; /** * Work item request type. */ export declare enum WorkItemRequestType { PowerShellSubmit = 0, StateQuery = 1, WorkItemSubmit = 2 } /** * Response at submit call of work item. */ export interface WorkItemResult { /** * The sequence id. */ sequenceId: number; /** * The session id (or instance id). */ id: string; /** * The state of notification. */ state: NotificationState; /** * The progress state. (0 to 100 if the powershell script respond with it.) */ percent?: number; /** * The error object. */ error?: any; /** * The last response object. */ object?: any; } /** * The work item base data. */ export interface WorkItemBaseData { /** * The node name. */ nodeName: string; /** * The module source name. */ sourceName: string; /** * The request time. */ timestamp: number; } /** * The base meta data of work item. A module populates them. */ export interface WorkItemMetaDataCore { /** * The identity of workitem type. (Unique ID within the module.) * ex.) "StopService", "InstallRole", "InstallWindowsUpdate", "CreateVM" ... */ typeId: string; /** * The target object name if any specific. * ex.) "VM007" (virtual machine), "WinRm" (service name) */ objectName?: string; /** * @deprecated please use inProgressTitle, successTitle, and errorTitle fields */ title?: string; /** * @deprecated * This field can be removed */ description?: string; /** * @deprecated use started message to tell user the action is being worked on */ submittedMessage?: string; /** * The localized notification title for in progress actions * Should be in the form "Executing some action" * ex) "Stopping service", "Installing role", "Creating new virtual machine" */ inProgressTitle?: string; /** * The started message. (localized) Non format message. * This is shown after the powershell script has started executing (~3 seconds after submit message to create powershell session) */ startedMessage?: string; /** * The progress message. (localized/optional) * At default, generic message displays. * A message can have insertion field with '{{, percent or objectName}}' from the latest PowerShell 'progress' object. * ex. 'Installation is in progress: {{percent}}%.' */ progressMessage?: string; /** * The localized notification title for successful actions * Should be in the form "Successfully executed some action" * ex) "Successfully stopped service", "Successfully installed role", "Successfully created new virtual machine" */ successTitle?: string; /** * The success message. (localized) * A message can have insertion field with '{{ or objectName}}' from the last PowerShell 'results' object. * ex. 'Successfully installed {{productName}}.' */ successMessage?: string; /** * The success link to navigate to the object view. (optional) * At default, it brings to the home page of the module. * This link is relative to the node/tool path unless linkType is specified. */ successLink?: string; /** * The type of success link. Default behavior is RelativeToTool */ successLinkType?: NotificationLinkType; /** * The text to show up on the success link text ex: "Go to on sme-xyz.domain.com" * By default the text will be the auto detected source name like "Files" */ successLinkText?: string; /** * The localized notification title for failed actions * Should be in the form "Failed to execute some action" * ex) "Failed to stop service", "Failed to install role", "Failed to create new virtual machine" */ errorTitle?: string; /** * if true, an error will not be generated from the work item so custom error handling can be used. * If the work item is recovered from the gateway, the work item will fall back * to generating a notification with the configured errorMessage */ disableErrorNotification?: boolean; /** * if true, no notification will be shown to the user. * If the work item is recovered from the gateway, the work item will fall back * to generating notifications with the configured messages. */ disableAllNotifications?: boolean; /** * The error message. (localized/optional) * At default, error message from the result display. * A message can have insertion field with '{{ or objectName}}' from the first PowerShell 'errors' object. * ex. 'Failed to install {productName}. ' */ errorMessage?: string; /** * The error link to navigate to original view. (optional) * At default, it brings to the home page of the module. * This link is relative to the node/tool path unless linkType is specified. */ errorLink?: string; /** * The type of error link. Default behavior is RelativeToTool */ errorLinkType?: NotificationLinkType; /** * The text to show up on the error link text ex: "Go to on sme-xyz.domain.com" * By default the text will be the auto detected source name like "Files" */ errorLinkText?: string; } /** * The work item request submit by a module. */ export interface WorkItemSubmitRequest extends WorkItemMetaDataCore { /** * The script code of PowerShell to execute on the node. * (Either powerShellScript or powerShellCommand. If both specified powerShellCommand will be used.) */ powerShellScript?: string; /** * The PowerShell command object. * (Either powerShellScript or powerShellCommand. If both specified powerShellCommand will be used.) */ powerShellCommand?: PowerShellCommand; /** * The work item id. * It's not from powershell scripts. * It's generated by a gateway api for long running c# task. The api returns 202 with workitem id. */ id?: string; /** * The node request options */ nodeRequestOptions?: NodeRequestOptions; } /** * The work item request for rpc data payload. */ export interface WorkItemRequest extends WorkItemSubmitRequest { /** * The request type. */ type?: WorkItemRequestType; /** * The parent URI window.location.pathname. */ locationPathname?: string; /** * The parent URI window.location.search */ locationSearch?: string; /** * The sequence Id. */ sequenceId?: number; } /** * The work item meta date to store on the gateway. * - sourceName and timestamp are auto populated when submits. */ export interface WorkItemMetaData extends WorkItemMetaDataCore, WorkItemBaseData { } /** * Find work item. */ export interface WorkItemFind { /** * name of node. */ nodeName: string; /** * name of module. */ moduleName: string; /** * id of notification type. */ typeId: string; } /** * Find work item results. */ export interface WorkItemFindResult extends WorkItemFind { /** * result of work items if exist. */ results: WorkItemResult[]; } /** * The recovered work item data. * * ex) * { * "id": "5972d0bc-a40a-439e-aab6-9785b407aa52", * "connection": "mycomputer", * "userId": "mydomain\\myname", * "appAuthorization": "", * "useHostIdentity": true, * "jobType": "PowerShellApi.GetOutput", * "startedTime": "2017-03-16T23:27:34.8001912Z", * "completedTime": "2017-03-16T23:27:38.5724403Z", * "failed": true, * "errorMessage": "Unhandled exception (AggregateException): One or more errors occurred.", * "completed": true, * "metadata": { * } * } */ export interface RecoveredWorkItem { appAuthorization: string; completed: boolean; completedTime: string; connection: string; errorMessage: string; failed: boolean; id: string; jobType: string; metadata: RpcWorkItem; startedTime: string; useHostIdentity: boolean; userId: string; }