bde148f286
* wip * some extra fixes * stuff kinda works? * need to figure out mocks * need to figure out mocks * fix db listener * gqlgen fix * minor gqlgen watch adjustment * lint fixes * delete old codegen file * converting migrations to ESM * getModuleDIrectory * vitest sort of works * added back ts-vitest * resolve gql double load * fixing test timeout configs * TSC lint fix * fix automate tests * moar debugging * debugging * more debugging * codegen update * server works * yargs migrated * chore(server): getting rid of global mocks for Server ESM (#5046) * got rid of email mock * got rid of comment mocks * got rid of multi region mocks * got rid of stripe mock * admin override mock updated * removed final mock * fixing import.meta.resolve calls * another import.meta.resolve fix * added requested test * nyc ESM fix * removed unneeded deps + linting * yarn lock forgot to commit * tryna fix flakyness * email capture util fix * sendEmail fix * fix TSX check * sender transporter fix + CR comments * merge main fix * test fixx * circleci fix * gqlgen bigint fix * error formatter fix * more error formatting improvements * esmloader added to Dockerfile * more dockerfile fixes * bg jobs fix
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { ProjectCreateArgs } from '@/modules/core/domain/projects/operations'
|
|
import {
|
|
ProjectVisibility,
|
|
StreamCreateInput
|
|
} from '@/modules/core/graph/generated/graphql'
|
|
import { ProjectRecordVisibility } from '@/modules/core/helpers/types'
|
|
import { throwUncoveredError } from '@speckle/shared'
|
|
import { has, get } from 'lodash-es'
|
|
|
|
export const isProjectCreateInput = (
|
|
i: StreamCreateInput | ProjectCreateArgs
|
|
): i is ProjectCreateArgs => {
|
|
if (!has(i, 'visibility')) return false
|
|
|
|
// If its lowercase, its not actually the project create input but the project itself - common mistake in tests
|
|
const visibility = get(i, 'visibility') as string
|
|
return visibility.toUpperCase() === visibility
|
|
}
|
|
|
|
export const mapGqlToDbProjectVisibility = (
|
|
visibility: ProjectVisibility
|
|
): ProjectRecordVisibility => {
|
|
switch (visibility) {
|
|
case ProjectVisibility.Public:
|
|
case ProjectVisibility.Unlisted:
|
|
return ProjectRecordVisibility.Public
|
|
case ProjectVisibility.Private:
|
|
return ProjectRecordVisibility.Private
|
|
case ProjectVisibility.Workspace:
|
|
return ProjectRecordVisibility.Workspace
|
|
default:
|
|
throwUncoveredError(visibility)
|
|
}
|
|
}
|
|
|
|
export const mapDbToGqlProjectVisibility = (
|
|
visibility: ProjectRecordVisibility
|
|
): ProjectVisibility => {
|
|
switch (visibility) {
|
|
case ProjectRecordVisibility.Public:
|
|
return ProjectVisibility.Public
|
|
case ProjectRecordVisibility.Private:
|
|
return ProjectVisibility.Private
|
|
case ProjectRecordVisibility.Workspace:
|
|
return ProjectVisibility.Workspace
|
|
default:
|
|
throwUncoveredError(visibility)
|
|
}
|
|
}
|