import type { ComponentManifest } from "./ComponentManifest"; import type { IconManifest } from "./IconManifest"; import type { LanguageManifest } from "./LanguageManifest"; import type { CommandConfig } from "./MessagesConfig"; import type { ModelManifest } from "./ModelManifest"; import type { ServiceManifest } from "./ServiceManifest"; import type { ToolManifest } from "./ToolManifest"; import type { UpgradeInfo } from "./UpgradeInfo"; /** * Allows a library to register various items that it provides, such as * components, services, language data, etc. */ export interface LibraryRegistry { /** * Returns true if there is a registered component of the specified name and * namespace. */ hasComponent(namespace: string, name: string): boolean; /** * Returns true if there is a registered model of the specified itemType. */ hasModel(itemType: string): boolean; /** * Returns true if there is a registered service with the specified * serviceId. */ hasService(serviceId: string): boolean; /** * Returns true if there is a registered icon with the specified iconId. */ hasIcon(iconId: string): boolean; /** * Returns true if there is a registered command with the specified name. */ hasCommand(name: string): boolean; /** * Returns true if there is a registered operation with the specified name. */ hasOperation(name: string): boolean; /** * Registers a component, which will be available to use in layouts. */ registerComponent(manifest: ComponentManifest): void; /** * Registers a model type. Models represent the state and behavior of * components and services. They are initialized from/saved to app config. */ registerModel(manifest: ModelManifest): void; /** * Registers a service. Services provide functionality to components and * other services. They can be used directly (via dependency injection), or * indirectly via the message bus (by implementing commands and * operations). */ registerService(manifest: ServiceManifest): void; /** * Registers a tool. Tools are an abstraction of command chains that allow * for simpler configuration of complicated actions. Tools are only * configured and used by Designer. */ registerTool(manifest: ToolManifest): void; /** * Registers localized language resources. This data will be used by the * `translate()` method on the `RegionService` and `UIContext`. */ registerLanguageResources(manifest: LanguageManifest): void; /** * Registers an image. Components and models can then reference the image by * ID. */ registerIcon(manifest: IconManifest): void; /** * Registers a command implementation. * * @param command The command configuration, indicating an implementing * service or model (specified by `serviceId` or `itemType`, * respectively). The service/model will need a callback function marked * with the `@command` decorator. Note that there can be more than one * implementation of a command. Implementations that are registered later * are invoked EARLIER, so that they can potentially hook or override * previously registered ones (see the `CommandContext` API for more * details). This is the OPPOSITE order from operations. */ registerCommand(command: CommandConfig): void; /** * Registers an operation implementation. * * @param operation The operation configuration, indicating an implementing * service or model (specified by `serviceId` or `itemType`, * respectively). The service/model will need a callback function marked * with the `@operation` decorator. Note that there can be more than one * implementation of an operation. Implementations that are registered * later are invoked LATER, so that they can potentially hook or override * the return value of previously registered ones (see the * `OperationContext` API for more details). This is the OPPOSITE order * from commands. */ registerOperation(operation: CommandConfig): void; /** * Overrides one or more configuration properties for a component registered * by another library. */ overrideComponent(manifest: Partial & Pick): void; /** * Overrides one or more configuration properties for a model registered by * another library. */ overrideModel(manifest: Partial & Pick): void; /** * Overrides one or more configuration properties for a service registered * by another library. */ overrideService(manifest: Partial & Pick): void; /** * Registers upgrade logic for app items that can manipulate the JSON config * before it is passed to the item's factory for construction. */ registerUpgrade(upgradeInfo: UpgradeInfo): void; }