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): obj is GrpcRequest => ( obj.type === grpcRequest.type ); export const isRequest = (obj: Pick): obj is Request => ( obj.type === request.type ); export const isRequestGroup = (obj: Pick): obj is RequestGroup => ( obj.type === requestGroup.type ); export const isProtoFile = (obj: Pick): obj is ProtoFile => ( obj.type === protoFile.type ); export const isProtoDirectory = (obj: Pick): obj is ProtoDirectory => ( obj.type === protoDirectory.type ); export const isWorkspace = (obj: Pick): obj is Workspace => ( obj.type === workspace.type ); export const isDesign = (obj: Partial) => ( obj.scope === WorkspaceScopeKeys.design ); export const isCollection = (obj: Workspace) => ( obj.scope === WorkspaceScopeKeys.collection );