insomnia/packages/insomnia-app/app/models/helpers/request-operations.js
Opender Singh ccd270a9fb
gRPC with Insomnia export format V4 (#2830)
* feat: initial commit to export grpc entities

* feat: grpc requests and protofiles in v4 export format

* test(export): add grpc requests and protofiles in export tests

* test(models): add isProtoFile tests
2020-11-14 12:31:18 +13:00

29 lines
950 B
JavaScript

// @flow
import * as models from '../index';
import { isGrpcRequest, isGrpcRequestId } from './is-model';
import type { GrpcRequest } from '../grpc-request';
export function getById(requestId: string): Promise<Request | GrpcRequest | null> {
return isGrpcRequestId(requestId)
? models.grpcRequest.getById(requestId)
: models.request.getById(requestId);
}
export function remove<T>(request: T): Promise<void> {
return isGrpcRequest(request)
? models.grpcRequest.remove(request)
: models.request.remove(request);
}
export function update<T>(request: T, patch: $Shape<T> = {}): Promise<T> {
return isGrpcRequest(request)
? models.grpcRequest.update(request, patch)
: models.request.update(request, patch);
}
export function duplicate<T>(request: T, patch: $Shape<T> = {}): Promise<T> {
return isGrpcRequest(request)
? models.grpcRequest.duplicate(request, patch)
: models.request.duplicate(request, patch);
}