import Name, { NameTypes } from "./resources/name"; import Pronunciation, { RelativeSource, SourceType } from "./resources/pronunciation"; import { NameOwner, User, UserResponse, PermissionsManager, ClientPreferences } from "gpdb-api-client"; import NameParser from "./name-parser"; import { loadParams as permissionsLoadParams } from "gpdb-api-client/build/main/types/repositories/permissions"; import { loadParams as preferencesLoadParams } from "gpdb-api-client/build/main/types/repositories/client-side-preferences"; import { CustomAttributeObject } from "../types/resources/custom-attribute"; export interface Meta { uri?: string; } export interface PublicAttributes { nameOwnerContext: NameOwner; userContext: User; nameParser: NameParser; } export interface PublicHelpers { isUserOwnsName: (nameOwnerSignature?: string) => boolean; } export interface GpdbRequests { permissions: PermissionsManager; customAttributes: CustomAttributeObject[]; preferences: ClientPreferences; complexSearch: (names: Array>, nameOwner?: NameOwner, meta?: Meta) => Promise<{ [t in NameTypes]: Pronunciation[]; }>; simpleSearch: (name: Omit, nameOwner?: NameOwner, meta?: Meta) => Promise; searchBySig: (nameOwner?: NameOwner) => Promise<[Array>, { [t in NameTypes]: Pronunciation[]; }]>; destroy: (id: string, sourceType?: SourceType, relativeSource?: RelativeSource) => Promise; restore: (id: string) => Promise; createUserResponse: (id: string, type: UserResponse, nameOwner?: NameOwner) => Promise; createRecording: (name: string, type: NameTypes, audio: string, owner?: NameOwner) => Promise; requestRecording: (name: string, type: NameTypes, nameOwner?: NameOwner) => Promise; findRecordingRequest: (name: string, type: NameTypes, nameOwner?: NameOwner) => Promise; loadPermissions: (rest?: permissionsLoadParams) => Promise; loadCustomAttributesConfig: () => Promise; loadClientPreferences: (rest?: preferencesLoadParams) => Promise; } export interface CustomAttributesRequests { saveCustomAttributes: (customAttributesValues: { [x: string]: any; }, nameOwner?: NameOwner) => Promise<{ [x: string]: any; }>; } export interface NamesServiceRequests { verifyNames: (name: string) => Promise<{ [t in NameTypes]: Name; }>; getSuggestions: (name: string) => Promise; } export interface AnalyticsRequests { sendAnalytics: (eventType: string, message: string | object | boolean, recordingId?: string, rootUrl?: string) => Promise; } export interface SettingsRequests { saveAudioSampleRate: (rate: number) => Promise; loadAudioSampleRate: () => Promise; } interface PreferredRecordings { firstNamePronunciation: Pronunciation | null; lastNamePronunciation: Pronunciation | null; } export interface PreferredRecordingsRequests { getPreferredRecordings: (args: { ownerContext: User; userContext?: User; }) => Promise; savePreferredRecordings: (args: PreferredRecordings) => Promise; deletePreferredRecordings: (args: PreferredRecordings) => Promise; } export interface Avatars { getAvatar: (owner?: User) => Promise; saveAvatar: (image: string, owner?: User) => Promise; deleteAvatar: () => Promise; } declare type IFrontController = PublicAttributes & PublicHelpers & GpdbRequests & CustomAttributesRequests & NamesServiceRequests & AnalyticsRequests & Partial & PreferredRecordingsRequests & Avatars; export default IFrontController;