From 62fc289088426b6500af7d7be8a3f72441652263 Mon Sep 17 00:00:00 2001 From: eirk Date: Sat, 25 Dec 2021 13:37:42 -0500 Subject: [PATCH] add original models --- models/Customer.ts | 13 ++++++ models/CustomerPortal.ts | 21 +++++++++ models/ExecutiveOrder.ts | 21 +++++++++ models/File.ts | 21 +++++++++ models/Inquiry.ts | 33 ++++++++++++++ models/Member.ts | 43 ++++++++++++++++++ models/Merchant.ts | 24 ++++++++++ models/Moderation.ts | 37 +++++++++++++++ models/Motion.ts | 35 +++++++++++++++ models/Note.ts | 19 ++++++++ models/PagerNumber.ts | 32 +++++++++++++ models/Proclamation.ts | 37 +++++++++++++++ models/Promo.ts | 13 ++++++ models/Rank.ts | 17 +++++++ models/Redirect.ts | 21 +++++++++ models/Resolution.ts | 33 ++++++++++++++ models/SAA.ts | 17 +++++++ models/Score.ts | 95 +++++++++++++++++++++++++++++++++++++++ models/ScoreHistorical.ts | 42 +++++++++++++++++ models/Staff.ts | 27 +++++++++++ models/Stat.ts | 13 ++++++ 21 files changed, 614 insertions(+) create mode 100644 models/Customer.ts create mode 100644 models/CustomerPortal.ts create mode 100644 models/ExecutiveOrder.ts create mode 100644 models/File.ts create mode 100644 models/Inquiry.ts create mode 100644 models/Member.ts create mode 100644 models/Merchant.ts create mode 100644 models/Moderation.ts create mode 100644 models/Motion.ts create mode 100644 models/Note.ts create mode 100644 models/PagerNumber.ts create mode 100644 models/Proclamation.ts create mode 100644 models/Promo.ts create mode 100644 models/Rank.ts create mode 100644 models/Redirect.ts create mode 100644 models/Resolution.ts create mode 100644 models/SAA.ts create mode 100644 models/Score.ts create mode 100644 models/ScoreHistorical.ts create mode 100644 models/Staff.ts create mode 100644 models/Stat.ts diff --git a/models/Customer.ts b/models/Customer.ts new file mode 100644 index 0000000..b7525b2 --- /dev/null +++ b/models/Customer.ts @@ -0,0 +1,13 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface CustomerInterface extends Document { + cusID: string, + userID: string, +} + +const Customer: Schema = new Schema({ + cusID: String, + userID: String, +}); + +export default model('Customer', Customer); diff --git a/models/CustomerPortal.ts b/models/CustomerPortal.ts new file mode 100644 index 0000000..ca96881 --- /dev/null +++ b/models/CustomerPortal.ts @@ -0,0 +1,21 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface CustomerPortalInterface extends Document { + key: string, + username: string, + userID: string, + emailAddress: string, + expiresOn: Date, + used?: boolean, +} + +const CustomerPortal: Schema = new Schema({ + key: String, + username: String, + userID: String, + emailAddress: String, + expiresOn: Date, + used: Boolean, +}); + +export default model('CustomerPortal', CustomerPortal); diff --git a/models/ExecutiveOrder.ts b/models/ExecutiveOrder.ts new file mode 100644 index 0000000..39f7b39 --- /dev/null +++ b/models/ExecutiveOrder.ts @@ -0,0 +1,21 @@ +import { Document, model, Schema } from 'mongoose'; + +export interface ExecutiveOrderInterface extends Document { + issuer: string; + subject: string; + body: string; + at: number; + oID: string; + msg: string; +} + +const ExecutiveOrder = new Schema({ + issuer: { type: String, required: true }, + subject: { type: String, required: true }, + body: { type: String, required: true }, + at: { type: Number, required: true }, + oID: { type: String, required: true, unique: true }, + msg: { type: String, required: true, unique: true }, +}); + +export default model('ExecutiveOrders', ExecutiveOrder); diff --git a/models/File.ts b/models/File.ts new file mode 100644 index 0000000..f2fa685 --- /dev/null +++ b/models/File.ts @@ -0,0 +1,21 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface FileInterface extends Document { + name: string, + identifier: string, + mimeType: string, + data: Buffer, + downloaded: number, + maxDownloads: number, +} + +const File: Schema = new Schema({ + name: String, + identifier: String, + mimeType: String, + data: Buffer, + downloaded: Number, + maxDownloads: Number, +}); + +export default model('File', File); diff --git a/models/Inquiry.ts b/models/Inquiry.ts new file mode 100644 index 0000000..318bcec --- /dev/null +++ b/models/Inquiry.ts @@ -0,0 +1,33 @@ +import { Document, Schema, model } from 'mongoose'; +import { ScoreInterfaceRaw } from '.'; + +export enum InqType { + HARD, + SOFT, +} + +export interface InquiryInterface extends Document { + iid?: string, + userID: string, + /** + * - 0: Hard + * - 1: Soft + */ + type: InqType, + name: string, + reason?: string, + date: Date, + report?: ScoreInterfaceRaw, +} + +const Inquiry: Schema = new Schema({ + iid: String, + userID: String, + type: Number, + name: String, + reason: String, + date: String, + report: Object, +}); + +export default model('Inquiry', Inquiry); diff --git a/models/Member.ts b/models/Member.ts new file mode 100644 index 0000000..2b33d8b --- /dev/null +++ b/models/Member.ts @@ -0,0 +1,43 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface MemberInterface extends Document { + userID: string, + additional?: { + langs: ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'], + operatingSystems: ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'], + github: string, + gitlab: string, + bio: string, + }, + misc?: { + t3TemporaryExpiration?: { + date: Date, + processed: boolean + previousTier: 1 | 2 | 3 + } + } + x509?: string, + pgp?: string, +} + +const Member: Schema = new Schema({ + userID: String, + additional: { + langs: Array, + operatingSystems: Array, + github: String, + gitlab: String, + bio: String, + }, + misc: { + t3TemporaryExpiration: { + date: Date, + processed: Boolean, + previousTier: Number, + }, + }, + x509: String, + pgp: String, +}); + +export default model('Member', Member); diff --git a/models/Merchant.ts b/models/Merchant.ts new file mode 100644 index 0000000..c78274a --- /dev/null +++ b/models/Merchant.ts @@ -0,0 +1,24 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface MerchantInterface extends Document { + name: string, + key: string, + privileged: boolean, + /** + * type + * - 0: soft + * - 1: hard + */ + type: 0 | 1; + pulls: [{ type: 0 | 1, reason: string, date: Date }], +} + +const Merchant: Schema = new Schema({ + name: String, + key: String, + privileged: Boolean, + type: Number, + pulls: Array, +}); + +export default model('Merchant', Merchant); diff --git a/models/Moderation.ts b/models/Moderation.ts new file mode 100644 index 0000000..e2adc56 --- /dev/null +++ b/models/Moderation.ts @@ -0,0 +1,37 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface ModerationInterface extends Document { + userID: string, + logID: string, + moderatorID: string, + reason: string, + /** + * @field 0 - Warn + * @field 1 - Unmute + * @field 2 - Mute + * @field 3 - Kick + * @field 4 - Unban + * @field 5 - Ban + */ + type: 0 | 1 | 2 | 3 | 4 | 5 + date: Date, + expiration?: { + date: Date, + processed: boolean + } +} + +const Moderation: Schema = new Schema({ + userID: String, + logID: String, + moderatorID: String, + reason: String, + type: Number, + date: Date, + expiration: { + date: Date, + processed: Boolean, + }, +}); + +export default model('Moderation', Moderation); diff --git a/models/Motion.ts b/models/Motion.ts new file mode 100644 index 0000000..e60685a --- /dev/null +++ b/models/Motion.ts @@ -0,0 +1,35 @@ +import { Document, model, Schema } from 'mongoose'; + +export interface MotionInterface extends Document { + issuer: string; + subject: string; + body: string; + at: number; + oID: string; + results?: { + yea: number; + nay: number; + present: number; + absent: number; + }; + processed: boolean; + msg: string; +} + +const Motion = new Schema({ + issuer: { type: String, required: true }, + subject: { type: String, required: true }, + body: { type: String, required: true }, + at: { type: Number, required: true }, + oID: { type: String, required: true, unique: true }, + results: { + yea: Number, + nay: Number, + present: Number, + absent: Number, + }, + processed: Boolean, + msg: { required: true, unique: true, type: String }, +}); + +export default model('Motions', Motion); diff --git a/models/Note.ts b/models/Note.ts new file mode 100644 index 0000000..2793b32 --- /dev/null +++ b/models/Note.ts @@ -0,0 +1,19 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface NoteInterface extends Document { + userID: string, + staffID: string, + date: Date, + category: 'comm' | 'cs' | 'edu' | '', + text: string, +} + +const Note: Schema = new Schema({ + userID: String, + staffID: String, + date: Date, + category: String, + text: String, +}); + +export default model('Note', Note); diff --git a/models/PagerNumber.ts b/models/PagerNumber.ts new file mode 100644 index 0000000..0d0cc16 --- /dev/null +++ b/models/PagerNumber.ts @@ -0,0 +1,32 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface PagerNumberRaw { + num: string, + // This field will be "" if the pager number doesn't belong to an individual user + individualAssignID: string, + emailAddresses: string[], + discordIDs: string[], + receiveEmail: boolean, + receivePhone: boolean, +} + +export interface PagerNumberInterface extends Document { + num: string, + // This field will be "" if the pager number doesn't belong to an individual user + individualAssignID: string, + emailAddresses: string[], + discordIDs: string[], + receiveEmail: boolean, + receivePhone: boolean, +} + +const PagerNumber: Schema = new Schema({ + num: String, + individualAssignID: String, + emailAddresses: Array, + discordIDs: Array, + receiveEmail: Boolean, + receivePhone: Boolean, +}); + +export default model('PagerNumber', PagerNumber); diff --git a/models/Proclamation.ts b/models/Proclamation.ts new file mode 100644 index 0000000..ab1f87d --- /dev/null +++ b/models/Proclamation.ts @@ -0,0 +1,37 @@ +import { Document, model, Schema } from 'mongoose'; + +export interface ProclamationInterface extends Document { + issuer: string; + subject: string; + body: string; + at: number; + oID: string; + results?: { + yea: number; + nay: number; + present: number; + absent: number; + }; + msg: string; + processed?: boolean; + votedDirectors: string[]; +} + +const Proclamation = new Schema({ + issuer: { type: String, required: true }, + subject: { type: String, required: true }, + body: { type: String, required: true }, + at: { type: Number, required: true }, + oID: { type: String, required: true, unique: true }, + results: { + yea: Number, + nay: Number, + present: Number, + absent: Number, + }, + msg: { type: String, required: true, unique: true }, + processed: Boolean, + votedDirectors: { type: Array, required: true }, +}); + +export default model('Proclamations', Proclamation); diff --git a/models/Promo.ts b/models/Promo.ts new file mode 100644 index 0000000..adbe2b0 --- /dev/null +++ b/models/Promo.ts @@ -0,0 +1,13 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface PromoInterface extends Document { + code: string, + pID: string, +} + +const Promo: Schema = new Schema({ + code: String, + pID: String, +}); + +export default model('Promo', Promo); diff --git a/models/Rank.ts b/models/Rank.ts new file mode 100644 index 0000000..ffdf443 --- /dev/null +++ b/models/Rank.ts @@ -0,0 +1,17 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface RankInterface extends Document { + name: string, + roleID: string, + permissions: string[], + description: string, +} + +const Rank: Schema = new Schema({ + name: String, + roleID: String, + permissions: Array, + description: String, +}); + +export default model('Rank', Rank); diff --git a/models/Redirect.ts b/models/Redirect.ts new file mode 100644 index 0000000..f17b77f --- /dev/null +++ b/models/Redirect.ts @@ -0,0 +1,21 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface RedirectInterface extends Document { + key: string, + to: string, + visitedCount: number, +} + +export interface RedirectRaw { + key: string, + to: string, + visitedCount: number, +} + +const Redirect: Schema = new Schema({ + key: String, + to: String, + visitedCount: Number, +}); + +export default model('Redirect', Redirect); diff --git a/models/Resolution.ts b/models/Resolution.ts new file mode 100644 index 0000000..b9f472c --- /dev/null +++ b/models/Resolution.ts @@ -0,0 +1,33 @@ +import { Document, model, Schema } from 'mongoose'; + +export interface ResolutionInterface extends Document { + issuer: string; + subject: string; + body: string; + at: number; + oID: string; + results: { + yea: number; + nay: number; + present: number; + absent: number; + }; + msg: string; +} + +const Resolution = new Schema({ + issuer: { type: String, required: true }, + subject: { type: String, required: true }, + body: { type: String, required: true }, + at: { type: Number, required: true }, + oID: { type: String, required: true, unique: true }, + results: { + yea: Number, + Nay: Number, + present: Number, + absent: Number, + }, + msg: { type: String, required: true, unique: true }, +}); + +export default model('Resolutions', Resolution); diff --git a/models/SAA.ts b/models/SAA.ts new file mode 100644 index 0000000..c489562 --- /dev/null +++ b/models/SAA.ts @@ -0,0 +1,17 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface SAAInterface extends Document { + userID: string, + applicationID: string, + serviceCode: string, + edsToken: string, +} + +const SAA: Schema = new Schema({ + userID: String, + applicationID: String, + serviceCode: String, + edsToken: String, +}); + +export default model('SAA', SAA); diff --git a/models/Score.ts b/models/Score.ts new file mode 100644 index 0000000..96820d2 --- /dev/null +++ b/models/Score.ts @@ -0,0 +1,95 @@ +// Community Score + +import { Document, Schema, model } from 'mongoose'; + +export interface Inquiry { + id?: string, + name: string, + reason: string, + date: Date, + report: ScoreInterfaceRaw, +} + +export interface ScoreInterfaceRaw { + userID: string + /** + * total will be between 800-200 - 0 signfies "No Score", too little information is available or other variable are too low + * - CALCULATION: `(COMBINED SUBSCORES x 5) * 5.13; Math.floor()` + */ + total: number, + /** + * 10 - 55 + */ + activity: number, + /** + * 0 - 54 + */ + roles: number, + /** + * -50 - 2 + * all users start out with 2 moderation points, the number of points decreases for each moderation. + */ + moderation: number, + /** + * -20 - 50 + * processed by CSD + */ + cloudServices: number, + // 0 or 20, 20 points are added if the user is a staff member + staff: number, + other: number, + notify: boolean, + locked: boolean, + inquiries: [ Inquiry ], + softInquiries: [{ name: string, date: Date }], + lastUpdate: Date, + pin: number[], +} + + +export interface ScoreInterface extends Document { + userID: string + total: number, + activity: number, + roles: number, + moderation: number, + cloudServices: number, + staff: number, + other: number, + notify: boolean, + locked: boolean, + inquiries: [ Inquiry ], + softInquiries: [{ name: string, date: Date }], + lastUpdate: Date, + pin: number[], + + // general & media + /* generalMessagesRatio: number, + // programming-support channels and cloud-support + supportMessagesRatio: number, + totalModerations: number, + notes: number, */ +} + +const Score: Schema = new Schema({ + userID: String, + total: Number, + activity: Number, + roles: Number, + moderation: Number, + cloudServices: Number, + staff: Number, + other: Number, + notify: Boolean, + locked: Boolean, + inquiries: Array, + softInquiries: Array, + lastUpdate: Date, + pin: Array, + /* generalMessagesRatio: Number, + supportMessagesRatio: Number, + totalModerations: Number, + notes: Number, */ +}); + +export default model('Score', Score); diff --git a/models/ScoreHistorical.ts b/models/ScoreHistorical.ts new file mode 100644 index 0000000..e768b3e --- /dev/null +++ b/models/ScoreHistorical.ts @@ -0,0 +1,42 @@ +import { Document, Schema, model, Types } from 'mongoose'; + +export interface ScoreHistoricalRaw { + userID: string, + report: { + total: number, + activity: number, + roles: number, + moderation: number, + cloudServices: number, + staff: number, + other: number, + }, + // inquiries: [ Types.ObjectId ], + inquiries: Types.ObjectId[], + date: Date, +} + +export interface ScoreHistoricalInterface extends Document { + userID: string, + report: { + total: number, + activity: number, + roles: number, + moderation: number, + cloudServices: number, + staff: number, + other: number, + }, + // inquiries: [ Types.ObjectId ], + inquiries: Types.ObjectId[], + date: Date +} + +const ScoreHistorical: Schema = new Schema({ + userID: String, + report: Object, + inquiries: Array, + date: Date, +}); + +export default model('ScoreHistorical', ScoreHistorical); diff --git a/models/Staff.ts b/models/Staff.ts new file mode 100644 index 0000000..83c8c2e --- /dev/null +++ b/models/Staff.ts @@ -0,0 +1,27 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface StaffInterface extends Document { + name: string, + userID: string, + title: string, + dept: string, + pn: string[], + emailAddress: string, + extension: string, + acknowledgements: string[], + additionalRoles: string[] +} + +const Staff: Schema = new Schema({ + name: String, + userID: String, + title: String, + dept: String, + pn: Array, + emailAddress: String, + extension: String, + acknowledgements: Array, + additionalRoles: Array, +}); + +export default model('Staff', Staff); diff --git a/models/Stat.ts b/models/Stat.ts new file mode 100644 index 0000000..7109699 --- /dev/null +++ b/models/Stat.ts @@ -0,0 +1,13 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface StatInterface extends Document { + name: 'messages' | 'commands' | 'pages' | 'requests', + value: number, +} + +const Stat: Schema = new Schema({ + name: String, + value: Number, +}); + +export default model('Stat', Stat);