|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License; |
| 4 | + * you may not use this file except in compliance with the Elastic License. |
| 5 | + */ |
| 6 | + |
| 7 | +import { |
| 8 | + ActionLicense, |
| 9 | + AllCases, |
| 10 | + BulkUpdateStatus, |
| 11 | + Case, |
| 12 | + CasesStatus, |
| 13 | + CaseUserActions, |
| 14 | + FetchCasesProps, |
| 15 | + SortFieldCase, |
| 16 | +} from '../types'; |
| 17 | +import { |
| 18 | + actionLicenses, |
| 19 | + allCases, |
| 20 | + basicCase, |
| 21 | + basicCaseCommentPatch, |
| 22 | + basicCasePost, |
| 23 | + casesStatus, |
| 24 | + caseUserActions, |
| 25 | + pushedCase, |
| 26 | + respReporters, |
| 27 | + serviceConnector, |
| 28 | + tags, |
| 29 | +} from '../mock'; |
| 30 | +import { |
| 31 | + CaseExternalServiceRequest, |
| 32 | + CasePatchRequest, |
| 33 | + CasePostRequest, |
| 34 | + CommentRequest, |
| 35 | + ServiceConnectorCaseParams, |
| 36 | + ServiceConnectorCaseResponse, |
| 37 | + User, |
| 38 | +} from '../../../../../../../plugins/case/common/api'; |
| 39 | + |
| 40 | +export const getCase = async ( |
| 41 | + caseId: string, |
| 42 | + includeComments: boolean = true, |
| 43 | + signal: AbortSignal |
| 44 | +): Promise<Case> => { |
| 45 | + return Promise.resolve(basicCase); |
| 46 | +}; |
| 47 | + |
| 48 | +export const getCasesStatus = async (signal: AbortSignal): Promise<CasesStatus> => |
| 49 | + Promise.resolve(casesStatus); |
| 50 | + |
| 51 | +export const getTags = async (signal: AbortSignal): Promise<string[]> => Promise.resolve(tags); |
| 52 | + |
| 53 | +export const getReporters = async (signal: AbortSignal): Promise<User[]> => |
| 54 | + Promise.resolve(respReporters); |
| 55 | + |
| 56 | +export const getCaseUserActions = async ( |
| 57 | + caseId: string, |
| 58 | + signal: AbortSignal |
| 59 | +): Promise<CaseUserActions[]> => Promise.resolve(caseUserActions); |
| 60 | + |
| 61 | +export const getCases = async ({ |
| 62 | + filterOptions = { |
| 63 | + search: '', |
| 64 | + reporters: [], |
| 65 | + status: 'open', |
| 66 | + tags: [], |
| 67 | + }, |
| 68 | + queryParams = { |
| 69 | + page: 1, |
| 70 | + perPage: 5, |
| 71 | + sortField: SortFieldCase.createdAt, |
| 72 | + sortOrder: 'desc', |
| 73 | + }, |
| 74 | + signal, |
| 75 | +}: FetchCasesProps): Promise<AllCases> => Promise.resolve(allCases); |
| 76 | + |
| 77 | +export const postCase = async (newCase: CasePostRequest, signal: AbortSignal): Promise<Case> => |
| 78 | + Promise.resolve(basicCasePost); |
| 79 | + |
| 80 | +export const patchCase = async ( |
| 81 | + caseId: string, |
| 82 | + updatedCase: Pick<CasePatchRequest, 'description' | 'status' | 'tags' | 'title'>, |
| 83 | + version: string, |
| 84 | + signal: AbortSignal |
| 85 | +): Promise<Case[]> => Promise.resolve([basicCase]); |
| 86 | + |
| 87 | +export const patchCasesStatus = async ( |
| 88 | + cases: BulkUpdateStatus[], |
| 89 | + signal: AbortSignal |
| 90 | +): Promise<Case[]> => Promise.resolve(allCases.cases); |
| 91 | + |
| 92 | +export const postComment = async ( |
| 93 | + newComment: CommentRequest, |
| 94 | + caseId: string, |
| 95 | + signal: AbortSignal |
| 96 | +): Promise<Case> => Promise.resolve(basicCase); |
| 97 | + |
| 98 | +export const patchComment = async ( |
| 99 | + caseId: string, |
| 100 | + commentId: string, |
| 101 | + commentUpdate: string, |
| 102 | + version: string, |
| 103 | + signal: AbortSignal |
| 104 | +): Promise<Case> => Promise.resolve(basicCaseCommentPatch); |
| 105 | + |
| 106 | +export const deleteCases = async (caseIds: string[], signal: AbortSignal): Promise<boolean> => |
| 107 | + Promise.resolve(true); |
| 108 | + |
| 109 | +export const pushCase = async ( |
| 110 | + caseId: string, |
| 111 | + push: CaseExternalServiceRequest, |
| 112 | + signal: AbortSignal |
| 113 | +): Promise<Case> => Promise.resolve(pushedCase); |
| 114 | + |
| 115 | +export const pushToService = async ( |
| 116 | + connectorId: string, |
| 117 | + casePushParams: ServiceConnectorCaseParams, |
| 118 | + signal: AbortSignal |
| 119 | +): Promise<ServiceConnectorCaseResponse> => Promise.resolve(serviceConnector); |
| 120 | + |
| 121 | +export const getActionLicense = async (signal: AbortSignal): Promise<ActionLicense[]> => |
| 122 | + Promise.resolve(actionLicenses); |
0 commit comments