Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.94.0] Search subspace result; Org verification #4646

Merged
merged 7 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions alkemio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ search:
use_new: ${SEARCH_USE_NEW}:true
# max results per search
max_results: ${SEARCH_MAX_RESULTS}:40
# the index pattern used when ingesting data, e.g. alkemio-data-[organization];
# the index pattern used when ingesting data in Elasticsearch, e.g. alkemio-data-[organization];
# The dash at the end is MANDATORY
index_pattern: ${SEARCH_INDEX_PATTERN}:alkemio-data-
index_pattern: ${ELASTIC_SEARCH_INDEX_PATTERN}:alkemio-data-

## identity ##

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alkemio-server",
"version": "0.93.3",
"version": "0.94.0",
"description": "Alkemio server, responsible for managing the shared Alkemio platform",
"author": "Alkemio Foundation",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion quickstart-services-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ services:
whiteboard-collaboration:
container_name: alkemio_dev_whiteboard_collaboration
hostname: whiteboard-collaboration
image: alkemio/whiteboard-collaboration-service:v0.3.1
image: alkemio/whiteboard-collaboration-service:v0.5.0
platform: linux/x86_64
environment:
- RABBITMQ_HOST
Expand Down
2 changes: 1 addition & 1 deletion quickstart-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ services:
whiteboard-collaboration:
container_name: alkemio_dev_whiteboard_collaboration
hostname: whiteboard-collaboration
image: alkemio/whiteboard-collaboration-service:v0.4.0
image: alkemio/whiteboard-collaboration-service:v0.5.0
platform: linux/x86_64
depends_on:
- rabbitmq
Expand Down
1 change: 1 addition & 0 deletions src/common/enums/search.result.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registerEnumType } from '@nestjs/graphql';

export enum SearchResultType {
SPACE = 'space',
SUBSPACE = 'subspace',
CHALLENGE = 'challenge', // todo remove
OPPORTUNITY = 'opportunity', // todo remove
USER = 'user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { AuthorizationPrivilege, LogContext } from '@common/enums';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { MachineOptions } from 'xstate';
import { LifecycleService } from '@domain/common/lifecycle/lifecycle.service';
import { EntityNotInitializedException } from '@common/exceptions';
import {
EntityNotInitializedException,
InvalidStateTransitionException,
RelationshipNotFoundException,
} from '@common/exceptions';
import { AgentInfo } from '@core/authentication.agent.info/agent.info';
import { AuthorizationService } from '@core/authorization/authorization.service';
import { IAuthorizationPolicy } from '@domain/common/authorization-policy';
import { OrganizationVerificationEventInput } from './dto/organization.verification.dto.event';
import { OrganizationVerificationEnum } from '@common/enums/organization.verification';
import { OrganizationVerificationService } from './organization.verification.service';
import { IOrganizationVerification } from './organization.verification.interface';
import { ILifecycle } from '@domain/common/lifecycle';

@Injectable()
export class OrganizationVerificationLifecycleOptionsProvider {
Expand All @@ -25,7 +30,7 @@ export class OrganizationVerificationLifecycleOptionsProvider {
organizationVerificationEventData: OrganizationVerificationEventInput,
agentInfo: AgentInfo
): Promise<IOrganizationVerification> {
const organizationVerification =
let organizationVerification =
await this.organizationVerificationService.getOrganizationVerificationOrFail(
organizationVerificationEventData.organizationVerificationID
);
Expand All @@ -51,9 +56,49 @@ export class OrganizationVerificationLifecycleOptionsProvider {
organizationVerification.authorization
);

return await this.organizationVerificationService.getOrganizationVerificationOrFail(
organizationVerification.id
organizationVerification =
await this.organizationVerificationService.getOrganizationVerificationOrFail(
organizationVerification.id,
{
relations: {
lifecycle: true,
},
}
);
if (!organizationVerification.lifecycle) {
throw new RelationshipNotFoundException(
`Unable to load lifecycle on Organization verification: ${organizationVerification.id}`,
LogContext.COMMUNITY
);
}
// Ensure the cached state is synced with the lifecycle state
organizationVerification.status = this.getOrganizationVerificationState(
organizationVerification.lifecycle
);
return await this.organizationVerificationService.save(
organizationVerification
);
}

private getOrganizationVerificationState(
lifecycle: ILifecycle
): OrganizationVerificationEnum | never {
const state = this.lifecycleService.getState(lifecycle);

switch (state) {
case 'notVerified':
case 'verificationPending':
case 'rejected':
case 'archived':
return OrganizationVerificationEnum.NOT_VERIFIED;
case 'manuallyVerified':
return OrganizationVerificationEnum.VERIFIED_MANUAL_ATTESTATION;
default:
throw new InvalidStateTransitionException(
`Organization Verification unrecognized state: ${state}`,
LogContext.COMMUNITY
);
}
}

private organizationVerificationLifecycleMachineOptions: Partial<
Expand Down
3 changes: 2 additions & 1 deletion src/domain/space/space/space.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { SpaceVisibility } from '@common/enums/space.visibility';
import { TemplatesSet } from '@domain/template/templates-set/templates.set.entity';
import { SpaceDefaults } from '../space.defaults/space.defaults.entity';
import { Profile } from '@domain/common/profile';
import { SpaceLevel } from '@common/enums/space.level';
@Entity()
export class Space extends NameableEntity implements ISpace {
@OneToOne(() => Profile, {
Expand Down Expand Up @@ -102,7 +103,7 @@ export class Space extends NameableEntity implements ISpace {
levelZeroSpaceID!: string;

@Column('int', { nullable: false })
level!: number;
level!: SpaceLevel;

@Column('varchar', {
length: ENUM_LENGTH,
Expand Down
5 changes: 3 additions & 2 deletions src/services/api/search/dto/search.result.entry.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import { ISearchResultCallout } from './search.result.dto.entry.callout';
const type = searchResult.type;
switch (type) {
case SearchResultType.SPACE:
case SearchResultType.CHALLENGE:
case SearchResultType.OPPORTUNITY:
case SearchResultType.SUBSPACE:
case SearchResultType.CHALLENGE: // todo remove - legacy from v1
case SearchResultType.OPPORTUNITY: // todo remove - legacy from v1
return ISearchResultSpace;
case SearchResultType.USER:
return ISearchResultUser;
Expand Down
5 changes: 3 additions & 2 deletions src/services/api/search/v1/search.result.builder.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ interface SearchResultBuilderFunction<TypedSearchResult> {

export interface ISearchResultBuilder {
[SearchResultType.SPACE]: SearchResultBuilderFunction<ISearchResultSpace>;
[SearchResultType.CHALLENGE]: SearchResultBuilderFunction<ISearchResultChallenge>;
[SearchResultType.OPPORTUNITY]: SearchResultBuilderFunction<ISearchResultOpportunity>;
[SearchResultType.SUBSPACE]: SearchResultBuilderFunction<ISearchResultSpace>;
[SearchResultType.CHALLENGE]: SearchResultBuilderFunction<ISearchResultChallenge>; // todo remove - legacy from v1
[SearchResultType.OPPORTUNITY]: SearchResultBuilderFunction<ISearchResultOpportunity>; // todo remove - legacy from v1
[SearchResultType.USER]: SearchResultBuilderFunction<ISearchResultUser>;
[SearchResultType.ORGANIZATION]: SearchResultBuilderFunction<ISearchResultOrganization>;
[SearchResultType.USERGROUP]: SearchResultBuilderFunction<ISearchResultUserGroup>;
Expand Down
4 changes: 4 additions & 0 deletions src/services/api/search/v1/search.result.builder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export default class SearchResultBuilderService
return searchResultSpace;
}

async [SearchResultType.SUBSPACE](rawSearchResult: ISearchResult) {
return this[SearchResultType.SPACE](rawSearchResult);
}

async [SearchResultType.CHALLENGE](rawSearchResult: ISearchResult) {
const subspace = await this.spaceService.getSpaceOrFail(
rawSearchResult.result.id
Expand Down
4 changes: 2 additions & 2 deletions src/services/api/search/v2/ingest/search.ingest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export class SearchIngestService {
...space,
account: undefined,
parentSpace: undefined,
type: SearchEntityTypes.SPACE,
type: SearchEntityTypes.SUBSPACE,
visibility: space?.visibility,
spaceID: space.parentSpace?.id ?? EMPTY_VALUE,
profile: {
Expand Down Expand Up @@ -512,7 +512,7 @@ export class SearchIngestService {
...space,
account: undefined,
parentSpace: undefined,
type: SearchEntityTypes.SPACE,
type: SearchEntityTypes.SUBSPACE,
visibility: space?.visibility,
spaceID: space.parentSpace?.parentSpace?.id ?? EMPTY_VALUE,
profile: {
Expand Down
6 changes: 1 addition & 5 deletions src/services/api/search/v2/result/search.result.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ export class SearchResultService {
const subspaces = await this.entityManager.find(Space, {
where: { id: In(subspaceIds) },
relations: { parentSpace: true },
select: {
id: true,
level: true,
parentSpace: { id: true, level: true },
},
});

return subspaces
Expand Down Expand Up @@ -627,6 +622,7 @@ export class SearchResultService {
select: {
id: true,
type: true,
level: true,
settingsStr: true,
visibility: true,
collaboration: {
Expand Down
Loading