oneuptime/Common/Models/SmsProvider.ts

54 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-04-26 20:24:24 +00:00
import mongoose, {
RequiredFields,
UniqueFields,
EncryptedFields,
Schema,
} from '../Infrastructure/ORM';
const schema: Schema = new Schema({
project: { type: String, ref: 'Project', index: true }, //Which project does this belong to.
enabled: { type: Boolean, default: false },
iv: Schema.Types.Buffer,
createdAt: {
type: Date,
default: Date.now,
},
deleted: { type: Boolean, default: false },
deletedAt: {
type: Date,
},
provider: {
type: String,
enum: ['twilio'],
required: true,
},
providerCredentials: {
twilio: {
accountSid: String,
authToken: String,
phoneNumber: String,
},
},
deletedByUser: { type: String, ref: 'User', index: true },
});
export const requiredFields: RequiredFields = schema.requiredPaths();
export const uniqueFields: UniqueFields = [];
export const encryptedFields: EncryptedFields = [
'providerCredentials.twilio.accountSid',
'providerCredentials.twilio.authToken',
];
export const slugifyField: string = '';
export default mongoose.model('SmsProvider', schema);