import { MarkedServiceFactoryConstructor, ServiceConstructor } from "../Service"; import { ObservableBox } from "./ObservableBox"; /** * Application metadata. * Typically generated by the build system. */ export interface ApplicationMetadata { /** * Package metadata. * Metadata structures contain information about services * that are needed during runtime. * * Services provided by packages in this attribute will be started * as necessary and can be referenced during runtime. */ packages?: Record; /** * Styles for UI component. */ styles?: ObservableBox; /** * Locales supported by the application. */ locales?: string[]; /** * Loads messages for the given locale. * * >NOTE: Previously (before runtime metadata version 1.1.0), this was a plain function; * >then a plain function in a box (the function is replaced to indicate a reload event for i18n messages). * * @returns A record of packageName -> (messageId, messageTemplate) entries. */ loadMessages?: MessageLoader | ObservableBox; } export type MessageLoader = (locale: string) => Promise; /** Package name -> Message ID -> Message text (FormatJS Syntax) */ export type MessagesRecord = Record>; /** * Describes a package to the runtime. */ export interface PackageMetadata { /** The globally unique name of the package. */ name: string; /** * Collection of services defined in the package. * * Key: unique service name within the package. * Value: service metadata. */ services?: Record; /** * Metadata about the UI Components contained in this package. */ ui?: UiMetadata; /** * Metadata about properties of this package. */ properties?: Record; } /** * Describes a service to the runtime. */ export interface ServiceMetadata { /** The unique name of the service in its package. */ name: string; /** Service constructor responsible for creating a new instance. */ clazz: ServiceConstructor | MarkedServiceFactoryConstructor; /** * Collection of references to other services. * The runtime will inject the required services when possible * or provide a diagnostic if not. * * Key: reference name. * Value: reference metadata. */ references?: Record; /** * Lists interfaces provided by this service. */ provides?: ProvidedInterfaceMetadata[]; } /** * Describes a service reference to the runtime. */ export interface InterfaceReferenceMetadata { /** The name of the referenced interface. */ name: string; /** Additional qualifier to disambiguate interface requirements. */ qualifier?: string | undefined; /** Inject all implementations as an array instead of a specific one. */ all?: boolean; } /** * Describes a provided interface to the runtime. */ export interface ProvidedInterfaceMetadata { /** The name of the provided interface. */ name: string; /** Additional qualifier for disambiguation of multiple interface implementations. */ qualifier?: string | undefined; } /** * Describes the UI to the runtime. */ export interface UiMetadata { /** * List of interface names required by the UI. * Interfaces in this list can be used by calling the `useService` hook * from a react component. */ references?: InterfaceReferenceMetadata[]; } /** * Metadata about a single property in a package. */ export interface PropertyMetadata { /** Default json value defined by the package. */ value: unknown; /** Whether the property must be specified by the application. */ required?: boolean; } export { type ObservableBox, createBox } from "./ObservableBox";