Skip to content

Commit

Permalink
chore: ensure parity between front-end and back-end dto
Browse files Browse the repository at this point in the history
  • Loading branch information
mbystedt committed Dec 19, 2024
1 parent a0eeda8 commit 9229e24
Show file tree
Hide file tree
Showing 117 changed files with 395 additions and 416 deletions.
File renamed without changes.
17 changes: 0 additions & 17 deletions src/intention/dto/package-rest.dto.ts

This file was deleted.

4 changes: 4 additions & 0 deletions src/persistence/dto/broker-account.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export class BrokerAccountBaseDto extends CollectionBaseDto {
@IsDefined()
name!: string;

@IsBoolean()
@IsDefined()
enableUserImport!: boolean;

@IsBoolean()
@IsDefined()
requireRoleId!: boolean;
Expand Down
11 changes: 10 additions & 1 deletion src/persistence/dto/collection-dto-union.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ export const CollectionDtoUnionObject = {
team: TeamDto,
user: UserDto,
};
export type CollectionDtoUnion = typeof CollectionDtoUnionObject;
export type CollectionDtoUnion = {
brokerAccount: BrokerAccountDto;
environment: EnvironmentDto;
project: ProjectDto;
server: ServerDto;
serviceInstance: ServiceInstanceDto;
service: ServiceDto;
team: TeamDto;
user: UserDto;
};

export const CollectionBaseSubTypes = Object.entries(
CollectionBaseDtoUnionObject,
Expand Down
2 changes: 1 addition & 1 deletion src/persistence/dto/connection-config.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Shared DTO: Copy in back-end and front-end should be identical

export class ConnectionConfigRestDto {
export class ConnectionConfigDto {
id!: string;
collection!: string;
description!: string;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/persistence/dto/edge.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
IsString,
ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
import { EdgePropDto } from './edge-prop.dto';
import { TimestampDto } from './timestamp.dto';
import { Type } from 'class-transformer';
// Shared DTO: Copy in back-end and front-end should be identical

export class EdgeInsertDto {
Expand Down
File renamed without changes.
49 changes: 17 additions & 32 deletions src/persistence/dto/graph-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,26 @@
import { ApiHideProperty, ApiProperty } from '@nestjs/swagger';
import {
Entity,
PrimaryKey,
Property,
SerializedPrimaryKey,
} from '@mikro-orm/core';
import { ObjectId } from 'mongodb';
import { Transform } from 'class-transformer';
import { Type } from 'class-transformer';
import { IsString, IsDefined, IsDate } from 'class-validator';
import { VertexDto } from './vertex.dto';
import { EdgeDto } from './edge.dto';

@Entity({ tableName: 'graphRequestDto' })
export class GraphRequestDto {
@ApiHideProperty()
@Transform((value) =>
value.obj.id ? new ObjectId(value.obj.id.toString()) : null,
)
@PrimaryKey()
@Property()
_id: ObjectId;
@IsString()
@IsDefined()
id!: string;

@SerializedPrimaryKey()
id!: string; // won't be saved in the database
@IsDate()
@IsDefined()
@Type(() => Date)
created!: Date;

@Property()
created: Date;
@IsString()
@IsDefined()
type!: 'edge' | 'vertex';

@Property()
type: 'edge' | 'vertex';
@IsDefined()
data!: Omit<EdgeDto, 'id'> | Omit<VertexDto, 'id'>;

@Property()
data: Omit<EdgeDto, 'id'> | Omit<VertexDto, 'id'>;

@Property()
@ApiProperty({ type: () => String })
@Transform((value) =>
value.obj.requestor ? new ObjectId(value.obj.requestor.toString()) : null,
)
requestor: ObjectId;
@IsString()
@IsDefined()
requestor!: string;
}
8 changes: 4 additions & 4 deletions src/persistence/dto/graph-server-installs.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { ServiceInstanceDto } from './service-instance.dto';
import { ServiceDto } from './service.dto';

export class GraphServerInstallInstanceDto extends ServiceInstanceDto {
edgeProp: EdgePropDto;
environment: EnvironmentDto;
service: ServiceDto;
edgeProp!: EdgePropDto;
environment!: EnvironmentDto;
service!: ServiceDto;
}

export class GraphServerInstallsResponseDto extends ServiceInstanceDto {
instances: GraphServerInstallInstanceDto[];
instances!: GraphServerInstallInstanceDto[];
}
8 changes: 4 additions & 4 deletions src/persistence/dto/group-registry-by-account.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class GroupRegistryByAccountDto {
_id: { accountId: string };
createdAt: Date[];
jti: string[];
blocked: boolean[];
_id!: { accountId: string };
createdAt!: Date[];
jti!: string[];
blocked!: boolean[];
}
2 changes: 1 addition & 1 deletion src/persistence/dto/intention-action-pointer.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export class IntentionActionPointerDto {

@IsString()
@IsDefined()
intention: string;
intention!: string;
source?: any;
}
2 changes: 1 addition & 1 deletion src/persistence/dto/jwt.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IsOptional, IsString } from 'class-validator';

export abstract class JwtDto {
@IsString()
id: string;
id!: string;

@IsString()
@IsOptional()
Expand Down
6 changes: 3 additions & 3 deletions src/persistence/dto/service.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
IsString,
ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
import { PackageBuildSearchResult } from './package-build.dto';
import { ServiceInstanceDetailsResponseDto } from './service-instance.dto';
import { VaultConfigDto } from './vault-config.dto';
import { CollectionBaseDto, VertexPointerDto } from './vertex-pointer.dto';
import { Type } from 'class-transformer';

// Shared DTO: Copy in back-end and front-end should be identical
export class ServiceBaseDto extends CollectionBaseDto {
Expand Down Expand Up @@ -45,6 +45,6 @@ export class ServiceDto extends ServiceBaseDto implements VertexPointerDto {
}

export class ServiceDetailsResponseDto extends ServiceDto {
serviceInstance: ServiceInstanceDetailsResponseDto[];
builds: PackageBuildSearchResult;
serviceInstance!: ServiceInstanceDetailsResponseDto[];
builds!: PackageBuildSearchResult;
}
6 changes: 3 additions & 3 deletions src/system/system.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Request } from 'express';
import { SystemRepository } from '../persistence/interfaces/system.repository';
import { ConnectionConfigRestDto } from '../persistence/dto/connection-config.dto';
import { ConnectionConfigDto } from '../persistence/dto/connection-config.dto';
import { GithubService } from '../github/github.service';
import { AuthService } from '../auth/auth.service';

Expand All @@ -13,10 +13,10 @@ export class SystemService {
private readonly github: GithubService,
) {}

async getConnections(): Promise<ConnectionConfigRestDto[]> {
async getConnections(): Promise<ConnectionConfigDto[]> {
return (await this.systemRepository.getConnectionConfigs()).sort(
(a, b) => a.order - b.order,
) as unknown as ConnectionConfigRestDto[];
) as unknown as ConnectionConfigDto[];
}

async generateGitHubAuthorizeUrl(request: Request) {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/app-initialize.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
CollectionEdgeConfigMap,
} from './service/graph.types';
import { PreferenceDto } from './preference.dto';
import { CollectionConfigDto } from './service/dto/collection-config.dto';
import { CollectionConfigDto } from './service/persistence/dto/collection-config.dto';
import { GraphUtilService } from './service/graph-util.service';
import { UserSelfDto } from './service/dto/user.dto';
import { UserSelfDto } from './service/persistence/dto/user.dto';

let userInfo: UserSelfDto;
let preferencesInit: PreferenceDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import { PermissionService } from '../../service/permission.service';
import { CONFIG_MAP } from '../../app-initialize.factory';
import { CollectionConfigMap } from '../../service/graph.types';

import { CollectionNames } from '../../service/dto/collection-dto-union.type';
import { CollectionConfigDto } from '../../service/dto/collection-config.dto';
import { CollectionNames } from '../../service/persistence/dto/collection-dto-union.type';
import { CollectionConfigDto } from '../../service/persistence/dto/collection-config.dto';
import { CollectionHeaderComponent } from '../../shared/collection-header/collection-header.component';
import { InspectorAccountComponent } from '../../graph/inspector-account/inspector-account.component';
import { InspectorInstallsComponent } from '../../graph/inspector-installs/inspector-installs.component';
Expand All @@ -49,10 +49,10 @@ import { TeamServicesComponent } from '../team-services/team-services.component'
import { TeamAccountsComponent } from '../team-accounts/team-accounts.component';
import { TeamMembersComponent } from '../team-members/team-members.component';
import { InspectorConnectionsComponent } from '../../graph/inspector-connections/inspector-connections.component';
import { CollectionCombo } from '../../service/dto/collection-search-result.dto';
import { CollectionCombo } from '../../service/collection/dto/collection-search-result.dto';
import { CollectionUtilService } from '../../service/collection-util.service';
import { VertexDto } from '../../service/dto/vertex.dto';
import { EdgeDto } from '../../service/dto/edge.dto';
import { VertexDto } from '../../service/persistence/dto/vertex.dto';
import { EdgeDto } from '../../service/persistence/dto/edge.dto';
import { GraphUtilService } from '../../service/graph-util.service';
import { InspectorPropertiesComponent } from '../../graph/inspector-properties/inspector-properties.component';
import { InspectorTimestampsComponent } from '../../graph/inspector-timestamps/inspector-timestamps.component';
Expand Down
14 changes: 7 additions & 7 deletions ui/src/app/browse/collection-table/collection-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ import { CONFIG_MAP, CURRENT_USER } from '../../app-initialize.factory';
import { CollectionConfigMap } from '../../service/graph.types';
import { GraphUtilService } from '../../service/graph-util.service';
import { GraphApiService } from '../../service/graph-api.service';
import { GraphTypeaheadData } from '../../service/dto/graph-typeahead-result.dto';
import { CollectionNames } from '../../service/dto/collection-dto-union.type';
import { GraphTypeaheadData } from '../../service/graph/dto/graph-typeahead-result.dto';
import { CollectionNames } from '../../service/persistence/dto/collection-dto-union.type';
import {
CollectionConfigDto,
CollectionFieldConfigMap,
} from '../../service/dto/collection-config.dto';
} from '../../service/persistence/dto/collection-config.dto';
import { VertexDialogComponent } from '../../graph/vertex-dialog/vertex-dialog.component';
import { PermissionService } from '../../service/permission.service';
import { TeamDto } from '../../service/dto/team.dto';
import { TeamDto } from '../../service/persistence/dto/team.dto';
import { AddTeamDialogComponent } from '../../team/add-team-dialog/add-team-dialog.component';
import { CollectionCombo } from '../../service/dto/collection-search-result.dto';
import { CollectionComboDto } from '../../service/dto/collection-combo.dto';
import { CollectionCombo } from '../../service/collection/dto/collection-search-result.dto';
import { CollectionComboDto } from '../../service/persistence/dto/collection-combo.dto';
import { PreferencesService } from '../../preferences.service';
import { InspectorVertexFieldComponent } from '../../graph/inspector-vertex-field/inspector-vertex-field.component';
import { InspectorTeamComponent } from '../../graph/inspector-team/inspector-team.component';
import { UserSelfDto } from '../../service/dto/user.dto';
import { UserSelfDto } from '../../service/persistence/dto/user.dto';

type ShowFilter = 'connected' | 'all';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
} from '@angular/material/dialog';
import { MatButtonModule } from '@angular/material/button';
import { InspectorPropertiesComponent } from '../../graph/inspector-properties/inspector-properties.component';
import { VertexPropDto } from '../../service/dto/vertex.dto';
import { EdgePropDto } from '../../service/dto/edge-prop.dto';
import { VertexPropDto } from '../../service/persistence/dto/vertex.dto';
import { EdgePropDto } from '../../service/persistence/dto/edge-prop.dto';

@Component({
selector: 'app-graph-prop-viewer-dialog',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { combineLatest, Subject, takeUntil } from 'rxjs';

import { CollectionHeaderComponent } from '../../shared/collection-header/collection-header.component';
import { PackageApiService } from '../../service/package-api.service';
import { PackageBuildDto } from '../../service/dto/package-build.dto';
import { PackageBuildDto } from '../../service/persistence/dto/package-build.dto';
import { FilesizePipe } from '../../util/filesize.pipe';
import { CollectionNames } from '../../service/dto/collection-dto-union.type';
import { CollectionNames } from '../../service/persistence/dto/collection-dto-union.type';
import { CollectionApiService } from '../../service/collection-api.service';
import { PackageUtilService } from '../../service/package-util.service';
import { InspectorInstallsComponent } from '../../graph/inspector-installs/inspector-installs.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { MatButtonModule } from '@angular/material/button';
import { MatDividerModule } from '@angular/material/divider';
import { MatTableModule } from '@angular/material/table';
import { PackageApiService } from '../../service/package-api.service';
import { PackageBuildDto } from '../../service/dto/package-build.dto';
import { PackageBuildDto } from '../../service/persistence/dto/package-build.dto';
import { MatIconModule } from '@angular/material/icon';
import { ClipboardModule } from '@angular/cdk/clipboard';
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { MatDialog } from '@angular/material/dialog';
import { MatSelectModule } from '@angular/material/select';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';

import { IntentionActionPointerDto } from '../../service/dto/intention-action-pointer.dto';
import { IntentionActionPointerDto } from '../../service/persistence/dto/intention-action-pointer.dto';
import { CollectionUtilService } from '../../service/collection-util.service';
import { CollectionNames } from '../../service/dto/collection-dto-union.type';
import { CollectionNames } from '../../service/persistence/dto/collection-dto-union.type';
import { GraphPropViewerDialogComponent } from '../graph-prop-viewer-dialog/graph-prop-viewer-dialog.component';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import {
InspectorInstanceDialogReturnDao,
} from '../../graph/inspector-instance-dialog/inspector-instance-dialog.component';
import { GraphApiService } from '../../service/graph-api.service';
import { ServiceDto } from '../../service/dto/service.dto';
import { ServiceDto } from '../../service/persistence/dto/service.dto';
import { PermissionService } from '../../service/permission.service';
import { VertexDto } from '../../service/dto/vertex.dto';
import { GraphDirectedCombo } from '../../service/dto/collection-combo.dto';
import { VertexDto } from '../../service/persistence/dto/vertex.dto';
import { GraphDirectedCombo } from '../../service/persistence/dto/collection-combo.dto';
import { CollectionApiService } from '../../service/collection-api.service';
import { EnvironmentDto } from '../../service/dto/environment.dto';
import { EnvironmentDto } from '../../service/persistence/dto/environment.dto';
import { ServiceInstanceDetailsComponent } from '../service-instance-details/service-instance-details.component';
import { CollectionUtilService } from '../../service/collection-util.service';
import { UserSelfDto } from '../../service/dto/user.dto';
import { UserSelfDto } from '../../service/persistence/dto/user.dto';

@Component({
selector: 'app-service-instances',
Expand Down
8 changes: 4 additions & 4 deletions ui/src/app/browse/team-accounts/team-accounts.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Component, Input, OnInit } from '@angular/core';
import { CollectionApiService } from '../../service/collection-api.service';
import { CollectionSearchResult } from '../../service/dto/collection-search-result.dto';
import { BrokerAccountDto } from '../../service/dto/broker-account.dto';
import { CollectionSearchResult } from '../../service/collection/dto/collection-search-result.dto';
import { BrokerAccountDto } from '../../service/persistence/dto/broker-account.dto';
import { CommonModule } from '@angular/common';
import { CollectionConfigDto } from '../../service/dto/collection-config.dto';
import { CollectionConfigDto } from '../../service/persistence/dto/collection-config.dto';
import { InspectorVertexComponent } from '../../graph/inspector-vertex/inspector-vertex.component';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { TeamDto } from '../../service/dto/team.dto';
import { TeamDto } from '../../service/persistence/dto/team.dto';
import { GraphUtilService } from '../../service/graph-util.service';
import { MatButtonModule } from '@angular/material/button';

Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/browse/team-members/team-members.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { MatTableModule } from '@angular/material/table';
import { MatListModule } from '@angular/material/list';
import { Subject, switchMap } from 'rxjs';

import { GraphDirectedCombo } from '../../service/dto/collection-combo.dto';
import { GraphDirectedCombo } from '../../service/persistence/dto/collection-combo.dto';
import { CONFIG_MAP } from '../../app-initialize.factory';
import { CollectionConfigMap } from '../../service/graph.types';
import { CollectionEdgeConfig } from '../../service/dto/collection-config.dto';
import { CollectionEdgeConfig } from '../../service/persistence/dto/collection-config.dto';
import { CollectionApiService } from '../../service/collection-api.service';
import { CollectionUtilService } from '../../service/collection-util.service';

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/browse/team-services/team-services.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input } from '@angular/core';
import { CollectionConfigInstanceDto } from '../../service/dto/collection-config.dto';
import { CollectionConfigInstanceDto } from '../../service/persistence/dto/collection-config.dto';
import { GraphApiService } from '../../service/graph-api.service';
import { MatIconModule } from '@angular/material/icon';
import { MatCardModule } from '@angular/material/card';
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/browse/team-summary/team-summary.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnChanges, OnInit } from '@angular/core';
import { GraphDirectedCombo } from '../../service/dto/collection-combo.dto';
import { GraphDirectedCombo } from '../../service/persistence/dto/collection-combo.dto';
import { CommonModule } from '@angular/common';
import { MatTableModule } from '@angular/material/table';

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/browse/user-alias/user-alias.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MatButtonModule } from '@angular/material/button';
import { SystemApiService } from '../../service/system-api.service';
import { CURRENT_USER } from '../../app-initialize.factory';
import { HealthStatusService } from '../../service/health-status.service';
import { UserSelfDto } from '../../service/dto/user.dto';
import { UserSelfDto } from '../../service/persistence/dto/user.dto';

@Component({
selector: 'app-user-alias',
Expand Down
Loading

0 comments on commit 9229e24

Please sign in to comment.