Skip to content

Commit

Permalink
Merge pull request #4875 from alkem-io/server-4619
Browse files Browse the repository at this point in the history
renamed space level enum entries
  • Loading branch information
valentinyanakiev authored Jan 29, 2025
2 parents a1a63ed + d8f3163 commit fab0743
Show file tree
Hide file tree
Showing 24 changed files with 78 additions and 78 deletions.
6 changes: 3 additions & 3 deletions src/common/enums/space.level.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { registerEnumType } from '@nestjs/graphql';

export enum SpaceLevel {
SPACE = 0,
CHALLENGE = 1,
OPPORTUNITY = 2,
L0 = 0,
L1 = 1,
L2 = 2,
}

registerEnumType(SpaceLevel, {
Expand Down
2 changes: 1 addition & 1 deletion src/core/bootstrap/bootstrap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ export class BootstrapService {
displayName: DEFAULT_SPACE_DISPLAYNAME,
tagline: 'An empty space to be populated',
},
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
type: SpaceType.SPACE,
collaborationData: {
calloutsSetData: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export class CalloutsSetService {
// Filter by Callout types
if (args.types && !args.types.includes(callout.type)) {
return false;
}
}

// Filter by Callout groups
if (groupNames.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class CollaborationService {
}

switch (space.level) {
case SpaceLevel.SPACE:
case SpaceLevel.L0:
const spacesInAccount = await this.entityManager.find(Space, {
where: {
levelZeroSpaceID: space.id,
Expand All @@ -239,7 +239,7 @@ export class CollaborationService {
}
return x.collaboration;
});
case SpaceLevel.CHALLENGE:
case SpaceLevel.L1:
const subsubspaces = space.subspaces;
if (!subsubspaces) {
throw new EntityNotInitializedException(
Expand Down
2 changes: 1 addition & 1 deletion src/domain/space/account/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class AccountService {
}

// Set data for the root space
spaceData.level = SpaceLevel.SPACE;
spaceData.level = SpaceLevel.L0;
spaceData.storageAggregatorParent = account.storageAggregator;

let space = await this.spaceService.createSpace(spaceData, agentInfo);
Expand Down
18 changes: 9 additions & 9 deletions src/domain/space/space.defaults/space.defaults.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ export class SpaceDefaultsService {

public getRoleSetCommunityRoles(spaceLevel: SpaceLevel): CreateRoleInput[] {
switch (spaceLevel) {
case SpaceLevel.CHALLENGE:
case SpaceLevel.OPPORTUNITY:
case SpaceLevel.L1:
case SpaceLevel.L2:
return subspaceCommunityRoles;
case SpaceLevel.SPACE:
case SpaceLevel.L0:
return spaceCommunityRoles;
default:
throw new EntityNotInitializedException(
Expand All @@ -208,11 +208,11 @@ export class SpaceDefaultsService {

public getProfileType(spaceLevel: SpaceLevel): ProfileType {
switch (spaceLevel) {
case SpaceLevel.CHALLENGE:
case SpaceLevel.L1:
return ProfileType.CHALLENGE;
case SpaceLevel.OPPORTUNITY:
case SpaceLevel.L2:
return ProfileType.OPPORTUNITY;
case SpaceLevel.SPACE:
case SpaceLevel.L0:
return ProfileType.SPACE;
}
}
Expand All @@ -221,10 +221,10 @@ export class SpaceDefaultsService {
spaceLevel: SpaceLevel
): CreateFormInput {
switch (spaceLevel) {
case SpaceLevel.CHALLENGE:
case SpaceLevel.OPPORTUNITY:
case SpaceLevel.L1:
case SpaceLevel.L2:
return subspceCommunityApplicationForm;
case SpaceLevel.SPACE:
case SpaceLevel.L0:
return spaceCommunityApplicationForm;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/domain/space/space/space.resolver.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class SpaceResolverQueries {
): Promise<ISpace> {
const space = await this.spaceService.getSpaceOrFail(ID, {
where: {
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
},
});
return space;
Expand Down
16 changes: 8 additions & 8 deletions src/domain/space/space/space.service.authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ export class SpaceAuthorizationService {
// Note: later will need additional logic here for Templates
let parentSpaceRoleSet: IRoleSet | undefined;
switch (space.level) {
case SpaceLevel.SPACE: {
case SpaceLevel.L0: {
space.authorization = this.resetToPrivateLevelZeroSpaceAuthorization(
space.authorization
);
break;
}
case SpaceLevel.CHALLENGE:
case SpaceLevel.OPPORTUNITY: {
case SpaceLevel.L1:
case SpaceLevel.L2: {
if (isPrivate) {
// Key: private get the base space authorization setup, that is then extended
space.authorization = this.resetToPrivateLevelZeroSpaceAuthorization(
Expand Down Expand Up @@ -262,11 +262,11 @@ export class SpaceAuthorizationService {
const globalAnonymousRegistered = this.getGlobalAnonymousRegistered();

switch (space.level) {
case SpaceLevel.SPACE:
case SpaceLevel.L0:
credentialCriteriasWithAccess.push(...globalAnonymousRegistered);
break;

case SpaceLevel.CHALLENGE:
case SpaceLevel.L1:
credentialCriteriasWithAccess.push(
...(await this.getL1SpaceLevelCredentials(
space,
Expand All @@ -275,7 +275,7 @@ export class SpaceAuthorizationService {
);
break;

case SpaceLevel.OPPORTUNITY:
case SpaceLevel.L2:
credentialCriteriasWithAccess.push(
...(await this.getL2SpaceLevelCredentials(
space,
Expand Down Expand Up @@ -415,7 +415,7 @@ export class SpaceAuthorizationService {

const updatedAuthorizations: IAuthorizationPolicy[] = [];

const isSubspaceCommunity = space.level !== SpaceLevel.SPACE;
const isSubspaceCommunity = space.level !== SpaceLevel.L0;

const communityAuthorizations =
await this.communityAuthorizationService.applyAuthorizationPolicy(
Expand All @@ -442,7 +442,7 @@ export class SpaceAuthorizationService {
updatedAuthorizations.push(...storageAuthorizations);

// Level zero space only entities
if (space.level === SpaceLevel.SPACE) {
if (space.level === SpaceLevel.L0) {
if (!space.templatesManager) {
throw new RelationshipNotFoundException(
`Unable to load templatesManager on level zero space for auth reset ${space.id} `,
Expand Down
4 changes: 2 additions & 2 deletions src/domain/space/space/space.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ const getSubspacesMock = (
...getEntityMock<Account>(),
},
type: SpaceType.CHALLENGE,
level: SpaceLevel.CHALLENGE,
level: SpaceLevel.L1,
visibility: SpaceVisibility.ACTIVE,
collaboration: {
id: '',
Expand Down Expand Up @@ -394,7 +394,7 @@ const getSubsubspacesMock = (subsubspaceId: string, count: number): Space[] => {
...getEntityMock<Account>(),
},
type: SpaceType.OPPORTUNITY,
level: SpaceLevel.OPPORTUNITY,
level: SpaceLevel.L2,
visibility: SpaceVisibility.ACTIVE,
collaboration: {
id: '',
Expand Down
30 changes: 15 additions & 15 deletions src/domain/space/space/space.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ export class SpaceService {
if (!spaceData.type) {
// default to match the level if not specified
switch (spaceData.level) {
case SpaceLevel.SPACE:
case SpaceLevel.L0:
spaceData.type = SpaceType.SPACE;
break;
case SpaceLevel.CHALLENGE:
case SpaceLevel.L1:
spaceData.type = SpaceType.CHALLENGE;
break;
case SpaceLevel.OPPORTUNITY:
case SpaceLevel.L2:
spaceData.type = SpaceType.OPPORTUNITY;
break;
default:
Expand All @@ -143,7 +143,7 @@ export class SpaceService {
}
// Hard code / overwrite for now for root space level
if (
spaceData.level === SpaceLevel.SPACE &&
spaceData.level === SpaceLevel.L0 &&
spaceData.type !== SpaceType.SPACE
) {
throw new NotSupportedException(
Expand Down Expand Up @@ -264,7 +264,7 @@ export class SpaceService {
// save the collaboration and all it's template sets
await this.save(space);

if (spaceData.level === SpaceLevel.SPACE) {
if (spaceData.level === SpaceLevel.L0) {
space.levelZeroSpaceID = space.id;
}

Expand All @@ -289,7 +289,7 @@ export class SpaceService {
type: AgentType.SPACE,
});

if (space.level === SpaceLevel.SPACE) {
if (space.level === SpaceLevel.L0) {
space.templatesManager = await this.createTemplatesManager();
}

Expand Down Expand Up @@ -382,7 +382,7 @@ export class SpaceService {
await this.licenseService.removeLicenseOrFail(space.license.id);
await this.authorizationPolicyService.delete(space.authorization);

if (space.level === SpaceLevel.SPACE) {
if (space.level === SpaceLevel.L0) {
if (!space.templatesManager || !space.templatesManager) {
throw new RelationshipNotFoundException(
`Unable to load entities to delete base subspace: ${space.id} `,
Expand Down Expand Up @@ -417,7 +417,7 @@ export class SpaceService {

return this.spaceRepository.findBy({
visibility: spaceVisibilityFilter,
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
});
}

Expand Down Expand Up @@ -500,7 +500,7 @@ export class SpaceService {
spaces = await this.spaceRepository.find({
where: {
id: In(args.IDs),
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
visibility: In(visibilities),
},
...options,
Expand All @@ -509,7 +509,7 @@ export class SpaceService {
spaces = await this.spaceRepository.find({
where: {
visibility: In(visibilities),
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
},
...options,
});
Expand Down Expand Up @@ -571,7 +571,7 @@ export class SpaceService {
if (visibilities) {
qb.leftJoinAndSelect('space.authorization', 'authorization');
qb.where({
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
visibility: In(visibilities),
});
}
Expand All @@ -589,7 +589,7 @@ export class SpaceService {
qb.leftJoinAndSelect('space.authorization', 'authorization_policy');
qb.leftJoinAndSelect('subspace.subspaces', 'subspaces');
qb.where({
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
id: In(IDs),
});
const spacesDataForSorting = await qb.getMany();
Expand Down Expand Up @@ -708,7 +708,7 @@ export class SpaceService {
.leftJoinAndSelect('s.authorization', 'authorization') // eager load the authorization
.innerJoin(Activity, 'a', 's.collaborationId = a.collaborationID')
.where({
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
visibility: SpaceVisibility.ACTIVE,
})
// activities in the past "daysOld" days
Expand Down Expand Up @@ -778,7 +778,7 @@ export class SpaceService {
): Promise<ISpace> {
if (updateData.visibility && updateData.visibility !== space.visibility) {
// Only update visibility on L0 spaces
if (space.level !== SpaceLevel.SPACE) {
if (space.level !== SpaceLevel.L0) {
throw new ValidationException(
`Unable to update visibility on Space ${space.id} as it is not a L0 space`,
LogContext.SPACES
Expand All @@ -794,7 +794,7 @@ export class SpaceService {

if (updateData.nameID && updateData.nameID !== space.nameID) {
let reservedNameIDs: string[] = [];
if (space.level === SpaceLevel.SPACE) {
if (space.level === SpaceLevel.L0) {
reservedNameIDs =
await this.namingService.getReservedNameIDsLevelZeroSpaces();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ export class StorageAggregatorService {
): Promise<string> {
let url = '';
switch (space.level) {
case SpaceLevel.OPPORTUNITY:
case SpaceLevel.L2:
url = await this.urlGeneratorService.generateUrlForSubsubspace(
space.id
);
break;
case SpaceLevel.CHALLENGE:
case SpaceLevel.L1:
url = await this.urlGeneratorService.generateUrlForSubspace(space.id);
break;
case SpaceLevel.SPACE:
case SpaceLevel.L0:
url = this.urlGeneratorService.generateUrlForSpace(space.nameID);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/domain/timeline/calendar/calendar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class CalendarService {
// to be levelZeroSpace = spaceId and level > space level
.where({
parentSpace: { id: rootSpaceId },
level: SpaceLevel.CHALLENGE,
level: SpaceLevel.L1,
})
.leftJoin(
Collaboration,
Expand Down
1 change: 0 additions & 1 deletion src/domain/timeline/event/event.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { NameableEntity } from '@domain/common/entity/nameable-entity/nameable.e
import { Room } from '@domain/communication/room/room.entity';
import { ENUM_LENGTH, UUID_LENGTH } from '@common/constants';
import { CalendarEventType } from '@common/enums/calendar.event.type';
import { Space } from '@domain/space/space/space.entity';

@Entity()
export class CalendarEvent extends NameableEntity implements ICalendarEvent {
Expand Down
6 changes: 3 additions & 3 deletions src/domain/timeline/event/event.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable, LoggerService } from '@nestjs/common';
import { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { EntityManager, FindOneOptions, In, Repository } from 'typeorm';
import { FindOneOptions, In, Repository } from 'typeorm';
import { EntityNotFoundException } from '@common/exceptions';
import { LogContext, ProfileType } from '@common/enums';
import { AuthorizationPolicy } from '@domain/common/authorization-policy';
Expand Down Expand Up @@ -224,7 +224,7 @@ export class CalendarEventService {
'subspace.collaborationId = collaboration.id'
)
.where('calendarEvent.id = :id', { id: calendarEvent.id })
.andWhere('subspace.level != :level', { level: SpaceLevel.SPACE })
.andWhere('subspace.level != :level', { level: SpaceLevel.L0 })
.select('subspace.id as spaceId')
.getRawOne<{ spaceId: string }>();

Expand Down
2 changes: 1 addition & 1 deletion src/services/adapters/activity-adapter/activity.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class ActivityAdapter {
);
}
const eventType =
subspace.level === SpaceLevel.OPPORTUNITY
subspace.level === SpaceLevel.L2
? ActivityEventType.OPPORTUNITY_CREATED
: ActivityEventType.CHALLENGE_CREATED;

Expand Down
4 changes: 2 additions & 2 deletions src/services/api/conversion/conversion.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class ConversionService {
profileData: {
displayName: subspace.profile.displayName,
},
level: SpaceLevel.SPACE,
level: SpaceLevel.L0,
type: SpaceType.SPACE,
collaborationData: {
calloutsSetData: {},
Expand Down Expand Up @@ -288,7 +288,7 @@ export class ConversionService {
displayName: subsubspace.profile.displayName,
},
storageAggregatorParent: levelZeroSpaceStorageAggregator,
level: SpaceLevel.CHALLENGE,
level: SpaceLevel.L1,
type: SpaceType.CHALLENGE,
};
const emptyChallenge = await this.spaceService.createSubspace(
Expand Down
Loading

0 comments on commit fab0743

Please sign in to comment.