Skip to main content

rear end

Suitable EnviromentSaaS
Private Deployment

Require

ONES
v6.0.40+

Overview

Process middleware is used to help you hijack certain operations on the ONES system. There are three types of hijacking: pre-processing, replacement, and post-processing.

  • Preface: Modify the input parameters of the operation, or throw a custom error through the error reporting SDK to reject the operation.
  • Replace: Completely replace this operation and customize the operation.
  • Post: You can do other things after this operation is completely executed.

Parameter format

In the prefix or postfix, the input and output parameter formats of the hijacking function must be consistent, but the substitution may be inconsistent, depending on capabilities.

limit

  • In the same process, it can be pre-hijacked by multiple plug-ins, and the order of execution is based on the plug-in activation time.
  • In the same process, it can only be replaced and hijacked by one plug-in.
  • In the same process, multiple plug-ins can be used for post-hijacking, and the execution order is in reverse order according to the plug-in activation time.

use

  • In config/plugin.yaml

    Declare the process middleware used in the middlewares field of the plugin.yaml file

    config/plugin.yaml
    middlewares:
    - abilityType: abilityType #Middleware ability type
    pre: preFunc # Preprocessing function
    replace: replaceFunc # Replacement processing function
    post: postFunc # Post-processing function
  • Write the corresponding function processing logic in /backend/src/index.ts

    /backend/src/index.ts
    import { PluginError, PluginErrorTypeEnum } from '@ones-op/node-error'
    import type { PluginRequest, PluginResponse } from '@ones-op/node-types'

    export async function preFunc(request: PluginRequest): Promise<PluginResponse> {
    const body = request.body as any
    const name = body?.name as string
    if (name.length > 10) {
    //Throw an error through the sdk that reports errors through the plug-in
    throw new PluginError(PluginErrorTypeEnum.error, 500, 'Name is too long')
    }
    //Modify operating parameters
    body.name = 'newName'
    return {
    body: body,
    }
    }

    export async function replaceFunc(request: PluginRequest): Promise<PluginResponse> {
    //Replace the original operation logic
    // result is the agreed parameter format
    return {
    body: result,
    }
    }

    export async function postFunc(request: PluginRequest): Promise<PluginResponse> {
    const param = request.body
    //Follow-up actions
    return {
    body: param,
    }
    }

Middleware list

updateTestCaseResult

ONES v6.0.40+

Description

Hijack and modify the execution use case result process

Example

/backend/src/index.ts
enum Result {
failed = 'failed',
passed = 'passed',
blocked = 'blocked',
skipped = 'skipped',
}

interface Case {
executor: string
note: string
result: Result
uuid: string
steps: Step[]
}

interface Step {
uuid: string
actual_result: string
execute_result: string
}

interface UpdateTestCaseResultReq {
teamUUID: string
planUUID: string
cases: Case[]
}

export async function updateTestCaseResultPreFunc(
request: PluginRequest<UpdateTestCaseResultReq>,
): Promise<PluginResponse> {
const param = request.body
//Modify, error return
return {
body: param,
}
}

Pre-method parameter description:

FieldDescriptionTypeRead Only
orgUUIDOrganization UUIDStringYes
teamUUIDteamUUIDstringyes
planUUIDTest plan UUIDStringYes
cases.executorexecutor UUIDstringno
cases.noteNotes filled in during executionStringNo
cases.resultThe execution result is an enumeration value passed: passed failed: failed blocked: blocked skipped: skippedEnumerationNo
cases.uuidUUID corresponding to the execution caseStringNo
cases.steps.uuidUUID to execute the steps in the use caseStringNo
cases.steps.execute_resultThe execution result of the steps in the use case, which is an enumeration value passed: passed failed: failed blocked: blocked skipped: skippedenumerationno
cases.steps.actual_resultActual execution resultsstringno

linkIssues

ONES v6.0.84+,v6.1.61+

Description

Support plugin hijack the Linking issues. Currently, only pre hijacking is supported, which means that the plugin can throw a standard error through an error SDK before the user actually linking issues. Parameter modification is not currently supported.

Example

/backend/src/index.ts
interface LinkIssuesReq {
teamID: string
operatorID: string
issueID: string
links: LinkIssues[]
}

interface LinkIssues {
issueIDs: string[]
issueLinkTypeID: string
linkDescType: string
}

export async function LinkIssuesPreFunc(
request: PluginRequest<LinkIssuesReq>,
): Promise<PluginResponse> {
Logger.info(request.body.teamID)
Logger.info(request.body.operatorID)
Logger.info(request.body.issueID)
for (let i = 0; i < request.body.links.length; i++) {
Logger.info(request.body.links[i])
}
return {
body: request.body,
}
}

Pre-method parameter description:

FieldDescriptionType
teamIDID of the teamstring
operatorIDID of the operatorstring
issueIDID of the issuestring
linksList of issues to be linkedObject array

links

FieldDescriptionType
issueIDsIssue ID listString array
issueLinkTypeIDIssue link typeString enumeration
linkDescTypeIssue link desc typeString enumeration

unlinkIssues

ONES v6.0.84+,v6.1.61+

Description

Support plugin hijack the unLink issues. Currently, only pre hijacking is supported, which means that the plugin can throw a standard error through an error SDK before the user actually unlink issues. Parameter modification is not currently supported.

Example

/backend/src/index.ts
interface UnlinkIssuesReq {
teamID: string
operatorID: string
issueID: string
links: UnlinkIssues[]
}

interface UnlinkIssues {
issueIDs: string[]
issueLinkTypeID: string
linkDescType: string
}

export async function UnlinkIssuesPreFunc(
request: PluginRequest<UnlinkIssuesReq>,
): Promise<PluginResponse> {
const param = request.body
Logger.info(param.teamID)
Logger.info(param.operatorID)
Logger.info(param.issueID)
for (let i = 0; i < param.links.length; i++) {
Logger.info(param.links[i])
}
return {
body: param,
}
}

Pre-method parameter description:

FieldDescriptionType
teamIDID of the teamstring
operatorIDID of the operatorstring
issueIDID of the issuestring
linksList of issues to be unlinkedObject array

links:

FieldDescriptionType
issueIDsIssue ID listString array
issueLinkTypeIDIssue link typeString enumeration
linkDescTypeIssue link desc typeString enumeration

createIssues

ONES v6.0.84+,v6.1.61+

Description

Support plugin hijack the issues creating. Currently, only pre hijacking is supported, which means that the plugin can throw a standard error through an error SDK before the user actually creating issues. Parameter modification is not currently supported.

Example

/backend/src/index.ts
interface CreateIssuesReq {
teamID: string
operatorID: string
issues: CreateIssue[]
}

interface CreateIssue {
issueID: string
assign: string
summary: string
parentIssueID: string
projectID: string
issueTypeScopeID: string
issueTypeID: string
subIssueTypeID: string
watchers: string[]
sprintID: string
deadline: string
descRich: string
priority: string
addManHours: AddManHourReq[]
fieldValues: FieldRawValue[]
}

interface AddManHourReq {
type: string
mode: string
hours: number
}

interface FieldRawValue {
fieldID: string
value: any
}

export async function CreateIssuesPreFunc(
request: PluginRequest<CreateIssuesReq>,
): Promise<PluginResponse> {
const param = request.body
Logger.info(param.teamID)
Logger.info(param.operatorID)
Logger.info(param.issues)
return {
body: param,
}
}

Pre-method parameter description:

FieldDescriptionType
teamIDID of the teamString
operatorIDID of the operatorString
issuesList of issues to be createdObject array

issues:

FieldDescriptionType
issueIDID of the issueString
assignAssign IDString
summarySummaryString
parentIssueIDParent ID of the issueString
statusIDIssue status IDString
projectIDProject of the issueString
issueTypeScopeIDType of the currently issueString
issueTypeIDType of the issueString
subIssueTypeIDType of the sub issueString
watchersWatchersString array
sprintIDSprint IDString
deadlineDeadlineint
descRichRich describesString
priorityPriorityString
addManHoursMan hours informationObject array
fieldValuesField valuesObject array

addManHours:

FieldDescriptionType
type'simple' or 'detailed'String enumeration
mode'recorded' or 'estimated'String enumeration
hoursMan hours valuesString

fieldValues:

FieldDescriptionType
fieldIDfield IDString
valuevalueAny

deleteIssue

ONES v6.0.84+,v6.1.61+

Description

Support plugin hijack the issues deleting. Currently, only pre hijacking is supported, which means that the plugin can throw a standard error through an error SDK before the user actually deleting issues. Parameter modification is not currently supported.

Example

/backend/src/index.ts
interface DeleteIssueReq {
teamID: string
operatorID: string
issueID: string
}

export async function DeleteTaskPreFunc(
request: PluginRequest<DeleteIssueReq>,
): Promise<PluginResponse> {
Logger.info(request.body.teamID)
Logger.info(request.body.operatorID)
Logger.info(request.body.issueID)
return {
body: request.body,
}
}

Pre-method parameter description:

FieldDescriptionType
teamIDID of the teamString
operatorIDID of the operatorString
issueIDList of issues to be deletedString

updateIssuesParent

ONES v6.0.84+,v6.1.61+

Description

Support plugin hijack the issues updating parent. Currently, only pre hijacking is supported, which means that the plugin can throw a standard error through an error SDK before the user actually updating issues parent. Parameter modification is not currently supported.

Example

/backend/src/index.ts
interface UpdateIssuesParentReq {
teamID: string
operatorID: string
issues: IssueParentReq[]
}

interface IssueParentReq {
issueID: string
parentIssueID: string
}

export async function UpdateIssuesParentPreFunc(
request: PluginRequest<UpdateIssuesParentReq>,
): Promise<PluginResponse> {
const param = request.body
Logger.info(param.teamID)
Logger.info(param.operatorID)
return {
body: param,
}
}

Pre-method parameter description:

FieldDescriptionType
teamIDID of the teamString
operatorIDID of the operatorString
issuesSub IssuesObject array

issues:

FieldDescriptionType
issueIDID of the issueString
parentIssueIDParent ID of the issueString

updateIssuesType

ONES v6.0.84+,v6.1.61+

Description

Support plugin hijack the issues updating type. Currently, only pre hijacking is supported, which means that the plugin can throw a standard error through an error SDK before the user actually updating issues type. Parameter modification is not currently supported.

Example

/backend/src/index.ts
interface UpdateIssuesTypeReq {
teamID: string
operatorID: string
action: string[]
issues: UpdateIssuesPayload[]
}

interface UpdateIssuesPayload {
issueID: string
parentIssueID: string
projectID: string
oldIssueTypeID: string
newIssueTypeID: string
subIssueTypeID: string
status: UpdateIssuesStatus
fieldValues: FieldRawValue[]
}

interface UpdateIssuesStatus {
oldStatusID: string
newStatusID: string
}

interface FieldRawValue {
fieldID: string
value: any
}

export async function UpdateIssuesTypePreFunc(
request: PluginRequest<UpdateIssuesTypeReq>,
): Promise<PluginResponse> {
const param = request.body
Logger.info(param.teamID)
Logger.info(param.operatorID)
return {
body: param,
}
}

Pre-method parameter description:

FieldDescriptionType
teamIDID of the teamString
operatorIDID of the operatorString
actionmodify_issue_type/std_to_sub_issue_type/sub_to_std_issue_type/std_to_sub_issue_type/sub_to_sub_issue_typeString enumeration
issuesIssuesObject array

issues:

FieldDescriptionType
issueIDID of the issueString
parentIssueIDParent ID of the issueString
projectIDProject IDString
oldIssueTypeIDOld issue type IDString
newIssueTypeIDNew issue type IDString
statusStatusObject array
fieldValuesFiled valueObject array

status:

FieldDescriptionType
oldStatusIDOld status IDString
newStatusIDNew status IDString

fieldValues:

FieldDescriptionType
fieldIDfield IDString
valuevalueAny