import type { ApiBase, RedirectStatusCode, } from '@nordcraft/core/dist/api/apiTypes' import type { Component, RouteDeclaration, } from '@nordcraft/core/dist/component/component.types' import type { Formula } from '@nordcraft/core/dist/formula/formula' import type { PluginFormula } from '@nordcraft/core/dist/formula/formulaTypes' import type { OldTheme, Theme } from '@nordcraft/core/dist/styling/theme' import type { PluginAction } from '@nordcraft/core/dist/types' 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 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?: Partial> actions?: Record formulas?: Record> routes?: Record config?: { // See https://github.com/nordcraftengine/nordcraft/releases runtimeVersion?: string 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 DatoCmsApiService extends BaseApiService { type: 'datocms' } interface UmbracoApiService extends BaseApiService { type: 'umbraco' } interface ContentfulApiService extends BaseApiService { type: 'contentful' } interface CustomApiService extends BaseApiService { type: 'custom' } export type ApiService = | ContentfulApiService | CustomApiService | DatoCmsApiService | SupabaseApiService | UmbracoApiService | XanoApiService 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 } } interface BaseRoute { source: RouteDeclaration destination: ApiBase enabled?: { formula: Formula } } export interface RewriteRoute extends BaseRoute { type: 'rewrite' } export interface RedirectRoute extends BaseRoute { type: 'redirect' status?: RedirectStatusCode } export type Route = RewriteRoute | RedirectRoute