Compare commits

..

4 Commits

7 changed files with 76 additions and 8 deletions

View File

@ -1,7 +1,13 @@
import { prop, getModelForClass, Ref } from "@typegoose/typegoose" import { prop, getModelForClass, Ref } from "@typegoose/typegoose"
import Member, { MemberAdditionalAcknowledgement, MemberUsedLanguages, MemberUsedOperatingSystems } from "./Member"; import Member, { MemberAdditionalAcknowledgement, MemberUsedLanguages, MemberUsedOperatingSystems } from "./Member";
interface AddtlScoreData { export enum GenerationMethod {
TIMER_INTERNAL, // generated by the internal cron-job timer automatically
INQUIRY_INTERNAL, // internal inquiry generated internally directly through the system. user checks their own inquiry, hard inquiry is performed by a staff member, etc.
INQUIRY_EXTERNAL, // external inquiry generated externally through the system via an external authorized request, such as via EDS
}
export interface AddtlScoreData {
activity: number; activity: number;
roles: number; roles: number;
moderation: number; moderation: number;
@ -16,14 +22,21 @@ interface AddtlScoreData {
export default class CommunityReport { export default class CommunityReport {
@prop({ required: true, index: true, ref: () => Member }) @prop({ required: true, index: true, ref: () => Member })
// the member on which this report was generated for
public member: Ref<Member> | undefined; public member: Ref<Member> | undefined;
@prop() @prop({ required: true })
public lastUpdated: Date | undefined; // the date in which this report was generated on
public date: Date | undefined;
@prop() @prop({ required: true })
// the CommScore of the member specified
public score: number | undefined; public score: number | undefined;
@prop() @prop({ required: true })
// the method in which this report was generated under
public generationMethod: GenerationMethod | undefined;
@prop({ required: true })
public additionalScoreData: AddtlScoreData | undefined; public additionalScoreData: AddtlScoreData | undefined;
} }

11
database/HardInquiry.ts Normal file
View File

@ -0,0 +1,11 @@
import { prop, getModelForClass, Ref } from "@typegoose/typegoose"
import Inquiry from "./Inquiry";
/**
* HardInquiry is a class which extends Inquiry.
* Structure is performed this way to have two separate collections for Hard and Soft inquiries.
*/
export default class HardInquiry extends Inquiry {
@prop({ required: true })
public reason: string | undefined;
}

View File

@ -1,5 +1,5 @@
import { prop, getModelForClass, Ref } from "@typegoose/typegoose" import { prop, getModelForClass, Ref } from "@typegoose/typegoose"
import Member, { MemberAdditionalAcknowledgement, MemberUsedLanguages, MemberUsedOperatingSystems } from "./Member"; import Member from "./Member";
import CommunityReport from "./CommunityReport" import CommunityReport from "./CommunityReport"
/** /**
@ -11,15 +11,27 @@ import CommunityReport from "./CommunityReport"
export default abstract class Inquiry { export default abstract class Inquiry {
@prop({ required: true, unique: true })
// the Inquiry Identifier (previously known as `iid`). this is an UUIDv4 string
public id: string | undefined;
@prop({ required: true, index: true, ref: () => Member }) @prop({ required: true, index: true, ref: () => Member })
// the member on which this inquiry was performed on
public member: Ref<Member> | undefined; public member: Ref<Member> | undefined;
@prop({ required: true }) @prop({ required: true })
// the date in which this inquiry was performed
public date: Date | undefined; public date: Date | undefined;
@prop({ required: true, ref: () => Member }) @prop({ required: true, ref: () => Member })
// the reference to the member who initiated this inquiry or a string value representing the name of a system that initiated the inquiry
public initiatedBy: Ref<Member> | string | undefined; public initiatedBy: Ref<Member> | string | undefined;
@prop({ required: true, ref: () => CommunityReport }) @prop({ required: true, ref: () => CommunityReport })
// the report that was generated or fetched from this inquiry as of current date
public report: Ref<CommunityReport> | undefined; public report: Ref<CommunityReport> | undefined;
@prop()
// a reason for the inquiry, if applicable. this value is required for HardInquiry
public reason: string | "N/A" | undefined;
} }

7
database/SoftInquiry.ts Normal file
View File

@ -0,0 +1,7 @@
import Inquiry from "./Inquiry";
/**
* SoftInquiry is a class which extends Inquiry.
* Structure is performed this way to have two separate collections for Hard and Soft inquiries.
*/
export default class SoftInquiry extends Inquiry {}

15
database/Vendor.ts Normal file
View File

@ -0,0 +1,15 @@
import { prop } from '@typegoose/typegoose';
// This class represents a Vendor, which ia an entity that is permitted to access CommunityReport information, and may be permitted to manipulate data, through the HTtP API.
export default class Vendor {
@prop({ required: true })
public name: string | undefined;
@prop({ required: true, unique: true })
// the uuidv4 string identifier of the vendor; this functions as the identifier and api key for the vendor
public key: string | undefined;
@prop({ default: false })
// determines if this vendor can perform a Hard Inquiry and receive additional privileged information
public privileged: boolean | undefined;
}

10
package-lock.json generated
View File

@ -9,9 +9,11 @@
"discord.js": "^14.14.1", "discord.js": "^14.14.1",
"mongoose": "^8.2.2", "mongoose": "^8.2.2",
"stripe": "^14.21.0", "stripe": "^14.21.0",
"typeorm": "^0.3.20" "typeorm": "^0.3.20",
"uuid": "^9.0.1"
}, },
"devDependencies": { "devDependencies": {
"@types/uuid": "^9.0.8",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.4.2" "typescript": "^5.4.2"
} }
@ -277,6 +279,12 @@
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
} }
}, },
"node_modules/@types/uuid": {
"version": "9.0.8",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.8.tgz",
"integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==",
"dev": true
},
"node_modules/@types/webidl-conversions": { "node_modules/@types/webidl-conversions": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",

View File

@ -1,5 +1,6 @@
{ {
"devDependencies": { "devDependencies": {
"@types/uuid": "^9.0.8",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.4.2" "typescript": "^5.4.2"
}, },
@ -8,6 +9,7 @@
"discord.js": "^14.14.1", "discord.js": "^14.14.1",
"mongoose": "^8.2.2", "mongoose": "^8.2.2",
"stripe": "^14.21.0", "stripe": "^14.21.0",
"typeorm": "^0.3.20" "typeorm": "^0.3.20",
"uuid": "^9.0.1"
} }
} }