rear end
Suitable Enviroment | SaaS |
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
fileconfig/plugin.yamlmiddlewares:
- 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.tsimport { 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
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:
Field | Description | Type | Read Only |
---|---|---|---|
orgUUID | Organization UUID | String | Yes |
teamUUID | teamUUID | string | yes |
planUUID | Test plan UUID | String | Yes |
cases.executor | executor UUID | string | no |
cases.note | Notes filled in during execution | String | No |
cases.result | The execution result is an enumeration value passed: passed failed: failed blocked: blocked skipped: skipped | Enumeration | No |
cases.uuid | UUID corresponding to the execution case | String | No |
cases.steps.uuid | UUID to execute the steps in the use case | String | No |
cases.steps.execute_result | The execution result of the steps in the use case, which is an enumeration value passed: passed failed: failed blocked: blocked skipped: skipped | enumeration | no |
cases.steps.actual_result | Actual execution results | string | no |
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
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:
Field | Description | Type |
---|---|---|
teamID | ID of the team | string |
operatorID | ID of the operator | string |
issueID | ID of the issue | string |
links | List of issues to be linked | Object array |
links
Field | Description | Type |
---|---|---|
issueIDs | Issue ID list | String array |
issueLinkTypeID | Issue link type | String enumeration |
linkDescType | Issue link desc type | String 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
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:
Field | Description | Type |
---|---|---|
teamID | ID of the team | string |
operatorID | ID of the operator | string |
issueID | ID of the issue | string |
links | List of issues to be unlinked | Object array |
links:
Field | Description | Type |
---|---|---|
issueIDs | Issue ID list | String array |
issueLinkTypeID | Issue link type | String enumeration |
linkDescType | Issue link desc type | String 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
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:
Field | Description | Type |
---|---|---|
teamID | ID of the team | String |
operatorID | ID of the operator | String |
issues | List of issues to be created | Object array |
issues:
Field | Description | Type |
---|---|---|
issueID | ID of the issue | String |
assign | Assign ID | String |
summary | Summary | String |
parentIssueID | Parent ID of the issue | String |
statusID | Issue status ID | String |
projectID | Project of the issue | String |
issueTypeScopeID | Type of the currently issue | String |
issueTypeID | Type of the issue | String |
subIssueTypeID | Type of the sub issue | String |
watchers | Watchers | String array |
sprintID | Sprint ID | String |
deadline | Deadline | int |
descRich | Rich describes | String |
priority | Priority | String |
addManHours | Man hours information | Object array |
fieldValues | Field values | Object array |
addManHours:
Field | Description | Type |
---|---|---|
type | 'simple' or 'detailed' | String enumeration |
mode | 'recorded' or 'estimated' | String enumeration |
hours | Man hours values | String |
fieldValues:
Field | Description | Type |
---|---|---|
fieldID | field ID | String |
value | value | Any |
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
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:
Field | Description | Type |
---|---|---|
teamID | ID of the team | String |
operatorID | ID of the operator | String |
issueID | List of issues to be deleted | String |
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
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:
Field | Description | Type |
---|---|---|
teamID | ID of the team | String |
operatorID | ID of the operator | String |
issues | Sub Issues | Object array |
issues:
Field | Description | Type |
---|---|---|
issueID | ID of the issue | String |
parentIssueID | Parent ID of the issue | String |
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
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:
Field | Description | Type |
---|---|---|
teamID | ID of the team | String |
operatorID | ID of the operator | String |
action | modify_issue_type/std_to_sub_issue_type/sub_to_std_issue_type/std_to_sub_issue_type/sub_to_sub_issue_type | String enumeration |
issues | Issues | Object array |
issues:
Field | Description | Type |
---|---|---|
issueID | ID of the issue | String |
parentIssueID | Parent ID of the issue | String |
projectID | Project ID | String |
oldIssueTypeID | Old issue type ID | String |
newIssueTypeID | New issue type ID | String |
status | Status | Object array |
fieldValues | Filed value | Object array |
status:
Field | Description | Type |
---|---|---|
oldStatusID | Old status ID | String |
newStatusID | New status ID | String |
fieldValues:
Field | Description | Type |
---|---|---|
fieldID | field ID | String |
value | value | Any |