Add all repos
This commit is contained in:
parent
faa12c60bc
commit
8a91c9b89b
369 changed files with 29047 additions and 28 deletions
52
metamigo-db/records/voice/voice-provider.ts
Normal file
52
metamigo-db/records/voice/voice-provider.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { RepositoryBase, recordInfo, UUID, Flavor } from "common";
|
||||
|
||||
/*
|
||||
* VoiceProvider
|
||||
*
|
||||
* A provider is a company that provides incoming voice call services
|
||||
*/
|
||||
|
||||
export type VoiceProviderId = Flavor<UUID, "VoiceProvider Id">;
|
||||
|
||||
export enum VoiceProviderKinds {
|
||||
TWILIO = "TWILIO",
|
||||
}
|
||||
|
||||
export type TwilioCredentials = {
|
||||
accountSid: string;
|
||||
apiKeySid: string;
|
||||
apiKeySecret: string;
|
||||
};
|
||||
|
||||
// expand this type later when we support more providers
|
||||
export type VoiceProviderCredentials = TwilioCredentials;
|
||||
|
||||
export interface UnsavedVoiceProvider {
|
||||
kind: VoiceProviderKinds;
|
||||
name: string;
|
||||
credentials: VoiceProviderCredentials;
|
||||
}
|
||||
|
||||
export interface SavedVoiceProvider extends UnsavedVoiceProvider {
|
||||
id: VoiceProviderId;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export const VoiceProviderRecord = recordInfo<
|
||||
UnsavedVoiceProvider,
|
||||
SavedVoiceProvider
|
||||
>("app_public", "voice_providers");
|
||||
|
||||
export class VoiceProviderRecordRepository extends RepositoryBase(
|
||||
VoiceProviderRecord
|
||||
) {
|
||||
async findByTwilioAccountSid(
|
||||
accountSid: string
|
||||
): Promise<SavedVoiceProvider | null> {
|
||||
return this.db.oneOrNone(
|
||||
"select * from $1 where credentials->>'accountSid' = $2",
|
||||
[this.schemaTable, accountSid]
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue