cal/packages/types/App.d.ts
Joe Au-Yeung a9a295dc54
Admin apps UI (#5494)
* Abstract app category navigation

* Send key schema to frontend

Co-authored-by: Omar López <zomars@users.noreply.github.com>

* Render keys for apps on admin

* Add enabled col for apps

* Save app keys to DB

* Add checks for admin role

* Abstract setup components

* Add AdminAppsList to setup wizard

* Migrate to v10 tRPC

* Default hide keys

* Display enabled apps

* Merge branch 'main' into admin-apps-ui

* Toggle calendars

* WIP

* Add params and include AppCategoryNavigation

* Refactor getEnabledApps

* Add warning for disabling apps

* Fallback to cal video when a video app is disabled

* WIP send disabled email

* Send email to all users of  event types with payment app

* Disable Stripe when app is disabled

* Disable apps in event types

* Send email to users on disabled apps

* Send email based on what app was disabled

* WIP type fix

* Disable navigation to apps list if already setup

* UI import fixes

* Waits for session data before redirecting

* Updates admin seeded password

To comply with admin password requirements

* Update yarn.lock

* Flex fixes

* Adds admin middleware

* Clean up

* WIP

* WIP

* NTS

* Add dirName to app metadata

* Upsert app if not in db

* Upsert app if not in db

* Add dirName to app metadata

* Add keys to app packages w/ keys

* Merge with main

* Toggle show keys & on enable

* Fix empty keys

* Fix lark calendar metadata

* Fix some type errors

* Fix Lark metadata & check for category when upserting

* More type fixes

* Fix types & add keys to google cal

* WIP

* WIP

* WIP

* More type fixes

* Fix type errors

* Fix type errors

* More type fixes

* More type fixes

* More type fixes

* Feedback

* Fixes default value

* Feedback

* Migrate credential invalid col default value "false"

* Upsert app on saving keys

* Clean up

* Validate app keys on frontend

* Add nonempty to app keys schemas

* Add web3

* Listlocale filter on categories / category

* Grab app metadata via category or categories

* Show empty screen if no apps are enabled

* Fix type checks

* Fix type checks

* Fix type checks

* Fix type checks

* Fix type checks

* Fix type checks

* Replace .nonempty() w/ .min(1)

* Fix type error

* Address feedback

* Added migration to keep current apps enabled

* Update apps.tsx

* Fix bug

* Add keys schema to Plausible app

* Add appKeysSchema to zod.ts template

* Update AdminAppsList.tsx

Co-authored-by: Omar López <zomars@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
2022-12-07 14:47:02 -07:00

142 lines
4.2 KiB
TypeScript

import type { Prisma } from "@prisma/client";
import { Optional } from "./utils";
type CommonProperties = {
default?: false;
type: string;
label: string;
messageForOrganizer?: string;
iconUrl?: string;
variable?: "locationLink";
defaultValueVariable?: "link";
attendeeInputType?: null;
attendeeInputPlaceholder?: null;
};
type StaticLinkBasedEventLocation = {
linkType: "static";
urlRegExp: string;
organizerInputPlaceholder?: string;
organizerInputType?: "text" | "phone";
} & CommonProperties;
type DynamicLinkBasedEventLocation = {
linkType: "dynamic";
urlRegExp?: null;
organizerInputType?: null;
organizerInputPlaceholder?: null;
} & CommonProperties;
export type EventLocationTypeFromAppMeta = StaticLinkBasedEventLocation | DynamicLinkBasedEventLocation;
type EventLocationAppData = {
location: EventLocationTypeFromAppMeta;
};
/**
* This is the definition for an app store's app metadata.
* This is used to display App info, categorize or hide certain apps in the app store.
*/
export interface App {
/**
* @deprecated
* Wheter if the app is installed or not. Usually we check for api keys in env
* variables to determine if this is true or not.
* */
installed?: boolean;
/** The app type */
type:
| `${string}_calendar`
| `${string}_messaging`
| `${string}_payment`
| `${string}_video`
| `${string}_web3`
| `${string}_other`
| `${string}_automation`
| `${string}_analytics`
| `${string}_other_calendar`;
/**
* @deprecated
*
* Use name instead. Remove this property after ensuring name has the required value everywhere
* */
title?: string;
/** The display name for the app */
name: string;
/** A brief description, usually found in the app's package.json */
description: string;
/**
* @deprecated logo is used instead
* The icon to display in /apps/installed
*/
imageSrc?: string;
/** TODO determine if we should use this instead of category */
variant:
| "calendar"
| "payment"
| "conferencing"
| "video"
| "other"
| "other_calendar"
| "web3"
| "automation";
/** The slug for the app store public page inside `/apps/[slug] */
slug: string;
/** The category to which this app belongs, currently we have `calendar`, `payment` or `video` */
/*
* @deprecated Use categories
*/
category: string;
/** The category to which this app belongs, currently we have `calendar`, `payment` or `video` */
categories?: string[];
/**
* `User` is the broadest category. `EventType` is when you want to add features to EventTypes.
* See https://app.gitbook.com/o/6snd8PyPYMhg0wUw6CeQ/s/VXRprBTuMlihk37NQgUU/~/changes/6xkqZ4qvJ3Xh9k8UaWaZ/engineering/product-specs/app-store#user-apps for more details
*/
extendsFeature?: "EventType" | "User";
/** An absolute url to the app logo */
logo: string;
/** Company or individual publishing this app */
publisher: string;
/** App's website */
url: string;
/** Optional documentation website URL */
docsUrl?: string;
/** Wether if the app is verified by Cal.com or not */
verified: boolean;
/** Wether the app should appear in the trending section of the app store */
trending: boolean;
/** Rating from 0 to 5, harcoded for now. Should be fetched later on. */
rating: number;
/** Number of reviews, harcoded for now. Should be fetched later on. */
reviews: number;
/**
* Wheter if the app is installed globally or needs user intervention.
* Used to show Connect/Disconnect buttons in App Store
* */
isGlobal?: boolean;
/** A contact email, mainly to ask for support */
email: string;
/** Needed API Keys (usually for global apps) */
key?: Prisma.JsonValue;
/** Needed API Keys (usually for global apps) */
key?: Prisma.JsonValue;
/** If not free, what kind of fees does the app have */
feeType?: "monthly" | "usage-based" | "one-time" | "free";
/** 0 = free. if type="usage-based" it's the price per booking */
price?: number;
/** only required for "usage-based" billing. % of commission for paid bookings */
commission?: number;
licenseRequired?: boolean;
isProOnly?: boolean;
appData?: EventLocationAppData;
dirName?: string;
}
export type AppMeta = Optional<App, "rating" | "trending" | "reviews" | "verified">;