import {CSSResult, CSSResultArray} from "lit-element" export * from "../types.js" import { User, Question, CardClues, MetalUser, AuthTokens, AccessToken, MetalGenerics, MetalSettings, ScheduleEvent, QuestionDraft, TokenStoreTopic, UserUmbrellaTopic, ScheduleSentryTopic, QuestionQuarryTopic, LiveshowLizardTopic, SettingsSheriffTopic, PremiumPachydermTopic, } from "../types.js" import {AuthModel} from "./models/auth-model.js" import {PaywallModel} from "./models/paywall-model.js" import {PersonalModel} from "./models/personal-model.js" import {ScheduleModel} from "./models/schedule-model.js" import {QuestionsModel} from "./models/questions-model.js" import {LiveshowViewModel, LiveshowModel} from "./models/liveshow-model.js" import * as loading from "./toolbox/loading.js" import {Logger} from "../toolbox/logger/interfaces.js" //////////////////////// export interface Personal { user: MetalUser settings: MetalSettings } export interface MetalConfig { ["core-server"]: string ["liveshow-server"]: string ["paywall-server"]: string ["questions-server"]: string ["schedule-server"]: string ["settings-server"]: string } export type CSS = CSSResult | CSSResultArray export type ConstructorFor = new(...args: any[]) => T export interface MetalOptions { logger: Logger tokenStore: TokenStoreTopic liveshowLizard: LiveshowLizardTopic scheduleSentry: ScheduleSentryTopic questionQuarry: QuestionQuarryTopic premiumPachyderm: PremiumPachydermTopic userUmbrella: UserUmbrellaTopic settingsSheriff: SettingsSheriffTopic //— checkoutPopupUrl: string decodeAccessToken: DecodeAccessToken triggerAccountPopup: TriggerAccountPopup triggerCheckoutPopup: TriggerCheckoutPopup } export interface AuthContext { user: U exp: number accessToken: AccessToken } export type GetAuthContext = () => Promise> export type DecodeAccessToken = (accessToken: AccessToken) => AuthContext export type TriggerAccountPopup = () => Promise export type TriggerCheckoutPopup = (o: {stripeSessionId: string}) => Promise export interface LoginWithAccessToken { (accessToken: AccessToken): Promise } export interface AuthPayload { user: U getAuthContext: GetAuthContext } export interface PremiumInfo { cardClues: CardClues } export interface QuestionValidation { angry: boolean message: string postable: boolean } export interface QuestionQuarryUi { fetchQuestions(o: { board: string }): Promise postQuestion(o: { draft: QuestionDraft }): Promise archiveQuestion(o: { questionId: string }): Promise likeQuestion(o: { like: boolean questionId: string }): Promise archiveBoard(o: { board: string }): Promise } export interface MockQuestion { tagline: string content: string likes: number ban?: { days: number reason: string } } export interface VideoPayload { vimeoId: string } export type PrepareHandleLikeClick = (o: { like: boolean questionId: string }) => (event: MouseEvent) => void // // supermodel // export interface Supermodel { auth: AuthModel paywall: PaywallModel personal: PersonalModel liveshow: LiveshowModel schedule: ScheduleModel questions: QuestionsModel // seeker: SeekerModel } export enum ProfileMode { Error, Loading, Loaded, None, } export enum BillingPremiumSubscription { Unsubscribed, Subscribed, } export enum PremiumStatus { NotPremium, Premium, } export enum PrivilegeLevel { Unknown, Unprivileged, Privileged, } // // component shares // export interface SettingsPremiumSubscription { card: CardClues } export interface AccountShare { login: () => Promise logout: () => Promise authLoad: loading.Load> } export interface MyAvatarShare { personalLoad: loading.Load } export interface ButtonPremiumShare { personalLoad: loading.Load premium: boolean premiumUntil: number premiumInfoLoad: loading.Load login(): Promise checkoutPremium(): Promise } export interface AdminModeShare { personalLoad: loading.Load setAdminMode(adminMode: boolean): Promise } export interface AdminOnlyShare { personalLoad: loading.Load } export interface PersonalShare { personal: Personal personalLoad: loading.Load saveProfile(profile: Personal["user"]["profile"]): Promise setAdminMode(adminMode: boolean): Promise // setAvatarPublicity(avatarPublicity: boolean): Promise } export interface PaywallShare { personalLoad: loading.Load premium: boolean premiumUntil: number premiumInfoLoad: loading.Load checkoutPremium(): Promise updatePremium(): Promise cancelPremium(): Promise } export interface QuestionsShare { user: MetalUser uiBureau: QuestionQuarryUi fetchCachedQuestions(board: string): Question[] } export interface CountdownShare { events: ScheduleEvent[] authLoad: loading.Load> loadEvent: (label: string) => Promise saveEvent: (event: ScheduleEvent) => Promise } export interface LiveshowShare { authLoad: loading.Load> makeViewModel(options: {label: string}): { dispose: () => void viewModel: LiveshowViewModel } } // export interface SeekerShare { // resultsLoad: loading.Load // query: (needle: string) => Promise // }