add original models

merge-requests/1/head
eirk 2021-12-25 13:37:42 -05:00
parent 2b12bf506f
commit 62fc289088
21 changed files with 614 additions and 0 deletions

13
models/Customer.ts Normal file
View File

@ -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<CustomerInterface>('Customer', Customer);

21
models/CustomerPortal.ts Normal file
View File

@ -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<CustomerPortalInterface>('CustomerPortal', CustomerPortal);

21
models/ExecutiveOrder.ts Normal file
View File

@ -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<ExecutiveOrderInterface>('ExecutiveOrders', ExecutiveOrder);

21
models/File.ts Normal file
View File

@ -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<FileInterface>('File', File);

33
models/Inquiry.ts Normal file
View File

@ -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<InquiryInterface>('Inquiry', Inquiry);

43
models/Member.ts Normal file
View File

@ -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<MemberInterface>('Member', Member);

24
models/Merchant.ts Normal file
View File

@ -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<MerchantInterface>('Merchant', Merchant);

37
models/Moderation.ts Normal file
View File

@ -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<ModerationInterface>('Moderation', Moderation);

35
models/Motion.ts Normal file
View File

@ -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<MotionInterface>('Motions', Motion);

19
models/Note.ts Normal file
View File

@ -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<NoteInterface>('Note', Note);

32
models/PagerNumber.ts Normal file
View File

@ -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<PagerNumberInterface>('PagerNumber', PagerNumber);

37
models/Proclamation.ts Normal file
View File

@ -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<ProclamationInterface>('Proclamations', Proclamation);

13
models/Promo.ts Normal file
View File

@ -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<PromoInterface>('Promo', Promo);

17
models/Rank.ts Normal file
View File

@ -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<RankInterface>('Rank', Rank);

21
models/Redirect.ts Normal file
View File

@ -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<RedirectInterface>('Redirect', Redirect);

33
models/Resolution.ts Normal file
View File

@ -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<ResolutionInterface>('Resolutions', Resolution);

17
models/SAA.ts Normal file
View File

@ -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<SAAInterface>('SAA', SAA);

95
models/Score.ts Normal file
View File

@ -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<ScoreInterface>('Score', Score);

42
models/ScoreHistorical.ts Normal file
View File

@ -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<ScoreHistoricalInterface>('ScoreHistorical', ScoreHistorical);

27
models/Staff.ts Normal file
View File

@ -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<StaffInterface>('Staff', Staff);

13
models/Stat.ts Normal file
View File

@ -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<StatInterface>('Stat', Stat);