Skip to content

Commit

Permalink
Separate connection model from signature
Browse files Browse the repository at this point in the history
  • Loading branch information
joonashak committed Oct 18, 2024
1 parent a801aea commit 5a529ac
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 135 deletions.
2 changes: 1 addition & 1 deletion server/src/dev-tools/data/connections.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MassStatus from "../../entities/signature/enums/mass-status.enum";
import MassStatus from "../../entities/connection/mass-status.enum";
import SigType from "../../entities/signature/enums/sig-type.enum";

/*
Expand Down
2 changes: 1 addition & 1 deletion server/src/dev-tools/data/wormholes-OLD.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MassStatus from "../../entities/signature/enums/mass-status.enum";
import MassStatus from "../../entities/connection/mass-status.enum";

export default [
// Jita chain.
Expand Down
55 changes: 55 additions & 0 deletions server/src/entities/connection/connection.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Field, ObjectType, registerEnumType } from "@nestjs/graphql";
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import mongoose, { Document } from "mongoose";
import MassStatus from "./mass-status.enum";

registerEnumType(MassStatus, { name: "MassStatus" });

@ObjectType()
@Schema()
export class Connection {
@Field()
id: string;

@Field()
@Prop({ index: true })
from: string;

@Field({ nullable: true })
@Prop()
to: string;

/**
* Connection's inherent type.
*
* Defined as the type of the "named-side" wormhole (e.g. H296) regardless of
* the actual direction, i.e., this type can never be K162.
*/
@Field({ nullable: true })
@Prop()
type: string;

@Field()
@Prop()
k162: boolean;

@Field()
@Prop()
eol: boolean;

@Field((type) => Date, { nullable: true })
@Prop()
eolAt?: Date;

@Field((type) => MassStatus)
@Prop()
massStatus: MassStatus;

@Field((type) => Connection)
@Prop({ type: mongoose.Schema.Types.ObjectId, ref: Connection.name })
reverse: Connection;
}

export type ConnectionDocument = Connection & Document;

export const ConnectionSchema = SchemaFactory.createForClass(Connection);
13 changes: 13 additions & 0 deletions server/src/entities/connection/connection.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Module } from "@nestjs/common";
import { MongooseModule } from "@nestjs/mongoose";
import { Connection, ConnectionSchema } from "./connection.model";

@Module({
imports: [
MongooseModule.forFeature([
{ name: Connection.name, schema: ConnectionSchema },
]),
],
exports: [MongooseModule],
})
export class ConnectionModule {}
3 changes: 3 additions & 0 deletions server/src/entities/entities.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Module } from "@nestjs/common";
import { CharacterModule } from "./character/character.module";
import { ConnectionModule } from "./connection/connection.module";
import { FolderModule } from "./folder/folder.module";
import { MapModule } from "./map/map.module";
import { SignatureModule } from "./signature/signature.module";
Expand All @@ -12,13 +13,15 @@ import { SystemModule } from "./system/system.module";
MapModule,
SignatureModule,
SystemModule,
ConnectionModule,
],
exports: [
CharacterModule,
FolderModule,
MapModule,
SignatureModule,
SystemModule,
ConnectionModule,
],
})
export class EntitiesModule {}
20 changes: 0 additions & 20 deletions server/src/entities/signature/connection.model.ts

This file was deleted.

2 changes: 1 addition & 1 deletion server/src/entities/signature/dto/add-signatures.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Field, InputType, OmitType } from "@nestjs/graphql";
import MassStatus from "../enums/mass-status.enum";
import MassStatus from "../../connection/mass-status.enum";
import { SignatureWithoutConnection } from "../signature.model";

@InputType()
Expand Down
4 changes: 3 additions & 1 deletion server/src/entities/signature/signature.model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Field, ObjectType, registerEnumType } from "@nestjs/graphql";
import { Connection } from "./connection.model";
import { Connection } from "../connection/connection.model";
import SigType from "./enums/sig-type.enum";

registerEnumType(SigType, { name: "SigType" });

// FIXME: This is probably not right and should be refactored.
// This split is done because a reference to another @InputType class with
// duplicate field names breaks the GraphQL type system.
@ObjectType()
Expand All @@ -17,6 +18,7 @@ export class SignatureWithoutConnection {
@Field((type) => SigType)
type: SigType;

// FIXME: Remove.
@Field({ nullable: true })
wormholeType?: string;

Expand Down
111 changes: 0 additions & 111 deletions server/src/entities/signature/signature.utils.ts

This file was deleted.

0 comments on commit 5a529ac

Please sign in to comment.