a6287fc06d
* init db migration * WIP store view * create service call * WIP insertion * insert sort of works * moving code arounmd * creation tests * avoid duplicate entries * fixes from main * basic group retrieval works * group filtering works * WIP view listing * filter by acl * fixes + WIP single group retrieval * wip pivot * more pivot query fixes * tests fixed after pivot * views list tests * fixing test command * business plan only checks * more tests for coverage * .dts import fix * cli fix * anutha one * auth policy tests for business plan access * WIP saved views panel base * BE listing adjustments * WIP group rendering * group render done * WIP post create cache updates * listing fine? * my vs theirs * auto open * minor fixes * click load omg * nicely loading views * type fix * less spammy loading * another type fix: * more lint fix * test fix * codecov disable * moar coverage * fix sidebar flashin * more test coverage * more test cvoverage * minor adfjustments * adj * saved view wipe fixes * CSR viewer * more improvements * extra feature flag checks * lint fix * feature flags fix * more test fixes
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import type { ProjectCreateArgs } from '@/modules/core/domain/projects/operations'
|
|
import type { StreamCreateInput } from '@/modules/core/graph/generated/graphql'
|
|
import { ProjectVisibility } 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)
|
|
}
|
|
}
|
|
|
|
export const mapGqlToDbSortDirection = (direction: 'ASC' | 'DESC'): 'asc' | 'desc' => {
|
|
switch (direction) {
|
|
case 'ASC':
|
|
return 'asc'
|
|
case 'DESC':
|
|
return 'desc'
|
|
default:
|
|
throwUncoveredError(direction)
|
|
}
|
|
}
|