import type { ApiBase, RedirectStatusCode, } from '@toddledev/core/dist/api/apiTypes' import type { Component, RouteDeclaration, } from '@toddledev/core/dist/component/component.types' import type { Formula } from '@toddledev/core/dist/formula/formula' import type { PluginFormula } from '@toddledev/core/dist/formula/formulaTypes' import type { OldTheme, Theme } from '@toddledev/core/dist/styling/theme' export type FileGetter = (args: { package?: string name: string type: keyof ProjectFiles }) => Promise< Component | PluginAction | PluginFormula | Route | Theme | ApiService > export interface ToddleProject { name: string description?: string | null short_id: string id: string emoji?: string | null type: 'app' | 'package' thumbnail?: { path: string } | null } export interface ProjectFiles { // Partial to make sure we check for the existence of a Component components: Partial> packages?: Record actions?: Record formulas?: Record> routes?: Record config?: { theme: OldTheme meta?: { icon?: { formula: Formula } robots?: { formula: Formula } sitemap?: { formula: Formula } manifest?: { formula: Formula } serviceWorker?: { formula: Formula } } } themes?: Record services?: Record } interface BaseApiService { name: string // Should we deprecate this? baseUrl?: Formula docsUrl?: Formula apiKey?: Formula meta?: Record } interface SupabaseApiService extends BaseApiService { type: 'supabase' meta?: { projectUrl?: Formula } } interface XanoApiService extends BaseApiService { type: 'xano' } interface CustomApiService extends BaseApiService { type: 'custom' } export type ApiService = SupabaseApiService | XanoApiService | CustomApiService export type InstalledPackage = Pick< ProjectFiles, // we might want to add themes + config later 'components' | 'actions' | 'formulas' > & { manifest: { name: string // commit represents the commit hash (version) of the package commit: string } } export interface PluginAction { name: string description?: string version?: 2 | never arguments: Array<{ name: string formula: Formula }> variableArguments: boolean | null handler: string // exported indicates that an action is exported in a package exported?: boolean } interface BaseRoute { source: RouteDeclaration destination: ApiBase } export interface RewriteRoute extends BaseRoute { type: 'rewrite' } export interface RedirectRoute extends BaseRoute { type: 'redirect' status?: RedirectStatusCode } export type Route = RewriteRoute | RedirectRoute