import Router from "@koa/router"; import type { default as Koa } from "koa"; import Emittery from "emittery"; import type Collection from "../chip-types/collection.js"; import Context, { SuperContext } from "../context.js"; import MongoDatastore from "../datastore/datastore.js"; import type Mailer from "../email/mailer.js"; import type LongRunningProcessEvents from "./collections/long-running-process-events.js"; import type LongRunningProcesses from "./collections/long-running-processes.js"; import type Sessions from "./collections/sessions.js"; import type Users from "./collections/users.js"; import ConfigManager from "./config-manager.js"; import type { PartialConfig } from "./config.js"; import Logger from "./logger.js"; import { type ManifestData } from "./manifest.js"; import type Metadata from "./metadata.js"; import { FileManager } from "@sealcode/file-manager"; import type { KoaResponsiveImageRouter } from "koa-responsive-image-router"; export type AppEvents = "starting" | "started" | "stopping" | "stopped"; export type Translation = string | ((...params: any[]) => string); /** The heart of your, well app. It all starts with `new App(...)` */ export declare abstract class App { /** The current status of the app */ status: "stopped" | "running" | "starting" | "stopping"; private emitter; fileManager: FileManager; imageRouter: KoaResponsiveImageRouter; /** The base collections including users, registration intents, etc */ static BaseCollections: { users: Users; sessions: Sessions; long_running_processes: LongRunningProcesses; long_running_process_events: LongRunningProcessEvents; }; /** The manifest assigned to this app. Stores things like the app name, domain, logo*/ abstract manifest: ManifestData; /** ConfigManager instance. It serves the config based on default * values and the config object provided to the app constructor */ ConfigManager: ConfigManager; /** The {@link Logger} instance assigned to this application */ Logger: Logger; /** The mongoDB client connected to the database specified in the app config */ Datastore: MongoDatastore; /** The Metadata manager assigned to this app. Used to store * certain state information that's not meant to be shown to the * user * * @internal */ Metadata: Metadata; /** The collections defined within the given app. */ abstract collections: { users: Users; sessions: Sessions; long_running_processes: LongRunningProcesses; long_running_process_events: LongRunningProcessEvents; [name: string]: Collection; }; /** A shorthand-way to create a new SuperContext: `new app.SuperContext()`. */ SuperContext: new (params?: Omit>[0], "app">) => SuperContext; /** A shorthand-way to create a new context: `new app.Context()`. */ Context: new (params?: Omit>[0], "app">) => Context; abstract config: PartialConfig; mailer: Mailer; translations: Record string) | undefined>>; constructor({ fileManager, imageRouter, }: { fileManager: FileManager; imageRouter: KoaResponsiveImageRouter; }); /** Initializes all the collection fields, prepares all the hooks, * connects to the database and starts the app, serving the REST * API */ start(): Promise; /** Stops the HTTP server, disconnects from the DB */ stop(): Promise; /** Removes all data inside the app. USE WITH CAUTION * @internal */ removeAllData(): Promise; /** Allows to listen for basic app status change events */ on(event_name: AppEvents, callback: () => Promise | void): Emittery.UnsubscribeFn; emit(event_name: string, data?: unknown): Promise; /** registers a collection within the app * @internal */ registerCollection(collection: Collection): void; initRouter(router: Router): void; getFeedHTMLMetatags(ctx: Koa.Context): Promise; cartesianProduct(arrays: T[][]): T[][]; addTranslations(new_translations_per_language: Record string) | undefined>>): void; }