import { Schema } from '@develohpanda/fluent-builder'; import { BaseModel, gitRepository, grpcRequest, request, requestGroup, workspace } from '..'; import { GitRepository } from '../git-repository'; import { Workspace } from '../workspace'; import { Request } from '../request'; import clone from 'clone'; import { GrpcRequest } from '../grpc-request'; import { RequestGroup } from '../request-group'; // move into fluent-builder const toSchema = (obj: T): Schema => { const cloned = clone(obj); const output: Partial> = {}; Object.keys(cloned).forEach(key => { output[key] = () => cloned[key]; }); return output as Schema; }; export const baseModelSchema: Schema = { _id: () => 'id', created: () => 1234, isPrivate: () => false, modified: () => 5678, name: () => 'name', parentId: () => '', type: () => 'base', }; export const workspaceModelSchema: Schema = { ...baseModelSchema, ...toSchema(workspace.init()), certificates: () => undefined, type: () => workspace.type, }; export const requestModelSchema: Schema = { ...baseModelSchema, ...toSchema(request.init()), type: () => request.type, }; export const grpcRequestModelSchema: Schema = { ...baseModelSchema, ...toSchema(grpcRequest.init()), type: () => grpcRequest.type, }; export const requestGroupModelSchema: Schema = { ...baseModelSchema, ...toSchema(requestGroup.init()), type: () => requestGroup.type, }; export const gitRepositorySchema: Schema = { ...baseModelSchema, type: () => gitRepository.type, author: () => ({ name: '', email: '' }), credentials: () => null, uri: () => '', needsFullClone: () => false, uriNeedsMigration: () => true, };