mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
5f4c19da35
Co-authored-by: Opender Singh <opender.singh@konghq.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { GrpcRequest } from '../grpc-request';
|
|
import { Request } from '../request';
|
|
import * as models from '../index';
|
|
import { isGrpcRequest, isGrpcRequestId } from './is-model';
|
|
|
|
export function getById(requestId: string): Promise<Request | GrpcRequest | null> {
|
|
return isGrpcRequestId(requestId)
|
|
? models.grpcRequest.getById(requestId)
|
|
: models.request.getById(requestId);
|
|
}
|
|
|
|
export function remove(request: Request | GrpcRequest) {
|
|
return isGrpcRequest(request)
|
|
? models.grpcRequest.remove(request)
|
|
: models.request.remove(request);
|
|
}
|
|
|
|
export function update<T extends object>(request: T, patch: Partial<T> = {}): Promise<T> {
|
|
// @ts-expect-error -- TSCONVERSION
|
|
return isGrpcRequest(request)
|
|
? models.grpcRequest.update(request, patch)
|
|
// @ts-expect-error -- TSCONVERSION
|
|
: models.request.update(request, patch);
|
|
}
|
|
|
|
export function duplicate<T extends object>(request: T, patch: Partial<T> = {}): Promise<T> {
|
|
// @ts-expect-error -- TSCONVERSION
|
|
return isGrpcRequest(request)
|
|
? models.grpcRequest.duplicate(request, patch)
|
|
// @ts-expect-error -- TSCONVERSION
|
|
: models.request.duplicate(request, patch);
|
|
}
|