mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import {
|
|
BaseModel,
|
|
space,
|
|
grpcRequest,
|
|
request,
|
|
requestGroup,
|
|
protoFile,
|
|
protoDirectory,
|
|
workspace,
|
|
} from '../index';
|
|
|
|
import type { Workspace } from '../workspace';
|
|
import { WorkspaceScopeKeys } from '../../models/workspace';
|
|
import { ProtoDirectory } from '../proto-directory';
|
|
import { ProtoFile } from '../proto-file';
|
|
import { RequestGroup } from '../request-group';
|
|
import { Request } from '../request';
|
|
import { GrpcRequest } from '../grpc-request';
|
|
|
|
export const isGrpcRequestId = (id: string | null) => (
|
|
id?.startsWith(`${grpcRequest.prefix}_`)
|
|
);
|
|
|
|
export const isSpaceId = (id: string | null) => (
|
|
id?.startsWith(`${space.prefix}_`)
|
|
);
|
|
|
|
// TODO: Invalid until we can ensure all requests are prefixed by the id correctly INS-341
|
|
// export const isRequestId = (id: string) => id.startsWith(`${request.prefix}_`);
|
|
|
|
export const isGrpcRequest = (obj: Pick<BaseModel, 'type'>): obj is GrpcRequest => (
|
|
obj.type === grpcRequest.type
|
|
);
|
|
|
|
export const isRequest = (obj: Pick<BaseModel, 'type'>): obj is Request => (
|
|
obj.type === request.type
|
|
);
|
|
|
|
export const isRequestGroup = (obj: Pick<BaseModel, 'type'>): obj is RequestGroup => (
|
|
obj.type === requestGroup.type
|
|
);
|
|
|
|
export const isProtoFile = (obj: Pick<BaseModel, 'type'>): obj is ProtoFile => (
|
|
obj.type === protoFile.type
|
|
);
|
|
|
|
export const isProtoDirectory = (obj: Pick<BaseModel, 'type'>): obj is ProtoDirectory => (
|
|
obj.type === protoDirectory.type
|
|
);
|
|
|
|
export const isWorkspace = (obj: Pick<BaseModel, 'type'>): obj is Workspace => (
|
|
obj.type === workspace.type
|
|
);
|
|
|
|
export const isDesign = (obj: Partial<Workspace>) => (
|
|
obj.scope === WorkspaceScopeKeys.design
|
|
);
|
|
|
|
export const isCollection = (obj: Workspace) => (
|
|
obj.scope === WorkspaceScopeKeys.collection
|
|
);
|